@ibyar/cli 0.8.2-dev.20221008 → 0.8.4

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
@@ -10,13 +10,13 @@
10
10
  [npm-url]: https://npmjs.org/package/@ibyar/cli
11
11
  [downloads-image]: https://img.shields.io/npm/dt/@ibyar/cli
12
12
  [downloads-url]: https://npmjs.org/package/@ibyar/cli
13
- [license-img]: https://img.shields.io/github/license/ibyar/cli
14
- [license-url]: https://github.com/ibyar/cli/blob/master/LICENSE
13
+ [license-img]: https://img.shields.io/github/license/ibyar/aurora
14
+ [license-url]: https://github.com/ibyar/aurora/blob/master/LICENSE
15
15
  [lerna-img]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
16
16
  [lerna-url]: https://lerna.js.org/
17
- [contributors]: https://img.shields.io/github/contributors/ibyar/cli
17
+ [contributors]: https://img.shields.io/github/contributors/ibyar/aurora
18
18
 
19
- The Ibyar/Aurora CLI tool.
19
+ The Ibyar/Aurora CLI tool. ( dev - prerelease)
20
20
 
21
21
 
22
22
  ## `Install`
@@ -29,6 +29,34 @@ npm i --save @ibyar/cli
29
29
  yarn add @ibyar/cli
30
30
  ```
31
31
 
32
+ # How to use
33
+
34
+ `npx ibyar --build --watch --verbose`
35
+
36
+ it load the configuration from a `tsconfig.json` file
37
+
38
+ ```
39
+ Usage: ibyar [options]
40
+
41
+ Examples:
42
+ ibyar
43
+ ibyar -b
44
+ ibyar -gt
45
+ ibyar -v
46
+ ibyar --help
47
+
48
+ Options:
49
+ -b --build compile the project source code with ibyar transformers
50
+ -gt --generate-types generate "web-types.json" files, and typescript
51
+ definitions '.d.ts' files.
52
+ you can import this file later in your "index.ts"
53
+ or "polyfills.ts" file, so any editor "VS Code" can
54
+ support autocomplete easily,
55
+ -h --help print help message
56
+ -v --version output the version number
57
+ ```
58
+
59
+
32
60
 
33
61
  The Ibyar CLI has a typescript transformer to generate a definitions for you component
34
62
 
package/bin/cli.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  #!/usr/bin/env node
2
+ export {};
package/bin/cli.js CHANGED
@@ -1,6 +1,41 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- if (process.argv.includes('-b') || process.argv.includes('--build')) {
2
+ import { exit } from 'process';
3
+ const CLI_VERSION = '0.8.3';
4
+ const args = process.argv;
5
+ const inputs = args.slice(2);
6
+ const showHelp = inputs.includes('-h') || inputs.includes('--help');
7
+ const printVersion = inputs.includes('-v') || inputs.includes('--version');
8
+ const runBuild = inputs.includes('-b') || inputs.includes('--build');
9
+ const generateTypes = inputs.includes('-gt') || inputs.includes('--generate-types');
10
+ if (showHelp) {
11
+ const help = `
12
+ Version ${CLI_VERSION}
13
+ Usage: ibyar [options]
14
+
15
+ Examples:
16
+ ibyar
17
+ ibyar -b
18
+ ibyar -gt
19
+ ibyar -v
20
+ ibyar --help
21
+
22
+ Options:
23
+ -b --build compile the project source code with ibyar transformers
24
+ -gt --generate-types generate "web-types.json" files, and typescript
25
+ definitions '.d.ts' files.
26
+ you can import this file later in your "index.ts"
27
+ or "polyfills.ts" file, so any editor "VS Code" can
28
+ support autocomplete easily,
29
+ -h --help print help message
30
+ -v --version output the version number`;
31
+ console.log(help);
32
+ exit();
33
+ }
34
+ if (printVersion) {
35
+ console.log(CLI_VERSION);
36
+ exit();
37
+ }
38
+ if (runBuild) {
4
39
  import('../compiler/compiler.js').then(module => {
5
40
  if (process.argv.includes('-w') || process.argv.includes('--watch')) {
6
41
  module.compileAndWatchArgs();
@@ -10,4 +45,7 @@ if (process.argv.includes('-b') || process.argv.includes('--build')) {
10
45
  }
11
46
  });
12
47
  }
48
+ if (generateTypes) {
49
+ console.log('generate types not supported yet.');
50
+ }
13
51
  //# 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":";;AAGA,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;IACpE,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACpE,MAAM,CAAC,mBAAmB,EAAE,CAAC;SAC7B;aAAM;YACN,MAAM,CAAC,WAAW,EAAE,CAAC;SACrB;IACF,CAAC,CAAC,CAAC;CACH","sourcesContent":["#!/usr/bin/env node\n\n\nif (process.argv.includes('-b') || process.argv.includes('--build')) {\n\timport('../compiler/compiler.js').then(module => {\n\t\tif (process.argv.includes('-w') || process.argv.includes('--watch')) {\n\t\t\tmodule.compileAndWatchArgs();\n\t\t} else {\n\t\t\tmodule.compileArgs();\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli/bin/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpE,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAE3E,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACrE,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAEpF,IAAI,QAAQ,EAAE;IACb,MAAM,IAAI,GACT;UACQ,WAAW;;;;;;;;;;;;;;;;;;0DAkBqC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,IAAI,EAAE,CAAC;CACP;AAGD,IAAI,YAAY,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC;CACP;AAED,IAAI,QAAQ,EAAE;IACb,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACpE,MAAM,CAAC,mBAAmB,EAAE,CAAC;SAC7B;aAAM;YACN,MAAM,CAAC,WAAW,EAAE,CAAC;SACrB;IACF,CAAC,CAAC,CAAC;CACH;AAED,IAAI,aAAa,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;CACjD","sourcesContent":["#!/usr/bin/env node\n\nimport { exit } from 'process';\n\nconst CLI_VERSION = '0.8.3';\n\nconst args = process.argv;\nconst inputs = args.slice(2);\n\nconst showHelp = inputs.includes('-h') || inputs.includes('--help');\nconst printVersion = 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 ${CLI_VERSION}\nUsage: ibyar [options]\n\nExamples:\n ibyar\n ibyar -b\n ibyar -gt\n ibyar -v\n ibyar --help\n\nOptions:\n -b --build compile the project source code with ibyar transformers\n -gt --generate-types generate \"web-types.json\" files, and typescript\n\t definitions '.d.ts' files. \n\t you can import this file later in your \"index.ts\" \n\t\t\t\t\t\t\t\tor \"polyfills.ts\" file, so any editor \"VS Code\" can\n\t\t\t\t\t\t\t\tsupport autocomplete easily,\n -h --help print help message\n -v --version output the version number`;\n\tconsole.log(help);\n\texit();\n}\n\n\nif (printVersion) {\n\tconsole.log(CLI_VERSION);\n\texit();\n}\n\nif (runBuild) {\n\timport('../compiler/compiler.js').then(module => {\n\t\tif (process.argv.includes('-w') || process.argv.includes('--watch')) {\n\t\t\tmodule.compileAndWatchArgs();\n\t\t} else {\n\t\t\tmodule.compileArgs();\n\t\t}\n\t});\n}\n\nif (generateTypes) {\n\tconsole.log('generate types not supported yet.');\n}\n"]}
