@intelligentgraphics/ig.gfx.packager 3.0.28 → 3.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/build/bin.mjs +1 -1
  2. package/build/{cli-RWjcRDQ7.mjs → cli-CuiqZ39_.mjs} +16 -22
  3. package/build/{cli-RWjcRDQ7.mjs.map → cli-CuiqZ39_.mjs.map} +1 -1
  4. package/build/{dependencies-_6rsdwHk.mjs → dependencies-BiYItaVS.mjs} +2 -2
  5. package/build/{dependencies-_6rsdwHk.mjs.map → dependencies-BiYItaVS.mjs.map} +1 -1
  6. package/build/{generateIndex-Dy12utjI.mjs → generateIndex-hg6jRXQv.mjs} +96 -83
  7. package/build/generateIndex-hg6jRXQv.mjs.map +1 -0
  8. package/build/{generateParameterType-DKwRLh1m.mjs → generateParameterType-CDjqLM4J.mjs} +2 -3
  9. package/build/{generateParameterType-DKwRLh1m.mjs.map → generateParameterType-CDjqLM4J.mjs.map} +1 -1
  10. package/build/{index-B9e-vtmM.mjs → index-B2kXo6K7.mjs} +298 -84
  11. package/build/index-B2kXo6K7.mjs.map +1 -0
  12. package/build/{index-CLoWLYI6.mjs → index-BoGrZubW.mjs} +14 -14
  13. package/build/index-BoGrZubW.mjs.map +1 -0
  14. package/build/{postinstall-DlYP6BrQ.mjs → postinstall-CbMUz2zy.mjs} +3 -4
  15. package/build/{postinstall-DlYP6BrQ.mjs.map → postinstall-CbMUz2zy.mjs.map} +1 -1
  16. package/build/{publishNpm-CEhZI6-O.mjs → publishNpm-CrnuTwss.mjs} +11 -10
  17. package/build/publishNpm-CrnuTwss.mjs.map +1 -0
  18. package/build/rollup-UR3DADp8.mjs +198 -0
  19. package/build/rollup-UR3DADp8.mjs.map +1 -0
  20. package/build/scripts-Bfojy_uD.mjs +48 -0
  21. package/build/scripts-Bfojy_uD.mjs.map +1 -0
  22. package/build/versionFile-DSqOw-XB.mjs +208 -0
  23. package/build/versionFile-DSqOw-XB.mjs.map +1 -0
  24. package/lib/lib.mjs +421 -331
  25. package/package.json +13 -8
  26. package/readme.md +87 -10
  27. package/build/generateIndex-Dy12utjI.mjs.map +0 -1
  28. package/build/index-B9e-vtmM.mjs.map +0 -1
  29. package/build/index-CLoWLYI6.mjs.map +0 -1
  30. package/build/publishNpm-CEhZI6-O.mjs.map +0 -1
  31. package/build/scripts-EvIjiH6G.mjs +0 -10
  32. package/build/scripts-EvIjiH6G.mjs.map +0 -1
  33. package/build/versionFile-C7xf8PjZ.mjs +0 -380
  34. package/build/versionFile-C7xf8PjZ.mjs.map +0 -1
@@ -1,10 +1,11 @@
1
1
  import ts from 'typescript';
2
+ import { resolveNamespaces, resolveNamespaceFullName } from '@intelligentgraphics/declarationbundler';
2
3
  import 'path';
3
4
  import 'fs';
4
5
  import 'resolve';
5
6
  import 'write-pkg';
6
- import { a as readPackageCreatorIndex, k as writePackageCreatorIndex } from './cli-RWjcRDQ7.mjs';
7
- import { g as getPackageTypescriptFiles } from './scripts-EvIjiH6G.mjs';
7
+ import { a as readPackageCreatorIndex, r as readPackageCreatorManifest, k as writePackageCreatorIndex } from './cli-CuiqZ39_.mjs';
8
+ import { r as readScriptPackageTSConfig, g as getPackageTypescriptFiles, a as resolveScriptPackageEntryModule } from './scripts-Bfojy_uD.mjs';
8
9
  import 'node:path';
9
10
  import 'node:fs';
10
11
  import 'axios';
@@ -14,7 +15,6 @@ import 'url';
14
15
  import 'glob';
15
16
  import 'assert';
16
17
  import 'events';
17
- import 'core-js/modules/es.typed-array.set.js';
18
18
  import 'util';
19
19
  import 'inquirer';
20
20
 
@@ -23,69 +23,96 @@ import 'inquirer';
23
23
  *
24
24
  * @param folderPath path to a src folder
