@komaci/common-shared 244.1.8 → 244.2.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.
|
@@ -117,10 +117,7 @@ export declare const doesAdgExist: (index: number, doc: KomaciDocument) => boole
|
|
|
117
117
|
* @param composition the composition to look at
|
|
118
118
|
* @param cb the function to run on every new composition. returning true here will end traversal for that subtree
|
|
119
119
|
*/
|
|
120
|
-
export declare function traverseComposition(composition: Composition,
|
|
121
|
-
pretraversal?: (Composition: Composition, iterationContext: string[], parent?: Composition) => boolean;
|
|
122
|
-
posttraversal?: (Composition: Composition, iterationContext: string[], parent?: Composition) => void;
|
|
123
|
-
}, iteratorContext?: string[], parent?: Composition): void;
|
|
120
|
+
export declare function traverseComposition(composition: Composition, cb: (Composition: Composition, iterationContext: string[]) => boolean, iteratorContext?: string[]): void;
|
|
124
121
|
/**
|
|
125
122
|
* Recursively probe a composition and it's children for usages of properties.
|
|
126
123
|
* @param composition Current composition
|
|
@@ -357,24 +357,19 @@ function updatePropertyIfExists(value, properties, key) {
|
|
|
357
357
|
* @param composition the composition to look at
|
|
358
358
|
* @param cb the function to run on every new composition. returning true here will end traversal for that subtree
|
|
359
359
|
*/
|
|
360
|
-
function traverseComposition(composition,
|
|
361
|
-
const found =
|
|
362
|
-
? callbacks.pretraversal(composition, iteratorContext, parent)
|
|
363
|
-
: false;
|
|
360
|
+
function traverseComposition(composition, cb, iteratorContext = []) {
|
|
361
|
+
const found = cb(composition, iteratorContext);
|
|
364
362
|
if (!found && composition && composition.compositions) {
|
|
365
363
|
for (const value of composition.compositions) {
|
|
366
364
|
if (isCompositionAnIteration(composition)) {
|
|
367
365
|
iteratorContext.unshift(composition.iterator);
|
|
368
366
|
}
|
|
369
|
-
traverseComposition(value,
|
|
367
|
+
traverseComposition(value, cb, iteratorContext);
|
|
370
368
|
if (isCompositionAnIteration(composition)) {
|
|
371
369
|
iteratorContext.shift();
|
|
372
370
|
}
|
|
373
371
|
}
|
|
374
372
|
}
|
|
375
|
-
if (callbacks.posttraversal) {
|
|
376
|
-
callbacks.posttraversal(composition, iteratorContext, parent);
|
|
377
|
-
}
|
|
378
373
|
}
|
|
379
374
|
exports.traverseComposition = traverseComposition;
|
|
380
375
|
/**
|
package/build/moduleMetadata.js
CHANGED
|
@@ -21,6 +21,7 @@ const initModuleMetadataObject = () => ({
|
|
|
21
21
|
adgs: new Map(),
|
|
22
22
|
exports: {},
|
|
23
23
|
templateKomaciDocMap: {},
|
|
24
|
+
hasRenderFunction: false,
|
|
24
25
|
staticMetadataId: '',
|
|
25
26
|
});
|
|
26
27
|
exports.initModuleMetadataObject = initModuleMetadataObject;
|
|
@@ -503,64 +504,43 @@ const addTemplateUsageForAdg = (doc, adgIndex, moduleMetadata) => {
|
|
|
503
504
|
const composition = doc.compositions[doc.exports.default.value];
|
|
504
505
|
adg.compositions = [composition];
|
|
505
506
|
adg.compositionRootIndex = doc.exports.default.value;
|
|
506
|
-
(0, komaciDocumentIntrospection_1.traverseComposition)(composition, {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
: `t${adgIndex}-${comp.input.value}`);
|
|
528
|
-
const importInfo = importName
|
|
529
|
-
? moduleMetadata.importsByName.get(importName)
|
|
530
|
-
: undefined;
|
|
531
|
-
if (importInfo) {
|
|
532
|
-
importInfo.usedInPriming = true;
|
|
533
|
-
}
|
|
534
|
-
//changing the comp node to be what t is referencing
|
|
535
|
-
if (!visitedImportForTemplate) {
|
|
536
|
-
comp.input.value = `t${adgIndex}-${comp.input.value}`;
|
|
537
|
-
}
|
|
507
|
+
(0, komaciDocumentIntrospection_1.traverseComposition)(composition, (comp, iterationContext) => {
|
|
508
|
+
(0, komaciDocumentIntrospection_1.updatePropertiesForComposition)(comp, adg.properties, adg.propertiesUsedInTemplate, iterationContext);
|
|
509
|
+
if (comp && comp.isActive) {
|
|
510
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.UNRESOLVED_FUNC);
|
|
511
|
+
}
|
|
512
|
+
if ((0, komaciDocumentIntrospection_1.isCompositionAComposedAdg)(comp)) {
|
|
513
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.COMPOSED_GRAPH_FUNC);
|
|
514
|
+
if (comp.input.type === 'ImportReference') {
|
|
515
|
+
const visitedImportForTemplate = comp.input.value.startsWith(`t`);
|
|
516
|
+
const importName = moduleMetadata.importIndexReference.get(visitedImportForTemplate
|
|
517
|
+
? comp.input.value
|
|
518
|
+
: `t${adgIndex}-${comp.input.value}`);
|
|
519
|
+
const importInfo = importName
|
|
520
|
+
? moduleMetadata.importsByName.get(importName)
|
|
521
|
+
: undefined;
|
|
522
|
+
if (importInfo) {
|
|
523
|
+
importInfo.usedInPriming = true;
|
|
524
|
+
}
|
|
525
|
+
//changing the comp node to be what t is referencing
|
|
526
|
+
if (!visitedImportForTemplate) {
|
|
527
|
+
comp.input.value = `t${adgIndex}-${comp.input.value}`;
|
|
538
528
|
}
|
|
539
529
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
posttraversal: (comp, iterationContext, parent) => {
|
|
555
|
-
// if the current composition is supposed to be slotted but its a child of a "processing" node i.e. conditional or iteration, set the slot on the parent
|
|
556
|
-
if (comp.slot &&
|
|
557
|
-
parent &&
|
|
558
|
-
(((0, komaciDocumentIntrospection_1.isCompositionAContainer)(parent) && parent.isActive) ||
|
|
559
|
-
(0, komaciDocumentIntrospection_1.isCompositionAnIteration)(parent))) {
|
|
560
|
-
parent.slot = comp.slot;
|
|
561
|
-
comp.slot = undefined;
|
|
562
|
-
}
|
|
563
|
-
},
|
|
530
|
+
}
|
|
531
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionASlot)(comp)) {
|
|
532
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.SLOT_FUNC);
|
|
533
|
+
}
|
|
534
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionAnIteration)(comp)) {
|
|
535
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.ITERATION_FUNC);
|
|
536
|
+
}
|
|
537
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionAnImage)(comp)) {
|
|
538
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.IMG_FUNC);
|
|
539
|
+
}
|
|
540
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionAContainer)(comp) && (comp.key || comp.slot)) {
|
|
541
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.ELEMENT_FUNC);
|
|
542
|
+
}
|
|
543
|
+
return false;
|
|
564
544
|
});
|
|
565
545
|
}
|
|
566
546
|
}
|
package/build/types.d.ts
CHANGED
|
@@ -35,8 +35,7 @@ export declare enum IdKeys {
|
|
|
35
35
|
REDUCER_FUNC_ID = "REDUCER_FUNC_ID",
|
|
36
36
|
IMG_SRC = "IMG_SRC",
|
|
37
37
|
IMG_FUNC = "IMG_FUNC",
|
|
38
|
-
HOISTED_RENDER_FUNC_ID = "HOISTED_RENDER_FUNC_ID"
|
|
39
|
-
CONDITION_FUNC = "CONDITION_FUNC"
|
|
38
|
+
HOISTED_RENDER_FUNC_ID = "HOISTED_RENDER_FUNC_ID"
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
41
|
* @typedef AstContext is an object that holds meta data information about the ast.
|
|
@@ -287,7 +286,7 @@ export declare type ModuleMetadata = {
|
|
|
287
286
|
templateKomaciDocMap: {
|
|
288
287
|
[fName: string]: KomaciDocument;
|
|
289
288
|
};
|
|
290
|
-
|
|
289
|
+
hasRenderFunction: boolean;
|
|
291
290
|
staticMetadataId: string;
|
|
292
291
|
includePropsMetadata?: boolean;
|
|
293
292
|
moduleType?: ModuleTypes.BUNDLE_MODULE | ModuleTypes.SCRIPT_ONLY | ModuleTypes.TEMPLATE_ONLY;
|
package/build/types.js
CHANGED
|
@@ -37,7 +37,6 @@ var IdKeys;
|
|
|
37
37
|
IdKeys["IMG_SRC"] = "IMG_SRC";
|
|
38
38
|
IdKeys["IMG_FUNC"] = "IMG_FUNC";
|
|
39
39
|
IdKeys["HOISTED_RENDER_FUNC_ID"] = "HOISTED_RENDER_FUNC_ID";
|
|
40
|
-
IdKeys["CONDITION_FUNC"] = "CONDITION_FUNC";
|
|
41
40
|
})(IdKeys = exports.IdKeys || (exports.IdKeys = {}));
|
|
42
41
|
/**
|
|
43
42
|
* Possbile types of properties we can encounter in a LWC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@komaci/common-shared",
|
|
3
|
-
"version": "244.
|
|
3
|
+
"version": "244.2.0",
|
|
4
4
|
"description": "Assets that are shared across Komaci commonjs packages",
|
|
5
5
|
"homepage": "https://komaci.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"build/komaci-mapping.json"
|
|
30
30
|
],
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@komaci/types": "244.
|
|
32
|
+
"@komaci/types": "244.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/core": "^7.9.0",
|