@stencil/core 5.0.0-alpha.9 → 5.0.0-beta.1
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/browser.d.ts +1534 -0
- package/dist/compiler/browser.js +16436 -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-CJG6qvQt.mjs} +2978 -1231
- package/dist/declarations/stencil-ext-modules.d.ts +5 -5
- package/dist/declarations/stencil-public-compiler.d.ts +226 -69
- package/dist/declarations/stencil-public-docs.d.ts +9 -0
- package/dist/declarations/stencil-public-runtime.d.ts +111 -10
- package/dist/fragment-Di1hWOC8.mjs +4 -0
- package/dist/{regular-expression-CFVJOTUh.mjs → helpers-Cpp3qc3u.mjs} +31 -15
- package/dist/{index-xAkMgLX_.d.ts → index-BXAcVN2j.d.ts} +152 -20
- package/dist/{index-vY35H18z.d.mts → index-BopBfjPu.d.mts} +508 -848
- package/dist/index-DmHmu3y0.d.mts +100 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +171 -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 +577 -189
- package/dist/runtime/client/runtime.d.ts +178 -21
- package/dist/runtime/client/runtime.js +577 -189
- package/dist/runtime/index.d.ts +32 -4
- package/dist/runtime/index.js +576 -187
- package/dist/runtime/server/index.d.mts +107 -9
- package/dist/runtime/server/index.mjs +499 -182
- 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 +4731 -105
- package/dist/testing/index.mjs +7563 -797
- package/dist/util-IKfWWLJo.mjs +724 -0
- package/dist/validation-DAdGTrys.mjs +791 -0
- package/package.json +31 -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];
|
|
426
|
-
|
|
427
|
-
const
|
|
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("&");
|
|
428
460
|
const onLoad = (importedModule) => {
|
|
429
|
-
if (!BUILD$1.hotModuleReplacement)
|
|
461
|
+
if (!BUILD$1.hotModuleReplacement) {
|
|
462
|
+
failedLoadAttempts.delete(bundleId);
|
|
463
|
+
cmpModules.set(bundleId, importedModule);
|
|
464
|
+
}
|
|
430
465
|
return importedModule[exportName];
|
|
431
466
|
};
|
|
432
|
-
const onError = (e) =>
|
|
467
|
+
const onError = (e) => {
|
|
468
|
+
failedLoadAttempts.set(bundleId, retryCount + 1);
|
|
469
|
+
consoleError(e, hostRef.$hostElement$);
|
|
470
|
+
};
|
|
471
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
472
|
+
const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
|
|
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);
|
|
@@ -3541,12 +3713,13 @@ const restoreSafeSelector = (placeholders, content) => {
|
|
|
3541
3713
|
const _polyfillHost = "-shadowcsshost";
|
|
3542
3714
|
const _polyfillSlotted = "-shadowcssslotted";
|
|
3543
3715
|
const _polyfillHostContext = "-shadowcsscontext";
|
|
3716
|
+
const _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
|
|
3544
3717
|
let _cssColonHostRe;
|
|
3545
3718
|
let _cssColonHostContextRe;
|
|
3546
3719
|
let _cssColonSlottedRe;
|
|
3547
|
-
const getCssColonHostRe = () => _cssColonHostRe ??=
|
|
3548
|
-
const getCssColonHostContextRe = () => _cssColonHostContextRe ??=
|
|
3549
|
-
const getCssColonSlottedRe = () => _cssColonSlottedRe ??=
|
|
3720
|
+
const getCssColonHostRe = () => _cssColonHostRe ??= new RegExp("(-shadowcsshost" + _parenSuffix, "gim");
|
|
3721
|
+
const getCssColonHostContextRe = () => _cssColonHostContextRe ??= new RegExp("(-shadowcsscontext" + _parenSuffix, "gim");
|
|
3722
|
+
const getCssColonSlottedRe = () => _cssColonSlottedRe ??= new RegExp("(-shadowcssslotted" + _parenSuffix, "gim");
|
|
3550
3723
|
const _polyfillHostNoCombinator = "-shadowcsshost-no-combinator";
|
|
3551
3724
|
const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
|
|
3552
3725
|
const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
|
|
@@ -4003,14 +4176,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
4003
4176
|
/**
|
|
4004
4177
|
* ensure this value is of the correct prop type
|
|
4005
4178
|
*/
|
|
4006
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4179
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
|
|
4180
|
+
/**
|
|
4181
|
+
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4182
|
+
* (regardless of its value, even "false") should make the property true.
|
|
4183
|
+
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4184
|
+
*/
|
|
4185
|
+
if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4186
|
+
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4187
|
+
}
|
|
4014
4188
|
/**
|
|
4015
4189
|
* force it to be a number
|
|
4016
4190
|
*/
|
|
@@ -4098,7 +4272,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4098
4272
|
}
|
|
4099
4273
|
if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4100
4274
|
if (instance.componentShouldUpdate) {
|
|
4101
|
-
|
|
4275
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4276
|
+
changes[propName] = {
|
|
4277
|
+
newVal,
|
|
4278
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4279
|
+
};
|
|
4102
4280
|
}
|
|
4103
4281
|
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4104
4282
|
}
|
|
@@ -4107,6 +4285,14 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4107
4285
|
//#endregion
|
|
4108
4286
|
//#region src/runtime/proxy-component.ts
|
|
4109
4287
|
/**
|
|
4288
|
+
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|
|
4289
|
+
* recognize an `attributeChangedCallback` it triggered itself.
|
|
4290
|
+
*
|
|
4291
|
+
* @param propValue the current value of a reflected prop
|
|
4292
|
+
* @returns the string the attribute would hold, or `null` if the attribute would be removed
|
|
4293
|
+
*/
|
|
4294
|
+
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4295
|
+
/**
|
|
4110
4296
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4111
4297
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4112
4298
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4232,11 +4418,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4232
4418
|
};
|
|
4233
4419
|
for (const deserializer of cmpMeta.$deserializers$[propName]) {
|
|
4234
4420
|
const [[methodName]] = Object.entries(deserializer);
|
|
4235
|
-
if (BUILD$1.lazyLoad)
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4421
|
+
if (BUILD$1.lazyLoad) {
|
|
4422
|
+
if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
|
|
4423
|
+
else hostRef.$fetchedCbList$.push(() => {
|
|
4424
|
+
setVal(methodName, hostRef.$lazyInstance$);
|
|
4425
|
+
});
|
|
4426
|
+
} else setVal(methodName, this);
|
|
4240
4427
|
}
|
|
4241
4428
|
return;
|
|
4242
4429
|
} else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
|
|
@@ -4253,14 +4440,16 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4253
4440
|
return;
|
|
4254
4441
|
}
|
|
4255
4442
|
const propFlags = members.find(([m]) => m === propName);
|
|
4256
|
-
const
|
|
4443
|
+
const propMemberFlags = propFlags ? propFlags[1][0] : 0;
|
|
4444
|
+
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4445
|
+
if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4257
4446
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4258
4447
|
if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
|
|
4259
4448
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4260
4449
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4261
4450
|
});
|
|
4262
4451
|
};
|
|
4263
|
-
Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
4452
|
+
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
4264
4453
|
const attrName = m[1] || propName;
|
|
4265
4454
|
attrNameToPropName.set(attrName, propName);
|
|
4266
4455
|
if (BUILD$1.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
|
|
@@ -4287,6 +4476,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4287
4476
|
try {
|
|
4288
4477
|
if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
|
|
4289
4478
|
hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
|
|
4479
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
|
|
4290
4480
|
const bundleId = cmpMeta.$lazyBundleId$;
|
|
4291
4481
|
if (BUILD$1.lazyLoad && bundleId) {
|
|
4292
4482
|
const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
|
|
@@ -4295,7 +4485,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4295
4485
|
Cstr = await CstrImport;
|
|
4296
4486
|
endLoad();
|
|
4297
4487
|
} else Cstr = CstrImport;
|
|
4298
|
-
if (!Cstr)
|
|
4488
|
+
if (!Cstr) {
|
|
4489
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
|
|
4490
|
+
hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
|
|
4491
|
+
if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
|
|
4492
|
+
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
4493
|
+
}
|
|
4299
4494
|
if (BUILD$1.member && !Cstr.isProxied) {
|
|
4300
4495
|
if (BUILD$1.propChangeCallback) {
|
|
4301
4496
|
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
@@ -4314,8 +4509,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4314
4509
|
}
|
|
4315
4510
|
if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4316
4511
|
endNewInstance();
|
|
4317
|
-
if (
|
|
4318
|
-
|
|
4512
|
+
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4513
|
+
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4514
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4515
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4516
|
+
} else queueMicrotask(() => {
|
|
4517
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4518
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4519
|
+
});
|
|
4319
4520
|
} else Cstr = elm.constructor;
|
|
4320
4521
|
if (BUILD$1.style && Cstr && Cstr.style) {
|
|
4321
4522
|
/**
|
|
@@ -4374,7 +4575,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4374
4575
|
hostRef.$onRenderResolve$();
|
|
4375
4576
|
hostRef.$onRenderResolve$ = void 0;
|
|
4376
4577
|
}
|
|
4377
|
-
if (BUILD$1.asyncLoading
|
|
4578
|
+
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
4579
|
+
if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
|
|
4378
4580
|
}
|
|
4379
4581
|
};
|
|
4380
4582
|
const fireConnectedCallback = (instance, elm) => {
|
|
@@ -4437,6 +4639,7 @@ const connectedCallback = (elm) => {
|
|
|
4437
4639
|
} else {
|
|
4438
4640
|
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
4439
4641
|
if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4642
|
+
else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
|
|
4440
4643
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
|
|
4441
4644
|
}
|
|
4442
4645
|
endConnected();
|
|
@@ -4466,6 +4669,7 @@ const disconnectedCallback = async (elm) => {
|
|
|
4466
4669
|
hostRef.$signalCleanup$();
|
|
4467
4670
|
hostRef.$signalCleanup$ = void 0;
|
|
4468
4671
|
}
|
|
4672
|
+
if (BUILD$1.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
|
|
4469
4673
|
if (!BUILD$1.lazyLoad) disconnectInstance(elm);
|
|
4470
4674
|
else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
|
|
4471
4675
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
|
|
@@ -4513,7 +4717,6 @@ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4513
4717
|
};
|
|
4514
4718
|
const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
4515
4719
|
const modulePath = hostElement.constructor.__stencil_module__;
|
|
4516
|
-
console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
|
|
4517
4720
|
if (!modulePath) {
|
|
4518
4721
|
console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor - was this built with devMode?`);
|
|
4519
4722
|
return;
|
|
@@ -4526,18 +4729,39 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4526
4729
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4527
4730
|
if (!NewClass) return;
|
|
4528
4731
|
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4529
|
-
if (ctor)
|
|
4530
|
-
|
|
4531
|
-
|
|
4732
|
+
if (ctor) {
|
|
4733
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4734
|
+
if (key === "constructor") continue;
|
|
4735
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4736
|
+
}
|
|
4737
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4738
|
+
if (styleDesc) {
|
|
4739
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4740
|
+
const newStyle = NewClass.style;
|
|
4741
|
+
if (newStyle) {
|
|
4742
|
+
const scopeId = getScopeId(cmpMeta);
|
|
4743
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4744
|
+
console.log("[stencil-hmr] registerStyle", {
|
|
4745
|
+
tag: cmpMeta.$tagName$,
|
|
4746
|
+
scopeId,
|
|
4747
|
+
isShadow,
|
|
4748
|
+
cssLen: newStyle.length
|
|
4749
|
+
});
|
|
4750
|
+
registerStyle(scopeId, newStyle, isShadow);
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4532
4753
|
}
|
|
4754
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4533
4755
|
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4756
|
+
const hostRef = getHostRef(el);
|
|
4757
|
+
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4758
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4759
|
+
hostRef.$rmListeners$ = void 0;
|
|
4760
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4761
|
+
}
|
|
4762
|
+
if (!isShadow && hostRef) {
|
|
4763
|
+
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4764
|
+
attachStyles(hostRef);
|
|
4541
4765
|
}
|
|
4542
4766
|
forceUpdate(el);
|
|
4543
4767
|
});
|
|
@@ -4548,7 +4772,9 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4548
4772
|
//#endregion
|
|
4549
4773
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4550
4774
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
4551
|
-
|
|
4775
|
+
const tag = transformTag(compactMeta[1]);
|
|
4776
|
+
const proxied = proxyCustomElement(Cstr, compactMeta);
|
|
4777
|
+
if (!customElements.get(tag)) customElements.define(tag, proxied);
|
|
4552
4778
|
};
|
|
4553
4779
|
const proxyCustomElement = (Cstr, compactMeta) => {
|
|
4554
4780
|
if (BUILD$1.profile && performance.mark && performance.getEntriesByName("st:app:start", "mark").length === 0) performance.mark("st:app:start");
|
|
@@ -4569,18 +4795,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4569
4795
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4570
4796
|
};
|
|
4571
4797
|
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
|
-
|
|
4798
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4799
|
+
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
4800
|
+
else {
|
|
4801
|
+
if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
|
|
4802
|
+
if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
|
|
4803
|
+
patchSlotAppendChild(Cstr.prototype);
|
|
4804
|
+
patchSlotAppend(Cstr.prototype);
|
|
4805
|
+
patchSlotPrepend(Cstr.prototype);
|
|
4806
|
+
patchSlotInsertAdjacentHTML(Cstr.prototype);
|
|
4807
|
+
patchInsertBefore(Cstr.prototype);
|
|
4808
|
+
patchSlotRemoveChild(Cstr.prototype);
|
|
4809
|
+
}
|
|
4810
|
+
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4582
4811
|
}
|
|
4583
|
-
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4584
4812
|
}
|
|
4585
4813
|
if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
|
|
4586
4814
|
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
@@ -4593,19 +4821,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4593
4821
|
componentOnReady() {
|
|
4594
4822
|
return getHostRef(this)?.$onReadyPromise$;
|
|
4595
4823
|
},
|
|
4596
|
-
connectedCallback() {
|
|
4597
|
-
|
|
4598
|
-
|
|
4824
|
+
async connectedCallback() {
|
|
4825
|
+
const isFirstConnect = !this.__hasHostListenerAttached;
|
|
4826
|
+
let hostRef;
|
|
4827
|
+
if (isFirstConnect) {
|
|
4828
|
+
hostRef = getHostRef(this);
|
|
4599
4829
|
if (!hostRef) return;
|
|
4600
4830
|
addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
|
|
4601
4831
|
this.__hasHostListenerAttached = true;
|
|
4602
4832
|
}
|
|
4603
4833
|
connectedCallback(this);
|
|
4604
|
-
if (
|
|
4834
|
+
if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4835
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4836
|
+
if (!this.isConnected) return;
|
|
4837
|
+
}
|
|
4838
|
+
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
4839
|
+
if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);
|
|
4605
4840
|
},
|
|
4606
4841
|
disconnectedCallback() {
|
|
4607
4842
|
disconnectedCallback(this);
|
|
4608
|
-
if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
|
|
4843
|
+
if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
|
|
4609
4844
|
},
|
|
4610
4845
|
__attachShadow() {
|
|
4611
4846
|
const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
|
|
@@ -4659,8 +4894,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4659
4894
|
const exclude = options.exclude || [];
|
|
4660
4895
|
const _reg = options.registry ?? getRegistry();
|
|
4661
4896
|
const head = win.document.head;
|
|
4662
|
-
const metaCharset =
|
|
4663
|
-
const dataStyles =
|
|
4897
|
+
const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
|
|
4898
|
+
const dataStyles = /*@__PURE__*/ win.document.createElement("style");
|
|
4664
4899
|
const deferredConnectedCallbacks = [];
|
|
4665
4900
|
let appLoadFallback;
|
|
4666
4901
|
let isBootstrapping = true;
|
|
@@ -4728,8 +4963,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4728
4963
|
*
|
|
4729
4964
|
* Also remove the reference from `deferredConnectedCallbacks` array
|
|
4730
4965
|
* otherwise removed instances won't get garbage collected.
|
|
4966
|
+
*
|
|
4967
|
+
* Use `nextTick` (microtask) rather than `plt.raf` since
|
|
4968
|
+
* `requestAnimationFrame` callbacks do not fire while `document.hidden`
|
|
4731
4969
|
*/
|
|
4732
|
-
|
|
4970
|
+
nextTick(() => {
|
|
4733
4971
|
const hostRef = getHostRef(this);
|
|
4734
4972
|
if (!hostRef) return;
|
|
4735
4973
|
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
|
|
@@ -4742,18 +4980,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4742
4980
|
}
|
|
4743
4981
|
};
|
|
4744
4982
|
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
|
-
|
|
4983
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4984
|
+
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
|
|
4985
|
+
else {
|
|
4986
|
+
if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
|
|
4987
|
+
if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
|
|
4988
|
+
patchSlotAppendChild(HostElement.prototype);
|
|
4989
|
+
patchSlotAppend(HostElement.prototype);
|
|
4990
|
+
patchSlotPrepend(HostElement.prototype);
|
|
4991
|
+
patchSlotInsertAdjacentHTML(HostElement.prototype);
|
|
4992
|
+
patchInsertBefore(HostElement.prototype);
|
|
4993
|
+
patchSlotRemoveChild(HostElement.prototype);
|
|
4994
|
+
}
|
|
4995
|
+
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4755
4996
|
}
|
|
4756
|
-
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4757
4997
|
}
|
|
4758
4998
|
if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
4759
4999
|
if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
@@ -4799,9 +5039,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
|
|
|
4799
5039
|
};
|
|
4800
5040
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
4801
5041
|
try {
|
|
4802
|
-
if (BUILD$1.lazyLoad)
|
|
4803
|
-
|
|
4804
|
-
|
|
5042
|
+
if (BUILD$1.lazyLoad) {
|
|
5043
|
+
if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
|
|
5044
|
+
else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
5045
|
+
} else hostRef.$hostElement$[methodName](ev);
|
|
4805
5046
|
} catch (e) {
|
|
4806
5047
|
consoleError(e, hostRef.$hostElement$);
|
|
4807
5048
|
}
|
|
@@ -4817,6 +5058,86 @@ const hostListenerOpts = (flags) => supportsListenerOptions ? {
|
|
|
4817
5058
|
capture: (flags & LISTENER_FLAGS.Capture) !== 0
|
|
4818
5059
|
} : (flags & LISTENER_FLAGS.Capture) !== 0;
|
|
4819
5060
|
//#endregion
|
|
5061
|
+
//#region src/runtime/inject-side-effect-style.ts
|
|
5062
|
+
const styleSheets = /* @__PURE__ */ new Map();
|
|
5063
|
+
const knownRoots = /* @__PURE__ */ new Set();
|
|
5064
|
+
const adoptedRoots = /* @__PURE__ */ new WeakMap();
|
|
5065
|
+
const knownFontFaces = /* @__PURE__ */ new Set();
|
|
5066
|
+
const adopt = (root, sheet) => {
|
|
5067
|
+
let roots = adoptedRoots.get(sheet);
|
|
5068
|
+
if (!roots) {
|
|
5069
|
+
roots = /* @__PURE__ */ new WeakSet();
|
|
5070
|
+
adoptedRoots.set(sheet, roots);
|
|
5071
|
+
}
|
|
5072
|
+
if (!roots.has(root)) {
|
|
5073
|
+
roots.add(root);
|
|
5074
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
5075
|
+
}
|
|
5076
|
+
};
|
|
5077
|
+
/**
|
|
5078
|
+
* Registers a root (a shadow root, or `document`) to receive every side-effect CSS import
|
|
5079
|
+
* (a plain, non-component `import './foo.css'`), now and in future. Call in `connectedCallback`,
|
|
5080
|
+
* paired with `unregisterSideEffectStyleTarget` in `disconnectedCallback` so the registry doesn't
|
|
5081
|
+
* hold disconnected roots forever.
|
|
5082
|
+
* @param root the root to register
|
|
5083
|
+
*/
|
|
5084
|
+
function registerSideEffectStyleTarget(root) {
|
|
5085
|
+
knownRoots.add(root);
|
|
5086
|
+
for (const sheet of styleSheets.values()) adopt(root, sheet);
|
|
5087
|
+
}
|
|
5088
|
+
/**
|
|
5089
|
+
* Removes a root registered via `registerSideEffectStyleTarget` - call in `disconnectedCallback`.
|
|
5090
|
+
* @param root the root to unregister
|
|
5091
|
+
*/
|
|
5092
|
+
function unregisterSideEffectStyleTarget(root) {
|
|
5093
|
+
knownRoots.delete(root);
|
|
5094
|
+
}
|
|
5095
|
+
const FONT_FACE_RE = /@font-face\s*\{[^{}]*\}/g;
|
|
5096
|
+
/**
|
|
5097
|
+
* Splits `@font-face` rules out of a CSS text - exported standalone (from private
|
|
5098
|
+
* module state - usually 3rd party node_modules) exported for testing
|
|
5099
|
+
* @param cssText the CSS text to split
|
|
5100
|
+
* @returns the font-face rules joined together (`null` if there were none) and the remaining CSS
|
|
5101
|
+
*/
|
|
5102
|
+
function splitFontFaces(cssText) {
|
|
5103
|
+
const fontFaces = cssText.match(FONT_FACE_RE);
|
|
5104
|
+
if (!fontFaces) return {
|
|
5105
|
+
fontFaceText: null,
|
|
5106
|
+
rest: cssText
|
|
5107
|
+
};
|
|
5108
|
+
return {
|
|
5109
|
+
fontFaceText: fontFaces.join("\n"),
|
|
5110
|
+
rest: cssText.replace(FONT_FACE_RE, "")
|
|
5111
|
+
};
|
|
5112
|
+
}
|
|
5113
|
+
/**
|
|
5114
|
+
* Applies plain (non-component) CSS text to every registered root - respects shadow DOM
|
|
5115
|
+
* encapsulation instead of always reaching for the top-level document. Not meant to be called
|
|
5116
|
+
* directly: this is what the compiler's CSS-to-ESM output calls for CSS with no Stencil `tag`
|
|
5117
|
+
* (i.e. not a component's own `styleUrl`), typically a third-party dependency's CSS import.
|
|
5118
|
+
*
|
|
5119
|
+
* `@font-face` rules are pulled out and adopted onto top-level `document` not per-root
|
|
5120
|
+
* (Chromium (https://issues.chromium.org/issues/41085401) per-root never loads).
|
|
5121
|
+
* @param cssText the CSS text to apply
|
|
5122
|
+
*/
|
|
5123
|
+
function injectSideEffectStyle(cssText) {
|
|
5124
|
+
const { fontFaceText, rest } = splitFontFaces(cssText);
|
|
5125
|
+
if (fontFaceText && !knownFontFaces.has(fontFaceText)) {
|
|
5126
|
+
knownFontFaces.add(fontFaceText);
|
|
5127
|
+
const fontFaceSheet = new CSSStyleSheet();
|
|
5128
|
+
fontFaceSheet.replaceSync(fontFaceText);
|
|
5129
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, fontFaceSheet];
|
|
5130
|
+
}
|
|
5131
|
+
if (!rest.trim()) return;
|
|
5132
|
+
let sheet = styleSheets.get(rest);
|
|
5133
|
+
if (!sheet) {
|
|
5134
|
+
sheet = new CSSStyleSheet();
|
|
5135
|
+
sheet.replaceSync(rest);
|
|
5136
|
+
styleSheets.set(rest, sheet);
|
|
5137
|
+
}
|
|
5138
|
+
for (const root of knownRoots) adopt(root, sheet);
|
|
5139
|
+
}
|
|
5140
|
+
//#endregion
|
|
4820
5141
|
//#region src/runtime/mixin.ts
|
|
4821
5142
|
const baseClass = BUILD$1.lazyLoad ? class {} : globalThis.HTMLElement || class {};
|
|
4822
5143
|
function Mixin(...mixins) {
|
|
@@ -4835,6 +5156,73 @@ const setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
|
4835
5156
|
//#region src/runtime/platform-options.ts
|
|
4836
5157
|
const setPlatformOptions = (opts) => Object.assign(plt, opts);
|
|
4837
5158
|
//#endregion
|
|
5159
|
+
//#region src/runtime/reactive-controller.ts
|
|
5160
|
+
const ReactiveControllerHost = (Base) => class ReactiveControllerHostMixin extends Base {
|
|
5161
|
+
controllers = /* @__PURE__ */ new Set();
|
|
5162
|
+
#connected = false;
|
|
5163
|
+
#updateCompleteResolvers = [];
|
|
5164
|
+
addController(controller) {
|
|
5165
|
+
this.controllers.add(controller);
|
|
5166
|
+
if (this.#connected) controller.hostConnected?.();
|
|
5167
|
+
}
|
|
5168
|
+
removeController(controller) {
|
|
5169
|
+
this.controllers.delete(controller);
|
|
5170
|
+
}
|
|
5171
|
+
requestUpdate() {
|
|
5172
|
+
forceUpdate(this);
|
|
5173
|
+
}
|
|
5174
|
+
get updateComplete() {
|
|
5175
|
+
return new Promise((resolve) => this.#updateCompleteResolvers.push(resolve));
|
|
5176
|
+
}
|
|
5177
|
+
connectedCallback() {
|
|
5178
|
+
super.connectedCallback?.();
|
|
5179
|
+
this.#connected = true;
|
|
5180
|
+
const el = getElement(this);
|
|
5181
|
+
if (el && el !== this) {
|
|
5182
|
+
el.addController = (controller) => this.addController(controller);
|
|
5183
|
+
el.removeController = (controller) => this.removeController(controller);
|
|
5184
|
+
el.requestUpdate = () => this.requestUpdate();
|
|
5185
|
+
Object.defineProperty(el, "updateComplete", {
|
|
5186
|
+
configurable: true,
|
|
5187
|
+
get: () => this.updateComplete
|
|
5188
|
+
});
|
|
5189
|
+
}
|
|
5190
|
+
this.controllers.forEach((c) => c.hostConnected?.());
|
|
5191
|
+
}
|
|
5192
|
+
disconnectedCallback() {
|
|
5193
|
+
super.disconnectedCallback?.();
|
|
5194
|
+
this.#connected = false;
|
|
5195
|
+
this.controllers.forEach((c) => c.hostDisconnected?.());
|
|
5196
|
+
}
|
|
5197
|
+
async componentWillLoad() {
|
|
5198
|
+
await super.componentWillLoad?.();
|
|
5199
|
+
await Promise.all([...this.controllers].map((c) => c.hostWillLoad?.()));
|
|
5200
|
+
}
|
|
5201
|
+
componentDidLoad() {
|
|
5202
|
+
super.componentDidLoad?.();
|
|
5203
|
+
this.controllers.forEach((c) => c.hostDidLoad?.());
|
|
5204
|
+
}
|
|
5205
|
+
async componentWillRender() {
|
|
5206
|
+
await super.componentWillRender?.();
|
|
5207
|
+
await Promise.all([...this.controllers].map((c) => c.hostWillRender?.()));
|
|
5208
|
+
}
|
|
5209
|
+
componentDidRender() {
|
|
5210
|
+
super.componentDidRender?.();
|
|
5211
|
+
this.controllers.forEach((c) => c.hostDidRender?.());
|
|
5212
|
+
const resolvers = this.#updateCompleteResolvers;
|
|
5213
|
+
this.#updateCompleteResolvers = [];
|
|
5214
|
+
resolvers.forEach((resolve) => resolve(true));
|
|
5215
|
+
}
|
|
5216
|
+
async componentWillUpdate() {
|
|
5217
|
+
await super.componentWillUpdate?.();
|
|
5218
|
+
await Promise.all([...this.controllers].map((c) => c.hostWillUpdate?.()));
|
|
5219
|
+
}
|
|
5220
|
+
componentDidUpdate() {
|
|
5221
|
+
super.componentDidUpdate?.();
|
|
5222
|
+
this.controllers.forEach((c) => c.hostDidUpdate?.());
|
|
5223
|
+
}
|
|
5224
|
+
};
|
|
5225
|
+
//#endregion
|
|
4838
5226
|
//#region src/runtime/render.ts
|
|
4839
5227
|
/**
|
|
4840
5228
|
* A WeakMap to persist HostRef objects across multiple render() calls to the
|
|
@@ -4921,4 +5309,4 @@ function hasKeys(obj) {
|
|
|
4921
5309
|
return false;
|
|
4922
5310
|
}
|
|
4923
5311
|
//#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 };
|
|
5312
|
+
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, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
|