@komaci/common-shared 240.1.5 → 242.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +7 -0
- package/build/allowlistNamespaces.js +27 -1
- package/build/index.d.ts +3 -0
- package/build/index.js +8 -1
- package/build/internal-namespaces.json +4 -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 +175 -0
- package/build/moduleMetadata.js +646 -0
- package/build/types.d.ts +217 -82
- package/build/types.js +54 -3
- package/build/utils.d.ts +33 -26
- package/build/utils.js +157 -203
- 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 } 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,32 +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;
|
|
95
|
+
/** Reference which adg this property is defined in */
|
|
96
|
+
fromAdg?: number;
|
|
97
|
+
inital?: StaticValue | PrimitiveValue;
|
|
132
98
|
};
|
|
133
99
|
/**
|
|
134
|
-
*
|
|
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
|
|
135
105
|
*/
|
|
136
|
-
export declare
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
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;
|
|
141
110
|
};
|
|
142
111
|
/**
|
|
143
112
|
* Added metadata specifically for properties that get values from imports
|
|
@@ -149,14 +118,42 @@ export declare type ImportPropertyContext = BasePropertyContext & {
|
|
|
149
118
|
/**
|
|
150
119
|
* Basic details about an Import
|
|
151
120
|
*/
|
|
152
|
-
export declare type
|
|
121
|
+
export declare type BasicImportMetadata = {
|
|
153
122
|
/** The name of the import as defined in the import object on komaci doc */
|
|
154
123
|
name: string;
|
|
124
|
+
/** The alias set for an import in the original module. i.e. `import { item as importAlias } from 'importPath'` */
|
|
125
|
+
importAlias?: string;
|
|
126
|
+
/** alias generated for the import as part of resolvable module composition. */
|
|
127
|
+
generatorAlias: string;
|
|
155
128
|
/** The name of the import namespace as defined in the import object on komaci doc */
|
|
156
129
|
resourceName: string;
|
|
157
130
|
/** The referential id for this import. i.e. 0/names/0 */
|
|
158
131
|
komaciDocImportRef: string;
|
|
132
|
+
/** flag representing if this import is from a namespace we support */
|
|
133
|
+
isFromInternalNamespace: boolean;
|
|
134
|
+
/** flag representing if the import is from a library we support (used for pure functions i.e. getters and template string inflation) */
|
|
135
|
+
isFromSupportedLibrary: boolean;
|
|
136
|
+
/** flag representing if this import is used as part of priming (in a wire, as part of a pure function, initial value, etc) */
|
|
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;
|
|
140
|
+
/**
|
|
141
|
+
* component id for if this import maps to a component used in a template
|
|
142
|
+
* this is only managed as part of processTemplateImports
|
|
143
|
+
*/
|
|
144
|
+
componentId?: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A type of import that extends the basic import metadata object to include a template komaci doc for an import.
|
|
148
|
+
*/
|
|
149
|
+
export declare type TemplateImportMetadata = BasicImportMetadata & {
|
|
150
|
+
templateKomaciDoc: KomaciDocument;
|
|
159
151
|
};
|
|
152
|
+
/**
|
|
153
|
+
* Main type for import meta data.
|
|
154
|
+
*/
|
|
155
|
+
export declare type ImportMetadata = BasicImportMetadata | TemplateImportMetadata;
|
|
156
|
+
export declare type ImportIndexReference = Record<string, ImportMetadata>;
|
|
160
157
|
/**
|
|
161
158
|
* Map for all class properties and their basic, KomaciDoc analyzable metadata.
|
|
162
159
|
*
|
|
@@ -190,4 +187,142 @@ export declare type ModuleContext = {
|
|
|
190
187
|
astContext: AstContext;
|
|
191
188
|
isExternal: boolean;
|
|
192
189
|
};
|
|
190
|
+
/** types of nodes */
|
|
191
|
+
export declare enum FunctionTypes {
|
|
192
|
+
WIRE_FUNCTION = "WireFunction",
|
|
193
|
+
PRIMING_FUNCTION = "PrimingFunction",
|
|
194
|
+
GETTER_FUNCTION = "GetterFunction",
|
|
195
|
+
TEMPLATE_STRING = "TemplateStringFunction",
|
|
196
|
+
ERROR = "ErrorFunction"
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Basic information needed by all function nodes
|
|
200
|
+
*/
|
|
201
|
+
export declare type BaseFunctionMetadata = {
|
|
202
|
+
type: FunctionTypes;
|
|
203
|
+
/** properties on the component this function requires to run */
|
|
204
|
+
requiredProperties: string[];
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Details about an error that occured during resolvable module compilation
|
|
208
|
+
*/
|
|
209
|
+
export declare type ErrorFunctionMetadata = {
|
|
210
|
+
type: FunctionTypes.ERROR;
|
|
211
|
+
input: Value[];
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Metadata for a wire function
|
|
215
|
+
*/
|
|
216
|
+
export declare type WireFunctionMetadata = BaseFunctionMetadata & {
|
|
217
|
+
type: FunctionTypes.WIRE_FUNCTION | FunctionTypes.PRIMING_FUNCTION;
|
|
218
|
+
input?: FunctionType['input'];
|
|
219
|
+
importReference: {
|
|
220
|
+
functionName: string;
|
|
221
|
+
batchingName?: string;
|
|
222
|
+
reducer?: string;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Metadata for a hoisted function type. Currently this is Getter functions and Template String Functions.
|
|
227
|
+
*/
|
|
228
|
+
export declare type HoistedFunctionMetadata = BaseFunctionMetadata & {
|
|
229
|
+
type: FunctionTypes.GETTER_FUNCTION | FunctionTypes.TEMPLATE_STRING;
|
|
230
|
+
/** ast node from the original component source */
|
|
231
|
+
componentAstNode?: NodePath<t.ClassProperty | t.ClassMethod>;
|
|
232
|
+
generatedName?: string;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Union of possible function types
|
|
236
|
+
*/
|
|
237
|
+
export declare type FunctionMetadata = HoistedFunctionMetadata | WireFunctionMetadata | ErrorFunctionMetadata;
|
|
238
|
+
export declare type AdgMetadata = {
|
|
239
|
+
/** basic generated name for references from other adg. can be overriden if the adg is an export */
|
|
240
|
+
defaultGeneratedName: string;
|
|
241
|
+
/** factory functions used in the resolvable module when we build the adg. this is literally only ever ADG_FUNCTION or UNRESOLVED_FUNCTION */
|
|
242
|
+
requiredAdgFactoryFunctions: Set<IdKeys>;
|
|
243
|
+
requiredCompositionFactoryFunctions: Set<IdKeys>;
|
|
244
|
+
/** the name given to this adg when exported */
|
|
245
|
+
exportName?: string;
|
|
246
|
+
/** list of properties used by the associated template */
|
|
247
|
+
propertiesUsedInTemplate: Set<string>;
|
|
248
|
+
/** compositions uplifted from template komaci document */
|
|
249
|
+
compositions?: KomaciDocument['compositions'];
|
|
250
|
+
/** properties consumable by this adg */
|
|
251
|
+
properties: Map<string, ClassPropertyContext>;
|
|
252
|
+
/** functions defined in this adg */
|
|
253
|
+
functions: FunctionMetadata[];
|
|
254
|
+
/** reference to the index in the adg array for the parent adg */
|
|
255
|
+
parentReference?: Adg['parentClass'];
|
|
256
|
+
/** to juggle weirdness with old getter support we can set this flag to avoid doing some extra processing on initial metadata collection */
|
|
257
|
+
hasSourceFile: boolean;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Complete structure of Metadata needed to compose a resolvable module
|
|
261
|
+
*/
|
|
262
|
+
export declare type ModuleMetadata = {
|
|
263
|
+
importGeneratorIndex: number;
|
|
264
|
+
adgGeneratorIndex: number;
|
|
265
|
+
importsByNamespace: ConsumedImports;
|
|
266
|
+
importsByName: Map<string, ImportMetadata>;
|
|
267
|
+
importIndexReference: Map<string, string>;
|
|
268
|
+
adgs: Map<number, AdgMetadata>;
|
|
269
|
+
exports: Record<string, AdgMetadata>;
|
|
270
|
+
templateKomaciDocMap: {
|
|
271
|
+
[fName: string]: KomaciDocument;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
export declare type ImportBinding = {
|
|
275
|
+
importPath: string;
|
|
276
|
+
identifier: string;
|
|
277
|
+
};
|
|
278
|
+
export declare type PrimingAdapterDefinition = {
|
|
279
|
+
/** Import metadata of the priming adapter */
|
|
280
|
+
prime: ImportBinding;
|
|
281
|
+
/** Contains metadata of the corresponding batch adapter */
|
|
282
|
+
batch?: {
|
|
283
|
+
prime: ImportBinding;
|
|
284
|
+
/** Metadata of the reducer that converts PrimingAdapter configuration to the corresponding single batch configuration */
|
|
285
|
+
reducer: ImportBinding;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Accepts importPath and identifier of a Wire Adapter
|
|
290
|
+
* Returns metadata of corresponding Priming Adapter or null if there is none
|
|
291
|
+
*/
|
|
292
|
+
export declare type GetPrimingAdapter = {
|
|
293
|
+
(importPath: string, identifier: string): PrimingAdapterDefinition | null;
|
|
294
|
+
};
|
|
295
|
+
export declare type WireAdaptersMapping = {
|
|
296
|
+
[importPath: string]: {
|
|
297
|
+
[identifier: string]: PrimingAdapterDefinition;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* @typedef ValidGetterContext is an object that holds information about the member varaibles within a getter function.
|
|
302
|
+
* @property {NodePath<t.ClassMethod>} getter is the babel object for the getter method node.
|
|
303
|
+
* @property {Array<string>} memberUsage is an array of member variable names that are within the getter.
|
|
304
|
+
* @property {number} f_index is the index at which this getter was added to the functions array in the Komaci document.
|
|
305
|
+
*/
|
|
306
|
+
export declare type ValidGetterContext = {
|
|
307
|
+
getter: NodePath<t.ClassMethod>;
|
|
308
|
+
memberUsage: Array<string>;
|
|
309
|
+
generatedName: string;
|
|
310
|
+
f_index?: number;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* @typedef ValidTemplateContext is an object that holds information about the member varaibles within a template.
|
|
314
|
+
* @property {NodePath<t.ClassProperty>} template is the babel object for the getter method node.
|
|
315
|
+
* @property {Array<string>} memberUsage is an array of member variable names that are within the template.
|
|
316
|
+
* @property {string} generatedName name used as function name in the resolvable module
|
|
317
|
+
* @property {number} f_index is the index at which this template was added to the functions array in the Komaci document.
|
|
318
|
+
*/
|
|
319
|
+
export declare type ValidTemplateContext = {
|
|
320
|
+
template: NodePath<t.ClassProperty>;
|
|
321
|
+
memberUsage: Array<string>;
|
|
322
|
+
generatedName: string;
|
|
323
|
+
f_index?: number;
|
|
324
|
+
};
|
|
325
|
+
export declare type Visited<T> = T & {
|
|
326
|
+
visited?: boolean;
|
|
327
|
+
};
|
|
193
328
|
//# 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.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,9 +43,25 @@ 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;
|
|
58
|
+
/** types of nodes */
|
|
59
|
+
var FunctionTypes;
|
|
60
|
+
(function (FunctionTypes) {
|
|
61
|
+
FunctionTypes["WIRE_FUNCTION"] = "WireFunction";
|
|
62
|
+
FunctionTypes["PRIMING_FUNCTION"] = "PrimingFunction";
|
|
63
|
+
FunctionTypes["GETTER_FUNCTION"] = "GetterFunction";
|
|
64
|
+
FunctionTypes["TEMPLATE_STRING"] = "TemplateStringFunction";
|
|
65
|
+
FunctionTypes["ERROR"] = "ErrorFunction";
|
|
66
|
+
})(FunctionTypes = exports.FunctionTypes || (exports.FunctionTypes = {}));
|
|
16
67
|
//# sourceMappingURL=types.js.map
|
package/build/utils.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
2
|
import { NodePath } from '@babel/core';
|
|
3
|
-
import { AstContext, ClassPropertyContext, ClassPropertyContexts,
|
|
3
|
+
import { AstContext, ClassPropertyContext, ClassPropertyContexts, ClassPropertyNodes, ImplicitConsumption, ImportMetadata, ModuleMetadata, ValidGetterContext, ValidTemplateContext } from './types';
|
|
4
|
+
import { Adg, FunctionType, KomaciDocument } from '@komaci/types';
|
|
4
5
|
export declare const LIGHTNING_NS = "lightning";
|
|
5
6
|
export declare const FORCE_NS = "force";
|
|
6
7
|
export declare const ONE_NS = "one";
|
|
8
|
+
export declare const GETTER_FUNCTION = "GetterFunction";
|
|
9
|
+
export declare const TEMPLATED_STRING_FUNCTION = "TemplatedStringFunction";
|
|
7
10
|
/**
|
|
8
11
|
* collect node paths for different pieces of a given class so we can more effectively traverse them in the future
|
|
9
12
|
*
|
|
@@ -12,21 +15,6 @@ export declare const ONE_NS = "one";
|
|
|
12
15
|
* @param ast babel abstract syntax tree
|
|
13
16
|
*/
|
|
14
17
|
export declare function getPropertyMetadataFromAst(ast: t.File): ClassPropertyNodes;
|
|
15
|
-
/**
|
|
16
|
-
* Given the AST of an entire JS source file, this method looks for class member properties.
|
|
17
|
-
* If there is no default export in the AST, no class properties will be returned (empty array is returned).
|
|
18
|
-
* @param astRoot AST representing an entire Program, as a @babel/types File object
|
|
19
|
-
* @returns Array of NodePath<ClassProperty> representing the @babel NodePaths for all class member
|
|
20
|
-
* properties, if any exist. Otherwise, returns an empty array.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getClassProperties(astRoot: t.File): t.ClassProperty[];
|
|
23
|
-
/**
|
|
24
|
-
* Utility method that takes in an @babel/types ClassProperty array, and returns an array of ClassPropertyInfo
|
|
25
|
-
* objects containing information about each ClassProperty from the input array.
|
|
26
|
-
* @param classProperties
|
|
27
|
-
* @returns Array of ClassPropertyInfo, where each element corresponds to the input ClassProperty array.
|
|
28
|
-
*/
|
|
29
|
-
export declare function getClassPropertyInfos(classProperties?: Array<t.ClassProperty | t.ClassMethod>): ClassPropertyInfo[];
|
|
30
18
|
/**
|
|
31
19
|
* Given a valid functional node (tempalte string or getter function), collect information that we may not have been able to collect via KomaciDocument
|
|
32
20
|
* and return a list of class member variables that are properly used in the method body.
|
|
@@ -41,8 +29,7 @@ export declare function getClassPropertyInfos(classProperties?: Array<t.ClassPro
|
|
|
41
29
|
* @returns ImplicitConsumption, which contains an array representing the properly-used member variables.
|
|
42
30
|
* Returns ImplicitConsumption with an empty array if none were found.
|
|
43
31
|
*/
|
|
44
|
-
export declare function implicitConsumptionMetadata(node: NodePath<t.ClassMethod | t.ClassProperty>,
|
|
45
|
-
moduleLevelConsumption: ModuleLevelConsumption): ImplicitConsumption;
|
|
32
|
+
export declare function implicitConsumptionMetadata(node: NodePath<t.ClassMethod | t.ClassProperty>, adgIndex: number, moduleMetadata: ModuleMetadata): ImplicitConsumption;
|
|
46
33
|
export declare function getMemberVarsFromGetter(path: NodePath<t.MemberExpression>, identifiers: Set<string>): void;
|
|
47
34
|
/**
|
|
48
35
|
* Collect metadata about all the imports consumed for an identifier in a getter
|
|
@@ -53,7 +40,7 @@ export declare function getMemberVarsFromGetter(path: NodePath<t.MemberExpressio
|
|
|
53
40
|
* @param consumedImports The map to add info to about this identifier, whether it is an import that is being used
|
|
54
41
|
* in the getter, or if it is assigned an import being used in the getter.
|
|
55
42
|
*/
|
|
56
|
-
export declare function collectImportUsage(path: NodePath<t.Identifier>,
|
|
43
|
+
export declare function collectImportUsage(path: NodePath<t.Identifier>, moduleMetadata: ModuleMetadata, properties: ClassPropertyContexts): void;
|
|
57
44
|
/**
|
|
58
45
|
* Some children of nodes can be a direct identifier or a string literal. helper helps do
|
|
59
46
|
* this consistant dance of getting the value from either
|
|
@@ -61,12 +48,6 @@ export declare function collectImportUsage(path: NodePath<t.Identifier>, classPr
|
|
|
61
48
|
* @returns value
|
|
62
49
|
*/
|
|
63
50
|
export declare function getFromIdentifierOrStringLiteral(node: t.Identifier | t.StringLiteral): string;
|
|
64
|
-
/**
|
|
65
|
-
* Function for getting an array of supported namesapce references.
|
|
66
|
-
* @param astRoot the root of the ast
|
|
67
|
-
* @returns an Array of supported namespace references.
|
|
68
|
-
*/
|
|
69
|
-
export declare function getAllImportReferences(astRoot: t.File): Map<string, ImportDeclarationInfo>;
|
|
70
51
|
/**
|
|
71
52
|
* Function to get an array of function names that are defined at the module level.
|
|
72
53
|
* @returns an array of function names that are defined at the module level.
|
|
@@ -149,5 +130,31 @@ export declare function isExpressionThisOrAlias(aliases: Set<string>, expr: t.Ex
|
|
|
149
130
|
* @param declaredGetterVars a collection of variables declared within the getter
|
|
150
131
|
* @param id the id of the member we are referencing.
|
|
151
132
|
*/
|
|
152
|
-
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;
|
|
134
|
+
/**
|
|
135
|
+
* Function to update the Komaci Document with validated getter information. This function will update the functions array in the
|
|
136
|
+
* export default adg along with the property references in the property array.
|
|
137
|
+
* @param komaciScriptDoc the komaci document
|
|
138
|
+
* @param validGetterContext a collection
|
|
139
|
+
*/
|
|
140
|
+
export declare function updateKomaciDocumentWithValidGetters(komaciScriptDoc: KomaciDocument, validGetterContext: ValidGetterContext[]): void;
|
|
141
|
+
/**
|
|
142
|
+
* Function to update the Komaci Document with validated template information. This function will update the functions array in the
|
|
143
|
+
* export default adg along with the property references in the property array.
|
|
144
|
+
* @param komaciScriptDoc the komaci document
|
|
145
|
+
* @param ValidTemplateContext details about the templates we've deemed to be valid
|
|
146
|
+
*/
|
|
147
|
+
export declare function updateKomaciDocumentWithValidTemplatedStrings(komaciScriptDoc: KomaciDocument, templateStrings: ValidTemplateContext[]): void;
|
|
148
|
+
/**
|
|
149
|
+
* Update the functions array with the newly formed function reference and point the property to it
|
|
150
|
+
* @param adg The adg to update
|
|
151
|
+
* @param propertyName name of the property to update
|
|
152
|
+
*/
|
|
153
|
+
export declare function addPropertyFunction(adg: Adg, propertyName: string, func: FunctionType): number;
|
|
154
|
+
/**
|
|
155
|
+
* Function to slpit an import path seperated by . EX: ./test.html = [, /test, html ]
|
|
156
|
+
* @param fullFilename the full file name
|
|
157
|
+
* @returns the full file name separated into segments.
|
|
158
|
+
*/
|
|
159
|
+
export declare function getFilepathSegments(fullFilename: string): string[];
|
|
153
160
|
//# sourceMappingURL=utils.d.ts.map
|