@stencil/core 5.0.0-alpha.27 → 5.0.0-alpha.29
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/app-data/index.d.ts +1 -1
- package/dist/{client-CvcvHKz4.mjs → client-D1MsT-Rp.mjs} +373 -238
- package/dist/compiler/index.d.mts +2 -3
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +272 -2
- package/dist/compiler/utils/index.mjs +4 -3
- package/dist/{compiler-D43Ied7R.mjs → compiler-BbS9TDF_.mjs} +1845 -1118
- package/dist/declarations/stencil-ext-modules.d.ts +5 -5
- package/dist/declarations/stencil-public-compiler.d.ts +108 -40
- package/dist/declarations/stencil-public-docs.d.ts +9 -0
- package/dist/declarations/stencil-public-runtime.d.ts +81 -6
- package/dist/fragment-Di1hWOC8.mjs +4 -0
- package/dist/{index-F3IidHM1.d.mts → index-BHj3EBl2.d.mts} +395 -312
- package/dist/{index-xAkMgLX_.d.ts → index-D2PAsXxx.d.ts} +133 -9
- package/dist/index-VK8okIiF.d.mts +108 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +91 -2
- package/dist/jsx-runtime.mjs +2 -1
- package/dist/{node-DKVq_Ud0.mjs → node-BQR4L-TG.mjs} +60 -58
- package/dist/reactive-controller-BdCpSAQP.d.mts +13 -0
- package/dist/{regular-expression-CFVJOTUh.mjs → regular-expression-XqU5zmPp.mjs} +20 -3
- package/dist/{chunk-z9aeyW2b.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
- package/dist/runtime/client/lazy.js +411 -165
- package/dist/runtime/client/runtime.d.ts +136 -9
- package/dist/runtime/client/runtime.js +411 -165
- package/dist/runtime/index.d.ts +5 -3
- package/dist/runtime/index.js +410 -163
- package/dist/runtime/server/index.d.mts +80 -8
- package/dist/runtime/server/index.mjs +333 -158
- package/dist/runtime/server/runner.d.mts +3 -0
- package/dist/runtime/server/runner.mjs +232 -308
- package/dist/signals/index.d.ts +2 -0
- package/dist/sys/node/index.d.mts +1 -2
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.d.mts +1 -1
- package/dist/sys/node/worker.mjs +6 -3
- package/dist/testing/index.d.mts +4 -9
- package/dist/testing/index.mjs +74 -56
- package/dist/util-BIa-iHnt.mjs +724 -0
- package/dist/validation-Dd3g77T5.mjs +778 -0
- package/package.json +27 -27
- package/dist/index-3fu7WQs4.d.mts +0 -205
- package/dist/validation-ByxKj8bC.mjs +0 -1458
- /package/{LICENSE.md → LICENSE} +0 -0
|
@@ -43,8 +43,20 @@ const HOST_FLAGS = {
|
|
|
43
43
|
isWatchReady: 128,
|
|
44
44
|
isListenReady: 256,
|
|
45
45
|
needsRerender: 512,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Set once this component's real (lazy-loaded) `connectedCallback` has fired for
|
|
48
|
+
* the first time. Lets a descendant skip creating/awaiting a connect-promise for
|
|
49
|
+
* an ancestor that's already connected. See {@link HostRef.$onFirstConnectResolve$}.
|
|
50
|
+
*/
|
|
51
|
+
hasFiredConnected: 1024,
|
|
52
|
+
/**
|
|
53
|
+
* Set when a lazy component's dynamic `import()` fails to resolve a
|
|
54
|
+
* constructor. Distinct from `hasInitializedComponent` being unset, which
|
|
55
|
+
* is true while an initialization attempt is merely queued/in-flight.
|
|
56
|
+
*/
|
|
57
|
+
hasFailedLoad: 2048,
|
|
58
|
+
devOnRender: 4096,
|
|
59
|
+
devOnDidLoad: 8192
|
|
48
60
|
};
|
|
49
61
|
const CF_scopedCssEncapsulation = 2;
|
|
50
62
|
/**
|
|
@@ -295,6 +307,10 @@ const DEFAULT_DOC_DATA = {
|
|
|
295
307
|
*/
|
|
296
308
|
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
297
309
|
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
310
|
+
/**
|
|
311
|
+
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
312
|
+
*/
|
|
313
|
+
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
298
314
|
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
299
315
|
"formAssociatedCallback",
|
|
300
316
|
"formResetCallback",
|
|
@@ -343,8 +359,10 @@ function createShadowRoot(cmpMeta) {
|
|
|
343
359
|
const updateFallbackSlotVisibility = (elm) => {
|
|
344
360
|
const childNodes = internalCall(elm, "childNodes");
|
|
345
361
|
if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
|
|
346
|
-
if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB")
|
|
347
|
-
|
|
362
|
+
if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") {
|
|
363
|
+
if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
|
|
364
|
+
else slotNode.hidden = false;
|
|
365
|
+
}
|
|
348
366
|
});
|
|
349
367
|
let i = 0;
|
|
350
368
|
for (i = 0; i < childNodes.length; i++) {
|
|
@@ -387,7 +405,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
|
387
405
|
slottedNodes.push(childNode);
|
|
388
406
|
if (typeof slotName !== "undefined") return slottedNodes;
|
|
389
407
|
}
|
|
390
|
-
slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode
|
|
408
|
+
slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
|
|
391
409
|
}
|
|
392
410
|
return slottedNodes;
|
|
393
411
|
}
|
|
@@ -418,7 +436,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
|
|
|
418
436
|
if (nodeToRelocate.getAttribute("slot") === slotName) return true;
|
|
419
437
|
return false;
|
|
420
438
|
}
|
|
421
|
-
if (nodeToRelocate["s-
|
|
439
|
+
if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
|
|
422
440
|
return slotName === "";
|
|
423
441
|
};
|
|
424
442
|
/**
|
|
@@ -467,8 +485,10 @@ function patchSlotNode(node) {
|
|
|
467
485
|
const assignedFactory = (elementsOnly) => function(opts) {
|
|
468
486
|
const toReturn = [];
|
|
469
487
|
const slotName = this["s-sn"];
|
|
470
|
-
if (opts?.flatten)
|
|
471
|
-
|
|
488
|
+
if (opts?.flatten) {
|
|
489
|
+
if (BUILD$1.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
|
|
490
|
+
else console.error("Flattening not supported for Stencil non-shadow slots");
|
|
491
|
+
}
|
|
472
492
|
const parent = this["s-cr"].parentElement;
|
|
473
493
|
(parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
|
|
474
494
|
if (slotName === getSlotName(n)) toReturn.push(n);
|
|
@@ -559,8 +579,10 @@ const patchCloneNode = (HostElementPrototype) => {
|
|
|
559
579
|
for (; i < childNodes.length; i++) {
|
|
560
580
|
slotted = childNodes[i]["s-nr"];
|
|
561
581
|
nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
|
|
562
|
-
if (slotted)
|
|
563
|
-
|
|
582
|
+
if (slotted) {
|
|
583
|
+
if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
|
|
584
|
+
else clonedNode.appendChild(slotted.cloneNode(true));
|
|
585
|
+
}
|
|
564
586
|
if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
|
|
565
587
|
}
|
|
566
588
|
}
|
|
@@ -763,11 +785,11 @@ const patchChildSlotNodes = (elm) => {
|
|
|
763
785
|
} });
|
|
764
786
|
patchHostOriginalAccessor("firstChild", elm);
|
|
765
787
|
Object.defineProperty(elm, "firstChild", { get() {
|
|
766
|
-
return this.childNodes[0];
|
|
788
|
+
return this.childNodes[0] || null;
|
|
767
789
|
} });
|
|
768
790
|
patchHostOriginalAccessor("lastChild", elm);
|
|
769
791
|
Object.defineProperty(elm, "lastChild", { get() {
|
|
770
|
-
return this.childNodes[this.childNodes.length - 1];
|
|
792
|
+
return this.childNodes[this.childNodes.length - 1] || null;
|
|
771
793
|
} });
|
|
772
794
|
patchHostOriginalAccessor("childNodes", elm);
|
|
773
795
|
Object.defineProperty(elm, "childNodes", { get() {
|
|
@@ -813,7 +835,7 @@ const patchNextSibling = (node) => {
|
|
|
813
835
|
Object.defineProperty(node, "nextSibling", { get: function() {
|
|
814
836
|
const parentNodes = this["s-ol"]?.parentNode.childNodes;
|
|
815
837
|
const index = parentNodes?.indexOf(this);
|
|
816
|
-
if (parentNodes && index > -1) return parentNodes[index + 1];
|
|
838
|
+
if (parentNodes && index > -1) return parentNodes[index + 1] || null;
|
|
817
839
|
return this.__nextSibling;
|
|
818
840
|
} });
|
|
819
841
|
};
|
|
@@ -828,7 +850,7 @@ const patchNextElementSibling = (element) => {
|
|
|
828
850
|
Object.defineProperty(element, "nextElementSibling", { get: function() {
|
|
829
851
|
const parentEles = this["s-ol"]?.parentNode.children;
|
|
830
852
|
const index = parentEles?.indexOf(this);
|
|
831
|
-
if (parentEles && index > -1) return parentEles[index + 1];
|
|
853
|
+
if (parentEles && index > -1) return parentEles[index + 1] || null;
|
|
832
854
|
return this.__nextElementSibling;
|
|
833
855
|
} });
|
|
834
856
|
};
|
|
@@ -843,7 +865,7 @@ const patchPreviousSibling = (node) => {
|
|
|
843
865
|
Object.defineProperty(node, "previousSibling", { get: function() {
|
|
844
866
|
const parentNodes = this["s-ol"]?.parentNode.childNodes;
|
|
845
867
|
const index = parentNodes?.indexOf(this);
|
|
846
|
-
if (parentNodes && index > -1) return parentNodes[index - 1];
|
|
868
|
+
if (parentNodes && index > -1) return parentNodes[index - 1] || null;
|
|
847
869
|
return this.__previousSibling;
|
|
848
870
|
} });
|
|
849
871
|
};
|
|
@@ -858,7 +880,7 @@ const patchPreviousElementSibling = (element) => {
|
|
|
858
880
|
Object.defineProperty(element, "previousElementSibling", { get: function() {
|
|
859
881
|
const parentNodes = this["s-ol"]?.parentNode.children;
|
|
860
882
|
const index = parentNodes?.indexOf(this);
|
|
861
|
-
if (parentNodes && index > -1) return parentNodes[index - 1];
|
|
883
|
+
if (parentNodes && index > -1) return parentNodes[index - 1] || null;
|
|
862
884
|
return this.__previousElementSibling;
|
|
863
885
|
} });
|
|
864
886
|
};
|
|
@@ -1033,7 +1055,7 @@ function queryNonceMetaTagContent(doc) {
|
|
|
1033
1055
|
}
|
|
1034
1056
|
//#endregion
|
|
1035
1057
|
//#region src/runtime/styles.ts
|
|
1036
|
-
const rootAppliedStyles =
|
|
1058
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
1037
1059
|
/**
|
|
1038
1060
|
* Get or initialize the set of applied style scope IDs for a container element.
|
|
1039
1061
|
*
|
|
@@ -1123,37 +1145,41 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1123
1145
|
/**
|
|
1124
1146
|
* attach styles at the end of the head tag if we render scoped components
|
|
1125
1147
|
*/
|
|
1126
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation))
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1148
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
|
|
1149
|
+
if (styleContainerNode.nodeName === "HEAD") {
|
|
1150
|
+
/**
|
|
1151
|
+
* if the page contains preconnect links, we want to insert the styles
|
|
1152
|
+
* after the last preconnect link to ensure the styles are preloaded
|
|
1153
|
+
*/
|
|
1154
|
+
const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
|
|
1155
|
+
const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
|
|
1156
|
+
styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
|
|
1157
|
+
} else if ("host" in styleContainerNode) {
|
|
1158
|
+
/**
|
|
1159
|
+
* If a scoped component is used within a shadow root and constructable stylesheets are
|
|
1160
|
+
* not supported, we want to insert the styles at the beginning of the shadow root node.
|
|
1161
|
+
*
|
|
1162
|
+
* However, if there is already a style node in the shadow root, we just append
|
|
1163
|
+
* the styles to the existing node.
|
|
1164
|
+
*
|
|
1165
|
+
* Note: order of how styles are applied is important. The new style node
|
|
1166
|
+
* should be inserted before the existing style node.
|
|
1167
|
+
*
|
|
1168
|
+
* During HMR, create separate style elements for scoped components so they can be
|
|
1169
|
+
* updated independently without affecting other components' styles.
|
|
1170
|
+
*/
|
|
1171
|
+
const existingStyleContainer = styleContainerNode.querySelector("style");
|
|
1172
|
+
if (existingStyleContainer && !BUILD$1.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
|
|
1173
|
+
else styleContainerNode.prepend(styleElm);
|
|
1174
|
+
} else styleContainerNode.append(styleElm);
|
|
1175
|
+
}
|
|
1152
1176
|
/**
|
|
1153
1177
|
* attach styles at the beginning of a shadow root node if we render shadow components
|
|
1154
1178
|
*/
|
|
1155
|
-
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)
|
|
1156
|
-
|
|
1179
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
|
|
1180
|
+
if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
|
|
1181
|
+
else styleContainerNode.insertBefore(styleElm, null);
|
|
1182
|
+
}
|
|
1157
1183
|
if (appliedStyles) appliedStyles.add(scopeId);
|
|
1158
1184
|
}
|
|
1159
1185
|
} else if (BUILD$1.constructableCSS) {
|
|
@@ -1376,11 +1402,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1376
1402
|
}
|
|
1377
1403
|
} else if (BUILD$1.vdomStyle && memberName === "style") {
|
|
1378
1404
|
if (BUILD$1.updatable) {
|
|
1379
|
-
for (const prop in oldValue) if (!newValue || newValue[prop] == null)
|
|
1380
|
-
|
|
1405
|
+
for (const prop in oldValue) if (!newValue || newValue[prop] == null) {
|
|
1406
|
+
if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
|
|
1407
|
+
else elm.style[prop] = "";
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
1411
|
+
if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
|
|
1412
|
+
else elm.style[prop] = newValue[prop];
|
|
1381
1413
|
}
|
|
1382
|
-
for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
|
|
1383
|
-
else elm.style[prop] = newValue[prop];
|
|
1384
1414
|
} else if (BUILD$1.vdomKey && memberName === "key") {} else if (BUILD$1.vdomRef && memberName === "ref") {
|
|
1385
1415
|
if (newValue) queueRefAttachment(newValue, elm);
|
|
1386
1416
|
} else if (BUILD$1.vdomListener && (BUILD$1.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
|
|
@@ -1389,7 +1419,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1389
1419
|
else memberName = ln[2] + memberName.slice(3);
|
|
1390
1420
|
if (oldValue || newValue) {
|
|
1391
1421
|
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
1392
|
-
memberName = memberName.replace(
|
|
1422
|
+
memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
|
|
1393
1423
|
if (oldValue) plt.rel(elm, memberName, oldValue, capture);
|
|
1394
1424
|
if (newValue) plt.ael(elm, memberName, newValue, capture);
|
|
1395
1425
|
}
|
|
@@ -1428,8 +1458,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1428
1458
|
if (!elm.tagName.includes("-")) {
|
|
1429
1459
|
const n = newValue == null ? "" : newValue;
|
|
1430
1460
|
if (memberName === "list") isProp = false;
|
|
1431
|
-
else if (oldValue == null || elm[memberName] !== n)
|
|
1432
|
-
|
|
1461
|
+
else if (oldValue == null || elm[memberName] !== n) {
|
|
1462
|
+
if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
|
|
1463
|
+
else elm.setAttribute(memberName, n);
|
|
1464
|
+
}
|
|
1433
1465
|
} else if (elm[memberName] !== newValue) elm[memberName] = newValue;
|
|
1434
1466
|
} catch {}
|
|
1435
1467
|
/**
|
|
@@ -1447,8 +1479,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1447
1479
|
}
|
|
1448
1480
|
}
|
|
1449
1481
|
if (newValue == null || newValue === false) {
|
|
1450
|
-
if (newValue !== false || elm.getAttribute(memberName) === "")
|
|
1451
|
-
|
|
1482
|
+
if (newValue !== false || elm.getAttribute(memberName) === "") {
|
|
1483
|
+
if (BUILD$1.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
|
|
1484
|
+
else elm.removeAttribute(memberName);
|
|
1485
|
+
}
|
|
1452
1486
|
} else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
|
|
1453
1487
|
newValue = newValue === true ? "" : newValue;
|
|
1454
1488
|
if (BUILD$1.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -1579,6 +1613,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1579
1613
|
}
|
|
1580
1614
|
} else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
1581
1615
|
elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
1616
|
+
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
1582
1617
|
if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
1583
1618
|
} else {
|
|
1584
1619
|
if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
@@ -1854,8 +1889,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
1854
1889
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
1855
1890
|
newStartVnode = newCh[++newStartIdx];
|
|
1856
1891
|
}
|
|
1857
|
-
if (node)
|
|
1858
|
-
|
|
1892
|
+
if (node) {
|
|
1893
|
+
if (BUILD$1.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
|
|
1894
|
+
else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
|
|
1895
|
+
}
|
|
1859
1896
|
}
|
|
1860
1897
|
if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
1861
1898
|
else if (BUILD$1.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
@@ -1942,6 +1979,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
1942
1979
|
*/
|
|
1943
1980
|
const relocateNodes = [];
|
|
1944
1981
|
/**
|
|
1982
|
+
* When a forwarded `<slot>` gets relocated, drag along any content already forwarded through it,
|
|
1983
|
+
* to wherever it just landed (or nowhere, to be hidden, if it didn't match anything).
|
|
1984
|
+
*
|
|
1985
|
+
* Runs as its own pass after {@link markSlotContentForRelocation} rather than inside it, so that
|
|
1986
|
+
* function's matching order - which hydration's node/comment ordering depends on - is untouched.
|
|
1987
|
+
*/
|
|
1988
|
+
const carryContentWithRelocatedSlotRefs = () => {
|
|
1989
|
+
for (const relocateData of relocateNodes.slice()) {
|
|
1990
|
+
const marker = relocateData.$nodeToRelocate$;
|
|
1991
|
+
if (!marker["s-sr"]) continue;
|
|
1992
|
+
const carriedSiblings = getSlotChildSiblings(marker, marker["s-sn"] || "", false);
|
|
1993
|
+
for (const carriedSibling of carriedSiblings) {
|
|
1994
|
+
if (!carriedSibling["s-ol"]) continue;
|
|
1995
|
+
let siblingRelocateData = relocateNodes.find((r) => r.$nodeToRelocate$ === carriedSibling);
|
|
1996
|
+
if (!siblingRelocateData) {
|
|
1997
|
+
siblingRelocateData = { $nodeToRelocate$: carriedSibling };
|
|
1998
|
+
relocateNodes.push(siblingRelocateData);
|
|
1999
|
+
}
|
|
2000
|
+
siblingRelocateData.$slotRefNode$ = relocateData.$slotRefNode$;
|
|
2001
|
+
if (relocateData.$slotRefNode$) carriedSibling["s-sh"] = relocateData.$slotRefNode$["s-hn"];
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
/**
|
|
1945
2006
|
* Mark the contents of a slot for relocation via adding references to them to
|
|
1946
2007
|
* the {@link relocateNodes} data structure. The actual work of relocating them
|
|
1947
2008
|
* will then be handled in {@link renderVdom}.
|
|
@@ -2140,6 +2201,7 @@ render() {
|
|
|
2140
2201
|
plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
|
|
2141
2202
|
if (checkSlotRelocate) {
|
|
2142
2203
|
markSlotContentForRelocation(rootVnode.$elm$);
|
|
2204
|
+
carryContentWithRelocatedSlotRefs();
|
|
2143
2205
|
for (const relocateData of relocateNodes) {
|
|
2144
2206
|
const nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
2145
2207
|
if (!nodeToRelocate["s-ol"] && win.document) {
|
|
@@ -2199,7 +2261,7 @@ render() {
|
|
|
2199
2261
|
}
|
|
2200
2262
|
if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
|
|
2201
2263
|
const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
|
|
2202
|
-
for (const childNode of children) if (childNode["s-hn"] !== hostTagName &&
|
|
2264
|
+
for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
|
|
2203
2265
|
if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
|
|
2204
2266
|
if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
|
|
2205
2267
|
else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
|
|
@@ -2217,16 +2279,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
|
|
|
2217
2279
|
const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
|
|
2218
2280
|
//#endregion
|
|
2219
2281
|
//#region src/runtime/update-component.ts
|
|
2282
|
+
/**
|
|
2283
|
+
* Get a promise that resolves once `hostRef`'s real `connectedCallback` has fired for the first time.
|
|
2284
|
+
*
|
|
2285
|
+
* @param hostRef the component's host reference
|
|
2286
|
+
* @returns a promise that resolves once the component's real `connectedCallback` has fired
|
|
2287
|
+
*/
|
|
2288
|
+
const ensureFirstConnectPromise = (hostRef) => {
|
|
2289
|
+
if (!hostRef.$onFirstConnectPromise$) hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
|
|
2290
|
+
return hostRef.$onFirstConnectPromise$;
|
|
2291
|
+
};
|
|
2292
|
+
/**
|
|
2293
|
+
* Resolve `hostRef`'s first-connect promise and flag it connected. Called once this
|
|
2294
|
+
* component's real `connectedCallback` fires, plus from error/disconnect cleanup so a
|
|
2295
|
+
* component that never connects can't hang an ancestor or descendant forever.
|
|
2296
|
+
*
|
|
2297
|
+
* @param hostRef the component's host reference
|
|
2298
|
+
*/
|
|
2299
|
+
const markFirstConnected = (hostRef) => {
|
|
2300
|
+
hostRef.$flags$ |= HOST_FLAGS.hasFiredConnected;
|
|
2301
|
+
hostRef.$onFirstConnectResolve$?.();
|
|
2302
|
+
hostRef.$onFirstConnectResolve$ = void 0;
|
|
2303
|
+
};
|
|
2304
|
+
/**
|
|
2305
|
+
* Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
|
|
2306
|
+
* Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
|
|
2307
|
+
* `connectedCallback` paths so a component never connects before its nearest Stencil
|
|
2308
|
+
* ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
|
|
2309
|
+
* that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
|
|
2310
|
+
* so the `whenDefined` wait is a no-op there - it only does real work for standalone's
|
|
2311
|
+
* autoloader, where the ancestor tag may not be defined yet.
|
|
2312
|
+
*
|
|
2313
|
+
* @param ancestorElm the nearest Stencil ancestor element
|
|
2314
|
+
*/
|
|
2315
|
+
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2316
|
+
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2317
|
+
if (!BUILD$1.lazyLoad && !ancestorHostRef) {
|
|
2318
|
+
await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2319
|
+
ancestorHostRef = getHostRef(ancestorElm);
|
|
2320
|
+
}
|
|
2321
|
+
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
2322
|
+
};
|
|
2220
2323
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2221
2324
|
if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
2222
2325
|
const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
|
|
2223
2326
|
ancestorComponent["s-p"].splice(index - 1, 1);
|
|
2224
2327
|
r();
|
|
2225
2328
|
}));
|
|
2329
|
+
if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
|
|
2226
2330
|
}
|
|
2227
2331
|
};
|
|
2228
2332
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
2229
|
-
if (BUILD$1.
|
|
2333
|
+
if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
|
|
2230
2334
|
if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
|
|
2231
2335
|
hostRef.$flags$ |= HOST_FLAGS.needsRerender;
|
|
2232
2336
|
return;
|
|
@@ -2234,6 +2338,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2234
2338
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2235
2339
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2236
2340
|
if (isInitialLoad) {
|
|
2341
|
+
const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2342
|
+
if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
|
|
2237
2343
|
queueMicrotask(() => {
|
|
2238
2344
|
dispatch();
|
|
2239
2345
|
});
|
|
@@ -2273,10 +2379,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2273
2379
|
let maybePromise;
|
|
2274
2380
|
if (isInitialLoad) {
|
|
2275
2381
|
if (BUILD$1.lazyLoad) {
|
|
2276
|
-
if (BUILD$1.slotRelocation && hostRef.$deferredConnectedCallback$) {
|
|
2277
|
-
hostRef.$deferredConnectedCallback$ = false;
|
|
2278
|
-
safeCall(instance, "connectedCallback", void 0, elm);
|
|
2279
|
-
}
|
|
2280
2382
|
if (BUILD$1.hostListener) {
|
|
2281
2383
|
hostRef.$flags$ |= HOST_FLAGS.isListenReady;
|
|
2282
2384
|
if (hostRef.$queuedListeners$) {
|
|
@@ -2289,6 +2391,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2289
2391
|
if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
|
|
2290
2392
|
maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
|
|
2291
2393
|
} else {
|
|
2394
|
+
if (BUILD$1.updatable && hostRef.$queuedPropChanges$) {
|
|
2395
|
+
const changes = hostRef.$queuedPropChanges$;
|
|
2396
|
+
hostRef.$queuedPropChanges$ = void 0;
|
|
2397
|
+
if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
|
|
2398
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
|
|
2399
|
+
return;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2292
2402
|
if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
|
|
2293
2403
|
maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
|
|
2294
2404
|
}
|
|
@@ -2403,7 +2513,6 @@ let renderingRef = null;
|
|
|
2403
2513
|
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
2404
2514
|
const allRenderFn = !!BUILD$1.allRenderFn;
|
|
2405
2515
|
const lazyLoad = !!BUILD$1.lazyLoad;
|
|
2406
|
-
const taskQueue = !!BUILD$1.taskQueue;
|
|
2407
2516
|
const updatable = !!BUILD$1.updatable;
|
|
2408
2517
|
try {
|
|
2409
2518
|
renderingRef = instance;
|
|
@@ -2412,14 +2521,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
|
2412
2521
|
* method, so we can call the method immediately. If not, check before calling it.
|
|
2413
2522
|
*/
|
|
2414
2523
|
instance = allRenderFn ? instance.render() : instance.render && instance.render();
|
|
2415
|
-
if (updatable
|
|
2524
|
+
if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
|
|
2416
2525
|
if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
|
|
2417
|
-
if (BUILD$1.hasRenderFn || BUILD$1.reflect)
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2526
|
+
if (BUILD$1.hasRenderFn || BUILD$1.reflect) {
|
|
2527
|
+
if (BUILD$1.vdomRender || BUILD$1.reflect) {
|
|
2528
|
+
if (BUILD$1.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
|
|
2529
|
+
else renderVdom(hostRef, instance, isInitialLoad);
|
|
2530
|
+
} else {
|
|
2531
|
+
const shadowRoot = elm.shadowRoot;
|
|
2532
|
+
if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
|
|
2533
|
+
else elm.textContent = instance;
|
|
2534
|
+
}
|
|
2423
2535
|
}
|
|
2424
2536
|
} catch (e) {
|
|
2425
2537
|
consoleError(e, hostRef.$hostElement$);
|
|
@@ -2559,17 +2671,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2559
2671
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2560
2672
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
2561
2673
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
2562
|
-
const
|
|
2674
|
+
const initialVal = hostRef.$instanceValues$.get(memberName);
|
|
2675
|
+
const sig = signal(initialVal);
|
|
2563
2676
|
hostRef.$signalValues$.set(memberName, sig);
|
|
2564
2677
|
let prevScheduleVal = sig.peek();
|
|
2565
2678
|
disposers.push(effect(() => {
|
|
2566
2679
|
const newVal = sig.value;
|
|
2567
2680
|
if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
|
|
2568
2681
|
if (instance?.componentShouldUpdate) {
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2682
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
2683
|
+
changes[memberName] = {
|
|
2684
|
+
newVal,
|
|
2685
|
+
oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
|
|
2686
|
+
};
|
|
2573
2687
|
}
|
|
2574
2688
|
if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
2575
2689
|
}
|
|
@@ -2604,7 +2718,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2604
2718
|
consoleError(e, elm);
|
|
2605
2719
|
}
|
|
2606
2720
|
}));
|
|
2607
|
-
|
|
2721
|
+
const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
|
|
2722
|
+
elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
|
|
2608
2723
|
hostRef.$signalCleanup$ = () => {
|
|
2609
2724
|
disposers.forEach((d) => d());
|
|
2610
2725
|
elm[STENCIL_SIGNALS_SYMBOL] = void 0;
|
|
@@ -2653,17 +2768,23 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
2653
2768
|
for (let i = 0; i < c.length; i++) {
|
|
2654
2769
|
child = c[i];
|
|
2655
2770
|
if (Array.isArray(child)) walk(child);
|
|
2656
|
-
else if (child != null && typeof child !== "boolean")
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2771
|
+
else if (child != null && typeof child !== "boolean") {
|
|
2772
|
+
if (BUILD$1.vdomSignals && isSignalLike(child)) {
|
|
2773
|
+
const sigVNode = newVNode(null, String(child.peek()));
|
|
2774
|
+
sigVNode.$signal$ = child;
|
|
2775
|
+
vNodeChildren.push(sigVNode);
|
|
2776
|
+
lastSimple = false;
|
|
2777
|
+
} else {
|
|
2778
|
+
if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
|
|
2779
|
+
else if (typeof nodeName !== "function" && child.$flags$ === void 0) {
|
|
2780
|
+
if (BUILD$1.isDev);
|
|
2781
|
+
else consoleError("Invalid vNode child");
|
|
2782
|
+
continue;
|
|
2783
|
+
}
|
|
2784
|
+
if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
|
2785
|
+
else vNodeChildren.push(simple ? newVNode(null, child) : child);
|
|
2786
|
+
lastSimple = simple;
|
|
2787
|
+
}
|
|
2667
2788
|
}
|
|
2668
2789
|
}
|
|
2669
2790
|
};
|
|
@@ -3646,14 +3767,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
3646
3767
|
/**
|
|
3647
3768
|
* ensure this value is of the correct prop type
|
|
3648
3769
|
*/
|
|
3649
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3770
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
|
|
3771
|
+
/**
|
|
3772
|
+
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
3773
|
+
* (regardless of its value, even "false") should make the property true.
|
|
3774
|
+
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
3775
|
+
*/
|
|
3776
|
+
if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
3777
|
+
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
3778
|
+
}
|
|
3657
3779
|
/**
|
|
3658
3780
|
* force it to be a number
|
|
3659
3781
|
*/
|
|
@@ -3741,7 +3863,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
3741
3863
|
}
|
|
3742
3864
|
if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3743
3865
|
if (instance.componentShouldUpdate) {
|
|
3744
|
-
|
|
3866
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3867
|
+
changes[propName] = {
|
|
3868
|
+
newVal,
|
|
3869
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
3870
|
+
};
|
|
3745
3871
|
}
|
|
3746
3872
|
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3747
3873
|
}
|
|
@@ -3875,11 +4001,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3875
4001
|
};
|
|
3876
4002
|
for (const deserializer of cmpMeta.$deserializers$[propName]) {
|
|
3877
4003
|
const [[methodName]] = Object.entries(deserializer);
|
|
3878
|
-
if (BUILD$1.lazyLoad)
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
4004
|
+
if (BUILD$1.lazyLoad) {
|
|
4005
|
+
if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
|
|
4006
|
+
else hostRef.$fetchedCbList$.push(() => {
|
|
4007
|
+
setVal(methodName, hostRef.$lazyInstance$);
|
|
4008
|
+
});
|
|
4009
|
+
} else setVal(methodName, this);
|
|
3883
4010
|
}
|
|
3884
4011
|
return;
|
|
3885
4012
|
} else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
|
|
@@ -3903,7 +4030,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3903
4030
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
3904
4031
|
});
|
|
3905
4032
|
};
|
|
3906
|
-
Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
4033
|
+
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
3907
4034
|
const attrName = m[1] || propName;
|
|
3908
4035
|
attrNameToPropName.set(attrName, propName);
|
|
3909
4036
|
if (BUILD$1.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
|
|
@@ -3930,6 +4057,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
3930
4057
|
try {
|
|
3931
4058
|
if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
|
|
3932
4059
|
hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
|
|
4060
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
|
|
3933
4061
|
const bundleId = cmpMeta.$lazyBundleId$;
|
|
3934
4062
|
if (BUILD$1.lazyLoad && bundleId) {
|
|
3935
4063
|
const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
|
|
@@ -3938,7 +4066,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
3938
4066
|
Cstr = await CstrImport;
|
|
3939
4067
|
endLoad();
|
|
3940
4068
|
} else Cstr = CstrImport;
|
|
3941
|
-
if (!Cstr)
|
|
4069
|
+
if (!Cstr) {
|
|
4070
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
|
|
4071
|
+
hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
|
|
4072
|
+
if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
|
|
4073
|
+
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
4074
|
+
}
|
|
3942
4075
|
if (BUILD$1.member && !Cstr.isProxied) {
|
|
3943
4076
|
if (BUILD$1.propChangeCallback) {
|
|
3944
4077
|
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
@@ -3957,8 +4090,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
3957
4090
|
}
|
|
3958
4091
|
if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
3959
4092
|
endNewInstance();
|
|
3960
|
-
if (
|
|
3961
|
-
|
|
4093
|
+
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4094
|
+
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4095
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4096
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4097
|
+
} else queueMicrotask(() => {
|
|
4098
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4099
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4100
|
+
});
|
|
3962
4101
|
} else Cstr = elm.constructor;
|
|
3963
4102
|
if (BUILD$1.style && Cstr && Cstr.style) {
|
|
3964
4103
|
/**
|
|
@@ -4017,7 +4156,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4017
4156
|
hostRef.$onRenderResolve$();
|
|
4018
4157
|
hostRef.$onRenderResolve$ = void 0;
|
|
4019
4158
|
}
|
|
4020
|
-
if (BUILD$1.asyncLoading
|
|
4159
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4160
|
+
if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
|
|
4021
4161
|
}
|
|
4022
4162
|
};
|
|
4023
4163
|
const fireConnectedCallback = (instance, elm) => {
|
|
@@ -4080,6 +4220,7 @@ const connectedCallback = (elm) => {
|
|
|
4080
4220
|
} else {
|
|
4081
4221
|
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
4082
4222
|
if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4223
|
+
else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
|
|
4083
4224
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
|
|
4084
4225
|
}
|
|
4085
4226
|
endConnected();
|
|
@@ -4109,6 +4250,7 @@ const disconnectedCallback = async (elm) => {
|
|
|
4109
4250
|
hostRef.$signalCleanup$();
|
|
4110
4251
|
hostRef.$signalCleanup$ = void 0;
|
|
4111
4252
|
}
|
|
4253
|
+
if (BUILD$1.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
|
|
4112
4254
|
if (!BUILD$1.lazyLoad) disconnectInstance(elm);
|
|
4113
4255
|
else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
|
|
4114
4256
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
|
|
@@ -4234,18 +4376,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4234
4376
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4235
4377
|
};
|
|
4236
4378
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4237
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot)
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4379
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4380
|
+
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
4381
|
+
else {
|
|
4382
|
+
if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
|
|
4383
|
+
if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
|
|
4384
|
+
patchSlotAppendChild(Cstr.prototype);
|
|
4385
|
+
patchSlotAppend(Cstr.prototype);
|
|
4386
|
+
patchSlotPrepend(Cstr.prototype);
|
|
4387
|
+
patchSlotInsertAdjacentHTML(Cstr.prototype);
|
|
4388
|
+
patchInsertBefore(Cstr.prototype);
|
|
4389
|
+
patchSlotRemoveChild(Cstr.prototype);
|
|
4390
|
+
}
|
|
4391
|
+
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4247
4392
|
}
|
|
4248
|
-
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4249
4393
|
}
|
|
4250
4394
|
if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
|
|
4251
4395
|
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
@@ -4258,19 +4402,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4258
4402
|
componentOnReady() {
|
|
4259
4403
|
return getHostRef(this)?.$onReadyPromise$;
|
|
4260
4404
|
},
|
|
4261
|
-
connectedCallback() {
|
|
4262
|
-
|
|
4263
|
-
|
|
4405
|
+
async connectedCallback() {
|
|
4406
|
+
const isFirstConnect = !this.__hasHostListenerAttached;
|
|
4407
|
+
let hostRef;
|
|
4408
|
+
if (isFirstConnect) {
|
|
4409
|
+
hostRef = getHostRef(this);
|
|
4264
4410
|
if (!hostRef) return;
|
|
4265
4411
|
addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
|
|
4266
4412
|
this.__hasHostListenerAttached = true;
|
|
4267
4413
|
}
|
|
4268
4414
|
connectedCallback(this);
|
|
4269
|
-
if (
|
|
4415
|
+
if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4416
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4417
|
+
if (!this.isConnected) return;
|
|
4418
|
+
}
|
|
4419
|
+
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
4420
|
+
if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);
|
|
4270
4421
|
},
|
|
4271
4422
|
disconnectedCallback() {
|
|
4272
4423
|
disconnectedCallback(this);
|
|
4273
|
-
if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
|
|
4424
|
+
if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
|
|
4274
4425
|
},
|
|
4275
4426
|
__attachShadow() {
|
|
4276
4427
|
const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
|
|
@@ -4324,8 +4475,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4324
4475
|
const exclude = options.exclude || [];
|
|
4325
4476
|
const _reg = options.registry ?? getRegistry();
|
|
4326
4477
|
const head = win.document.head;
|
|
4327
|
-
const metaCharset =
|
|
4328
|
-
const dataStyles =
|
|
4478
|
+
const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
|
|
4479
|
+
const dataStyles = /*@__PURE__*/ win.document.createElement("style");
|
|
4329
4480
|
const deferredConnectedCallbacks = [];
|
|
4330
4481
|
let appLoadFallback;
|
|
4331
4482
|
let isBootstrapping = true;
|
|
@@ -4393,8 +4544,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4393
4544
|
*
|
|
4394
4545
|
* Also remove the reference from `deferredConnectedCallbacks` array
|
|
4395
4546
|
* otherwise removed instances won't get garbage collected.
|
|
4547
|
+
*
|
|
4548
|
+
* Use `nextTick` (microtask) rather than `plt.raf` since
|
|
4549
|
+
* `requestAnimationFrame` callbacks do not fire while `document.hidden`
|
|
4396
4550
|
*/
|
|
4397
|
-
|
|
4551
|
+
nextTick(() => {
|
|
4398
4552
|
const hostRef = getHostRef(this);
|
|
4399
4553
|
if (!hostRef) return;
|
|
4400
4554
|
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
|
|
@@ -4407,18 +4561,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4407
4561
|
}
|
|
4408
4562
|
};
|
|
4409
4563
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
|
|
4410
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot)
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4564
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4565
|
+
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
|
|
4566
|
+
else {
|
|
4567
|
+
if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
|
|
4568
|
+
if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
|
|
4569
|
+
patchSlotAppendChild(HostElement.prototype);
|
|
4570
|
+
patchSlotAppend(HostElement.prototype);
|
|
4571
|
+
patchSlotPrepend(HostElement.prototype);
|
|
4572
|
+
patchSlotInsertAdjacentHTML(HostElement.prototype);
|
|
4573
|
+
patchInsertBefore(HostElement.prototype);
|
|
4574
|
+
patchSlotRemoveChild(HostElement.prototype);
|
|
4575
|
+
}
|
|
4576
|
+
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4420
4577
|
}
|
|
4421
|
-
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4422
4578
|
}
|
|
4423
4579
|
if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
4424
4580
|
if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
@@ -4464,9 +4620,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
|
|
|
4464
4620
|
};
|
|
4465
4621
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
4466
4622
|
try {
|
|
4467
|
-
if (BUILD$1.lazyLoad)
|
|
4468
|
-
|
|
4469
|
-
|
|
4623
|
+
if (BUILD$1.lazyLoad) {
|
|
4624
|
+
if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
|
|
4625
|
+
else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
4626
|
+
} else hostRef.$hostElement$[methodName](ev);
|
|
4470
4627
|
} catch (e) {
|
|
4471
4628
|
consoleError(e, hostRef.$hostElement$);
|
|
4472
4629
|
}
|
|
@@ -4686,7 +4843,8 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
|
|
|
4686
4843
|
const nodeName = parentNode?.nodeName;
|
|
4687
4844
|
if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
|
|
4688
4845
|
const textNodeId = `t.${childId}`;
|
|
4689
|
-
|
|
4846
|
+
const commentBeforeTextNode = doc.createComment(textNodeId);
|
|
4847
|
+
insertBefore(parentNode, commentBeforeTextNode, childElm);
|
|
4690
4848
|
}
|
|
4691
4849
|
} else if (childElm.nodeType === NODE_TYPE.CommentNode) {
|
|
4692
4850
|
if (childElm["s-sr"]) childElm.nodeValue = `s.${childId}.${childElm["s-sn"] || ""}`;
|
|
@@ -4721,22 +4879,19 @@ function proxyHostElement(elm, cstr) {
|
|
|
4721
4879
|
const propValue = elm[memberName];
|
|
4722
4880
|
let attrPropVal;
|
|
4723
4881
|
const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
|
|
4724
|
-
if (attrValue != null)
|
|
4725
|
-
|
|
4726
|
-
|
|
4882
|
+
if (attrValue != null) {
|
|
4883
|
+
if (cmpMeta.$deserializers$?.[memberName]) for (const deserializer of cmpMeta.$deserializers$[memberName]) {
|
|
4884
|
+
const [[methodName]] = Object.entries(deserializer);
|
|
4885
|
+
attrPropVal = cstr.prototype[methodName](attrValue, memberName);
|
|
4886
|
+
}
|
|
4887
|
+
else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
|
|
4727
4888
|
}
|
|
4728
|
-
else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
|
|
4729
4889
|
if (propValue !== void 0) {
|
|
4730
4890
|
attrPropVal = propValue;
|
|
4731
4891
|
delete elm[memberName];
|
|
4732
4892
|
}
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
origSetter.apply(elm, [attrPropVal]);
|
|
4736
|
-
attrPropVal = origGetter ? origGetter.apply(elm) : attrPropVal;
|
|
4737
|
-
}
|
|
4738
|
-
hostRef?.$instanceValues$?.set(memberName, attrPropVal);
|
|
4739
|
-
}
|
|
4893
|
+
const userSetter = !cstr.isProxied ? origSetter : void 0;
|
|
4894
|
+
if (attrPropVal !== void 0 && !userSetter) hostRef?.$instanceValues$?.set(memberName, attrPropVal);
|
|
4740
4895
|
const getterSetterDescriptor = {
|
|
4741
4896
|
get: function() {
|
|
4742
4897
|
return getValue(this, memberName);
|
|
@@ -4750,8 +4905,26 @@ function proxyHostElement(elm, cstr) {
|
|
|
4750
4905
|
Object.defineProperty(elm, memberName, getterSetterDescriptor);
|
|
4751
4906
|
Object.defineProperty(elm, metaAttributeName, getterSetterDescriptor);
|
|
4752
4907
|
hostRef.$fetchedCbList$.push(() => {
|
|
4753
|
-
if (
|
|
4754
|
-
|
|
4908
|
+
if (userSetter && attrPropVal !== void 0) {
|
|
4909
|
+
userSetter.apply(hostRef.$lazyInstance$, [attrPropVal]);
|
|
4910
|
+
const processedValue = origGetter ? origGetter.apply(hostRef.$lazyInstance$) : attrPropVal;
|
|
4911
|
+
setValue(elm, memberName, processedValue, cmpMeta);
|
|
4912
|
+
} else if (!hostRef?.$instanceValues$?.has(memberName)) setValue(elm, memberName, attrPropVal !== void 0 ? attrPropVal : hostRef.$lazyInstance$[memberName], cmpMeta);
|
|
4913
|
+
if (userSetter) Object.defineProperty(hostRef.$lazyInstance$, memberName, {
|
|
4914
|
+
get: origGetter ? function() {
|
|
4915
|
+
return origGetter.call(this);
|
|
4916
|
+
} : function() {
|
|
4917
|
+
return getValue(this, memberName);
|
|
4918
|
+
},
|
|
4919
|
+
set: function(newValue) {
|
|
4920
|
+
userSetter.call(this, newValue);
|
|
4921
|
+
newValue = origGetter ? origGetter.call(this) : newValue;
|
|
4922
|
+
setValue(elm, memberName, newValue, cmpMeta);
|
|
4923
|
+
},
|
|
4924
|
+
configurable: true,
|
|
4925
|
+
enumerable: true
|
|
4926
|
+
});
|
|
4927
|
+
else Object.defineProperty(hostRef.$lazyInstance$, memberName, getterSetterDescriptor);
|
|
4755
4928
|
});
|
|
4756
4929
|
} else if (memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(elm, memberName, { value(...args) {
|
|
4757
4930
|
const ref = getHostRef(this);
|
|
@@ -4931,7 +5104,7 @@ function shouldHydrate(elm) {
|
|
|
4931
5104
|
if (parentNode == null) return true;
|
|
4932
5105
|
return shouldHydrate(parentNode);
|
|
4933
5106
|
}
|
|
4934
|
-
const NO_HYDRATE_TAGS = new Set([
|
|
5107
|
+
const NO_HYDRATE_TAGS = /* @__PURE__ */ new Set([
|
|
4935
5108
|
"CODE",
|
|
4936
5109
|
"HEAD",
|
|
4937
5110
|
"IFRAME",
|
|
@@ -4960,9 +5133,11 @@ function renderCatchError(opts, results, err) {
|
|
|
4960
5133
|
const u = new URL(opts.url);
|
|
4961
5134
|
if (u.pathname !== "/") diagnostic.header += ": " + u.pathname;
|
|
4962
5135
|
} catch {}
|
|
4963
|
-
if (err != null)
|
|
4964
|
-
|
|
4965
|
-
|
|
5136
|
+
if (err != null) {
|
|
5137
|
+
if (err.stack != null) diagnostic.messageText = err.stack.toString();
|
|
5138
|
+
else if (err.message != null) diagnostic.messageText = err.message.toString();
|
|
5139
|
+
else diagnostic.messageText = err.toString();
|
|
5140
|
+
}
|
|
4966
5141
|
results.diagnostics.push(diagnostic);
|
|
4967
5142
|
}
|
|
4968
5143
|
function printTag(elm) {
|
|
@@ -5073,7 +5248,7 @@ const writeTask = (cb) => {
|
|
|
5073
5248
|
}
|
|
5074
5249
|
});
|
|
5075
5250
|
};
|
|
5076
|
-
const resolved =
|
|
5251
|
+
const resolved = /*@__PURE__*/ Promise.resolve();
|
|
5077
5252
|
const nextTick = (cb) => resolved.then(cb);
|
|
5078
5253
|
const defaultConsoleError = (e) => {
|
|
5079
5254
|
if (e != null) console.error(e.stack || e.message || e);
|