@komaci/common-shared 242.0.0 → 242.1.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.
- package/build/adaptersMapping.d.ts +3 -0
- package/build/adaptersMapping.js +29 -0
- package/build/allowlistAdapters.d.ts +6 -0
- package/build/allowlistAdapters.js +10 -0
- package/build/allowlistNamespaces.d.ts +6 -0
- package/build/allowlistNamespaces.js +21 -1
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/build/internal-namespaces.json +14 -0
- package/build/komaci-mapping.json +288 -0
- package/build/komaciDocumentIntrospection.d.ts +45 -20
- package/build/komaciDocumentIntrospection.js +224 -121
- package/build/moduleMetadata.d.ts +130 -8
- package/build/moduleMetadata.js +543 -16
- package/build/types.d.ts +139 -97
- package/build/types.js +46 -3
- package/build/utils.d.ts +5 -27
- package/build/utils.js +30 -207
- package/build/wires.d.ts +12 -0
- package/build/wires.js +56 -0
- package/package.json +4 -3
package/build/types.d.ts
CHANGED
|
@@ -1,77 +1,50 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import { PrimitiveValue, PropertyReference, UnresolvedValue, ImportReference as KomaciDocImportReference, Binding, KomaciDocument, FunctionType } from '@komaci/types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export declare type ValidTemplateContext = {
|
|
39
|
-
template: NodePath<t.ClassProperty>;
|
|
40
|
-
memberUsage: Array<string>;
|
|
41
|
-
generatedName: string;
|
|
42
|
-
f_index?: number;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @typedef ImportDeclarationInfo is an object that holds information about the import declarations
|
|
46
|
-
* @property {string} identifierName is the name of the imported resource.
|
|
47
|
-
* @property {string} namespace Full import source path
|
|
48
|
-
* @property {boolean} isSupported a boolean field to determine if an import is supported or not.
|
|
49
|
-
* @property {boolean} isDefault a boolean field to determine if an import is the default import.
|
|
50
|
-
* @property {boolean} isNamespaceSpecifier a boolean field to determine if an import is a namespace import.
|
|
51
|
-
* @property {string} trueName sometimes imports are renamed so we maintain their true name for later processing
|
|
52
|
-
*/
|
|
53
|
-
export declare type ImportDeclarationInfo = {
|
|
54
|
-
identifierName: string;
|
|
55
|
-
namespace: string;
|
|
56
|
-
isSupported: boolean;
|
|
57
|
-
isDefault: boolean;
|
|
58
|
-
isNamespaceSpecifier: boolean;
|
|
59
|
-
trueName?: string;
|
|
60
|
-
};
|
|
3
|
+
import { PrimitiveValue, PropertyReference, UnresolvedValue, ImportReference as KomaciDocImportReference, Binding, KomaciDocument, FunctionType, StaticValue, Adg, Value } from '@komaci/types';
|
|
4
|
+
export declare const ERROR_PREFIX = "[komaci] ";
|
|
5
|
+
export declare const CONTEXT = "ctx";
|
|
6
|
+
export declare const PROPS = "props";
|
|
7
|
+
export declare enum IdKeys {
|
|
8
|
+
CONTEXT = "CONTEXT",
|
|
9
|
+
PROPS = "PROPS",
|
|
10
|
+
FACTORY = "FACTORY",
|
|
11
|
+
COMPOSED_GRAPH_FUNC = "COMPOSED_GRAPH_FUNC",
|
|
12
|
+
ITERATION_FUNC = "ITERATION_FUNC",
|
|
13
|
+
UNRESOLVED_FUNC = "UNRESOLVED_FUNC",
|
|
14
|
+
SLOT_FUNC = "SLOT_FUNC",
|
|
15
|
+
ELEMENT_FUNC = "ELEMENT_FUNC",
|
|
16
|
+
ADG_FUNC = "ADG_FUNC",
|
|
17
|
+
SLOT = "SLOT",
|
|
18
|
+
COMPONENT_ID = "COMPONENT_ID",
|
|
19
|
+
UNDEFINED = "UNDEFINED",
|
|
20
|
+
PROP_API = "PROP_API",
|
|
21
|
+
PROP_INIT = "PROP_INIT",
|
|
22
|
+
PROP_FUNC = "PROP_FUNC",
|
|
23
|
+
PROP_GETTER = "PROP_GETTER",
|
|
24
|
+
DEFAULT_COMP = "DEFAULT_COMP",
|
|
25
|
+
FUNC_ID = "FUNC_ID",
|
|
26
|
+
FUNC_NAME = "FUNC_NAME",
|
|
27
|
+
FUNC_TYPE = "FUNC_TYPE",
|
|
28
|
+
FUNC_CONFIG = "FUNC_CONFIG",
|
|
29
|
+
FUNC_INPUT = "FUNC_INPUT",
|
|
30
|
+
WIRE_TYPE = "WIRE_TYPE",
|
|
31
|
+
UNRESOLVED_VALUE = "UNRESOLVED_VALUE",
|
|
32
|
+
BATCH_FUNC_ID = "BATCH_FUNC_ID",
|
|
33
|
+
BATCH_FUNC_NAME = "BATCH_FUNC_NAME",
|
|
34
|
+
REDUCER_FUNC_ID = "REDUCER_FUNC_ID",
|
|
35
|
+
IMG_SRC = "IMG_SRC",
|
|
36
|
+
IMG_FUNC = "IMG_FUNC"
|
|
37
|
+
}
|
|
61
38
|
/**
|
|
62
39
|
* @typedef AstContext is an object that holds meta data information about the ast.
|
|
63
|
-
* @property {Map<string, ImportDeclarationInfo>} importDeclarations a collection of importDeclarationInfo
|
|
64
40
|
* @property {string[]} moduleFunctions is a collection of function names that are defined on the module level.
|
|
65
41
|
* @property {string[]} moduleVariables is a collection of variable names that are defined on the module level.
|
|
66
42
|
* @property {string[]} classFunctions is a collection of functino names that are defined on the class level.
|
|
67
|
-
* @property {string[]} classProperties is a collection of class properties.
|
|
68
43
|
*/
|
|
69
44
|
export declare type AstContext = {
|
|
70
|
-
importDeclarations: Map<string, ImportDeclarationInfo>;
|
|
71
45
|
moduleFunctions: string[];
|
|
72
46
|
moduleVariables: string[];
|
|
73
47
|
classFunctions: string[];
|
|
74
|
-
classProperties: ClassPropertyInfo[];
|
|
75
48
|
};
|
|
76
49
|
/**
|
|
77
50
|
* Contextual info about all the imports from a specific resource for use in module composition
|
|
@@ -90,16 +63,6 @@ export declare type ImportDetail = {
|
|
|
90
63
|
};
|
|
91
64
|
/** Mapping of resources to contextual info about themselves */
|
|
92
65
|
export declare type ConsumedImports = Map<string, ImportDetail>;
|
|
93
|
-
/** Mapping of specific imports to their general metadata info */
|
|
94
|
-
export declare type ImportDeclarations = Map<string, ImportDeclarationInfo>;
|
|
95
|
-
/**
|
|
96
|
-
* A stateful object to populate across getters for how they consume high level things. like imports.
|
|
97
|
-
*
|
|
98
|
-
* @property {Map} consumedImports all of the imports that getters use. This is uniquely data not retrievable by komaci document.
|
|
99
|
-
*/
|
|
100
|
-
export declare type ModuleLevelConsumption = {
|
|
101
|
-
consumedImports: ConsumedImports;
|
|
102
|
-
};
|
|
103
66
|
/**
|
|
104
67
|
* Metadata about specific things a getter consumed. for later processing
|
|
105
68
|
*/
|
|
@@ -112,34 +75,38 @@ export declare type ImplicitConsumption = {
|
|
|
112
75
|
export declare enum PropertyTypes {
|
|
113
76
|
WIRE = "wire",
|
|
114
77
|
GETTER = "getter",
|
|
115
|
-
|
|
116
|
-
PUBLIC = "api",
|
|
78
|
+
BASE = "base",
|
|
117
79
|
IMPORT_REFERENCE = "importReference",
|
|
118
80
|
TEMPLATE_STRING = "templateString"
|
|
119
81
|
}
|
|
120
82
|
/**
|
|
121
83
|
* Contextual information about a property and who consumes it
|
|
122
84
|
*/
|
|
123
|
-
export declare type ClassPropertyContext = BasePropertyContext |
|
|
85
|
+
export declare type ClassPropertyContext = BasePropertyContext | ImportPropertyContext | FunctionalPropertyContext;
|
|
124
86
|
/**
|
|
125
87
|
* Base type for property context
|
|
126
88
|
*/
|
|
127
89
|
export declare type BasePropertyContext = {
|
|
90
|
+
isPublic: boolean;
|
|
128
91
|
/** Type of property */
|
|
129
92
|
type: PropertyTypes;
|
|
130
93
|
/** If this property is used in priming through wires, compositions or implicitly through a getter */
|
|
131
94
|
usedInPriming: boolean;
|
|
132
95
|
/** Reference which adg this property is defined in */
|
|
133
|
-
fromAdg?:
|
|
96
|
+
fromAdg?: number;
|
|
97
|
+
inital?: StaticValue | PrimitiveValue;
|
|
134
98
|
};
|
|
135
99
|
/**
|
|
136
|
-
*
|
|
100
|
+
* When a function is considered unsupported i.e.:
|
|
101
|
+
* - wire reference is not supported
|
|
102
|
+
* - getter or template string does not pass purity checks
|
|
103
|
+
*
|
|
104
|
+
* we set the f index for property metadata to -1
|
|
137
105
|
*/
|
|
138
|
-
export declare
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
wire: ImportMetadata;
|
|
106
|
+
export declare const UNSUPPORTED_FUNCTION = -1;
|
|
107
|
+
export declare type FunctionalPropertyContext = BasePropertyContext & {
|
|
108
|
+
/** index of associated function (if there is one). If the function is unsupported in anyway this is set to `UNSUPPORTED_FUNCTION` */
|
|
109
|
+
functionIndex: number;
|
|
143
110
|
};
|
|
144
111
|
/**
|
|
145
112
|
* Added metadata specifically for properties that get values from imports
|
|
@@ -157,17 +124,19 @@ export declare type ImportMetadata = {
|
|
|
157
124
|
/** The alias set for an import in the original module. i.e. `import { item as importAlias } from 'importPath'` */
|
|
158
125
|
importAlias?: string;
|
|
159
126
|
/** alias generated for the import as part of resolvable module composition. */
|
|
160
|
-
generatorAlias
|
|
127
|
+
generatorAlias: string;
|
|
161
128
|
/** The name of the import namespace as defined in the import object on komaci doc */
|
|
162
129
|
resourceName: string;
|
|
163
130
|
/** The referential id for this import. i.e. 0/names/0 */
|
|
164
131
|
komaciDocImportRef: string;
|
|
165
132
|
/** flag representing if this import is from a namespace we support */
|
|
166
|
-
isFromInternalNamespace
|
|
133
|
+
isFromInternalNamespace: boolean;
|
|
167
134
|
/** flag representing if the import is from a library we support (used for pure functions i.e. getters and template string inflation) */
|
|
168
|
-
isFromSupportedLibrary
|
|
135
|
+
isFromSupportedLibrary: boolean;
|
|
169
136
|
/** flag representing if this import is used as part of priming (in a wire, as part of a pure function, initial value, etc) */
|
|
170
|
-
usedInPriming
|
|
137
|
+
usedInPriming: boolean;
|
|
138
|
+
/** flag representing if this import was statically picked up as part of the komaci document. we have to keep all statically analyzable imports */
|
|
139
|
+
staticallyAnalyzable: boolean;
|
|
171
140
|
/**
|
|
172
141
|
* component id for if this import maps to a component used in a template
|
|
173
142
|
* this is only managed as part of processTemplateImports
|
|
@@ -213,24 +182,35 @@ export declare enum FunctionTypes {
|
|
|
213
182
|
WIRE_FUNCTION = "WireFunction",
|
|
214
183
|
PRIMING_FUNCTION = "PrimingFunction",
|
|
215
184
|
GETTER_FUNCTION = "GetterFunction",
|
|
216
|
-
TEMPLATE_STRING = "TemplateStringFunction"
|
|
185
|
+
TEMPLATE_STRING = "TemplateStringFunction",
|
|
186
|
+
ERROR = "ErrorFunction"
|
|
217
187
|
}
|
|
218
188
|
/**
|
|
219
189
|
* Basic information needed by all function nodes
|
|
220
190
|
*/
|
|
221
191
|
export declare type BaseFunctionMetadata = {
|
|
222
|
-
input?: FunctionType['input'];
|
|
223
192
|
type: FunctionTypes;
|
|
193
|
+
/** properties on the component this function requires to run */
|
|
224
194
|
requiredProperties: string[];
|
|
225
|
-
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Details about an error that occured during resolvable module compilation
|
|
198
|
+
*/
|
|
199
|
+
export declare type ErrorFunctionMetadata = {
|
|
200
|
+
type: FunctionTypes.ERROR;
|
|
201
|
+
input: Value[];
|
|
226
202
|
};
|
|
227
203
|
/**
|
|
228
204
|
* Metadata for a wire function
|
|
229
205
|
*/
|
|
230
206
|
export declare type WireFunctionMetadata = BaseFunctionMetadata & {
|
|
231
207
|
type: FunctionTypes.WIRE_FUNCTION | FunctionTypes.PRIMING_FUNCTION;
|
|
232
|
-
|
|
233
|
-
|
|
208
|
+
input?: FunctionType['input'];
|
|
209
|
+
importReference: {
|
|
210
|
+
functionName: string;
|
|
211
|
+
batchingName?: string;
|
|
212
|
+
reducer?: string;
|
|
213
|
+
};
|
|
234
214
|
};
|
|
235
215
|
/**
|
|
236
216
|
* Metadata for a hoisted function type. Currently this is Getter functions and Template String Functions.
|
|
@@ -238,36 +218,98 @@ export declare type WireFunctionMetadata = BaseFunctionMetadata & {
|
|
|
238
218
|
export declare type HoistedFunctionMetadata = BaseFunctionMetadata & {
|
|
239
219
|
type: FunctionTypes.GETTER_FUNCTION | FunctionTypes.TEMPLATE_STRING;
|
|
240
220
|
/** ast node from the original component source */
|
|
241
|
-
componentAstNode?: t.ClassProperty | t.ClassMethod
|
|
221
|
+
componentAstNode?: NodePath<t.ClassProperty | t.ClassMethod>;
|
|
222
|
+
generatedName?: string;
|
|
242
223
|
};
|
|
243
224
|
/**
|
|
244
225
|
* Union of possible function types
|
|
245
226
|
*/
|
|
246
|
-
export declare type FunctionMetadata = HoistedFunctionMetadata | WireFunctionMetadata;
|
|
227
|
+
export declare type FunctionMetadata = HoistedFunctionMetadata | WireFunctionMetadata | ErrorFunctionMetadata;
|
|
247
228
|
export declare type AdgMetadata = {
|
|
248
229
|
/** basic generated name for references from other adg. can be overriden if the adg is an export */
|
|
249
230
|
defaultGeneratedName: string;
|
|
231
|
+
/** factory functions used in the resolvable module when we build the adg. this is literally only ever ADG_FUNCTION or UNRESOLVED_FUNCTION */
|
|
232
|
+
requiredAdgFactoryFunctions: Set<IdKeys>;
|
|
233
|
+
requiredCompositionFactoryFunctions: Set<IdKeys>;
|
|
250
234
|
/** the name given to this adg when exported */
|
|
251
235
|
exportName?: string;
|
|
252
236
|
/** list of properties used by the associated template */
|
|
253
|
-
propertiesUsedInTemplate: string
|
|
237
|
+
propertiesUsedInTemplate: Set<string>;
|
|
254
238
|
/** compositions uplifted from template komaci document */
|
|
255
|
-
compositions
|
|
239
|
+
compositions?: KomaciDocument['compositions'];
|
|
256
240
|
/** properties consumable by this adg */
|
|
257
241
|
properties: Map<string, ClassPropertyContext>;
|
|
258
242
|
/** functions defined in this adg */
|
|
259
243
|
functions: FunctionMetadata[];
|
|
260
244
|
/** reference to the index in the adg array for the parent adg */
|
|
261
|
-
parentReference?:
|
|
245
|
+
parentReference?: Adg['parentClass'];
|
|
246
|
+
/** to juggle weirdness with old getter support we can set this flag to avoid doing some extra processing on initial metadata collection */
|
|
247
|
+
hasSourceFile: boolean;
|
|
262
248
|
};
|
|
263
249
|
/**
|
|
264
250
|
* Complete structure of Metadata needed to compose a resolvable module
|
|
265
251
|
*/
|
|
266
252
|
export declare type ModuleMetadata = {
|
|
253
|
+
importGeneratorIndex: number;
|
|
254
|
+
adgGeneratorIndex: number;
|
|
267
255
|
importsByNamespace: ConsumedImports;
|
|
268
256
|
importsByName: Map<string, ImportMetadata>;
|
|
269
257
|
importIndexReference: Map<string, string>;
|
|
270
|
-
adgs: AdgMetadata
|
|
258
|
+
adgs: Map<number, AdgMetadata>;
|
|
271
259
|
exports: Record<string, AdgMetadata>;
|
|
272
260
|
};
|
|
261
|
+
export declare type ImportBinding = {
|
|
262
|
+
importPath: string;
|
|
263
|
+
identifier: string;
|
|
264
|
+
};
|
|
265
|
+
export declare type PrimingAdapterDefinition = {
|
|
266
|
+
/** Import metadata of the priming adapter */
|
|
267
|
+
prime: ImportBinding;
|
|
268
|
+
/** Contains metadata of the corresponding batch adapter */
|
|
269
|
+
batch?: {
|
|
270
|
+
prime: ImportBinding;
|
|
271
|
+
/** Metadata of the reducer that converts PrimingAdapter configuration to the corresponding single batch configuration */
|
|
272
|
+
reducer: ImportBinding;
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Accepts importPath and identifier of a Wire Adapter
|
|
277
|
+
* Returns metadata of corresponding Priming Adapter or null if there is none
|
|
278
|
+
*/
|
|
279
|
+
export declare type GetPrimingAdapter = {
|
|
280
|
+
(importPath: string, identifier: string): PrimingAdapterDefinition | null;
|
|
281
|
+
};
|
|
282
|
+
export declare type WireAdaptersMapping = {
|
|
283
|
+
[importPath: string]: {
|
|
284
|
+
[identifier: string]: PrimingAdapterDefinition;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* @typedef ValidGetterContext is an object that holds information about the member varaibles within a getter function.
|
|
289
|
+
* @property {NodePath<t.ClassMethod>} getter is the babel object for the getter method node.
|
|
290
|
+
* @property {Array<string>} memberUsage is an array of member variable names that are within the getter.
|
|
291
|
+
* @property {number} f_index is the index at which this getter was added to the functions array in the Komaci document.
|
|
292
|
+
*/
|
|
293
|
+
export declare type ValidGetterContext = {
|
|
294
|
+
getter: NodePath<t.ClassMethod>;
|
|
295
|
+
memberUsage: Array<string>;
|
|
296
|
+
generatedName: string;
|
|
297
|
+
f_index?: number;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* @typedef ValidTemplateContext is an object that holds information about the member varaibles within a template.
|
|
301
|
+
* @property {NodePath<t.ClassProperty>} template is the babel object for the getter method node.
|
|
302
|
+
* @property {Array<string>} memberUsage is an array of member variable names that are within the template.
|
|
303
|
+
* @property {string} generatedName name used as function name in the resolvable module
|
|
304
|
+
* @property {number} f_index is the index at which this template was added to the functions array in the Komaci document.
|
|
305
|
+
*/
|
|
306
|
+
export declare type ValidTemplateContext = {
|
|
307
|
+
template: NodePath<t.ClassProperty>;
|
|
308
|
+
memberUsage: Array<string>;
|
|
309
|
+
generatedName: string;
|
|
310
|
+
f_index?: number;
|
|
311
|
+
};
|
|
312
|
+
export declare type Visited<T> = T & {
|
|
313
|
+
visited?: boolean;
|
|
314
|
+
};
|
|
273
315
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.js
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FunctionTypes = exports.PropertyTypes = void 0;
|
|
3
|
+
exports.FunctionTypes = exports.UNSUPPORTED_FUNCTION = exports.PropertyTypes = exports.IdKeys = exports.PROPS = exports.CONTEXT = exports.ERROR_PREFIX = void 0;
|
|
4
|
+
exports.ERROR_PREFIX = '[komaci] ';
|
|
5
|
+
exports.CONTEXT = 'ctx';
|
|
6
|
+
exports.PROPS = 'props';
|
|
7
|
+
var IdKeys;
|
|
8
|
+
(function (IdKeys) {
|
|
9
|
+
IdKeys["CONTEXT"] = "CONTEXT";
|
|
10
|
+
IdKeys["PROPS"] = "PROPS";
|
|
11
|
+
IdKeys["FACTORY"] = "FACTORY";
|
|
12
|
+
IdKeys["COMPOSED_GRAPH_FUNC"] = "COMPOSED_GRAPH_FUNC";
|
|
13
|
+
IdKeys["ITERATION_FUNC"] = "ITERATION_FUNC";
|
|
14
|
+
IdKeys["UNRESOLVED_FUNC"] = "UNRESOLVED_FUNC";
|
|
15
|
+
IdKeys["SLOT_FUNC"] = "SLOT_FUNC";
|
|
16
|
+
IdKeys["ELEMENT_FUNC"] = "ELEMENT_FUNC";
|
|
17
|
+
IdKeys["ADG_FUNC"] = "ADG_FUNC";
|
|
18
|
+
IdKeys["SLOT"] = "SLOT";
|
|
19
|
+
IdKeys["COMPONENT_ID"] = "COMPONENT_ID";
|
|
20
|
+
IdKeys["UNDEFINED"] = "UNDEFINED";
|
|
21
|
+
IdKeys["PROP_API"] = "PROP_API";
|
|
22
|
+
IdKeys["PROP_INIT"] = "PROP_INIT";
|
|
23
|
+
IdKeys["PROP_FUNC"] = "PROP_FUNC";
|
|
24
|
+
IdKeys["PROP_GETTER"] = "PROP_GETTER";
|
|
25
|
+
IdKeys["DEFAULT_COMP"] = "DEFAULT_COMP";
|
|
26
|
+
IdKeys["FUNC_ID"] = "FUNC_ID";
|
|
27
|
+
IdKeys["FUNC_NAME"] = "FUNC_NAME";
|
|
28
|
+
IdKeys["FUNC_TYPE"] = "FUNC_TYPE";
|
|
29
|
+
IdKeys["FUNC_CONFIG"] = "FUNC_CONFIG";
|
|
30
|
+
IdKeys["FUNC_INPUT"] = "FUNC_INPUT";
|
|
31
|
+
IdKeys["WIRE_TYPE"] = "WIRE_TYPE";
|
|
32
|
+
IdKeys["UNRESOLVED_VALUE"] = "UNRESOLVED_VALUE";
|
|
33
|
+
IdKeys["BATCH_FUNC_ID"] = "BATCH_FUNC_ID";
|
|
34
|
+
IdKeys["BATCH_FUNC_NAME"] = "BATCH_FUNC_NAME";
|
|
35
|
+
IdKeys["REDUCER_FUNC_ID"] = "REDUCER_FUNC_ID";
|
|
36
|
+
IdKeys["IMG_SRC"] = "IMG_SRC";
|
|
37
|
+
IdKeys["IMG_FUNC"] = "IMG_FUNC";
|
|
38
|
+
})(IdKeys = exports.IdKeys || (exports.IdKeys = {}));
|
|
4
39
|
/**
|
|
5
40
|
* Possbile types of properties we can encounter in a LWC
|
|
6
41
|
*/
|
|
@@ -8,11 +43,18 @@ var PropertyTypes;
|
|
|
8
43
|
(function (PropertyTypes) {
|
|
9
44
|
PropertyTypes["WIRE"] = "wire";
|
|
10
45
|
PropertyTypes["GETTER"] = "getter";
|
|
11
|
-
PropertyTypes["
|
|
12
|
-
PropertyTypes["PUBLIC"] = "api";
|
|
46
|
+
PropertyTypes["BASE"] = "base";
|
|
13
47
|
PropertyTypes["IMPORT_REFERENCE"] = "importReference";
|
|
14
48
|
PropertyTypes["TEMPLATE_STRING"] = "templateString";
|
|
15
49
|
})(PropertyTypes = exports.PropertyTypes || (exports.PropertyTypes = {}));
|
|
50
|
+
/**
|
|
51
|
+
* When a function is considered unsupported i.e.:
|
|
52
|
+
* - wire reference is not supported
|
|
53
|
+
* - getter or template string does not pass purity checks
|
|
54
|
+
*
|
|
55
|
+
* we set the f index for property metadata to -1
|
|
56
|
+
*/
|
|
57
|
+
exports.UNSUPPORTED_FUNCTION = -1;
|
|
16
58
|
/** types of nodes */
|
|
17
59
|
var FunctionTypes;
|
|
18
60
|
(function (FunctionTypes) {
|
|
@@ -20,5 +62,6 @@ var FunctionTypes;
|
|
|
20
62
|
FunctionTypes["PRIMING_FUNCTION"] = "PrimingFunction";
|
|
21
63
|
FunctionTypes["GETTER_FUNCTION"] = "GetterFunction";
|
|
22
64
|
FunctionTypes["TEMPLATE_STRING"] = "TemplateStringFunction";
|
|
65
|
+
FunctionTypes["ERROR"] = "ErrorFunction";
|
|
23
66
|
})(FunctionTypes = exports.FunctionTypes || (exports.FunctionTypes = {}));
|
|
24
67
|
//# sourceMappingURL=types.js.map
|
package/build/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
2
|
import { NodePath } from '@babel/core';
|
|
3
|
-
import { AstContext, ClassPropertyContext, ClassPropertyContexts,
|
|
4
|
-
import { FunctionType, KomaciDocument
|
|
3
|
+
import { AstContext, ClassPropertyContext, ClassPropertyContexts, ClassPropertyNodes, ImplicitConsumption, ImportMetadata, ModuleMetadata, ValidGetterContext, ValidTemplateContext } from './types';
|
|
4
|
+
import { Adg, FunctionType, KomaciDocument } from '@komaci/types';
|
|
5
5
|
export declare const LIGHTNING_NS = "lightning";
|
|
6
6
|
export declare const FORCE_NS = "force";
|
|
7
7
|
export declare const ONE_NS = "one";
|
|
@@ -15,21 +15,6 @@ export declare const TEMPLATED_STRING_FUNCTION = "TemplatedStringFunction";
|
|
|
15
15
|
* @param ast babel abstract syntax tree
|
|
16
16
|
*/
|
|
17
17
|
export declare function getPropertyMetadataFromAst(ast: t.File): ClassPropertyNodes;
|
|
18
|
-
/**
|
|
19
|
-
* Given the AST of an entire JS source file, this method looks for class member properties.
|
|
20
|
-
* If there is no default export in the AST, no class properties will be returned (empty array is returned).
|
|
21
|
-
* @param astRoot AST representing an entire Program, as a @babel/types File object
|
|
22
|
-
* @returns Array of NodePath<ClassProperty> representing the @babel NodePaths for all class member
|
|
23
|
-
* properties, if any exist. Otherwise, returns an empty array.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getClassProperties(astRoot: t.File): t.ClassProperty[];
|
|
26
|
-
/**
|
|
27
|
-
* Utility method that takes in an @babel/types ClassProperty array, and returns an array of ClassPropertyInfo
|
|
28
|
-
* objects containing information about each ClassProperty from the input array.
|
|
29
|
-
* @param classProperties
|
|
30
|
-
* @returns Array of ClassPropertyInfo, where each element corresponds to the input ClassProperty array.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getClassPropertyInfos(classProperties?: Array<t.ClassProperty | t.ClassMethod>): ClassPropertyInfo[];
|
|
33
18
|
/**
|
|
34
19
|
* Given a valid functional node (tempalte string or getter function), collect information that we may not have been able to collect via KomaciDocument
|
|
35
20
|
* and return a list of class member variables that are properly used in the method body.
|
|
@@ -44,8 +29,7 @@ export declare function getClassPropertyInfos(classProperties?: Array<t.ClassPro
|
|
|
44
29
|
* @returns ImplicitConsumption, which contains an array representing the properly-used member variables.
|
|
45
30
|
* Returns ImplicitConsumption with an empty array if none were found.
|
|
46
31
|
*/
|
|
47
|
-
export declare function implicitConsumptionMetadata(node: NodePath<t.ClassMethod | t.ClassProperty>,
|
|
48
|
-
moduleLevelConsumption: ModuleLevelConsumption): ImplicitConsumption;
|
|
32
|
+
export declare function implicitConsumptionMetadata(node: NodePath<t.ClassMethod | t.ClassProperty>, adgIndex: number, moduleMetadata: ModuleMetadata): ImplicitConsumption;
|
|
49
33
|
export declare function getMemberVarsFromGetter(path: NodePath<t.MemberExpression>, identifiers: Set<string>): void;
|
|
50
34
|
/**
|
|
51
35
|
* Collect metadata about all the imports consumed for an identifier in a getter
|
|
@@ -56,7 +40,7 @@ export declare function getMemberVarsFromGetter(path: NodePath<t.MemberExpressio
|
|
|
56
40
|
* @param consumedImports The map to add info to about this identifier, whether it is an import that is being used
|
|
57
41
|
* in the getter, or if it is assigned an import being used in the getter.
|
|
58
42
|
*/
|
|
59
|
-
export declare function collectImportUsage(path: NodePath<t.Identifier>,
|
|
43
|
+
export declare function collectImportUsage(path: NodePath<t.Identifier>, moduleMetadata: ModuleMetadata, properties: ClassPropertyContexts): void;
|
|
60
44
|
/**
|
|
61
45
|
* Some children of nodes can be a direct identifier or a string literal. helper helps do
|
|
62
46
|
* this consistant dance of getting the value from either
|
|
@@ -64,12 +48,6 @@ export declare function collectImportUsage(path: NodePath<t.Identifier>, classPr
|
|
|
64
48
|
* @returns value
|
|
65
49
|
*/
|
|
66
50
|
export declare function getFromIdentifierOrStringLiteral(node: t.Identifier | t.StringLiteral): string;
|
|
67
|
-
/**
|
|
68
|
-
* Function for getting an array of supported namesapce references.
|
|
69
|
-
* @param astRoot the root of the ast
|
|
70
|
-
* @returns an Array of supported namespace references.
|
|
71
|
-
*/
|
|
72
|
-
export declare function getAllImportReferences(astRoot: t.File): Map<string, ImportDeclarationInfo>;
|
|
73
51
|
/**
|
|
74
52
|
* Function to get an array of function names that are defined at the module level.
|
|
75
53
|
* @returns an array of function names that are defined at the module level.
|
|
@@ -152,7 +130,7 @@ export declare function isExpressionThisOrAlias(aliases: Set<string>, expr: t.Ex
|
|
|
152
130
|
* @param declaredGetterVars a collection of variables declared within the getter
|
|
153
131
|
* @param id the id of the member we are referencing.
|
|
154
132
|
*/
|
|
155
|
-
export declare function isDeclaredInAst(astContext: AstContext, declaredGetterVars: string[], id: string): boolean;
|
|
133
|
+
export declare function isDeclaredInAst(astContext: AstContext, importDeclarations: Map<string, ImportMetadata>, classProperties: ClassPropertyContexts, declaredGetterVars: string[], id: string): boolean;
|
|
156
134
|
/**
|
|
157
135
|
* Function to update the Komaci Document with validated getter information. This function will update the functions array in the
|
|
158
136
|
* export default adg along with the property references in the property array.
|