coralite 0.31.4 → 0.31.5
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,2IAXW,cAAc,QAmMxB;;IA3ND;;;;;;;;;;;;;;;;OAgBG;IAEH;;OAEG;IAEH;;;;;;;;;;;;OAYG;IACH,8HAXW,cAAc,EAmMxB;IA1JC,6DAA+B;IAG/B;;;;;;;;;;;;;;MAWC;IAED,oDAAoD;IACpD,eADW,GAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAClB;IAG9B;;;;;;;;;;;;;;MAcC;IAGD,8BAAqD;IAGrD;;;;;;;;
|
|
1
|
+
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,2IAXW,cAAc,QAmMxB;;IA3ND;;;;;;;;;;;;;;;;OAgBG;IAEH;;OAEG;IAEH;;;;;;;;;;;;OAYG;IACH,8HAXW,cAAc,EAmMxB;IA1JC,6DAA+B;IAG/B;;;;;;;;;;;;;;MAWC;IAED,oDAAoD;IACpD,eADW,GAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAClB;IAG9B;;;;;;;;;;;;;;MAcC;IAGD,8BAAqD;IAGrD;;;;;;;;8BAu1CS,qBAAqB,GAAG,eAAe,GAAG,eAAe,EAAE,YAC3D,oBAAoB,KAClB,MAAM;;;;;;;;;;;;MAl0ChB;IA6FH;;;OAGG;IACH,cAFa,OAAO,CAAC,IAAI,CAAC,CA0PzB;IAvPC,+BA2CE;IAWF;;OAEG;IACH;;MAA6C;IA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AAU,OAAO,CAAC,oBAAoB,CAAC,CA4EzC;IAED;;;;;;;;;;;;;OAaG;IACH,sFATG;QAA6B,MAAM,EAA3B,cAAc;QACa,MAAM,EAAjC,oBAAoB;QACE,OAAO,EAA7B,eAAe;QACS,SAAS,EAAjC,iBAAiB;QACJ,SAAS,EAAtB,MAAM;QACO,aAAa;KAElC,GAAU,OAAO,CAAC,oBAAoB,CAAC,CAiHzC;IAED;;;;;;;;;;;;;OAaG;IACH,yBAFa,OAAO,CAAC,oBAAoB,CAAC,CAOzC;IAED;;;;;;;;;;OAUG;IACH,mBAVsB,CAAC,wBAMZ,WAAW,GAAC,cAAc,GAAC,cAAc,GAAC,gBAAgB,GAAC,mBAAmB,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,eAAe,GAAC,cAAc,QAC1K,CAAC,GACA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAc5B;IAED;;;;;;;OAOG;IACH,qBAHW,WAAW,GAAC,cAAc,GAAC,cAAc,GAAC,gBAAgB,GAAC,mBAAmB,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,eAAe,GAAC,cAAc,4BAapL;;;wCA1vCU,cAAc,KACZ,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;oCA7qCN,mBAAmB;4CAAnB,mBAAmB;8BA/Bd,qBAAqB;6BAHT,WAAW;4BAAX,WAAW;+BACiB,YAAY;2CAiCzD,mBAAmB;qCAAnB,mBAAmB;0CAIL,gBAAgB;+BAvBxB,iBAAiB;oCAmBvB,mBAAmB;uCAAnB,mBAAmB;0CAAnB,mBAAmB;qCAAnB,mBAAmB;oCAAnB,mBAAmB"}
|
package/dist/lib/index.js
CHANGED
|
@@ -6447,25 +6447,39 @@ function cleanKeys(object) {
|
|
|
6447
6447
|
}
|
|
6448
6448
|
return result;
|
|
6449
6449
|
}
|
|
6450
|
-
function normalizeObjectFunctions(target) {
|
|
6450
|
+
function normalizeObjectFunctions(target, seen = /* @__PURE__ */ new WeakMap()) {
|
|
6451
|
+
if (typeof target !== "object" || target === null) {
|
|
6452
|
+
return target;
|
|
6453
|
+
}
|
|
6454
|
+
if (seen.has(target)) {
|
|
6455
|
+
return seen.get(target);
|
|
6456
|
+
}
|
|
6451
6457
|
if (Array.isArray(target)) {
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
for (
|
|
6458
|
+
const arr = [];
|
|
6459
|
+
seen.set(target, arr);
|
|
6460
|
+
for (let i = 0; i < target.length; i++) {
|
|
6461
|
+
arr.push(normalizeObjectFunctions(target[i], seen));
|
|
6462
|
+
}
|
|
6463
|
+
return arr;
|
|
6464
|
+
}
|
|
6465
|
+
const obj = {};
|
|
6466
|
+
seen.set(target, obj);
|
|
6467
|
+
for (const key in target) {
|
|
6468
|
+
if (Object.hasOwn(target, key)) {
|
|
6455
6469
|
if (typeof target[key] === "function") {
|
|
6456
|
-
if (target[key].__normalized) continue;
|
|
6457
6470
|
const normalizedString = normalizeFunction(target[key]);
|
|
6458
6471
|
const originalFunction = target[key];
|
|
6459
|
-
|
|
6472
|
+
const wrapper = function() {
|
|
6460
6473
|
return originalFunction.apply(this, arguments);
|
|
6461
6474
|
};
|
|
6462
|
-
|
|
6463
|
-
|
|
6475
|
+
wrapper.toString = () => normalizedString;
|
|
6476
|
+
obj[key] = wrapper;
|
|
6464
6477
|
} else {
|
|
6465
|
-
normalizeObjectFunctions(target[key]);
|
|
6478
|
+
obj[key] = normalizeObjectFunctions(target[key], seen);
|
|
6466
6479
|
}
|
|
6467
6480
|
}
|
|
6468
6481
|
}
|
|
6482
|
+
return obj;
|
|
6469
6483
|
}
|
|
6470
6484
|
function hasObjectKeys(obj) {
|
|
6471
6485
|
return obj && typeof obj === "object" && Object.keys(obj).length > 0;
|
|
@@ -6497,10 +6511,10 @@ function normalizeFunction(func) {
|
|
|
6497
6511
|
if (header.startsWith("async get ") || header.startsWith("async set ")) {
|
|
6498
6512
|
return original;
|
|
6499
6513
|
}
|
|
6500
|
-
return original.replace(/^async\s+([$\w]+)\s*\(/, "async function
|
|
6514
|
+
return original.replace(/^async\s+([$\w]+)\s*\(/, "async function(");
|
|
6501
6515
|
} else {
|
|
6502
6516
|
if (header.startsWith("get ") || header.startsWith("set ")) return original;
|
|
6503
|
-
return original.replace(/^([$\w]+)\s*\(/, "function
|
|
6517
|
+
return original.replace(/^([$\w]+)\s*\(/, "function(");
|
|
6504
6518
|
}
|
|
6505
6519
|
}
|
|
6506
6520
|
function cloneNode(nodeMap, node, parent) {
|
|
@@ -9691,10 +9705,10 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
|
|
|
9691
9705
|
entryCodeParts.push("const coraliteComponentDefaults = {\n");
|
|
9692
9706
|
for (const key of processedComponentKeys) {
|
|
9693
9707
|
if (this.sharedFunctions[key] && this.sharedFunctions[key].defaultValues) {
|
|
9694
|
-
normalizeObjectFunctions(this.sharedFunctions[key].defaultValues);
|
|
9708
|
+
const normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[key].defaultValues);
|
|
9695
9709
|
entryCodeParts.push(` "${key}": (() => {
|
|
9696
9710
|
`);
|
|
9697
|
-
entryCodeParts.push(` const defaults = ${serialize(
|
|
9711
|
+
entryCodeParts.push(` const defaults = ${serialize(normalizedDefaults)};
|
|
9698
9712
|
`);
|
|
9699
9713
|
entryCodeParts.push(` return defaults;
|
|
9700
9714
|
`);
|
|
@@ -9792,12 +9806,17 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
|
|
|
9792
9806
|
refs: []
|
|
9793
9807
|
});
|
|
9794
9808
|
const styles = JSON.stringify(this.sharedFunctions[componentId].styles || "");
|
|
9809
|
+
let normalizedDefaults = this.sharedFunctions[componentId].defaultValues || {};
|
|
9795
9810
|
if (this.sharedFunctions[componentId].defaultValues) {
|
|
9796
|
-
normalizeObjectFunctions(this.sharedFunctions[componentId].defaultValues);
|
|
9811
|
+
normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[componentId].defaultValues);
|
|
9797
9812
|
}
|
|
9798
|
-
const defaults = serialize(
|
|
9813
|
+
const defaults = serialize(normalizedDefaults);
|
|
9799
9814
|
const dependencies = JSON.stringify(this.sharedFunctions[componentId].components || []);
|
|
9800
|
-
|
|
9815
|
+
let normalizedSlots = this.sharedFunctions[componentId].slots || {};
|
|
9816
|
+
if (this.sharedFunctions[componentId].slots) {
|
|
9817
|
+
normalizedSlots = normalizeObjectFunctions(this.sharedFunctions[componentId].slots);
|
|
9818
|
+
}
|
|
9819
|
+
const slots = serialize(normalizedSlots);
|
|
9801
9820
|
componentEntryCode += `
|
|
9802
9821
|
export default {
|
|
9803
9822
|
componentId: "${componentId}",
|
|
@@ -11556,12 +11575,13 @@ const globalSetupValuesPromise = getSetups(globalContext);
|
|
|
11556
11575
|
};
|
|
11557
11576
|
context.root = window.document;
|
|
11558
11577
|
const setupValues = await globalSetupValuesPromise;
|
|
11559
|
-
context.values = { ...context.values, ...setupValues };
|
|
11560
11578
|
const helpers = await getHelpers(context);
|
|
11561
11579
|
context.helpers = helpers;
|
|
11562
11580
|
|
|
11563
11581
|
const module = await import('${base2}assets/js/${scriptResult.manifest[instance.componentId]}');
|
|
11564
11582
|
|
|
11583
|
+
context.values = { ...module.default.defaultValues, ...context.values, ...setupValues };
|
|
11584
|
+
|
|
11565
11585
|
// Explicitly load declarative script dependencies if any
|
|
11566
11586
|
const deps = module.default.dependencies || [];
|
|
11567
11587
|
if (deps.length > 0) {
|
|
@@ -11836,7 +11856,6 @@ Coralite.prototype._processDependentComponents = async function(componentIds, re
|
|
|
11836
11856
|
};
|
|
11837
11857
|
let nestedComponents = [];
|
|
11838
11858
|
let defaultValues = {};
|
|
11839
|
-
let slots = {};
|
|
11840
11859
|
if (scriptResult.__script__) {
|
|
11841
11860
|
const extractedScript = findAndExtractScript(module.script);
|
|
11842
11861
|
if (extractedScript) {
|
|
@@ -11849,7 +11868,9 @@ Coralite.prototype._processDependentComponents = async function(componentIds, re
|
|
|
11849
11868
|
nestedComponents = Array.from(/* @__PURE__ */ new Set([...scriptComponents, ...declarativeComponents]));
|
|
11850
11869
|
scriptObj.components = nestedComponents;
|
|
11851
11870
|
defaultValues = scriptResult.__script__.defaultValues || {};
|
|
11852
|
-
|
|
11871
|
+
if (scriptResult.__script__.slots) {
|
|
11872
|
+
scriptObj.slots = scriptResult.__script__.slots;
|
|
11873
|
+
}
|
|
11853
11874
|
delete scriptResult.__script__;
|
|
11854
11875
|
} else {
|
|
11855
11876
|
const declarativeComponents = (module.customElements || []).map((el) => el.name);
|
|
@@ -11898,7 +11919,7 @@ Coralite.prototype._processDependentComponents = async function(componentIds, re
|
|
|
11898
11919
|
templateValues,
|
|
11899
11920
|
defaultValues,
|
|
11900
11921
|
styles: stylesHTML,
|
|
11901
|
-
slots
|
|
11922
|
+
slots: scriptObj.slots || {}
|
|
11902
11923
|
});
|
|
11903
11924
|
if (nestedComponents.length > 0) {
|
|
11904
11925
|
await this._processDependentComponents(nestedComponents, renderContext, parentComponent);
|