• Home
  • Raw
  • Download

Lines Matching refs:ts

16 import ts from 'typescript';
130 export let contextGlobal: ts.TransformationContext;
137 export function processUISyntax(program: ts.Program, ut = false): Function {
138 let entryNodeKey: ts.Expression;
139 return (context: ts.TransformationContext) => {
142 return (node: ts.SourceFile) => {
143 const hasTsNoCheckOrTsIgnore = ts.hasTsNoCheckOrTsIgnoreFlag(node);
157 node = ts.visitEachChild(node, processResourceNode, context);
160 … const processedNode: ts.SourceFile = ts.getTypeExportImportAndConstEnumTransformer(context)(node);
172 node = ts.visitEachChild(node, processAllNodes, context);
178 const statements: ts.Statement[] = Array.from(node.statements);
185 node = ts.factory.updateSourceFile(node, statements);
188 … const processedNode: ts.SourceFile = ts.getTypeExportImportAndConstEnumTransformer(context)(node);
202 function entryKeyNode(node: ts.Node): ts.Expression {
205 …if (item.expression && ts.isCallExpression(item.expression) && ts.isIdentifier(item.expression.exp…
207 item.expression.arguments.length && ts.isIdentifier(item.expression.arguments[0])) {
215 function isESObjectNode(node: ts.Node): boolean {
216 if (node.kind === ts.SyntaxKind.TypeReference) {
218 …if (n.typeName?.kind === ts.SyntaxKind.Identifier && (n.typeName as ts.Identifier).escapedText ===…
225 function processAllNodes(node: ts.Node): ts.Node {
227 ts.isImportDeclaration(node)) {
230 (ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node) ||
231ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)))…
234 if (ts.isStructDeclaration(node)) {
243 } else if (ts.isFunctionDeclaration(node)) {
247 ts.isBlock(node.body)) {
250 let parameters: ts.NodeArray<ts.ParameterDeclaration> =
251 ts.factory.createNodeArray(Array.from(node.parameters));
253 node = ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers,
276 node = processResourceData(node as ts.CallExpression);
278 node = processWorker(node as ts.NewExpression);
280 node = processAnimateTo(node as ts.CallExpression);
284 node = ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
286 return ts.visitEachChild(node, processAllNodes, context);
288 function processResourceNode(node: ts.Node): ts.Node {
290 node = processResourceData(node as ts.CallExpression);
292 return ts.visitEachChild(node, processResourceNode, context);
297 function generateId(statements: ts.Statement[], node: ts.SourceFile): void {
299 ts.factory.createVariableStatement(
301 ts.factory.createVariableDeclarationList(
302 [ts.factory.createVariableDeclaration(
303 ts.factory.createIdentifier(_GENERATE_ID),
305 ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
306 ts.factory.createNumericLiteral('0')
308 ts.NodeFlags.Let
311 ts.factory.createFunctionDeclaration(
315 ts.factory.createIdentifier(GENERATE_ID),
318 ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
319 ts.factory.createBlock(
320 [ts.factory.createReturnStatement(ts.factory.createBinaryExpression(
321 ts.factory.createStringLiteral(path.basename(node.fileName, EXTNAME_ETS) + '_'),
322 ts.factory.createToken(ts.SyntaxKind.PlusToken), ts.factory.createPrefixUnaryExpression(
323 ts.SyntaxKind.PlusPlusToken,
324 ts.factory.createIdentifier(_GENERATE_ID)
340 function isCustomDialogController(node: ts.Expression) {
341 const tempParent: ts.Node = node.parent;
347 if (ts.isNewExpression(node) && node.expression && ts.isIdentifier(node.expression) &&
357 function createCustomDialogController(parent: ts.Expression, node: ts.NewExpression,
358 log: LogInfo[]): ts.NewExpression {
360 ts.isObjectLiteralExpression(node.arguments[0]) && node.arguments[0].properties) {
361 … const newproperties: ts.ObjectLiteralElementLike[] = node.arguments[0].properties.map((item) => {
365 item as ts.PropertyAssignment, componentName);
369 return ts.factory.createNewExpression(node.expression, node.typeArguments,
370 [ts.factory.createObjectLiteralExpression(newproperties, true), ts.factory.createThis()]);
376 function isCustomDialogControllerPropertyAssignment(node: ts.ObjectLiteralElementLike,
378 if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
392 function validateCustomDialogControllerBuilderInit(node: ts.ObjectLiteralElementLike,
401 function processCustomDialogControllerPropertyAssignment(parent: ts.Expression,
402 node: ts.PropertyAssignment, componentName: string): ts.PropertyAssignment {
403 if (ts.isCallExpression(node.initializer)) {
404 return ts.factory.updatePropertyAssignment(node, node.name,
409 function processCustomDialogControllerBuilder(parent: ts.Expression,
410 node: ts.CallExpression, componentName: string): ts.ArrowFunction {
411 …const newExp: ts.Expression = createCustomComponentNewExpression(node, componentName, false, false…
412 const jsDialog: ts.Identifier = ts.factory.createIdentifier(JS_DIALOG);
416 function createCustomComponentBuilderArrowFunction(node: ts.CallExpression, parent: ts.Expression,
417 jsDialog: ts.Identifier, newExp: ts.Expression): ts.ArrowFunction {
418 let mountNodde: ts.PropertyAccessExpression;
419 if (ts.isBinaryExpression(parent)) {
421 } else if (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) {
422 mountNodde = ts.factory.createPropertyAccessExpression(ts.factory.createThis(),
423 parent.name as ts.Identifier);
425 return ts.factory.createArrowFunction(
430 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
431 ts.factory.createBlock(
434 ts.factory.createVariableStatement(
436 ts.factory.createVariableDeclarationList(
437 [ts.factory.createVariableDeclaration(jsDialog, undefined, undefined, newExp)],
438 ts.NodeFlags.Let
441 ts.factory.createExpressionStatement(
442 ts.factory.createCallExpression(
443 ts.factory.createPropertyAccessExpression(
445 ts.factory.createIdentifier(SET_CONTROLLER_METHOD)
451 ts.factory.createExpressionStatement(createViewCreate(jsDialog))
458 export function isResource(node: ts.Node): boolean {
459 return ts.isCallExpression(node) && ts.isIdentifier(node.expression) &&
464 export function isAnimateTo(node: ts.Node): boolean {
465 return ts.isCallExpression(node) && ts.isIdentifier(node.expression) &&
469 export function processResourceData(node: ts.CallExpression,
470 … {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node {
471 if (ts.isStringLiteral(node.arguments[0])) {
482 function getResourceDataNode(node: ts.CallExpression,
483 previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}): ts.Node {
484 const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.');
502 function isResourcefile(node: ts.CallExpression, previewLog: {isAcceleratePreview: boolean, log: Lo…
513 function createResourceParam(resourceValue: number, resourceType: number, argsArr: ts.Expression[]):
514 ts.ObjectLiteralExpression {
521 const propertyArray: Array<ts.PropertyAssignment> = [
522 ts.factory.createPropertyAssignment(
523 ts.factory.createStringLiteral(RESOURCE_NAME_ID),
524 ts.factory.createNumericLiteral(resourceValue)
526 ts.factory.createPropertyAssignment(
527 ts.factory.createStringLiteral(RESOURCE_NAME_TYPE),
528 ts.factory.createNumericLiteral(resourceType)
530 ts.factory.createPropertyAssignment(
531 ts.factory.createIdentifier(RESOURCE_NAME_PARAMS),
532 ts.factory.createArrayLiteralExpression(argsArr, false)
537 propertyArray.push(ts.factory.createPropertyAssignment(
538 ts.factory.createStringLiteral(RESOURCE_NAME_BUNDLE),
539 ts.factory.createStringLiteral(projectConfig.bundleName)
544 propertyArray.push(ts.factory.createPropertyAssignment(
545 ts.factory.createStringLiteral(RESOURCE_NAME_MODULE),
546 ts.factory.createStringLiteral(projectConfig.moduleName)
550 const resourceParams: ts.ObjectLiteralExpression = ts.factory.createObjectLiteralExpression(
600 function isWorker(node: ts.Node): boolean {
601 return ts.isNewExpression(node) && ts.isPropertyAccessExpression(node.expression) &&
602 ts.isIdentifier(node.expression.name) &&
606 function processWorker(node: ts.NewExpression): ts.Node {
607 if (node.arguments.length && ts.isStringLiteral(node.arguments[0])) {
608 const args: ts.Expression[] = Array.from(node.arguments);
611 const stringNode: ts.StringLiteral = ts.factory.createStringLiteral(
614 return ts.factory.updateNewExpression(node, node.expression, node.typeArguments, args);
619 export function processAnimateTo(node: ts.CallExpression): ts.CallExpression {
620 return ts.factory.updateCallExpression(node, ts.factory.createPropertyAccessExpression(
621 ts.factory.createIdentifier(GLOBAL_CONTEXT), ts.factory.createIdentifier(ATTRIBUTE_ANIMATETO)),
625 function processExtend(node: ts.FunctionDeclaration, log: LogInfo[],
626 decoratorName: string): ts.FunctionDeclaration {
629 const statementArray: ts.Statement[] = [];
630 let bodynode: ts.Block;
632 const attrSet: ts.CallExpression = node.body.statements[0].expression;
634 …const changeCompName: ts.ExpressionStatement = ts.factory.createExpressionStatement(processExtendB…
635 bindComponentAttr(changeCompName as ts.ExpressionStatement,
636 ts.factory.createIdentifier(componentName), statementArray, log);
638 bodynode = ts.visitEachChild(node.body, traverseExtendExpression, contextGlobal);
647 … return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken,
648 ts.factory.createIdentifier(extendFunctionName), node.typeParameters,
649 … node.parameters, ts.factory.createToken(ts.SyntaxKind.VoidKeyword), isOriginalExtend(node.body) ?
650 ts.factory.updateBlock(node.body, statementArray) : bodynode);
654 ts.factory.createIdentifier(componentName), statementArray, log);
655 … return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken,
657 …[...node.parameters, ...createAnimatableParameterNode()], ts.factory.createToken(ts.SyntaxKind.Voi…
658 ts.factory.updateBlock(node.body, createAnimatableBody(componentName, node.name,
662 function traverseExtendExpression(node: ts.Node): ts.Node {
663 if (ts.isExpressionStatement(node) && isDollarNode(node, componentName)) {
664 const changeCompName: ts.ExpressionStatement =
665 ts.factory.createExpressionStatement(processExtendBody(node.expression, componentName));
666 const statementArray: ts.Statement[] = [];
667 … bindComponentAttr(changeCompName, ts.factory.createIdentifier(componentName), statementArray, []);
668 return ts.factory.createBlock(statementArray, true);
670 return ts.visitEachChild(node, traverseExtendExpression, contextGlobal);
674 function createAnimatableParameterNode(): ts.ParameterDeclaration[] {
676 ts.factory.createParameterDeclaration(
677 undefined, undefined, undefined, ts.factory.createIdentifier(ELMTID)),
678 ts.factory.createParameterDeclaration(
679 undefined, undefined, undefined, ts.factory.createIdentifier(ISINITIALRENDER)),
680 ts.factory.createParameterDeclaration(
681 undefined, undefined, undefined, ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT))
685 function createAnimatableBody(componentName: string, funcName: ts.Identifier,
686 parameters: ts.NodeArray<ts.ParameterDeclaration>, attrArray: ts.Statement[]): ts.Statement[] {
687 const paramNode: ts.Identifier[] = [];
688 parameters.forEach((item: ts.ParameterDeclaration) => {
689 if (item.name && ts.isIdentifier(item.name)) {
694 ts.factory.createIfStatement(
695 ts.factory.createIdentifier(ISINITIALRENDER),
696 ts.factory.createBlock([
700 ts.factory.createBlock([
701 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
702 ts.factory.createPropertyAccessExpression(
703 ts.factory.createIdentifier(componentName),
704 ts.factory.createIdentifier(UPDATE_ANIMATABLE_PROPERTY)
706 [ ts.factory.createStringLiteral(funcName.escapedText.toString()), ...paramNode ]
713 function createAnimatableProperty(componentName: string, funcName: ts.Identifier,
714 parameters: ts.NodeArray<ts.ParameterDeclaration>,
715 paramNode: ts.Identifier[], attrArray: ts.Statement[]) {
716 const componentIdentifier: ts.Identifier = ts.factory.createIdentifier(componentName);
717 return ts.factory.createExpressionStatement(
718 ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(
720 ts.factory.createIdentifier(CREATE_ANIMATABLE_PROPERTY)),
722 ts.factory.createStringLiteral(funcName.escapedText.toString()),
724 ts.factory.createArrowFunction(undefined, undefined, parameters, undefined,
725 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
726 ts.factory.createBlock([
738 function createAnimatableFrameNode(componentName: string): ts.ExpressionStatement {
739 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
740 ts.factory.createPropertyAccessExpression(
741 ts.factory.createIdentifier(VIEW_STACK_PROCESSOR),
742 ts.factory.createIdentifier(GET_AND_PUSH_FRAME_NODE),
745 ts.factory.createStringLiteral(componentName),
746 ts.factory.createIdentifier(ELMTID)
751 function createAnimatableUpdateFunc(): ts.ExpressionStatement {
752 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
753 ts.factory.createPropertyAccessExpression(
754 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
755 ts.factory.createIdentifier(FINISH_UPDATE_FUNC),
756 ), undefined, [ts.factory.createIdentifier(ELMTID)]
760 function processConcurrent(node: ts.FunctionDeclaration): ts.FunctionDeclaration {
762 const statementArray: ts.Statement[]
763 = [ts.factory.createExpressionStatement(ts.factory.createStringLiteral('use concurrent')),
765 …return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken, n…
766 …node.typeParameters, node.parameters, node.type, ts.factory.updateBlock(node.body, statementArray)…
771 export function isOriginalExtend(node: ts.Block): boolean {
772 let innerNode: ts.Node = node.statements[0];
773 if (node.statements.length === 1 && ts.isExpressionStatement(innerNode)) {
777 …if (ts.isIdentifier(innerNode) && innerNode.pos && innerNode.end && innerNode.pos === innerNode.en…
785 function isDollarNode(node: ts.ExpressionStatement, componentName: string): boolean {
786 let innerNode: ts.Node = node;
794 if (ts.isIdentifier(innerNode) && innerNode.getText() === changedIdentifier) {
801 function processExtendBody(node: ts.Node, componentName?: string): ts.Expression {
803 case ts.SyntaxKind.CallExpression:
804 return ts.factory.createCallExpression(processExtendBody(node.expression, componentName),
806 case ts.SyntaxKind.PropertyAccessExpression:
807 return ts.factory.createPropertyAccessExpression(
809 case ts.SyntaxKind.Identifier:
811 return ts.factory.createIdentifier(node.escapedText.toString().replace(INSTANCE, ''));
813 return ts.factory.createIdentifier(componentName);
826 export function isExtendFunction(node: ts.FunctionDeclaration, extendResult: ExtendResult,
830 if (ts.isCallExpression(node.decorators[i].expression)) {
831 … parseExtendNode(node.decorators[i].expression as ts.CallExpression, extendResult, checkArguments);
841 function parseExtendNode(node: ts.CallExpression, extendResult: ExtendResult, checkArguments: boole…
842 if (ts.isIdentifier(node.expression)) {
853 if (node.arguments.length && ts.isIdentifier(node.arguments[0])) {
858 function createEntryNode(node: ts.SourceFile, context: ts.TransformationContext,
859 entryNodeKey: ts.Expression, id: number): ts.SourceFile {
867 const entryNode: ts.ExpressionStatement =
869 cardRelativePath, entryNodeKey, id) as ts.ExpressionStatement;
872 const entryNodes: ts.ExpressionStatement[] =
874 cardRelativePath, entryNodeKey, id) as ts.ExpressionStatement[];
883 const statementsArray: ts.Statement =
889 function createEntryFunction(name: string, context: ts.TransformationContext, cardRelativePath: str…
890 …entryNodeKey: ts.Expression, id: number): ts.ExpressionStatement | (ts.ExpressionStatement | ts.Bl…
891 const newArray: ts.Expression[] = [
896 const [localStorageName, entryOptionNode]: [string, ts.Expression] = addStorageParam(name); constant
905 const newExpressionStatement: ts.ExpressionStatement =
912 if (entryOptionNode && ts.isObjectLiteralExpression(entryOptionNode)) {
930 function createLoadPageConditionalJudgMent(context: ts.TransformationContext, name: string,
931 cardRelativePath: string, localStorageName: string, entryOptionNode: ts.Expression,
932 argsArr: ts.Expression[] = undefined, isComponentPreview: boolean = false)
933 : (ts.ExpressionStatement | ts.Block | ts.IfStatement)[] {
935 let routeNameNode: ts.Expression;
936 let storageNode: ts.Expression;
938 const originArray: ts.ExpressionStatement[] = [
945 if (ts.isObjectLiteralExpression(entryOptionNode)) {
949 if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name)) {
967 ] : [ts.factory.createBlock([
977 ] : [ts.factory.createBlock([
987 ] : [ts.factory.createBlock([
997 ] : [ts.factory.createBlock([
1010 function judgeRouteNameAndStorage(context: ts.TransformationContext, name: string,
1011 …cardRelativePath: string, isObject: boolean, entryOptionNode: ts.Expression, routeNameNode: ts.Exp…
1012 storageNode: ts.Expression, argsArr: ts.Expression[] = undefined): ts.IfStatement {
1013 return ts.factory.createIfStatement(
1015 judgeRouteAndStorageForIdentifier(entryOptionNode as ts.Identifier, true, true),
1016 ts.factory.createBlock(
1023 ts.factory.createIfStatement(
1025 judgeRouteAndStorageForIdentifier(entryOptionNode as ts.Identifier, true, false),
1026 ts.factory.createBlock(
1033 ts.factory.createIfStatement(
1035 judgeRouteAndStorageForIdentifier(entryOptionNode as ts.Identifier, false, true),
1036 ts.factory.createBlock(
1043 ts.factory.createBlock(
1055 function judgeRouteAndStorageForObject(hasRouteName: boolean, hasStorage: boolean): ts.BinaryExpres…
1056 return ts.factory.createBinaryExpression(
1057 ts.factory.createBinaryExpression(
1058 ts.factory.createIdentifier(ROUTENAME_NODE),
1059ts.factory.createToken(hasRouteName ? ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind.EqualsE…
1060 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)
1062 ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken),
1063 ts.factory.createBinaryExpression(
1064 ts.factory.createIdentifier(STORAGE_NODE),
1065ts.factory.createToken(hasStorage ? ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind.EqualsEqu…
1066 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)
1071 function judgeRouteAndStorageForIdentifier(entryOptionNode: ts.Identifier, hasRouteName: boolean,
1072 hasStorage: boolean): ts.BinaryExpression {
1073 return ts.factory.createBinaryExpression(
1074 ts.factory.createBinaryExpression(
1076 ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken),
1077 ts.factory.createBinaryExpression(
1078 ts.factory.createPropertyAccessExpression(
1080 ts.factory.createIdentifier(ROUTE_NAME)
1082ts.factory.createToken(hasRouteName ? ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind.EqualsE…
1083 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)
1086 ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken),
1087 ts.factory.createBinaryExpression(
1088 ts.factory.createPropertyAccessExpression(
1090 ts.factory.createIdentifier(STORAGE)
1092ts.factory.createToken(hasStorage ? ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind.EqualsEqu…
1093 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)
1098 function assignRouteNameAndStorage(routeNameNode, storageNode, hasRouteName, hasStorage): ts.Expres…
1099 const assignOperation: ts.VariableStatement[] = [];
1101 assignOperation.push(ts.factory.createVariableStatement(
1103 ts.factory.createVariableDeclarationList(
1104 [ts.factory.createVariableDeclaration(
1105 ts.factory.createIdentifier(ROUTENAME_NODE),
1110 ts.NodeFlags.Let
1115 assignOperation.push(ts.factory.createVariableStatement(
1117 ts.factory.createVariableDeclarationList(
1118 [ts.factory.createVariableDeclaration(
1119 ts.factory.createIdentifier(STORAGE_NODE),
1124 ts.NodeFlags.Let
1131 function createLoadDocumentWithRoute(context: ts.TransformationContext, name: string,
1132 cardRelativePath: string, isObject: boolean, entryOptionNode: ts.Expression,
1133 routeNameNode: ts.Node, storageNode: ts.Node, hasRouteName: boolean, hasStorage: boolean,
1134 shouldCreateAccsessRecording: boolean, argsArr: ts.Expression[]): ts.ExpressionStatement[] {
1135 const newArray: ts.Expression[] = [
1142 newArray.push(ts.factory.createPropertyAccessExpression(
1144 ts.factory.createIdentifier(STORAGE)
1150 newArray.push(ts.factory.createIdentifier(STORAGE_NODE));
1160 const newExpression: ts.Expression = context.factory.createNewExpression(
1180 context.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
1183 …isObject ? ts.factory.createIdentifier(ROUTENAME_NODE) : context.factory.createPropertyAccessExpre…