@ibyar/cli 2.2.0 → 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 CHANGED
@@ -41,24 +41,77 @@ Usage: ibyar [options]
41
41
  Examples:
42
42
  ibyar
43
43
  ibyar -b
44
- ibyar -b -w
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
@@ -8,7 +8,6 @@ const inputs = args.slice(2);
8
8
  const showHelp = inputs.includes('-h') || inputs.includes('--help');
9
9
  const printVersion = inputs.length === 1 && (inputs.includes('-v') || inputs.includes('--version'));
10
10
  const runBuild = inputs.includes('-b') || inputs.includes('--build');
11
- const generateTypes = inputs.includes('-gt') || inputs.includes('--generate-types');
12
11
  if (showHelp) {
13
12
  const help = `
14
13
  Version ${readPackageVersion()}
@@ -24,12 +23,8 @@ Examples:
24
23
 
25
24
  Options:
26
25
  -b --build compile the project source code with ibyar transformers
26
+ and generate '.d.ts' files with created Custom HTML Element definitions.
27
27
  -w --watch compile and watch source files, used with --build
28
- -gt --generate-types generate "web-types.json" files, and typescript
29
- definitions '.d.ts' files.
30
- you can import this file later in your "index.ts"
31
- or "polyfills.ts" file, so any editor "VS Code" can
32
- support autocomplete easily,
33
28
  -h --help print help message
34
29
  -v --version output the version number`;
35
30
  console.log(help);
@@ -48,9 +43,6 @@ if (runBuild) {
48
43
  }
49
44
  }).catch(error => console.error(error));
50
45
  }
51
- if (generateTypes) {
52
- console.log('generate types not supported yet.');
53
- }
54
46
  function readPackageVersion() {
55
47
  const url = fileURLToPath(import.meta.url);
56
48
  const path = join(url, '..', '..', 'package.json');
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,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CA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C,mBAAmB,EAAE,CAAC;QAC9B,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,WAAW,EAAE,CAAC;QACtB,CAAC;IACF,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,aAAa,EAAE,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,kBAAkB;IAC1B,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,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');\nconst generateTypes = inputs.includes('-gt') || inputs.includes('--generate-types');\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-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(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\nif (generateTypes) {\n\tconsole.log('generate types not supported yet.');\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"]}
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,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,Q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D,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"]}
@@ -1,7 +1,8 @@
1
1
  import '../directives/register.js';
2
2
  import ts from 'typescript/lib/tsserverlibrary.js';
3
3
  export declare function getTransformers(program: ts.Program): ts.CustomTransformers;
4
- export declare function scanDirective(program: ts.Program): void;
4
+ export declare function scanDirectives(program: ts.Program): void;
5
+ export declare function scanDirectivesOnceAsTransformer(): (program: ts.Program) => (context: ts.TransformationContext) => ts.Transformer<ts.SourceFile>;
5
6
  export declare function emitProgram(program: ts.Program): void;
6
7
  export declare function compileFiles(files: readonly string[], options: ts.CompilerOptions): void;
7
8
  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,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAOnD,wBAAgB,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAY1E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAEhD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,QAG9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,eAAe,QAIjF;AAoBD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,QAejF;AAID,wBAAgB,aAAa,WAW5B;AAED,wBAAgB,WAAW,SAO1B;AAED,wBAAgB,mBAAmB,SAOlC"}
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;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"}
@@ -18,11 +18,23 @@ export function getTransformers(program) {
18
18
  ],
19
19
  };
20
20
  }
