@ibyar/cli 2.1.2 → 2.2.1
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 +59 -6
- package/bin/cli.js +13 -12
- package/bin/cli.js.map +1 -1
- package/compiler/compiler.d.ts +4 -1
- package/compiler/compiler.d.ts.map +1 -1
- package/compiler/compiler.js +43 -11
- package/compiler/compiler.js.map +1 -1
- package/index.d.ts +8 -0
- package/index.d.ts.map +1 -1
- package/index.js +8 -0
- package/index.js.map +1 -1
- package/package.json +8 -8
- package/transformer/after-declarations-directive.d.ts +8 -0
- package/transformer/after-declarations-directive.d.ts.map +1 -0
- package/transformer/after-declarations-directive.js +26 -0
- package/transformer/after-declarations-directive.js.map +1 -0
- package/transformer/factory.d.ts +2 -2
- package/transformer/factory.js +2 -2
- package/transformer/factory.js.map +1 -1
- package/transformer/helpers.d.ts +2 -0
- package/transformer/helpers.d.ts.map +1 -1
- package/transformer/helpers.js +55 -19
- package/transformer/helpers.js.map +1 -1
- package/transformer/modules.d.ts.map +1 -1
- package/transformer/modules.js +0 -6
- package/transformer/modules.js.map +1 -1
- package/webpack/loader.d.ts +7 -0
- package/webpack/loader.d.ts.map +1 -0
- package/webpack/loader.js +47 -0
- package/webpack/loader.js.map +1 -0
package/README.md
CHANGED
|
@@ -41,24 +41,77 @@ Usage: ibyar [options]
|
|
|
41
41
|
Examples:
|
|
42
42
|
ibyar
|
|
43
43
|
ibyar -b
|
|
44
|
-
|
|
44
|
+
ibyar -b -w
|
|
45
45
|
ibyar -gt
|
|
46
46
|
ibyar -v
|
|
47
47
|
ibyar --help
|
|
48
48
|
|
|
49
49
|
Options:
|
|
50
50
|
-b --build compile the project source code with ibyar transformers
|
|
51
|
+
and generate '.d.ts' files with created Custom HTML Element definitions.
|
|
51
52
|
-w --watch compile and watch source files, used with --build
|
|
52
|
-
-gt --generate-types generate "web-types.json" files, and typescript
|
|
53
|
-
definitions '.d.ts' files.
|
|
54
|
-
you can import this file later in your "index.ts"
|
|
55
|
-
or "polyfills.ts" file, so any editor "VS Code" can
|
|
56
|
-
support autocomplete easily,
|
|
57
53
|
-h --help print help message
|
|
58
54
|
-v --version output the version number
|
|
59
55
|
```
|
|
60
56
|
|
|
61
57
|
|
|
58
|
+
## WebPack Bundle
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
- add webpack loader
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
module.exports = {
|
|
65
|
+
entry: './src/index.ts',
|
|
66
|
+
module: {
|
|
67
|
+
exprContextCritical: false,
|
|
68
|
+
rules: [
|
|
69
|
+
{
|
|
70
|
+
test: /\.tsx?$/,
|
|
71
|
+
use: ['@ibyar/cli',],
|
|
72
|
+
exclude: /node_modules/,
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Rollup Bundle
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import typescript from '@rollup/plugin-typescript';
|
|
83
|
+
import {
|
|
84
|
+
beforeCompileDirectiveOptions, beforeCompileComponentOptions,
|
|
85
|
+
afterDeclarationsCompileComponentOptions,
|
|
86
|
+
afterDeclarationsCompileDirectiveOptions,
|
|
87
|
+
scanDirectivesOnceAsTransformer,
|
|
88
|
+
} from '@ibyar/cli';
|
|
89
|
+
|
|
90
|
+
export default = {
|
|
91
|
+
...,
|
|
92
|
+
plugins: [
|
|
93
|
+
nodeResolve(),
|
|
94
|
+
typescript({
|
|
95
|
+
transformers: {
|
|
96
|
+
before: [
|
|
97
|
+
{ type: 'program', factory: scanDirectivesOnceAsTransformer() },
|
|
98
|
+
{ type: 'program', factory: beforeCompileDirectiveOptions },
|
|
99
|
+
{ type: 'program', factory: beforeCompileComponentOptions },
|
|
100
|
+
],
|
|
101
|
+
after: [],
|
|
102
|
+
afterDeclarations: [
|
|
103
|
+
{ type: 'program', factory: afterDeclarationsCompileComponentOptions },
|
|
104
|
+
{ type: 'program', factory: afterDeclarationsCompileDirectiveOptions },
|
|
105
|
+
],
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
html({ include: "**/*.html" }),
|
|
109
|
+
css({ output: 'style.css' }),
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
|
|
62
115
|
|
|
63
116
|
The Ibyar CLI has a typescript transformer to generate a definitions for you component
|
|
64
117
|
|
package/bin/cli.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { join } from 'path';
|
|
2
3
|
import { exit } from 'process';
|
|
3
|
-
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
4
6
|
const args = process.argv;
|
|
5
7
|
const inputs = args.slice(2);
|
|
6
8
|
const showHelp = inputs.includes('-h') || inputs.includes('--help');
|
|
7
9
|
const printVersion = inputs.length === 1 && (inputs.includes('-v') || inputs.includes('--version'));
|
|
8
10
|
const runBuild = inputs.includes('-b') || inputs.includes('--build');
|
|
9
|
-
const generateTypes = inputs.includes('-gt') || inputs.includes('--generate-types');
|
|
10
11
|
if (showHelp) {
|
|
11
12
|
const help = `
|
|
12
|
-
Version ${
|
|
13
|
+
Version ${readPackageVersion()}
|
|
13
14
|
Usage: ibyar [options]
|
|
14
15
|
|
|
15
16
|
Examples:
|
|
@@ -22,19 +23,15 @@ Examples:
|
|
|
22
23
|
|
|
23
24
|
Options:
|
|
24
25
|
-b --build compile the project source code with ibyar transformers
|
|
26
|
+
and generate '.d.ts' files with created Custom HTML Element definitions.
|
|
25
27
|
-w --watch compile and watch source files, used with --build
|
|
26
|
-
-gt --generate-types generate "web-types.json" files, and typescript
|
|
27
|
-
definitions '.d.ts' files.
|
|
28
|
-
you can import this file later in your "index.ts"
|
|
29
|
-
or "polyfills.ts" file, so any editor "VS Code" can
|
|
30
|
-
support autocomplete easily,
|
|
31
28
|
-h --help print help message
|
|
32
29
|
-v --version output the version number`;
|
|
33
30
|
console.log(help);
|
|
34
31
|
exit();
|
|
35
32
|
}
|
|
36
33
|
if (printVersion) {
|
|
37
|
-
console.log(
|
|
34
|
+
console.log(readPackageVersion());
|
|
38
35
|
}
|
|
39
36
|
if (runBuild) {
|
|
40
37
|
import('../compiler/compiler.js').then(module => {
|
|
@@ -44,9 +41,13 @@ if (runBuild) {
|
|
|
44
41
|
else {
|
|
45
42
|
module.compileArgs();
|
|
46
43
|
}
|
|
47
|
-
});
|
|
44
|
+
}).catch(error => console.error(error));
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
function readPackageVersion() {
|
|
47
|
+
const url = fileURLToPath(import.meta.url);
|
|
48
|
+
const path = join(url, '..', '..', 'package.json');
|
|
49
|
+
const string = readFileSync(path, 'utf-8').toString();
|
|
50
|
+
const { version } = JSON.parse(string);
|
|
51
|
+
return version;
|
|
51
52
|
}
|
|
52
53
|
//# sourceMappingURL=cli.js.map
|
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;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli/bin/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,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Ac,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAwB,CAAC;IAC9D,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { join } from 'path';\nimport { exit } from 'process';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\n\nconst args = process.argv;\nconst inputs = args.slice(2);\n\nconst showHelp = inputs.includes('-h') || inputs.includes('--help');\nconst printVersion = inputs.length === 1 && (inputs.includes('-v') || inputs.includes('--version'));\n\nconst runBuild = inputs.includes('-b') || inputs.includes('--build');\n\nif (showHelp) {\n\tconst help =\n\t\t`\nVersion ${readPackageVersion()}\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 and generate '.d.ts' files with created Custom HTML Element definitions.\n\t-w\t\t--watch\t\t\t\tcompile and watch source files, used with --build\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(readPackageVersion());\n}\n\nif (runBuild) {\n\timport('../compiler/compiler.js').then(module => {\n\t\tif (inputs.includes('-w') || inputs.includes('--watch')) {\n\t\t\tmodule.compileAndWatchArgs();\n\t\t} else {\n\t\t\tmodule.compileArgs();\n\t\t}\n\t}).catch(error => console.error(error));\n}\n\nfunction readPackageVersion(): string {\n\tconst url = fileURLToPath(import.meta.url);\n\tconst path = join(url, '..', '..', 'package.json');\n\tconst string = readFileSync(path, 'utf-8').toString();\n\tconst { version } = JSON.parse(string) as { version: string };\n\treturn version;\n}\n"]}
|
package/compiler/compiler.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import '../directives/register.js';
|
|
2
2
|
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getTransformers(program: ts.Program): ts.CustomTransformers;
|
|
4
|
+
export declare function scanDirectives(program: ts.Program): void;
|
|
5
|
+
export declare function scanDirectivesOnceAsTransformer(): (program: ts.Program) => (context: ts.TransformationContext) => ts.Transformer<ts.SourceFile>;
|
|
4
6
|
export declare function emitProgram(program: ts.Program): void;
|
|
5
7
|
export declare function compileFiles(files: readonly string[], options: ts.CompilerOptions): void;
|
|
6
8
|
export declare function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine): void;
|
|
9
|
+
export declare function getConfigPath(): string;
|
|
7
10
|
export declare function compileArgs(): void;
|
|
8
11
|
export declare function compileAndWatchArgs(): void;
|
|
9
12
|
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -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,
|
|
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"}
|
package/compiler/compiler.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import '../directives/register.js';
|
|
2
2
|
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
3
3
|
import { afterDeclarationsCompileComponentOptions } from '../transformer/after-declarations-component.js';
|
|
4
|
-
import { afterDeclarationsCompileDirectiveOptions } from '../transformer/after-declarations-
|
|
4
|
+
import { afterDeclarationsCompileDirectiveOptions } from '../transformer/after-declarations-directive.js';
|
|
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
|
-
export function
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export function emitProgram(program) {
|
|
12
|
-
scanDirective(program);
|
|
13
|
-
program.emit(undefined, undefined, undefined, undefined, {
|
|
8
|
+
export function getTransformers(program) {
|
|
9
|
+
return {
|
|
14
10
|
before: [
|
|
15
11
|
beforeCompileDirectiveOptions(program),
|
|
16
12
|
beforeCompileComponentOptions(program),
|
|
@@ -20,22 +16,58 @@ export function emitProgram(program) {
|
|
|
20
16
|
afterDeclarationsCompileComponentOptions(program),
|
|
21
17
|
afterDeclarationsCompileDirectiveOptions(program),
|
|
22
18
|
],
|
|
23
|
-
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function scanDirectives(program) {
|
|
22
|
+
program.getSourceFiles().forEach(scanDirectivesTypeVisitor);
|
|
23
|
+
}
|
|
24
|
+
export function scanDirectivesOnceAsTransformer() {
|
|
25
|
+
let scanDone = false;
|
|
26
|
+
let ignoreTransformer = (context) => sourceFile => sourceFile;
|
|
27
|
+
return (program) => {
|
|
28
|
+
if (scanDone) {
|
|
29
|
+
return ignoreTransformer;
|
|
30
|
+
}
|
|
31
|
+
scanDone = true;
|
|
32
|
+
scanDirectives(program);
|
|
33
|
+
return ignoreTransformer;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function emitProgram(program) {
|
|
37
|
+
scanDirectives(program);
|
|
38
|
+
program.emit(undefined, undefined, undefined, undefined, getTransformers(program));
|
|
24
39
|
}
|
|
25
40
|
export function compileFiles(files, options) {
|
|
26
41
|
const host = ts.createCompilerHost(options);
|
|
27
42
|
const program = ts.createProgram(files, options, host);
|
|
28
43
|
emitProgram(program);
|
|
29
44
|
}
|
|
45
|
+
const formatHost = {
|
|
46
|
+
getCanonicalFileName: path => path,
|
|
47
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
48
|
+
getNewLine: () => ts.sys.newLine
|
|
49
|
+
};
|
|
50
|
+
function reportDiagnostic(diagnostic) {
|
|
51
|
+
console.error("Error", diagnostic.code, ":", ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Prints a diagnostic every time the watch status changes.
|
|
55
|
+
* This is mainly for messages like "Starting compilation" or "Compilation completed".
|
|
56
|
+
*/
|
|
57
|
+
function reportWatchStatusChanged(diagnostic) {
|
|
58
|
+
console.info(ts.formatDiagnostic(diagnostic, formatHost));
|
|
59
|
+
}
|
|
30
60
|
export function compileAndWatchFiles(configPath, cmd) {
|
|
31
|
-
const
|
|
61
|
+
const createProgram = ts.createSemanticDiagnosticsBuilderProgram;
|
|
62
|
+
const host = ts.createWatchCompilerHost(configPath, cmd.options, ts.sys, createProgram, reportDiagnostic, reportWatchStatusChanged, cmd.watchOptions);
|
|
32
63
|
const programFactory = ts.createWatchProgram(host);
|
|
33
64
|
const programBuilder = programFactory.getProgram();
|
|
34
65
|
const program = programBuilder.getProgram();
|
|
35
66
|
emitProgram(program);
|
|
36
67
|
}
|
|
37
|
-
function getConfigPath() {
|
|
38
|
-
const
|
|
68
|
+
export function getConfigPath() {
|
|
69
|
+
const tsconfig = process.argv.slice(2).filter(arg => arg.includes('tsconfig'))[0];
|
|
70
|
+
const configPath = ts.findConfigFile('./', /*searchPath*/ ts.sys.fileExists, tsconfig ?? 'tsconfig.json');
|
|
39
71
|
if (!configPath) {
|
|
40
72
|
throw new Error("Could not find a valid 'tsconfig.json'.");
|
|
41
73
|
}
|
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,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,wCAAwC,EAAE,MAAM
|
|
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,KA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AC,GAAG,CAAC,UAAU,EACjB,QAAQ,IAAI,eAAe,CAC3B,CAAC;IACF,IAAI,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"]}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export * from './transformer/factory.js';
|
|
2
|
+
export * from './transformer/helpers.js';
|
|
3
|
+
export * from './transformer/modules.js';
|
|
2
4
|
export * from './transformer/before-component.js';
|
|
5
|
+
export * from './transformer/before-directive.js';
|
|
3
6
|
export * from './transformer/after-declarations-component.js';
|
|
7
|
+
export * from './transformer/after-declarations-directive.js';
|
|
8
|
+
export * from './directives/register.js';
|
|
4
9
|
export * from './compiler/compiler.js';
|
|
5
10
|
export * from './elements/tags.js';
|
|
11
|
+
export * from './webpack/loader.js';
|
|
12
|
+
import { loader } from './webpack/loader.js';
|
|
13
|
+
export default loader;
|
|
6
14
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,eAAe,MAAM,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export * from './transformer/factory.js';
|
|
2
|
+
export * from './transformer/helpers.js';
|
|
3
|
+
export * from './transformer/modules.js';
|
|
2
4
|
export * from './transformer/before-component.js';
|
|
5
|
+
export * from './transformer/before-directive.js';
|
|
3
6
|
export * from './transformer/after-declarations-component.js';
|
|
7
|
+
export * from './transformer/after-declarations-directive.js';
|
|
8
|
+
export * from './directives/register.js';
|
|
4
9
|
export * from './compiler/compiler.js';
|
|
5
10
|
export * from './elements/tags.js';
|
|
11
|
+
export * from './webpack/loader.js';
|
|
12
|
+
import { loader } from './webpack/loader.js';
|
|
13
|
+
export default loader;
|
|
6
14
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,eAAe,MAAM,CAAC","sourcesContent":["export * from './transformer/factory.js';\nexport * from './transformer/helpers.js';\nexport * from './transformer/modules.js';\nexport * from './transformer/before-component.js';\nexport * from './transformer/before-directive.js';\nexport * from './transformer/after-declarations-component.js';\nexport * from './transformer/after-declarations-directive.js';\nexport * from './directives/register.js';\nexport * from './compiler/compiler.js';\nexport * from './elements/tags.js';\nexport * from './webpack/loader.js';\n\nimport { loader } from './webpack/loader.js';\nexport default loader;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/cli",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "The Ibyar/Aurora CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ibyar/aurora",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ibyar/core": "^2.1
|
|
40
|
-
"@ibyar/decorators": "^2.1
|
|
41
|
-
"@ibyar/directives": "^2.1
|
|
42
|
-
"@ibyar/elements": "^2.1
|
|
43
|
-
"@ibyar/expressions": "^2.1
|
|
44
|
-
"@ibyar/pipes": "^2.1
|
|
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
45
|
"tslib": "^2.6.3",
|
|
46
46
|
"typescript": "^5.5.2"
|
|
47
47
|
},
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"shadow-dom",
|
|
75
75
|
"typescript"
|
|
76
76
|
],
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "6c3b1c8d19faf00022c58ba2b893f4bb56147600"
|
|
78
78
|
}
|
|
@@ -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-directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-declarations-directive.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-directive.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-directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-declarations-directive.js","sourceRoot":"","sources":["../../../src/cli/transformer/after-declarations-directive.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"]}
|
package/transformer/factory.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare function updateModuleTypeWithComponentView(classes: ClassInfo[]):
|
|
|
38
38
|
*
|
|
39
39
|
* example:
|
|
40
40
|
* ```ts
|
|
41
|
-
* export type ɵɵ
|
|
41
|
+
* export type ɵɵ0IfDirective0ɵɵ = {
|
|
42
42
|
* selector: '*if';
|
|
43
43
|
* successor: '*else',
|
|
44
44
|
* inputs: [
|
|
@@ -47,7 +47,7 @@ export declare function updateModuleTypeWithComponentView(classes: ClassInfo[]):
|
|
|
47
47
|
* { name: 'elseTemplateRef', aliasName: 'else' },
|
|
48
48
|
* ],
|
|
49
49
|
* outputs: [],
|
|
50
|
-
* }
|
|
50
|
+
* };
|
|
51
51
|
* ```
|
|
52
52
|
* @param classes directive class information
|
|
53
53
|
* @returns new array of statements
|
package/transformer/factory.js
CHANGED
|
@@ -126,7 +126,7 @@ export function updateModuleTypeWithComponentView(classes) {
|
|
|
126
126
|
*
|
|
127
127
|
* example:
|
|
128
128
|
* ```ts
|
|
129
|
-
* export type ɵɵ
|
|
129
|
+
* export type ɵɵ0IfDirective0ɵɵ = {
|
|
130
130
|
* selector: '*if';
|
|
131
131
|
* successor: '*else',
|
|
132
132
|
* inputs: [
|
|
@@ -135,7 +135,7 @@ export function updateModuleTypeWithComponentView(classes) {
|
|
|
135
135
|
* { name: 'elseTemplateRef', aliasName: 'else' },
|
|
136
136
|
* ],
|
|
137
137
|
* outputs: [],
|
|
138
|
-
* }
|
|
138
|
+
* };
|
|
139
139
|
* ```
|
|
140
140
|
* @param classes directive class information
|
|
141
141
|
* @returns new array of statements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/cli/transformer/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD,MAAM,UAAU,mBAAmB,CAAC,IAA4B;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAU;IACtD,OAAO,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAU;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IACD,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC5D,KAAK,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC7D,KAAK,QAAQ,CAAC,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CAAC;QACD,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,aAAa,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,iBAAiB,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YACrD,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;QAClB,iBAAiB,GAAG,iBAAiB,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;aACxD,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aAC1D,IAAI,CAAC,EAAE,CAAC,CAAC;QACX,OAAO,kBAAkB,WAAW,CAAC,iBAAiB,CAAC,mBAAmB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IAC9F,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { ToCamelCase } from '@ibyar/core/node.js';\nimport { ClassInfo } from './modules.js';\n\n\nexport function convertToProperties(json: { [key: string]: any }): ts.ObjectLiteralElementLike[] {\n\tconst keys = Object.keys(json);\n\treturn keys.map(key => createProperty(key, json[key]));\n}\n\nexport function createProperty(name: string, value: any): ts.ObjectLiteralElementLike {\n\treturn ts.factory.createPropertyAssignment(name, createInitializer(value));\n}\n\nexport function createInitializer(value: any): ts.Expression {\n\tif (Array.isArray(value)) {\n\t\tconst elements = value.map(createInitializer);\n\t\treturn ts.factory.createArrayLiteralExpression(elements);\n\t}\n\tswitch (typeof value) {\n\t\tcase 'string': return ts.factory.createStringLiteral(value);\n\t\tcase 'number': return ts.factory.createNumericLiteral(value);\n\t\tcase 'bigint': return ts.factory.createBigIntLiteral(value.toString());\n\t\tcase 'boolean': return value ? ts.factory.createTrue() : ts.factory.createFalse();\n\t\tcase 'object': {\n\t\t\tif (!value) {\n\t\t\t\treturn ts.factory.createNull();\n\t\t\t}\n\t\t\tconst properties = convertToProperties(value);\n\t\t\treturn ts.factory.createObjectLiteralExpression(properties);\n\t\t};\n\t}\n\treturn ts.factory.createNull();\n}\n\n\nexport function createInterfaceType(viewName: string, extendsType: string) {\n\tconst identifier = ts.factory.createIdentifier(extendsType);\n\tconst expressionWithTypeArguments = ts.factory.createExpressionWithTypeArguments(identifier, undefined);\n\tconst heritageClause = ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [expressionWithTypeArguments]);\n\treturn ts.factory.createInterfaceDeclaration(undefined, viewName, undefined, [heritageClause], []);\n\t// const exportModifier: ts.ModifierSyntaxKind = ts.SyntaxKind.ExportKeyword;\n\t// const modifier = ts.factory.createModifier(exportModifier);\n\t// return ts.factory.createInterfaceDeclaration([modifier], viewName, undefined, [heritageClause], []);\n}\n\nexport function createTypeLiteral(typeName: string) {\n\tconst members: ts.TypeElement[] = [\n\t\tts.factory.createConstructSignature(undefined, [], ts.factory.createTypeReferenceNode(typeName)),\n\t\tts.factory.createPropertySignature(\n\t\t\t[ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],\n\t\t\t'prototype',\n\t\t\tundefined,\n\t\t\tts.factory.createTypeReferenceNode(typeName)\n\t\t),\n\t];\n\treturn ts.factory.createTypeLiteralNode(members);\n}\n\n/**\n * create view constructor interface of Type `T`\n * \n * ```ts\n * interface ConstructorOfView<T> {\n * \tnew(): T;\n * \treadonly prototype: T;\n * }\n * ```\n */\nexport function createConstructorOfViewInterfaceDeclaration() {\n\tconst typeParameter = ts.factory.createTypeParameterDeclaration(undefined, 'T');\n\tconst members: ts.TypeElement[] = [\n\t\tts.factory.createConstructSignature(undefined, [], ts.factory.createTypeReferenceNode('T')),\n\t\tts.factory.createPropertySignature(\n\t\t\t[ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],\n\t\t\t'prototype',\n\t\t\tundefined,\n\t\t\tts.factory.createTypeReferenceNode('T')\n\t\t),\n\t];\n\treturn ts.factory.createInterfaceDeclaration(undefined, 'ConstructorOfView', [typeParameter], undefined, members);\n}\n\nexport function createStaticPropertyViewType(typeName: string) {\n\tconst typeArgument = ts.factory.createTypeReferenceNode(typeName);\n\treturn ts.factory.createTypeReferenceNode('ConstructorOfView', [typeArgument]);\n}\n\n\nexport function generateStatements(sourceText: string, scriptTarget = ts.ScriptTarget.ES2020, scriptKind = ts.ScriptKind.TS): ts.NodeArray<ts.Statement> {\n\treturn ts.createSourceFile('temp', sourceText, scriptTarget, false, scriptKind).statements;\n}\n\nexport function generateNode<T = ts.Node>(sourceText: string, scriptTarget = ts.ScriptTarget.ES2020, scriptKind = ts.ScriptKind.TS): T {\n\treturn generateStatements(sourceText, scriptTarget, scriptKind)[0] as T;\n}\n\n/**\n * declare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'user-view': HTMLUserViewElement;\n\t}\n}\n */\n\nexport function updateGlobalHTMLElementTagNameMap(views: { tagName: string, viewName: string }[]): ts.NodeArray<ts.Statement> {\n\tconst sourceCode = `\n\t\tdeclare global {\n\t\t\tinterface HTMLElementTagNameMap {\n\t\t\t\t${views.map(view => `['${view.tagName}']: ${view.viewName};`).join('\\n')}\n\t\t\t}\n\t\t}`;\n\treturn generateStatements(sourceCode);\n}\n\nexport function updateModuleTypeWithComponentView(classes: ClassInfo[]): ts.NodeArray<ts.Statement> {\n\tconst viewClassDeclarations = classes.map(c => {\n\t\tconst inputs = c.inputs.map(input => input.aliasName);\n\t\tconst outputs = c.outputs.map(input => input.aliasName).map(output => 'on' + ToCamelCase(output));\n\t\tconst attributes = [...inputs, ...outputs].map(s => `'${s}'`).join(' | ');\n\t\tconst interfaceBody = `\n\t\t\tpublic static observedAttributes: [${attributes}];\n\n\t\t\t${c.inputs.map(input => `public ${input.aliasName}${input.type ? `: ${input.type}` : ''};`).join('\\n')}\n\n\t\t\t${c.outputs.map(output => `public on${ToCamelCase(output.aliasName)}${output.type ? `: ${output.type}` : ''};`).join('\\n')}\n\t\t\t\n\t\t`;\n\t\t// need to fix @FormValue type;\n\t\treturn c.views.map(view => `\n\t\t\tdeclare class ${view.viewName} extends ${view.extendsType} {\n\t\t\t\t${interfaceBody.trim()}\n\t\t\t}\n\t\t\tdeclare interface ${view.viewName} extends ${view.formAssociated ? `BaseFormAssociatedComponent<${c.name}>, ` : ''}BaseComponent<${c.name}> {}\n\t\t`);\n\t});\n\tconst views = classes.flatMap(c => c.views.map(v => ({ tagName: v.selector, viewName: v.viewName })));\n\tconst sourceCode = `\n\t\timport { BaseComponent, BaseFormAssociatedComponent, ConstructorOfView } from '@ibyar/core';\n\t\t${viewClassDeclarations.join('\\n')}\n\t\tdeclare global {\n\t\t\tinterface HTMLElementTagNameMap {\n\t\t\t\t${views.map(view => `['${view.tagName}']: ${view.viewName};`).join('\\n')}\n\t\t\t}\n\t\t}`;\n\treturn generateStatements(sourceCode);\n}\n\n/**\n * create new type with name `ɵɵ0Directives0ɵɵ`\n * \n * example:\n * ```ts\n * export type ɵɵ0Directives0ɵɵ = [{\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 * \toutputs: [],\n * }];\n * ```\n * @param classes directive class information\n * @returns new array of statements\n */\nexport function updateModuleTypeWithDirectives(classes: ClassInfo[]): ts.NodeArray<ts.Statement> {\n\tconst nodes: string[] | undefined = classes.map(directive => {\n\t\tconst inputs: string[] = directive.inputs.map(input => `{name: '${input.name}', aliasName: '${input.aliasName}'}`);\n\t\tconst outputs: string[] = directive.outputs.map(output => `{name: '${output.name}', aliasName: '${output.aliasName}'}`);\n\t\tconst temp: string[] = [`selector: '${directive.name}'`];\n\t\tif (directive.successor) {\n\t\t\ttemp.push(`successor: '${directive.successor}'`);\n\t\t}\n\t\tif (directive.inputs.length > 0) {\n\t\t\ttemp.push(`inputs: [${inputs.join(',')}]`);\n\t\t}\n\t\tif (directive.outputs.length > 0) {\n\t\t\ttemp.push(`outputs: [${outputs.join(',')}]`);\n\t\t}\n\t\tlet directiveTypeName = directive.name.startsWith('*')\n\t\t\t? directive.name.substring(1)\n\t\t\t: directive.name;\n\t\tdirectiveTypeName = directiveTypeName.replaceAll('-', ' ')\n\t\t\t.split(' ')\n\t\t\t.map(str => str.charAt(0).toUpperCase() + str.substring(1))\n\t\t\t.join('');\n\t\treturn `export type ɵɵ0${ToCamelCase(directiveTypeName)}Directive0ɵɵ = {${temp.join(',')}};`;\n\t});\n\treturn generateStatements(nodes.join());\n}\n"]}
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/cli/transformer/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD,MAAM,UAAU,mBAAmB,CAAC,IAA4B;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAU;IACtD,OAAO,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,iBAA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CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { ToCamelCase } from '@ibyar/core/node.js';\nimport { ClassInfo } from './modules.js';\n\n\nexport function convertToProperties(json: { [key: string]: any }): ts.ObjectLiteralElementLike[] {\n\tconst keys = Object.keys(json);\n\treturn keys.map(key => createProperty(key, json[key]));\n}\n\nexport function createProperty(name: string, value: any): ts.ObjectLiteralElementLike {\n\treturn ts.factory.createPropertyAssignment(name, createInitializer(value));\n}\n\nexport function createInitializer(value: any): ts.Expression {\n\tif (Array.isArray(value)) {\n\t\tconst elements = value.map(createInitializer);\n\t\treturn ts.factory.createArrayLiteralExpression(elements);\n\t}\n\tswitch (typeof value) {\n\t\tcase 'string': return ts.factory.createStringLiteral(value);\n\t\tcase 'number': return ts.factory.createNumericLiteral(value);\n\t\tcase 'bigint': return ts.factory.createBigIntLiteral(value.toString());\n\t\tcase 'boolean': return value ? ts.factory.createTrue() : ts.factory.createFalse();\n\t\tcase 'object': {\n\t\t\tif (!value) {\n\t\t\t\treturn ts.factory.createNull();\n\t\t\t}\n\t\t\tconst properties = convertToProperties(value);\n\t\t\treturn ts.factory.createObjectLiteralExpression(properties);\n\t\t};\n\t}\n\treturn ts.factory.createNull();\n}\n\n\nexport function createInterfaceType(viewName: string, extendsType: string) {\n\tconst identifier = ts.factory.createIdentifier(extendsType);\n\tconst expressionWithTypeArguments = ts.factory.createExpressionWithTypeArguments(identifier, undefined);\n\tconst heritageClause = ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [expressionWithTypeArguments]);\n\treturn ts.factory.createInterfaceDeclaration(undefined, viewName, undefined, [heritageClause], []);\n\t// const exportModifier: ts.ModifierSyntaxKind = ts.SyntaxKind.ExportKeyword;\n\t// const modifier = ts.factory.createModifier(exportModifier);\n\t// return ts.factory.createInterfaceDeclaration([modifier], viewName, undefined, [heritageClause], []);\n}\n\nexport function createTypeLiteral(typeName: string) {\n\tconst members: ts.TypeElement[] = [\n\t\tts.factory.createConstructSignature(undefined, [], ts.factory.createTypeReferenceNode(typeName)),\n\t\tts.factory.createPropertySignature(\n\t\t\t[ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],\n\t\t\t'prototype',\n\t\t\tundefined,\n\t\t\tts.factory.createTypeReferenceNode(typeName)\n\t\t),\n\t];\n\treturn ts.factory.createTypeLiteralNode(members);\n}\n\n/**\n * create view constructor interface of Type `T`\n * \n * ```ts\n * interface ConstructorOfView<T> {\n * \tnew(): T;\n * \treadonly prototype: T;\n * }\n * ```\n */\nexport function createConstructorOfViewInterfaceDeclaration() {\n\tconst typeParameter = ts.factory.createTypeParameterDeclaration(undefined, 'T');\n\tconst members: ts.TypeElement[] = [\n\t\tts.factory.createConstructSignature(undefined, [], ts.factory.createTypeReferenceNode('T')),\n\t\tts.factory.createPropertySignature(\n\t\t\t[ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],\n\t\t\t'prototype',\n\t\t\tundefined,\n\t\t\tts.factory.createTypeReferenceNode('T')\n\t\t),\n\t];\n\treturn ts.factory.createInterfaceDeclaration(undefined, 'ConstructorOfView', [typeParameter], undefined, members);\n}\n\nexport function createStaticPropertyViewType(typeName: string) {\n\tconst typeArgument = ts.factory.createTypeReferenceNode(typeName);\n\treturn ts.factory.createTypeReferenceNode('ConstructorOfView', [typeArgument]);\n}\n\n\nexport function generateStatements(sourceText: string, scriptTarget = ts.ScriptTarget.ES2020, scriptKind = ts.ScriptKind.TS): ts.NodeArray<ts.Statement> {\n\treturn ts.createSourceFile('temp', sourceText, scriptTarget, false, scriptKind).statements;\n}\n\nexport function generateNode<T = ts.Node>(sourceText: string, scriptTarget = ts.ScriptTarget.ES2020, scriptKind = ts.ScriptKind.TS): T {\n\treturn generateStatements(sourceText, scriptTarget, scriptKind)[0] as T;\n}\n\n/**\n * declare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'user-view': HTMLUserViewElement;\n\t}\n}\n */\n\nexport function updateGlobalHTMLElementTagNameMap(views: { tagName: string, viewName: string }[]): ts.NodeArray<ts.Statement> {\n\tconst sourceCode = `\n\t\tdeclare global {\n\t\t\tinterface HTMLElementTagNameMap {\n\t\t\t\t${views.map(view => `['${view.tagName}']: ${view.viewName};`).join('\\n')}\n\t\t\t}\n\t\t}`;\n\treturn generateStatements(sourceCode);\n}\n\nexport function updateModuleTypeWithComponentView(classes: ClassInfo[]): ts.NodeArray<ts.Statement> {\n\tconst viewClassDeclarations = classes.map(c => {\n\t\tconst inputs = c.inputs.map(input => input.aliasName);\n\t\tconst outputs = c.outputs.map(input => input.aliasName).map(output => 'on' + ToCamelCase(output));\n\t\tconst attributes = [...inputs, ...outputs].map(s => `'${s}'`).join(' | ');\n\t\tconst interfaceBody = `\n\t\t\tpublic static observedAttributes: [${attributes}];\n\n\t\t\t${c.inputs.map(input => `public ${input.aliasName}${input.type ? `: ${input.type}` : ''};`).join('\\n')}\n\n\t\t\t${c.outputs.map(output => `public on${ToCamelCase(output.aliasName)}${output.type ? `: ${output.type}` : ''};`).join('\\n')}\n\t\t\t\n\t\t`;\n\t\t// need to fix @FormValue type;\n\t\treturn c.views.map(view => `\n\t\t\tdeclare class ${view.viewName} extends ${view.extendsType} {\n\t\t\t\t${interfaceBody.trim()}\n\t\t\t}\n\t\t\tdeclare interface ${view.viewName} extends ${view.formAssociated ? `BaseFormAssociatedComponent<${c.name}>, ` : ''}BaseComponent<${c.name}> {}\n\t\t`);\n\t});\n\tconst views = classes.flatMap(c => c.views.map(v => ({ tagName: v.selector, viewName: v.viewName })));\n\tconst sourceCode = `\n\t\timport { BaseComponent, BaseFormAssociatedComponent, ConstructorOfView } from '@ibyar/core';\n\t\t${viewClassDeclarations.join('\\n')}\n\t\tdeclare global {\n\t\t\tinterface HTMLElementTagNameMap {\n\t\t\t\t${views.map(view => `['${view.tagName}']: ${view.viewName};`).join('\\n')}\n\t\t\t}\n\t\t}`;\n\treturn generateStatements(sourceCode);\n}\n\n/**\n * create new type with name `ɵɵ0Directives0ɵɵ`\n * \n * example:\n * ```ts\n * export type ɵɵ0IfDirective0ɵɵ = {\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 * \toutputs: [],\n * };\n * ```\n * @param classes directive class information\n * @returns new array of statements\n */\nexport function updateModuleTypeWithDirectives(classes: ClassInfo[]): ts.NodeArray<ts.Statement> {\n\tconst nodes: string[] | undefined = classes.map(directive => {\n\t\tconst inputs: string[] = directive.inputs.map(input => `{name: '${input.name}', aliasName: '${input.aliasName}'}`);\n\t\tconst outputs: string[] = directive.outputs.map(output => `{name: '${output.name}', aliasName: '${output.aliasName}'}`);\n\t\tconst temp: string[] = [`selector: '${directive.name}'`];\n\t\tif (directive.successor) {\n\t\t\ttemp.push(`successor: '${directive.successor}'`);\n\t\t}\n\t\tif (directive.inputs.length > 0) {\n\t\t\ttemp.push(`inputs: [${inputs.join(',')}]`);\n\t\t}\n\t\tif (directive.outputs.length > 0) {\n\t\t\ttemp.push(`outputs: [${outputs.join(',')}]`);\n\t\t}\n\t\tlet directiveTypeName = directive.name.startsWith('*')\n\t\t\t? directive.name.substring(1)\n\t\t\t: directive.name;\n\t\tdirectiveTypeName = directiveTypeName.replaceAll('-', ' ')\n\t\t\t.split(' ')\n\t\t\t.map(str => str.charAt(0).toUpperCase() + str.substring(1))\n\t\t\t.join('');\n\t\treturn `export type ɵɵ0${ToCamelCase(directiveTypeName)}Directive0ɵɵ = {${temp.join(',')}};`;\n\t});\n\treturn generateStatements(nodes.join());\n}\n"]}
|
package/transformer/helpers.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare function isInputDecorator(decorator: ts.Decorator): boolean;
|
|
|
41
41
|
* @returns
|
|
42
42
|
*/
|
|
43
43
|
export declare function isOutputDecorator(decorator: ts.Decorator): boolean;
|
|
44
|
+
export declare function getMapByDecoratorForPropertyDeclaration(member: ts.PropertyDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[];
|
|
45
|
+
export declare function getMapByDecoratorForSetAccessorDeclaration(member: ts.SetAccessorDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[];
|
|
44
46
|
export declare function getMapByDecorator(classNode: ts.ClassDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[];
|
|
45
47
|
/**
|
|
46
48
|
* get a component or directive inputs that is annotated by `@Input` or `@FormValue`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/cli/transformer/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,SAAc,GAAG,OAAO,CAElG;AAGD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,SAAc,GAAG,OAAO,CAElG;AAED,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,SAAc,EAAE,aAAa,SAAc,GAAG,OAAO,CAE1I;AAGD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,QAAQ,SAAS,GAAG,OAAO,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,cAAc,SAAe,GAAG,OAAO,CAErG;AAGD;;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,MAAM,EAAE,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAShH"}
|
package/transformer/helpers.js
CHANGED
|
@@ -60,30 +60,66 @@ export function isInputDecorator(decorator) {
|
|
|
60
60
|
export function isOutputDecorator(decorator) {
|
|
61
61
|
return ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === 'Output';
|
|
62
62
|
}
|
|
63
|
+
export function getMapByDecoratorForPropertyDeclaration(member, checker, decoratorFilter) {
|
|
64
|
+
const infos = [];
|
|
65
|
+
const decorators = ts.getDecorators(member);
|
|
66
|
+
if (!decorators) {
|
|
67
|
+
return infos;
|
|
68
|
+
}
|
|
69
|
+
const inputDecorators = decorators.filter(decoratorFilter);
|
|
70
|
+
if (!inputDecorators.length) {
|
|
71
|
+
return infos;
|
|
72
|
+
}
|
|
73
|
+
let inputType = member.type?.getText();
|
|
74
|
+
if (!inputType && member.initializer) {
|
|
75
|
+
inputType = checker.typeToString(checker.getTypeAtLocation(member.initializer), member.initializer, undefined);
|
|
76
|
+
}
|
|
77
|
+
inputDecorators.forEach(input => {
|
|
78
|
+
const decoratorCall = input.expression;
|
|
79
|
+
const aliasName = decoratorCall.arguments[0];
|
|
80
|
+
const alias = aliasName ? aliasName.text : member.name.getText();
|
|
81
|
+
infos.push({ name: member.name.getText(), aliasName: alias, type: inputType });
|
|
82
|
+
});
|
|
83
|
+
return infos;
|
|
84
|
+
}
|
|
85
|
+
export function getMapByDecoratorForSetAccessorDeclaration(member, checker, decoratorFilter) {
|
|
86
|
+
const infos = [];
|
|
87
|
+
const decorators = ts.getDecorators(member);
|
|
88
|
+
if (!decorators) {
|
|
89
|
+
return infos;
|
|
90
|
+
}
|
|
91
|
+
const inputDecorators = decorators.filter(decoratorFilter);
|
|
92
|
+
if (!inputDecorators.length) {
|
|
93
|
+
return infos;
|
|
94
|
+
}
|
|
95
|
+
let memberName;
|
|
96
|
+
if (ts.isIdentifier(member.name)) {
|
|
97
|
+
memberName = member.name.getText();
|
|
98
|
+
}
|
|
99
|
+
else if (ts.isComputedPropertyName(member.name) && ts.isStringLiteral(member.name.expression)) {
|
|
100
|
+
memberName = member.name.expression.getText();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return infos;
|
|
104
|
+
}
|
|
105
|
+
let inputType = checker.typeToString(checker.getTypeAtLocation(member.parameters[0]), member.parameters[0], undefined);
|
|
106
|
+
inputDecorators.forEach(input => {
|
|
107
|
+
const decoratorCall = input.expression;
|
|
108
|
+
const aliasName = decoratorCall.arguments[0];
|
|
109
|
+
const alias = aliasName ? aliasName.text : memberName;
|
|
110
|
+
infos.push({ name: memberName, aliasName: alias, type: inputType });
|
|
111
|
+
});
|
|
112
|
+
return infos;
|
|
113
|
+
}
|
|
63
114
|
export function getMapByDecorator(classNode, checker, decoratorFilter) {
|
|
64
115
|
const infos = [];
|
|
65
116
|
classNode.members.forEach(member => {
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
const decorators = ts.getDecorators(member);
|
|
70
|
-
if (!decorators) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const inputDecorators = decorators.filter(decoratorFilter);
|
|
74
|
-
if (!inputDecorators.length) {
|
|
75
|
-
return;
|
|
117
|
+
if (ts.isPropertyDeclaration(member)) {
|
|
118
|
+
infos.push(...getMapByDecoratorForPropertyDeclaration(member, checker, decoratorFilter));
|
|
76
119
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
inputType = checker.typeToString(checker.getTypeAtLocation(member.initializer), member.initializer, undefined);
|
|
120
|
+
else if (ts.isSetAccessorDeclaration(member)) {
|
|
121
|
+
infos.push(...getMapByDecoratorForSetAccessorDeclaration(member, checker, decoratorFilter));
|
|
80
122
|
}
|
|
81
|
-
inputDecorators.forEach(input => {
|
|
82
|
-
const decoratorCall = input.expression;
|
|
83
|
-
const aliasName = decoratorCall.arguments[0];
|
|
84
|
-
const alias = aliasName ? aliasName.text : member.name.getText();
|
|
85
|
-
infos.push({ name: member.name.getText(), aliasName: alias, type: inputType });
|
|
86
|
-
});
|
|
87
123
|
});
|
|
88
124
|
return infos;
|
|
89
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/cli/transformer/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAInD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAuB,EAAE,aAAa,GAAG,WAAW;IACxF,OAAO,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,aAAa,CAAC;AACjH,CAAC;AAAA,CAAC;AAGF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAuB,EAAE,aAAa,GAAG,WAAW;IACxF,OAAO,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,aAAa,CAAC;AACjH,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,+BAA+B,CAAC,SAAuB,EAAE,aAAa,GAAG,WAAW,EAAE,aAAa,GAAG,WAAW;IAChI,OAAO,oBAAoB,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,oBAAoB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACzG,CAAC;AAAA,CAAC;AAGF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB,EAAE,QAAQ,GAAG,MAAM;IACzE,OAAO,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC;AAC5G,CAAC;AAAA,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,q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AE,iBAAiB,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,SAA8B,EAAE,OAAuB;IACrF,OAAO,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAkC,EAAE,QAAgB;IAC3F,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU;SACxC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,CAAsC,CAAC;IAEvF,MAAM,WAAW,GAAG,gBAAgB,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;IAC5D,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IACD,OAAO,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { DecoratorInfo } from './modules.js';\n\n\n/**\n * check if a decorator is a `@Component` decorator;\n * @param decorator \n * @param expressionName \n * @returns \n */\nexport function isComponentDecorator(decorator: ts.Decorator, componentName = 'Component'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === componentName;\n};\n\n\n/**\n * check if a decorator is a `@Directive` decorator;\n * @param decorator \n * @param directiveName \n * @returns \n */\nexport function isDirectiveDecorator(decorator: ts.Decorator, directiveName = 'Directive'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === directiveName;\n};\n\nexport function isComponentOrDirectiveDecorator(decorator: ts.Decorator, componentName = 'Component', directiveName = 'Directive'): boolean {\n\treturn isComponentDecorator(decorator, componentName) || isDirectiveDecorator(decorator, directiveName);\n};\n\n\n/**\n * check if a decorator is a `@Pipe` decorator;\n * @param decorator \n * @param pipeName \n * @returns \n */\nexport function isPipeDecorator(decorator: ts.Decorator, pipeName = 'Pipe'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === pipeName;\n};\n\n/**\n * check if a decorator is a `@Injectable` decorator;\n * @param decorator \n * @param injectableName \n * @returns \n */\nexport function isInjectableDecorator(decorator: ts.Decorator, injectableName = 'Injectable'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === injectableName;\n};\n\n\n/**\n * check if Decorator is `@Input` or `@FormValue`\n * @param decorator \n * @returns \n */\nexport function isInputDecorator(decorator: ts.Decorator): boolean {\n\treturn ts.isCallExpression(decorator.expression) && (\n\t\tdecorator.expression.expression.getText() === 'Input'\n\t\t|| decorator.expression.expression.getText() === 'FormValue'\n\t);\n}\n\n/**\n * check if Decorator is `@Output`\n * @param decorator \n * @returns \n */\nexport function isOutputDecorator(decorator: ts.Decorator): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === 'Output';\n}\n\nexport function getMapByDecorator(classNode: ts.ClassDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[] {\n\tconst infos: DecoratorInfo[] = [];\n\tclassNode.members.forEach(member => {\n\t\tif (!ts.isPropertyDeclaration(member)) {\n\t\t\treturn;\n\t\t}\n\t\tconst decorators = ts.getDecorators(member);\n\t\tif (!decorators) {\n\t\t\treturn;\n\t\t}\n\t\tconst inputDecorators = decorators.filter(decoratorFilter);\n\t\tif (!inputDecorators.length) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputType = member.type?.getText();\n\t\tif (!inputType && member.initializer) {\n\t\t\tinputType = checker.typeToString(checker.getTypeAtLocation(member.initializer), member.initializer, undefined);\n\t\t}\n\t\tinputDecorators.forEach(input => {\n\t\t\tconst decoratorCall = input.expression as ts.CallExpression;\n\t\t\tconst aliasName = decoratorCall.arguments[0] as ts.StringLiteralLike;\n\t\t\tconst alias = aliasName ? aliasName.text : member.name.getText();\n\t\t\tinfos.push({ name: member.name.getText(), aliasName: alias, type: inputType });\n\t\t});\n\t})\n\treturn infos;\n}\n\n/**\n * get a component or directive inputs that is annotated by `@Input` or `@FormValue`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getInputs(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): DecoratorInfo[] {\n\treturn getMapByDecorator(classNode, checker, isInputDecorator);\n}\n\n/**\n * get a component or directive input names that is annotated by `@Input` or `@FormValue`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getInputNames(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): string[] {\n\treturn getInputs(classNode, checker).map(info => info.aliasName);\n}\n\n/**\n * get a component or directive outputs that is annotated by `@Output`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getOutputs(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): DecoratorInfo[] {\n\treturn getMapByDecorator(classNode, checker, isOutputDecorator);\n}\n\n/**\n * get a component or directive output names that is annotated by `@Output`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getOutputNames(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): string[] {\n\treturn getOutputs(classNode, checker).map(info => info.aliasName);\n}\n\n/**\n * get text value for a property in ObjectLiteralExpression\n * @param option \n * @param property \n * @returns \n */\nexport function getTextValueForProperty(option: ts.ObjectLiteralExpression, property: string): string | undefined {\n\tconst selectorProperty = option.properties\n\t\t.find(prop => prop.name?.getText() === property) as ts.PropertyAssignment | undefined;\n\n\tconst initializer = selectorProperty?.initializer.getText();\n\tif (!initializer) {\n\t\treturn;\n\t}\n\treturn initializer?.substring(1, initializer.length - 1);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/cli/transformer/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAInD;;;;;GAKG;AACH,MAAM,UAAU,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AAgB,CAAC,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,SAA8B,EAAE,OAAuB;IACpF,OAAO,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,SAA8B,EAAE,OAAuB;IACjF,OAAO,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,SAA8B,EAAE,OAAuB;IACrF,OAAO,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAkC,EAAE,QAAgB;IAC3F,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU;SACxC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,CAAsC,CAAC;IAEvF,MAAM,WAAW,GAAG,gBAAgB,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;IAC5D,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IACD,OAAO,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import ts from 'typescript/lib/tsserverlibrary.js';\nimport { DecoratorInfo } from './modules.js';\n\n\n/**\n * check if a decorator is a `@Component` decorator;\n * @param decorator \n * @param expressionName \n * @returns \n */\nexport function isComponentDecorator(decorator: ts.Decorator, componentName = 'Component'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === componentName;\n};\n\n\n/**\n * check if a decorator is a `@Directive` decorator;\n * @param decorator \n * @param directiveName \n * @returns \n */\nexport function isDirectiveDecorator(decorator: ts.Decorator, directiveName = 'Directive'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === directiveName;\n};\n\nexport function isComponentOrDirectiveDecorator(decorator: ts.Decorator, componentName = 'Component', directiveName = 'Directive'): boolean {\n\treturn isComponentDecorator(decorator, componentName) || isDirectiveDecorator(decorator, directiveName);\n};\n\n\n/**\n * check if a decorator is a `@Pipe` decorator;\n * @param decorator \n * @param pipeName \n * @returns \n */\nexport function isPipeDecorator(decorator: ts.Decorator, pipeName = 'Pipe'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === pipeName;\n};\n\n/**\n * check if a decorator is a `@Injectable` decorator;\n * @param decorator \n * @param injectableName \n * @returns \n */\nexport function isInjectableDecorator(decorator: ts.Decorator, injectableName = 'Injectable'): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === injectableName;\n};\n\n\n/**\n * check if Decorator is `@Input` or `@FormValue`\n * @param decorator \n * @returns \n */\nexport function isInputDecorator(decorator: ts.Decorator): boolean {\n\treturn ts.isCallExpression(decorator.expression) && (\n\t\tdecorator.expression.expression.getText() === 'Input'\n\t\t|| decorator.expression.expression.getText() === 'FormValue'\n\t);\n}\n\n/**\n * check if Decorator is `@Output`\n * @param decorator \n * @returns \n */\nexport function isOutputDecorator(decorator: ts.Decorator): boolean {\n\treturn ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() === 'Output';\n}\n\nexport function getMapByDecoratorForPropertyDeclaration(member: ts.PropertyDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[] {\n\tconst infos: DecoratorInfo[] = [];\n\tconst decorators = ts.getDecorators(member);\n\tif (!decorators) {\n\t\treturn infos;\n\t}\n\tconst inputDecorators = decorators.filter(decoratorFilter);\n\tif (!inputDecorators.length) {\n\t\treturn infos;\n\t}\n\tlet inputType = member.type?.getText();\n\tif (!inputType && member.initializer) {\n\t\tinputType = checker.typeToString(checker.getTypeAtLocation(member.initializer), member.initializer, undefined);\n\t}\n\tinputDecorators.forEach(input => {\n\t\tconst decoratorCall = input.expression as ts.CallExpression;\n\t\tconst aliasName = decoratorCall.arguments[0] as ts.StringLiteralLike;\n\t\tconst alias = aliasName ? aliasName.text : member.name.getText();\n\t\tinfos.push({ name: member.name.getText(), aliasName: alias, type: inputType });\n\t});\n\treturn infos;\n}\n\nexport function getMapByDecoratorForSetAccessorDeclaration(member: ts.SetAccessorDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[] {\n\tconst infos: DecoratorInfo[] = [];\n\tconst decorators = ts.getDecorators(member);\n\tif (!decorators) {\n\t\treturn infos;\n\t}\n\tconst inputDecorators = decorators.filter(decoratorFilter);\n\tif (!inputDecorators.length) {\n\t\treturn infos;\n\t}\n\n\tlet memberName: string;\n\tif (ts.isIdentifier(member.name)) {\n\t\tmemberName = member.name.getText();\n\t} else if (ts.isComputedPropertyName(member.name) && ts.isStringLiteral(member.name.expression)) {\n\t\tmemberName = member.name.expression.getText();\n\t} else {\n\t\treturn infos;\n\t}\n\n\tlet inputType = checker.typeToString(checker.getTypeAtLocation(member.parameters[0]), member.parameters[0], undefined);\n\tinputDecorators.forEach(input => {\n\t\tconst decoratorCall = input.expression as ts.CallExpression;\n\t\tconst aliasName = decoratorCall.arguments[0] as ts.StringLiteralLike;\n\t\tconst alias = aliasName ? aliasName.text : memberName;\n\t\tinfos.push({ name: memberName, aliasName: alias, type: inputType });\n\t});\n\treturn infos;\n}\n\nexport function getMapByDecorator(classNode: ts.ClassDeclaration, checker: ts.TypeChecker, decoratorFilter: ((decorator: ts.Decorator) => boolean)): DecoratorInfo[] {\n\tconst infos: DecoratorInfo[] = [];\n\tclassNode.members.forEach(member => {\n\t\tif (ts.isPropertyDeclaration(member)) {\n\t\t\tinfos.push(...getMapByDecoratorForPropertyDeclaration(member, checker, decoratorFilter));\n\t\t} else if (ts.isSetAccessorDeclaration(member)) {\n\t\t\tinfos.push(...getMapByDecoratorForSetAccessorDeclaration(member, checker, decoratorFilter));\n\t\t}\n\t})\n\treturn infos;\n}\n\n/**\n * get a component or directive inputs that is annotated by `@Input` or `@FormValue`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getInputs(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): DecoratorInfo[] {\n\treturn getMapByDecorator(classNode, checker, isInputDecorator);\n}\n\n/**\n * get a component or directive input names that is annotated by `@Input` or `@FormValue`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getInputNames(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): string[] {\n\treturn getInputs(classNode, checker).map(info => info.aliasName);\n}\n\n/**\n * get a component or directive outputs that is annotated by `@Output`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getOutputs(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): DecoratorInfo[] {\n\treturn getMapByDecorator(classNode, checker, isOutputDecorator);\n}\n\n/**\n * get a component or directive output names that is annotated by `@Output`.\n * @param classNode \n * @param checker \n * @returns \n */\nexport function getOutputNames(classNode: ts.ClassDeclaration, checker: ts.TypeChecker): string[] {\n\treturn getOutputs(classNode, checker).map(info => info.aliasName);\n}\n\n/**\n * get text value for a property in ObjectLiteralExpression\n * @param option \n * @param property \n * @returns \n */\nexport function getTextValueForProperty(option: ts.ObjectLiteralExpression, property: string): string | undefined {\n\tconst selectorProperty = option.properties\n\t\t.find(prop => prop.name?.getText() === property) as ts.PropertyAssignment | undefined;\n\n\tconst initializer = selectorProperty?.initializer.getText();\n\tif (!initializer) {\n\t\treturn;\n\t}\n\treturn initializer?.substring(1, initializer.length - 1);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../../src/cli/trans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,MAAM,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IAGhH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAGxC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAGzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAIzC,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAGjD,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAGhC,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC;CAGtC;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
package/transformer/modules.js
CHANGED
|
@@ -8,12 +8,6 @@ class ModuleManger {
|
|
|
8
8
|
}
|
|
9
9
|
map = new Map();
|
|
10
10
|
add(info) {
|
|
11
|
-
if (info.classes?.length) {
|
|
12
|
-
const old = this.map.get(info.path);
|
|
13
|
-
if (old) {
|
|
14
|
-
info.classes = info.classes.concat(old.classes ?? []);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
11
|
this.map.set(info.path, info);
|
|
18
12
|
}
|
|
19
13
|
clear() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/cli/transformer/modules.ts"],"names":[],"mappings":"AAuBA,MAAM,YAAY;IACjB,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACpC,CAAC;IACD,CAAC,MAAM,CAAC,WAAW,CAAC,GAAW,aAAa,CAAC;IAE7C,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACtB,CAAC;IAEO,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE5C,GAAG,CAAC,IAAgB;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CAAC;IAC3B,CAAC;IACD,IAAI;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IACD,MAAM;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;CACD;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC","sourcesContent":["import type ts from 'typescript/lib/tsserverlibrary.js';\n\nexport type ViewInfo = {\n\tselector: string;\n\textendsType: string;\n\tviewName: string;\n\tinterFaceType: ts.InterfaceDeclaration;\n\tformAssociated: boolean;\n};\n\nexport type DecoratorInfo = { name: string, aliasName: string, type?: string };\n\nexport type ClassInfo = {\n\ttype: 'component' | 'directive';\n\tname: string,\n\tsuccessor?: string;\n\tviews: ViewInfo[];\n\tinputs: DecoratorInfo[];\n\toutputs: DecoratorInfo[];\n};\n\nexport type ModuleInfo = { path: string; classes?: ClassInfo[]; }\n\nclass ModuleManger implements Map<string, ModuleInfo> {\n\t[Symbol.iterator](): IterableIterator<[string, ModuleInfo]> {\n\t\treturn this.map[Symbol.iterator]();\n\t}\n\t[Symbol.toStringTag]: string = 'Module Info';\n\n\tget size(): number {\n\t\treturn this.map.size;\n\t}\n\n\tprivate map = new Map<string, ModuleInfo>();\n\n\tadd(info: ModuleInfo) {\n\t\tthis.map.set(info.path, info);\n\t}\n\tclear(): void {\n\t\tthis.map.clear();\n\t}\n\tdelete(key: string): boolean {\n\t\treturn this.map.delete(key);\n\t}\n\tforEach(callbackfn: (value: ModuleInfo, key: string, map: Map<string, ModuleInfo>) => void, thisArg?: any): void {\n\t\tthis.map.forEach(callbackfn, thisArg);\n\t}\n\tget(key: string): ModuleInfo | undefined {\n\t\treturn this.map.get(key);\n\t}\n\thas(key: string): boolean {\n\t\treturn this.map.has(key);\n\t}\n\tset(key: string, value: ModuleInfo): this {\n\t\tthis.map.set(key, value);\n\t\treturn this;\n\t}\n\tentries(): IterableIterator<[string, ModuleInfo]> {\n\t\treturn this.map.entries();\n\t}\n\tkeys(): IterableIterator<string> {\n\t\treturn this.map.keys();\n\t}\n\tvalues(): IterableIterator<ModuleInfo> {\n\t\treturn this.map.values();\n\t}\n}\n\nexport const moduleManger = new ModuleManger();\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as webpack from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* The entry point for ts-loader
|
|
4
|
+
*/
|
|
5
|
+
export declare function initTypeScript(): void;
|
|
6
|
+
export declare function loader(this: webpack.LoaderContext<{}>, contents: string, inputSourceMap?: Record<string, any>): void;
|
|
7
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/cli/webpack/loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AASxC;;GAEG;AAEH,wBAAgB,cAAc,SAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAoB7G"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { normalize } from 'path';
|
|
2
|
+
import ts from 'typescript/lib/tsserverlibrary.js';
|
|
3
|
+
import { getConfigPath, getTransformers, scanDirectives } from '../compiler/compiler.js';
|
|
4
|
+
let host;
|
|
5
|
+
let program;
|
|
6
|
+
let orgWriteFile;
|
|
7
|
+
let transformers;
|
|
8
|
+
/**
|
|
9
|
+
* The entry point for ts-loader
|
|
10
|
+
*/
|
|
11
|
+
export function initTypeScript() {
|
|
12
|
+
const configPath = getConfigPath();
|
|
13
|
+
const cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys);
|
|
14
|
+
if (!cmd) {
|
|
15
|
+
console.log(`can't parse command line `);
|
|
16
|
+
throw new Error('');
|
|
17
|
+
}
|
|
18
|
+
host = ts.createCompilerHost(cmd.options);
|
|
19
|
+
orgWriteFile = host.writeFile;
|
|
20
|
+
program = ts.createProgram(cmd.fileNames, cmd.options, host);
|
|
21
|
+
transformers = getTransformers(program);
|
|
22
|
+
scanDirectives(program);
|
|
23
|
+
}
|
|
24
|
+
export function loader(contents, inputSourceMap) {
|
|
25
|
+
if (!program) {
|
|
26
|
+
try {
|
|
27
|
+
initTypeScript();
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
this.callback(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let content, sourceMap;
|
|
34
|
+
host.writeFile = (fileName, contents) => {
|
|
35
|
+
if (fileName.endsWith('.map')) {
|
|
36
|
+
sourceMap = contents;
|
|
37
|
+
}
|
|
38
|
+
else if (fileName.endsWith('.js')) {
|
|
39
|
+
content = contents;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const filePath = normalize(this.resourcePath);
|
|
43
|
+
program.emit(program.getSourceFile(filePath), undefined, undefined, undefined, transformers);
|
|
44
|
+
this.callback(null, content, sourceMap);
|
|
45
|
+
host.writeFile = orgWriteFile;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/cli/webpack/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzF,IAAI,IAAqB,CAAC;AAC1B,IAAI,OAAmB,CAAC;AACxB,IAAI,YAAkC,CAAC;AACvC,IAAI,YAAmC,CAAC;AAExC;;GAEG;AAEH,MAAM,UAAU,cAAc;IAC7B,MAAM,UAAU,GAAG,aA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CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAC7F,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC;AAC/B,CAAC","sourcesContent":["import { normalize } from 'path';\nimport type * as webpack from 'webpack';\nimport ts from 'typescript/lib/tsserverlibrary.js';\nimport { getConfigPath, getTransformers, scanDirectives } from '../compiler/compiler.js';\n\nlet host: ts.CompilerHost;\nlet program: ts.Program;\nlet orgWriteFile: ts.WriteFileCallback;\nlet transformers: ts.CustomTransformers;\n\n/**\n * The entry point for ts-loader\n */\n\nexport function initTypeScript() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\tconsole.log(`can't parse command line `);\n\t\tthrow new Error('');\n\t}\n\thost = ts.createCompilerHost(cmd.options);\n\torgWriteFile = host.writeFile;\n\tprogram = ts.createProgram(cmd.fileNames, cmd.options, host);\n\ttransformers = getTransformers(program);\n\tscanDirectives(program);\n}\n\nexport function loader(this: webpack.LoaderContext<{}>, contents: string, inputSourceMap?: Record<string, any>) {\n\tif (!program) {\n\t\ttry {\n\t\t\tinitTypeScript();\n\t\t} catch (e) {\n\t\t\tthis.callback(e as Error);\n\t\t}\n\t}\n\tlet content: string | undefined, sourceMap: string | undefined;\n\thost.writeFile = (fileName: string, contents: string) => {\n\t\tif (fileName.endsWith('.map')) {\n\t\t\tsourceMap = contents;\n\t\t} else if (fileName.endsWith('.js')) {\n\t\t\tcontent = contents;\n\t\t}\n\t};\n\tconst filePath = normalize(this.resourcePath);\n\tprogram.emit(program.getSourceFile(filePath), undefined, undefined, undefined, transformers);\n\tthis.callback(null, content, sourceMap);\n\thost.writeFile = orgWriteFile;\n}\n"]}
|