@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.
Files changed (45) hide show
  1. package/README.md +55 -13
  2. package/compiler/compiler.d.ts +4 -0
  3. package/compiler/compiler.d.ts.map +1 -1
  4. package/compiler/compiler.js +90 -3
  5. package/compiler/compiler.js.map +1 -1
  6. package/directives/register.d.ts +1 -1
  7. package/directives/register.d.ts.map +1 -1
  8. package/directives/register.js +5 -4
  9. package/directives/register.js.map +1 -1
  10. package/package.json +10 -10
  11. package/transformer/before-component.d.ts.map +1 -1
  12. package/transformer/before-component.js +8 -2
  13. package/transformer/before-component.js.map +1 -1
  14. package/transformer/before-directive.d.ts.map +1 -1
  15. package/transformer/before-directive.js +5 -5
  16. package/transformer/before-directive.js.map +1 -1
  17. package/transformer/factory.d.ts.map +1 -1
  18. package/transformer/factory.js +12 -5
  19. package/transformer/factory.js.map +1 -1
  20. package/transformer/helpers.d.ts +8 -1
  21. package/transformer/helpers.d.ts.map +1 -1
  22. package/transformer/helpers.js +17 -1
  23. package/transformer/helpers.js.map +1 -1
  24. package/transformer/modules.d.ts +2 -1
  25. package/transformer/modules.d.ts.map +1 -1
  26. package/transformer/modules.js.map +1 -1
  27. package/transformer/scan-directives.d.ts.map +1 -1
  28. package/transformer/scan-directives.js +5 -1
  29. package/transformer/scan-directives.js.map +1 -1
  30. package/directives/directives.d.ts +0 -3
  31. package/directives/directives.d.ts.map +0 -1
  32. package/directives/directives.js +0 -48
  33. package/directives/directives.js.map +0 -1
  34. package/transformer/after-declarations-component copy.d.ts +0 -9
  35. package/transformer/after-declarations-component copy.d.ts.map +0 -1
  36. package/transformer/after-declarations-component copy.js +0 -56
  37. package/transformer/after-declarations-component copy.js.map +0 -1
  38. package/transformer/after-declarations-directie.d.ts +0 -8
  39. package/transformer/after-declarations-directie.d.ts.map +0 -1
  40. package/transformer/after-declarations-directie.js +0 -26
  41. package/transformer/after-declarations-directie.js.map +0 -1
  42. package/transformer/before-component copy.d.ts +0 -9
  43. package/transformer/before-component copy.d.ts.map +0 -1
  44. package/transformer/before-component copy.js +0 -212
  45. package/transformer/before-component copy.js.map +0 -1
package/README.md CHANGED
@@ -22,11 +22,11 @@ The Ibyar/Aurora CLI tool. ( dev - prerelease)
22
22
  ## `Install`
23
23
 
24
24
  ``` bash
25
- npm i --save @ibyar/cli
25
+ npm i -g --save @ibyar/cli
26
26
  ```
27
27
 
28
28
  ``` bash
29
- yarn add @ibyar/cli
29
+ yarn global add @ibyar/cli
30
30
  ```
31
31
 
32
32
  # How to use
@@ -40,25 +40,26 @@ Usage: ibyar [options]
40
40
 
41
41
  Examples:
42
42
  ibyar
43
- ibyar -b
44
- ibyar -b -w
45
- ibyar -gt
46
- ibyar -v
43
+ ibyar -b # run build
44
+ ibyar -b -w # run build and watch
45
+ ibyar -b -v -w # run build, show tsc logs and watch
46
+ ibyar -v # show cli version
47
47
  ibyar --help
48
48
 
49
49
  Options:
50
50
  -b --build compile the project source code with ibyar transformers
51
51
  and generate '.d.ts' files with created Custom HTML Element definitions.
52
- -w --watch compile and watch source files, used with --build
52
+ -w --watch compile and watch source files, used with --build
53
53
  -h --help print help message
54
54
  -v --version output the version number
55
55
  ```
56
56
 
57
57
 
58
- ## WebPack Bundle
59
58
 
59
+ ## Integration with `Webpack`
60
60
 
61
- - add webpack loader
61
+
62
+ ### add @ibyar/cli as loader
62
63
 
63
64
  ```js
