@komaci/esm-generator 240.1.4 → 242.0.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.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -28,12 +28,12 @@ describe('updateKomaciDocumentWithValidTemplatedStrings', () => {
28
28
  memberUsage: [],
29
29
  },
30
30
  ];
31
- (0, shared_1.updateKomaciDocumentWithValidTemplatedStrings)(komaciDoc, templateStringsInfo);
31
+ (0, common_shared_1.updateKomaciDocumentWithValidTemplatedStrings)(komaciDoc, templateStringsInfo);
32
32
  expect(komaciDoc.adgs?.[0].functions).toHaveLength(3);
33
- expect(komaciDoc.adgs?.[0].functions?.[1].type).toBe(shared_1.TEMPLATED_STRING_FUNCTION);
33
+ expect(komaciDoc.adgs?.[0].functions?.[1].type).toBe(common_shared_1.TEMPLATED_STRING_FUNCTION);
34
34
  expect(komaciDoc.adgs?.[0].functions?.[1].reference.type).toBe('InternalReference');
35
35
  expect(komaciDoc.adgs?.[0].functions?.[1].reference.value).toBe('t0');
36
- expect(komaciDoc.adgs?.[0].functions?.[2].type).toBe(shared_1.TEMPLATED_STRING_FUNCTION);
36
+ expect(komaciDoc.adgs?.[0].functions?.[2].type).toBe(common_shared_1.TEMPLATED_STRING_FUNCTION);
37
37
  expect(komaciDoc.adgs?.[0].functions?.[2].reference.type).toBe('InternalReference');
38
38
  expect(komaciDoc.adgs?.[0].functions?.[2].reference.value).toBe('t1');
39
39
  });
package/build/index.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- import { GeneratorInput } from './types';
1
+ import { GeneratorInput, GeneratorState } from './types';
2
2
  export { GeneratorInput } from './types';
3
3
  export declare function generateKomaciModule(input: GeneratorInput): string;
4
+ /**
5
+ * Helper function to process and build the resolvable module based off the generator input and inital generator state.
6
+ * @param input the Generator input
7
+ * @param generatorState the inital generator state
8
+ * @returns the resolvable module.
9
+ */
10
+ export declare function processGeneratorInputAndState(input: GeneratorInput, generatorState: GeneratorState): string;
4
11
  //# sourceMappingURL=index.d.ts.map
package/build/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -22,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
27
  };
24
28
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.generateKomaciModule = void 0;
29
+ exports.processGeneratorInputAndState = exports.generateKomaciModule = void 0;
26
30
  const generator_1 = __importDefault(require("@babel/generator"));
27
31
  const shared_1 = require("./shared");
28
32
  const modGenScript_1 = require("./modGenScript");
@@ -53,78 +57,88 @@ function generateKomaciModule(input) {
53
57
  isDefaultExportFound: false,
54
58
  };
