@ibyar/cli 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -13
- package/compiler/compiler.d.ts +4 -0
- package/compiler/compiler.d.ts.map +1 -1
- package/compiler/compiler.js +90 -3
- package/compiler/compiler.js.map +1 -1
- package/directives/register.d.ts +1 -1
- package/directives/register.d.ts.map +1 -1
- package/directives/register.js +5 -4
- package/directives/register.js.map +1 -1
- package/package.json +10 -10
- package/transformer/before-component.d.ts.map +1 -1
- package/transformer/before-component.js +8 -2
- package/transformer/before-component.js.map +1 -1
- package/transformer/before-directive.d.ts.map +1 -1
- package/transformer/before-directive.js +5 -5
- package/transformer/before-directive.js.map +1 -1
- package/transformer/factory.d.ts.map +1 -1
- package/transformer/factory.js +12 -5
- package/transformer/factory.js.map +1 -1
- package/transformer/helpers.d.ts +8 -1
- package/transformer/helpers.d.ts.map +1 -1
- package/transformer/helpers.js +17 -1
- package/transformer/helpers.js.map +1 -1
- package/transformer/modules.d.ts +2 -1
- package/transformer/modules.d.ts.map +1 -1
- package/transformer/modules.js.map +1 -1
- package/transformer/scan-directives.d.ts.map +1 -1
- package/transformer/scan-directives.js +5 -1
- package/transformer/scan-directives.js.map +1 -1
- package/directives/directives.d.ts +0 -3
- package/directives/directives.d.ts.map +0 -1
- package/directives/directives.js +0 -48
- package/directives/directives.js.map +0 -1
- package/transformer/after-declarations-component copy.d.ts +0 -9
- package/transformer/after-declarations-component copy.d.ts.map +0 -1
- package/transformer/after-declarations-component copy.js +0 -56
- package/transformer/after-declarations-component copy.js.map +0 -1
- package/transformer/after-declarations-directie.d.ts +0 -8
- package/transformer/after-declarations-directie.d.ts.map +0 -1
- package/transformer/after-declarations-directie.js +0 -26
- package/transformer/after-declarations-directie.js.map +0 -1
- package/transformer/before-component copy.d.ts +0 -9
- package/transformer/before-component copy.d.ts.map +0 -1
- package/transformer/before-component copy.js +0 -212
- package/transformer/before-component copy.js.map +0 -1
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
-
import { buildExpressionNodes } from '@ibyar/core/node';
|
|
3
|
-
import { htmlParser, directiveRegistry } from '@ibyar/elements/node';
|
|
4
|
-
import { getExtendsTypeBySelector } from '../elements/tags.js';
|
|
5
|
-
import { createConstructorOfViewInterfaceDeclaration, convertToProperties, createInterfaceType } from './factory.js';
|
|
6
|
-
import { moduleManger } from './modules.js';
|
|
7
|
-
import { isComponentDecorator, isDirectiveDecorator, getInputNames, getInputs, getOutputNames, getOutputs, getTextValueForProperty, isComponentOrDirectiveDecorator, } from './helpers.js';
|
|
8
|
-
/**
|
|
9
|
-
* search for `@Component({})` and precompile the source code
|
|
10
|
-
* @param program a ts program
|
|
11
|
-
* @returns a transformer factory of source file
|
|
12
|
-
*/
|
|
13
|
-
export function beforeCompileComponentOptions(program) {
|
|
14
|
-
const typeChecker = program.getTypeChecker();
|
|
15
|
-
return (context) => {
|
|
16
|
-
return sourceFile => {
|
|
17
|
-
let visitSourceFile = false;
|
|
18
|
-
let componentPropertyName;
|
|
19
|
-
let directivePropertyName;
|
|
20
|
-
for (const statement of sourceFile.statements) {
|
|
21
|
-
if (ts.isImportDeclaration(statement)) {
|
|
22
|
-
const modulePath = statement.moduleSpecifier.getText();
|
|
23
|
-
if (statement.importClause && modulePath.includes('@ibyar/aurora') || modulePath.includes('@ibyar/core')) {
|
|
24
|
-
statement.importClause?.namedBindings?.forEachChild(importSpecifier => {
|
|
25
|
-
if (visitSourceFile) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (ts.isImportSpecifier(importSpecifier)) {
|
|
29
|
-
if (importSpecifier.propertyName?.getText() === 'Component') {
|
|
30
|
-
visitSourceFile = true;
|
|
31
|
-
componentPropertyName = importSpecifier.name.getText();
|
|
32
|
-
}
|
|
33
|
-
else if (importSpecifier.name.getText() === 'Component') {
|
|
34
|
-
visitSourceFile = true;
|
|
35
|
-
componentPropertyName = importSpecifier.name.getText();
|
|
36
|
-
}
|
|
37
|
-
if (importSpecifier.propertyName?.getText() === 'Directive') {
|
|
38
|
-
visitSourceFile = true;
|
|
39
|
-
directivePropertyName = importSpecifier.name.getText();
|
|
40
|
-
}
|
|
41
|
-
else if (importSpecifier.name.getText() === 'Directive') {
|
|
42
|
-
visitSourceFile = true;
|
|
43
|
-
directivePropertyName = importSpecifier.name.getText();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (visitSourceFile) {
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!visitSourceFile) {
|
|
54
|
-
moduleManger.add({ path: sourceFile.fileName, skip: true });
|
|
55
|
-
return sourceFile;
|
|
56
|
-
}
|
|
57
|
-
const classes = [];
|
|
58
|
-
const updateSourceFile = ts.visitNode(sourceFile, (node) => {
|
|
59
|
-
return ts.visitEachChild(node, (childNode) => {
|
|
60
|
-
let decoratorArguments;
|
|
61
|
-
if (ts.isClassDeclaration(childNode)) {
|
|
62
|
-
const decorators = ts.getDecorators(childNode);
|
|
63
|
-
if (!decorators || decorators.length === 0) {
|
|
64
|
-
return childNode;
|
|
65
|
-
}
|
|
66
|
-
const hasDecorator = decorators.some(decorator => isComponentOrDirectiveDecorator(decorator, componentPropertyName, directivePropertyName));
|
|
67
|
-
if (!hasDecorator) {
|
|
68
|
-
return childNode;
|
|
69
|
-
}
|
|
70
|
-
const viewInfos = [];
|
|
71
|
-
const modifiers = childNode.modifiers?.map(modifier => {
|
|
72
|
-
if (!ts.isDecorator(modifier)) {
|
|
73
|
-
return modifier;
|
|
74
|
-
}
|
|
75
|
-
if (isDirectiveDecorator(modifier)) {
|
|
76
|
-
const options = modifier.expression.arguments[0];
|
|
77
|
-
if (ts.isObjectLiteralExpression(options)) {
|
|
78
|
-
const selector = getTextValueForProperty(options, 'selector');
|
|
79
|
-
if (!selector) {
|
|
80
|
-
return modifier;
|
|
81
|
-
}
|
|
82
|
-
const successor = getTextValueForProperty(options, 'successor');
|
|
83
|
-
const inputs = getInputNames(childNode, typeChecker);
|
|
84
|
-
const outputs = getOutputNames(childNode, typeChecker);
|
|
85
|
-
directiveRegistry.update(selector, { inputs, outputs, successor });
|
|
86
|
-
}
|
|
87
|
-
return modifier;
|
|
88
|
-
}
|
|
89
|
-
if (!isComponentDecorator(modifier)) {
|
|
90
|
-
return modifier;
|
|
91
|
-
}
|
|
92
|
-
const updateDecoratorOptions = (option) => {
|
|
93
|
-
const selector = getTextValueForProperty(option, 'selector');
|
|
94
|
-
if (!selector) {
|
|
95
|
-
console.error(`Component missing selector name: ${childNode.name?.getText()}`);
|
|
96
|
-
return option;
|
|
97
|
-
}
|
|
98
|
-
const viewName = `HTML${selector.split('-')
|
|
99
|
-
.map(name => name.replace(/^\w/, char => char.toUpperCase()))
|
|
100
|
-
.join('')}Element`;
|
|
101
|
-
const extendProperty = option.properties.find(prop => prop.name?.getText() === 'extend');
|
|
102
|
-
const extend = extendProperty?.initializer.getText().substring(1, extendProperty?.initializer.getText().length - 1);
|
|
103
|
-
const extendsType = getExtendsTypeBySelector(extend);
|
|
104
|
-
const formAssociatedProperty = option.properties.find(prop => prop.name?.getText() === 'formAssociated');
|
|
105
|
-
const formAssociated = formAssociatedProperty?.initializer.getText().substring(1, formAssociatedProperty?.initializer.getText().length - 1);
|
|
106
|
-
viewInfos.push({
|
|
107
|
-
selector,
|
|
108
|
-
viewName,
|
|
109
|
-
extendsType,
|
|
110
|
-
interFaceType: createInterfaceType(viewName, extendsType),
|
|
111
|
-
formAssociated: 'true' == formAssociated,
|
|
112
|
-
});
|
|
113
|
-
const stylesProperty = option.properties.find(prop => prop.name?.getText() === 'styles');
|
|
114
|
-
const styles = stylesProperty?.initializer.getText().substring(1, stylesProperty?.initializer.getText().length - 1);
|
|
115
|
-
const template = option.properties.find(prop => prop.name?.getText() === 'template');
|
|
116
|
-
if (template && ts.isPropertyAssignment(template) && ts.isStringLiteralLike(template.initializer)) {
|
|
117
|
-
const text = template?.initializer.getText().substring(1, template?.initializer.getText().length - 1);
|
|
118
|
-
const html = styles
|
|
119
|
-
? `<style>${styles}</style>${text}`
|
|
120
|
-
: text;
|
|
121
|
-
const domNode = htmlParser.toDomRootNode(html);
|
|
122
|
-
buildExpressionNodes(domNode);
|
|
123
|
-
const serialized = JSON.stringify(domNode);
|
|
124
|
-
const json = JSON.parse(serialized);
|
|
125
|
-
const name = ts.factory.createIdentifier('compiledTemplate');
|
|
126
|
-
const initializer = ts.factory.createObjectLiteralExpression(convertToProperties(json));
|
|
127
|
-
const update = ts.factory.updatePropertyAssignment(template, name, initializer);
|
|
128
|
-
decoratorArguments = option.properties.map(prop => {
|
|
129
|
-
if (template === prop) {
|
|
130
|
-
return update;
|
|
131
|
-
}
|
|
132
|
-
return prop;
|
|
133
|
-
}).filter(prop => {
|
|
134
|
-
if (prop.name?.getText(sourceFile) === 'styles') {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
});
|
|
139
|
-
return ts.factory.updateObjectLiteralExpression(option, decoratorArguments);
|
|
140
|
-
}
|
|
141
|
-
return option;
|
|
142
|
-
// options.properties.filter((prop: ts.PropertyAssignment) => {
|
|
143
|
-
// switch (prop.name.getText()) {
|
|
144
|
-
// case 'template':
|
|
145
|
-
// case 'templateUrl':
|
|
146
|
-
// case 'styles':
|
|
147
|
-
// return true;
|
|
148
|
-
// default: return false;
|
|
149
|
-
// }
|
|
150
|
-
// })
|
|
151
|
-
};
|
|
152
|
-
const decoratorCall = modifier.expression;
|
|
153
|
-
const options = decoratorCall.arguments[0];
|
|
154
|
-
let argumentsOption;
|
|
155
|
-
if (ts.isArrayLiteralExpression(options)) {
|
|
156
|
-
const elements = options.elements.map(element => {
|
|
157
|
-
if (ts.isObjectLiteralExpression(element)) {
|
|
158
|
-
return updateDecoratorOptions(element);
|
|
159
|
-
}
|
|
160
|
-
return element;
|
|
161
|
-
});
|
|
162
|
-
argumentsOption = ts.factory.updateArrayLiteralExpression(options, elements);
|
|
163
|
-
}
|
|
164
|
-
else if (ts.isObjectLiteralExpression(options)) {
|
|
165
|
-
argumentsOption = updateDecoratorOptions(options);
|
|
166
|
-
}
|
|
167
|
-
if (argumentsOption) {
|
|
168
|
-
return ts.factory.updateDecorator(modifier, ts.factory.updateCallExpression(decoratorCall, decoratorCall.expression, decoratorCall.typeArguments, [argumentsOption]));
|
|
169
|
-
}
|
|
170
|
-
return modifier;
|
|
171
|
-
});
|
|
172
|
-
classes.push({
|
|
173
|
-
name: childNode.name?.getText() ?? '',
|
|
174
|
-
views: viewInfos,
|
|
175
|
-
inputs: getInputs(childNode, typeChecker),
|
|
176
|
-
outputs: getOutputs(childNode, typeChecker),
|
|
177
|
-
});
|
|
178
|
-
// const staticMembers = viewInfos.map(
|
|
179
|
-
// viewInfo => ts.factory.createPropertyDeclaration(
|
|
180
|
-
// [
|
|
181
|
-
// ts.factory.createModifier(ts.SyntaxKind.StaticKeyword),
|
|
182
|
-
// ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)
|
|
183
|
-
// ],
|
|
184
|
-
// viewInfo.viewName,
|
|
185
|
-
// undefined,
|
|
186
|
-
// createStaticPropertyViewType(viewInfo.viewName),
|
|
187
|
-
// undefined,
|
|
188
|
-
// )
|
|
189
|
-
// );
|
|
190
|
-
return ts.factory.updateClassDeclaration(childNode, modifiers ? ts.factory.createNodeArray(modifiers) : void 0, childNode.name, childNode.typeParameters, childNode.heritageClauses, [/*...staticMembers,*/ ...childNode.members.slice()]);
|
|
191
|
-
}
|
|
192
|
-
return childNode;
|
|
193
|
-
}, context);
|
|
194
|
-
});
|
|
195
|
-
if (classes.length) {
|
|
196
|
-
moduleManger.add({ path: sourceFile.fileName, classes });
|
|
197
|
-
const statements = updateSourceFile.statements?.slice() ?? [];
|
|
198
|
-
statements.push(createConstructorOfViewInterfaceDeclaration());
|
|
199
|
-
const interfaces = classes.flatMap(s => s.views).map(info => {
|
|
200
|
-
return ts.setTextRange(info.interFaceType, updateSourceFile);
|
|
201
|
-
});
|
|
202
|
-
statements.push(); //emit inputs and outputs for component and directives;
|
|
203
|
-
statements.push(...interfaces);
|
|
204
|
-
return ts.factory.updateSourceFile(sourceFile, statements, updateSourceFile.isDeclarationFile, updateSourceFile.typeReferenceDirectives, updateSourceFile.referencedFiles, updateSourceFile.hasNoDefaultLib, updateSourceFile.libReferenceDirectives);
|
|
205
|
-
}
|
|
206
|
-
moduleManger.add({ path: sourceFile.fileName, skip: true });
|
|
207
|
-
return updateSourceFile;
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
export default beforeCompileComponentOptions;
|
|
212
|
-
//# sourceMappingURL=before-component%20copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"before-component copy.js","sourceRoot":"","sources":["../../../src/cli/transformer/before-component copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EACN,2CAA2C,EAC3C,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAuB,MAAM,cAAc,CAAC;AACjE,OAAO,EACN,oBAAoB,EAAE,oBAAoB,EAC1C,aAAa,EAAE,SAAS,EAAE,cAAc,EACxC,UAAU,EAAE,uBAAuB,EACnC,+BAA+B,GAC/B,MAAM,cAAc,CAAC;AAItB;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAmB;IAChE,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAC7C,OAAO,CAAC,OAAiC,EAAiC,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serverlibrary.js';\nimport { buildExpressionNodes } from '@ibyar/core/node';\nimport { htmlParser, directiveRegistry } from '@ibyar/elements/node';\nimport { getExtendsTypeBySelector } from '../elements/tags.js';\nimport {\n\tcreateConstructorOfViewInterfaceDeclaration,\n\tconvertToProperties, createInterfaceType\n} from './factory.js';\nimport { moduleManger, ViewInfo, ClassInfo } from './modules.js';\nimport {\n\tisComponentDecorator, isDirectiveDecorator,\n\tgetInputNames, getInputs, getOutputNames,\n\tgetOutputs, getTextValueForProperty,\n\tisComponentOrDirectiveDecorator,\n} from './helpers.js';\n\n\n\n/**\n * search for `@Component({})` and precompile the source code\n * @param program a ts program \n * @returns a transformer factory of source file\n */\nexport function beforeCompileComponentOptions(program: ts.Program): ts.TransformerFactory<ts.SourceFile> {\n\tconst typeChecker = program.getTypeChecker();\n\treturn (context: ts.TransformationContext): ts.Transformer<ts.SourceFile> => {\n\t\treturn sourceFile => {\n\t\t\tlet visitSourceFile = false;\n\t\t\tlet componentPropertyName: string;\n\t\t\tlet directivePropertyName: string;\n\t\t\tfor (const statement of sourceFile.statements) {\n\t\t\t\tif (ts.isImportDeclaration(statement)) {\n\t\t\t\t\tconst modulePath = statement.moduleSpecifier.getText();\n\t\t\t\t\tif (statement.importClause && modulePath.includes('@ibyar/aurora') || modulePath.includes('@ibyar/core')) {\n\t\t\t\t\t\tstatement.importClause?.namedBindings?.forEachChild(importSpecifier => {\n\t\t\t\t\t\t\tif (visitSourceFile) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (ts.isImportSpecifier(importSpecifier)) {\n\t\t\t\t\t\t\t\tif (importSpecifier.propertyName?.getText() === 'Component') {\n\t\t\t\t\t\t\t\t\tvisitSourceFile = true;\n\t\t\t\t\t\t\t\t\tcomponentPropertyName = importSpecifier.name.getText();\n\t\t\t\t\t\t\t\t} else if (importSpecifier.name.getText() === 'Component') {\n\t\t\t\t\t\t\t\t\tvisitSourceFile = true;\n\t\t\t\t\t\t\t\t\tcomponentPropertyName = importSpecifier.name.getText();\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (importSpecifier.propertyName?.getText() === 'Directive') {\n\t\t\t\t\t\t\t\t\tvisitSourceFile = true;\n\t\t\t\t\t\t\t\t\tdirectivePropertyName = importSpecifier.name.getText();\n\t\t\t\t\t\t\t\t} else if (importSpecifier.name.getText() === 'Directive') {\n\t\t\t\t\t\t\t\t\tvisitSourceFile = true;\n\t\t\t\t\t\t\t\t\tdirectivePropertyName = importSpecifier.name.getText();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (visitSourceFile) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!visitSourceFile) {\n\t\t\t\tmoduleManger.add({ path: sourceFile.fileName, skip: true });\n\t\t\t\treturn sourceFile;\n\t\t\t}\n\n\t\t\tconst classes: ClassInfo[] = [];\n\t\t\tconst updateSourceFile = ts.visitNode(sourceFile, (node: ts.SourceFile) => {\n\t\t\t\treturn ts.visitEachChild(node, (childNode) => {\n\t\t\t\t\tlet decoratorArguments: ts.ObjectLiteralElementLike[] | undefined;\n\t\t\t\t\tif (ts.isClassDeclaration(childNode)) {\n\t\t\t\t\t\tconst decorators = ts.getDecorators(childNode);\n\t\t\t\t\t\tif (!decorators || decorators.length === 0) {\n\t\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst hasDecorator = decorators.some(decorator => isComponentOrDirectiveDecorator(decorator, componentPropertyName, directivePropertyName));\n\t\t\t\t\t\tif (!hasDecorator) {\n\t\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst viewInfos: ViewInfo[] = [];\n\t\t\t\t\t\tconst modifiers = childNode.modifiers?.map(modifier => {\n\t\t\t\t\t\t\tif (!ts.isDecorator(modifier)) {\n\t\t\t\t\t\t\t\treturn modifier;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isDirectiveDecorator(modifier)) {\n\t\t\t\t\t\t\t\tconst options = (modifier.expression as ts.CallExpression).arguments[0];\n\t\t\t\t\t\t\t\tif (ts.isObjectLiteralExpression(options)) {\n\t\t\t\t\t\t\t\t\tconst selector = getTextValueForProperty(options, 'selector');\n\t\t\t\t\t\t\t\t\tif (!selector) {\n\t\t\t\t\t\t\t\t\t\treturn modifier;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst successor = getTextValueForProperty(options, 'successor');\n\t\t\t\t\t\t\t\t\tconst inputs = getInputNames(childNode, typeChecker);\n\t\t\t\t\t\t\t\t\tconst outputs = getOutputNames(childNode, typeChecker);\n\t\t\t\t\t\t\t\t\tdirectiveRegistry.update(selector, { inputs, outputs, successor });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn modifier;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!isComponentDecorator(modifier)) {\n\t\t\t\t\t\t\t\treturn modifier;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst updateDecoratorOptions = (option: ts.ObjectLiteralExpression) => {\n\t\t\t\t\t\t\t\tconst selector = getTextValueForProperty(option, 'selector');\n\t\t\t\t\t\t\t\tif (!selector) {\n\t\t\t\t\t\t\t\t\tconsole.error(`Component missing selector name: ${childNode.name?.getText()}`);\n\t\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst viewName = `HTML${selector.split('-')\n\t\t\t\t\t\t\t\t\t.map(name => name.replace(/^\\w/, char => char.toUpperCase()))\n\t\t\t\t\t\t\t\t\t.join('')}Element`;\n\n\n\t\t\t\t\t\t\t\tconst extendProperty = option.properties.find(prop => prop.name?.getText() === 'extend') as ts.PropertyAssignment | undefined;\n\t\t\t\t\t\t\t\tconst extend = extendProperty?.initializer.getText().substring(1, extendProperty?.initializer.getText().length - 1);\n\t\t\t\t\t\t\t\tconst extendsType = getExtendsTypeBySelector(extend);\n\n\t\t\t\t\t\t\t\tconst formAssociatedProperty = option.properties.find(prop => prop.name?.getText() === 'formAssociated') as ts.PropertyAssignment | undefined;\n\t\t\t\t\t\t\t\tconst formAssociated = formAssociatedProperty?.initializer.getText().substring(1, formAssociatedProperty?.initializer.getText().length - 1);\n\n\t\t\t\t\t\t\t\tviewInfos.push({\n\t\t\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\t\t\tviewName,\n\t\t\t\t\t\t\t\t\textendsType,\n\t\t\t\t\t\t\t\t\tinterFaceType: createInterfaceType(viewName, extendsType),\n\t\t\t\t\t\t\t\t\tformAssociated: 'true' == formAssociated,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tconst stylesProperty = option.properties.find(prop => prop.name?.getText() === 'styles') as ts.PropertyAssignment | undefined;\n\t\t\t\t\t\t\t\tconst styles = stylesProperty?.initializer.getText().substring(1, stylesProperty?.initializer.getText().length - 1);\n\n\t\t\t\t\t\t\t\tconst template = option.properties.find(prop => prop.name?.getText() === 'template');\n\t\t\t\t\t\t\t\tif (template && ts.isPropertyAssignment(template) && ts.isStringLiteralLike(template.initializer)) {\n\t\t\t\t\t\t\t\t\tconst text = template?.initializer.getText().substring(1, template?.initializer.getText().length - 1);\n\t\t\t\t\t\t\t\t\tconst html = styles\n\t\t\t\t\t\t\t\t\t\t? `<style>${styles}</style>${text}`\n\t\t\t\t\t\t\t\t\t\t: text;\n\t\t\t\t\t\t\t\t\tconst domNode = htmlParser.toDomRootNode(html);\n\t\t\t\t\t\t\t\t\tbuildExpressionNodes(domNode);\n\t\t\t\t\t\t\t\t\tconst serialized = JSON.stringify(domNode);\n\t\t\t\t\t\t\t\t\tconst json = JSON.parse(serialized);\n\t\t\t\t\t\t\t\t\tconst name = ts.factory.createIdentifier('compiledTemplate');\n\t\t\t\t\t\t\t\t\tconst initializer = ts.factory.createObjectLiteralExpression(convertToProperties(json));\n\t\t\t\t\t\t\t\t\tconst update = ts.factory.updatePropertyAssignment(template, name, initializer);\n\t\t\t\t\t\t\t\t\tdecoratorArguments = option.properties.map(prop => {\n\t\t\t\t\t\t\t\t\t\tif (template === prop) {\n\t\t\t\t\t\t\t\t\t\t\treturn update;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn prop;\n\t\t\t\t\t\t\t\t\t}).filter(prop => {\n\t\t\t\t\t\t\t\t\t\tif (prop.name?.getText(sourceFile) === 'styles') {\n\t\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\treturn ts.factory.updateObjectLiteralExpression(option, decoratorArguments);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn option;\n\n\t\t\t\t\t\t\t\t// options.properties.filter((prop: ts.PropertyAssignment) => {\n\t\t\t\t\t\t\t\t// \tswitch (prop.name.getText()) {\n\t\t\t\t\t\t\t\t// \t\tcase 'template':\n\t\t\t\t\t\t\t\t// \t\tcase 'templateUrl':\n\t\t\t\t\t\t\t\t// \t\tcase 'styles':\n\t\t\t\t\t\t\t\t// \t\t\treturn true;\n\t\t\t\t\t\t\t\t// \t\tdefault: return false;\n\t\t\t\t\t\t\t\t// \t}\n\t\t\t\t\t\t\t\t// })\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst decoratorCall = modifier.expression as ts.CallExpression;\n\t\t\t\t\t\t\tconst options = decoratorCall.arguments[0];\n\t\t\t\t\t\t\tlet argumentsOption: ts.Expression | undefined;\n\t\t\t\t\t\t\tif (ts.isArrayLiteralExpression(options)) {\n\t\t\t\t\t\t\t\tconst elements: ts.Expression[] = options.elements.map(element => {\n\t\t\t\t\t\t\t\t\tif (ts.isObjectLiteralExpression(element)) {\n\t\t\t\t\t\t\t\t\t\treturn updateDecoratorOptions(element);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn element;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\targumentsOption = ts.factory.updateArrayLiteralExpression(options, elements);\n\t\t\t\t\t\t\t} else if (ts.isObjectLiteralExpression(options)) {\n\t\t\t\t\t\t\t\targumentsOption = updateDecoratorOptions(options);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (argumentsOption) {\n\t\t\t\t\t\t\t\treturn ts.factory.updateDecorator(\n\t\t\t\t\t\t\t\t\tmodifier,\n\t\t\t\t\t\t\t\t\tts.factory.updateCallExpression(\n\t\t\t\t\t\t\t\t\t\tdecoratorCall,\n\t\t\t\t\t\t\t\t\t\tdecoratorCall.expression,\n\t\t\t\t\t\t\t\t\t\tdecoratorCall.typeArguments,\n\t\t\t\t\t\t\t\t\t\t[argumentsOption]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn modifier;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tclasses.push({\n\t\t\t\t\t\t\tname: childNode.name?.getText() ?? '',\n\t\t\t\t\t\t\tviews: viewInfos,\n\t\t\t\t\t\t\tinputs: getInputs(childNode, typeChecker),\n\t\t\t\t\t\t\toutputs: getOutputs(childNode, typeChecker),\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// const staticMembers = viewInfos.map(\n\t\t\t\t\t\t// \tviewInfo => ts.factory.createPropertyDeclaration(\n\t\t\t\t\t\t// \t\t[\n\t\t\t\t\t\t// \t\t\tts.factory.createModifier(ts.SyntaxKind.StaticKeyword),\n\t\t\t\t\t\t// \t\t\tts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)\n\t\t\t\t\t\t// \t\t],\n\t\t\t\t\t\t// \t\tviewInfo.viewName,\n\t\t\t\t\t\t// \t\tundefined,\n\t\t\t\t\t\t// \t\tcreateStaticPropertyViewType(viewInfo.viewName),\n\t\t\t\t\t\t// \t\tundefined,\n\t\t\t\t\t\t// \t)\n\t\t\t\t\t\t// );\n\t\t\t\t\t\treturn ts.factory.updateClassDeclaration(\n\t\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\t\tmodifiers ? ts.factory.createNodeArray(modifiers) : void 0,\n\t\t\t\t\t\t\tchildNode.name,\n\t\t\t\t\t\t\tchildNode.typeParameters,\n\t\t\t\t\t\t\tchildNode.heritageClauses,\n\t\t\t\t\t\t\t[/*...staticMembers,*/ ...childNode.members.slice()],\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn childNode;\n\t\t\t\t}, context);\n\t\t\t}) as ts.SourceFile;\n\t\t\tif (classes.length) {\n\t\t\t\tmoduleManger.add({ path: sourceFile.fileName, classes });\n\t\t\t\tconst statements = updateSourceFile.statements?.slice() ?? [];\n\t\t\t\tstatements.push(createConstructorOfViewInterfaceDeclaration());\n\t\t\t\tconst interfaces = classes.flatMap(s => s.views).map(info => {\n\t\t\t\t\treturn ts.setTextRange(info.interFaceType, updateSourceFile);\n\t\t\t\t});\n\t\t\t\tstatements.push(); //emit inputs and outputs for component and directives;\n\t\t\t\tstatements.push(...interfaces);\n\t\t\t\treturn ts.factory.updateSourceFile(\n\t\t\t\t\tsourceFile,\n\t\t\t\t\tstatements,\n\t\t\t\t\tupdateSourceFile.isDeclarationFile,\n\t\t\t\t\tupdateSourceFile.typeReferenceDirectives,\n\t\t\t\t\tupdateSourceFile.referencedFiles,\n\t\t\t\t\tupdateSourceFile.hasNoDefaultLib,\n\t\t\t\t\tupdateSourceFile.libReferenceDirectives,\n\t\t\t\t);\n\t\t\t}\n\t\t\tmoduleManger.add({ path: sourceFile.fileName, skip: true });\n\t\t\treturn updateSourceFile;\n\t\t};\n\t};\n}\n\nexport default beforeCompileComponentOptions;\n"]}
|