coralite 0.31.3 → 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.
- package/dist/lib/coralite.d.ts.map +1 -1
- package/dist/lib/index.js +184 -38
- package/dist/lib/index.js.map +2 -2
- package/dist/lib/parse.d.ts.map +1 -1
- package/dist/lib/script-manager.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +23 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/plugins/define-component.d.ts.map +1 -1
- package/dist/plugins/define-component.js +11 -7
- package/dist/plugins/metadata.d.ts.map +1 -1
- package/dist/plugins/metadata.js +7 -1
- package/package.json +1 -1
|
@@ -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;IACp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AAnB,mBAAmB;0CAIL,gBAAgB;+BAvBxB,iBAAiB;oCAmBvB,mBAAmB;uCAAnB,mBAAmB;0CAAnB,mBAAmB;qCAAnB,mBAAmB;oCAAnB,mBAAmB"}
|
package/dist/lib/index.js
CHANGED
|
@@ -6447,6 +6447,53 @@ function cleanKeys(object) {
|
|
|
6447
6447
|
}
|
|
6448
6448
|
return result;
|
|
6449
6449
|
}
|
|
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
|
+
}
|
|
6457
|
+
if (Array.isArray(target)) {
|
|
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)) {
|
|
6469
|
+
if (typeof target[key] === "function") {
|
|
6470
|
+
const normalizedString = normalizeFunction(target[key]);
|
|
6471
|
+
const originalFunction = target[key];
|
|
6472
|
+
const wrapper = function() {
|
|
6473
|
+
return originalFunction.apply(this, arguments);
|
|
6474
|
+
};
|
|
6475
|
+
wrapper.toString = () => normalizedString;
|
|
6476
|
+
obj[key] = wrapper;
|
|
6477
|
+
} else {
|
|
6478
|
+
obj[key] = normalizeObjectFunctions(target[key], seen);
|
|
6479
|
+
}
|
|
6480
|
+
}
|
|
6481
|
+
}
|
|
6482
|
+
return obj;
|
|
6483
|
+
}
|
|
6484
|
+
function hasObjectKeys(obj) {
|
|
6485
|
+
return obj && typeof obj === "object" && Object.keys(obj).length > 0;
|
|
6486
|
+
}
|
|
6487
|
+
function mergeUniqueObjects(arr1, arr2) {
|
|
6488
|
+
const all = [...arr1 || [], ...arr2 || []];
|
|
6489
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6490
|
+
return all.filter((item) => {
|
|
6491
|
+
const key = typeof item === "object" ? JSON.stringify(item) : item;
|
|
6492
|
+
if (seen.has(key)) return false;
|
|
6493
|
+
seen.add(key);
|
|
6494
|
+
return true;
|
|
6495
|
+
});
|
|
6496
|
+
}
|
|
6450
6497
|
function normalizeFunction(func) {
|
|
6451
6498
|
const original = func.toString().trim();
|
|
6452
6499
|
const firstBrace = original.indexOf("{");
|
|
@@ -6464,10 +6511,10 @@ function normalizeFunction(func) {
|
|
|
6464
6511
|
if (header.startsWith("async get ") || header.startsWith("async set ")) {
|
|
6465
6512
|
return original;
|
|
6466
6513
|
}
|
|
6467
|
-
return original.replace(/^async\s+([$\w]+)\s*\(/, "async function
|
|
6514
|
+
return original.replace(/^async\s+([$\w]+)\s*\(/, "async function(");
|
|
6468
6515
|
} else {
|
|
6469
6516
|
if (header.startsWith("get ") || header.startsWith("set ")) return original;
|
|
6470
|
-
return original.replace(/^([$\w]+)\s*\(/, "function
|
|
6517
|
+
return original.replace(/^([$\w]+)\s*\(/, "function(");
|
|
6471
6518
|
}
|
|
6472
6519
|
}
|
|
6473
6520
|
function cloneNode(nodeMap, node, parent) {
|
|
@@ -9211,10 +9258,11 @@ function createElement({
|
|
|
9211
9258
|
if (!VALID_TAGS[sanitisedName]) {
|
|
9212
9259
|
const specUrl = "https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name";
|
|
9213
9260
|
try {
|
|
9214
|
-
|
|
9261
|
+
element.name = name;
|
|
9262
|
+
if (isValidCustomElementName(name)) {
|
|
9215
9263
|
element.slots = [];
|
|
9216
9264
|
} else {
|
|
9217
|
-
const message = 'Invalid custom element tag name: "' +
|
|
9265
|
+
const message = 'Invalid custom element tag name: "' + name + '" (' + specUrl + ")";
|
|
9218
9266
|
if (typeof onError === "function") {
|
|
9219
9267
|
onError({
|
|
9220
9268
|
level: "WARN",
|
|
@@ -9462,19 +9510,68 @@ ScriptManager.prototype.getHelpers = function() {
|
|
|
9462
9510
|
}
|
|
9463
9511
|
return `{${helpers}}`;
|
|
9464
9512
|
};
|
|
9465
|
-
ScriptManager.prototype.registerComponent = function({
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9513
|
+
ScriptManager.prototype.registerComponent = function({
|
|
9514
|
+
id,
|
|
9515
|
+
script = {},
|
|
9516
|
+
filePath,
|
|
9517
|
+
templateAST = null,
|
|
9518
|
+
templateValues = null,
|
|
9519
|
+
defaultValues = {},
|
|
9520
|
+
styles = "",
|
|
9521
|
+
slots = {}
|
|
9522
|
+
}) {
|
|
9523
|
+
if (!this.sharedFunctions[id]) {
|
|
9524
|
+
this.sharedFunctions[id] = {
|
|
9525
|
+
id,
|
|
9526
|
+
imports: [],
|
|
9527
|
+
components: [],
|
|
9528
|
+
filePath: `/component-${id}.js`
|
|
9529
|
+
};
|
|
9530
|
+
}
|
|
9531
|
+
const target = this.sharedFunctions[id];
|
|
9532
|
+
if (hasObjectKeys(script)) {
|
|
9533
|
+
target.script = script;
|
|
9534
|
+
}
|
|
9535
|
+
if (templateAST) {
|
|
9536
|
+
target.templateAST = templateAST;
|
|
9537
|
+
}
|
|
9538
|
+
if (templateValues) {
|
|
9539
|
+
target.templateValues = templateValues;
|
|
9540
|
+
}
|
|
9541
|
+
if (styles) {
|
|
9542
|
+
target.styles = styles;
|
|
9543
|
+
}
|
|
9544
|
+
if (filePath) {
|
|
9545
|
+
target.filePath = resolve(filePath);
|
|
9546
|
+
}
|
|
9547
|
+
if (hasObjectKeys(defaultValues)) {
|
|
9548
|
+
if (target.defaultValues) {
|
|
9549
|
+
target.defaultValues = {
|
|
9550
|
+
...target.defaultValues,
|
|
9551
|
+
...defaultValues
|
|
9552
|
+
};
|
|
9553
|
+
} else {
|
|
9554
|
+
target.defaultValues = defaultValues;
|
|
9555
|
+
}
|
|
9556
|
+
}
|
|
9557
|
+
if (hasObjectKeys(slots)) {
|
|
9558
|
+
if (target.slots) {
|
|
9559
|
+
target.slots = {
|
|
9560
|
+
...target.slots,
|
|
9561
|
+
...slots
|
|
9562
|
+
};
|
|
9563
|
+
} else {
|
|
9564
|
+
target.slots = slots;
|
|
9565
|
+
}
|
|
9566
|
+
}
|
|
9567
|
+
if (script) {
|
|
9568
|
+
if (script.imports?.length) {
|
|
9569
|
+
target.imports = mergeUniqueObjects(target.imports, script.imports);
|
|
9570
|
+
}
|
|
9571
|
+
if (script.components?.length) {
|
|
9572
|
+
target.components = mergeUniqueObjects(target.components, script.components);
|
|
9573
|
+
}
|
|
9574
|
+
}
|
|
9478
9575
|
};
|
|
9479
9576
|
ScriptManager.prototype.generateInstanceWrapper = function(id, instanceContext) {
|
|
9480
9577
|
const values = instanceContext.values ? serialize(instanceContext.values) : "{}";
|
|
@@ -9608,9 +9705,10 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
|
|
|
9608
9705
|
entryCodeParts.push("const coraliteComponentDefaults = {\n");
|
|
9609
9706
|
for (const key of processedComponentKeys) {
|
|
9610
9707
|
if (this.sharedFunctions[key] && this.sharedFunctions[key].defaultValues) {
|
|
9708
|
+
const normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[key].defaultValues);
|
|
9611
9709
|
entryCodeParts.push(` "${key}": (() => {
|
|
9612
9710
|
`);
|
|
9613
|
-
entryCodeParts.push(` const defaults = ${serialize(
|
|
9711
|
+
entryCodeParts.push(` const defaults = ${serialize(normalizedDefaults)};
|
|
9614
9712
|
`);
|
|
9615
9713
|
entryCodeParts.push(` return defaults;
|
|
9616
9714
|
`);
|
|
@@ -9708,9 +9806,17 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
|
|
|
9708
9806
|
refs: []
|
|
9709
9807
|
});
|
|
9710
9808
|
const styles = JSON.stringify(this.sharedFunctions[componentId].styles || "");
|
|
9711
|
-
|
|
9809
|
+
let normalizedDefaults = this.sharedFunctions[componentId].defaultValues || {};
|
|
9810
|
+
if (this.sharedFunctions[componentId].defaultValues) {
|
|
9811
|
+
normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[componentId].defaultValues);
|
|
9812
|
+
}
|
|
9813
|
+
const defaults = serialize(normalizedDefaults);
|
|
9712
9814
|
const dependencies = JSON.stringify(this.sharedFunctions[componentId].components || []);
|
|
9713
|
-
|
|
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);
|
|
9714
9820
|
componentEntryCode += `
|
|
9715
9821
|
export default {
|
|
9716
9822
|
componentId: "${componentId}",
|
|
@@ -10139,12 +10245,14 @@ var defineComponent = createPlugin({
|
|
|
10139
10245
|
const computedSlot = slots[name];
|
|
10140
10246
|
const slotContent = [];
|
|
10141
10247
|
const elementSlots = [];
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10248
|
+
if (element && element.slots) {
|
|
10249
|
+
for (let i = 0; i < element.slots.length; i++) {
|
|
10250
|
+
const slot = element.slots[i];
|
|
10251
|
+
if (slot.name === name) {
|
|
10252
|
+
slotContent.push(slot.node);
|
|
10253
|
+
} else {
|
|
10254
|
+
elementSlots.push(slot);
|
|
10255
|
+
}
|
|
10148
10256
|
}
|
|
10149
10257
|
}
|
|
10150
10258
|
const result = computedSlot(slotContent, results) || slotContent;
|
|
@@ -10183,7 +10291,9 @@ var defineComponent = createPlugin({
|
|
|
10183
10291
|
}
|
|
10184
10292
|
}
|
|
10185
10293
|
}
|
|
10186
|
-
element
|
|
10294
|
+
if (element) {
|
|
10295
|
+
element.slots = elementSlots;
|
|
10296
|
+
}
|
|
10187
10297
|
}
|
|
10188
10298
|
}
|
|
10189
10299
|
}
|
|
@@ -10270,7 +10380,13 @@ var metadataPlugin = createPlugin({
|
|
|
10270
10380
|
id: element.name,
|
|
10271
10381
|
values,
|
|
10272
10382
|
element,
|
|
10273
|
-
component:
|
|
10383
|
+
component: (
|
|
10384
|
+
/** @type {any} */
|
|
10385
|
+
{
|
|
10386
|
+
...elements,
|
|
10387
|
+
path: data2.path
|
|
10388
|
+
}
|
|
10389
|
+
),
|
|
10274
10390
|
contextId: data2.path.pathname + i3 + element.name,
|
|
10275
10391
|
index: i3
|
|
10276
10392
|
});
|
|
@@ -11200,6 +11316,13 @@ const globalSetupValuesPromise = getSetups(globalContext);
|
|
|
11200
11316
|
// Merge defaults
|
|
11201
11317
|
this._values = Object.assign({}, module.default.defaultValues, this._values);
|
|
11202
11318
|
|
|
11319
|
+
if (module.default.templateValues && module.default.templateValues.refs) {
|
|
11320
|
+
for (let i = 0; i < module.default.templateValues.refs.length; i++) {
|
|
11321
|
+
const ref = module.default.templateValues.refs[i];
|
|
11322
|
+
this._values['ref_' + ref.name] = this.componentId + '__' + ref.name + '-' + this._index;
|
|
11323
|
+
}
|
|
11324
|
+
}
|
|
11325
|
+
|
|
11203
11326
|
;(async () => {
|
|
11204
11327
|
const deps = module.default.dependencies || [];
|
|
11205
11328
|
if (deps.length > 0) {
|
|
@@ -11452,12 +11575,13 @@ const globalSetupValuesPromise = getSetups(globalContext);
|
|
|
11452
11575
|
};
|
|
11453
11576
|
context.root = window.document;
|
|
11454
11577
|
const setupValues = await globalSetupValuesPromise;
|
|
11455
|
-
context.values = { ...context.values, ...setupValues };
|
|
11456
11578
|
const helpers = await getHelpers(context);
|
|
11457
11579
|
context.helpers = helpers;
|
|
11458
11580
|
|
|
11459
11581
|
const module = await import('${base2}assets/js/${scriptResult.manifest[instance.componentId]}');
|
|
11460
11582
|
|
|
11583
|
+
context.values = { ...module.default.defaultValues, ...context.values, ...setupValues };
|
|
11584
|
+
|
|
11461
11585
|
// Explicitly load declarative script dependencies if any
|
|
11462
11586
|
const deps = module.default.dependencies || [];
|
|
11463
11587
|
if (deps.length > 0) {
|
|
@@ -11744,6 +11868,9 @@ Coralite.prototype._processDependentComponents = async function(componentIds, re
|
|
|
11744
11868
|
nestedComponents = Array.from(/* @__PURE__ */ new Set([...scriptComponents, ...declarativeComponents]));
|
|
11745
11869
|
scriptObj.components = nestedComponents;
|
|
11746
11870
|
defaultValues = scriptResult.__script__.defaultValues || {};
|
|
11871
|
+
if (scriptResult.__script__.slots) {
|
|
11872
|
+
scriptObj.slots = scriptResult.__script__.slots;
|
|
11873
|
+
}
|
|
11747
11874
|
delete scriptResult.__script__;
|
|
11748
11875
|
} else {
|
|
11749
11876
|
const declarativeComponents = (module.customElements || []).map((el) => el.name);
|
|
@@ -11768,6 +11895,22 @@ Coralite.prototype._processDependentComponents = async function(componentIds, re
|
|
|
11768
11895
|
defaultValues[token] = scriptResult[token];
|
|
11769
11896
|
}
|
|
11770
11897
|
}
|
|
11898
|
+
if (templateValues && templateValues.refs) {
|
|
11899
|
+
for (let i = 0; i < templateValues.refs.length; i++) {
|
|
11900
|
+
const ref2 = templateValues.refs[i];
|
|
11901
|
+
defaultValues[`ref_${ref2.name}`] = "";
|
|
11902
|
+
if (!scriptObj.values) {
|
|
11903
|
+
scriptObj.values = {};
|
|
11904
|
+
}
|
|
11905
|
+
scriptObj.values[`ref_${ref2.name}`] = "";
|
|
11906
|
+
}
|
|
11907
|
+
}
|
|
11908
|
+
if (!scriptResult.__script__) {
|
|
11909
|
+
scriptResult.__script__ = { defaultValues };
|
|
11910
|
+
} else {
|
|
11911
|
+
scriptResult.__script__.defaultValues = defaultValues;
|
|
11912
|
+
}
|
|
11913
|
+
scriptObj.defaultValues = defaultValues;
|
|
11771
11914
|
this._scriptManager.registerComponent({
|
|
11772
11915
|
id: module.id,
|
|
11773
11916
|
script: scriptObj,
|
|
@@ -11776,7 +11919,7 @@ Coralite.prototype._processDependentComponents = async function(componentIds, re
|
|
|
11776
11919
|
templateValues,
|
|
11777
11920
|
defaultValues,
|
|
11778
11921
|
styles: stylesHTML,
|
|
11779
|
-
slots:
|
|
11922
|
+
slots: scriptObj.slots || {}
|
|
11780
11923
|
});
|
|
11781
11924
|
if (nestedComponents.length > 0) {
|
|
11782
11925
|
await this._processDependentComponents(nestedComponents, renderContext, parentComponent);
|
|
@@ -11995,23 +12138,23 @@ Coralite.prototype.createComponentElement = async function({
|
|
|
11995
12138
|
contextId: childContextId,
|
|
11996
12139
|
index,
|
|
11997
12140
|
renderContext
|
|
11998
|
-
}, false).then((
|
|
11999
|
-
|
|
12141
|
+
}, false).then((childComponentElement) => ({
|
|
12142
|
+
childComponentElement,
|
|
12000
12143
|
customElement
|
|
12001
12144
|
}))
|
|
12002
12145
|
);
|
|
12003
12146
|
}
|
|
12004
12147
|
const results = await Promise.all(createComponentTasks);
|
|
12005
12148
|
for (let i = 0; i < results.length; i++) {
|
|
12006
|
-
const {
|
|
12149
|
+
const { childComponentElement, customElement } = results[i];
|
|
12007
12150
|
const children = customElement.parent.children;
|
|
12008
12151
|
if (!childIndex) {
|
|
12009
12152
|
childIndex = customElement.parentChildIndex;
|
|
12010
12153
|
} else {
|
|
12011
12154
|
childIndex = children.indexOf(customElement, customElement.parentChildIndex);
|
|
12012
12155
|
}
|
|
12013
|
-
if (
|
|
12014
|
-
children.splice(childIndex, 1, ...
|
|
12156
|
+
if (childComponentElement && typeof childComponentElement === "object") {
|
|
12157
|
+
children.splice(childIndex, 1, ...childComponentElement.children);
|
|
12015
12158
|
}
|
|
12016
12159
|
}
|
|
12017
12160
|
const slots = module.slotElements[id];
|
|
@@ -12050,8 +12193,8 @@ Coralite.prototype.createComponentElement = async function({
|
|
|
12050
12193
|
for (let i2 = startIndex; i2 > -1; i2--) {
|
|
12051
12194
|
const node = slotNodes[i2];
|
|
12052
12195
|
if (node.name) {
|
|
12053
|
-
const
|
|
12054
|
-
if (
|
|
12196
|
+
const slotComponentItem = this.components.getItem(node.name);
|
|
12197
|
+
if (slotComponentItem) {
|
|
12055
12198
|
const slotContextId = contextId + slotName + i2 + node.name;
|
|
12056
12199
|
const currentValues = renderContext.values[slotContextId] || {};
|
|
12057
12200
|
const attribValues = cleanKeys(node.attribs);
|
|
@@ -12068,7 +12211,7 @@ Coralite.prototype.createComponentElement = async function({
|
|
|
12068
12211
|
id: node.name,
|
|
12069
12212
|
values: renderContext.values[slotContextId],
|
|
12070
12213
|
element: node,
|
|
12071
|
-
component
|
|
12214
|
+
component,
|
|
12072
12215
|
contextId: slotContextId,
|
|
12073
12216
|
index,
|
|
12074
12217
|
renderContext
|
|
@@ -12363,6 +12506,7 @@ export {
|
|
|
12363
12506
|
getHtmlFile,
|
|
12364
12507
|
getHtmlFileSync,
|
|
12365
12508
|
getHtmlFiles,
|
|
12509
|
+
hasObjectKeys,
|
|
12366
12510
|
hasValidCommentStructure,
|
|
12367
12511
|
hasValidElementStructure,
|
|
12368
12512
|
hasValidTextNodeStructure,
|
|
@@ -12378,8 +12522,10 @@ export {
|
|
|
12378
12522
|
isRemovableNode,
|
|
12379
12523
|
isValidChildNode,
|
|
12380
12524
|
kebabToCamel,
|
|
12525
|
+
mergeUniqueObjects,
|
|
12381
12526
|
metadataPlugin,
|
|
12382
12527
|
normalizeFunction,
|
|
12528
|
+
normalizeObjectFunctions,
|
|
12383
12529
|
parseHTML,
|
|
12384
12530
|
parseModule,
|
|
12385
12531
|
refsPlugin,
|