@@ -1,4 +1,4 @@
1
- declare type SelectorType = {
1
+ type SelectorType = {
2
2
  selector?: string;
3
3
  type: string;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/cli",
3
- "version": "0.8.2-dev.20221008",
3
+ "version": "0.8.4",
4
4
  "description": "The Ibyar/Aurora CLI tool",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ibyar/aurora",
@@ -9,6 +9,16 @@
9
9
  "url": "https://github.com/ibyar/aurora.git",
10
10
  "directory": "packages/cli"
11
11
  },
12
+ "bugs": {
13
+ "url": "https://github.com/ibyar/aurora/issues"
14
+ },
15
+ "author": "The Ibyar Authors (https://github.com/ibyar/aurora/graphs/contributors)",
16
+ "contributors": [
17
+ {
18
+ "name": "Muhammad Salem",
19
+ "email": "salem.ebo@gmail.com"
20
+ }
21
+ ],
12
22
  "main": "./index.js",
13
23
  "module": "./index.js",
14
24
  "types": "./index.d.ts",
@@ -26,14 +36,14 @@
26
36
  "access": "public"
27
37
  },
28
38
  "dependencies": {
29
- "@ibyar/core": "^0.8.2-dev.20221008",
30
- "@ibyar/directives": "^0.8.2-dev.20221008",
31
- "@ibyar/elements": "^0.8.2-dev.20221008",
32
- "@ibyar/expressions": "^0.8.2-dev.20221008",
33
- "@ibyar/pipes": "^0.8.2-dev.20221008",
39
+ "@ibyar/core": "^0.8.4",
40
+ "@ibyar/directives": "^0.8.4",
41
+ "@ibyar/elements": "^0.8.4",
42
+ "@ibyar/expressions": "^0.8.4",
43
+ "@ibyar/pipes": "^0.8.4",
34
44
  "reflect-metadata": "^0.1.13",
35
- "tslib": "^2.4.0",
36
- "typescript": "^4.8.4"
45
+ "tslib": "^2.4.1",
46
+ "typescript": "^4.9.4"
37
47
  },