21
- export function scanDirective(program) {
21
+ export function scanDirectives(program) {
22
22
  program.getSourceFiles().forEach(scanDirectivesTypeVisitor);
23
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
+ }
24
36
  export function emitProgram(program) {
25
- scanDirective(program);
37
+ scanDirectives(program);
26
38
  program.emit(undefined, undefined, undefined, undefined, getTransformers(program));
27
39
  }
28
40
  export function compileFiles(files, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,UAAU,eA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AAM,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 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, getTransformers(program));\n}\n\nexport function compileFiles(files: readonly string[], options: ts.CompilerOptions) {\n\tconst host = ts.createCompilerHost(options);\n\tconst program = ts.createProgram(files, options, host);\n\temitProgram(program);\n}\n\nconst formatHost: ts.FormatDiagnosticsHost = {\n\tgetCanonicalFileName: path => path,\n\tgetCurrentDirectory: ts.sys.getCurrentDirectory,\n\tgetNewLine: () => ts.sys.newLine\n};\n\nfunction reportDiagnostic(diagnostic: ts.Diagnostic) {\n\tconsole.error(\"Error\", diagnostic.code, \":\", ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()));\n}\n\n/**\n * Prints a diagnostic every time the watch status changes.\n * This is mainly for messages like \"Starting compilation\" or \"Compilation completed\".\n */\nfunction reportWatchStatusChanged(diagnostic: ts.Diagnostic) {\n\tconsole.info(ts.formatDiagnostic(diagnostic, formatHost));\n}\n\nexport function compileAndWatchFiles(configPath: string, cmd: ts.ParsedCommandLine) {\n\tconst createProgram = ts.createSemanticDiagnosticsBuilderProgram;\n\tconst host = ts.createWatchCompilerHost(\n\t\tconfigPath,\n\t\tcmd.options,\n\t\tts.sys,\n\t\tcreateProgram,\n\t\treportDiagnostic,\n\t\treportWatchStatusChanged,\n\t\tcmd.watchOptions,\n\t);\n\tconst programFactory = ts.createWatchProgram(host);\n\tconst programBuilder = programFactory.getProgram();\n\tconst program = programBuilder.getProgram();\n\temitProgram(program);\n}\n\n\n\nexport function getConfigPath() {\n\tconst tsconfig = process.argv.slice(2).filter(arg => arg.includes('tsconfig'))[0];\n\tconst configPath = ts.findConfigFile(\n\t\t'./',\t\t\t/*searchPath*/\n\t\tts.sys.fileExists,\n\t\ttsconfig ?? 'tsconfig.json'\n\t);\n\tif (!configPath) {\n\t\tthrow new Error(\"Could not find a valid 'tsconfig.json'.\");\n\t}\n\treturn configPath;\n}\n\nexport function compileArgs() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\treturn;\n\t}\n\tcompileFiles(cmd.fileNames, cmd.options);\n}\n\nexport function compileAndWatchArgs() {\n\tconst configPath = getConfigPath();\n\tconst cmd = ts.getParsedCommandLineOfConfigFile(configPath, {}, ts.sys as any);\n\tif (!cmd) {\n\t\treturn;\n\t}\n\tcompileAndWatchFiles(configPath, cmd);\n}\n"]}
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/cli/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,wCAAwC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,UAAU,eAAe,CAAC,OAAmB;IAClD,OAAO;QACN,MAAM,EAAE;YACP,6BAA6B,CAAC,OAAO,CAAC;YACtC,6BAA6B,CAAC,OAAO,CAAC;SACtC;QACD,KAAK,EAAE,EAAE;QACT,iBAAiB,EAAE;YAClB,wCAAwC,CAAC,OAAO,CAAqD;YACrG,wCAAwC,CAAC,OAAO,CAAqD;SACrG;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAmB;IACjD,OAAO,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC9C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,iBAAiB,GAAG,CAAC,OAAiC,EAAiC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC;IACvH,OAAO,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AAC;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/cli",
3
- "version": "2.2.0",
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.2.0",
40
- "@ibyar/decorators": "^2.2.0",
41
- "@ibyar/directives": "^2.2.0",
42
- "@ibyar/elements": "^2.2.0",
43
- "@ibyar/expressions": "^2.2.0",
44
- "@ibyar/pipes": "^2.2.0",
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": "70db847b00908addff4aed9e7e4f545edb5f2526"
77
+ "gitHead": "6c3b1c8d19faf00022c58ba2b893f4bb56147600"
78
78
  }
@@ -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;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,GAAG,OA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Aa,EAAE,CAUnK;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,aAAa,EAAE,CAElG;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,MAAM,EAAE,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,aAAa,EAAE,CAEnG;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,MAAM,EAAE,CAEhG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAShH"}
@@ -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 (!ts.isPropertyDeclaration(member)) {
67
- return;
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
- let inputType = member.type?.getText();
78
- if (!inputType && member.initializer) {
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,qBAAqB,CA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B,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,oBAAoB,CAAC,SA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;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"]}
package/webpack/loader.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { normalize } from 'path';
2
2
  import ts from 'typescript/lib/tsserverlibrary.js';
3
- import { getConfigPath, getTransformers, scanDirective } from '../compiler/compiler.js';
3
+ import { getConfigPath, getTransformers, scanDirectives } from '../compiler/compiler.js';
4
4
  let host;
5
5
  let program;
6
6
  let orgWriteFile;
@@ -19,7 +19,7 @@ export function initTypeScript() {
19
19
  orgWriteFile = host.writeFile;
20
20
  program = ts.createProgram(cmd.fileNames, cmd.options, host);
21
21
  transformers = getTransformers(program);
22
- scanDirective(program);
22
+ scanDirectives(program);
23
23
  }
24
24
  export function loader(contents, inputSourceMap) {
25
25
  if (!program) {
@@ -1 +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,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExF,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,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,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC;IAC9B,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7D,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,aAAa,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,MAAM,CAAkC,QAAgB,EAAE,cAAoC;IAC7G,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,IAAI,CAAC;YACJ,cAAc,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,IAAI,CAAC,QAAQ,CAAC,CAAU,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;IACD,IAAI,OAA2B,EAAE,SAA6B,CAAC;IAC/D,IAAI,CAAC,SAAS,GAAG,CAAC,QAAgB,EAAE,QAAgB,EAAE,EAAE;QACvD,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,SAAS,GAAG,QAAQ,CAAC;QACtB,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,GAAG,QAAQ,CAAC;QACpB,CAAC;IACF,CAAC,CAAC;IACF,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,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, scanDirective } 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\tscanDirective(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"]}
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,aAAa,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,gCAAgC,CAAC,UAAU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AC,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"]}