@stencil/core 5.0.0-alpha.9 → 5.0.0-beta.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.
- package/README.md +94 -0
- package/dist/app-data/index.d.ts +1 -1
- package/dist/app-data/index.js +4 -1
- package/dist/client-BRu0GtRn.mjs +2368 -0
- package/dist/compiler/index.d.mts +167 -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-C0qmPoKu.mjs → compiler-NrvbUOX1.mjs} +2754 -1259
- package/dist/declarations/stencil-ext-modules.d.ts +5 -5
- package/dist/declarations/stencil-public-compiler.d.ts +208 -66
- package/dist/declarations/stencil-public-docs.d.ts +9 -0
- package/dist/declarations/stencil-public-runtime.d.ts +91 -6
- package/dist/fragment-Di1hWOC8.mjs +4 -0
- package/dist/{regular-expression-CFVJOTUh.mjs → helpers-Cpp3qc3u.mjs} +31 -15
- package/dist/index-BOrz3rbJ.d.mts +100 -0
- package/dist/{index-xAkMgLX_.d.ts → index-DnISpqrd.d.ts} +149 -9
- package/dist/{index-vY35H18z.d.mts → index-RrQfiPWK.d.mts} +490 -845
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +91 -2
- package/dist/jsx-runtime.mjs +2 -1
- package/dist/{node--akYC-sG.mjs → node-75gQKkFz.mjs} +60 -58
- package/dist/{chunk-z9aeyW2b.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
- package/dist/runtime/client/lazy.js +481 -184
- package/dist/runtime/client/runtime.d.ts +149 -10
- package/dist/runtime/client/runtime.js +481 -184
- package/dist/runtime/index.d.ts +6 -4
- package/dist/runtime/index.js +480 -182
- package/dist/runtime/server/index.d.mts +80 -8
- package/dist/runtime/server/index.mjs +403 -177
- package/dist/runtime/server/runner.d.mts +3 -0
- package/dist/runtime/server/runner.mjs +320 -337
- package/dist/signals/index.d.ts +2 -0
- package/dist/signals/index.js +4 -1
- 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 +4716 -105
- package/dist/testing/index.mjs +7590 -794
- package/dist/util-IKfWWLJo.mjs +724 -0
- package/dist/validation-DAdGTrys.mjs +791 -0
- package/package.json +27 -27
- package/dist/client-aTQ7xHxx.mjs +0 -4678
- package/dist/index-BvkyxSY6.d.mts +0 -205
- package/dist/validation-ByxKj8bC.mjs +0 -1458
- /package/{LICENSE.md → LICENSE} +0 -0
|
@@ -138,8 +138,20 @@ const HOST_FLAGS = {
|
|
|
138
138
|
isWatchReady: 128,
|
|
139
139
|
isListenReady: 256,
|
|
140
140
|
needsRerender: 512,
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Set once this component's real (lazy-loaded) `connectedCallback` has fired for
|
|
143
|
+
* the first time. Lets a descendant skip creating/awaiting a connect-promise for
|
|
144
|
+
* an ancestor that's already connected. See {@link HostRef.$onFirstConnectResolve$}.
|
|
145
|
+
*/
|
|
146
|
+
hasFiredConnected: 1024,
|
|
147
|
+
/**
|
|
148
|
+
* Set when a lazy component's dynamic `import()` fails to resolve a
|
|
149
|
+
* constructor. Distinct from `hasInitializedComponent` being unset, which
|
|
150
|
+
* is true while an initialization attempt is merely queued/in-flight.
|
|
151
|
+
*/
|
|
152
|
+
hasFailedLoad: 2048,
|
|
153
|
+
devOnRender: 4096,
|
|
154
|
+
devOnDidLoad: 8192
|
|
143
155
|
};
|
|
144
156
|
const CF_scopedCssEncapsulation = 2;
|
|
145
157
|
/**
|
|
@@ -224,7 +236,17 @@ const CMP_FLAGS = {
|
|
|
224
236
|
* e.g. `encapsulation: { type: 'none', patches: ['all'] }`
|
|
225
237
|
* Equivalent to the global `experimentalSlotFixes` config option.
|
|
226
238
|
*/
|
|
227
|
-
patchAll: 32768
|
|
239
|
+
patchAll: 32768,
|
|
240
|
+
/**
|
|
241
|
+
* Determines if `clonable` is enabled for a component that uses the shadow DOM.
|
|
242
|
+
* e.g. `encapsulation: { type: 'shadow', clonable: true }` is set on the `@Component()` decorator
|
|
243
|
+
*/
|
|
244
|
+
shadowClonable: 65536,
|
|
245
|
+
/**
|
|
246
|
+
* Determines if `serializable` is enabled for a component that uses the shadow DOM.
|
|
247
|
+
* e.g. `encapsulation: { type: 'shadow', serializable: true }` is set on the `@Component()` decorator
|
|
248
|
+
*/
|
|
249
|
+
shadowSerializable: 1 << 17
|
|
228
250
|
};
|
|
229
251
|
/**
|
|
230
252
|
* Namespaces
|
|
@@ -371,8 +393,13 @@ const registerHost = (hostElement, cmpMeta) => {
|
|
|
371
393
|
if (BUILD$1.asyncLoading) {
|
|
372
394
|
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
|
|
373
395
|
hostElement["s-rp"] = hostRef.$onReadyPromise$;
|
|
396
|
+
if (!BUILD$1.lazyLoad) {
|
|
397
|
+
hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
|
|
398
|
+
hostElement["s-fc"] = hostRef.$onFirstConnectPromise$;
|
|
399
|
+
}
|
|
374
400
|
if (!hostElement["s-p"]) hostElement["s-p"] = [];
|
|
375
401
|
if (!hostElement["s-rc"]) hostElement["s-rc"] = [];
|
|
402
|
+
if (!hostElement["s-pc"]) hostElement["s-pc"] = [];
|
|
376
403
|
}
|
|
377
404
|
if (BUILD$1.lazyLoad) hostRef.$fetchedCbList$ = [];
|
|
378
405
|
const ref = hostRef;
|
|
@@ -392,7 +419,12 @@ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
|
|
|
392
419
|
const setErrorHandler = (handler) => customError = handler;
|
|
393
420
|
//#endregion
|
|
394
421
|
//#region src/client/client-load-module.ts
|
|
395
|
-
const cmpModules =
|
|
422
|
+
const cmpModules = /*@__PURE__*/ new Map();
|
|
423
|
+
/**
|
|
424
|
+
* Tracks how many times a dynamic `import()` for a given lazy bundle has failed.
|
|
425
|
+
* Used to cache bust the retry attempt in connected-callback.ts
|
|
426
|
+
*/
|
|
427
|
+
const failedLoadAttempts = /*@__PURE__*/ new Map();
|
|
396
428
|
/**
|
|
397
429
|
* We need to separate out this prefix so that Esbuild doesn't try to resolve
|
|
398
430
|
* the below, but instead retains a dynamic `import()` statement in the
|
|
@@ -423,13 +455,21 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
423
455
|
} else if (!bundleId) return;
|
|
424
456
|
const module = !BUILD$1.hotModuleReplacement ? cmpModules.get(bundleId) : false;
|
|
425
457
|
if (module) return module[exportName];
|
|
458
|
+
const retryCount = failedLoadAttempts.get(bundleId) ?? 0;
|
|
459
|
+
const cacheBustParams = [retryCount > 0 ? `s-retry=${retryCount}` : "", BUILD$1.hotModuleReplacement && hmrVersionId ? `s-hmr=${hmrVersionId}` : ""].filter(Boolean).join("&");
|
|
426
460
|
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
427
|
-
const entryFile = `${bundleId}.entry.js${
|
|
461
|
+
const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
|
|
428
462
|
const onLoad = (importedModule) => {
|
|
429
|
-
if (!BUILD$1.hotModuleReplacement)
|
|
463
|
+
if (!BUILD$1.hotModuleReplacement) {
|
|
464
|
+
failedLoadAttempts.delete(bundleId);
|
|
465
|
+
cmpModules.set(bundleId, importedModule);
|
|
466
|
+
}
|
|
430
467
|
return importedModule[exportName];
|
|
431
468
|
};
|
|
432
|
-
const onError = (e) =>
|
|
469
|
+
const onError = (e) => {
|
|
470
|
+
failedLoadAttempts.set(bundleId, retryCount + 1);
|
|
471
|
+
consoleError(e, hostRef.$hostElement$);
|
|
472
|
+
};
|
|
433
473
|
if (lazyLoadBasePath) return import(
|
|
434
474
|
/* @vite-ignore */
|
|
435
475
|
/* webpackInclude: /\.entry\.js$/ */
|
|
@@ -447,7 +487,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
447
487
|
};
|
|
448
488
|
//#endregion
|
|
449
489
|
//#region src/client/client-style.ts
|
|
450
|
-
const styles =
|
|
490
|
+
const styles = /*@__PURE__*/ new Map();
|
|
451
491
|
const modeResolutionChain = [];
|
|
452
492
|
const setScopedSsr = (_opts) => {};
|
|
453
493
|
const needsScopedSSR = () => false;
|
|
@@ -510,6 +550,10 @@ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
|
510
550
|
*/
|
|
511
551
|
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
512
552
|
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
553
|
+
/**
|
|
554
|
+
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
555
|
+
*/
|
|
556
|
+
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
513
557
|
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
514
558
|
"formAssociatedCallback",
|
|
515
559
|
"formResetCallback",
|
|
@@ -532,7 +576,7 @@ const plt = {
|
|
|
532
576
|
const setPlatformHelpers = (helpers) => {
|
|
533
577
|
Object.assign(plt, helpers);
|
|
534
578
|
};
|
|
535
|
-
const supportsListenerOptions =
|
|
579
|
+
const supportsListenerOptions = /*@__PURE__*/ (() => {
|
|
536
580
|
let supported = false;
|
|
537
581
|
try {
|
|
538
582
|
win.document?.addEventListener("e", null, Object.defineProperty({}, "passive", { get() {
|
|
@@ -542,14 +586,14 @@ const supportsListenerOptions = /* @__PURE__ */ (() => {
|
|
|
542
586
|
return supported;
|
|
543
587
|
})();
|
|
544
588
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
545
|
-
const supportsConstructableStylesheets = BUILD$1.constructableCSS ?
|
|
589
|
+
const supportsConstructableStylesheets = BUILD$1.constructableCSS ? /*@__PURE__*/ (() => {
|
|
546
590
|
try {
|
|
547
591
|
if (!win.document.adoptedStyleSheets) return false;
|
|
548
592
|
return typeof new CSSStyleSheet().replaceSync === "function";
|
|
549
593
|
} catch {}
|
|
550
594
|
return false;
|
|
551
595
|
})() : false;
|
|
552
|
-
const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ?
|
|
596
|
+
const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /*@__PURE__*/ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
|
|
553
597
|
//#endregion
|
|
554
598
|
//#region src/client/client-task-queue.ts
|
|
555
599
|
let queueCongestion = 0;
|
|
@@ -557,12 +601,13 @@ let queuePending = false;
|
|
|
557
601
|
const queueDomReads = [];
|
|
558
602
|
const queueDomWrites = [];
|
|
559
603
|
const queueDomWritesLow = [];
|
|
604
|
+
const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
|
|
560
605
|
const queueTask = (queue, write) => (cb) => {
|
|
561
606
|
queue.push(cb);
|
|
562
607
|
if (!queuePending) {
|
|
563
608
|
queuePending = true;
|
|
564
609
|
if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
|
|
565
|
-
else
|
|
610
|
+
else scheduleFlush();
|
|
566
611
|
}
|
|
567
612
|
};
|
|
568
613
|
const consume = (queue) => {
|
|
@@ -595,16 +640,16 @@ const flush = () => {
|
|
|
595
640
|
queueDomWritesLow.push(...queueDomWrites);
|
|
596
641
|
queueDomWrites.length = 0;
|
|
597
642
|
}
|
|
598
|
-
if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)
|
|
643
|
+
if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) scheduleFlush();
|
|
599
644
|
else queueCongestion = 0;
|
|
600
645
|
} else {
|
|
601
646
|
consume(queueDomWrites);
|
|
602
|
-
if (queuePending = queueDomReads.length > 0)
|
|
647
|
+
if (queuePending = queueDomReads.length > 0) scheduleFlush();
|
|
603
648
|
}
|
|
604
649
|
};
|
|
605
650
|
const nextTick = (cb) => promiseResolve().then(cb);
|
|
606
|
-
const readTask =
|
|
607
|
-
const writeTask =
|
|
651
|
+
const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
|
|
652
|
+
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
608
653
|
//#endregion
|
|
609
654
|
//#region src/runtime/asset-path.ts
|
|
610
655
|
const getAssetPath = (path) => {
|
|
@@ -641,12 +686,15 @@ function createShadowRoot(cmpMeta) {
|
|
|
641
686
|
if (BUILD$1.shadowSlotAssignmentManual) {
|
|
642
687
|
if (!!(cmpMeta.$flags$ & CMP_FLAGS.shadowSlotAssignmentManual)) opts.slotAssignment = "manual";
|
|
643
688
|
}
|
|
689
|
+
if (BUILD$1.shadowClonable) opts.clonable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowClonable);
|
|
690
|
+
if (BUILD$1.shadowSerializable) opts.serializable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowSerializable);
|
|
644
691
|
const shadowRoot = this.attachShadow(opts);
|
|
645
692
|
if (BUILD$1.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
|
|
646
693
|
if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported(globalStyles) ?? null;
|
|
647
|
-
if (globalStyleSheet)
|
|
648
|
-
|
|
649
|
-
|
|
694
|
+
if (globalStyleSheet) {
|
|
695
|
+
if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
|
|
696
|
+
else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
|
|
697
|
+
} else if (globalStyles && !supportsConstructableStylesheets) {
|
|
650
698
|
const styleElm = document.createElement("style");
|
|
651
699
|
styleElm.innerHTML = globalStyles;
|
|
652
700
|
if (BUILD$1.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, GLOBAL_STYLE_ID);
|
|
@@ -671,8 +719,10 @@ function createShadowRoot(cmpMeta) {
|
|
|
671
719
|
const updateFallbackSlotVisibility = (elm) => {
|
|
672
720
|
const childNodes = internalCall(elm, "childNodes");
|
|
673
721
|
if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
|
|
674
|
-
if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB")
|
|
675
|
-
|
|
722
|
+
if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") {
|
|
723
|
+
if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
|
|
724
|
+
else slotNode.hidden = false;
|
|
725
|
+
}
|
|
676
726
|
});
|
|
677
727
|
let i = 0;
|
|
678
728
|
for (i = 0; i < childNodes.length; i++) {
|
|
@@ -715,7 +765,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
|
715
765
|
slottedNodes.push(childNode);
|
|
716
766
|
if (typeof slotName !== "undefined") return slottedNodes;
|
|
717
767
|
}
|
|
718
|
-
slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode
|
|
768
|
+
slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
|
|
719
769
|
}
|
|
720
770
|
return slottedNodes;
|
|
721
771
|
}
|
|
@@ -746,7 +796,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
|
|
|
746
796
|
if (nodeToRelocate.getAttribute("slot") === slotName) return true;
|
|
747
797
|
return false;
|
|
748
798
|
}
|
|
749
|
-
if (nodeToRelocate["s-
|
|
799
|
+
if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
|
|
750
800
|
return slotName === "";
|
|
751
801
|
};
|
|
752
802
|
/**
|
|
@@ -795,8 +845,10 @@ function patchSlotNode(node) {
|
|
|
795
845
|
const assignedFactory = (elementsOnly) => function(opts) {
|
|
796
846
|
const toReturn = [];
|
|
797
847
|
const slotName = this["s-sn"];
|
|
798
|
-
if (opts?.flatten)
|
|
799
|
-
|
|
848
|
+
if (opts?.flatten) {
|
|
849
|
+
if (BUILD$1.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
|
|
850
|
+
else console.error("Flattening not supported for Stencil non-shadow slots");
|
|
851
|
+
}
|
|
800
852
|
const parent = this["s-cr"].parentElement;
|
|
801
853
|
(parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
|
|
802
854
|
if (slotName === getSlotName(n)) toReturn.push(n);
|
|
@@ -887,8 +939,10 @@ const patchCloneNode = (HostElementPrototype) => {
|
|
|
887
939
|
for (; i < childNodes.length; i++) {
|
|
888
940
|
slotted = childNodes[i]["s-nr"];
|
|
889
941
|
nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
|
|
890
|
-
if (slotted)
|
|
891
|
-
|
|
942
|
+
if (slotted) {
|
|
943
|
+
if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
|
|
944
|
+
else clonedNode.appendChild(slotted.cloneNode(true));
|
|
945
|
+
}
|
|
892
946
|
if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
|
|
893
947
|
}
|
|
894
948
|
}
|
|
@@ -1091,11 +1145,11 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1091
1145
|
} });
|
|
1092
1146
|
patchHostOriginalAccessor("firstChild", elm);
|
|
1093
1147
|
Object.defineProperty(elm, "firstChild", { get() {
|
|
1094
|
-
return this.childNodes[0];
|
|
1148
|
+
return this.childNodes[0] || null;
|
|
1095
1149
|
} });
|
|
1096
1150
|
patchHostOriginalAccessor("lastChild", elm);
|
|
1097
1151
|
Object.defineProperty(elm, "lastChild", { get() {
|
|
1098
|
-
return this.childNodes[this.childNodes.length - 1];
|
|
1152
|
+
return this.childNodes[this.childNodes.length - 1] || null;
|
|
1099
1153
|
} });
|
|
1100
1154
|
patchHostOriginalAccessor("childNodes", elm);
|
|
1101
1155
|
Object.defineProperty(elm, "childNodes", { get() {
|
|
@@ -1141,7 +1195,7 @@ const patchNextSibling = (node) => {
|
|
|
1141
1195
|
Object.defineProperty(node, "nextSibling", { get: function() {
|
|
1142
1196
|
const parentNodes = this["s-ol"]?.parentNode.childNodes;
|
|
1143
1197
|
const index = parentNodes?.indexOf(this);
|
|
1144
|
-
if (parentNodes && index > -1) return parentNodes[index + 1];
|
|
1198
|
+
if (parentNodes && index > -1) return parentNodes[index + 1] || null;
|
|
1145
1199
|
return this.__nextSibling;
|
|
1146
1200
|
} });
|
|
1147
1201
|
};
|
|
@@ -1156,7 +1210,7 @@ const patchNextElementSibling = (element) => {
|
|
|
1156
1210
|
Object.defineProperty(element, "nextElementSibling", { get: function() {
|
|
1157
1211
|
const parentEles = this["s-ol"]?.parentNode.children;
|
|
1158
1212
|
const index = parentEles?.indexOf(this);
|
|
1159
|
-
if (parentEles && index > -1) return parentEles[index + 1];
|
|
1213
|
+
if (parentEles && index > -1) return parentEles[index + 1] || null;
|
|
1160
1214
|
return this.__nextElementSibling;
|
|
1161
1215
|
} });
|
|
1162
1216
|
};
|
|
@@ -1171,7 +1225,7 @@ const patchPreviousSibling = (node) => {
|
|
|
1171
1225
|
Object.defineProperty(node, "previousSibling", { get: function() {
|
|
1172
1226
|
const parentNodes = this["s-ol"]?.parentNode.childNodes;
|
|
1173
1227
|
const index = parentNodes?.indexOf(this);
|
|
1174
|
-
if (parentNodes && index > -1) return parentNodes[index - 1];
|
|
1228
|
+
if (parentNodes && index > -1) return parentNodes[index - 1] || null;
|
|
1175
1229
|
return this.__previousSibling;
|
|
1176
1230
|
} });
|
|
1177
1231
|
};
|
|
@@ -1186,7 +1240,7 @@ const patchPreviousElementSibling = (element) => {
|
|
|
1186
1240
|
Object.defineProperty(element, "previousElementSibling", { get: function() {
|
|
1187
1241
|
const parentNodes = this["s-ol"]?.parentNode.children;
|
|
1188
1242
|
const index = parentNodes?.indexOf(this);
|
|
1189
|
-
if (parentNodes && index > -1) return parentNodes[index - 1];
|
|
1243
|
+
if (parentNodes && index > -1) return parentNodes[index - 1] || null;
|
|
1190
1244
|
return this.__previousElementSibling;
|
|
1191
1245
|
} });
|
|
1192
1246
|
};
|
|
@@ -1361,7 +1415,7 @@ function queryNonceMetaTagContent(doc) {
|
|
|
1361
1415
|
}
|
|
1362
1416
|
//#endregion
|
|
1363
1417
|
//#region src/runtime/styles.ts
|
|
1364
|
-
const rootAppliedStyles =
|
|
1418
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
1365
1419
|
/**
|
|
1366
1420
|
* Get or initialize the set of applied style scope IDs for a container element.
|
|
1367
1421
|
*
|
|
@@ -1385,9 +1439,10 @@ const getAppliedStyles = (container) => {
|
|
|
1385
1439
|
* @param prepend if true, add to beginning; if false, add to end
|
|
1386
1440
|
*/
|
|
1387
1441
|
const adoptStylesheet = (container, sheet, prepend = false) => {
|
|
1388
|
-
if (supportsMutableAdoptedStyleSheets)
|
|
1389
|
-
|
|
1390
|
-
|
|
1442
|
+
if (supportsMutableAdoptedStyleSheets) {
|
|
1443
|
+
if (prepend) container.adoptedStyleSheets.unshift(sheet);
|
|
1444
|
+
else container.adoptedStyleSheets.push(sheet);
|
|
1445
|
+
} else if (prepend) container.adoptedStyleSheets = [sheet, ...container.adoptedStyleSheets];
|
|
1391
1446
|
else container.adoptedStyleSheets = [...container.adoptedStyleSheets, sheet];
|
|
1392
1447
|
};
|
|
1393
1448
|
/**
|
|
@@ -1400,7 +1455,7 @@ const adoptStylesheet = (container, sheet, prepend = false) => {
|
|
|
1400
1455
|
* @returns a new CSSStyleSheet for the correct window
|
|
1401
1456
|
*/
|
|
1402
1457
|
const createStylesheetForWindow = (container, cssText) => {
|
|
1403
|
-
const sheet = new (container.defaultView ?? container.ownerDocument?.defaultView ?? win).CSSStyleSheet();
|
|
1458
|
+
const sheet = new (container.defaultView ?? (container.ownerDocument?.defaultView) ?? win).CSSStyleSheet();
|
|
1404
1459
|
sheet.replaceSync(cssText);
|
|
1405
1460
|
return sheet;
|
|
1406
1461
|
};
|
|
@@ -1471,41 +1526,46 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1471
1526
|
/**
|
|
1472
1527
|
* attach styles at the end of the head tag if we render scoped components
|
|
1473
1528
|
*/
|
|
1474
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation))
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1529
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
|
|
1530
|
+
if (styleContainerNode.nodeName === "HEAD") {
|
|
1531
|
+
/**
|
|
1532
|
+
* if the page contains preconnect links, we want to insert the styles
|
|
1533
|
+
* after the last preconnect link to ensure the styles are preloaded
|
|
1534
|
+
*/
|
|
1535
|
+
const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
|
|
1536
|
+
const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
|
|
1537
|
+
styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
|
|
1538
|
+
} else if ("host" in styleContainerNode) {
|
|
1539
|
+
if (supportsConstructableStylesheets) {
|
|
1540
|
+
const stylesheet = createStylesheetForWindow(styleContainerNode, style);
|
|
1541
|
+
adoptStylesheet(styleContainerNode, stylesheet, true);
|
|
1542
|
+
} else {
|
|
1543
|
+
/**
|
|
1544
|
+
* If a scoped component is used within a shadow root and constructable stylesheets are
|
|
1545
|
+
* not supported, we want to insert the styles at the beginning of the shadow root node.
|
|
1546
|
+
*
|
|
1547
|
+
* However, if there is already a style node in the shadow root, we just append
|
|
1548
|
+
* the styles to the existing node.
|
|
1549
|
+
*
|
|
1550
|
+
* Note: order of how styles are applied is important. The new style node
|
|
1551
|
+
* should be inserted before the existing style node.
|
|
1552
|
+
*
|
|
1553
|
+
* During HMR, create separate style elements for scoped components so they can be
|
|
1554
|
+
* updated independently without affecting other components' styles.
|
|
1555
|
+
*/
|
|
1556
|
+
const existingStyleContainer = styleContainerNode.querySelector("style");
|
|
1557
|
+
if (existingStyleContainer && !BUILD$1.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
|
|
1558
|
+
else styleContainerNode.prepend(styleElm);
|
|
1559
|
+
}
|
|
1560
|
+
} else styleContainerNode.append(styleElm);
|
|
1502
1561
|
}
|
|
1503
|
-
else styleContainerNode.append(styleElm);
|
|
1504
1562
|
/**
|
|
1505
1563
|
* attach styles at the beginning of a shadow root node if we render shadow components
|
|
1506
1564
|
*/
|
|
1507
|
-
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)
|
|
1508
|
-
|
|
1565
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
|
|
1566
|
+
if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
|
|
1567
|
+
else styleContainerNode.insertBefore(styleElm, null);
|
|
1568
|
+
}
|
|
1509
1569
|
if (appliedStyles) appliedStyles.add(scopeId);
|
|
1510
1570
|
}
|
|
1511
1571
|
} else if (BUILD$1.constructableCSS) {
|
|
@@ -1597,7 +1657,12 @@ const hydrateScopedToShadow = () => {
|
|
|
1597
1657
|
if (!win.document) return;
|
|
1598
1658
|
const styleElements = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1599
1659
|
let i = 0;
|
|
1600
|
-
for (; i < styleElements.length; i++)
|
|
1660
|
+
for (; i < styleElements.length; i++) {
|
|
1661
|
+
const scopeId = styleElements[i].getAttribute(HYDRATED_STYLE_ID);
|
|
1662
|
+
const existing = styles.get(scopeId);
|
|
1663
|
+
const allowCS = existing !== void 0 ? existing instanceof CSSStyleSheet : true;
|
|
1664
|
+
registerStyle(scopeId, convertScopedToShadow(styleElements[i].innerHTML), allowCS);
|
|
1665
|
+
}
|
|
1601
1666
|
};
|
|
1602
1667
|
//#endregion
|
|
1603
1668
|
//#region src/utils/helpers.ts
|
|
@@ -1729,11 +1794,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1729
1794
|
}
|
|
1730
1795
|
} else if (BUILD$1.vdomStyle && memberName === "style") {
|
|
1731
1796
|
if (BUILD$1.updatable) {
|
|
1732
|
-
for (const prop in oldValue) if (!newValue || newValue[prop] == null)
|
|
1733
|
-
|
|
1797
|
+
for (const prop in oldValue) if (!newValue || newValue[prop] == null) {
|
|
1798
|
+
if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
|
|
1799
|
+
else elm.style[prop] = "";
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
1803
|
+
if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
|
|
1804
|
+
else elm.style[prop] = newValue[prop];
|
|
1734
1805
|
}
|
|
1735
|
-
for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
|
|
1736
|
-
else elm.style[prop] = newValue[prop];
|
|
1737
1806
|
} else if (BUILD$1.vdomKey && memberName === "key") {} else if (BUILD$1.vdomRef && memberName === "ref") {
|
|
1738
1807
|
if (newValue) queueRefAttachment(newValue, elm);
|
|
1739
1808
|
} else if (BUILD$1.vdomListener && (BUILD$1.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
|
|
@@ -1742,11 +1811,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1742
1811
|
else memberName = ln[2] + memberName.slice(3);
|
|
1743
1812
|
if (oldValue || newValue) {
|
|
1744
1813
|
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
1745
|
-
memberName = memberName.replace(
|
|
1814
|
+
memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
|
|
1746
1815
|
if (oldValue) plt.rel(elm, memberName, oldValue, capture);
|
|
1747
1816
|
if (newValue) plt.ael(elm, memberName, newValue, capture);
|
|
1748
1817
|
}
|
|
1749
|
-
} else if (BUILD$1.
|
|
1818
|
+
} else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "a" && memberName.startsWith("attr:")) {
|
|
1750
1819
|
const propName = memberName.slice(5);
|
|
1751
1820
|
let attrName;
|
|
1752
1821
|
if (BUILD$1.member) {
|
|
@@ -1761,7 +1830,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1761
1830
|
if (newValue !== false || elm.getAttribute(attrName) === "") elm.removeAttribute(attrName);
|
|
1762
1831
|
} else elm.setAttribute(attrName, newValue === true ? "" : newValue);
|
|
1763
1832
|
return;
|
|
1764
|
-
} else if (BUILD$1.
|
|
1833
|
+
} else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "p" && memberName.startsWith("prop:")) {
|
|
1765
1834
|
const propName = memberName.slice(5);
|
|
1766
1835
|
try {
|
|
1767
1836
|
elm[propName] = newValue;
|
|
@@ -1781,8 +1850,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1781
1850
|
if (!elm.tagName.includes("-")) {
|
|
1782
1851
|
const n = newValue == null ? "" : newValue;
|
|
1783
1852
|
if (memberName === "list") isProp = false;
|
|
1784
|
-
else if (oldValue == null || elm[memberName] !== n)
|
|
1785
|
-
|
|
1853
|
+
else if (oldValue == null || elm[memberName] !== n) {
|
|
1854
|
+
if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
|
|
1855
|
+
else elm.setAttribute(memberName, n);
|
|
1856
|
+
}
|
|
1786
1857
|
} else if (elm[memberName] !== newValue) elm[memberName] = newValue;
|
|
1787
1858
|
} catch {}
|
|
1788
1859
|
/**
|
|
@@ -1800,8 +1871,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1800
1871
|
}
|
|
1801
1872
|
}
|
|
1802
1873
|
if (newValue == null || newValue === false) {
|
|
1803
|
-
if (newValue !== false || elm.getAttribute(memberName) === ""
|
|
1804
|
-
|
|
1874
|
+
if (newValue !== false || elm.getAttribute(memberName) === "" || flags & VNODE_FLAGS.isHost && !isEnumeratedAttribute(memberName)) {
|
|
1875
|
+
if (BUILD$1.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
|
|
1876
|
+
else elm.removeAttribute(memberName);
|
|
1877
|
+
}
|
|
1805
1878
|
} else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
|
|
1806
1879
|
newValue = newValue === true ? "" : newValue;
|
|
1807
1880
|
if (BUILD$1.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -1809,6 +1882,18 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1809
1882
|
}
|
|
1810
1883
|
}
|
|
1811
1884
|
};
|
|
1885
|
+
/**
|
|
1886
|
+
* Attribute names that are enumerated (tri-state true/false/unset) rather than
|
|
1887
|
+
* plain boolean-presence attributes. An explicit `"false"` string on one of
|
|
1888
|
+
* these is semantically different from the attribute being absent, so a
|
|
1889
|
+
* reflected `false` value must not clear a pre-existing literal value.
|
|
1890
|
+
*/
|
|
1891
|
+
const ENUMERATED_ATTRIBUTES = /*@__PURE__*/ new Set([
|
|
1892
|
+
"draggable",
|
|
1893
|
+
"contenteditable",
|
|
1894
|
+
"spellcheck"
|
|
1895
|
+
]);
|
|
1896
|
+
const isEnumeratedAttribute = (attrName) => ENUMERATED_ATTRIBUTES.has(attrName) || attrName.startsWith("aria-");
|
|
1812
1897
|
const parseClassListRegex = /\s/;
|
|
1813
1898
|
/**
|
|
1814
1899
|
* Parsed a string of classnames into an array
|
|
@@ -1932,6 +2017,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1932
2017
|
}
|
|
1933
2018
|
} else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
1934
2019
|
elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
2020
|
+
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
1935
2021
|
if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
1936
2022
|
} else {
|
|
1937
2023
|
if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
@@ -2207,8 +2293,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2207
2293
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2208
2294
|
newStartVnode = newCh[++newStartIdx];
|
|
2209
2295
|
}
|
|
2210
|
-
if (node)
|
|
2211
|
-
|
|
2296
|
+
if (node) {
|
|
2297
|
+
if (BUILD$1.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
|
|
2298
|
+
else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
|
|
2299
|
+
}
|
|
2212
2300
|
}
|
|
2213
2301
|
if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
2214
2302
|
else if (BUILD$1.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
@@ -2295,6 +2383,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2295
2383
|
*/
|
|
2296
2384
|
const relocateNodes = [];
|
|
2297
2385
|
/**
|
|
2386
|
+
* When a forwarded `<slot>` gets relocated, drag along any content already forwarded through it,
|
|
2387
|
+
* to wherever it just landed (or nowhere, to be hidden, if it didn't match anything).
|
|
2388
|
+
*
|
|
2389
|
+
* Runs as its own pass after {@link markSlotContentForRelocation} rather than inside it, so that
|
|
2390
|
+
* function's matching order - which hydration's node/comment ordering depends on - is untouched.
|
|
2391
|
+
*/
|
|
2392
|
+
const carryContentWithRelocatedSlotRefs = () => {
|
|
2393
|
+
for (const relocateData of relocateNodes.slice()) {
|
|
2394
|
+
const marker = relocateData.$nodeToRelocate$;
|
|
2395
|
+
if (!marker["s-sr"]) continue;
|
|
2396
|
+
const carriedSiblings = getSlotChildSiblings(marker, marker["s-sn"] || "", false);
|
|
2397
|
+
for (const carriedSibling of carriedSiblings) {
|
|
2398
|
+
if (!carriedSibling["s-ol"]) continue;
|
|
2399
|
+
let siblingRelocateData = relocateNodes.find((r) => r.$nodeToRelocate$ === carriedSibling);
|
|
2400
|
+
if (!siblingRelocateData) {
|
|
2401
|
+
siblingRelocateData = { $nodeToRelocate$: carriedSibling };
|
|
2402
|
+
relocateNodes.push(siblingRelocateData);
|
|
2403
|
+
}
|
|
2404
|
+
siblingRelocateData.$slotRefNode$ = relocateData.$slotRefNode$;
|
|
2405
|
+
if (relocateData.$slotRefNode$) carriedSibling["s-sh"] = relocateData.$slotRefNode$["s-hn"];
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
/**
|
|
2298
2410
|
* Mark the contents of a slot for relocation via adding references to them to
|
|
2299
2411
|
* the {@link relocateNodes} data structure. The actual work of relocating them
|
|
2300
2412
|
* will then be handled in {@link renderVdom}.
|
|
@@ -2399,7 +2511,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2399
2511
|
return newNode;
|
|
2400
2512
|
}
|
|
2401
2513
|
}
|
|
2402
|
-
if (parent
|
|
2514
|
+
if (BUILD$1.slotRelocation && parent?.__insertBefore) return parent.__insertBefore(newNode, reference);
|
|
2403
2515
|
else return parent?.insertBefore(newNode, reference);
|
|
2404
2516
|
};
|
|
2405
2517
|
/**
|
|
@@ -2493,6 +2605,7 @@ render() {
|
|
|
2493
2605
|
plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
|
|
2494
2606
|
if (checkSlotRelocate) {
|
|
2495
2607
|
markSlotContentForRelocation(rootVnode.$elm$);
|
|
2608
|
+
carryContentWithRelocatedSlotRefs();
|
|
2496
2609
|
for (const relocateData of relocateNodes) {
|
|
2497
2610
|
const nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
2498
2611
|
if (!nodeToRelocate["s-ol"] && win.document) {
|
|
@@ -2552,7 +2665,7 @@ render() {
|
|
|
2552
2665
|
}
|
|
2553
2666
|
if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
|
|
2554
2667
|
const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
|
|
2555
|
-
for (const childNode of children) if (childNode["s-hn"] !== hostTagName &&
|
|
2668
|
+
for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
|
|
2556
2669
|
if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
|
|
2557
2670
|
if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
|
|
2558
2671
|
else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
|
|
@@ -2570,16 +2683,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
|
|
|
2570
2683
|
const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
|
|
2571
2684
|
//#endregion
|
|
2572
2685
|
//#region src/runtime/update-component.ts
|
|
2686
|
+
/**
|
|
2687
|
+
* Get a promise that resolves once `hostRef`'s real `connectedCallback` has fired for the first time.
|
|
2688
|
+
*
|
|
2689
|
+
* @param hostRef the component's host reference
|
|
2690
|
+
* @returns a promise that resolves once the component's real `connectedCallback` has fired
|
|
2691
|
+
*/
|
|
2692
|
+
const ensureFirstConnectPromise = (hostRef) => {
|
|
2693
|
+
if (!hostRef.$onFirstConnectPromise$) hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
|
|
2694
|
+
return hostRef.$onFirstConnectPromise$;
|
|
2695
|
+
};
|
|
2696
|
+
/**
|
|
2697
|
+
* Resolve `hostRef`'s first-connect promise and flag it connected. Called once this
|
|
2698
|
+
* component's real `connectedCallback` fires, plus from error/disconnect cleanup so a
|
|
2699
|
+
* component that never connects can't hang an ancestor or descendant forever.
|
|
2700
|
+
*
|
|
2701
|
+
* @param hostRef the component's host reference
|
|
2702
|
+
*/
|
|
2703
|
+
const markFirstConnected = (hostRef) => {
|
|
2704
|
+
hostRef.$flags$ |= HOST_FLAGS.hasFiredConnected;
|
|
2705
|
+
hostRef.$onFirstConnectResolve$?.();
|
|
2706
|
+
hostRef.$onFirstConnectResolve$ = void 0;
|
|
2707
|
+
};
|
|
2708
|
+
/**
|
|
2709
|
+
* Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
|
|
2710
|
+
* Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
|
|
2711
|
+
* `connectedCallback` paths so a component never connects before its nearest Stencil
|
|
2712
|
+
* ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
|
|
2713
|
+
* that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
|
|
2714
|
+
* so the `whenDefined` wait is a no-op there - it only does real work for standalone's
|
|
2715
|
+
* autoloader, where the ancestor tag may not be defined yet.
|
|
2716
|
+
*
|
|
2717
|
+
* @param ancestorElm the nearest Stencil ancestor element
|
|
2718
|
+
*/
|
|
2719
|
+
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2720
|
+
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2721
|
+
if (!BUILD$1.lazyLoad && !ancestorHostRef) {
|
|
2722
|
+
await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2723
|
+
ancestorHostRef = getHostRef(ancestorElm);
|
|
2724
|
+
}
|
|
2725
|
+
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
2726
|
+
};
|
|
2573
2727
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2574
2728
|
if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
2575
2729
|
const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
|
|
2576
2730
|
ancestorComponent["s-p"].splice(index - 1, 1);
|
|
2577
2731
|
r();
|
|
2578
2732
|
}));
|
|
2733
|
+
if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
|
|
2579
2734
|
}
|
|
2580
2735
|
};
|
|
2581
2736
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
2582
|
-
if (BUILD$1.
|
|
2737
|
+
if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
|
|
2583
2738
|
if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
|
|
2584
2739
|
hostRef.$flags$ |= HOST_FLAGS.needsRerender;
|
|
2585
2740
|
return;
|
|
@@ -2587,6 +2742,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2587
2742
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2588
2743
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2589
2744
|
if (isInitialLoad) {
|
|
2745
|
+
const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2746
|
+
if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
|
|
2590
2747
|
queueMicrotask(() => {
|
|
2591
2748
|
dispatch();
|
|
2592
2749
|
});
|
|
@@ -2626,10 +2783,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2626
2783
|
let maybePromise;
|
|
2627
2784
|
if (isInitialLoad) {
|
|
2628
2785
|
if (BUILD$1.lazyLoad) {
|
|
2629
|
-
if (BUILD$1.slotRelocation && hostRef.$deferredConnectedCallback$) {
|
|
2630
|
-
hostRef.$deferredConnectedCallback$ = false;
|
|
2631
|
-
safeCall(instance, "connectedCallback", void 0, elm);
|
|
2632
|
-
}
|
|
2633
2786
|
if (BUILD$1.hostListener) {
|
|
2634
2787
|
hostRef.$flags$ |= HOST_FLAGS.isListenReady;
|
|
2635
2788
|
if (hostRef.$queuedListeners$) {
|
|
@@ -2642,6 +2795,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2642
2795
|
if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
|
|
2643
2796
|
maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
|
|
2644
2797
|
} else {
|
|
2798
|
+
if (BUILD$1.updatable && hostRef.$queuedPropChanges$) {
|
|
2799
|
+
const changes = hostRef.$queuedPropChanges$;
|
|
2800
|
+
hostRef.$queuedPropChanges$ = void 0;
|
|
2801
|
+
if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
|
|
2802
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2645
2806
|
if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
|
|
2646
2807
|
maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
|
|
2647
2808
|
}
|
|
@@ -2756,7 +2917,6 @@ let renderingRef = null;
|
|
|
2756
2917
|
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
2757
2918
|
const allRenderFn = !!BUILD$1.allRenderFn;
|
|
2758
2919
|
const lazyLoad = !!BUILD$1.lazyLoad;
|
|
2759
|
-
const taskQueue = !!BUILD$1.taskQueue;
|
|
2760
2920
|
const updatable = !!BUILD$1.updatable;
|
|
2761
2921
|
try {
|
|
2762
2922
|
renderingRef = instance;
|
|
@@ -2765,14 +2925,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
|
2765
2925
|
* method, so we can call the method immediately. If not, check before calling it.
|
|
2766
2926
|
*/
|
|
2767
2927
|
instance = allRenderFn ? instance.render() : instance.render && instance.render();
|
|
2768
|
-
if (updatable
|
|
2928
|
+
if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
|
|
2769
2929
|
if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
|
|
2770
|
-
if (BUILD$1.hasRenderFn || BUILD$1.reflect)
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2930
|
+
if (BUILD$1.hasRenderFn || BUILD$1.reflect) {
|
|
2931
|
+
if (BUILD$1.vdomRender || BUILD$1.reflect) {
|
|
2932
|
+
if (BUILD$1.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
|
|
2933
|
+
else renderVdom(hostRef, instance, isInitialLoad);
|
|
2934
|
+
} else {
|
|
2935
|
+
const shadowRoot = elm.shadowRoot;
|
|
2936
|
+
if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
|
|
2937
|
+
else elm.textContent = instance;
|
|
2938
|
+
}
|
|
2776
2939
|
}
|
|
2777
2940
|
} catch (e) {
|
|
2778
2941
|
consoleError(e, hostRef.$hostElement$);
|
|
@@ -2912,17 +3075,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2912
3075
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2913
3076
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
2914
3077
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
2915
|
-
const
|
|
3078
|
+
const initialVal = hostRef.$instanceValues$.get(memberName);
|
|
3079
|
+
const sig = signal(initialVal);
|
|
2916
3080
|
hostRef.$signalValues$.set(memberName, sig);
|
|
2917
3081
|
let prevScheduleVal = sig.peek();
|
|
2918
3082
|
disposers.push(effect(() => {
|
|
2919
3083
|
const newVal = sig.value;
|
|
2920
3084
|
if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
|
|
2921
3085
|
if (instance?.componentShouldUpdate) {
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
3086
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3087
|
+
changes[memberName] = {
|
|
3088
|
+
newVal,
|
|
3089
|
+
oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
|
|
3090
|
+
};
|
|
2926
3091
|
}
|
|
2927
3092
|
if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
2928
3093
|
}
|
|
@@ -2957,7 +3122,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2957
3122
|
consoleError(e, elm);
|
|
2958
3123
|
}
|
|
2959
3124
|
}));
|
|
2960
|
-
|
|
3125
|
+
const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
|
|
3126
|
+
elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
|
|
2961
3127
|
hostRef.$signalCleanup$ = () => {
|
|
2962
3128
|
disposers.forEach((d) => d());
|
|
2963
3129
|
elm[STENCIL_SIGNALS_SYMBOL] = void 0;
|
|
@@ -3006,24 +3172,30 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3006
3172
|
for (let i = 0; i < c.length; i++) {
|
|
3007
3173
|
child = c[i];
|
|
3008
3174
|
if (Array.isArray(child)) walk(child);
|
|
3009
|
-
else if (child != null && typeof child !== "boolean")
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3175
|
+
else if (child != null && typeof child !== "boolean") {
|
|
3176
|
+
if (BUILD$1.vdomSignals && isSignalLike(child)) {
|
|
3177
|
+
const sigVNode = newVNode(null, String(child.peek()));
|
|
3178
|
+
sigVNode.$signal$ = child;
|
|
3179
|
+
vNodeChildren.push(sigVNode);
|
|
3180
|
+
lastSimple = false;
|
|
3181
|
+
} else {
|
|
3182
|
+
if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
|
|
3183
|
+
else if (typeof nodeName !== "function" && child.$flags$ === void 0) {
|
|
3184
|
+
if (BUILD$1.isDev) consoleDevError(`vNode passed as children has unexpected type.
|
|
3185
|
+
Make sure it's using the correct h() function.
|
|
3186
|
+
Empty objects can also be the cause, look for JSX comments that became objects.`);
|
|
3187
|
+
else consoleError("Invalid vNode child");
|
|
3188
|
+
continue;
|
|
3189
|
+
}
|
|
3190
|
+
if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
|
3191
|
+
else vNodeChildren.push(simple ? newVNode(null, child) : child);
|
|
3192
|
+
lastSimple = simple;
|
|
3193
|
+
}
|
|
3022
3194
|
}
|
|
3023
3195
|
}
|
|
3024
3196
|
};
|
|
3025
3197
|
walk(children);
|
|
3026
|
-
if (vnodeData) {
|
|
3198
|
+
if (vnodeData && typeof vnodeData === "object") {
|
|
3027
3199
|
if (BUILD$1.isDev && nodeName === "input") validateInputProperties(vnodeData);
|
|
3028
3200
|
if (BUILD$1.vdomKey && vnodeData.key) key = vnodeData.key;
|
|
3029
3201
|
if (BUILD$1.slotRelocation && vnodeData.name) slotName = vnodeData.name;
|
|
@@ -3124,7 +3296,7 @@ const convertToPrivate = (node) => {
|
|
|
3124
3296
|
/**
|
|
3125
3297
|
* Validates the ordering of attributes on an input element
|
|
3126
3298
|
*
|
|
3127
|
-
* @param inputElm the element to validate
|
|
3299
|
+
* @param inputElm the vnode data (JSX props) for the element to validate
|
|
3128
3300
|
*/
|
|
3129
3301
|
const validateInputProperties = (inputElm) => {
|
|
3130
3302
|
const props = Object.keys(inputElm);
|
|
@@ -4003,14 +4175,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
4003
4175
|
/**
|
|
4004
4176
|
* ensure this value is of the correct prop type
|
|
4005
4177
|
*/
|
|
4006
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4178
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
|
|
4179
|
+
/**
|
|
4180
|
+
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4181
|
+
* (regardless of its value, even "false") should make the property true.
|
|
4182
|
+
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4183
|
+
*/
|
|
4184
|
+
if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4185
|
+
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4186
|
+
}
|
|
4014
4187
|
/**
|
|
4015
4188
|
* force it to be a number
|
|
4016
4189
|
*/
|
|
@@ -4098,7 +4271,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4098
4271
|
}
|
|
4099
4272
|
if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4100
4273
|
if (instance.componentShouldUpdate) {
|
|
4101
|
-
|
|
4274
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4275
|
+
changes[propName] = {
|
|
4276
|
+
newVal,
|
|
4277
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4278
|
+
};
|
|
4102
4279
|
}
|
|
4103
4280
|
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4104
4281
|
}
|
|
@@ -4232,11 +4409,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4232
4409
|
};
|
|
4233
4410
|
for (const deserializer of cmpMeta.$deserializers$[propName]) {
|
|
4234
4411
|
const [[methodName]] = Object.entries(deserializer);
|
|
4235
|
-
if (BUILD$1.lazyLoad)
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4412
|
+
if (BUILD$1.lazyLoad) {
|
|
4413
|
+
if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
|
|
4414
|
+
else hostRef.$fetchedCbList$.push(() => {
|
|
4415
|
+
setVal(methodName, hostRef.$lazyInstance$);
|
|
4416
|
+
});
|
|
4417
|
+
} else setVal(methodName, this);
|
|
4240
4418
|
}
|
|
4241
4419
|
return;
|
|
4242
4420
|
} else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
|
|
@@ -4260,7 +4438,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4260
4438
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4261
4439
|
});
|
|
4262
4440
|
};
|
|
4263
|
-
Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
4441
|
+
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
4264
4442
|
const attrName = m[1] || propName;
|
|
4265
4443
|
attrNameToPropName.set(attrName, propName);
|
|
4266
4444
|
if (BUILD$1.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
|
|
@@ -4287,6 +4465,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4287
4465
|
try {
|
|
4288
4466
|
if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
|
|
4289
4467
|
hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
|
|
4468
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
|
|
4290
4469
|
const bundleId = cmpMeta.$lazyBundleId$;
|
|
4291
4470
|
if (BUILD$1.lazyLoad && bundleId) {
|
|
4292
4471
|
const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
|
|
@@ -4295,7 +4474,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4295
4474
|
Cstr = await CstrImport;
|
|
4296
4475
|
endLoad();
|
|
4297
4476
|
} else Cstr = CstrImport;
|
|
4298
|
-
if (!Cstr)
|
|
4477
|
+
if (!Cstr) {
|
|
4478
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
|
|
4479
|
+
hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
|
|
4480
|
+
if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
|
|
4481
|
+
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
4482
|
+
}
|
|
4299
4483
|
if (BUILD$1.member && !Cstr.isProxied) {
|
|
4300
4484
|
if (BUILD$1.propChangeCallback) {
|
|
4301
4485
|
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
@@ -4314,8 +4498,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4314
4498
|
}
|
|
4315
4499
|
if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4316
4500
|
endNewInstance();
|
|
4317
|
-
if (
|
|
4318
|
-
|
|
4501
|
+
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4502
|
+
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4503
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4504
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4505
|
+
} else queueMicrotask(() => {
|
|
4506
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4507
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4508
|
+
});
|
|
4319
4509
|
} else Cstr = elm.constructor;
|
|
4320
4510
|
if (BUILD$1.style && Cstr && Cstr.style) {
|
|
4321
4511
|
/**
|
|
@@ -4374,7 +4564,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4374
4564
|
hostRef.$onRenderResolve$();
|
|
4375
4565
|
hostRef.$onRenderResolve$ = void 0;
|
|
4376
4566
|
}
|
|
4377
|
-
if (BUILD$1.asyncLoading
|
|
4567
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4568
|
+
if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
|
|
4378
4569
|
}
|
|
4379
4570
|
};
|
|
4380
4571
|
const fireConnectedCallback = (instance, elm) => {
|
|
@@ -4437,6 +4628,7 @@ const connectedCallback = (elm) => {
|
|
|
4437
4628
|
} else {
|
|
4438
4629
|
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
4439
4630
|
if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4631
|
+
else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
|
|
4440
4632
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
|
|
4441
4633
|
}
|
|
4442
4634
|
endConnected();
|
|
@@ -4466,6 +4658,7 @@ const disconnectedCallback = async (elm) => {
|
|
|
4466
4658
|
hostRef.$signalCleanup$();
|
|
4467
4659
|
hostRef.$signalCleanup$ = void 0;
|
|
4468
4660
|
}
|
|
4661
|
+
if (BUILD$1.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
|
|
4469
4662
|
if (!BUILD$1.lazyLoad) disconnectInstance(elm);
|
|
4470
4663
|
else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
|
|
4471
4664
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
|
|
@@ -4513,7 +4706,6 @@ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4513
4706
|
};
|
|
4514
4707
|
const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
4515
4708
|
const modulePath = hostElement.constructor.__stencil_module__;
|
|
4516
|
-
console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
|
|
4517
4709
|
if (!modulePath) {
|
|
4518
4710
|
console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor - was this built with devMode?`);
|
|
4519
4711
|
return;
|
|
@@ -4526,18 +4718,39 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4526
4718
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4527
4719
|
if (!NewClass) return;
|
|
4528
4720
|
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4529
|
-
if (ctor)
|
|
4530
|
-
|
|
4531
|
-
|
|
4721
|
+
if (ctor) {
|
|
4722
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4723
|
+
if (key === "constructor") continue;
|
|
4724
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4725
|
+
}
|
|
4726
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4727
|
+
if (styleDesc) {
|
|
4728
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4729
|
+
const newStyle = NewClass.style;
|
|
4730
|
+
if (newStyle) {
|
|
4731
|
+
const scopeId = getScopeId(cmpMeta);
|
|
4732
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4733
|
+
console.log("[stencil-hmr] registerStyle", {
|
|
4734
|
+
tag: cmpMeta.$tagName$,
|
|
4735
|
+
scopeId,
|
|
4736
|
+
isShadow,
|
|
4737
|
+
cssLen: newStyle.length
|
|
4738
|
+
});
|
|
4739
|
+
registerStyle(scopeId, newStyle, isShadow);
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4532
4742
|
}
|
|
4743
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4533
4744
|
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4745
|
+
const hostRef = getHostRef(el);
|
|
4746
|
+
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4747
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4748
|
+
hostRef.$rmListeners$ = void 0;
|
|
4749
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4750
|
+
}
|
|
4751
|
+
if (!isShadow && hostRef) {
|
|
4752
|
+
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4753
|
+
attachStyles(hostRef);
|
|
4541
4754
|
}
|
|
4542
4755
|
forceUpdate(el);
|
|
4543
4756
|
});
|
|
@@ -4548,7 +4761,9 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4548
4761
|
//#endregion
|
|
4549
4762
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4550
4763
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
4551
|
-
|
|
4764
|
+
const tag = transformTag(compactMeta[1]);
|
|
4765
|
+
const proxied = proxyCustomElement(Cstr, compactMeta);
|
|
4766
|
+
if (!customElements.get(tag)) customElements.define(tag, proxied);
|
|
4552
4767
|
};
|
|
4553
4768
|
const proxyCustomElement = (Cstr, compactMeta) => {
|
|
4554
4769
|
if (BUILD$1.profile && performance.mark && performance.getEntriesByName("st:app:start", "mark").length === 0) performance.mark("st:app:start");
|
|
@@ -4569,18 +4784,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4569
4784
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4570
4785
|
};
|
|
4571
4786
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4572
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot)
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4787
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4788
|
+
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
4789
|
+
else {
|
|
4790
|
+
if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
|
|
4791
|
+
if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
|
|
4792
|
+
patchSlotAppendChild(Cstr.prototype);
|
|
4793
|
+
patchSlotAppend(Cstr.prototype);
|
|
4794
|
+
patchSlotPrepend(Cstr.prototype);
|
|
4795
|
+
patchSlotInsertAdjacentHTML(Cstr.prototype);
|
|
4796
|
+
patchInsertBefore(Cstr.prototype);
|
|
4797
|
+
patchSlotRemoveChild(Cstr.prototype);
|
|
4798
|
+
}
|
|
4799
|
+
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4582
4800
|
}
|
|
4583
|
-
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4584
4801
|
}
|
|
4585
4802
|
if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
|
|
4586
4803
|
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
@@ -4593,19 +4810,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4593
4810
|
componentOnReady() {
|
|
4594
4811
|
return getHostRef(this)?.$onReadyPromise$;
|
|
4595
4812
|
},
|
|
4596
|
-
connectedCallback() {
|
|
4597
|
-
|
|
4598
|
-
|
|
4813
|
+
async connectedCallback() {
|
|
4814
|
+
const isFirstConnect = !this.__hasHostListenerAttached;
|
|
4815
|
+
let hostRef;
|
|
4816
|
+
if (isFirstConnect) {
|
|
4817
|
+
hostRef = getHostRef(this);
|
|
4599
4818
|
if (!hostRef) return;
|
|
4600
4819
|
addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
|
|
4601
4820
|
this.__hasHostListenerAttached = true;
|
|
4602
4821
|
}
|
|
4603
4822
|
connectedCallback(this);
|
|
4604
|
-
if (
|
|
4823
|
+
if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4824
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4825
|
+
if (!this.isConnected) return;
|
|
4826
|
+
}
|
|
4827
|
+
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
4828
|
+
if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);
|
|
4605
4829
|
},
|
|
4606
4830
|
disconnectedCallback() {
|
|
4607
4831
|
disconnectedCallback(this);
|
|
4608
|
-
if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
|
|
4832
|
+
if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
|
|
4609
4833
|
},
|
|
4610
4834
|
__attachShadow() {
|
|
4611
4835
|
const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
|
|
@@ -4659,8 +4883,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4659
4883
|
const exclude = options.exclude || [];
|
|
4660
4884
|
const _reg = options.registry ?? getRegistry();
|
|
4661
4885
|
const head = win.document.head;
|
|
4662
|
-
const metaCharset =
|
|
4663
|
-
const dataStyles =
|
|
4886
|
+
const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
|
|
4887
|
+
const dataStyles = /*@__PURE__*/ win.document.createElement("style");
|
|
4664
4888
|
const deferredConnectedCallbacks = [];
|
|
4665
4889
|
let appLoadFallback;
|
|
4666
4890
|
let isBootstrapping = true;
|
|
@@ -4728,8 +4952,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4728
4952
|
*
|
|
4729
4953
|
* Also remove the reference from `deferredConnectedCallbacks` array
|
|
4730
4954
|
* otherwise removed instances won't get garbage collected.
|
|
4955
|
+
*
|
|
4956
|
+
* Use `nextTick` (microtask) rather than `plt.raf` since
|
|
4957
|
+
* `requestAnimationFrame` callbacks do not fire while `document.hidden`
|
|
4731
4958
|
*/
|
|
4732
|
-
|
|
4959
|
+
nextTick(() => {
|
|
4733
4960
|
const hostRef = getHostRef(this);
|
|
4734
4961
|
if (!hostRef) return;
|
|
4735
4962
|
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
|
|
@@ -4742,18 +4969,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4742
4969
|
}
|
|
4743
4970
|
};
|
|
4744
4971
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
|
|
4745
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot)
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4972
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4973
|
+
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
|
|
4974
|
+
else {
|
|
4975
|
+
if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
|
|
4976
|
+
if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
|
|
4977
|
+
patchSlotAppendChild(HostElement.prototype);
|
|
4978
|
+
patchSlotAppend(HostElement.prototype);
|
|
4979
|
+
patchSlotPrepend(HostElement.prototype);
|
|
4980
|
+
patchSlotInsertAdjacentHTML(HostElement.prototype);
|
|
4981
|
+
patchInsertBefore(HostElement.prototype);
|
|
4982
|
+
patchSlotRemoveChild(HostElement.prototype);
|
|
4983
|
+
}
|
|
4984
|
+
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4755
4985
|
}
|
|
4756
|
-
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4757
4986
|
}
|
|
4758
4987
|
if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
4759
4988
|
if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
@@ -4799,9 +5028,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
|
|
|
4799
5028
|
};
|
|
4800
5029
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
4801
5030
|
try {
|
|
4802
|
-
if (BUILD$1.lazyLoad)
|
|
4803
|
-
|
|
4804
|
-
|
|
5031
|
+
if (BUILD$1.lazyLoad) {
|
|
5032
|
+
if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
|
|
5033
|
+
else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
5034
|
+
} else hostRef.$hostElement$[methodName](ev);
|
|
4805
5035
|
} catch (e) {
|
|
4806
5036
|
consoleError(e, hostRef.$hostElement$);
|
|
4807
5037
|
}
|
|
@@ -4835,6 +5065,73 @@ const setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
|
4835
5065
|
//#region src/runtime/platform-options.ts
|
|
4836
5066
|
const setPlatformOptions = (opts) => Object.assign(plt, opts);
|
|
4837
5067
|
//#endregion
|
|
5068
|
+
//#region src/runtime/reactive-controller.ts
|
|
5069
|
+
const ReactiveControllerHost = (Base) => class ReactiveControllerHostMixin extends Base {
|
|
5070
|
+
controllers = /* @__PURE__ */ new Set();
|
|
5071
|
+
#connected = false;
|
|
5072
|
+
#updateCompleteResolvers = [];
|
|
5073
|
+
addController(controller) {
|
|
5074
|
+
this.controllers.add(controller);
|
|
5075
|
+
if (this.#connected) controller.hostConnected?.();
|
|
5076
|
+
}
|
|
5077
|
+
removeController(controller) {
|
|
5078
|
+
this.controllers.delete(controller);
|
|
5079
|
+
}
|
|
5080
|
+
requestUpdate() {
|
|
5081
|
+
forceUpdate(this);
|
|
5082
|
+
}
|
|
5083
|
+
get updateComplete() {
|
|
5084
|
+
return new Promise((resolve) => this.#updateCompleteResolvers.push(resolve));
|
|
5085
|
+
}
|
|
5086
|
+
connectedCallback() {
|
|
5087
|
+
super.connectedCallback?.();
|
|
5088
|
+
this.#connected = true;
|
|
5089
|
+
const el = getElement(this);
|
|
5090
|
+
if (el && el !== this) {
|
|
5091
|
+
el.addController = (controller) => this.addController(controller);
|
|
5092
|
+
el.removeController = (controller) => this.removeController(controller);
|
|
5093
|
+
el.requestUpdate = () => this.requestUpdate();
|
|
5094
|
+
Object.defineProperty(el, "updateComplete", {
|
|
5095
|
+
configurable: true,
|
|
5096
|
+
get: () => this.updateComplete
|
|
5097
|
+
});
|
|
5098
|
+
}
|
|
5099
|
+
this.controllers.forEach((c) => c.hostConnected?.());
|
|
5100
|
+
}
|
|
5101
|
+
disconnectedCallback() {
|
|
5102
|
+
super.disconnectedCallback?.();
|
|
5103
|
+
this.#connected = false;
|
|
5104
|
+
this.controllers.forEach((c) => c.hostDisconnected?.());
|
|
5105
|
+
}
|
|
5106
|
+
async componentWillLoad() {
|
|
5107
|
+
await super.componentWillLoad?.();
|
|
5108
|
+
await Promise.all([...this.controllers].map((c) => c.hostWillLoad?.()));
|
|
5109
|
+
}
|
|
5110
|
+
componentDidLoad() {
|
|
5111
|
+
super.componentDidLoad?.();
|
|
5112
|
+
this.controllers.forEach((c) => c.hostDidLoad?.());
|
|
5113
|
+
}
|
|
5114
|
+
async componentWillRender() {
|
|
5115
|
+
await super.componentWillRender?.();
|
|
5116
|
+
await Promise.all([...this.controllers].map((c) => c.hostWillRender?.()));
|
|
5117
|
+
}
|
|
5118
|
+
componentDidRender() {
|
|
5119
|
+
super.componentDidRender?.();
|
|
5120
|
+
this.controllers.forEach((c) => c.hostDidRender?.());
|
|
5121
|
+
const resolvers = this.#updateCompleteResolvers;
|
|
5122
|
+
this.#updateCompleteResolvers = [];
|
|
5123
|
+
resolvers.forEach((resolve) => resolve(true));
|
|
5124
|
+
}
|
|
5125
|
+
async componentWillUpdate() {
|
|
5126
|
+
await super.componentWillUpdate?.();
|
|
5127
|
+
await Promise.all([...this.controllers].map((c) => c.hostWillUpdate?.()));
|
|
5128
|
+
}
|
|
5129
|
+
componentDidUpdate() {
|
|
5130
|
+
super.componentDidUpdate?.();
|
|
5131
|
+
this.controllers.forEach((c) => c.hostDidUpdate?.());
|
|
5132
|
+
}
|
|
5133
|
+
};
|
|
5134
|
+
//#endregion
|
|
4838
5135
|
//#region src/runtime/render.ts
|
|
4839
5136
|
/**
|
|
4840
5137
|
* A WeakMap to persist HostRef objects across multiple render() calls to the
|
|
@@ -4921,4 +5218,4 @@ function hasKeys(obj) {
|
|
|
4921
5218
|
return false;
|
|
4922
5219
|
}
|
|
4923
5220
|
//#endregion
|
|
4924
|
-
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };
|
|
5221
|
+
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };
|