38
48
  "scripts": {
39
49
  "build": "tsc --build --verbose"
@@ -66,5 +76,5 @@
66
76
  "shadow-dom",
67
77
  "typescript"
68
78
  ],
69
- "gitHead": "abe877ef8e4d4914a0b9bc12dc88154ba9f0b2b9"
79
+ "gitHead": "bb412fef645853fc2af3d86e14b633813a988a2b"
70
80
  }
@@ -95,7 +95,7 @@ export function updateModule(classes) {
95
95
  const outputs = Object.keys(c.outputs).map(output => 'on' + ToCamelCase(output));
96
96
  const attributes = [...inputs, ...outputs].map(s => `'${s}'`).join(' | ');
97
97
  const interfaceBody = `
98
- public static observedAttributes: ${attributes}[];
98
+ public static observedAttributes: [${attributes}];
99
99
 
100
100
  ${inputs.map(input => `public ${input}: ${c.inputs[input]};`).join('\n')}
101
101
 
@@ -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,C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C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;mBACV,IAAI,CAAC,QAAQ,YAAY,IAAI,CAAC,WAAW;MACtD,aAAa,CAAC,IAAI,EAAE;;uBAEH,IAAI,CAAC,QAAQ,YAAY,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,IAAI;GACzI,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,MAAM,UAAU,GAAG;;IAEhB,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;;;MAG9B,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;IAExE,CAAC;IACJ,OAAO,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACvC,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 updateModule(classes: ClassInfo[]): ts.NodeArray<ts.Statement> {\n\n\tconst viewClassDeclarations = classes.map(c => {\n\t\tconst inputs = Object.keys(c.inputs);\n\t\tconst outputs = Object.keys(c.outputs).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${inputs.map(input => `public ${input}: ${c.inputs[input]};`).join('\\n')}\n\n\t\t\t${Object.keys(c.outputs).map(output => `public on${ToCamelCase(output)}: ${c.outputs[output]};`).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}"]}
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,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CAAC,QAAQ,YAAY,IAAI,CAAC,WAAW;MACtD,aAAa,CAAC,IAAI,EAAE;;uBAEH,IAAI,CAAC,QAAQ,YAAY,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,IAAI;GACzI,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,MAAM,UAAU,GAAG;;IAEhB,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;;;MAG9B,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;IAExE,CAAC;IACJ,OAAO,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACvC,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 updateModule(classes: ClassInfo[]): ts.NodeArray<ts.Statement> {\n\n\tconst viewClassDeclarations = classes.map(c => {\n\t\tconst inputs = Object.keys(c.inputs);\n\t\tconst outputs = Object.keys(c.outputs).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${inputs.map(input => `public ${input}: ${c.inputs[input]};`).join('\\n')}\n\n\t\t\t${Object.keys(c.outputs).map(output => `public on${ToCamelCase(output)}: ${c.outputs[output]};`).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}"]}
@@ -1,20 +1,20 @@
1
- export declare type ViewInfo = {
1
+ export type ViewInfo = {
2
2
  selector: string;
3
3
  extendsType: string;
4
4
  viewName: string;
5
5
  interFaceType: ts.InterfaceDeclaration;
6
6
  formAssociated: boolean;
7
7
  };
8
- export declare type InputOutputTypeInfo = {
8
+ export type InputOutputTypeInfo = {
9
9
  [name: string]: string | undefined;
10
10
  };
11
- export declare type ClassInfo = {
11
+ export type ClassInfo = {
12
12
  name: string;
13
13
  views: ViewInfo[];
14
14
  inputs: InputOutputTypeInfo;
15
15
  outputs: InputOutputTypeInfo;
16
16
  };
17
- export declare type ModuleInfo = {
17
+ export type ModuleInfo = {
18
18
  path: string;
19
19
  skip: true;
20
20
  } | {