@ibyar/cli 2.0.1 → 2.1.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 +2 -0
- package/bin/cli.js +7 -5
- package/bin/cli.js.map +1 -1
- package/compiler/compiler.d.ts +2 -0
- package/compiler/compiler.d.ts.map +1 -1
- package/compiler/compiler.js +10 -0
- package/compiler/compiler.js.map +1 -1
- package/directives/directives.d.ts +3 -0
- package/directives/directives.d.ts.map +1 -0
- package/directives/directives.js +48 -0
- package/directives/directives.js.map +1 -0
- package/directives/register.d.ts +9 -0
- package/directives/register.d.ts.map +1 -0
- package/directives/register.js +87 -0
- package/directives/register.js.map +1 -0
- package/package.json +8 -7
- package/transformer/after-declarations-component copy.d.ts +9 -0
- package/transformer/after-declarations-component copy.d.ts.map +1 -0
- package/transformer/after-declarations-component copy.js +56 -0
- package/transformer/after-declarations-component copy.js.map +1 -0
- package/transformer/after-declarations-component.d.ts +0 -1
- package/transformer/after-declarations-component.d.ts.map +1 -1
- package/transformer/after-declarations-component.js +4 -9
- package/transformer/after-declarations-component.js.map +1 -1
- package/transformer/after-declarations-directie.d.ts +8 -0
- package/transformer/after-declarations-directie.d.ts.map +1 -0
- package/transformer/after-declarations-directie.js +26 -0
- package/transformer/after-declarations-directie.js.map +1 -0
- package/transformer/before-component copy.d.ts +9 -0
- package/transformer/before-component copy.d.ts.map +1 -0
- package/transformer/before-component copy.js +212 -0
- package/transformer/before-component copy.js.map +1 -0
- package/transformer/before-component.d.ts +0 -7
- package/transformer/before-component.d.ts.map +1 -1
- package/transformer/before-component.js +23 -65
- package/transformer/before-component.js.map +1 -1
- package/transformer/before-directive.d.ts +8 -0
- package/transformer/before-directive.d.ts.map +1 -0
- package/transformer/before-directive.js +94 -0
- package/transformer/before-directive.js.map +1 -0
- package/transformer/factory.d.ts +21 -1
- package/transformer/factory.d.ts.map +1 -1
- package/transformer/factory.js +43 -5
- package/transformer/factory.js.map +1 -1
- package/transformer/helpers.d.ts +80 -0
- package/transformer/helpers.d.ts.map +1 -0
- package/transformer/helpers.js +141 -0
- package/transformer/helpers.js.map +1 -0
- package/transformer/modules.d.ts +8 -8
- package/transformer/modules.d.ts.map +1 -1
- package/transformer/modules.js +6 -0
- package/transformer/modules.js.map +1 -1
- package/transformer/scan-directives.d.ts +22 -0
- package/transformer/scan-directives.d.ts.map +1 -0
- package/transformer/scan-directives.js +79 -0
- package/transformer/scan-directives.js.map +1 -0
package/README.md
CHANGED
|
@@ -41,12 +41,14 @@ Usage: ibyar [options]
|
|
|
41
41
|
Examples:
|
|
42
42
|
ibyar
|
|
43
43
|
ibyar -b
|
|
44
|
+
ibyar -b -w
|
|
44
45
|
ibyar -gt
|
|
45
46
|
ibyar -v
|
|
46
47
|
ibyar --help
|
|
47
48
|
|
|
48
49
|
Options:
|
|
49
50
|
-b --build compile the project source code with ibyar transformers
|
|
51
|
+
-w --watch compile and watch source files, used with --build
|
|
50
52
|
-gt --generate-types generate "web-types.json" files, and typescript
|
|
51
53
|
definitions '.d.ts' files.
|
|
52
54
|
you can import this file later in your "index.ts"
|
package/bin/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { exit } from 'process';
|
|
3
|
-
const CLI_VERSION = '1.0
|
|
3
|
+
const CLI_VERSION = '2.1.0';
|
|
4
4
|
const args = process.argv;
|
|
5
5
|
const inputs = args.slice(2);
|
|
6
|
-
const showHelp = inputs
|
|
7
|
-
const printVersion = inputs
|
|
8
|
-
const runBuild = inputs
|
|
9
|
-
const generateTypes = inputs
|
|
6
|
+
const showHelp = inputs[0] === '-h' || inputs[0] === '--help';
|
|
7
|
+
const printVersion = inputs[0] === '-v' || inputs[0] === '--version';
|
|
8
|
+
const runBuild = inputs[0] === '-b' || inputs[0] === '--build';
|
|
9
|
+
const generateTypes = inputs[0] === '-gt' || inputs[0] === '--generate-types';
|
|
10
10
|
if (showHelp) {
|
|
11
11
|
const help = `
|
|
12
12
|
Version ${CLI_VERSION}
|
|
@@ -15,12 +15,14 @@ Usage: ibyar [options]
|
|
|
15
15
|
Examples:
|
|
16
16
|
ibyar
|
|
17
17
|
ibyar -b
|
|
18
|
+
ibyar -b -w
|
|
18
19
|
ibyar -gt
|
|
19
20
|
ibyar -v
|
|
20
21
|
ibyar --help
|
|
21
22
|
|
|
22
23
|
Options:
|
|
23
24
|
-b --build compile the project source code with ibyar transformers
|
|
25
|
+
-w --watch compile and watch source files, used with --build
|
|
24
26
|
-gt --generate-types generate "web-types.json" files, and typescript
|
|
25
27
|
definitions '.d.ts' files.
|
|
26
28
|
you can import this file later in your "index.ts"
|
package/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli/bin/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli/bin/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AAC9D,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC;AAErE,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;AAC/D,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC;AAE9E,IAAI,QAAQ,EAAE,CAAC;IACd,MAAM,IAAI,GACT;UACQ,WAAW;;;;;;;;;;;;;;;;;;;;0DAoBqC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,IAAI,EAAE,CAAC;AACR,CAAC;AAGD,IAAI,YAAY,EAAE,CAAC;IAClB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC;AACR,CAAC;AAED,IAAI,QAAQ,EAAE,CAAC;IACd,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACrE,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9B,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,WAAW,EAAE,CAAC;QACtB,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,IAAI,aAAa,EAAE,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAClD,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { exit } from 'process';\n\nconst CLI_VERSION = '2.1.0';\n\nconst args = process.argv;\nconst inputs = args.slice(2);\n\nconst showHelp = inputs[0] === '-h' || inputs[0] === '--help';\nconst printVersion = inputs[0] === '-v' || inputs[0] === '--version';\n\nconst runBuild = inputs[0] === '-b' || inputs[0] === '--build';\nconst generateTypes = inputs[0] === '-gt' || inputs[0] === '--generate-types';\n\nif (showHelp) {\n\tconst help =\n\t\t`\nVersion ${CLI_VERSION}\nUsage: ibyar [options]\n\nExamples:\n ibyar\n ibyar -b\n ibyar -b -w\n ibyar -gt\n ibyar -v\n ibyar --help\n\nOptions:\n -b --build compile the project source code with ibyar transformers\n\t-w\t\t--watch\t\t\t\tcompile and watch source files, used with --build\n -gt --generate-types generate \"web-types.json\" files, and typescript\n\t definitions '.d.ts' files. \n\t you can import this file later in your \"index.ts\" \n\t\t\t\t\t\t\t\tor \"polyfills.ts\" file, so any editor \"VS Code\" can\n\t\t\t\t\t\t\t\tsupport autocomplete easily,\n -h --help print help message\n -v --version output the version number`;\n\tconsole.log(help);\n\texit();\n}\n\n\nif (printVersion) {\n\tconsole.log(CLI_VERSION);\n\texit();\n}\n\nif (runBuild) {\n\timport('../compiler/compiler.js').then(module => {\n\t\tif (process.argv.includes('-w') || process.argv.includes('--watch')) {\n\t\t\tmodule.compileAndWatchArgs();\n\t\t} else {\n\t\t\tmodule.compileArgs();\n\t\t}\n\t});\n}\n\nif (generateTypes) {\n\tconsole.log('generate types not supported yet.');\n}\n"]}
|
package/compiler/compiler.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import '../directives/register.js';
|
|
1
2
|
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
3
|
+
export declare function scanDirective(program: ts.Program): void;
|
|
2
4
|
export declare function emitProgram(program: ts.Program): void;
|
|
3
5
|
export declare function compileFiles(files: readonly string[], options: ts.CompilerOptions): void;
|
|
4
6
|
export declare function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;
|
|
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,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAEhD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAa9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,eAAe,QAIjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,QAMjF;AAeD,wBAAgB,WAAW,SAO1B;AAED,wBAAgB,mBAAmB,SAOlC"}
|
package/compiler/compiler.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
import '../directives/register.js';
|
|
1
2
|
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
3
|
import { afterDeclarationsCompileComponentOptions } from '../transformer/after-declarations-component.js';
|
|
4
|
+
import { afterDeclarationsCompileDirectiveOptions } from '../transformer/after-declarations-directie.js';
|
|
3
5
|
import { beforeCompileComponentOptions } from '../transformer/before-component.js';
|
|
6
|
+
import { beforeCompileDirectiveOptions } from '../transformer/before-directive.js';
|
|
7
|
+
import { scanDirectivesTypeVisitor } from '../transformer/scan-directives.js';
|
|
8
|
+
export function scanDirective(program) {
|
|
9
|
+
program.getSourceFiles().forEach(scanDirectivesTypeVisitor);
|
|
10
|
+
}
|
|
4
11
|
export function emitProgram(program) {
|
|
12
|
+
scanDirective(program);
|
|
5
13
|
program.emit(undefined, undefined, undefined, undefined, {
|
|
6
14
|
before: [
|
|
15
|
+
beforeCompileDirectiveOptions(program),
|
|
7
16
|
beforeCompileComponentOptions(program),
|
|
8
17
|
],
|
|
9
18
|
after: [],
|
|
10
19
|
afterDeclarations: [
|
|
11
20
|
afterDeclarationsCompileComponentOptions(program),
|
|
21
|
+
afterDeclarationsCompileDirectiveOptions(program),
|
|
12
22
|
],
|
|
13
23
|
});
|
|
14
24
|
}
|
package/compiler/compiler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;
|
|
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,+CAA+C,CAAC;AACzG,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,aAAa,CAAC,OAAmB;IAChD,OAAO,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAmB;IAC9C,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE;QACxD,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;YACrG,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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-directie.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 scanDirective(program: ts.Program) {\n\tprogram.getSourceFiles().forEach(scanDirectivesTypeVisitor);\n}\n\nexport function emitProgram(program: ts.Program) {\n\tscanDirective(program);\n\tprogram.emit(undefined, undefined, undefined, undefined, {\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 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\nexport function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine) {\n\tconst host = ts.createWatchCompilerHost(configPath, cmd.options, ts.sys);\n\tconst programFactory = ts.createWatchProgram(host);\n\tconst programBuilder = programFactory.getProgram();\n\tconst program = programBuilder.getProgram();\n\temitProgram(program);\n}\n\n\nfunction getConfigPath() {\n\tconst configPath = ts.findConfigFile(\n\t\t'./',\t\t\t/*searchPath*/\n\t\tts.sys.fileExists,\n\t\t'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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../../../src/cli/directives/directives.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,wBAAgB,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,QAgD/C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import * as ts from "typescript";
|
|
3
|
+
export function delint(sourceFile) {
|
|
4
|
+
delintNode(sourceFile);
|
|
5
|
+
function delintNode(node) {
|
|
6
|
+
switch (node.kind) {
|
|
7
|
+
case ts.SyntaxKind.ForStatement:
|
|
8
|
+
case ts.SyntaxKind.ForInStatement:
|
|
9
|
+
case ts.SyntaxKind.WhileStatement:
|
|
10
|
+
case ts.SyntaxKind.DoStatement:
|
|
11
|
+
if (node.statement.kind !== ts.SyntaxKind.Block) {
|
|
12
|
+
report(node, 'A looping statement\'s contents should be wrapped in a block body.');
|
|
13
|
+
}
|
|
14
|
+
break;
|
|
15
|
+
case ts.SyntaxKind.IfStatement:
|
|
16
|
+
const ifStatement = node;
|
|
17
|
+
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
|
|
18
|
+
report(ifStatement.thenStatement, 'An if statement\'s contents should be wrapped in a block body.');
|
|
19
|
+
}
|
|
20
|
+
if (ifStatement.elseStatement &&
|
|
21
|
+
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
|
|
22
|
+
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
|
|
23
|
+
report(ifStatement.elseStatement, 'An else statement\'s contents should be wrapped in a block body.');
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
case ts.SyntaxKind.BinaryExpression:
|
|
27
|
+
const op = node.operatorToken.kind;
|
|
28
|
+
if (op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken) {
|
|
29
|
+
report(node, 'Use \'===\' and \'!==\'.');
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
ts.forEachChild(node, delintNode);
|
|
34
|
+
}
|
|
35
|
+
function report(node, message) {
|
|
36
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
37
|
+
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const fileNames = process.argv.slice(2);
|
|
41
|
+
fileNames.forEach(fileName => {
|
|
42
|
+
// Parse a file
|
|
43
|
+
const sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015,
|
|
44
|
+
/*setParentNodes */ true);
|
|
45
|
+
// delint it
|
|
46
|
+
delint(sourceFile);
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=directives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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C,gBAAgB;gBAClC,MAAM,EAAE,GAAI,IAA4B,CAAC,aAAa,CAAC,IAAI,CAAC;gBAC5D,IAAI,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,IAAI,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC;oBAC3F,MAAM,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;gBAC1C,CAAC;gBACD,MAAM;QACR,CAAC;QAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,MAAM,CAAC,IAAa,EAAE,OAAe;QAC7C,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,QAAQ,KAAK,IAAI,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC;AACF,CAAC;AAED,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;IAC5B,eAAe;IACf,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CACrC,QAAQ,EACR,YAAY,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,EACjC,EAAE,CAAC,YAAY,CAAC,MAAM;IACpB,mBAAmB,CAAC,IAAI,CAC1B,CAAC;IAEF,YAAY;IACZ,MAAM,CAAC,UAAU,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC","sourcesContent":["import { readFileSync } from \"fs\";\nimport * as ts from \"typescript\";\n\nexport function delint(sourceFile: ts.SourceFile) {\n\tdelintNode(sourceFile);\n\tfunction delintNode(node: ts.Node) {\n\t\tswitch (node.kind) {\n\t\t\tcase ts.SyntaxKind.ForStatement:\n\t\t\tcase ts.SyntaxKind.ForInStatement:\n\t\t\tcase ts.SyntaxKind.WhileStatement:\n\t\t\tcase ts.SyntaxKind.DoStatement:\n\t\t\t\tif ((node as ts.IterationStatement).statement.kind !== ts.SyntaxKind.Block) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\t'A looping statement\\'s contents should be wrapped in a block body.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase ts.SyntaxKind.IfStatement:\n\t\t\t\tconst ifStatement = node as ts.IfStatement;\n\t\t\t\tif (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {\n\t\t\t\t\treport(ifStatement.thenStatement, 'An if statement\\'s contents should be wrapped in a block body.');\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tifStatement.elseStatement &&\n\t\t\t\t\tifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&\n\t\t\t\t\tifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement\n\t\t\t\t) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tifStatement.elseStatement,\n\t\t\t\t\t\t'An else statement\\'s contents should be wrapped in a block body.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase ts.SyntaxKind.BinaryExpression:\n\t\t\t\tconst op = (node as ts.BinaryExpression).operatorToken.kind;\n\t\t\t\tif (op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken) {\n\t\t\t\t\treport(node, 'Use \\'===\\' and \\'!==\\'.');\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\n\t\tts.forEachChild(node, delintNode);\n\t}\n\n\tfunction report(node: ts.Node, message: string) {\n\t\tconst { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n\t\tconsole.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);\n\t}\n}\n\nconst fileNames = process.argv.slice(2);\nfileNames.forEach(fileName => {\n\t// Parse a file\n\tconst sourceFile = ts.createSourceFile(\n\t\tfileName,\n\t\treadFileSync(fileName).toString(),\n\t\tts.ScriptTarget.ES2015,\n /*setParentNodes */ true\n\t);\n\n\t// delint it\n\tdelint(sourceFile);\n});"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DecoratorInfo } from '../transformer/modules.js';
|
|
2
|
+
export interface DirectiveInfo {
|
|
3
|
+
selector: string;
|
|
4
|
+
successor?: string;
|
|
5
|
+
inputs?: DecoratorInfo[];
|
|
6
|
+
outputs?: DecoratorInfo[];
|
|
7
|
+
}
|
|
8
|
+
export declare function registerDirectiveCall(info: DirectiveInfo): void;
|
|
9
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { registerDirective } from '@ibyar/core/node.js';
|
|
2
|
+
import { directiveRegistry } from '@ibyar/elements/node.js';
|
|
3
|
+
import { metadataHoler } from '@ibyar/decorators';
|
|
4
|
+
export function registerDirectiveCall(info) {
|
|
5
|
+
directiveRegistry.register(info.selector, {
|
|
6
|
+
successor: info.successor,
|
|
7
|
+
inputs: info.inputs?.map(i => i.aliasName),
|
|
8
|
+
outputs: info.outputs?.map(i => i.aliasName),
|
|
9
|
+
});
|
|
10
|
+
const modelClass = {};
|
|
11
|
+
const modelKey = {};
|
|
12
|
+
modelClass[Symbol.metadata] = modelKey;
|
|
13
|
+
const metadata = metadataHoler.getOrCreate(modelKey);
|
|
14
|
+
metadata.modelClass = modelClass;
|
|
15
|
+
metadata.selector = info.selector;
|
|
16
|
+
metadata.inputs = info.inputs?.map(input => ({ modelProperty: input.name, viewAttribute: input.aliasName }));
|
|
17
|
+
registerDirective(modelClass);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* register `class` and `style` attribute directive
|
|
21
|
+
*/
|
|
22
|
+
registerDirectiveCall({
|
|
23
|
+
selector: 'class',
|
|
24
|
+
inputs: [{ name: 'class', aliasName: 'class' }],
|
|
25
|
+
});
|
|
26
|
+
registerDirectiveCall({
|
|
27
|
+
selector: 'style',
|
|
28
|
+
inputs: [{ name: 'style', aliasName: 'style' }],
|
|
29
|
+
});
|
|
30
|
+
// registerDirective
|
|
31
|
+
/**
|
|
32
|
+
* for of/await/in directives
|
|
33
|
+
*/
|
|
34
|
+
registerDirectiveCall({
|
|
35
|
+
selector: '*for',
|
|
36
|
+
successor: '*empty',
|
|
37
|
+
inputs: [
|
|
38
|
+
{ name: 'forOf', aliasName: 'of' },
|
|
39
|
+
{ name: 'trackBy', aliasName: 'trackBy' },
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
registerDirectiveCall({
|
|
43
|
+
selector: '*forOf',
|
|
44
|
+
successor: '*empty',
|
|
45
|
+
inputs: [
|
|
46
|
+
{ name: 'forOf', aliasName: 'of' },
|
|
47
|
+
{ name: 'trackBy', aliasName: 'trackBy' },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
registerDirectiveCall({
|
|
51
|
+
selector: '*forAwait',
|
|
52
|
+
successor: '*empty',
|
|
53
|
+
inputs: [{ name: 'forOf', aliasName: 'of' },],
|
|
54
|
+
});
|
|
55
|
+
registerDirectiveCall({
|
|
56
|
+
selector: '*forIn',
|
|
57
|
+
successor: '*empty',
|
|
58
|
+
inputs: [{ name: 'forOf', aliasName: 'of' },],
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* if then else directive
|
|
62
|
+
*/
|
|
63
|
+
registerDirectiveCall({
|
|
64
|
+
selector: '*if',
|
|
65
|
+
successor: '*else',
|
|
66
|
+
inputs: [
|
|
67
|
+
{ name: 'ifCondition', aliasName: 'if' },
|
|
68
|
+
{ name: 'thenTemplateRef', aliasName: 'then' },
|
|
69
|
+
{ name: 'elseTemplateRef', aliasName: 'else' },
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* switch case default directives
|
|
74
|
+
*/
|
|
75
|
+
registerDirectiveCall({
|
|
76
|
+
selector: '*switch',
|
|
77
|
+
inputs: [{ name: 'switchValue', aliasName: 'switch' },],
|
|
78
|
+
});
|
|
79
|
+
registerDirectiveCall({
|
|
80
|
+
selector: '*case',
|
|
81
|
+
inputs: [{ name: 'caseValue', aliasName: 'case' },],
|
|
82
|
+
});
|
|
83
|
+
registerDirectiveCall({
|
|
84
|
+
selector: '*default',
|
|
85
|
+
inputs: [{ name: 'defaultCaseValue', aliasName: 'default' },],
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +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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AAQ,EAAE,UAAU;IACpB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE;CAC7D,CAAC,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\n/**\n * register `class` and `style` attribute directive\n */\nregisterDirectiveCall({\n\tselector: 'class',\n\tinputs: [{ name: 'class', aliasName: 'class' }],\n});\n\nregisterDirectiveCall({\n\tselector: 'style',\n\tinputs: [{ name: 'style', aliasName: 'style' }],\n});\n\n\n// registerDirective\n\n/**\n * for of/await/in directives\n */\nregisterDirectiveCall({\n\tselector: '*for',\n\tsuccessor: '*empty',\n\tinputs: [\n\t\t{ name: 'forOf', aliasName: 'of' },\n\t\t{ name: 'trackBy', aliasName: 'trackBy' },\n\t],\n});\n\nregisterDirectiveCall({\n\tselector: '*forOf',\n\tsuccessor: '*empty',\n\tinputs: [\n\t\t{ name: 'forOf', aliasName: 'of' },\n\t\t{ name: 'trackBy', aliasName: 'trackBy' },\n\t],\n});\n\nregisterDirectiveCall({\n\tselector: '*forAwait',\n\tsuccessor: '*empty',\n\tinputs: [{ name: 'forOf', aliasName: 'of' },],\n});\n\nregisterDirectiveCall({\n\tselector: '*forIn',\n\tsuccessor: '*empty',\n\tinputs: [{ name: 'forOf', aliasName: 'of' },],\n});\n\n\n/**\n * if then else directive\n */\nregisterDirectiveCall({\n\tselector: '*if',\n\tsuccessor: '*else',\n\tinputs: [\n\t\t{ name: 'ifCondition', aliasName: 'if' },\n\t\t{ name: 'thenTemplateRef', aliasName: 'then' },\n\t\t{ name: 'elseTemplateRef', aliasName: 'else' },\n\t],\n});\n\n\n/**\n * switch case default directives\n */\nregisterDirectiveCall({\n\tselector: '*switch',\n\tinputs: [{ name: 'switchValue', aliasName: 'switch' },],\n});\n\nregisterDirectiveCall({\n\tselector: '*case',\n\tinputs: [{ name: 'caseValue', aliasName: 'case' },],\n});\n\nregisterDirectiveCall({\n\tselector: '*default',\n\tinputs: [{ name: 'defaultCaseValue', aliasName: 'default' },],\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "The Ibyar/Aurora CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ibyar/aurora",
|
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ibyar/core": "^2.0
|
|
40
|
-
"@ibyar/
|
|
41
|
-
"@ibyar/
|
|
42
|
-
"@ibyar/
|
|
43
|
-
"@ibyar/
|
|
39
|
+
"@ibyar/core": "^2.1.0",
|
|
40
|
+
"@ibyar/decorators": "^2.1.0",
|
|
41
|
+
"@ibyar/directives": "^2.1.0",
|
|
42
|
+
"@ibyar/elements": "^2.1.0",
|
|
43
|
+
"@ibyar/expressions": "^2.1.0",
|
|
44
|
+
"@ibyar/pipes": "^2.1.0",
|
|
44
45
|
"tslib": "^2.6.3",
|
|
45
46
|
"typescript": "^5.5.2"
|
|
46
47
|
},
|
|
@@ -73,5 +74,5 @@
|
|
|
73
74
|
"shadow-dom",
|
|
74
75
|
"typescript"
|
|
75
76
|
],
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "9f8ca74fb05ae35ddfe22f4513c1175fffab9ea9"
|
|
77
78
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
/**
|
|
3
|
+
* search for `@Component({})` and update definition files
|
|
4
|
+
* @param program a ts program
|
|
5
|
+
* @returns a transformer factory of source file
|
|
6
|
+
*/
|
|
7
|
+
export declare function afterDeclarationsCompileComponentOptions(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
|
|
8
|
+
export default afterDeclarationsCompileComponentOptions;
|
|
9
|
+
//# sourceMappingURL=after-declarations-component%20copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-declarations-component copy.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-component copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAKnD;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAoElH;AAED,eAAe,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
import { createStaticPropertyViewType, updateModule } from './factory.js';
|
|
3
|
+
import { moduleManger } from './modules.js';
|
|
4
|
+
/**
|
|
5
|
+
* search for `@Component({})` and update definition files
|
|
6
|
+
* @param program a ts program
|
|
7
|
+
* @returns a transformer factory of source file
|
|
8
|
+
*/
|
|
9
|
+
export function afterDeclarationsCompileComponentOptions(program) {
|
|
10
|
+
const typeChecker = program.getTypeChecker();
|
|
11
|
+
return (context) => {
|
|
12
|
+
return sourceFile => {
|
|
13
|
+
const moduleInfo = moduleManger.get(sourceFile.fileName);
|
|
14
|
+
moduleManger.delete(sourceFile.fileName);
|
|
15
|
+
if (!moduleInfo) {
|
|
16
|
+
return sourceFile;
|
|
17
|
+
}
|
|
18
|
+
else if (moduleInfo.skip || !moduleInfo.classes) {
|
|
19
|
+
return sourceFile;
|
|
20
|
+
}
|
|
21
|
+
const classes = moduleInfo.classes.filter(c => c.type === 'component');
|
|
22
|
+
const sourceViewInfos = classes.flatMap(c => c.views);
|
|
23
|
+
const updateSourceFile = ts.visitNode(sourceFile, (node) => {
|
|
24
|
+
return ts.visitEachChild(node, (childNode) => {
|
|
25
|
+
if (!ts.isClassDeclaration(childNode)) {
|
|
26
|
+
return childNode;
|
|
27
|
+
}
|
|
28
|
+
const info = classes.find(c => c.name === childNode.name?.getText());
|
|
29
|
+
if (!info) {
|
|
30
|
+
return childNode;
|
|
31
|
+
}
|
|
32
|
+
const viewInfos = info.views;
|
|
33
|
+
const staticMembers = viewInfos.map(viewInfo => ts.factory.createPropertyDeclaration([
|
|
34
|
+
ts.factory.createModifier(ts.SyntaxKind.StaticKeyword),
|
|
35
|
+
ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)
|
|
36
|
+
], viewInfo.viewName, undefined, createStaticPropertyViewType(viewInfo.viewName), undefined)).map(staticMember => ts.setTextRange(staticMember, childNode));
|
|
37
|
+
return ts.factory.updateClassDeclaration(childNode, childNode.modifiers, childNode.name, childNode.typeParameters, childNode.heritageClauses, [...staticMembers, ...childNode.members.slice()]);
|
|
38
|
+
}, context);
|
|
39
|
+
});
|
|
40
|
+
if (sourceViewInfos.length) {
|
|
41
|
+
const statements = updateSourceFile.statements?.slice() ?? [];
|
|
42
|
+
// statements.push(createConstructorOfViewInterfaceDeclaration());
|
|
43
|
+
// const interfaces = sourceViewInfos.map(info => {
|
|
44
|
+
// return ts.setTextRange(info.interFaceType, updateSourceFile);
|
|
45
|
+
// });
|
|
46
|
+
// statements.push(...interfaces);
|
|
47
|
+
// statements.push(...updateGlobalHTMLElementTagNameMap(sourceViewInfos.map(v => ({ tagName: v.selector, viewName: v.viewName }))));
|
|
48
|
+
statements.push(...updateModule(classes));
|
|
49
|
+
return ts.factory.updateSourceFile(sourceFile, statements, updateSourceFile.isDeclarationFile, updateSourceFile.typeReferenceDirectives, updateSourceFile.referencedFiles, updateSourceFile.hasNoDefaultLib, updateSourceFile.libReferenceDirectives);
|
|
50
|
+
}
|
|
51
|
+
return updateSourceFile;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export default afterDeclarationsCompileComponentOptions;
|
|
56
|
+
//# sourceMappingURL=after-declarations-component%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-declarations-component copy.js","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-component copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAY,MAAM,cAAc,CAAC;AAGtD;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CAAC,OAAmB;IAC3E,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAC7C,OAAO,CAAC,OAAiC,EAAiC,EAAE;QAC3E,OAAO,UAAU,CAAC,EAAE;YACnB,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACzD,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,OAAO,UAAU,CAAC;YACnB,CAAC;iBAAM,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,UA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C,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;oBACjE,OAAO,EAAE,CAAC,OAAO,CAAC,sBAAsB,CACvC,SAAS,EACT,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,cAAc,EACxB,SAAS,CAAC,eAAe,EACzB,CAAC,GAAG,aAAa,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAChD,CAAC;gBACH,CAAC,EAAE,OAAO,CAAC,CAAC;YACb,CAAC,CAAkB,CAAC;YACpB,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;gBAC5B,MAAM,UAAU,GAAG,gBAAgB,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBAC9D,kEAAkE;gBAClE,mDAAmD;gBACnD,iEAAiE;gBACjE,MAAM;gBACN,kCAAkC;gBAClC,oIAAoI;gBACpI,UAAU,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC1C,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;AAED,eAAe,wCAAwC,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { createStaticPropertyViewType, updateModule } from './factory.js';\nimport { moduleManger, ViewInfo } from './modules.js';\n\n\n/**\n * search for `@Component({})` and update definition files\n * @param program a ts program \n * @returns a transformer factory of source file\n */\nexport function afterDeclarationsCompileComponentOptions(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\tconst moduleInfo = moduleManger.get(sourceFile.fileName);\n\t\t\tmoduleManger.delete(sourceFile.fileName);\n\t\t\tif (!moduleInfo) {\n\t\t\t\treturn sourceFile;\n\t\t\t} else if (moduleInfo.skip || !moduleInfo.classes) {\n\t\t\t\treturn sourceFile;\n\t\t\t}\n\n\t\t\tconst classes = moduleInfo.classes.filter(c => c.type === 'component');\n\n\t\t\tconst sourceViewInfos: ViewInfo[] = classes.flatMap(c => c.views);\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\tif (!ts.isClassDeclaration(childNode)) {\n\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t}\n\t\t\t\t\tconst info = classes.find(c => c.name === childNode.name?.getText());\n\n\t\t\t\t\tif (!info) {\n\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t}\n\t\t\t\t\tconst viewInfos: ViewInfo[] = info.views;\n\t\t\t\t\tconst staticMembers = viewInfos.map(viewInfo => ts.factory.createPropertyDeclaration(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tts.factory.createModifier(ts.SyntaxKind.StaticKeyword),\n\t\t\t\t\t\t\tts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)\n\t\t\t\t\t\t],\n\t\t\t\t\t\tviewInfo.viewName,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tcreateStaticPropertyViewType(viewInfo.viewName),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t)).map(staticMember => ts.setTextRange(staticMember, childNode));\n\t\t\t\t\treturn ts.factory.updateClassDeclaration(\n\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\tchildNode.modifiers,\n\t\t\t\t\t\tchildNode.name,\n\t\t\t\t\t\tchildNode.typeParameters,\n\t\t\t\t\t\tchildNode.heritageClauses,\n\t\t\t\t\t\t[...staticMembers, ...childNode.members.slice()],\n\t\t\t\t\t);\n\t\t\t\t}, context);\n\t\t\t}) as ts.SourceFile;\n\t\t\tif (sourceViewInfos.length) {\n\t\t\t\tconst statements = updateSourceFile.statements?.slice() ?? [];\n\t\t\t\t// statements.push(createConstructorOfViewInterfaceDeclaration());\n\t\t\t\t// const interfaces = sourceViewInfos.map(info => {\n\t\t\t\t// \treturn ts.setTextRange(info.interFaceType, updateSourceFile);\n\t\t\t\t// });\n\t\t\t\t// statements.push(...interfaces);\n\t\t\t\t// statements.push(...updateGlobalHTMLElementTagNameMap(sourceViewInfos.map(v => ({ tagName: v.selector, viewName: v.viewName }))));\n\t\t\t\tstatements.push(...updateModule(classes));\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\nexport default afterDeclarationsCompileComponentOptions;\n"]}
|
|
@@ -5,5 +5,4 @@ import ts from 'typescript/lib/tsserverlibrary.js';
|
|
|
5
5
|
* @returns a transformer factory of source file
|
|
6
6
|
*/
|
|
7
7
|
export declare function afterDeclarationsCompileComponentOptions(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
|
|
8
|
-
export default afterDeclarationsCompileComponentOptions;
|
|
9
8
|
//# sourceMappingURL=after-declarations-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"after-declarations-component.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAKnD;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"after-declarations-component.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAKnD;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAiElH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
-
import { createStaticPropertyViewType,
|
|
2
|
+
import { createStaticPropertyViewType, updateModuleTypeWithComponentView } from './factory.js';
|
|
3
3
|
import { moduleManger } from './modules.js';
|
|
4
4
|
/**
|
|
5
5
|
* search for `@Component({})` and update definition files
|
|
@@ -11,14 +11,10 @@ export function afterDeclarationsCompileComponentOptions(program) {
|
|
|
11
11
|
return (context) => {
|
|
12
12
|
return sourceFile => {
|
|
13
13
|
const moduleInfo = moduleManger.get(sourceFile.fileName);
|
|
14
|
-
|
|
15
|
-
if (!moduleInfo) {
|
|
14
|
+
if (!moduleInfo?.classes?.length) {
|
|
16
15
|
return sourceFile;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
return sourceFile;
|
|
20
|
-
}
|
|
21
|
-
const classes = moduleInfo.classes;
|
|
17
|
+
const classes = moduleInfo.classes.filter(c => c.type === 'component');
|
|
22
18
|
const sourceViewInfos = classes.flatMap(c => c.views);
|
|
23
19
|
const updateSourceFile = ts.visitNode(sourceFile, (node) => {
|
|
24
20
|
return ts.visitEachChild(node, (childNode) => {
|
|
@@ -45,12 +41,11 @@ export function afterDeclarationsCompileComponentOptions(program) {
|
|
|
45
41
|
// });
|
|
46
42
|
// statements.push(...interfaces);
|
|
47
43
|
// statements.push(...updateGlobalHTMLElementTagNameMap(sourceViewInfos.map(v => ({ tagName: v.selector, viewName: v.viewName }))));
|
|
48
|
-
statements.push(...
|
|
44
|
+
statements.push(...updateModuleTypeWithComponentView(classes));
|
|
49
45
|
return ts.factory.updateSourceFile(sourceFile, statements, updateSourceFile.isDeclarationFile, updateSourceFile.typeReferenceDirectives, updateSourceFile.referencedFiles, updateSourceFile.hasNoDefaultLib, updateSourceFile.libReferenceDirectives);
|
|
50
46
|
}
|
|
51
47
|
return updateSourceFile;
|
|
52
48
|
};
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
|
-
export default afterDeclarationsCompileComponentOptions;
|
|
56
51
|
//# sourceMappingURL=after-declarations-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"after-declarations-component.js","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,
|
|
1
|
+
{"version":3,"file":"after-declarations-component.js","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAY,MAAM,cAAc,CAAC;AAGtD;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CAAC,OAAmB;IAC3E,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAC7C,OAAO,CAAC,OAAiC,EAAiC,EAAE;QAC3E,OAAO,UAAU,CAAC,EAAE;YACnB,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACzD,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EA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E,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;oBACjE,OAAO,EAAE,CAAC,OAAO,CAAC,sBAAsB,CACvC,SAAS,EACT,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,cAAc,EACxB,SAAS,CAAC,eAAe,EACzB,CAAC,GAAG,aAAa,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAChD,CAAC;gBACH,CAAC,EAAE,OAAO,CAAC,CAAC;YACb,CAAC,CAAkB,CAAC;YACpB,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;gBAC5B,MAAM,UAAU,GAAG,gBAAgB,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBAC9D,kEAAkE;gBAClE,mDAAmD;gBACnD,iEAAiE;gBACjE,MAAM;gBACN,kCAAkC;gBAClC,oIAAoI;gBACpI,UAAU,CAAC,IAAI,CAAC,GAAG,iCAAiC,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC/D,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 { createStaticPropertyViewType, updateModuleTypeWithComponentView } from './factory.js';\nimport { moduleManger, ViewInfo } from './modules.js';\n\n\n/**\n * search for `@Component({})` and update definition files\n * @param program a ts program \n * @returns a transformer factory of source file\n */\nexport function afterDeclarationsCompileComponentOptions(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\tconst moduleInfo = moduleManger.get(sourceFile.fileName);\n\t\t\tif (!moduleInfo?.classes?.length) {\n\t\t\t\treturn sourceFile;\n\t\t\t}\n\n\t\t\tconst classes = moduleInfo.classes.filter(c => c.type === 'component');\n\n\t\t\tconst sourceViewInfos: ViewInfo[] = classes.flatMap(c => c.views);\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\tif (!ts.isClassDeclaration(childNode)) {\n\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t}\n\t\t\t\t\tconst info = classes.find(c => c.name === childNode.name?.getText());\n\n\t\t\t\t\tif (!info) {\n\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t}\n\t\t\t\t\tconst viewInfos: ViewInfo[] = info.views;\n\t\t\t\t\tconst staticMembers = viewInfos.map(viewInfo => ts.factory.createPropertyDeclaration(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tts.factory.createModifier(ts.SyntaxKind.StaticKeyword),\n\t\t\t\t\t\t\tts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)\n\t\t\t\t\t\t],\n\t\t\t\t\t\tviewInfo.viewName,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tcreateStaticPropertyViewType(viewInfo.viewName),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t)).map(staticMember => ts.setTextRange(staticMember, childNode));\n\t\t\t\t\treturn ts.factory.updateClassDeclaration(\n\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\tchildNode.modifiers,\n\t\t\t\t\t\tchildNode.name,\n\t\t\t\t\t\tchildNode.typeParameters,\n\t\t\t\t\t\tchildNode.heritageClauses,\n\t\t\t\t\t\t[...staticMembers, ...childNode.members.slice()],\n\t\t\t\t\t);\n\t\t\t\t}, context);\n\t\t\t}) as ts.SourceFile;\n\t\t\tif (sourceViewInfos.length) {\n\t\t\t\tconst statements = updateSourceFile.statements?.slice() ?? [];\n\t\t\t\t// statements.push(createConstructorOfViewInterfaceDeclaration());\n\t\t\t\t// const interfaces = sourceViewInfos.map(info => {\n\t\t\t\t// \treturn ts.setTextRange(info.interFaceType, updateSourceFile);\n\t\t\t\t// });\n\t\t\t\t// statements.push(...interfaces);\n\t\t\t\t// statements.push(...updateGlobalHTMLElementTagNameMap(sourceViewInfos.map(v => ({ tagName: v.selector, viewName: v.viewName }))));\n\t\t\t\tstatements.push(...updateModuleTypeWithComponentView(classes));\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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
/**
|
|
3
|
+
* search for `@Directive({})` and update definition files
|
|
4
|
+
* @param program a ts program
|
|
5
|
+
* @returns a transformer factory of source file
|
|
6
|
+
*/
|
|
7
|
+
export declare function afterDeclarationsCompileDirectiveOptions(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
|
|
8
|
+
//# sourceMappingURL=after-declarations-directie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-declarations-directie.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-directie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAKnD;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CA0BlH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
import { updateModuleTypeWithDirectives } from './factory.js';
|
|
3
|
+
import { moduleManger } from './modules.js';
|
|
4
|
+
/**
|
|
5
|
+
* search for `@Directive({})` and update definition files
|
|
6
|
+
* @param program a ts program
|
|
7
|
+
* @returns a transformer factory of source file
|
|
8
|
+
*/
|
|
9
|
+
export function afterDeclarationsCompileDirectiveOptions(program) {
|
|
10
|
+
return (context) => {
|
|
11
|
+
return sourceFile => {
|
|
12
|
+
const moduleInfo = moduleManger.get(sourceFile.fileName);
|
|
13
|
+
if (!moduleInfo?.classes?.length) {
|
|
14
|
+
return sourceFile;
|
|
15
|
+
}
|
|
16
|
+
const classes = moduleInfo.classes.filter(c => c.type === 'directive');
|
|
17
|
+
if (!(classes.length > 0)) {
|
|
18
|
+
return sourceFile;
|
|
19
|
+
}
|
|
20
|
+
const statements = sourceFile.statements?.slice() ?? [];
|
|
21
|
+
statements.push(...updateModuleTypeWithDirectives(classes));
|
|
22
|
+
return ts.factory.updateSourceFile(sourceFile, statements, sourceFile.isDeclarationFile, sourceFile.typeReferenceDirectives, sourceFile.referencedFiles, sourceFile.hasNoDefaultLib, sourceFile.libReferenceDirectives);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=after-declarations-directie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-declarations-directie.js","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-directie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CAAC,OAAmB;IAC3E,OAAO,CAAC,OAAiC,EAAiC,EAAE;QAC3E,OAAO,UAAU,CAAC,EAAE;YACnB,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACzD,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;gBAClC,OAAO,UAAU,CAAC;YACnB,CAAC;YAED,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;YACvE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC3B,OAAO,UAAU,CAAC;YACnB,CAAC;YAED,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACxD,UAAU,CAAC,IAAI,CAAC,GAAG,8BAA8B,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5D,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,CACjC,UAAU,EACV,UAAU,EACV,UAAU,CAAC,iBAAiB,EAC5B,UAAU,CAAC,uBAAuB,EAClC,UAAU,CAAC,eAAe,EAC1B,UAAU,CAAC,eAAe,EAC1B,UAAU,CAAC,sBAAsB,CACjC,CAAC;QACH,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { updateModuleTypeWithDirectives } from './factory.js';\nimport { moduleManger } from './modules.js';\n\n\n/**\n * search for `@Directive({})` and update definition files\n * @param program a ts program \n * @returns a transformer factory of source file\n */\nexport function afterDeclarationsCompileDirectiveOptions(program: ts.Program): ts.TransformerFactory<ts.SourceFile> {\n\treturn (context: ts.TransformationContext): ts.Transformer<ts.SourceFile> => {\n\t\treturn sourceFile => {\n\t\t\tconst moduleInfo = moduleManger.get(sourceFile.fileName);\n\t\t\tif (!moduleInfo?.classes?.length) {\n\t\t\t\treturn sourceFile;\n\t\t\t}\n\n\t\t\tconst classes = moduleInfo.classes.filter(c => c.type === 'directive');\n\t\t\tif (!(classes.length > 0)) {\n\t\t\t\treturn sourceFile;\n\t\t\t}\n\n\t\t\tconst statements = sourceFile.statements?.slice() ?? [];\n\t\t\tstatements.push(...updateModuleTypeWithDirectives(classes));\n\t\t\treturn ts.factory.updateSourceFile(\n\t\t\t\tsourceFile,\n\t\t\t\tstatements,\n\t\t\t\tsourceFile.isDeclarationFile,\n\t\t\t\tsourceFile.typeReferenceDirectives,\n\t\t\t\tsourceFile.referencedFiles,\n\t\t\t\tsourceFile.hasNoDefaultLib,\n\t\t\t\tsourceFile.libReferenceDirectives,\n\t\t\t);\n\t\t};\n\t};\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
/**
|
|
3
|
+
* search for `@Component({})` and precompile the source code
|
|
4
|
+
* @param program a ts program
|
|
5
|
+
* @returns a transformer factory of source file
|
|
6
|
+
*/
|
|
7
|
+
export declare function beforeCompileComponentOptions(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
|
|
8
|
+
export default beforeCompileComponentOptions;
|
|
9
|
+
//# sourceMappingURL=before-component%20copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"before-component copy.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/before-component copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAkBnD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAoOvG;AAED,eAAe,6BAA6B,CAAC"}
|