64
65
  module.exports = {
@@ -76,7 +77,50 @@ module.exports = {
76
77
  };
77
78
  ```
78
79
 
79
- ## Rollup Bundle
80
+ ### use `ts-loader`
81
+
82
+ ```js
83
+ // 1. import default from the plugin module
84
+ import {
85
+ beforeCompileDirectiveOptions, beforeCompileComponentOptions,
86
+ afterDeclarationsCompileComponentOptions,
87
+ afterDeclarationsCompileDirectiveOptions,
88
+ scanDirectivesOnceAsTransformer,
89
+ } from '@ibyar/cli';
90
+
91
+
92
+ // 3. add getCustomTransformer method to the loader config
93
+ var config = {
94
+ ...
95
+ module: {
96
+ rules: [
97
+ {
98
+ test: /\.tsx?$/,
99
+ loader: 'ts-loader',
100
+ options: {
101
+ ... // other loader's options
102
+ getCustomTransformers: () => ({
103
+ before: [
104
+ scanDirectivesOnceAsTransformer(),
105
+ beforeCompileDirectiveOptions,
106
+ beforeCompileComponentOptions,
107
+ ],
108
+ after: [],
109
+ afterDeclarations: [
110
+ afterDeclarationsCompileComponentOptions,
111
+ afterDeclarationsCompileDirectiveOptions,
112
+ ],
113
+ })
114
+ }
115
+ }
116
+ ]
117
+ }
118
+ ...
119
+ };
120
+ ```
121
+
122
+ ## Integration with `Rollup`
123
+
80
124
 
81
125
  ```js
82
126
  import typescript from '@rollup/plugin-typescript';
@@ -90,7 +134,6 @@ import {
90
134
  export default = {
91
135
  ...,
92
136
  plugins: [
93
- nodeResolve(),
94
137
  typescript({
95
138
  transformers: {
96
139
  before: [
@@ -105,14 +148,13 @@ export default = {
105
148
  ],
106
149
  }
107
150
  }),
108
- html({ include: "**/*.html" }),
109
- css({ output: 'style.css' }),
110
151
  ],
111
152
  };
112
153
 
113
154
  ```
114
155
 
115
156
 
157
+
116
158
  The Ibyar CLI has a typescript transformer to generate a definitions for you component
117
159
 
118
160
  ```ts
@@ -6,6 +6,10 @@ export declare function scanDirectivesOnceAsTransformer(): (program: ts.Program)
6
6
  export declare function emitProgram(program: ts.Program): void;
7
7
  export declare function compileFiles(files: readonly string[], options: ts.CompilerOptions): void;
8
8
  export declare function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine): void;
9
+ export declare function patchProgram(tsProgram: ts.Program): void;
10
+ export declare function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: ts.CompilerOptions | undefined, host?: ts.CompilerHost, oldProgram?: ts.EmitAndSemanticDiagnosticsBuilderProgram | undefined, configFileParsingDiagnostics?: readonly ts.Diagnostic[], projectReferences?: readonly ts.ProjectReference[] | undefined): ts.EmitAndSemanticDiagnosticsBuilderProgram;
11
+ export declare function compileSolution(configFilePath: string, cmd: ts.ParsedCommandLine): void;
12
+ export declare function compileSolutionAndWatch(configFilePath: string, cmd: ts.ParsedCommandLine): void;
9
13
  export declare function getConfigPath(): string;
10
14
  export declare function compileArgs(): void;
11
15
  export declare function compileAndWatchArgs(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAOnD,wBAAgB,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAY1E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAEjD;AAED,wBAAgB,+BAA+B,cAG7B,EAAE,CAAC,OAAO,eADO,EAAE,CAAC,qBAAqB,KAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAS1F;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAG9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,eAAe,QAIjF;AAoBD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,QAejF;AAID,wBAAgB,aAAa,WAW5B;AAED,wBAAgB,WAAW,SAO1B;AAED,wBAAgB,mBAAmB,SAOlC"}
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AASnD,wBAAgB,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAY1E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAEjD;AAED,wBAAgB,+BAA+B,cAG7B,EAAE,CAAC,OAAO,eADO,EAAE,CAAC,qBAAqB,KAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAS1F;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAG9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,eAAe,QAIjF;AAoBD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,QAejF;AAID,wBAAgB,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,QAcjD;AAED,wBAAgB,8CAA8C,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,eAAe,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,wCAAwC,GAAG,SAAS,EAAE,4BAA4B,CAAC,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,gBAAgB,EAAE,GAAG,SAAS,+CAKtW;AAyCD,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,QAMhF;AAED,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,QAMxF;AAED,wBAAgB,aAAa,WAkB5B;AAED,wBAAgB,WAAW,SAW1B;AAED,wBAAgB,mBAAmB,SAWlC"}
@@ -5,6 +5,8 @@ import { afterDeclarationsCompileDirectiveOptions } from '../transformer/after-d
5
5
  import { beforeCompileComponentOptions } from '../transformer/before-component.js';
6
6
  import { beforeCompileDirectiveOptions } from '../transformer/before-directive.js';
7
7
  import { scanDirectivesTypeVisitor } from '../transformer/scan-directives.js';
8
+ import { dirname, join, resolve, relative } from 'path';
9
+ import { existsSync } from 'fs';
8
10
  export function getTransformers(program) {
9
11
  return {
10
12
  before: [
@@ -65,8 +67,83 @@ export function compileAndWatchFiles(configPath, cmd) {
65
67
  const program = programBuilder.getProgram();
66
68
  emitProgram(program);
67
69
  }
70
+ export function patchProgram(tsProgram) {
71
+ const program = tsProgram;
72
+ program.__emit = program.emit;
73
+ const programTransformers = getTransformers(program);
74
+ program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
75
+ if (!customTransformers) {
76
+ return program.__emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, programTransformers);
77
+ }
78
+ return program.__emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, {
79
+ before: [...(customTransformers?.before ?? []), ...programTransformers.before],
80
+ after: [...(customTransformers?.after ?? []), ...programTransformers.after],
81
+ afterDeclarations: [...(customTransformers?.afterDeclarations ?? []), ...programTransformers.afterDeclarations],
82
+ });
83
+ };
84
+ }
85
+ export function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
86
+ const program = ts.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
87
+ scanDirectives(program.getProgram());
88
+ patchProgram(program.getProgram());
89
+ return program;
90
+ }
91
+ const diagHost = {
92
+ getCanonicalFileName: function (fileName) {
93
+ return ts.sys.resolvePath(fileName);
94
+ },
95
+ getCurrentDirectory: function () {
96
+ return ts.sys.getCurrentDirectory();
97
+ },
98
+ getNewLine: function () {
99
+ return ts.sys.newLine;
100
+ }
101
+ };
102
+ function getTime() {
103
+ const date = new Date();
104
+ return `[${date.toLocaleTimeString('en-US')}]`;
105
+ }
106
+ function reportDiag(diag) {
107
+ let output = ts.sys.writeOutputIsTTY?.() ?
108
+ ts.formatDiagnosticsWithColorAndContext([diag], diagHost) :
109
+ ts.formatDiagnostic(diag, diagHost);
110
+ output = output.replace(/^[\r\n]+/, '').replace(/[\r\n]+$/, '');
111
+ ts.sys.write(`${getTime()} ${output}` + '\n');
112
+ }
113
+ function reportError(errorCount, filesInError) {
114
+ ts.sys.write(`Error count: ${errorCount}\n`);
115
+ filesInError.forEach(error => ts.sys.write(`Error file: ${error?.fileName}(${error?.line})\n`));
116
+ }
117
+ function printProjects(solution) {
118
+ const projects = solution?.getBuildOrder();
119
+ if (Array.isArray(projects) && projects?.length) {
120
+ console.log(`${getTime()} Projects in this build: `);
121
+ projects.forEach(project => console.log(`\t* ${relative(process.cwd(), project)}`));
122
+ }
123
+ }
124
+ export function compileSolution(configFilePath, cmd) {
125
+ const rootNames = [dirname(configFilePath)];
126
+ const solutionHost = ts.createSolutionBuilderHost(ts.sys, createEmitAndSemanticDiagnosticsBuilderProgram, reportDiag, reportDiag, reportError);
127
+ const solution = ts.createSolutionBuilder(solutionHost, rootNames, {});
128
+ printProjects(solution);
129
+ solution.build();
130
+ }
131
+ export function compileSolutionAndWatch(configFilePath, cmd) {
132
+ const rootNames = [dirname(configFilePath)];
133
+ const solutionHost = ts.createSolutionBuilderWithWatchHost(ts.sys, createEmitAndSemanticDiagnosticsBuilderProgram, reportDiag, reportDiag, reportDiag);
134
+ const solution = ts.createSolutionBuilderWithWatch(solutionHost, rootNames, {}, cmd.watchOptions);
135
+ printProjects(solution);
136
+ solution.build();
137
+ }
68
138
  export function getConfigPath() {
69
- const tsconfig = process.argv.slice(2).filter(arg => arg.includes('tsconfig'))[0];
139
+ const args = process.argv.slice(2);
140
+ let tsconfig = args.filter(arg => arg.includes('tsconfig'))[0];
141
+ if (!tsconfig && args.length > 1 /** -b */) {
142
+ const path = join(args.at(-1), 'tsconfig.json');
143
+ if (existsSync(path)) {
144
+ tsconfig = resolve(path);
145
+ }
146
+ }
70
147
  const configPath = ts.findConfigFile('./', /*searchPath*/ ts.sys.fileExists, tsconfig ?? 'tsconfig.json');
71
148
  if (!configPath) {
72
149
  throw new Error("Could not find a valid 'tsconfig.json'.");
@@ -79,7 +156,12 @@ export function compileArgs() {
79
156
  if (!cmd) {
80
157
  return;
81
158
  }
82
- compileFiles(cmd.fileNames, cmd.options);
159
+ if (cmd.projectReferences?.length) {
160
+ compileSolution(configPath, cmd);
161
+ }
162
+ else {
163
+ compileFiles(cmd.fileNames, cmd.options);
164
+ }
83
165
  }
84
166
  export function compileAndWatchArgs() {
85
167
  const configPath = getConfigPath();
@@ -87,6 +169,11 @@ export function compileAndWatchArgs() {
87
169
  if (!cmd) {
88
170
  return;
89
171
  }
90
- compileAndWatchFiles(configPath, cmd);
172
+ if (cmd.projectReferences?.length) {
173
+ compileSolutionAndWatch(configPath, cmd);
174
+ }
175
+ else {
176
+ compileAndWatchFiles(configPath, cmd);
177
+ }
91
178
  }
92
179
  //# sourceMappingURL=compiler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,UAAU,eAAe,CAAC,OAAmB;IAClD,OAAO;QACN,MAAM,EAAE;YACP,6BAA6B,CAAC,OAAO,CAAC;YACtC,6BAA6B,CAAC,OAAO,CAAC;SACtC;QACD,KAAK,EAAE,EAAE;QACT,iBAAiB,EAAE;YAClB,wCAAwC,CAAC,OAAO,CAAqD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AI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW;IAC1B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,gCAAgC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,GAAU,CAAC,CAAC;IAC/E,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO;IACR,CAAC;IACD,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,mBAAmB;IAClC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,gCAAgC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,GAAU,CAAC,CAAC;IAC/E,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO;IACR,CAAC;IACD,oBAAoB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import '../directives/register.js';\nimport ts from 'typescript/lib/tsserverlibrary.js';\nimport { afterDeclarationsCompileComponentOptions } from '../transformer/after-declarations-component.js';\nimport { afterDeclarationsCompileDirectiveOptions } from '../transformer/after-declarations-directive.js';\nimport { beforeCompileComponentOptions } from '../transformer/before-component.js';\nimport { beforeCompileDirectiveOptions } from '../transformer/before-directive.js';\nimport { scanDirectivesTypeVisitor } from '../transformer/scan-directives.js';\n\nexport function getTransformers(program: ts.Program): ts.CustomTransformers {\n\treturn {\n\t\tbefore: [\n\t\t\tbeforeCompileDirectiveOptions(program),\n\t\t\tbeforeCompileComponentOptions(program),\n\t\t],\n\t\tafter: [],\n\t\tafterDeclarations: [\n\t\t\tafterDeclarationsCompileComponentOptions(program) as ts.TransformerFactory<ts.SourceFile | ts.Bundle>,\n\t\t\tafterDeclarationsCompileDirectiveOptions(program) as ts.TransformerFactory<ts.SourceFile | ts.Bundle>,\n\t\t],\n\t};\n}\n\nexport function scanDirectives(program: ts.Program) {\n\tprogram.getSourceFiles().forEach(scanDirectivesTypeVisitor);\n}\n\nexport function scanDirectivesOnceAsTransformer() {\n\tlet scanDone = false;\n\tlet ignoreTransformer = (context: ts.TransformationContext): ts.Transformer<ts.SourceFile> => sourceFile => sourceFile;\n\treturn (program: ts.Program) => {\n\t\tif (scanDone) {\n\t\t\treturn ignoreTransformer;\n\t\t}\n\t\tscanDone = true;\n\t\tscanDirectives(program);\n\t\treturn ignoreTransformer;\n\t};\n}\n\nexport function emitProgram(program: ts.Program) {\n\tscanDirectives(program);\n\tprogram.emit(undefined, undefined, undefined, undefined, getTransformers(program));\n}\n\nexport function compileFiles(files: readonly string[], options: ts.CompilerOptions) {\n\tconst host = ts.createCompilerHost(options);\n\tconst program = ts.createProgram(files, options, host);\n\temitProgram(program);\n}\n\nconst formatHost: ts.FormatDiagnosticsHost = {\n\tgetCanonicalFileName: path => path,\n\tgetCurrentDirectory: ts.sys.getCurrentDirectory,\n\tgetNewLine: () => ts.sys.newLine\n};\n\nfunction reportDiagnostic(diagnostic: ts.Diagnostic) {\n\tconsole.error(\"Error\", diagnostic.code, \":\", ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()));\n}\n\n/**\n * Prints a diagnostic every time the watch status changes.\n * This is mainly for messages like \"Starting compilation\" or \"Compilation completed\".\n */\nfunction reportWatchStatusChanged(diagnostic: ts.Diagnostic) {\n\tconsole.info(ts.formatDiagnostic(diagnostic, formatHost));\n}\n\nexport function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine) {\n\tconst createProgram = ts.createSemanticDiagnosticsBuilderProgram;\n\tconst host = ts.createWatchCompilerHost(\n\t\tconfigPath,\n\t\tcmd.options,\n\t\tts.sys,\n\t\tcreateProgram,\n\t\treportDiagnostic,\n\t\treportWatchStatusChanged,\n\t\tcmd.watchOptions,\n\t);\n\tconst programFactory = ts.createWatchProgram(host);\n\tconst programBuilder = programFactory.getProgram();\n\tconst program = programBuilder.getProgram();\n\temitProgram(program);\n}\n\n\n\nexport function getConfigPath() {\n\tconst tsconfig = process.argv.slice(2).filter(arg => arg.includes('tsconfig'))[0];\n\tconst configPath = ts.findConfigFile(\n\t\t'./',\t\t\t/*searchPath*/\n\t\tts.sys.fileExists,\n\t\ttsconfig ?? 'tsconfig.json'\n\t);\n\tif (!configPath) {\n\t\tthrow new Error(\"Could not find a valid 'tsconfig.json'.\");\n\t}\n\treturn configPath;\n}\n\nexport function compileArgs() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\treturn;\n\t}\n\tcompileFiles(cmd.fileNames, cmd.options);\n}\n\nexport function compileAndWatchArgs() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\treturn;\n\t}\n\tcompileAndWatchFiles(configPath, cmd);\n}\n"]}
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,UAAU,EA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,CAAC;IAClC,CAAC;SAAM,CAAC;QACP,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;AACF,CAAC;AAED,MAAM,UAAU,mBAAmB;IAClC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,gCAAgC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,GAAU,CAAC,CAAC;IAC/E,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO;IACR,CAAC;IACD,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;QACnC,uBAAuB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACP,oBAAoB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;AACF,CAAC","sourcesContent":["import '../directives/register.js';\nimport ts from 'typescript/lib/tsserverlibrary.js';\nimport { afterDeclarationsCompileComponentOptions } from '../transformer/after-declarations-component.js';\nimport { afterDeclarationsCompileDirectiveOptions } from '../transformer/after-declarations-directive.js';\nimport { beforeCompileComponentOptions } from '../transformer/before-component.js';\nimport { beforeCompileDirectiveOptions } from '../transformer/before-directive.js';\nimport { scanDirectivesTypeVisitor } from '../transformer/scan-directives.js';\nimport { dirname, join, resolve, relative } from 'path';\nimport { existsSync } from 'fs';\n\nexport function getTransformers(program: ts.Program): ts.CustomTransformers {\n\treturn {\n\t\tbefore: [\n\t\t\tbeforeCompileDirectiveOptions(program),\n\t\t\tbeforeCompileComponentOptions(program),\n\t\t],\n\t\tafter: [],\n\t\tafterDeclarations: [\n\t\t\tafterDeclarationsCompileComponentOptions(program) as ts.TransformerFactory<ts.SourceFile | ts.Bundle>,\n\t\t\tafterDeclarationsCompileDirectiveOptions(program) as ts.TransformerFactory<ts.SourceFile | ts.Bundle>,\n\t\t],\n\t};\n}\n\nexport function scanDirectives(program: ts.Program) {\n\tprogram.getSourceFiles().forEach(scanDirectivesTypeVisitor);\n}\n\nexport function scanDirectivesOnceAsTransformer() {\n\tlet scanDone = false;\n\tlet ignoreTransformer = (context: ts.TransformationContext): ts.Transformer<ts.SourceFile> => sourceFile => sourceFile;\n\treturn (program: ts.Program) => {\n\t\tif (scanDone) {\n\t\t\treturn ignoreTransformer;\n\t\t}\n\t\tscanDone = true;\n\t\tscanDirectives(program);\n\t\treturn ignoreTransformer;\n\t};\n}\n\nexport function emitProgram(program: ts.Program) {\n\tscanDirectives(program);\n\tprogram.emit(undefined, undefined, undefined, undefined, getTransformers(program));\n}\n\nexport function compileFiles(files: readonly string[], options: ts.CompilerOptions) {\n\tconst host = ts.createCompilerHost(options);\n\tconst program = ts.createProgram(files, options, host);\n\temitProgram(program);\n}\n\nconst formatHost: ts.FormatDiagnosticsHost = {\n\tgetCanonicalFileName: path => path,\n\tgetCurrentDirectory: ts.sys.getCurrentDirectory,\n\tgetNewLine: () => ts.sys.newLine\n};\n\nfunction reportDiagnostic(diagnostic: ts.Diagnostic) {\n\tconsole.error(\"Error\", diagnostic.code, \":\", ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()));\n}\n\n/**\n * Prints a diagnostic every time the watch status changes.\n * This is mainly for messages like \"Starting compilation\" or \"Compilation completed\".\n */\nfunction reportWatchStatusChanged(diagnostic: ts.Diagnostic) {\n\tconsole.info(ts.formatDiagnostic(diagnostic, formatHost));\n}\n\nexport function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine) {\n\tconst createProgram = ts.createSemanticDiagnosticsBuilderProgram;\n\tconst host = ts.createWatchCompilerHost(\n\t\tconfigPath,\n\t\tcmd.options,\n\t\tts.sys,\n\t\tcreateProgram,\n\t\treportDiagnostic,\n\t\treportWatchStatusChanged,\n\t\tcmd.watchOptions,\n\t);\n\tconst programFactory = ts.createWatchProgram(host);\n\tconst programBuilder = programFactory.getProgram();\n\tconst program = programBuilder.getProgram();\n\temitProgram(program);\n}\n\ntype ProgramPatch = ts.Program & { __emit: (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: ts.CustomTransformers) => ts.EmitResult };\n\nexport function patchProgram(tsProgram: ts.Program) {\n\tconst program = tsProgram as ProgramPatch;\n\tprogram.__emit = program.emit;\n\tconst programTransformers = getTransformers(program);\n\tprogram.emit = (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: ts.CustomTransformers): ts.EmitResult => {\n\t\tif (!customTransformers) {\n\t\t\treturn program.__emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, programTransformers);\n\t\t}\n\t\treturn program.__emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, {\n\t\t\tbefore: [...(customTransformers?.before ?? []), ...programTransformers.before!],\n\t\t\tafter: [...(customTransformers?.after ?? []), ...programTransformers.after!],\n\t\t\tafterDeclarations: [...(customTransformers?.afterDeclarations ?? []), ...programTransformers.afterDeclarations!],\n\t\t});\n\t};\n}\n\nexport function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: ts.CompilerOptions | undefined, host?: ts.CompilerHost, oldProgram?: ts.EmitAndSemanticDiagnosticsBuilderProgram | undefined, configFileParsingDiagnostics?: readonly ts.Diagnostic[], projectReferences?: readonly ts.ProjectReference[] | undefined) {\n\tconst program = ts.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);\n\tscanDirectives(program.getProgram());\n\tpatchProgram(program.getProgram());\n\treturn program;\n}\n\n\nconst diagHost = {\n\tgetCanonicalFileName: function (fileName: string) {\n\t\treturn ts.sys.resolvePath(fileName)\n\t},\n\tgetCurrentDirectory: function () {\n\t\treturn ts.sys.getCurrentDirectory();\n\t},\n\tgetNewLine: function () {\n\t\treturn ts.sys.newLine;\n\t}\n};\n\nfunction getTime() {\n\tconst date = new Date();\n\treturn `[${date.toLocaleTimeString('en-US')}]`;\n}\n\nfunction reportDiag(diag: ts.Diagnostic) {\n\tlet output = ts.sys.writeOutputIsTTY?.() ?\n\t\tts.formatDiagnosticsWithColorAndContext([diag], diagHost) :\n\t\tts.formatDiagnostic(diag, diagHost);\n\toutput = output.replace(/^[\\r\\n]+/, '').replace(/[\\r\\n]+$/, '');\n\tts.sys.write(`${getTime()} ${output}` + '\\n');\n}\n\nfunction reportError(errorCount: number, filesInError: (ts.ReportFileInError | undefined)[]) {\n\tts.sys.write(`Error count: ${errorCount}\\n`);\n\tfilesInError.forEach(error => ts.sys.write(`Error file: ${error?.fileName}(${error?.line})\\n`));\n}\n\nfunction printProjects(solution: ts.SolutionBuilder<ts.EmitAndSemanticDiagnosticsBuilderProgram>) {\n\tconst projects = (solution as any)?.getBuildOrder() as string[];\n\tif (Array.isArray(projects) && projects?.length) {\n\t\tconsole.log(`${getTime()} Projects in this build: `);\n\t\tprojects.forEach(project => console.log(`\\t* ${relative(process.cwd(), project)}`));\n\t}\n}\n\nexport function compileSolution(configFilePath: string, cmd: ts.ParsedCommandLine) {\n\tconst rootNames = [dirname(configFilePath)];\n\tconst solutionHost = ts.createSolutionBuilderHost(ts.sys, createEmitAndSemanticDiagnosticsBuilderProgram, reportDiag, reportDiag, reportError);\n\tconst solution = ts.createSolutionBuilder(solutionHost, rootNames, {});\n\tprintProjects(solution);\n\tsolution.build();\n}\n\nexport function compileSolutionAndWatch(configFilePath: string, cmd: ts.ParsedCommandLine) {\n\tconst rootNames = [dirname(configFilePath)];\n\tconst solutionHost = ts.createSolutionBuilderWithWatchHost(ts.sys, createEmitAndSemanticDiagnosticsBuilderProgram, reportDiag, reportDiag, reportDiag);\n\tconst solution = ts.createSolutionBuilderWithWatch(solutionHost, rootNames, {}, cmd.watchOptions);\n\tprintProjects(solution);\n\tsolution.build();\n}\n\nexport function getConfigPath() {\n\tconst args = process.argv.slice(2);\n\tlet tsconfig = args.filter(arg => arg.includes('tsconfig'))[0];\n\tif (!tsconfig && args.length > 1 /** -b */) {\n\t\tconst path = join(args.at(-1)!, 'tsconfig.json');\n\t\tif (existsSync(path)) {\n\t\t\ttsconfig = resolve(path);\n\t\t}\n\t}\n\tconst configPath = ts.findConfigFile(\n\t\t'./',\t\t\t/*searchPath*/\n\t\tts.sys.fileExists,\n\t\ttsconfig ?? 'tsconfig.json'\n\t);\n\tif (!configPath) {\n\t\tthrow new Error(\"Could not find a valid 'tsconfig.json'.\");\n\t}\n\treturn configPath;\n}\n\nexport function compileArgs() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\treturn;\n\t}\n\tif (cmd.projectReferences?.length) {\n\t\tcompileSolution(configPath, cmd);\n\t} else {\n\t\tcompileFiles(cmd.fileNames, cmd.options);\n\t}\n}\n\nexport function compileAndWatchArgs() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\treturn;\n\t}\n\tif (cmd.projectReferences?.length) {\n\t\tcompileSolutionAndWatch(configPath, cmd);\n\t} else {\n\t\tcompileAndWatchFiles(configPath, cmd);\n\t}\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { DecoratorInfo } from '../transformer/modules.js';
2
2
  export interface DirectiveInfo {
3
3
  selector: string;
4
- successor?: string;
4
+ successors?: string[];
5
5
  inputs?: DecoratorInfo[];
6
6
  outputs?: DecoratorInfo[];
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/cli/directives/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;CAC1B;AACD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,QAcxD"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/cli/directives/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,QAgBxD"}
@@ -1,12 +1,13 @@
1
- import { registerDirective } from '@ibyar/core/node.js';
1
+ import { deleteDirective, provideDirective } from '@ibyar/core/node.js';
2
2
  import { directiveRegistry } from '@ibyar/elements/node.js';
3
3
  import { metadataHoler } from '@ibyar/decorators';
4
4
  export function registerDirectiveCall(info) {
5
- directiveRegistry.register(info.selector, {
6
- successor: info.successor,
5
+ directiveRegistry.set(info.selector, {
6
+ successors: info.successors,
7
7
  inputs: info.inputs?.map(i => i.aliasName),
8
8
  outputs: info.outputs?.map(i => i.aliasName),
9
9
  });
10
+ deleteDirective(info.selector);
10
11
  const modelClass = {};
11
12
  const modelKey = {};
12
13
  modelClass[Symbol.metadata] = modelKey;
@@ -14,6 +15,6 @@ export function registerDirectiveCall(info) {
14
15
  metadata.modelClass = modelClass;
15
16
  metadata.selector = info.selector;
16
17
  metadata.inputs = info.inputs?.map(input => ({ modelProperty: input.name, viewAttribute: input.aliasName }));
17
- registerDirective(modelClass);
18
+ provideDirective(modelClass);
18
19
  }
19
20
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/cli/directives/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAQlD,MAAM,UAAU,qBAAqB,CAAC,IAAmB;IACxD,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE;QACzC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1C,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KAC5C,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,QAAQ,GAAG,EAAE,CAAC;IACnB,UAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IAChD,MAAM,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAClC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7G,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { registerDirective } from '@ibyar/core/node.js';\nimport { directiveRegistry } from '@ibyar/elements/node.js';\nimport { DecoratorInfo } from '../transformer/modules.js';\nimport { metadataHoler } from '@ibyar/decorators';\n\nexport interface DirectiveInfo {\n\tselector: string,\n\tsuccessor?: string,\n\tinputs?: DecoratorInfo[],\n\toutputs?: DecoratorInfo[],\n}\nexport function registerDirectiveCall(info: DirectiveInfo) {\n\tdirectiveRegistry.register(info.selector, {\n\t\tsuccessor: info.successor,\n\t\tinputs: info.inputs?.map(i => i.aliasName),\n\t\toutputs: info.outputs?.map(i => i.aliasName),\n\t});\n\tconst modelClass = {};\n\tconst modelKey = {};\n\t(modelClass as any)[Symbol.metadata] = modelKey;\n\tconst metadata = metadataHoler.getOrCreate(modelKey);\n\tmetadata.modelClass = modelClass;\n\tmetadata.selector = info.selector;\n\tmetadata.inputs = info.inputs?.map(input => ({ modelProperty: input.name, viewAttribute: input.aliasName }));\n\tregisterDirective(modelClass);\n}\n"]}
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/cli/directives/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AASlD,MAAM,UAAU,qBAAqB,CAAC,IAAmB;IACxD,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;QACpC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1C,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KAC5C,CAAC,CAAC;IAEH,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,QAAQ,GAAG,EAAE,CAAC;IACnB,UAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IAChD,MAAM,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAClC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7G,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { deleteDirective, provideDirective } from '@ibyar/core/node.js';\nimport { directiveRegistry } from '@ibyar/elements/node.js';\nimport { DecoratorInfo } from '../transformer/modules.js';\nimport { metadataHoler } from '@ibyar/decorators';\n\nexport interface DirectiveInfo {\n\tselector: string,\n\tsuccessors?: string[],\n\tinputs?: DecoratorInfo[],\n\toutputs?: DecoratorInfo[],\n}\n\nexport function registerDirectiveCall(info: DirectiveInfo) {\n\tdirectiveRegistry.set(info.selector, {\n\t\tsuccessors: info.successors,\n\t\tinputs: info.inputs?.map(i => i.aliasName),\n\t\toutputs: info.outputs?.map(i => i.aliasName),\n\t});\n\n\tdeleteDirective(info.selector);\n\tconst modelClass = {};\n\tconst modelKey = {};\n\t(modelClass as any)[Symbol.metadata] = modelKey;\n\tconst metadata = metadataHoler.getOrCreate(modelKey);\n\tmetadata.modelClass = modelClass;\n\tmetadata.selector = info.selector;\n\tmetadata.inputs = info.inputs?.map(input => ({ modelProperty: input.name, viewAttribute: input.aliasName }));\n\tprovideDirective(modelClass);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/cli",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "The Ibyar/Aurora CLI tool",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ibyar/aurora",
@@ -36,14 +36,14 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@ibyar/core": "^2.2.1",
40
- "@ibyar/decorators": "^2.2.1",
41
- "@ibyar/directives": "^2.2.1",
42
- "@ibyar/elements": "^2.2.1",
43
- "@ibyar/expressions": "^2.2.1",
44
- "@ibyar/pipes": "^2.2.1",
45
- "tslib": "^2.6.3",
46
- "typescript": "^5.5.2"
39
+ "@ibyar/core": "^2.4.0",
40
+ "@ibyar/decorators": "^2.4.0",
41
+ "@ibyar/directives": "^2.4.0",
42
+ "@ibyar/elements": "^2.4.0",
43
+ "@ibyar/expressions": "^2.4.0",
44
+ "@ibyar/pipes": "^2.4.0",
45
+ "tslib": "^2.7.0",
46
+ "typescript": "^5.6.2"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsc --build --verbose",
@@ -74,5 +74,5 @@
74
74
  "shadow-dom",
75
75
  "typescript"
76
76
  ],
77
- "gitHead": "6c3b1c8d19faf00022c58ba2b893f4bb56147600"
77
+ "gitHead": "53497612809ca931456ce404746d2fea7ff92b84"
78
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"before-component.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/before-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAiBnD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAwMvG"}
1
+ {"version":3,"file":"before-component.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/before-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAiBnD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CA+MvG"}
@@ -4,7 +4,7 @@ import { htmlParser } from '@ibyar/elements/node.js';
4
4
  import { getExtendsTypeBySelector } from '../elements/tags.js';
5
5
  import { createConstructorOfViewInterfaceDeclaration, convertToProperties, createInterfaceType } from './factory.js';
6
6
  import { moduleManger } from './modules.js';
7
- import { getInputs, getOutputs, getTextValueForProperty, isComponentDecorator } from './helpers.js';
7
+ import { getInputs, getOutputs, getTextValueFormLiteralProperty, isComponentDecorator } from './helpers.js';
8
8
  /**
9
9
  * search for `@Component({})` and precompile the source code
10
10
  * @param program a ts program
@@ -63,7 +63,7 @@ export function beforeCompileComponentOptions(program) {
63
63
  return modifier;
64
64
  }
65
65
  const updateDecoratorOptions = (option) => {
66
- const selector = getTextValueForProperty(option, 'selector');
66
+ const selector = getTextValueFormLiteralProperty(option, 'selector');
67
67
  if (!selector) {
68
68
  console.error(`Component missing selector name: ${childNode.name?.getText()}`);
69
69
  return option;
@@ -76,12 +76,18 @@ export function beforeCompileComponentOptions(program) {
76
76
  const extendsType = getExtendsTypeBySelector(extend);
77
77
  const formAssociatedProperty = option.properties.find(prop => prop.name?.getText() === 'formAssociated');
78
78
  const formAssociated = formAssociatedProperty?.initializer.getText().substring(1, formAssociatedProperty?.initializer.getText().length - 1);
79
+ const disabledFeaturesInitializer = option.properties.find(prop => prop.name?.getText() === 'disabledFeatures')?.initializer;
80
+ let disabledFeatures = undefined;
81
+ if (disabledFeaturesInitializer && ts.isArrayLiteralExpression(disabledFeaturesInitializer)) {
82
+ disabledFeatures = disabledFeaturesInitializer.elements.filter(ts.isStringLiteral).map(el => el.getText(sourceFile));
83
+ }
79
84
  viewInfos.push({
80
85
  selector,
81
86
  viewName,
82
87
  extendsType,
83
88
  interFaceType: createInterfaceType(viewName, extendsType),
84
89
  formAssociated: 'true' == formAssociated,
90
+ disabledFeatures: [],
85
91
  });
86
92
  const stylesProperty = option.properties.find(prop => prop.name?.getText() === 'styles');
87
93
  const styles = stylesProperty?.initializer.getText().substring(1, stylesProperty?.initializer.getText().length - 1);
@@ -1 +1 @@
1
- {"version":3,"file":"before-component.js","sourceRoot":"","sources":["../../../src/cli/transformer/before-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,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,SAAS,EAAE,UAAU,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,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,EAAE;QAC3E,OAAO,UAAU,CAAC,EAAE;YACnB,IAAI,eAAe,GAAG,KAAK,CAAC;YAC5B,IAAI,qBAA6B,CAAC;YAClC,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;gBAC/C,IAAI,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC;oBACvC,MAAM,UAAU,GAAG,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;oBACvD,IAAI,SAAS,CAAC,YAAY,IAAI,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;wBAC1G,SAAS,CAAC,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE;4BACrE,IAAI,eAAe,EAAE,CAAC;gCACrB,OAAO;4BACR,CA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gBAAgB,CAAC,CAAC;gBAC9D,CAAC,CAAC,CAAC;gBACH,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,uDAAuD;gBAC1E,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;gBAC/B,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,CACjC,UAAU,EACV,UAAU,EACV,gBAAgB,CAAC,iBAAiB,EAClC,gBAAgB,CAAC,uBAAuB,EACxC,gBAAgB,CAAC,eAAe,EAChC,gBAAgB,CAAC,eAAe,EAChC,gBAAgB,CAAC,sBAAsB,CACvC,CAAC;YACH,CAAC;YACD,OAAO,gBAAgB,CAAC;QACzB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { buildExpressionNodes } from '@ibyar/core/node.js';\nimport { htmlParser } from '@ibyar/elements/node.js';\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\tgetInputs, getOutputs,\n\tgetTextValueForProperty,\n\tisComponentDecorator\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\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\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\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 => isComponentDecorator(decorator, componentPropertyName));\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\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\ttype: 'component',\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\treturn updateSourceFile;\n\t\t};\n\t};\n}\n"]}
1
+ {"version":3,"file":"before-component.js","sourceRoot":"","sources":["../../../src/cli/transformer/before-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,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,SAAS,EAAE,UAAU,EACrB,+BAA+B,EAC/B,oBAAoB,EACpB,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,EAAE;QAC3E,OAAO,UAAU,CAAC,EAAE;YACnB,IAAI,eAAe,GAAG,KAAK,CAAC;YAC5B,IAAI,qBAA6B,CAAC;YAClC,KAAK,MAAM,SAAS,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Ae,EAChC,gBAAgB,CAAC,eAAe,EAChC,gBAAgB,CAAC,sBAAsB,CACvC,CAAC;YACH,CAAC;YACD,OAAO,gBAAgB,CAAC;QACzB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { buildExpressionNodes } from '@ibyar/core/node.js';\nimport { htmlParser } from '@ibyar/elements/node.js';\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\tgetInputs, getOutputs,\n\tgetTextValueFormLiteralProperty,\n\tisComponentDecorator\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\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\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\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 => isComponentDecorator(decorator, componentPropertyName));\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\tconst updateDecoratorOptions = (option: ts.ObjectLiteralExpression) => {\n\t\t\t\t\t\t\t\tconst selector = getTextValueFormLiteralProperty(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\tconst disabledFeaturesInitializer = (option.properties.find(prop => prop.name?.getText() === 'disabledFeatures') as ts.PropertyAssignment | undefined)?.initializer as ts.ArrayLiteralExpression | undefined;\n\t\t\t\t\t\t\t\tlet disabledFeatures: string[] | undefined = undefined;\n\t\t\t\t\t\t\t\tif (disabledFeaturesInitializer && ts.isArrayLiteralExpression(disabledFeaturesInitializer)) {\n\t\t\t\t\t\t\t\t\tdisabledFeatures = disabledFeaturesInitializer.elements.filter(ts.isStringLiteral).map(el => el.getText(sourceFile));\n\t\t\t\t\t\t\t\t}\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\tdisabledFeatures: [],\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\ttype: 'component',\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\treturn updateSourceFile;\n\t\t};\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"before-directive.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/before-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAUnD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAkFvG"}
1
+ {"version":3,"file":"before-directive.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/before-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAWnD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAkFvG"}
@@ -1,6 +1,6 @@
1
1
  import ts from 'typescript/lib/tsserverlibrary.js';
2
2
  import { moduleManger } from './modules.js';
3
- import { getInputs, getOutputs, getTextValueForProperty, isDirectiveDecorator } from './helpers.js';
3
+ import { getInputs, getOutputs, getTextValueFormArrayLiteralProperty, getTextValueFormLiteralProperty, isDirectiveDecorator } from './helpers.js';
4
4
  import { registerDirectiveCall } from '../directives/register.js';
5
5
  /**
6
6
  * search for `@Directive({})` and to register with the html parser
@@ -57,21 +57,21 @@ export function beforeCompileDirectiveOptions(program) {
57
57
  if (ts.isDecorator(modifier) && isDirectiveDecorator(modifier, directivePropertyName)) {
58
58
  const options = modifier.expression.arguments[0];
59
59
  if (ts.isObjectLiteralExpression(options)) {
60
- const selector = getTextValueForProperty(options, 'selector');
60
+ const selector = getTextValueFormLiteralProperty(options, 'selector');
61
61
  if (selector) {
62
- const successor = getTextValueForProperty(options, 'successor');
62
+ const successors = getTextValueFormArrayLiteralProperty(options, 'successors');
63
63
  const inputs = getInputs(childNode, typeChecker);
64
64
  const outputs = getOutputs(childNode, typeChecker);
65
65
  registerDirectiveCall({
66
66
  selector,
67
- successor,
67
+ successors,
68
68
  inputs,
69
69
  outputs
70
70
  });
71
71
  classes.push({
72
72
  type: 'directive',
73
73
  name: selector,
74
- successor,
74
+ successors,
75
75
  inputs,
76
76
  outputs,
77
77
  views: [],
@@ -1 +1 @@
1
- {"version":3,"file":"before-directive.js","sourceRoot":"","sources":["../../../src/cli/transformer/before-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACN,SAAS,EAAE,UAAU,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAmB;IAChE,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAC7C,OAAO,CAAC,OAAiC,EAAiC,EAAE;QAC3E,OAAO,UAAU,CAAC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M;4CACN,OAAO;yCACP,CAAC,CAAC;wCACH,OAAO,CAAC,IAAI,CAAC;4CACZ,IAAI,EAAE,WAAW;4CACjB,IAAI,EAAE,QAAQ;4CACd,SAAS;4CACT,MAAM;4CACN,OAAO;4CACP,KAAK,EAAE,EAAE;yCACT,CAAC,CAAC;oCACJ,CAAC;gCACF,CAAC;4BACF,CAAC;wBACF,CAAC,CAAC,CAAC;oBACJ,CAAC;oBACD,OAAO,SAAS,CAAC;gBAClB,CAAC,EAAE,OAAO,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACpB,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,UAAU,CAAC;QACnB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { ClassInfo, moduleManger } from './modules.js';\nimport {\n\tgetInputs, getOutputs,\n\tgetTextValueForProperty,\n\tisDirectiveDecorator\n} from './helpers.js';\nimport { registerDirectiveCall } from '../directives/register.js';\n\n\n/**\n * search for `@Directive({})` and to register with the html parser\n * @param program a ts program \n * @returns a transformer factory of source file\n */\nexport function beforeCompileDirectiveOptions(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 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() === '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\treturn sourceFile;\n\t\t\t}\n\t\t\tconst classes: ClassInfo[] = [];\n\t\t\tts.visitNode(sourceFile, (node: ts.SourceFile) => {\n\t\t\t\treturn ts.visitEachChild(node, (childNode) => {\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 => isDirectiveDecorator(decorator, 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\tchildNode.modifiers?.forEach(modifier => {\n\t\t\t\t\t\t\tif (ts.isDecorator(modifier) && isDirectiveDecorator(modifier, directivePropertyName)) {\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\tconst successor = getTextValueForProperty(options, 'successor');\n\t\t\t\t\t\t\t\t\t\tconst inputs = getInputs(childNode, typeChecker);\n\t\t\t\t\t\t\t\t\t\tconst outputs = getOutputs(childNode, typeChecker);\n\t\t\t\t\t\t\t\t\t\tregisterDirectiveCall({\n\t\t\t\t\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\t\t\t\t\tsuccessor,\n\t\t\t\t\t\t\t\t\t\t\tinputs,\n\t\t\t\t\t\t\t\t\t\t\toutputs\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tclasses.push({\n\t\t\t\t\t\t\t\t\t\t\ttype: 'directive',\n\t\t\t\t\t\t\t\t\t\t\tname: selector,\n\t\t\t\t\t\t\t\t\t\t\tsuccessor,\n\t\t\t\t\t\t\t\t\t\t\tinputs,\n\t\t\t\t\t\t\t\t\t\t\toutputs,\n\t\t\t\t\t\t\t\t\t\t\tviews: [],\n\t\t\t\t\t\t\t\t\t\t});\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});\n\t\t\t\t\t}\n\t\t\t\t\treturn childNode;\n\t\t\t\t}, context);\n\t\t\t});\n\t\t\tif (classes.length) {\n\t\t\t\tmoduleManger.add({ path: sourceFile.fileName, classes });\n\t\t\t}\n\t\t\treturn sourceFile;\n\t\t};\n\t};\n}\n"]}
1
+ {"version":3,"file":"before-directive.js","sourceRoot":"","sources":["../../../src/cli/transformer/before-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACN,SAAS,EAAE,UAAU,EACrB,oCAAoC,EACpC,+BAA+B,EAC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wCACd,MAAM,UAAU,GAAG,oCAAoC,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;wCAC/E,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;wCACjD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;wCACnD,qBAAqB,CAAC;4CACrB,QAAQ;4CACR,UAAU;4CACV,MAAM;4CACN,OAAO;yCACP,CAAC,CAAC;wCACH,OAAO,CAAC,IAAI,CAAC;4CACZ,IAAI,EAAE,WAAW;4CACjB,IAAI,EAAE,QAAQ;4CACd,UAAU;4CACV,MAAM;4CACN,OAAO;4CACP,KAAK,EAAE,EAAE;yCACT,CAAC,CAAC;oCACJ,CAAC;gCACF,CAAC;4BACF,CAAC;wBACF,CAAC,CAAC,CAAC;oBACJ,CAAC;oBACD,OAAO,SAAS,CAAC;gBAClB,CAAC,EAAE,OAAO,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACpB,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,UAAU,CAAC;QACnB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { ClassInfo, moduleManger } from './modules.js';\nimport {\n\tgetInputs, getOutputs,\n\tgetTextValueFormArrayLiteralProperty,\n\tgetTextValueFormLiteralProperty,\n\tisDirectiveDecorator\n} from './helpers.js';\nimport { registerDirectiveCall } from '../directives/register.js';\n\n\n/**\n * search for `@Directive({})` and to register with the html parser\n * @param program a ts program \n * @returns a transformer factory of source file\n */\nexport function beforeCompileDirectiveOptions(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 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() === '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\treturn sourceFile;\n\t\t\t}\n\t\t\tconst classes: ClassInfo[] = [];\n\t\t\tts.visitNode(sourceFile, (node: ts.SourceFile) => {\n\t\t\t\treturn ts.visitEachChild(node, (childNode) => {\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 => isDirectiveDecorator(decorator, 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\tchildNode.modifiers?.forEach(modifier => {\n\t\t\t\t\t\t\tif (ts.isDecorator(modifier) && isDirectiveDecorator(modifier, directivePropertyName)) {\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 = getTextValueFormLiteralProperty(options, 'selector');\n\t\t\t\t\t\t\t\t\tif (selector) {\n\t\t\t\t\t\t\t\t\t\tconst successors = getTextValueFormArrayLiteralProperty(options, 'successors');\n\t\t\t\t\t\t\t\t\t\tconst inputs = getInputs(childNode, typeChecker);\n\t\t\t\t\t\t\t\t\t\tconst outputs = getOutputs(childNode, typeChecker);\n\t\t\t\t\t\t\t\t\t\tregisterDirectiveCall({\n\t\t\t\t\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\t\t\t\t\tsuccessors,\n\t\t\t\t\t\t\t\t\t\t\tinputs,\n\t\t\t\t\t\t\t\t\t\t\toutputs\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tclasses.push({\n\t\t\t\t\t\t\t\t\t\t\ttype: 'directive',\n\t\t\t\t\t\t\t\t\t\t\tname: selector,\n\t\t\t\t\t\t\t\t\t\t\tsuccessors,\n\t\t\t\t\t\t\t\t\t\t\tinputs,\n\t\t\t\t\t\t\t\t\t\t\toutputs,\n\t\t\t\t\t\t\t\t\t\t\tviews: [],\n\t\t\t\t\t\t\t\t\t\t});\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});\n\t\t\t\t\t}\n\t\t\t\t\treturn childNode;\n\t\t\t\t}, context);\n\t\t\t});\n\t\t\tif (classes.length) {\n\t\t\t\tmoduleManger.add({ path: sourceFile.fileName, classes });\n\t\t\t}\n\t\t\treturn sourceFile;\n\t\t};\n\t};\n}\n"]}