@komaci/common-shared 244.1.4 → 244.1.7
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,7 +117,10 @@ 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,
|
|
120
|
+
export declare function traverseComposition(composition: Composition, callbacks: {
|
|
121
|
+
pretraversal?: (Composition: Composition, iterationContext: string[], parent?: Composition) => boolean;
|
|
122
|
+
posttraversal?: (Composition: Composition, iterationContext: string[], parent?: Composition) => void;
|
|
123
|
+
}, iteratorContext?: string[], parent?: Composition): void;
|
|
121
124
|
/**
|
|
122
125
|
* Recursively probe a composition and it's children for usages of properties.
|
|
123
126
|
* @param composition Current composition
|
|
@@ -357,19 +357,24 @@ 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 =
|
|
360
|
+
function traverseComposition(composition, callbacks, iteratorContext = [], parent) {
|
|
361
|
+
const found = callbacks.pretraversal
|
|
362
|
+
? callbacks.pretraversal(composition, iteratorContext, parent)
|
|
363
|
+
: false;
|
|
362
364
|
if (!found && composition && composition.compositions) {
|
|
363
365
|
for (const value of composition.compositions) {
|
|
364
366
|
if (isCompositionAnIteration(composition)) {
|
|
365
367
|
iteratorContext.unshift(composition.iterator);
|
|
366
368
|
}
|
|
367
|
-
traverseComposition(value,
|
|
369
|
+
traverseComposition(value, callbacks, iteratorContext, composition);
|
|
368
370
|
if (isCompositionAnIteration(composition)) {
|
|
369
371
|
iteratorContext.shift();
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
}
|
|
375
|
+
if (callbacks.posttraversal) {
|
|
376
|
+
callbacks.posttraversal(composition, iteratorContext, parent);
|
|
377
|
+
}
|
|
373
378
|
}
|
|
374
379
|
exports.traverseComposition = traverseComposition;
|
|
375
380
|
/**
|
package/build/moduleMetadata.js
CHANGED
|
@@ -21,7 +21,6 @@ const initModuleMetadataObject = () => ({
|
|
|
21
21
|
adgs: new Map(),
|
|
22
22
|
exports: {},
|
|
23
23
|
templateKomaciDocMap: {},
|
|
24
|
-
hasRenderFunction: false,
|
|
25
24
|
staticMetadataId: '',
|
|
26
25
|
});
|
|
27
26
|
exports.initModuleMetadataObject = initModuleMetadataObject;
|
|
@@ -504,43 +503,64 @@ const addTemplateUsageForAdg = (doc, adgIndex, moduleMetadata) => {
|
|
|
504
503
|
const composition = doc.compositions[doc.exports.default.value];
|
|
505
504
|
adg.compositions = [composition];
|
|
506
505
|
adg.compositionRootIndex = doc.exports.default.value;
|
|
507
|
-
(0, komaciDocumentIntrospection_1.traverseComposition)(composition,
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
506
|
+
(0, komaciDocumentIntrospection_1.traverseComposition)(composition, {
|
|
507
|
+
pretraversal: (comp, iterationContext, parent) => {
|
|
508
|
+
(0, komaciDocumentIntrospection_1.updatePropertiesForComposition)(comp, adg.properties, adg.propertiesUsedInTemplate, iterationContext);
|
|
509
|
+
if (comp && comp.isActive) {
|
|
510
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.CONDITION_FUNC);
|
|
511
|
+
}
|
|
512
|
+
if (parent &&
|
|
513
|
+
(0, komaciDocumentIntrospection_1.isCompositionAComposedAdg)(parent) &&
|
|
514
|
+
((0, komaciDocumentIntrospection_1.isCompositionAComposedAdg)(comp) ||
|
|
515
|
+
(0, komaciDocumentIntrospection_1.isCompositionAContainer)(comp) ||
|
|
516
|
+
(0, komaciDocumentIntrospection_1.isCompositionASlot)(comp) ||
|
|
517
|
+
(0, komaciDocumentIntrospection_1.isCompositionAnIteration)(comp)) &&
|
|
518
|
+
!comp.slot) {
|
|
519
|
+
comp.slot = '';
|
|
520
|
+
}
|
|
521
|
+
if ((0, komaciDocumentIntrospection_1.isCompositionAComposedAdg)(comp)) {
|
|
522
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.COMPOSED_GRAPH_FUNC);
|
|
523
|
+
if (comp.input.type === 'ImportReference') {
|
|
524
|
+
const visitedImportForTemplate = comp.input.value.startsWith(`t`);
|
|
525
|
+
const importName = moduleMetadata.importIndexReference.get(visitedImportForTemplate
|
|
526
|
+
? comp.input.value
|
|
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
|
+
}
|
|
528
538
|
}
|
|
529
539
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
540
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionASlot)(comp)) {
|
|
541
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.SLOT_FUNC);
|
|
542
|
+
}
|
|
543
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionAnIteration)(comp)) {
|
|
544
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.ITERATION_FUNC);
|
|
545
|
+
}
|
|
546
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionAnImage)(comp)) {
|
|
547
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.IMG_FUNC);
|
|
548
|
+
}
|
|
549
|
+
else if ((0, komaciDocumentIntrospection_1.isCompositionAContainer)(comp) && (comp.key || comp.slot)) {
|
|
550
|
+
adg.requiredCompositionFactoryFunctions.add(types_1.IdKeys.ELEMENT_FUNC);
|
|
551
|
+
}
|
|
552
|
+
return false;
|
|
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
|
+
},
|
|
544
564
|
});
|
|
545
565
|
}
|
|
546
566
|
}
|
package/build/types.d.ts
CHANGED
|
@@ -35,7 +35,8 @@ 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"
|
|
38
|
+
HOISTED_RENDER_FUNC_ID = "HOISTED_RENDER_FUNC_ID",
|
|
39
|
+
CONDITION_FUNC = "CONDITION_FUNC"
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* @typedef AstContext is an object that holds meta data information about the ast.
|
|
@@ -286,8 +287,9 @@ export declare type ModuleMetadata = {
|
|
|
286
287
|
templateKomaciDocMap: {
|
|
287
288
|
[fName: string]: KomaciDocument;
|
|
288
289
|
};
|
|
289
|
-
|
|
290
|
+
renderFunction?: HoistedFunctionMetadata;
|
|
290
291
|
staticMetadataId: string;
|
|
292
|
+
includePropsMetadata?: boolean;
|
|
291
293
|
moduleType?: ModuleTypes.BUNDLE_MODULE | ModuleTypes.SCRIPT_ONLY | ModuleTypes.TEMPLATE_ONLY;
|
|
292
294
|
};
|
|
293
295
|
export declare type ImportBinding = {
|
package/build/types.js
CHANGED
|
@@ -37,6 +37,7 @@ 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";
|
|
40
41
|
})(IdKeys = exports.IdKeys || (exports.IdKeys = {}));
|
|
41
42
|
/**
|
|
42
43
|
* 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.1.
|
|
3
|
+
"version": "244.1.7",
|
|
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.1.
|
|
32
|
+
"@komaci/types": "244.1.7"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/core": "^7.9.0",
|