55
59
  try {
56
- if (input.moduleInfo.type === 'file') {
60
+ return processGeneratorInputAndState(input, generatorState);
61
+ }
62
+ catch (e) {
63
+ const babelOutput = (0, generator_1.default)(t.file((0, modGenScript_1.produceErrorAdgFunction)(generatorState, e)));
64
+ return babelOutput.code;
65
+ }
66
+ }
67
+ exports.generateKomaciModule = generateKomaciModule;
68
+ /**
69
+ * Helper function to process and build the resolvable module based off the generator input and inital generator state.
70
+ * @param input the Generator input
71
+ * @param generatorState the inital generator state
72
+ * @returns the resolvable module.
73
+ */
74
+ function processGeneratorInputAndState(input, generatorState) {
75
+ if (input.moduleInfo.type === 'file') {
76
+ // Determine file type based on extension in file name.
77
+ const segments = input.moduleInfo.fileName.split('.');
78
+ if (segments.length < 2) {
79
+ throw new Error(shared_1.ERROR_PREFIX + 'unable to determine file type');
80
+ }
81
+ const fileExt = segments[segments.length - 1];
82
+ let sourceFile;
83
+ if (fileExt === 'html') {
84
+ sourceFile = (0, modGenTemplate_1.generateTemplateModule)(generatorState, input.moduleInfo.komaciDoc);
85
+ }
86
+ else if (fileExt === 'js') {
87
+ sourceFile = (0, modGenScript_1.generateScriptModule)(generatorState, input.moduleInfo.komaciDoc);
88
+ }
89
+ else {
90
+ throw new Error(shared_1.ERROR_PREFIX + 'unsupported file extension: ' + fileExt);
91
+ }
92
+ const babelOutput = (0, generator_1.default)(sourceFile);
93
+ return babelOutput.code;
94
+ }
95
+ else if (input.moduleInfo.type === 'bundle') {
96
+ // code to process a bundle
97
+ let filename = '', fileExt;
98
+ const docMap = input.moduleInfo.files; // {'test.html' : KomaciDoc1, 'test.js' : KomaciDoc2}
99
+ const filesMap = {}; // {'html' : {'test.html' : KomaciDoc1}, 'js' : {'test.js' : KomaciDoc2 }}
100
+ let sourceFile;
101
+ for (const [fullFilename, komaciDoc] of Object.entries(docMap)) {
57
102
  // Determine file type based on extension in file name.
58
- const segments = input.moduleInfo.fileName.split('.');
103
+ const segments = fullFilename.split('.');
59
104
  if (segments.length < 2) {
60
105
  throw new Error(shared_1.ERROR_PREFIX + 'unable to determine file type');
61
106
  }
62
- const fileExt = segments[segments.length - 1];
63
- let sourceFile;
64
- if (fileExt === 'html') {
65
- sourceFile = (0, modGenTemplate_1.generateTemplateModule)(generatorState, input.moduleInfo.komaciDoc);
107
+ filename = segments[0]; // the filename, up to but not including, the file separator character
108
+ fileExt = segments[segments.length - 1]; // filename extension, not including the separator
109
+ if (filename !== input.moduleInfo.name) {
110
+ continue; // ignore files whose name do not match moduleInfo.name
111
+ }
112
+ let filesObj = {};
113
+ // check for existing map entry in order to append to it
114
+ // to support multiple files per filetype in the future
115
+ if (filesMap[fileExt]) {
116
+ filesObj = filesMap[fileExt];
117
+ }
118
+ filesObj[filename] = komaciDoc;
119
+ if (fileExt == 'html') {
120
+ filesMap['html'] = filesObj;
66
121
  }
67
122
  else if (fileExt === 'js') {
68
- sourceFile = (0, modGenScript_1.generateScriptModule)(generatorState, input.moduleInfo.komaciDoc);
123
+ filesMap['js'] = filesObj;
69
124
  }
70
125
  else {
71
126
  throw new Error(shared_1.ERROR_PREFIX + 'unsupported file extension: ' + fileExt);
72
127
  }
73
- const babelOutput = (0, generator_1.default)(sourceFile);
74
- return babelOutput.code;
75
128
  }
76
- else if (input.moduleInfo.type === 'bundle') {
77
- // code to process a bundle
78
- let filename = '', fileExt;
79
- const docMap = input.moduleInfo.files; // {'test.html' : KomaciDoc1, 'test.js' : KomaciDoc2}
80
- const filesMap = {}; // {'html' : {'test.html' : KomaciDoc1}, 'js' : {'test.js' : KomaciDoc2 }}
81
- let sourceFile;
82
- for (const [fullFilename, komaciDoc] of Object.entries(docMap)) {
83
- // Determine file type based on extension in file name.
84
- const segments = fullFilename.split('.');
85
- if (segments.length < 2) {
86
- throw new Error(shared_1.ERROR_PREFIX + 'unable to determine file type');
87
- }
88
- filename = segments[0]; // the filename, up to but not including, the file separator character
89
- fileExt = segments[segments.length - 1]; // filename extension, not including the separator
90
- if (filename !== input.moduleInfo.name) {
91
- continue; // ignore files whose name do not match moduleInfo.name
92
- }
93
- let filesObj = {};
94
- // check for existing map entry in order to append to it
95
- // to support multiple files per filetype in the future
96
- if (filesMap[fileExt]) {
97
- filesObj = filesMap[fileExt];
98
- }
99
- filesObj[filename] = komaciDoc;
100
- if (fileExt == 'html') {
101
- filesMap['html'] = filesObj;
102
- }
103
- else if (fileExt === 'js') {
104
- filesMap['js'] = filesObj;
105
- }
106
- else {
107
- throw new Error(shared_1.ERROR_PREFIX + 'unsupported file extension: ' + fileExt);
108
- }
109
- }
110
- const komaciJSDoc = filesMap && filesMap['js'] && filesMap['js'][input.moduleInfo.name]
111
- ? filesMap['js'][input.moduleInfo.name]
112
- : {};
113
- const komaciHTMLDoc = filesMap && filesMap['html'] && filesMap['html'][input.moduleInfo.name]
114
- ? filesMap['html'][input.moduleInfo.name]
115
- : {};
116
- // eslint-disable-next-line prefer-const
117
- sourceFile = (0, modGenScript_1.generateCombinedModule)(generatorState, komaciJSDoc, komaciHTMLDoc);
118
- // Generate source from constructed AST.
119
- const babelOutput = (0, generator_1.default)(sourceFile);
120
- return babelOutput.code;
121
- }
122
- throw new Error(shared_1.ERROR_PREFIX + 'unrecognized input type');
123
- }
124
- catch (e) {
125
- const babelOutput = (0, generator_1.default)(t.file((0, modGenScript_1.produceErrorAdgFunction)(generatorState, e)));
129
+ const komaciJSDoc = filesMap && filesMap['js'] && filesMap['js'][input.moduleInfo.name]
130
+ ? filesMap['js'][input.moduleInfo.name]
131
+ : {};
132
+ const komaciHTMLDoc = filesMap && filesMap['html'] && filesMap['html'][input.moduleInfo.name]
133
+ ? filesMap['html'][input.moduleInfo.name]
134
+ : {};
135
+ // eslint-disable-next-line prefer-const
136
+ sourceFile = (0, modGenScript_1.generateCombinedModule)(generatorState, komaciJSDoc, komaciHTMLDoc);
137
+ // Generate source from constructed AST.
138
+ const babelOutput = (0, generator_1.default)(sourceFile);
126
139
  return babelOutput.code;
127
140
  }
141
+ throw new Error(shared_1.ERROR_PREFIX + 'unrecognized input type');
128
142
  }
129
- exports.generateKomaciModule = generateKomaciModule;
143
+ exports.processGeneratorInputAndState = processGeneratorInputAndState;
130
144
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -66,8 +70,8 @@ function generateScriptModule(generatorState, komaciDoc) {
66
70
  // once we know what getters are using which imports, modify the functions array in the komaci documents
67
71
  // (in memory) as well property references in the Properties array
68
72
  updateImportsWithGetterConsumption(komaciDoc, moduleLevelConsumption.consumedImports);
69
- (0, shared_1.updateKomaciDocumentWithValidGetters)(komaciDoc, processedGetterContext);
70
- (0, shared_1.updateKomaciDocumentWithValidTemplatedStrings)(komaciDoc, processedTemplateStrings);
73
+ (0, common_shared_1.updateKomaciDocumentWithValidGetters)(komaciDoc, processedGetterContext);
74
+ (0, common_shared_1.updateKomaciDocumentWithValidTemplatedStrings)(komaciDoc, processedTemplateStrings);
71
75
  }
72
76
  // Import default composition if not in-lined into the ADGs.
73
77
  importDefaultCompositionIfNotInlinedIntoADG(generatorState, komaciDoc.adgs, statements);
@@ -182,8 +186,8 @@ function generateCombinedModule(generatorState, komaciScriptDoc, komaciTemplateD
182
186
  // once we know what getters are using which imports, modify the functions array in the komaci documents
183
187
  // (in memory) as well property references in the Properties array
184
188
  updateImportsWithGetterConsumption(komaciScriptDoc, moduleLevelConsumption.consumedImports);
185
- (0, shared_1.updateKomaciDocumentWithValidGetters)(komaciScriptDoc, processedGetterContext);
186
- (0, shared_1.updateKomaciDocumentWithValidTemplatedStrings)(komaciScriptDoc, processedTemplateStrings);
189
+ (0, common_shared_1.updateKomaciDocumentWithValidGetters)(komaciScriptDoc, processedGetterContext);
190
+ (0, common_shared_1.updateKomaciDocumentWithValidTemplatedStrings)(komaciScriptDoc, processedTemplateStrings);
187
191
  }
188
192
  generatorState.inlineTemplateDoc = komaciTemplateDoc;
189
193
  if (doesScriptHaveADGs(komaciScriptDoc)) {
@@ -752,8 +756,8 @@ adgFunc) {
752
756
  const getterFuncObjPropArr = processLocalFunction(adgFunc, shared_1.GETTER_FUNCTION);
753
757
  return t.objectExpression(getterFuncObjPropArr);
754
758
  }
755
- else if (adgFunc.type === shared_1.TEMPLATED_STRING_FUNCTION) {
756
- return t.objectExpression(processLocalFunction(adgFunc, shared_1.TEMPLATED_STRING_FUNCTION));
759
+ else if (adgFunc.type === common_shared_1.TEMPLATED_STRING_FUNCTION) {
760
+ return t.objectExpression(processLocalFunction(adgFunc, common_shared_1.TEMPLATED_STRING_FUNCTION));
757
761
  }
758
762
  else if (adgFunc.type === shared_1.ERROR_FUNCTION) {
759
763
  return t.objectExpression(processErrorFunction(generatorState, adgFunc));
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/build/shared.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as t from '@babel/types';
2
2
  import { GeneratorState, ImportInfo, ImportUsageState } from './types';
3
- import { Binding, PrimitiveValue, Value, PropertyReference, FunctionType, KomaciDocument, Adg } from '@komaci/types';
3
+ import { Binding, PrimitiveValue, Value, PropertyReference } from '@komaci/types';
4
4
  import { NodePath } from '@babel/core';
5
5
  import { ValidGetterContext, ValidTemplateContext, ModuleLevelConsumption, AstContext, ClassPropertyContexts, ModuleContext } from '@komaci/common-shared';
6
6
  export declare const ERROR_PREFIX = "[komaci esm-generator] ";
@@ -11,7 +11,6 @@ export declare const UNRESOLVED = "unresolved";
11
11
  export declare const USER_VARIABLE_PREFIX = "user_var_";
12
12
  export declare const WIRE_FUNCTION = "WireFunction";
13
13
  export declare const GETTER_FUNCTION = "GetterFunction";
14
- export declare const TEMPLATED_STRING_FUNCTION = "TemplatedStringFunction";
15
14
  export declare const ERROR_FUNCTION = "ErrorFunction";
16
15
  export declare const PRIMING_FUNCTION = "PrimingFunction";
17
16
  export declare const ID: {
@@ -105,13 +104,6 @@ export declare function processGetters(properties: ClassPropertyContexts, module
105
104
  export declare function transformGetters(genCombinedModuleAST: t.File, importReferencesMap: {
106
105
  [refId: string]: ImportInfo;
107
106
  }, getterImportUsage: AstContext['importDeclarations'], validGetterContexts: ValidGetterContext[]): void;
108
- /**
109
- * Function to update the Komaci Document with validated getter information. This function will update the functions array in the
110
- * export default adg along with the property references in the property array.
111
- * @param komaciScriptDoc the komaci document
112
- * @param validGetterContext a collection
113
- */
114
- export declare function updateKomaciDocumentWithValidGetters(komaciScriptDoc: KomaciDocument, validGetterContext: ValidGetterContext[]): void;
115
107
  /**
116
108
  * Validate what templates are good and then uplift the metadata about how they interact with other portions of the modules.
117
109
  * i.e. import, property references, used in priming
@@ -154,17 +146,4 @@ export declare function mapRealNameToGenerated(importReferencesMap: {
154
146
  * @param trueToGeneratedImport Mapping of real import name to generated name
155
147
  */
156
148
  export declare function sanitizeFunction(nodePath: NodePath<t.ClassProperty | t.ClassMethod>, definedImports: AstContext['importDeclarations'], trueToGeneratedImport: Map<string, string>): void;
157
- /**
158
- * Function to update the Komaci Document with validated template information. This function will update the functions array in the
159
- * export default adg along with the property references in the property array.
160
- * @param komaciScriptDoc the komaci document
161
- * @param ValidTemplateContext details about the templates we've deemed to be valid
162
- */
163
- export declare function updateKomaciDocumentWithValidTemplatedStrings(komaciScriptDoc: KomaciDocument, templateStrings: ValidTemplateContext[]): void;
164
- /**
165
- * Update the functions array with the newly formed function reference and point the property to it
166
- * @param adg The adg to update
167
- * @param propertyName name of the property to update
168
- */
169
- export declare function addPropertyFunction(adg: Adg, propertyName: string, func: FunctionType): number;
170
149
  //# sourceMappingURL=shared.d.ts.map
package/build/shared.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
23
  return result;
20
24
  };
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.addPropertyFunction = exports.updateKomaciDocumentWithValidTemplatedStrings = exports.sanitizeFunction = exports.mapRealNameToGenerated = exports.hoistTemplateStrings = exports.processTemplateStrings = exports.updateKomaciDocumentWithValidGetters = exports.transformGetters = exports.processGetters = exports.getComponentSrcJs = exports.valueToExpression = exports.bindingRootToExpression = exports.bindingToExpression = exports.primitiveToExpression = exports.getFactoryFuncDeclaration = exports.retrieveImportInfo = exports.updateImportInfoState = exports.ID = exports.PRIMING_FUNCTION = exports.ERROR_FUNCTION = exports.TEMPLATED_STRING_FUNCTION = exports.GETTER_FUNCTION = exports.WIRE_FUNCTION = exports.USER_VARIABLE_PREFIX = exports.UNRESOLVED = exports.ADG_IMPORT_SUFFIX = exports.PROPS = exports.CONTEXT = exports.ERROR_PREFIX = void 0;
26
+ exports.sanitizeFunction = exports.mapRealNameToGenerated = exports.hoistTemplateStrings = exports.processTemplateStrings = exports.transformGetters = exports.processGetters = exports.getComponentSrcJs = exports.valueToExpression = exports.bindingRootToExpression = exports.bindingToExpression = exports.primitiveToExpression = exports.getFactoryFuncDeclaration = exports.retrieveImportInfo = exports.updateImportInfoState = exports.ID = exports.PRIMING_FUNCTION = exports.ERROR_FUNCTION = exports.GETTER_FUNCTION = exports.WIRE_FUNCTION = exports.USER_VARIABLE_PREFIX = exports.UNRESOLVED = exports.ADG_IMPORT_SUFFIX = exports.PROPS = exports.CONTEXT = exports.ERROR_PREFIX = void 0;
23
27
  const t = __importStar(require("@babel/types"));
24
28
  const types_1 = require("./types");
25
29
  const static_analyzer_1 = require("@komaci/static-analyzer");
@@ -32,7 +36,6 @@ exports.UNRESOLVED = 'unresolved';
32
36
  exports.USER_VARIABLE_PREFIX = 'user_var_';
33
37
  exports.WIRE_FUNCTION = 'WireFunction';
34
38
  exports.GETTER_FUNCTION = 'GetterFunction';
35
- exports.TEMPLATED_STRING_FUNCTION = 'TemplatedStringFunction';
36
39
  exports.ERROR_FUNCTION = 'ErrorFunction';
37
40
  exports.PRIMING_FUNCTION = 'PrimingFunction';
38
41
  exports.ID = {
@@ -352,49 +355,6 @@ function transformGetters(genCombinedModuleAST, importReferencesMap, getterImpor
352
355
  body.splice(insertBeforeIndex, 0, ...hoistedGetters);
353
356
  }
354
357
  exports.transformGetters = transformGetters;
355
- /**
356
- * Function to update the Komaci Document with validated getter information. This function will update the functions array in the
357
- * export default adg along with the property references in the property array.
358
- * @param komaciScriptDoc the komaci document
359
- * @param validGetterContext a collection
360
- */
361
- function updateKomaciDocumentWithValidGetters(komaciScriptDoc, validGetterContext) {
362
- if (komaciScriptDoc.exports) {
363
- //get the exort mapping for the export default
364
- const defaultExportMapping = komaciScriptDoc.exports['default'];
365
- if (defaultExportMapping && defaultExportMapping.type === 'AdgReference') {
366
- const defaultExportAdg = komaciScriptDoc.adgs?.[defaultExportMapping.value];
367
- //foreach getter in the context.
368
- validGetterContext.forEach((getter) => {
369
- //Get the name of the getter.
370
- const getterName = getter.getter.node.key.name;
371
- const inputArr = {
372
- type: 'ArrayValue',
373
- value: [],
374
- };
375
- getter.memberUsage.forEach((member) => {
376
- const primVal = {
377
- type: 'PrimitiveValue',
378
- value: member,
379
- };
380
- inputArr.value.push(primVal);
381
- });
382
- //create a new functionType obj with getter information.
383
- const validGetterFunction = {
384
- type: exports.GETTER_FUNCTION,
385
- reference: { type: 'InternalReference', value: getter.generatedName },
386
- input: [inputArr],
387
- location: undefined,
388
- };
389
- //if we have an adg make changes to it.
390
- if (defaultExportAdg) {
391
- getter.f_index = addPropertyFunction(defaultExportAdg, getterName, validGetterFunction);
392
- }
393
- });
394
- }
395
- }
396
- }
397
- exports.updateKomaciDocumentWithValidGetters = updateKomaciDocumentWithValidGetters;
398
358
  /**
399
359
  * Validate what templates are good and then uplift the metadata about how they interact with other portions of the modules.
400
360
  * i.e. import, property references, used in priming
@@ -517,72 +477,4 @@ function sanitizeFunction(nodePath, definedImports, trueToGeneratedImport) {
517
477
  nodePath.traverse(Visitors);
518
478
  }
519
479
  exports.sanitizeFunction = sanitizeFunction;
520
- /**
521
- * Function to update the Komaci Document with validated template information. This function will update the functions array in the
522
- * export default adg along with the property references in the property array.
523
- * @param komaciScriptDoc the komaci document
524
- * @param ValidTemplateContext details about the templates we've deemed to be valid
525
- */
526
- function updateKomaciDocumentWithValidTemplatedStrings(komaciScriptDoc, templateStrings) {
527
- if (komaciScriptDoc.exports?.default?.type === 'AdgReference') {
528
- const adg = komaciScriptDoc.adgs?.[komaciScriptDoc.exports.default.value];
529
- if (adg) {
530
- templateStrings.forEach((template) => {
531
- const propertyName = template.template.node.key.name;
532
- const inputArr = {
533
- type: 'ArrayValue',
534
- value: [],
535
- };
536
- template.memberUsage.forEach((member) => {
537
- const primVal = {
538
- type: 'PrimitiveValue',
539
- value: member,
540
- };
541
- inputArr.value.push(primVal);
542
- });
543
- const validTemplateStringFunction = {
544
- type: exports.TEMPLATED_STRING_FUNCTION,
545
- reference: {
546
- type: 'InternalReference',
547
- value: template.generatedName,
548
- },
549
- input: [inputArr],
550
- location: undefined,
551
- };
552
- //if we have an adg make changes to it.
553
- if (adg) {
554
- template.f_index = addPropertyFunction(adg, propertyName, validTemplateStringFunction);
555
- }
556
- });
557
- }
558
- }
559
- }
560
- exports.updateKomaciDocumentWithValidTemplatedStrings = updateKomaciDocumentWithValidTemplatedStrings;
561
- /**
562
- * Update the functions array with the newly formed function reference and point the property to it
563
- * @param adg The adg to update
564
- * @param propertyName name of the property to update
565
- */
566
- function addPropertyFunction(adg, propertyName, func) {
567
- if (!adg.functions) {
568
- adg.functions = [];
569
- }
570
- if (!adg.properties) {
571
- adg.properties = {};
572
- }
573
- //push getter onto array get the length.
574
- const fIndex = adg.functions.push(func);
575
- const refIndex = fIndex - 1;
576
- //create new property to reference function array.
577
- const property = {
578
- isPublic: adg.properties[propertyName]?.isPublic || false,
579
- input: {
580
- type: 'FunctionReference',
581
- value: refIndex,
582
- },
583
- };
584
- adg.properties[propertyName] = property;
585
- return refIndex;
586
- }
587
- exports.addPropertyFunction = addPropertyFunction;
588
480
  //# sourceMappingURL=shared.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@komaci/esm-generator",
3
- "version": "240.1.4",
3
+ "version": "242.0.0",
4
4
  "description": "Komaci generator for ADG ES modules",
5
5
  "homepage": "https://komaci.dev/",
6
6
  "repository": {
@@ -28,13 +28,13 @@
28
28
  "dependencies": {
29
29
  "@babel/core": "^7.9.0",
30
30
  "@babel/generator": "^7.9.0",
31
- "@komaci/common-shared": "240.1.4",
32
- "@komaci/static-analyzer": "240.1.4",
31
+ "@komaci/common-shared": "242.0.0",
32
+ "@komaci/static-analyzer": "242.0.0",
33
33
  "o11y": "^240.7.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@babel/types": "^7.9.0",
37
- "@komaci/types": "240.1.4",
37
+ "@komaci/types": "242.0.0",
38
38
  "@lwc-platform/sfdc-lwc-compiler": "^2.18.0-240.2"
39
39
  }
40
40
  }