@stencil/core 5.0.0-alpha.8 → 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 +2 -0
- package/dist/{runtime/app-data → app-data}/index.js +5 -2
- 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-B3pUYg_P.mjs → compiler-NrvbUOX1.mjs} +2904 -1269
- package/dist/declarations/stencil-ext-modules.d.ts +5 -5
- package/dist/declarations/stencil-public-compiler.d.ts +208 -62
- 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-BuveMLxy.d.ts → index-DnISpqrd.d.ts} +150 -10
- package/dist/{index-CVhWFUM0.d.mts → index-RrQfiPWK.d.mts} +490 -841
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +91 -2
- package/dist/jsx-runtime.mjs +2 -1
- package/dist/{node-10UamZmn.mjs → node-75gQKkFz.mjs} +60 -58
- package/dist/{chunk-z9aeyW2b.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
- package/dist/runtime/client/lazy.js +483 -347
- package/dist/runtime/client/runtime.d.ts +150 -39
- package/dist/runtime/client/runtime.js +483 -347
- package/dist/runtime/index.d.ts +6 -32
- package/dist/runtime/index.js +482 -345
- package/dist/runtime/server/index.d.mts +81 -9
- package/dist/runtime/server/index.mjs +419 -193
- package/dist/runtime/server/runner.d.mts +3 -0
- package/dist/runtime/server/runner.mjs +321 -338
- package/dist/signals/index.d.ts +2 -0
- package/dist/signals/index.js +5 -2
- 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 +7744 -791
- package/dist/util-IKfWWLJo.mjs +724 -0
- package/dist/validation-DAdGTrys.mjs +791 -0
- package/package.json +33 -33
- package/dist/client-Dd-NB5Ei.mjs +0 -4833
- package/dist/index-ch-cf-bZ.d.mts +0 -205
- package/dist/runtime/app-data/index.d.ts +0 -2
- package/dist/validation-ByxKj8bC.mjs +0 -1458
- /package/{LICENSE.md → LICENSE} +0 -0
- /package/dist/{runtime/app-globals → app-globals}/index.d.ts +0 -0
- /package/dist/{runtime/app-globals → app-globals}/index.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/
|
|
2
|
-
import { globalStyles } from "@stencil/core/
|
|
1
|
+
import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/app-data";
|
|
2
|
+
import { globalStyles } from "@stencil/core/app-globals";
|
|
3
3
|
import { effect, effect as effect$1, signal } from "@preact/signals-core";
|
|
4
4
|
//#region src/client/client-build.ts
|
|
5
5
|
const Build = {
|
|
@@ -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;
|
|
@@ -502,12 +542,6 @@ const HYDRATE_ID = "s-id";
|
|
|
502
542
|
const HYDRATED_STYLE_ID = "sty-id";
|
|
503
543
|
const HYDRATE_CHILD_ID = "c-id";
|
|
504
544
|
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
505
|
-
const STENCIL_DOC_DATA = "_stencilDocData";
|
|
506
|
-
const DEFAULT_DOC_DATA = {
|
|
507
|
-
hostIds: 0,
|
|
508
|
-
rootLevelIds: 0,
|
|
509
|
-
staticComponents: /* @__PURE__ */ new Set()
|
|
510
|
-
};
|
|
511
545
|
/**
|
|
512
546
|
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
513
547
|
*
|
|
@@ -516,6 +550,10 @@ const DEFAULT_DOC_DATA = {
|
|
|
516
550
|
*/
|
|
517
551
|
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
518
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;
|
|
519
557
|
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
520
558
|
"formAssociatedCallback",
|
|
521
559
|
"formResetCallback",
|
|
@@ -538,7 +576,7 @@ const plt = {
|
|
|
538
576
|
const setPlatformHelpers = (helpers) => {
|
|
539
577
|
Object.assign(plt, helpers);
|
|
540
578
|
};
|
|
541
|
-
const supportsListenerOptions =
|
|
579
|
+
const supportsListenerOptions = /*@__PURE__*/ (() => {
|
|
542
580
|
let supported = false;
|
|
543
581
|
try {
|
|
544
582
|
win.document?.addEventListener("e", null, Object.defineProperty({}, "passive", { get() {
|
|
@@ -548,14 +586,14 @@ const supportsListenerOptions = /* @__PURE__ */ (() => {
|
|
|
548
586
|
return supported;
|
|
549
587
|
})();
|
|
550
588
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
551
|
-
const supportsConstructableStylesheets = BUILD$1.constructableCSS ?
|
|
589
|
+
const supportsConstructableStylesheets = BUILD$1.constructableCSS ? /*@__PURE__*/ (() => {
|
|
552
590
|
try {
|
|
553
591
|
if (!win.document.adoptedStyleSheets) return false;
|
|
554
592
|
return typeof new CSSStyleSheet().replaceSync === "function";
|
|
555
593
|
} catch {}
|
|
556
594
|
return false;
|
|
557
595
|
})() : false;
|
|
558
|
-
const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ?
|
|
596
|
+
const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /*@__PURE__*/ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
|
|
559
597
|
//#endregion
|
|
560
598
|
//#region src/client/client-task-queue.ts
|
|
561
599
|
let queueCongestion = 0;
|
|
@@ -563,12 +601,13 @@ let queuePending = false;
|
|
|
563
601
|
const queueDomReads = [];
|
|
564
602
|
const queueDomWrites = [];
|
|
565
603
|
const queueDomWritesLow = [];
|
|
604
|
+
const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
|
|
566
605
|
const queueTask = (queue, write) => (cb) => {
|
|
567
606
|
queue.push(cb);
|
|
568
607
|
if (!queuePending) {
|
|
569
608
|
queuePending = true;
|
|
570
609
|
if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
|
|
571
|
-
else
|
|
610
|
+
else scheduleFlush();
|
|
572
611
|
}
|
|
573
612
|
};
|
|
574
613
|
const consume = (queue) => {
|
|
@@ -601,16 +640,16 @@ const flush = () => {
|
|
|
601
640
|
queueDomWritesLow.push(...queueDomWrites);
|
|
602
641
|
queueDomWrites.length = 0;
|
|
603
642
|
}
|
|
604
|
-
if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)
|
|
643
|
+
if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) scheduleFlush();
|
|
605
644
|
else queueCongestion = 0;
|
|
606
645
|
} else {
|
|
607
646
|
consume(queueDomWrites);
|
|
608
|
-
if (queuePending = queueDomReads.length > 0)
|
|
647
|
+
if (queuePending = queueDomReads.length > 0) scheduleFlush();
|
|
609
648
|
}
|
|
610
649
|
};
|
|
611
650
|
const nextTick = (cb) => promiseResolve().then(cb);
|
|
612
|
-
const readTask =
|
|
613
|
-
const writeTask =
|
|
651
|
+
const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
|
|
652
|
+
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
614
653
|
//#endregion
|
|
615
654
|
//#region src/runtime/asset-path.ts
|
|
616
655
|
const getAssetPath = (path) => {
|
|
@@ -647,12 +686,15 @@ function createShadowRoot(cmpMeta) {
|
|
|
647
686
|
if (BUILD$1.shadowSlotAssignmentManual) {
|
|
648
687
|
if (!!(cmpMeta.$flags$ & CMP_FLAGS.shadowSlotAssignmentManual)) opts.slotAssignment = "manual";
|
|
649
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);
|
|
650
691
|
const shadowRoot = this.attachShadow(opts);
|
|
651
692
|
if (BUILD$1.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
|
|
652
693
|
if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported(globalStyles) ?? null;
|
|
653
|
-
if (globalStyleSheet)
|
|
654
|
-
|
|
655
|
-
|
|
694
|
+
if (globalStyleSheet) {
|
|
695
|
+
if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
|
|
696
|
+
else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
|
|
697
|
+
} else if (globalStyles && !supportsConstructableStylesheets) {
|
|
656
698
|
const styleElm = document.createElement("style");
|
|
657
699
|
styleElm.innerHTML = globalStyles;
|
|
658
700
|
if (BUILD$1.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, GLOBAL_STYLE_ID);
|
|
@@ -677,8 +719,10 @@ function createShadowRoot(cmpMeta) {
|
|
|
677
719
|
const updateFallbackSlotVisibility = (elm) => {
|
|
678
720
|
const childNodes = internalCall(elm, "childNodes");
|
|
679
721
|
if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
|
|
680
|
-
if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB")
|
|
681
|
-
|
|
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
|
+
}
|
|
682
726
|
});
|
|
683
727
|
let i = 0;
|
|
684
728
|
for (i = 0; i < childNodes.length; i++) {
|
|
@@ -721,7 +765,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
|
721
765
|
slottedNodes.push(childNode);
|
|
722
766
|
if (typeof slotName !== "undefined") return slottedNodes;
|
|
723
767
|
}
|
|
724
|
-
slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode
|
|
768
|
+
slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
|
|
725
769
|
}
|
|
726
770
|
return slottedNodes;
|
|
727
771
|
}
|
|
@@ -752,7 +796,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
|
|
|
752
796
|
if (nodeToRelocate.getAttribute("slot") === slotName) return true;
|
|
753
797
|
return false;
|
|
754
798
|
}
|
|
755
|
-
if (nodeToRelocate["s-
|
|
799
|
+
if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
|
|
756
800
|
return slotName === "";
|
|
757
801
|
};
|
|
758
802
|
/**
|
|
@@ -801,8 +845,10 @@ function patchSlotNode(node) {
|
|
|
801
845
|
const assignedFactory = (elementsOnly) => function(opts) {
|
|
802
846
|
const toReturn = [];
|
|
803
847
|
const slotName = this["s-sn"];
|
|
804
|
-
if (opts?.flatten)
|
|
805
|
-
|
|
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
|
+
}
|
|
806
852
|
const parent = this["s-cr"].parentElement;
|
|
807
853
|
(parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
|
|
808
854
|
if (slotName === getSlotName(n)) toReturn.push(n);
|
|
@@ -893,8 +939,10 @@ const patchCloneNode = (HostElementPrototype) => {
|
|
|
893
939
|
for (; i < childNodes.length; i++) {
|
|
894
940
|
slotted = childNodes[i]["s-nr"];
|
|
895
941
|
nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
|
|
896
|
-
if (slotted)
|
|
897
|
-
|
|
942
|
+
if (slotted) {
|
|
943
|
+
if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
|
|
944
|
+
else clonedNode.appendChild(slotted.cloneNode(true));
|
|
945
|
+
}
|
|
898
946
|
if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
|
|
899
947
|
}
|
|
900
948
|
}
|
|
@@ -1097,11 +1145,11 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1097
1145
|
} });
|
|
1098
1146
|
patchHostOriginalAccessor("firstChild", elm);
|
|
1099
1147
|
Object.defineProperty(elm, "firstChild", { get() {
|
|
1100
|
-
return this.childNodes[0];
|
|
1148
|
+
return this.childNodes[0] || null;
|
|
1101
1149
|
} });
|
|
1102
1150
|
patchHostOriginalAccessor("lastChild", elm);
|
|
1103
1151
|
Object.defineProperty(elm, "lastChild", { get() {
|
|
1104
|
-
return this.childNodes[this.childNodes.length - 1];
|
|
1152
|
+
return this.childNodes[this.childNodes.length - 1] || null;
|
|
1105
1153
|
} });
|
|
1106
1154
|
patchHostOriginalAccessor("childNodes", elm);
|
|
1107
1155
|
Object.defineProperty(elm, "childNodes", { get() {
|
|
@@ -1147,7 +1195,7 @@ const patchNextSibling = (node) => {
|
|
|
1147
1195
|
Object.defineProperty(node, "nextSibling", { get: function() {
|
|
1148
1196
|
const parentNodes = this["s-ol"]?.parentNode.childNodes;
|
|
1149
1197
|
const index = parentNodes?.indexOf(this);
|
|
1150
|
-
if (parentNodes && index > -1) return parentNodes[index + 1];
|
|
1198
|
+
if (parentNodes && index > -1) return parentNodes[index + 1] || null;
|
|
1151
1199
|
return this.__nextSibling;
|
|
1152
1200
|
} });
|
|
1153
1201
|
};
|
|
@@ -1162,7 +1210,7 @@ const patchNextElementSibling = (element) => {
|
|
|
1162
1210
|
Object.defineProperty(element, "nextElementSibling", { get: function() {
|
|
1163
1211
|
const parentEles = this["s-ol"]?.parentNode.children;
|
|
1164
1212
|
const index = parentEles?.indexOf(this);
|
|
1165
|
-
if (parentEles && index > -1) return parentEles[index + 1];
|
|
1213
|
+
if (parentEles && index > -1) return parentEles[index + 1] || null;
|
|
1166
1214
|
return this.__nextElementSibling;
|
|
1167
1215
|
} });
|
|
1168
1216
|
};
|
|
@@ -1177,7 +1225,7 @@ const patchPreviousSibling = (node) => {
|
|
|
1177
1225
|
Object.defineProperty(node, "previousSibling", { get: function() {
|
|
1178
1226
|
const parentNodes = this["s-ol"]?.parentNode.childNodes;
|
|
1179
1227
|
const index = parentNodes?.indexOf(this);
|
|
1180
|
-
if (parentNodes && index > -1) return parentNodes[index - 1];
|
|
1228
|
+
if (parentNodes && index > -1) return parentNodes[index - 1] || null;
|
|
1181
1229
|
return this.__previousSibling;
|
|
1182
1230
|
} });
|
|
1183
1231
|
};
|
|
@@ -1192,7 +1240,7 @@ const patchPreviousElementSibling = (element) => {
|
|
|
1192
1240
|
Object.defineProperty(element, "previousElementSibling", { get: function() {
|
|
1193
1241
|
const parentNodes = this["s-ol"]?.parentNode.children;
|
|
1194
1242
|
const index = parentNodes?.indexOf(this);
|
|
1195
|
-
if (parentNodes && index > -1) return parentNodes[index - 1];
|
|
1243
|
+
if (parentNodes && index > -1) return parentNodes[index - 1] || null;
|
|
1196
1244
|
return this.__previousElementSibling;
|
|
1197
1245
|
} });
|
|
1198
1246
|
};
|
|
@@ -1367,7 +1415,7 @@ function queryNonceMetaTagContent(doc) {
|
|
|
1367
1415
|
}
|
|
1368
1416
|
//#endregion
|
|
1369
1417
|
//#region src/runtime/styles.ts
|
|
1370
|
-
const rootAppliedStyles =
|
|
1418
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
1371
1419
|
/**
|
|
1372
1420
|
* Get or initialize the set of applied style scope IDs for a container element.
|
|
1373
1421
|
*
|
|
@@ -1391,9 +1439,10 @@ const getAppliedStyles = (container) => {
|
|
|
1391
1439
|
* @param prepend if true, add to beginning; if false, add to end
|
|
1392
1440
|
*/
|
|
1393
1441
|
const adoptStylesheet = (container, sheet, prepend = false) => {
|
|
1394
|
-
if (supportsMutableAdoptedStyleSheets)
|
|
1395
|
-
|
|
1396
|
-
|
|
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];
|
|
1397
1446
|
else container.adoptedStyleSheets = [...container.adoptedStyleSheets, sheet];
|
|
1398
1447
|
};
|
|
1399
1448
|
/**
|
|
@@ -1406,7 +1455,7 @@ const adoptStylesheet = (container, sheet, prepend = false) => {
|
|
|
1406
1455
|
* @returns a new CSSStyleSheet for the correct window
|
|
1407
1456
|
*/
|
|
1408
1457
|
const createStylesheetForWindow = (container, cssText) => {
|
|
1409
|
-
const sheet = new (container.defaultView ?? container.ownerDocument?.defaultView ?? win).CSSStyleSheet();
|
|
1458
|
+
const sheet = new (container.defaultView ?? (container.ownerDocument?.defaultView) ?? win).CSSStyleSheet();
|
|
1410
1459
|
sheet.replaceSync(cssText);
|
|
1411
1460
|
return sheet;
|
|
1412
1461
|
};
|
|
@@ -1477,41 +1526,46 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1477
1526
|
/**
|
|
1478
1527
|
* attach styles at the end of the head tag if we render scoped components
|
|
1479
1528
|
*/
|
|
1480
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation))
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
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);
|
|
1508
1561
|
}
|
|
1509
|
-
else styleContainerNode.append(styleElm);
|
|
1510
1562
|
/**
|
|
1511
1563
|
* attach styles at the beginning of a shadow root node if we render shadow components
|
|
1512
1564
|
*/
|
|
1513
|
-
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)
|
|
1514
|
-
|
|
1565
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
|
|
1566
|
+
if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
|
|
1567
|
+
else styleContainerNode.insertBefore(styleElm, null);
|
|
1568
|
+
}
|
|
1515
1569
|
if (appliedStyles) appliedStyles.add(scopeId);
|
|
1516
1570
|
}
|
|
1517
1571
|
} else if (BUILD$1.constructableCSS) {
|
|
@@ -1603,7 +1657,12 @@ const hydrateScopedToShadow = () => {
|
|
|
1603
1657
|
if (!win.document) return;
|
|
1604
1658
|
const styleElements = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1605
1659
|
let i = 0;
|
|
1606
|
-
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
|
+
}
|
|
1607
1666
|
};
|
|
1608
1667
|
//#endregion
|
|
1609
1668
|
//#region src/utils/helpers.ts
|
|
@@ -1735,11 +1794,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1735
1794
|
}
|
|
1736
1795
|
} else if (BUILD$1.vdomStyle && memberName === "style") {
|
|
1737
1796
|
if (BUILD$1.updatable) {
|
|
1738
|
-
for (const prop in oldValue) if (!newValue || newValue[prop] == null)
|
|
1739
|
-
|
|
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];
|
|
1740
1805
|
}
|
|
1741
|
-
for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
|
|
1742
|
-
else elm.style[prop] = newValue[prop];
|
|
1743
1806
|
} else if (BUILD$1.vdomKey && memberName === "key") {} else if (BUILD$1.vdomRef && memberName === "ref") {
|
|
1744
1807
|
if (newValue) queueRefAttachment(newValue, elm);
|
|
1745
1808
|
} else if (BUILD$1.vdomListener && (BUILD$1.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
|
|
@@ -1748,11 +1811,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1748
1811
|
else memberName = ln[2] + memberName.slice(3);
|
|
1749
1812
|
if (oldValue || newValue) {
|
|
1750
1813
|
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
1751
|
-
memberName = memberName.replace(
|
|
1814
|
+
memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
|
|
1752
1815
|
if (oldValue) plt.rel(elm, memberName, oldValue, capture);
|
|
1753
1816
|
if (newValue) plt.ael(elm, memberName, newValue, capture);
|
|
1754
1817
|
}
|
|
1755
|
-
} else if (BUILD$1.
|
|
1818
|
+
} else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "a" && memberName.startsWith("attr:")) {
|
|
1756
1819
|
const propName = memberName.slice(5);
|
|
1757
1820
|
let attrName;
|
|
1758
1821
|
if (BUILD$1.member) {
|
|
@@ -1767,7 +1830,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1767
1830
|
if (newValue !== false || elm.getAttribute(attrName) === "") elm.removeAttribute(attrName);
|
|
1768
1831
|
} else elm.setAttribute(attrName, newValue === true ? "" : newValue);
|
|
1769
1832
|
return;
|
|
1770
|
-
} else if (BUILD$1.
|
|
1833
|
+
} else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "p" && memberName.startsWith("prop:")) {
|
|
1771
1834
|
const propName = memberName.slice(5);
|
|
1772
1835
|
try {
|
|
1773
1836
|
elm[propName] = newValue;
|
|
@@ -1787,8 +1850,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1787
1850
|
if (!elm.tagName.includes("-")) {
|
|
1788
1851
|
const n = newValue == null ? "" : newValue;
|
|
1789
1852
|
if (memberName === "list") isProp = false;
|
|
1790
|
-
else if (oldValue == null || elm[memberName] !== n)
|
|
1791
|
-
|
|
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
|
+
}
|
|
1792
1857
|
} else if (elm[memberName] !== newValue) elm[memberName] = newValue;
|
|
1793
1858
|
} catch {}
|
|
1794
1859
|
/**
|
|
@@ -1806,8 +1871,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1806
1871
|
}
|
|
1807
1872
|
}
|
|
1808
1873
|
if (newValue == null || newValue === false) {
|
|
1809
|
-
if (newValue !== false || elm.getAttribute(memberName) === ""
|
|
1810
|
-
|
|
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
|
+
}
|
|
1811
1878
|
} else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
|
|
1812
1879
|
newValue = newValue === true ? "" : newValue;
|
|
1813
1880
|
if (BUILD$1.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -1815,6 +1882,18 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1815
1882
|
}
|
|
1816
1883
|
}
|
|
1817
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-");
|
|
1818
1897
|
const parseClassListRegex = /\s/;
|
|
1819
1898
|
/**
|
|
1820
1899
|
* Parsed a string of classnames into an array
|
|
@@ -1938,6 +2017,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1938
2017
|
}
|
|
1939
2018
|
} else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
1940
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;
|
|
1941
2021
|
if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
1942
2022
|
} else {
|
|
1943
2023
|
if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
@@ -2213,8 +2293,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2213
2293
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2214
2294
|
newStartVnode = newCh[++newStartIdx];
|
|
2215
2295
|
}
|
|
2216
|
-
if (node)
|
|
2217
|
-
|
|
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
|
+
}
|
|
2218
2300
|
}
|
|
2219
2301
|
if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
2220
2302
|
else if (BUILD$1.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
@@ -2301,6 +2383,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2301
2383
|
*/
|
|
2302
2384
|
const relocateNodes = [];
|
|
2303
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
|
+
/**
|
|
2304
2410
|
* Mark the contents of a slot for relocation via adding references to them to
|
|
2305
2411
|
* the {@link relocateNodes} data structure. The actual work of relocating them
|
|
2306
2412
|
* will then be handled in {@link renderVdom}.
|
|
@@ -2405,7 +2511,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2405
2511
|
return newNode;
|
|
2406
2512
|
}
|
|
2407
2513
|
}
|
|
2408
|
-
if (parent
|
|
2514
|
+
if (BUILD$1.slotRelocation && parent?.__insertBefore) return parent.__insertBefore(newNode, reference);
|
|
2409
2515
|
else return parent?.insertBefore(newNode, reference);
|
|
2410
2516
|
};
|
|
2411
2517
|
/**
|
|
@@ -2499,6 +2605,7 @@ render() {
|
|
|
2499
2605
|
plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
|
|
2500
2606
|
if (checkSlotRelocate) {
|
|
2501
2607
|
markSlotContentForRelocation(rootVnode.$elm$);
|
|
2608
|
+
carryContentWithRelocatedSlotRefs();
|
|
2502
2609
|
for (const relocateData of relocateNodes) {
|
|
2503
2610
|
const nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
2504
2611
|
if (!nodeToRelocate["s-ol"] && win.document) {
|
|
@@ -2558,7 +2665,7 @@ render() {
|
|
|
2558
2665
|
}
|
|
2559
2666
|
if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
|
|
2560
2667
|
const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
|
|
2561
|
-
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) {
|
|
2562
2669
|
if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
|
|
2563
2670
|
if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
|
|
2564
2671
|
else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
|
|
@@ -2576,16 +2683,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
|
|
|
2576
2683
|
const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
|
|
2577
2684
|
//#endregion
|
|
2578
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
|
+
};
|
|
2579
2727
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2580
2728
|
if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
2581
2729
|
const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
|
|
2582
2730
|
ancestorComponent["s-p"].splice(index - 1, 1);
|
|
2583
2731
|
r();
|
|
2584
2732
|
}));
|
|
2733
|
+
if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
|
|
2585
2734
|
}
|
|
2586
2735
|
};
|
|
2587
2736
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
2588
|
-
if (BUILD$1.
|
|
2737
|
+
if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
|
|
2589
2738
|
if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
|
|
2590
2739
|
hostRef.$flags$ |= HOST_FLAGS.needsRerender;
|
|
2591
2740
|
return;
|
|
@@ -2593,6 +2742,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2593
2742
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2594
2743
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2595
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);
|
|
2596
2747
|
queueMicrotask(() => {
|
|
2597
2748
|
dispatch();
|
|
2598
2749
|
});
|
|
@@ -2632,10 +2783,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2632
2783
|
let maybePromise;
|
|
2633
2784
|
if (isInitialLoad) {
|
|
2634
2785
|
if (BUILD$1.lazyLoad) {
|
|
2635
|
-
if (BUILD$1.slotRelocation && hostRef.$deferredConnectedCallback$) {
|
|
2636
|
-
hostRef.$deferredConnectedCallback$ = false;
|
|
2637
|
-
safeCall(instance, "connectedCallback", void 0, elm);
|
|
2638
|
-
}
|
|
2639
2786
|
if (BUILD$1.hostListener) {
|
|
2640
2787
|
hostRef.$flags$ |= HOST_FLAGS.isListenReady;
|
|
2641
2788
|
if (hostRef.$queuedListeners$) {
|
|
@@ -2648,6 +2795,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2648
2795
|
if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
|
|
2649
2796
|
maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
|
|
2650
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
|
+
}
|
|
2651
2806
|
if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
|
|
2652
2807
|
maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
|
|
2653
2808
|
}
|
|
@@ -2762,7 +2917,6 @@ let renderingRef = null;
|
|
|
2762
2917
|
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
2763
2918
|
const allRenderFn = !!BUILD$1.allRenderFn;
|
|
2764
2919
|
const lazyLoad = !!BUILD$1.lazyLoad;
|
|
2765
|
-
const taskQueue = !!BUILD$1.taskQueue;
|
|
2766
2920
|
const updatable = !!BUILD$1.updatable;
|
|
2767
2921
|
try {
|
|
2768
2922
|
renderingRef = instance;
|
|
@@ -2771,14 +2925,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
|
2771
2925
|
* method, so we can call the method immediately. If not, check before calling it.
|
|
2772
2926
|
*/
|
|
2773
2927
|
instance = allRenderFn ? instance.render() : instance.render && instance.render();
|
|
2774
|
-
if (updatable
|
|
2928
|
+
if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
|
|
2775
2929
|
if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
|
|
2776
|
-
if (BUILD$1.hasRenderFn || BUILD$1.reflect)
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
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
|
+
}
|
|
2782
2939
|
}
|
|
2783
2940
|
} catch (e) {
|
|
2784
2941
|
consoleError(e, hostRef.$hostElement$);
|
|
@@ -2918,17 +3075,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2918
3075
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2919
3076
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
2920
3077
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
2921
|
-
const
|
|
3078
|
+
const initialVal = hostRef.$instanceValues$.get(memberName);
|
|
3079
|
+
const sig = signal(initialVal);
|
|
2922
3080
|
hostRef.$signalValues$.set(memberName, sig);
|
|
2923
3081
|
let prevScheduleVal = sig.peek();
|
|
2924
3082
|
disposers.push(effect(() => {
|
|
2925
3083
|
const newVal = sig.value;
|
|
2926
3084
|
if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
|
|
2927
3085
|
if (instance?.componentShouldUpdate) {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3086
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3087
|
+
changes[memberName] = {
|
|
3088
|
+
newVal,
|
|
3089
|
+
oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
|
|
3090
|
+
};
|
|
2932
3091
|
}
|
|
2933
3092
|
if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
2934
3093
|
}
|
|
@@ -2963,7 +3122,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2963
3122
|
consoleError(e, elm);
|
|
2964
3123
|
}
|
|
2965
3124
|
}));
|
|
2966
|
-
|
|
3125
|
+
const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
|
|
3126
|
+
elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
|
|
2967
3127
|
hostRef.$signalCleanup$ = () => {
|
|
2968
3128
|
disposers.forEach((d) => d());
|
|
2969
3129
|
elm[STENCIL_SIGNALS_SYMBOL] = void 0;
|
|
@@ -3012,24 +3172,30 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3012
3172
|
for (let i = 0; i < c.length; i++) {
|
|
3013
3173
|
child = c[i];
|
|
3014
3174
|
if (Array.isArray(child)) walk(child);
|
|
3015
|
-
else if (child != null && typeof child !== "boolean")
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
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
|
+
}
|
|
3028
3194
|
}
|
|
3029
3195
|
}
|
|
3030
3196
|
};
|
|
3031
3197
|
walk(children);
|
|
3032
|
-
if (vnodeData) {
|
|
3198
|
+
if (vnodeData && typeof vnodeData === "object") {
|
|
3033
3199
|
if (BUILD$1.isDev && nodeName === "input") validateInputProperties(vnodeData);
|
|
3034
3200
|
if (BUILD$1.vdomKey && vnodeData.key) key = vnodeData.key;
|
|
3035
3201
|
if (BUILD$1.slotRelocation && vnodeData.name) slotName = vnodeData.name;
|
|
@@ -3130,7 +3296,7 @@ const convertToPrivate = (node) => {
|
|
|
3130
3296
|
/**
|
|
3131
3297
|
* Validates the ordering of attributes on an input element
|
|
3132
3298
|
*
|
|
3133
|
-
* @param inputElm the element to validate
|
|
3299
|
+
* @param inputElm the vnode data (JSX props) for the element to validate
|
|
3134
3300
|
*/
|
|
3135
3301
|
const validateInputProperties = (inputElm) => {
|
|
3136
3302
|
const props = Object.keys(inputElm);
|
|
@@ -4009,14 +4175,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
4009
4175
|
/**
|
|
4010
4176
|
* ensure this value is of the correct prop type
|
|
4011
4177
|
*/
|
|
4012
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
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
|
+
}
|
|
4020
4187
|
/**
|
|
4021
4188
|
* force it to be a number
|
|
4022
4189
|
*/
|
|
@@ -4104,7 +4271,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4104
4271
|
}
|
|
4105
4272
|
if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4106
4273
|
if (instance.componentShouldUpdate) {
|
|
4107
|
-
|
|
4274
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4275
|
+
changes[propName] = {
|
|
4276
|
+
newVal,
|
|
4277
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4278
|
+
};
|
|
4108
4279
|
}
|
|
4109
4280
|
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4110
4281
|
}
|
|
@@ -4238,11 +4409,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4238
4409
|
};
|
|
4239
4410
|
for (const deserializer of cmpMeta.$deserializers$[propName]) {
|
|
4240
4411
|
const [[methodName]] = Object.entries(deserializer);
|
|
4241
|
-
if (BUILD$1.lazyLoad)
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
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);
|
|
4246
4418
|
}
|
|
4247
4419
|
return;
|
|
4248
4420
|
} else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
|
|
@@ -4266,7 +4438,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4266
4438
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4267
4439
|
});
|
|
4268
4440
|
};
|
|
4269
|
-
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]) => {
|
|
4270
4442
|
const attrName = m[1] || propName;
|
|
4271
4443
|
attrNameToPropName.set(attrName, propName);
|
|
4272
4444
|
if (BUILD$1.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
|
|
@@ -4293,6 +4465,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4293
4465
|
try {
|
|
4294
4466
|
if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
|
|
4295
4467
|
hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
|
|
4468
|
+
hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
|
|
4296
4469
|
const bundleId = cmpMeta.$lazyBundleId$;
|
|
4297
4470
|
if (BUILD$1.lazyLoad && bundleId) {
|
|
4298
4471
|
const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
|
|
@@ -4301,7 +4474,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4301
4474
|
Cstr = await CstrImport;
|
|
4302
4475
|
endLoad();
|
|
4303
4476
|
} else Cstr = CstrImport;
|
|
4304
|
-
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
|
+
}
|
|
4305
4483
|
if (BUILD$1.member && !Cstr.isProxied) {
|
|
4306
4484
|
if (BUILD$1.propChangeCallback) {
|
|
4307
4485
|
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
@@ -4320,8 +4498,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4320
4498
|
}
|
|
4321
4499
|
if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4322
4500
|
endNewInstance();
|
|
4323
|
-
if (
|
|
4324
|
-
|
|
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
|
+
});
|
|
4325
4509
|
} else Cstr = elm.constructor;
|
|
4326
4510
|
if (BUILD$1.style && Cstr && Cstr.style) {
|
|
4327
4511
|
/**
|
|
@@ -4380,7 +4564,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4380
4564
|
hostRef.$onRenderResolve$();
|
|
4381
4565
|
hostRef.$onRenderResolve$ = void 0;
|
|
4382
4566
|
}
|
|
4383
|
-
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);
|
|
4384
4569
|
}
|
|
4385
4570
|
};
|
|
4386
4571
|
const fireConnectedCallback = (instance, elm) => {
|
|
@@ -4443,6 +4628,7 @@ const connectedCallback = (elm) => {
|
|
|
4443
4628
|
} else {
|
|
4444
4629
|
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
4445
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);
|
|
4446
4632
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
|
|
4447
4633
|
}
|
|
4448
4634
|
endConnected();
|
|
@@ -4472,6 +4658,7 @@ const disconnectedCallback = async (elm) => {
|
|
|
4472
4658
|
hostRef.$signalCleanup$();
|
|
4473
4659
|
hostRef.$signalCleanup$ = void 0;
|
|
4474
4660
|
}
|
|
4661
|
+
if (BUILD$1.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
|
|
4475
4662
|
if (!BUILD$1.lazyLoad) disconnectInstance(elm);
|
|
4476
4663
|
else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
|
|
4477
4664
|
else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
|
|
@@ -4519,7 +4706,6 @@ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4519
4706
|
};
|
|
4520
4707
|
const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
4521
4708
|
const modulePath = hostElement.constructor.__stencil_module__;
|
|
4522
|
-
console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
|
|
4523
4709
|
if (!modulePath) {
|
|
4524
4710
|
console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor - was this built with devMode?`);
|
|
4525
4711
|
return;
|
|
@@ -4532,18 +4718,39 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4532
4718
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4533
4719
|
if (!NewClass) return;
|
|
4534
4720
|
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4535
|
-
if (ctor)
|
|
4536
|
-
|
|
4537
|
-
|
|
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
|
+
}
|
|
4538
4742
|
}
|
|
4743
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4539
4744
|
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
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);
|
|
4547
4754
|
}
|
|
4548
4755
|
forceUpdate(el);
|
|
4549
4756
|
});
|
|
@@ -4554,7 +4761,9 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4554
4761
|
//#endregion
|
|
4555
4762
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4556
4763
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
4557
|
-
|
|
4764
|
+
const tag = transformTag(compactMeta[1]);
|
|
4765
|
+
const proxied = proxyCustomElement(Cstr, compactMeta);
|
|
4766
|
+
if (!customElements.get(tag)) customElements.define(tag, proxied);
|
|
4558
4767
|
};
|
|
4559
4768
|
const proxyCustomElement = (Cstr, compactMeta) => {
|
|
4560
4769
|
if (BUILD$1.profile && performance.mark && performance.getEntriesByName("st:app:start", "mark").length === 0) performance.mark("st:app:start");
|
|
@@ -4575,18 +4784,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4575
4784
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4576
4785
|
};
|
|
4577
4786
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4578
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot)
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
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);
|
|
4588
4800
|
}
|
|
4589
|
-
if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4590
4801
|
}
|
|
4591
4802
|
if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
|
|
4592
4803
|
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
@@ -4599,19 +4810,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4599
4810
|
componentOnReady() {
|
|
4600
4811
|
return getHostRef(this)?.$onReadyPromise$;
|
|
4601
4812
|
},
|
|
4602
|
-
connectedCallback() {
|
|
4603
|
-
|
|
4604
|
-
|
|
4813
|
+
async connectedCallback() {
|
|
4814
|
+
const isFirstConnect = !this.__hasHostListenerAttached;
|
|
4815
|
+
let hostRef;
|
|
4816
|
+
if (isFirstConnect) {
|
|
4817
|
+
hostRef = getHostRef(this);
|
|
4605
4818
|
if (!hostRef) return;
|
|
4606
4819
|
addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
|
|
4607
4820
|
this.__hasHostListenerAttached = true;
|
|
4608
4821
|
}
|
|
4609
4822
|
connectedCallback(this);
|
|
4610
|
-
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);
|
|
4611
4829
|
},
|
|
4612
4830
|
disconnectedCallback() {
|
|
4613
4831
|
disconnectedCallback(this);
|
|
4614
|
-
if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
|
|
4832
|
+
if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
|
|
4615
4833
|
},
|
|
4616
4834
|
__attachShadow() {
|
|
4617
4835
|
const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
|
|
@@ -4665,8 +4883,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4665
4883
|
const exclude = options.exclude || [];
|
|
4666
4884
|
const _reg = options.registry ?? getRegistry();
|
|
4667
4885
|
const head = win.document.head;
|
|
4668
|
-
const metaCharset =
|
|
4669
|
-
const dataStyles =
|
|
4886
|
+
const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
|
|
4887
|
+
const dataStyles = /*@__PURE__*/ win.document.createElement("style");
|
|
4670
4888
|
const deferredConnectedCallbacks = [];
|
|
4671
4889
|
let appLoadFallback;
|
|
4672
4890
|
let isBootstrapping = true;
|
|
@@ -4734,8 +4952,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4734
4952
|
*
|
|
4735
4953
|
* Also remove the reference from `deferredConnectedCallbacks` array
|
|
4736
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`
|
|
4737
4958
|
*/
|
|
4738
|
-
|
|
4959
|
+
nextTick(() => {
|
|
4739
4960
|
const hostRef = getHostRef(this);
|
|
4740
4961
|
if (!hostRef) return;
|
|
4741
4962
|
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
|
|
@@ -4748,18 +4969,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4748
4969
|
}
|
|
4749
4970
|
};
|
|
4750
4971
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
|
|
4751
|
-
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot)
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
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);
|
|
4761
4985
|
}
|
|
4762
|
-
if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4763
4986
|
}
|
|
4764
4987
|
if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
4765
4988
|
if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
@@ -4805,9 +5028,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
|
|
|
4805
5028
|
};
|
|
4806
5029
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
4807
5030
|
try {
|
|
4808
|
-
if (BUILD$1.lazyLoad)
|
|
4809
|
-
|
|
4810
|
-
|
|
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);
|
|
4811
5035
|
} catch (e) {
|
|
4812
5036
|
consoleError(e, hostRef.$hostElement$);
|
|
4813
5037
|
}
|
|
@@ -4841,6 +5065,73 @@ const setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
|
4841
5065
|
//#region src/runtime/platform-options.ts
|
|
4842
5066
|
const setPlatformOptions = (opts) => Object.assign(plt, opts);
|
|
4843
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
|
|
4844
5135
|
//#region src/runtime/render.ts
|
|
4845
5136
|
/**
|
|
4846
5137
|
* A WeakMap to persist HostRef objects across multiple render() calls to the
|
|
@@ -4927,159 +5218,4 @@ function hasKeys(obj) {
|
|
|
4927
5218
|
return false;
|
|
4928
5219
|
}
|
|
4929
5220
|
//#endregion
|
|
4930
|
-
|
|
4931
|
-
/**
|
|
4932
|
-
* Updates the DOM generated on the server with annotations such as node attributes and
|
|
4933
|
-
* comment nodes to facilitate future client-side hydration. These annotations are used for things
|
|
4934
|
-
* like moving elements back to their original hosts if using Shadow DOM on the client, and for quickly
|
|
4935
|
-
* reconstructing the vNode representations of the DOM.
|
|
4936
|
-
*
|
|
4937
|
-
* @param doc The DOM generated by the server.
|
|
4938
|
-
* @param staticComponents Any components that should be considered static and do not need client-side hydration.
|
|
4939
|
-
*/
|
|
4940
|
-
const insertVdomAnnotations = (doc, staticComponents) => {
|
|
4941
|
-
if (doc != null) {
|
|
4942
|
-
/**
|
|
4943
|
-
* Initiated `docData` object from the document if it exists to ensure we
|
|
4944
|
-
* maintain the same `docData` object across multiple hydration hydration runs.
|
|
4945
|
-
*/
|
|
4946
|
-
const docData = "_stencilDocData" in doc ? doc[STENCIL_DOC_DATA] : { ...DEFAULT_DOC_DATA };
|
|
4947
|
-
docData.staticComponents = new Set(staticComponents);
|
|
4948
|
-
const orgLocationNodes = [];
|
|
4949
|
-
parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
|
|
4950
|
-
orgLocationNodes.forEach((orgLocationNode) => {
|
|
4951
|
-
if (orgLocationNode != null && orgLocationNode["s-nr"]) {
|
|
4952
|
-
const nodeRef = orgLocationNode["s-nr"];
|
|
4953
|
-
let hostId = nodeRef["s-host-id"];
|
|
4954
|
-
let nodeId = nodeRef["s-node-id"];
|
|
4955
|
-
let childId = `${hostId}.${nodeId}`;
|
|
4956
|
-
if (hostId == null) {
|
|
4957
|
-
hostId = 0;
|
|
4958
|
-
docData.rootLevelIds++;
|
|
4959
|
-
nodeId = docData.rootLevelIds;
|
|
4960
|
-
childId = `${hostId}.${nodeId}`;
|
|
4961
|
-
if (nodeRef.nodeType === NODE_TYPE.ElementNode) {
|
|
4962
|
-
nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
|
|
4963
|
-
if (typeof nodeRef["s-sn"] === "string" && !nodeRef.getAttribute("slot")) nodeRef.setAttribute("s-sn", nodeRef["s-sn"]);
|
|
4964
|
-
} else if (nodeRef.nodeType === NODE_TYPE.TextNode) {
|
|
4965
|
-
if (hostId === 0) {
|
|
4966
|
-
if (nodeRef.nodeValue?.trim() === "") {
|
|
4967
|
-
orgLocationNode.remove();
|
|
4968
|
-
return;
|
|
4969
|
-
}
|
|
4970
|
-
}
|
|
4971
|
-
const commentBeforeTextNode = doc.createComment(childId);
|
|
4972
|
-
commentBeforeTextNode.nodeValue = `t.${childId}`;
|
|
4973
|
-
insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
|
|
4974
|
-
} else if (nodeRef.nodeType === NODE_TYPE.CommentNode) {
|
|
4975
|
-
const commentBeforeTextNode = doc.createComment(childId);
|
|
4976
|
-
commentBeforeTextNode.nodeValue = `c.${childId}`;
|
|
4977
|
-
nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
|
|
4978
|
-
}
|
|
4979
|
-
}
|
|
4980
|
-
let orgLocationNodeId = `o.${childId}`;
|
|
4981
|
-
const orgLocationParentNode = orgLocationNode.parentElement;
|
|
4982
|
-
if (orgLocationParentNode) {
|
|
4983
|
-
if (orgLocationParentNode["s-en"] === "") orgLocationNodeId += `.`;
|
|
4984
|
-
else if (orgLocationParentNode["s-en"] === "c") orgLocationNodeId += `.c`;
|
|
4985
|
-
}
|
|
4986
|
-
orgLocationNode.nodeValue = orgLocationNodeId;
|
|
4987
|
-
}
|
|
4988
|
-
});
|
|
4989
|
-
}
|
|
4990
|
-
};
|
|
4991
|
-
/**
|
|
4992
|
-
* Recursively parses a node generated by the server and its children to set host and child id
|
|
4993
|
-
* attributes read during client-side hydration. This function also tracks whether each node is
|
|
4994
|
-
* an original location reference node meaning that a node has been moved via slot relocation.
|
|
4995
|
-
*
|
|
4996
|
-
* @param doc The DOM generated by the server.
|
|
4997
|
-
* @param node The node to parse.
|
|
4998
|
-
* @param docData An object containing metadata about the document.
|
|
4999
|
-
* @param orgLocationNodes An array of nodes that have been moved via slot relocation.
|
|
5000
|
-
*/
|
|
5001
|
-
const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
|
|
5002
|
-
if (node == null) return;
|
|
5003
|
-
if (node["s-nr"] != null) orgLocationNodes.push(node);
|
|
5004
|
-
if (node.nodeType === NODE_TYPE.ElementNode) [...Array.from(node.childNodes), ...Array.from(node.shadowRoot?.childNodes || [])].forEach((childNode) => {
|
|
5005
|
-
const hostRef = getHostRef(childNode);
|
|
5006
|
-
if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, { nodeIds: 0 });
|
|
5007
|
-
parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
|
|
5008
|
-
});
|
|
5009
|
-
};
|
|
5010
|
-
/**
|
|
5011
|
-
* Insert attribute annotations on an element for its host ID and, potentially, its child ID.
|
|
5012
|
-
* Also makes calls to insert annotations on the element's children, keeping track of the depth of
|
|
5013
|
-
* the component tree.
|
|
5014
|
-
*
|
|
5015
|
-
* @param doc The DOM generated by the server.
|
|
5016
|
-
* @param hostElm The element to insert annotations for.
|
|
5017
|
-
* @param vnode The vNode representation of the element.
|
|
5018
|
-
* @param docData An object containing metadata about the document.
|
|
5019
|
-
* @param cmpData An object containing metadata about the component.
|
|
5020
|
-
*/
|
|
5021
|
-
const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
|
|
5022
|
-
if (vnode != null) {
|
|
5023
|
-
const hostId = ++docData.hostIds;
|
|
5024
|
-
hostElm.setAttribute(HYDRATE_ID, hostId);
|
|
5025
|
-
if (hostElm["s-cr"] != null) hostElm["s-cr"].nodeValue = `r.${hostId}`;
|
|
5026
|
-
if (vnode.$children$ != null) {
|
|
5027
|
-
const depth = 0;
|
|
5028
|
-
vnode.$children$.forEach((vnodeChild, index) => {
|
|
5029
|
-
insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
|
|
5030
|
-
});
|
|
5031
|
-
}
|
|
5032
|
-
if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute("c-id")) {
|
|
5033
|
-
const parent = hostElm.parentElement;
|
|
5034
|
-
if (parent && parent.childNodes) {
|
|
5035
|
-
const parentChildNodes = Array.from(parent.childNodes);
|
|
5036
|
-
const comment = parentChildNodes.find((node) => node.nodeType === NODE_TYPE.CommentNode && node["s-sr"]);
|
|
5037
|
-
if (comment) {
|
|
5038
|
-
const index = parentChildNodes.indexOf(hostElm) - 1;
|
|
5039
|
-
vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`);
|
|
5040
|
-
}
|
|
5041
|
-
}
|
|
5042
|
-
}
|
|
5043
|
-
}
|
|
5044
|
-
};
|
|
5045
|
-
/**
|
|
5046
|
-
* Recursively analyzes the type of a child vNode and inserts annotations on the vNodes's element based on its type.
|
|
5047
|
-
* Element nodes receive a child ID attribute, text nodes have a comment with the child ID inserted before them,
|
|
5048
|
-
* and comment nodes representing a slot have their node value set to a slot node ID containing the child ID.
|
|
5049
|
-
*
|
|
5050
|
-
* @param doc The DOM generated by the server.
|
|
5051
|
-
* @param vnodeChild The vNode to insert annotations for.
|
|
5052
|
-
* @param cmpData An object containing metadata about the component.
|
|
5053
|
-
* @param hostId The host ID of this element's parent.
|
|
5054
|
-
* @param depth How deep this element sits in the component tree relative to its parent.
|
|
5055
|
-
* @param index The index of this element in its parent's children array.
|
|
5056
|
-
*/
|
|
5057
|
-
const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
|
|
5058
|
-
const childElm = vnodeChild.$elm$;
|
|
5059
|
-
if (childElm == null) return;
|
|
5060
|
-
const nodeId = cmpData.nodeIds++;
|
|
5061
|
-
const childId = `${hostId}.${nodeId}.${depth}.${index}`;
|
|
5062
|
-
childElm["s-host-id"] = hostId;
|
|
5063
|
-
childElm["s-node-id"] = nodeId;
|
|
5064
|
-
if (childElm.nodeType === NODE_TYPE.ElementNode) {
|
|
5065
|
-
childElm.setAttribute(HYDRATE_CHILD_ID, childId);
|
|
5066
|
-
if (typeof childElm["s-sn"] === "string" && !childElm.getAttribute("slot")) childElm.setAttribute("s-sn", childElm["s-sn"]);
|
|
5067
|
-
} else if (childElm.nodeType === NODE_TYPE.TextNode) {
|
|
5068
|
-
const parentNode = childElm.parentNode;
|
|
5069
|
-
const nodeName = parentNode?.nodeName;
|
|
5070
|
-
if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
|
|
5071
|
-
const textNodeId = `t.${childId}`;
|
|
5072
|
-
insertBefore(parentNode, doc.createComment(textNodeId), childElm);
|
|
5073
|
-
}
|
|
5074
|
-
} else if (childElm.nodeType === NODE_TYPE.CommentNode) {
|
|
5075
|
-
if (childElm["s-sr"]) childElm.nodeValue = `s.${childId}.${childElm["s-sn"] || ""}`;
|
|
5076
|
-
}
|
|
5077
|
-
if (vnodeChild.$children$ != null) {
|
|
5078
|
-
const childDepth = depth + 1;
|
|
5079
|
-
vnodeChild.$children$.forEach((vnode, childIndex) => {
|
|
5080
|
-
insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, childIndex);
|
|
5081
|
-
});
|
|
5082
|
-
}
|
|
5083
|
-
};
|
|
5084
|
-
//#endregion
|
|
5085
|
-
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, insertVdomAnnotations, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, renderVdom, 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 };
|