25
25
  */ function generateIndex({ location, ignore = [], strictOptional = false }) {
26
- const files = getPackageTypescriptFiles(location);
27
- const filtered = files.filter((path)=>{
28
- return !ignore.some((suffix)=>path.endsWith(suffix));
29
- });
30
26
  const arr = [];
31
27
  const existingIndex = readPackageCreatorIndex(location) ?? [];
32
- const program = ts.createProgram(filtered, {
33
- allowJs: true
34
- });
28
+ const manifest = readPackageCreatorManifest(location);
29
+ const compilerOptions = readScriptPackageTSConfig(location).options;
30
+ const isModule = compilerOptions.module === ts.ModuleKind.ES2015 || compilerOptions.module === ts.ModuleKind.ESNext;
31
+ const files = getPackageTypescriptFiles(location).filter((path)=>!ignore.some((suffix)=>path.endsWith(suffix)));
32
+ let program;
33
+ let namespaces;
34
+ if (isModule) {
35
+ const entryFilePath = resolveScriptPackageEntryModule(location, manifest);
36
+ if (entryFilePath === undefined) {
37
+ throw new Error(`Could not resolve entry module`);
38
+ }
39
+ const host = ts.createCompilerHost({}, true);
40
+ program = ts.createProgram([
41
+ entryFilePath
42
+ ], {
43
+ allowJs: true,
44
+ ...compilerOptions
45
+ }, host);
46
+ const entryFile = program.getSourceFile(entryFilePath);
47
+ if (entryFile === undefined) {
48
+ throw new Error(`Failed to find entry module`);
49
+ }
50
+ namespaces = resolveNamespaces(entryFile, program, host, manifest.Scope ?? manifest.Package);
51
+ } else {
52
+ program = ts.createProgram(files, {
53
+ allowJs: true
54
+ });
55
+ namespaces = [];
56
+ }
35
57
  const typeChecker = program.getTypeChecker();
36
- filtered.forEach((file)=>{
58
+ files.forEach((file)=>{
37
59
  // Create a Program to represent the project, then pull out the
38
60
  // source file to parse its AST.
39
61
  const sourceFile = program.getSourceFile(file);
62
+ const namespace = namespaces.find((namespace)=>namespace.files.includes(sourceFile));
40
63
  // Loop through the root AST nodes of the file
41
- ts.forEachChild(sourceFile, (node)=>{
42
- for (const scriptingClass of findScriptingClasses(node)){
43
- if (scriptingClass.node.name === undefined) {
44
- throw new Error(`Expected ${scriptingClass.type} class to have a name`);
45
- }
46
- const name = typeChecker.getFullyQualifiedName(typeChecker.getSymbolAtLocation(scriptingClass.node.name));
47
- if (name.length > 45) {
48
- throw new Error(`Package name length >45 '${name}'`);
49
- }
50
- const parameterDeclaration = getScriptingClassParameterdeclaration(scriptingClass);
51
- const parametersType = parameterDeclaration === undefined ? undefined : typeChecker.getTypeAtLocation(parameterDeclaration);
52
- if (parametersType === undefined) {
53
- console.log(`Failed to find parameters type declaration for ${scriptingClass.type} ${name}. Skipping parameter list generation`);
54
- }
55
- const existingIndexEntry = existingIndex.find((entry)=>entry.Name === name);
56
- const obj = {
57
- Name: name,
58
- Description: (existingIndexEntry == null ? void 0 : existingIndexEntry.Description) ?? name,
59
- Type: scriptingClass.type === "evaluator" ? "Evaluator" : "Interactor",
60
- Parameters: []
61
- };
62
- const rawDocTags = ts.getJSDocTags(scriptingClass.node);
63
- const dict = getTagDict(rawDocTags);
64
- if (dict.summary) {
65
- obj.Description = dict.summary;
66
- } else {
67
- const comment = typeChecker.getTypeAtLocation(scriptingClass.node).symbol.getDocumentationComment(typeChecker).map((comment)=>comment.text).join(" ");
68
- if (comment) {
69
- obj.Description = comment;
70
- }
64
+ for (const scriptingClass of findScriptingClasses(sourceFile)){
65
+ if (scriptingClass.node.name === undefined) {
66
+ throw new Error(`Expected ${scriptingClass.type} class to have a name`);
67
+ }
68
+ let name;
69
+ if (isModule && namespace !== undefined) {
70
+ const moduleNamespace = resolveNamespaceFullName(namespace);
71
+ name = `${moduleNamespace}.${scriptingClass.node.name.text}`;
72
+ } else {
73
+ name = typeChecker.getFullyQualifiedName(typeChecker.getSymbolAtLocation(scriptingClass.node.name));
74
+ }
75
+ if (name.length > 45) {
76
+ throw new Error(`Package name length >45 '${name}'`);
77
+ }
78
+ const parameterDeclaration = getScriptingClassParameterdeclaration(scriptingClass);
79
+ const parametersType = parameterDeclaration === undefined ? undefined : typeChecker.getTypeAtLocation(parameterDeclaration);
80
+ if (parametersType === undefined) {
81
+ console.log(`Failed to find parameters type declaration for ${scriptingClass.type} ${name}. Skipping parameter list generation`);
82
+ }
83
+ const existingIndexEntry = existingIndex.find((entry)=>entry.Name === name);
84
+ const obj = {
85
+ Name: name,
86
+ Description: existingIndexEntry?.Description ?? name,
87
+ Type: scriptingClass.type === "evaluator" ? "Evaluator" : "Interactor",
88
+ Parameters: []
89
+ };
90
+ const rawDocTags = ts.getJSDocTags(scriptingClass.node);
91
+ const dict = getTagDict(rawDocTags);
92
+ if (dict.summary) {
93
+ obj.Description = dict.summary;
94
+ } else {
95
+ const comment = typeChecker.getTypeAtLocation(scriptingClass.node).symbol.getDocumentationComment(typeChecker).map((comment)=>comment.text).join(" ");
96
+ if (comment) {
97
+ obj.Description = comment;
71
98
  }
72
- if (parametersType !== undefined) {
73
- obj.Parameters = parseParametersList(typeChecker.getPropertiesOfType(parametersType), strictOptional);
74
- if (obj.Parameters.length === 0 && parametersType.getStringIndexType() !== undefined) {
75
- obj.Parameters = (existingIndexEntry == null ? void 0 : existingIndexEntry.Parameters) ?? [];
76
- }
77
- } else if (existingIndexEntry !== undefined) {
78
- obj.Parameters = existingIndexEntry.Parameters;
99
+ }
100
+ if (parametersType !== undefined) {
101
+ obj.Parameters = parseParametersList(typeChecker.getPropertiesOfType(parametersType), strictOptional);
102
+ if (obj.Parameters.length === 0 && parametersType.getStringIndexType() !== undefined) {
103
+ obj.Parameters = existingIndexEntry?.Parameters ?? [];
79
104
  }
80
- arr.push(obj);
105
+ } else if (existingIndexEntry !== undefined) {
106
+ obj.Parameters = existingIndexEntry.Parameters;
81
107
  }
82
- });
108
+ arr.push(obj);
109
+ }
83
110
  });
84
111
  arr.sort((a, b)=>a.Name.localeCompare(b.Name));
85
112
  writePackageCreatorIndex(location, arr);
86
113
  }
87
114
  function capitalizeFirstLetter(string) {
88
- return (string == null ? void 0 : string.charAt(0).toUpperCase()) + (string == null ? void 0 : string.slice(1));
115
+ return string?.charAt(0).toUpperCase() + string?.slice(1);
89
116
  }
90
117
  const parseDefault = (value, type)=>{
91
118
  const uType = capitalizeFirstLetter(type);
@@ -140,7 +167,6 @@ const parseTypeFromName = (name)=>{
140
167
  };
141
168
  const parseParametersList = (properties, strictOptional)=>{
142
169
  return properties.map((symbol, i)=>{
143
- var _symbol_getDeclarations;
144
170
  const parameter = {
145
171
  Name: symbol.name,
146
172
  Description: undefined,
@@ -151,14 +177,13 @@ const parseParametersList = (properties, strictOptional)=>{
151
177
  if (parameter.Name.length > 45) {
152
178
  throw new Error(`Parameter name length >45 '${parameter.Name}'`);
153
179
  }
154
- let declaration = (_symbol_getDeclarations = symbol.getDeclarations()) == null ? void 0 : _symbol_getDeclarations[0];
180
+ let declaration = symbol.getDeclarations()?.[0];
155
181
  let documentationComment = symbol.getDocumentationComment(undefined);
156
182
  let checkLinksSymbol = symbol;
157
183
  while(checkLinksSymbol !== undefined && declaration === undefined){
158
184
  const links = checkLinksSymbol.links;
159
- if (links == null ? void 0 : links.syntheticOrigin) {
160
- var _links_syntheticOrigin_getDeclarations;
161
- declaration = (_links_syntheticOrigin_getDeclarations = links.syntheticOrigin.getDeclarations()) == null ? void 0 : _links_syntheticOrigin_getDeclarations[0];
185
+ if (links?.syntheticOrigin) {
186
+ declaration = links.syntheticOrigin.getDeclarations()?.[0];
162
187
  if (documentationComment.length === 0) {
163
188
  documentationComment = links.syntheticOrigin.getDocumentationComment(undefined);
164
189
  }
@@ -229,8 +254,7 @@ const getScriptingClassParameterdeclaration = (scriptingClass)=>{
229
254
  };
230
255
  const isScriptingClassParameterDeclaration = (scriptingClass, memberNode, parameterIndex)=>{
231
256
  if (scriptingClass.type === "evaluator") {
232
- var _memberNode_name;
233
- return (memberNode == null ? void 0 : (_memberNode_name = memberNode.name) == null ? void 0 : _memberNode_name.getText()) == "Create" && parameterIndex === 2;
257
+ return memberNode?.name?.getText() == "Create" && parameterIndex === 2;
234
258
  }
235
259
  if (scriptingClass.type === "interactor") {
236
260
  return memberNode.kind === ts.SyntaxKind.Constructor && parameterIndex === 0;
@@ -242,31 +266,20 @@ const isScriptingClassParameterDeclaration = (scriptingClass, memberNode, parame
242
266
  *
243
267
  * @param {ts.Node} node
244
268
  * @return {*}
245
- */ const findScriptingClasses = (node)=>{
246
- let body;
247
- if (ts.isModuleDeclaration(node)) {
248
- body = node.body;
249
- }
250
- if (body !== undefined && ts.isModuleDeclaration(body)) {
251
- body = body.body;
252
- }
253
- const classes = [];
254
- if (body !== undefined) {
255
- ts.forEachChild(body, (child)=>{
256
- if (!ts.isClassDeclaration(child)) {
257
- return;
258
- }
259
- const scriptingClass = detectScriptingClass(child);
260
- if (scriptingClass !== undefined) {
261
- classes.push(scriptingClass);
262
- }
263
- });
269
+ */ function* findScriptingClasses(node) {
270
+ for (const child of node.getChildren()){
271
+ if (!ts.isClassDeclaration(child)) {
272
+ yield* findScriptingClasses(child);
273
+ continue;
274
+ }
275
+ const scriptingClass = detectScriptingClass(child);
276
+ if (scriptingClass !== undefined) {
277
+ yield scriptingClass;
278
+ }
264
279
  }
265
- return classes;
266
- };
280
+ }
267
281
  const detectScriptingClass = (node)=>{
268
- var _node_heritageClauses, _node_heritageClauses1;
269
- const isEvaluator = (_node_heritageClauses = node.heritageClauses) == null ? void 0 : _node_heritageClauses.some((clause)=>{
282
+ const isEvaluator = node.heritageClauses?.some((clause)=>{
270
283
  if (clause.token !== ts.SyntaxKind.ExtendsKeyword && clause.token !== ts.SyntaxKind.ImplementsKeyword) {
271
284
  return false;
272
285
  }
@@ -278,7 +291,7 @@ const detectScriptingClass = (node)=>{
278
291
  type: "evaluator"
279
292
  };
280
293
  }
281
- const isInteractor = (_node_heritageClauses1 = node.heritageClauses) == null ? void 0 : _node_heritageClauses1.some((clause)=>{
294
+ const isInteractor = node.heritageClauses?.some((clause)=>{
282
295
  if (clause.token !== ts.SyntaxKind.ExtendsKeyword) {
283
296
  return false;
284
297
  }
@@ -293,4 +306,4 @@ const detectScriptingClass = (node)=>{
293
306
  };
294
307
 
295
308
  export { generateIndex };
296
- //# sourceMappingURL=generateIndex-Dy12utjI.mjs.map
309
+ //# sourceMappingURL=generateIndex-hg6jRXQv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateIndex-hg6jRXQv.mjs","sources":["../src/commands/generateIndex.ts"],"sourcesContent":["import ts from \"typescript\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport {\n\tresolveNamespaceFullName,\n\tresolveNamespaces,\n\tNamespace,\n} from \"@intelligentgraphics/declarationbundler\";\n\nimport {\n\tPackageLocation,\n\twritePackageCreatorIndex,\n\treadPackageCreatorIndex,\n\treadPackageCreatorManifest,\n} from \"../lib/package\";\nimport {\n\tgetPackageTypescriptFiles,\n\treadScriptPackageTSConfig,\n\tresolveScriptPackageEntryModule,\n} from \"../lib/scripts\";\nimport {\n\tCreatorIndexEntry,\n\tCreatorIndexParameter,\n\tCreatorIndexParameterType,\n} from \"../lib/package\";\n\nexport interface GenerateIndexOptions {\n\tignore?: string[];\n\tlocation: PackageLocation;\n\n\t/**\n\t * Marks non optional parameter object properties as required in the generated index\n\t *\n\t * @type {boolean}\n\t */\n\tstrictOptional?: boolean;\n}\n\n/**\n * Extracts and returns script array for _Index.json from a src folder\n *\n * @param folderPath path to a src folder\n */\nexport function generateIndex({\n\tlocation,\n\tignore = [],\n\tstrictOptional = false,\n}: GenerateIndexOptions) {\n\tconst arr: CreatorIndexEntry[] = [];\n\n\tconst existingIndex = readPackageCreatorIndex(location) ?? [];\n\tconst manifest = readPackageCreatorManifest(location);\n\n\tconst compilerOptions = readScriptPackageTSConfig(location).options;\n\n\tconst isModule =\n\t\tcompilerOptions.module === ts.ModuleKind.ES2015 ||\n\t\tcompilerOptions.module === ts.ModuleKind.ESNext;\n\n\tconst files = getPackageTypescriptFiles(location).filter(\n\t\t(path) => !ignore.some((suffix) => path.endsWith(suffix)),\n\t);\n\n\tlet program: ts.Program;\n\tlet namespaces: Namespace[];\n\n\tif (isModule) {\n\t\tconst entryFilePath = resolveScriptPackageEntryModule(\n\t\t\tlocation,\n\t\t\tmanifest,\n\t\t);\n\n\t\tif (entryFilePath === undefined) {\n\t\t\tthrow new Error(`Could not resolve entry module`);\n\t\t}\n\n\t\tconst host = ts.createCompilerHost({}, true);\n\t\tprogram = ts.createProgram(\n\t\t\t[entryFilePath],\n\t\t\t{ allowJs: true, ...compilerOptions },\n\t\t\thost,\n\t\t);\n\n\t\tconst entryFile = program.getSourceFile(entryFilePath);\n\n\t\tif (entryFile === undefined) {\n\t\t\tthrow new Error(`Failed to find entry module`);\n\t\t}\n\n\t\tnamespaces = resolveNamespaces(\n\t\t\tentryFile,\n\t\t\tprogram,\n\t\t\thost,\n\t\t\tmanifest.Scope ?? manifest.Package,\n\t\t);\n\t} else {\n\t\tprogram = ts.createProgram(files, { allowJs: true });\n\t\tnamespaces = [];\n\t}\n\n\tconst typeChecker = program.getTypeChecker();\n\n\tfiles.forEach((file) => {\n\t\t// Create a Program to represent the project, then pull out the\n\t\t// source file to parse its AST.\n\t\tconst sourceFile = program.getSourceFile(file)!;\n\t\tconst namespace = namespaces.find((namespace) =>\n\t\t\tnamespace.files.includes(sourceFile),\n\t\t);\n\n\t\t// Loop through the root AST nodes of the file\n\n\t\tfor (const scriptingClass of findScriptingClasses(sourceFile)) {\n\t\t\tif (scriptingClass.node.name === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expected ${scriptingClass.type} class to have a name`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet name: string;\n\n\t\t\tif (isModule && namespace !== undefined) {\n\t\t\t\tconst moduleNamespace = resolveNamespaceFullName(namespace);\n\t\t\t\tname = `${moduleNamespace}.${scriptingClass.node.name.text}`;\n\t\t\t} else {\n\t\t\t\tname = typeChecker.getFullyQualifiedName(\n\t\t\t\t\ttypeChecker.getSymbolAtLocation(scriptingClass.node.name)!,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (name.length > 45) {\n\t\t\t\tthrow new Error(`Package name length >45 '${name}'`);\n\t\t\t}\n\n\t\t\tconst parameterDeclaration =\n\t\t\t\tgetScriptingClassParameterdeclaration(scriptingClass);\n\n\t\t\tconst parametersType =\n\t\t\t\tparameterDeclaration === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: typeChecker.getTypeAtLocation(parameterDeclaration);\n\n\t\t\tif (parametersType === undefined) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`Failed to find parameters type declaration for ${scriptingClass.type} ${name}. Skipping parameter list generation`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst existingIndexEntry = existingIndex.find(\n\t\t\t\t(entry) => entry.Name === name,\n\t\t\t);\n\n\t\t\tconst obj: CreatorIndexEntry = {\n\t\t\t\tName: name,\n\t\t\t\tDescription: existingIndexEntry?.Description ?? name,\n\t\t\t\tType:\n\t\t\t\t\tscriptingClass.type === \"evaluator\"\n\t\t\t\t\t\t? \"Evaluator\"\n\t\t\t\t\t\t: \"Interactor\",\n\t\t\t\tParameters: [],\n\t\t\t};\n\n\t\t\tconst rawDocTags = ts.getJSDocTags(scriptingClass.node);\n\n\t\t\tconst dict = getTagDict(rawDocTags);\n\t\t\tif (dict.summary) {\n\t\t\t\tobj.Description = dict.summary;\n\t\t\t} else {\n\t\t\t\tconst comment = typeChecker\n\t\t\t\t\t.getTypeAtLocation(scriptingClass.node)\n\t\t\t\t\t.symbol.getDocumentationComment(typeChecker)\n\t\t\t\t\t.map((comment) => comment.text)\n\t\t\t\t\t.join(\" \");\n\n\t\t\t\tif (comment) {\n\t\t\t\t\tobj.Description = comment;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (parametersType !== undefined) {\n\t\t\t\tobj.Parameters = parseParametersList(\n\t\t\t\t\ttypeChecker.getPropertiesOfType(parametersType),\n\t\t\t\t\tstrictOptional,\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\tobj.Parameters.length === 0 &&\n\t\t\t\t\tparametersType.getStringIndexType() !== undefined\n\t\t\t\t) {\n\t\t\t\t\tobj.Parameters = existingIndexEntry?.Parameters ?? [];\n\t\t\t\t}\n\t\t\t} else if (existingIndexEntry !== undefined) {\n\t\t\t\tobj.Parameters = existingIndexEntry.Parameters;\n\t\t\t}\n\n\t\t\tarr.push(obj);\n\t\t}\n\t});\n\n\tarr.sort((a, b) => a.Name.localeCompare(b.Name));\n\n\twritePackageCreatorIndex(location, arr);\n}\n\nfunction capitalizeFirstLetter(string: string) {\n\treturn string?.charAt(0).toUpperCase() + string?.slice(1);\n}\n\nconst parseDefault = (value: string, type: string) => {\n\tconst uType: CreatorIndexParameterType = capitalizeFirstLetter(\n\t\ttype,\n\t) as CreatorIndexParameterType;\n\tif (value === \"null\") return null;\n\tswitch (uType) {\n\t\tcase \"LengthM\":\n\t\tcase \"ArcDEG\":\n\t\tcase \"Float\":\n\t\t\treturn parseFloat(value);\n\t\tcase \"Integer\":\n\t\tcase \"Int\":\n\t\t\treturn parseInt(value);\n\t\tcase \"Boolean\":\n\t\tcase \"Bool\":\n\t\t\treturn value === \"true\";\n\t\tcase \"Material\":\n\t\tcase \"String\":\n\t\tcase \"Geometry\":\n\t\tdefault:\n\t\t\treturn value.replace(/^\"/, \"\").replace(/\"$/, \"\");\n\t}\n};\n\nconst parseTypeFromName = (\n\tname: string,\n): CreatorIndexParameterType | undefined => {\n\tconst parts = name.split(\".\");\n\tconst identifier = parts[parts.length - 1];\n\n\tswitch (identifier) {\n\t\tcase \"LengthM\":\n\t\tcase \"ArcDEG\":\n\t\tcase \"Float\":\n\t\tcase \"Integer\":\n\t\t\treturn identifier;\n\t\tcase \"GeometryReference\":\n\t\t\treturn \"Geometry\";\n\t\tcase \"MaterialReference\":\n\t\t\treturn \"Material\";\n\t\tcase \"AnimationReference\":\n\t\t\treturn \"Animation\";\n\t\tcase \"InteractorReference\":\n\t\t\treturn \"Interactor\";\n\t\tcase \"EvaluatorReference\":\n\t\t\treturn \"Evaluator\";\n\t\tcase \"String\":\n\t\tcase \"string\":\n\t\t\treturn \"String\";\n\t\tcase \"number\":\n\t\tcase \"Number\":\n\t\t\treturn \"Float\";\n\t\tcase \"boolean\":\n\t\tcase \"Boolean\":\n\t\t\treturn \"Boolean\";\n\t}\n};\n\nconst parseParametersList = (\n\tproperties: ts.Symbol[],\n\tstrictOptional: boolean,\n): CreatorIndexParameter[] => {\n\treturn properties.map((symbol, i) => {\n\t\tconst parameter: CreatorIndexParameter = {\n\t\t\tName: symbol.name,\n\t\t\tDescription: undefined,\n\t\t\tType: \"String\",\n\t\t\tDefault: undefined,\n\t\t\tDisplayIndex: i + 1,\n\t\t};\n\n\t\tif (parameter.Name.length > 45) {\n\t\t\tthrow new Error(`Parameter name length >45 '${parameter.Name}'`);\n\t\t}\n\n\t\tlet declaration: ts.Declaration | undefined =\n\t\t\tsymbol.getDeclarations()?.[0];\n\t\tlet documentationComment = symbol.getDocumentationComment(undefined);\n\n\t\tlet checkLinksSymbol: ts.Symbol | undefined = symbol;\n\n\t\twhile (checkLinksSymbol !== undefined && declaration === undefined) {\n\t\t\tconst links = (\n\t\t\t\tcheckLinksSymbol as {\n\t\t\t\t\tlinks?: {\n\t\t\t\t\t\tmappedType?: ts.Type;\n\t\t\t\t\t\tsyntheticOrigin?: ts.Symbol;\n\t\t\t\t\t};\n\t\t\t\t} & ts.Symbol\n\t\t\t).links;\n\n\t\t\tif (links?.syntheticOrigin) {\n\t\t\t\tdeclaration = links.syntheticOrigin.getDeclarations()?.[0];\n\n\t\t\t\tif (documentationComment.length === 0) {\n\t\t\t\t\tdocumentationComment =\n\t\t\t\t\t\tlinks.syntheticOrigin.getDocumentationComment(\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tcheckLinksSymbol = links.syntheticOrigin;\n\t\t\t}\n\t\t}\n\n\t\tif (declaration !== undefined) {\n\t\t\tconst rawDocTags = ts.getJSDocTags(declaration);\n\n\t\t\tconst dict = getTagDict(rawDocTags);\n\n\t\t\tif (dict.summary) {\n\t\t\t\tparameter.Description = dict.summary;\n\t\t\t} else {\n\t\t\t\tconst comment = documentationComment\n\t\t\t\t\t.map((comment) => comment.text)\n\t\t\t\t\t.join(\" \");\n\n\t\t\t\tif (comment) {\n\t\t\t\t\tparameter.Description = comment;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (dict.creatorType) {\n\t\t\t\tparameter.Type = dict.creatorType as CreatorIndexParameterType;\n\t\t\t} else {\n\t\t\t\tconst propertySignature = declaration as ts.PropertySignature;\n\t\t\t\tif (propertySignature.type !== undefined) {\n\t\t\t\t\tconst parsedType = parseTypeFromName(\n\t\t\t\t\t\tpropertySignature.type.getText(),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (parsedType !== undefined) {\n\t\t\t\t\t\tparameter.Type = parsedType;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (dict.default) {\n\t\t\t\tparameter.Default = parseDefault(dict.default, parameter.Type);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tstrictOptional &&\n\t\t\t\tdeclaration.kind === ts.SyntaxKind.PropertySignature\n\t\t\t) {\n\t\t\t\tconst propertySignature = declaration as ts.PropertySignature;\n\t\t\t\tif (propertySignature.questionToken === undefined) {\n\t\t\t\t\tparameter.Required = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parameter;\n\t});\n};\n\ninterface IDocTags {\n\tdefault?: string;\n\tcreatorType?: string;\n\tsummary?: string;\n}\n\nfunction getTagDict(tags: readonly ts.JSDocTag[]): IDocTags {\n\tconst dict: IDocTags = {};\n\n\tfor (const tag of tags) {\n\t\tdict[tag.tagName.text] = tag.comment;\n\t}\n\n\treturn dict;\n}\n\nconst getScriptingClassParameterdeclaration = (\n\tscriptingClass: ScriptingClass,\n) => {\n\tfor (const member of scriptingClass.node.members) {\n\t\tif (ts.isMethodDeclaration(member)) {\n\t\t\tfor (let index = 0; index < member.parameters.length; index++) {\n\t\t\t\tconst parameter = member.parameters[index];\n\t\t\t\tif (\n\t\t\t\t\tisScriptingClassParameterDeclaration(\n\t\t\t\t\t\tscriptingClass,\n\t\t\t\t\t\tmember,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn parameter;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ts.isConstructorDeclaration(member)) {\n\t\t\tfor (let index = 0; index < member.parameters.length; index++) {\n\t\t\t\tconst parameter = member.parameters[index];\n\t\t\t\tif (\n\t\t\t\t\tisScriptingClassParameterDeclaration(\n\t\t\t\t\t\tscriptingClass,\n\t\t\t\t\t\tmember,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn parameter;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst isScriptingClassParameterDeclaration = (\n\tscriptingClass: ScriptingClass,\n\tmemberNode: ts.ClassElement,\n\tparameterIndex: number,\n) => {\n\tif (scriptingClass.type === \"evaluator\") {\n\t\treturn memberNode?.name?.getText() == \"Create\" && parameterIndex === 2;\n\t}\n\tif (scriptingClass.type === \"interactor\") {\n\t\treturn (\n\t\t\tmemberNode.kind === ts.SyntaxKind.Constructor &&\n\t\t\tparameterIndex === 0\n\t\t);\n\t}\n\treturn false;\n};\n\ninterface ScriptingClass {\n\tnode: ts.ClassDeclaration;\n\ttype: \"interactor\" | \"evaluator\";\n}\n\n/**\n * Finds interactors and evaluators within a script file\n *\n * @param {ts.Node} node\n * @return {*}\n */\nfunction* findScriptingClasses(\n\tnode: ts.Node,\n): Generator<ScriptingClass, void, void> {\n\tfor (const child of node.getChildren()) {\n\t\tif (!ts.isClassDeclaration(child)) {\n\t\t\tyield* findScriptingClasses(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst scriptingClass = detectScriptingClass(child);\n\n\t\tif (scriptingClass !== undefined) {\n\t\t\tyield scriptingClass;\n\t\t}\n\t}\n}\n\nconst detectScriptingClass = (\n\tnode: ts.ClassDeclaration,\n): ScriptingClass | undefined => {\n\tconst isEvaluator = node.heritageClauses?.some((clause) => {\n\t\tif (\n\t\t\tclause.token !== ts.SyntaxKind.ExtendsKeyword &&\n\t\t\tclause.token !== ts.SyntaxKind.ImplementsKeyword\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn clause.types.some((type) =>\n\t\t\ttype.getText().includes(\"Evaluator\"),\n\t\t);\n\t});\n\n\tif (isEvaluator) {\n\t\treturn {\n\t\t\tnode,\n\t\t\ttype: \"evaluator\",\n\t\t};\n\t}\n\n\tconst isInteractor = node.heritageClauses?.some((clause) => {\n\t\tif (clause.token !== ts.SyntaxKind.ExtendsKeyword) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn clause.types.some((type) =>\n\t\t\ttype.getText().includes(\"Interactor\"),\n\t\t);\n\t});\n\n\tif (isInteractor) {\n\t\treturn {\n\t\t\tnode,\n\t\t\ttype: \"interactor\",\n\t\t};\n\t}\n};\n"],"names":["generateIndex","location","ignore","strictOptional","arr","existingIndex","readPackageCreatorIndex","manifest","readPackageCreatorManifest","compilerOptions","readScriptPackageTSConfig","options","isModule","module","ts","ModuleKind","ES2015","ESNext","files","getPackageTypescriptFiles","filter","path","some","suffix","endsWith","program","namespaces","entryFilePath","resolveScriptPackageEntryModule","undefined","Error","host","createCompilerHost","createProgram","allowJs","entryFile","getSourceFile","resolveNamespaces","Scope","Package","typeChecker","getTypeChecker","forEach","file","sourceFile","namespace","find","includes","scriptingClass","findScriptingClasses","node","name","type","moduleNamespace","resolveNamespaceFullName","text","getFullyQualifiedName","getSymbolAtLocation","length","parameterDeclaration","getScriptingClassParameterdeclaration","parametersType","getTypeAtLocation","console","log","existingIndexEntry","entry","Name","obj","Description","Type","Parameters","rawDocTags","getJSDocTags","dict","getTagDict","summary","comment","symbol","getDocumentationComment","map","join","parseParametersList","getPropertiesOfType","getStringIndexType","push","sort","a","b","localeCompare","writePackageCreatorIndex","capitalizeFirstLetter","string","charAt","toUpperCase","slice","parseDefault","value","uType","parseFloat","parseInt","replace","parseTypeFromName","parts","split","identifier","properties","i","parameter","Default","DisplayIndex","declaration","getDeclarations","documentationComment","checkLinksSymbol","links","syntheticOrigin","creatorType","propertySignature","parsedType","getText","default","kind","SyntaxKind","PropertySignature","questionToken","Required","tags","tag","tagName","member","members","isMethodDeclaration","index","parameters","isScriptingClassParameterDeclaration","isConstructorDeclaration","memberNode","parameterIndex","Constructor","child","getChildren","isClassDeclaration","detectScriptingClass","isEvaluator","heritageClauses","clause","token","ExtendsKeyword","ImplementsKeyword","types","isInteractor"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA;;;;IAKO,SAASA,aAAAA,CAAc,EAC7BC,QAAQ,EACRC,MAAAA,GAAS,EAAE,EACXC,cAAAA,GAAiB,KAAK,EACA,EAAA;AACtB,IAAA,MAAMC,MAA2B,EAAE;IAEnC,MAAMC,aAAAA,GAAgBC,uBAAAA,CAAwBL,QAAAA,CAAAA,IAAa,EAAE;AAC7D,IAAA,MAAMM,WAAWC,0BAAAA,CAA2BP,QAAAA,CAAAA;IAE5C,MAAMQ,eAAAA,GAAkBC,yBAAAA,CAA0BT,QAAAA,CAAAA,CAAUU,OAAO;AAEnE,IAAA,MAAMC,QAAAA,GACLH,eAAAA,CAAgBI,MAAM,KAAKC,GAAGC,UAAU,CAACC,MAAM,IAC/CP,gBAAgBI,MAAM,KAAKC,EAAAA,CAAGC,UAAU,CAACE,MAAM;AAEhD,IAAA,MAAMC,KAAAA,GAAQC,yBAAAA,CAA0BlB,QAAAA,CAAAA,CAAUmB,MAAM,CACvD,CAACC,IAAAA,GAAS,CAACnB,MAAAA,CAAOoB,IAAI,CAAC,CAACC,MAAAA,GAAWF,IAAAA,CAAKG,QAAQ,CAACD,MAAAA,CAAAA,CAAAA,CAAAA;IAGlD,IAAIE,OAAAA;IACJ,IAAIC,UAAAA;AAEJ,IAAA,IAAId,QAAAA,EAAU;QACb,MAAMe,aAAAA,GAAgBC,gCACrB3B,QAAAA,EACAM,QAAAA,CAAAA;AAGD,QAAA,IAAIoB,kBAAkBE,SAAAA,EAAW;AAChC,YAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,8BAA8B,CAAC,CAAA;AACjD,QAAA;AAEA,QAAA,MAAMC,IAAAA,GAAOjB,EAAAA,CAAGkB,kBAAkB,CAAC,EAAC,EAAG,IAAA,CAAA;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wG,YAAAA,EAAc;QACjB,OAAO;AACNrG,YAAAA,IAAAA;YACAE,IAAAA,EAAM;AACP,SAAA;AACD,IAAA;AACD,CAAA;;;;"}
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import * as os from 'os';
5
5
  import 'resolve';
6
6
  import 'write-pkg';
7
- import { a as readPackageCreatorIndex, r as readPackageCreatorManifest, l as getCreatorIndexParameterPrimaryJSType } from './cli-RWjcRDQ7.mjs';
7
+ import { a as readPackageCreatorIndex, r as readPackageCreatorManifest, l as getCreatorIndexParameterPrimaryJSType } from './cli-CuiqZ39_.mjs';
8
8
  import 'glob';
9
9
  import 'node:path';
10
10
  import 'node:fs';
@@ -14,7 +14,6 @@ import 'yargs/yargs';
14
14
  import 'url';
15
15
  import 'assert';
16
16
  import 'events';
17
- import 'core-js/modules/es.typed-array.set.js';
18
17
  import 'util';
19
18
  import 'inquirer';
20
19
 
@@ -72,4 +71,4 @@ const generateParameterType = ({ location, name })=>{
72
71
  };
73
72
 
74
73
  export { generateParameterType };
75
- //# sourceMappingURL=generateParameterType-DKwRLh1m.mjs.map
74
+ //# sourceMappingURL=generateParameterType-CDjqLM4J.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateParameterType-DKwRLh1m.mjs","sources":["../src/commands/generateParameterType.ts"],"sourcesContent":["import ts from \"typescript\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as os from \"os\";\n\nimport {\n\tPackageLocation,\n\tgetCreatorIndexParameterPrimaryJSType,\n\treadPackageCreatorIndex,\n\treadPackageCreatorManifest,\n} from \"@intelligentgraphics/ig.gfx.tools.core\";\n\nexport interface GenerateParameterTypeOptions {\n\tlocation: PackageLocation;\n\tname: string;\n}\n\nexport const generateParameterType = ({\n\tlocation,\n\tname,\n}: GenerateParameterTypeOptions) => {\n\tconst index = readPackageCreatorIndex(location);\n\tconst manifest = readPackageCreatorManifest(location);\n\n\tif (index === undefined) {\n\t\tthrow new Error(`Could not find the _Index.json file`);\n\t}\n\n\tlet qualifiedName = name;\n\tlet className = name;\n\n\tconst scope = manifest.Scope ?? manifest.Package;\n\n\tif (name.startsWith(scope)) {\n\t\tclassName = name.slice(scope.length + 1);\n\t} else {\n\t\tqualifiedName = `${scope}.${name}`;\n\t}\n\n\tconst informations = index.find((item) => item.Name === qualifiedName);\n\n\tif (informations === undefined) {\n\t\tthrow new Error(`Could not find an index entry for ${name}`);\n\t}\n\n\tconst members: ts.TypeElement[] = [];\n\n\tif (informations.Parameters !== undefined) {\n\t\tconst sortedList = informations.Parameters.slice();\n\t\tsortedList.sort((a, b) => a.DisplayIndex - b.DisplayIndex);\n\n\t\tfor (const parameter of sortedList) {\n\t\t\tconst jsType = getCreatorIndexParameterPrimaryJSType(\n\t\t\t\tparameter.Type,\n\t\t\t);\n\n\t\t\tconst type =\n\t\t\t\tjsType === \"string\"\n\t\t\t\t\t? ts.factory.createTypeReferenceNode(\"string\")\n\t\t\t\t\t: ts.factory.createUnionTypeNode([\n\t\t\t\t\t\t\tts.factory.createTypeReferenceNode(jsType),\n\t\t\t\t\t\t\tts.factory.createTypeReferenceNode(\"string\"),\n\t\t\t\t\t ]);\n\n\t\t\tlet propertySignature = ts.factory.createPropertySignature(\n\t\t\t\tundefined,\n\t\t\t\tparameter.Name,\n\t\t\t\tparameter.Required\n\t\t\t\t\t? undefined\n\t\t\t\t\t: ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n\t\t\t\ttype,\n\t\t\t);\n\n\t\t\tconst jsdocParts: string[] = [];\n\n\t\t\tif (parameter.Description !== undefined) {\n\t\t\t\tjsdocParts.push(parameter.Description, \"\");\n\t\t\t}\n\n\t\t\tjsdocParts.push(`@creatorType ${parameter.Type}`);\n\n\t\t\tif (jsType === \"string\") {\n\t\t\t\tjsdocParts.push(`@default \"${parameter.Default}\"`);\n\t\t\t} else {\n\t\t\t\tjsdocParts.push(`@default ${parameter.Default}`);\n\t\t\t}\n\n\t\t\tconst jsdocContent = jsdocParts\n\t\t\t\t.map((part) => `* ${part}`)\n\t\t\t\t.join(\"\\n \");\n\t\t\tpropertySignature = ts.addSyntheticLeadingComment(\n\t\t\t\tpropertySignature,\n\t\t\t\tts.SyntaxKind.MultiLineCommentTrivia,\n\t\t\t\t`*\\n ${jsdocContent}\\n `,\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tmembers.push(propertySignature);\n\t\t}\n\t}\n\n\tconst interfaceName = `${className}Params`;\n\n\tlet interfaceDeclaration = ts.factory.createInterfaceDeclaration(\n\t\tundefined,\n\t\tinterfaceName,\n\t\tundefined,\n\t\tundefined,\n\t\tmembers,\n\t);\n\n\tinterfaceDeclaration = ts.addSyntheticLeadingComment(\n\t\tinterfaceDeclaration,\n\t\tts.SyntaxKind.MultiLineCommentTrivia,\n\t\t`*\\n * Parameters for the ${className} class\\n `,\n\t\ttrue,\n\t);\n\n\tconst printer = ts.createPrinter();\n\tconst content = printer\n\t\t.printNode(\n\t\t\tts.EmitHint.Unspecified,\n\t\t\tinterfaceDeclaration,\n\t\t\tts.createSourceFile(\"index.ts\", \"\", ts.ScriptTarget.Latest),\n\t\t)\n\t\t.replace(/ /g, \"\\t\");\n\n\tconst outFile = path.join(location.scriptsDir, `${interfaceName}.txt`);\n\n\tfs.writeFileSync(\n\t\toutFile,\n\t\t`Generated parameters interface for ${className}. Insert the interface declaration next to the class and use it as the type for the parameters. Afterwards you can delete this file.` +\n\t\t\tos.EOL +\n\t\t\tos.EOL +\n\t\t\tcontent,\n\t);\n};\n"],"names":["generateParameterType","location","name","index","readPackageCreatorIndex","manifest","readPackageCreatorManifest","undefined","Error","qualifiedName","className","scope","Scope","Package","startsWith","slice","length","informations","find","item","Name","members","Parameters","sortedList","sort","a","b","DisplayIndex","parameter","jsType","getCreatorIndexParameterPrimaryJSType","Type","type","ts","factory","createTypeReferenceNode","createUnionTypeNode","propertySignature","createPropertySignature","Required","createToken","SyntaxKind","QuestionToken","jsdocParts","Description","push","Default","jsdocContent","map","part","join","addSyntheticLeadingComment","MultiLineCommentTrivia","interfaceName","interfaceDeclaration","createInterfaceDeclaration","printer","createPrinter","content","printNode","EmitHint","Unspecified","createSourceFile","ScriptTarget","Latest","replace","outFile","path","scriptsDir","fs","writeFileSync","os","EOL"],"mappings":";;;;;;;;;;;;;;;;;;;;MAiBaA,qBAAwB,GAAA,CAAC,EACrCC,QAAQ,EACRC,IAAI,EAC0B,GAAA;AAC9B,IAAA,MAAMC,QAAQC,uBAAwBH,CAAAA,QAAAA,CAAAA,CAAAA;AACtC,IAAA,MAAMI,WAAWC,0BAA2BL,CAAAA,QAAAA,CAAAA,CAAAA;AAE5C,IAAA,IAAIE,UAAUI,SAAW,EAAA;AACxB,QAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,mCAAmC,CAAC,CAAA,CAAA;AACtD,KAAA;AAEA,IAAA,IAAIC,aAAgBP,GAAAA,IAAAA,CAAAA;AACpB,IAAA,IAAIQ,SAAYR,GAAAA,IAAAA,CAAAA;AAEhB,IAAA,MAAMS,KAAQN,GAAAA,QAAAA,CAASO,KAAK,IAAIP,SAASQ,OAAO,CAAA;IAEhD,IAAIX,IAAAA,CAAKY,UAAU,CAACH,KAAQ,CAAA,EAAA;AAC3BD,QAAAA,SAAAA,GAAYR,IAAKa,CAAAA,KAAK,CAACJ,KAAAA,CAAMK,MAAM,GAAG,CAAA,CAAA,CAAA;KAChC,MAAA;AACNP,QAAAA,aAAAA,GAAgB,CAAC,EAAEE,KAAAA,CAAM,CAAC,EAAET,KAAK,CAAC,CAAA;AACnC,KAAA;IAEA,MAAMe,YAAAA,GAAed,MAAMe,IAAI,CAAC,CAACC,IAASA,GAAAA,IAAAA,CAAKC,IAAI,KAAKX,aAAAA,CAAAA,CAAAA;AAExD,IAAA,IAAIQ,iBAAiBV,SAAW,EAAA;AAC/B,QAAA,MAAM,IAAIC,KAAM,CAAA,CAAC,kCAAkC,EAAEN,KAAK,CAAC,CAAA,CAAA;AAC5D,KAAA;AAEA,IAAA,MAAMmB,UAA4B,EAAE,C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,GAAG2B,QAAQ,CAACC,WAAW,EACvBP,oBACArB,EAAAA,EAAAA,CAAG6B,gBAAgB,CAAC,UAAA,EAAY,IAAI7B,EAAG8B,CAAAA,YAAY,CAACC,MAAM,CAAA,CAAA,CAE1DC,OAAO,CAAC,OAAS,EAAA,IAAA,CAAA,CAAA;IAEnB,MAAMC,OAAAA,GAAUC,IAAKjB,CAAAA,IAAI,CAACjD,QAAAA,CAASmE,UAAU,EAAE,CAAC,EAAEf,aAAc,CAAA,IAAI,CAAC,CAAA,CAAA;AAErEgB,IAAAA,EAAAA,CAAGC,aAAa,CACfJ,OACA,EAAA,CAAC,mCAAmC,EAAExD,SAAAA,CAAU,oIAAoI,CAAC,GACpL6D,EAAGC,CAAAA,GAAG,GACND,EAAAA,CAAGC,GAAG,GACNd,OAAAA,CAAAA,CAAAA;AAEH;;;;"}
1
+ {"version":3,"file":"generateParameterType-CDjqLM4J.mjs","sources":["../src/commands/generateParameterType.ts"],"sourcesContent":["import ts from \"typescript\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as os from \"os\";\n\nimport {\n\tPackageLocation,\n\tgetCreatorIndexParameterPrimaryJSType,\n\treadPackageCreatorIndex,\n\treadPackageCreatorManifest,\n} from \"@intelligentgraphics/ig.gfx.tools.core\";\n\nexport interface GenerateParameterTypeOptions {\n\tlocation: PackageLocation;\n\tname: string;\n}\n\nexport const generateParameterType = ({\n\tlocation,\n\tname,\n}: GenerateParameterTypeOptions) => {\n\tconst index = readPackageCreatorIndex(location);\n\tconst manifest = readPackageCreatorManifest(location);\n\n\tif (index === undefined) {\n\t\tthrow new Error(`Could not find the _Index.json file`);\n\t}\n\n\tlet qualifiedName = name;\n\tlet className = name;\n\n\tconst scope = manifest.Scope ?? manifest.Package;\n\n\tif (name.startsWith(scope)) {\n\t\tclassName = name.slice(scope.length + 1);\n\t} else {\n\t\tqualifiedName = `${scope}.${name}`;\n\t}\n\n\tconst informations = index.find((item) => item.Name === qualifiedName);\n\n\tif (informations === undefined) {\n\t\tthrow new Error(`Could not find an index entry for ${name}`);\n\t}\n\n\tconst members: ts.TypeElement[] = [];\n\n\tif (informations.Parameters !== undefined) {\n\t\tconst sortedList = informations.Parameters.slice();\n\t\tsortedList.sort((a, b) => a.DisplayIndex - b.DisplayIndex);\n\n\t\tfor (const parameter of sortedList) {\n\t\t\tconst jsType = getCreatorIndexParameterPrimaryJSType(\n\t\t\t\tparameter.Type,\n\t\t\t);\n\n\t\t\tconst type =\n\t\t\t\tjsType === \"string\"\n\t\t\t\t\t? ts.factory.createTypeReferenceNode(\"string\")\n\t\t\t\t\t: ts.factory.createUnionTypeNode([\n\t\t\t\t\t\t\tts.factory.createTypeReferenceNode(jsType),\n\t\t\t\t\t\t\tts.factory.createTypeReferenceNode(\"string\"),\n\t\t\t\t\t ]);\n\n\t\t\tlet propertySignature = ts.factory.createPropertySignature(\n\t\t\t\tundefined,\n\t\t\t\tparameter.Name,\n\t\t\t\tparameter.Required\n\t\t\t\t\t? undefined\n\t\t\t\t\t: ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n\t\t\t\ttype,\n\t\t\t);\n\n\t\t\tconst jsdocParts: string[] = [];\n\n\t\t\tif (parameter.Description !== undefined) {\n\t\t\t\tjsdocParts.push(parameter.Description, \"\");\n\t\t\t}\n\n\t\t\tjsdocParts.push(`@creatorType ${parameter.Type}`);\n\n\t\t\tif (jsType === \"string\") {\n\t\t\t\tjsdocParts.push(`@default \"${parameter.Default}\"`);\n\t\t\t} else {\n\t\t\t\tjsdocParts.push(`@default ${parameter.Default}`);\n\t\t\t}\n\n\t\t\tconst jsdocContent = jsdocParts\n\t\t\t\t.map((part) => `* ${part}`)\n\t\t\t\t.join(\"\\n \");\n\t\t\tpropertySignature = ts.addSyntheticLeadingComment(\n\t\t\t\tpropertySignature,\n\t\t\t\tts.SyntaxKind.MultiLineCommentTrivia,\n\t\t\t\t`*\\n ${jsdocContent}\\n `,\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tmembers.push(propertySignature);\n\t\t}\n\t}\n\n\tconst interfaceName = `${className}Params`;\n\n\tlet interfaceDeclaration = ts.factory.createInterfaceDeclaration(\n\t\tundefined,\n\t\tinterfaceName,\n\t\tundefined,\n\t\tundefined,\n\t\tmembers,\n\t);\n\n\tinterfaceDeclaration = ts.addSyntheticLeadingComment(\n\t\tinterfaceDeclaration,\n\t\tts.SyntaxKind.MultiLineCommentTrivia,\n\t\t`*\\n * Parameters for the ${className} class\\n `,\n\t\ttrue,\n\t);\n\n\tconst printer = ts.createPrinter();\n\tconst content = printer\n\t\t.printNode(\n\t\t\tts.EmitHint.Unspecified,\n\t\t\tinterfaceDeclaration,\n\t\t\tts.createSourceFile(\"index.ts\", \"\", ts.ScriptTarget.Latest),\n\t\t)\n\t\t.replace(/ /g, \"\\t\");\n\n\tconst outFile = path.join(location.scriptsDir, `${interfaceName}.txt`);\n\n\tfs.writeFileSync(\n\t\toutFile,\n\t\t`Generated parameters interface for ${className}. Insert the interface declaration next to the class and use it as the type for the parameters. Afterwards you can delete this file.` +\n\t\t\tos.EOL +\n\t\t\tos.EOL +\n\t\t\tcontent,\n\t);\n};\n"],"names":["generateParameterType","location","name","index","readPackageCreatorIndex","manifest","readPackageCreatorManifest","undefined","Error","qualifiedName","className","scope","Scope","Package","startsWith","slice","length","informations","find","item","Name","members","Parameters","sortedList","sort","a","b","DisplayIndex","parameter","jsType","getCreatorIndexParameterPrimaryJSType","Type","type","ts","factory","createTypeReferenceNode","createUnionTypeNode","propertySignature","createPropertySignature","Required","createToken","SyntaxKind","QuestionToken","jsdocParts","Description","push","Default","jsdocContent","map","part","join","addSyntheticLeadingComment","MultiLineCommentTrivia","interfaceName","interfaceDeclaration","createInterfaceDeclaration","printer","createPrinter","content","printNode","EmitHint","Unspecified","createSourceFile","ScriptTarget","Latest","replace","outFile","path","scriptsDir","fs","writeFileSync","os","EOL"],"mappings":";;;;;;;;;;;;;;;;;;;MAiBaA,qBAAAA,GAAwB,CAAC,EACrCC,QA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