@stencil/core 5.0.0-beta.3 → 5.0.0-beta.30

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.
Files changed (36) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-BRu0GtRn.mjs → client-BYvfR_Hx.mjs} +127 -68
  3. package/dist/compiler/browser.d.ts +114 -81
  4. package/dist/compiler/browser.js +733 -336
  5. package/dist/compiler/index.d.mts +110 -2
  6. package/dist/compiler/index.mjs +3 -3
  7. package/dist/compiler/utils/index.d.mts +1 -1
  8. package/dist/{compiler-BPgV6bA4.mjs → compiler-6RhuOkQ0.mjs} +4829 -2895
  9. package/dist/declarations/stencil-public-compiler.d.ts +152 -129
  10. package/dist/declarations/stencil-public-docs.d.ts +23 -0
  11. package/dist/declarations/stencil-public-runtime.d.ts +60 -58
  12. package/dist/{index-DmHmu3y0.d.mts → index-BGUOG9Wc.d.mts} +6 -2
  13. package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
  14. package/dist/{index-BopBfjPu.d.mts → index-BogZpjP2.d.mts} +150 -127
  15. package/dist/index.d.mts +3 -0
  16. package/dist/index.mjs +1 -1
  17. package/dist/jsx-runtime.d.mts +6 -0
  18. package/dist/jsx-runtime.mjs +1 -1
  19. package/dist/{node-75gQKkFz.mjs → node-CvPPhnWO.mjs} +41 -47
  20. package/dist/runtime/client/lazy.js +252 -189
  21. package/dist/runtime/client/runtime.d.ts +71 -66
  22. package/dist/runtime/client/runtime.js +252 -189
  23. package/dist/runtime/index.d.ts +4 -5
  24. package/dist/runtime/index.js +250 -187
  25. package/dist/runtime/server/index.d.mts +11 -11
  26. package/dist/runtime/server/index.mjs +302 -228
  27. package/dist/runtime/server/runner.d.mts +4 -4
  28. package/dist/runtime/server/runner.mjs +82 -54
  29. package/dist/signals/index.d.ts +11 -2
  30. package/dist/signals/index.js +14 -35
  31. package/dist/sys/node/index.d.mts +1 -1
  32. package/dist/sys/node/index.mjs +1 -1
  33. package/dist/sys/node/worker.mjs +2 -2
  34. package/dist/testing/index.d.mts +136 -120
  35. package/dist/testing/index.mjs +259 -201
  36. package/package.json +8 -4
@@ -1,6 +1,105 @@
1
1
  import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/app-data";
2
2
  import { globalScripts, globalStyles } from "@stencil/core/app-globals";
3
- import { effect, effect as effect$1, signal } from "@preact/signals-core";
3
+ import * as SignalsCore from "@preact/signals-core";
4
+ //#region src/runtime/runtime-constants.ts
5
+ /**
6
+ * Bit flags for recording various properties of VDom nodes
7
+ */
8
+ const VNODE_FLAGS = {
9
+ /**
10
+ * Whether or not a vdom node is a slot reference
11
+ */
12
+ isSlotReference: 1,
13
+ /**
14
+ * Whether or not a slot element has fallback content
15
+ */
16
+ isSlotFallback: 2,
17
+ /**
18
+ * Whether or not an element is a host element
19
+ */
20
+ isHost: 4
21
+ };
22
+ const PROXY_FLAGS = {
23
+ isElementConstructor: 1,
24
+ proxyState: 2
25
+ };
26
+ const PLATFORM_FLAGS = {
27
+ /**
28
+ * designates a node in the DOM as being actively moved by the runtime
29
+ */
30
+ isTmpDisconnected: 1,
31
+ appLoaded: 2,
32
+ queueSync: 4,
33
+ queueMask: 6
34
+ };
35
+ /**
36
+ * A (subset) of node types which are relevant for the Stencil runtime. These
37
+ * values are based on the values which can possibly be returned by the
38
+ * `.nodeType` property of a DOM node. See here for details:
39
+ *
40
+ * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
41
+ */
42
+ const NODE_TYPE = {
43
+ ElementNode: 1,
44
+ TextNode: 3,
45
+ CommentNode: 8,
46
+ DocumentNode: 9,
47
+ DocumentTypeNode: 10,
48
+ DocumentFragment: 11
49
+ };
50
+ const HYDRATE_ID = "s-id";
51
+ const HYDRATED_STYLE_ID = "sty-id";
52
+ const HYDRATE_CHILD_ID = "c-id";
53
+ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
54
+ const STENCIL_DOC_DATA = "_stencilDocData";
55
+ const DEFAULT_DOC_DATA = {
56
+ hostIds: 0,
57
+ rootLevelIds: 0,
58
+ staticComponents: /* @__PURE__ */ new Set()
59
+ };
60
+ /**
61
+ * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
62
+ *
63
+ * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
64
+ * support as of Stencil v4.
65
+ */
66
+ const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
67
+ const XLINK_NS = "http://www.w3.org/1999/xlink";
68
+ /**
69
+ * Minimum delay, in milliseconds, before retrying a failed lazy component load.
70
+ */
71
+ const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
72
+ const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
73
+ "formAssociatedCallback",
74
+ "formResetCallback",
75
+ "formDisabledCallback",
76
+ "formStateRestoreCallback"
77
+ ];
78
+ const SERVER_BUILD_FLAGS = {
79
+ isBrowser: false,
80
+ isServer: true,
81
+ isDev: false,
82
+ isTesting: false
83
+ };
84
+ //#endregion
85
+ //#region src/runtime/tag-transform.ts
86
+ let tagTransformer = void 0;
87
+ /**
88
+ * Transforms a tag name using the current tag transformer
89
+ * @param tag - the tag to transform e.g. `my-tag`
90
+ * @returns the transformed tag e.g. `new-my-tag`
91
+ */
92
+ function transformTag(tag) {
93
+ if (!tagTransformer) return tag;
94
+ return tagTransformer(tag);
95
+ }
96
+ /**
97
+ * Sets the tag transformer to be used when rendering custom elements
98
+ * @param transformer the transformer function to use. Must return a string
99
+ */
100
+ function setTagTransformer(transformer) {
101
+ tagTransformer = transformer;
102
+ }
4
103
  const MEMBER_FLAGS = {
5
104
  String: 1,
6
105
  Number: 2,
@@ -253,81 +352,6 @@ const reWireGetterSetter = (instance, hostRef) => {
253
352
  });
254
353
  };
255
354
  //#endregion
256
- //#region src/runtime/runtime-constants.ts
257
- /**
258
- * Bit flags for recording various properties of VDom nodes
259
- */
260
- const VNODE_FLAGS = {
261
- /**
262
- * Whether or not a vdom node is a slot reference
263
- */
264
- isSlotReference: 1,
265
- /**
266
- * Whether or not a slot element has fallback content
267
- */
268
- isSlotFallback: 2,
269
- /**
270
- * Whether or not an element is a host element
271
- */
272
- isHost: 4
273
- };
274
- const PROXY_FLAGS = {
275
- isElementConstructor: 1,
276
- proxyState: 2
277
- };
278
- const PLATFORM_FLAGS = {
279
- /**
280
- * designates a node in the DOM as being actively moved by the runtime
281
- */
282
- isTmpDisconnected: 1,
283
- appLoaded: 2,
284
- queueSync: 4,
285
- queueMask: 6
286
- };
287
- /**
288
- * A (subset) of node types which are relevant for the Stencil runtime. These
289
- * values are based on the values which can possibly be returned by the
290
- * `.nodeType` property of a DOM node. See here for details:
291
- *
292
- * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
293
- */
294
- const NODE_TYPE = {
295
- ElementNode: 1,
296
- TextNode: 3,
297
- CommentNode: 8,
298
- DocumentNode: 9,
299
- DocumentTypeNode: 10,
300
- DocumentFragment: 11
301
- };
302
- const HYDRATE_ID = "s-id";
303
- const HYDRATED_STYLE_ID = "sty-id";
304
- const HYDRATE_CHILD_ID = "c-id";
305
- const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
306
- const STENCIL_DOC_DATA = "_stencilDocData";
307
- const DEFAULT_DOC_DATA = {
308
- hostIds: 0,
309
- rootLevelIds: 0,
310
- staticComponents: /* @__PURE__ */ new Set()
311
- };
312
- /**
313
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
314
- *
315
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
316
- * support as of Stencil v4.
317
- */
318
- const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
319
- const XLINK_NS = "http://www.w3.org/1999/xlink";
320
- /**
321
- * Minimum delay, in milliseconds, before retrying a failed lazy component load.
322
- */
323
- const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
324
- const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
325
- "formAssociatedCallback",
326
- "formResetCallback",
327
- "formDisabledCallback",
328
- "formStateRestoreCallback"
329
- ];
330
- //#endregion
331
355
  //#region src/utils/shadow-root.ts
332
356
  let globalStyleSheet;
333
357
  const GLOBAL_STYLE_ID = "sc-global";
@@ -1311,6 +1335,13 @@ const isComplexType = (o) => {
1311
1335
  return o === "object" || o === "function";
1312
1336
  };
1313
1337
  //#endregion
1338
+ //#region src/runtime/signals-core.ts
1339
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
1340
+ const effect = (fn, options) => getCore().effect(fn, options);
1341
+ function signal(value, options) {
1342
+ return getCore().signal(value, options);
1343
+ }
1344
+ //#endregion
1314
1345
  //#region src/runtime/event-emitter.ts
1315
1346
  const createEvent = (ref, name, flags) => {
1316
1347
  const elm = getElement(ref);
@@ -1337,6 +1368,11 @@ const emitEvent = (elm, name, opts) => {
1337
1368
  return ev;
1338
1369
  };
1339
1370
  const getRegistry = () => customElements;
1371
+ /**
1372
+ * @param elm a defined component host
1373
+ * @returns the registry the host's class was defined in, else the active registry
1374
+ */
1375
+ const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
1340
1376
  //#endregion
1341
1377
  //#region src/runtime/vdom/set-accessor.ts
1342
1378
  /**
@@ -1380,7 +1416,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1380
1416
  attrMap.get(memberName)?.();
1381
1417
  if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
1382
1418
  let prevVal = oldValue;
1383
- attrMap.set(memberName, effect$1(() => {
1419
+ attrMap.set(memberName, effect(() => {
1384
1420
  const curVal = newValue.value;
1385
1421
  setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
1386
1422
  prevVal = curVal;
@@ -1460,10 +1496,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1460
1496
  const isComplex = isComplexType(newValue);
1461
1497
  if (!BUILD$1.lazyLoad) {
1462
1498
  const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
1463
- if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && typeof customElements !== "undefined" && !customElements.get(elm.tagName.toLowerCase())) {
1499
+ if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
1464
1500
  if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
1465
1501
  elm["s-pp"].set(memberName, newValue);
1466
- return;
1502
+ if (isComplex || /[A-Z]/.test(memberName)) return;
1467
1503
  }
1468
1504
  }
1469
1505
  if ((isProp || isComplex && newValue !== null) && !isSvg) try {
@@ -1581,6 +1617,7 @@ function sortedAttrNames(attrNames) {
1581
1617
  let scopeId;
1582
1618
  let contentRef;
1583
1619
  let hostTagName;
1620
+ let hostRegistry;
1584
1621
  let useNativeShadowDom = false;
1585
1622
  let checkSlotFallbackVisibility = false;
1586
1623
  let checkSlotRelocate = false;
@@ -1597,16 +1634,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
1597
1634
  const disposeSignalVNode = (vnode) => {
1598
1635
  const elm = vnode.$elm$;
1599
1636
  if (elm) {
1600
- const dispose = signalNodeDisposers.get(elm);
1601
- if (dispose) {
1602
- dispose();
1603
- signalNodeDisposers.delete(elm);
1604
- }
1637
+ disposeTextSignal(elm);
1605
1638
  disposeAllSignalAttrs(elm);
1606
1639
  }
1607
1640
  vnode.$children$?.forEach(disposeSignalVNode);
1608
1641
  };
1609
1642
  /**
1643
+ * Tear down a text node's signal subscription, if it has one.
1644
+ * @param textNode the text node to unsubscribe
1645
+ */
1646
+ const disposeTextSignal = (textNode) => {
1647
+ const dispose = signalNodeDisposers.get(textNode);
1648
+ if (dispose) {
1649
+ dispose();
1650
+ signalNodeDisposers.delete(textNode);
1651
+ }
1652
+ };
1653
+ /**
1654
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
1655
+ * @param textNode the text node to keep in sync
1656
+ * @param textSig the signal to subscribe to
1657
+ */
1658
+ const wireTextSignal = (textNode, textSig) => {
1659
+ signalNodeDisposers.set(textNode, effect(() => {
1660
+ textNode.data = String(textSig.value);
1661
+ }));
1662
+ };
1663
+ /**
1610
1664
  * Create a DOM Node corresponding to one of the children of a given VNode.
1611
1665
  *
1612
1666
  * @param oldParentVNode the parent VNode from the previous render
@@ -1628,13 +1682,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1628
1682
  if (BUILD$1.isDev && newVNode.$elm$) newVNode.$text$ !== null ? `${newVNode.$text$}` : `${String(newVNode.$tag$)}`;
1629
1683
  if (BUILD$1.vdomText && newVNode.$text$ != null) {
1630
1684
  elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
1631
- if (BUILD$1.vdomSignals && newVNode.$signal$) {
1632
- const textSig = newVNode.$signal$;
1633
- const textNode = elm;
1634
- signalNodeDisposers.set(textNode, effect$1(() => {
1635
- textNode.data = String(textSig.value);
1636
- }));
1637
- }
1685
+ if (BUILD$1.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
1638
1686
  } else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1639
1687
  elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1640
1688
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -1643,8 +1691,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1643
1691
  if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
1644
1692
  if (!win.document) throw new Error("No DOM environment available for rendering.");
1645
1693
  const tag = !useNativeShadowDom && BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
1646
- const _reg = getRegistry();
1647
- const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
1694
+ const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
1648
1695
  elm = newVNode.$elm$ = BUILD$1.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
1649
1696
  if (BUILD$1.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
1650
1697
  if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
@@ -1902,7 +1949,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
1902
1949
  }
1903
1950
  if (BUILD$1.vdomKey && idxInOld >= 0) {
1904
1951
  elmToMove = oldCh[idxInOld];
1905
- if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
1952
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1906
1953
  else {
1907
1954
  patch(elmToMove, newStartVnode, isInitialRender);
1908
1955
  oldCh[idxInOld] = void 0;
@@ -1995,7 +2042,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
1995
2042
  else if (BUILD$1.hydrateClientSide && isInitialRender && BUILD$1.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
1996
2043
  if (BUILD$1.svg && isSvgMode && tag === "svg") isSvgMode = false;
1997
2044
  } else if (BUILD$1.vdomText && BUILD$1.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
1998
- else if (BUILD$1.vdomText && oldVNode.$text$ !== text) elm.data = text;
2045
+ else if (BUILD$1.vdomText) {
2046
+ if (BUILD$1.vdomSignals && newVNode.$signal$) {
2047
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
2048
+ disposeTextSignal(elm);
2049
+ wireTextSignal(elm, newVNode.$signal$);
2050
+ }
2051
+ } else {
2052
+ if (BUILD$1.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
2053
+ if (oldVNode.$text$ !== text) elm.data = text;
2054
+ }
2055
+ }
1999
2056
  };
2000
2057
  /**
2001
2058
  * Component-global information about nodes which are either currently being
@@ -2183,6 +2240,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2183
2240
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2184
2241
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2185
2242
  hostTagName = hostElm.tagName;
2243
+ hostRegistry = getHostRegistry(hostElm);
2186
2244
  if (BUILD$1.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
2187
2245
  Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2188
2246
 
@@ -2335,11 +2393,12 @@ const markFirstConnected = (hostRef) => {
2335
2393
  * autoloader, where the ancestor tag may not be defined yet.
2336
2394
  *
2337
2395
  * @param ancestorElm the nearest Stencil ancestor element
2396
+ * @param registry the registry the waiting component is defined in
2338
2397
  */
2339
- const awaitAncestorConnected = async (ancestorElm) => {
2398
+ const awaitAncestorConnected = async (ancestorElm, registry) => {
2340
2399
  let ancestorHostRef = getHostRef(ancestorElm);
2341
2400
  if (!BUILD$1.lazyLoad && !ancestorHostRef) {
2342
- await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2401
+ await registry.whenDefined(ancestorElm.tagName.toLowerCase());
2343
2402
  ancestorHostRef = getHostRef(ancestorElm);
2344
2403
  }
2345
2404
  if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
@@ -2695,8 +2754,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2695
2754
  const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
2696
2755
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
2697
2756
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
2698
- const initialVal = hostRef.$instanceValues$.get(memberName);
2699
- const sig = signal(initialVal);
2757
+ const sig = signal(hostRef.$instanceValues$.get(memberName));
2700
2758
  hostRef.$signalValues$.set(memberName, sig);
2701
2759
  let prevScheduleVal = sig.peek();
2702
2760
  disposers.push(effect(() => {
@@ -2875,17 +2933,23 @@ const vdomFnUtils = {
2875
2933
  * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
2876
2934
  * friendlier public interface (hence, 'convertToPublic').
2877
2935
  *
2878
- * @param node the virtual DOM node to convert
2936
+ * Functional components receive primitive children unwrapped, so those
2937
+ * become text-only child nodes.
2938
+ *
2939
+ * @param node the virtual DOM node (or primitive child) to convert
2879
2940
  * @returns a converted child node
2880
2941
  */
2881
- const convertToPublic = (node) => ({
2942
+ const convertToPublic = (node) => typeof node !== "object" ? {
2943
+ vtag: null,
2944
+ vtext: String(node)
2945
+ } : {
2882
2946
  vattrs: node.$attrs$,
2883
2947
  vchildren: node.$children$,
2884
2948
  vkey: node.$key$,
2885
2949
  vname: node.$name$,
2886
2950
  vtag: node.$tag$,
2887
2951
  vtext: node.$text$
2888
- });
2952
+ };
2889
2953
  /**
2890
2954
  * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
2891
2955
  * order to use the resulting object in the virtual DOM. The initial object was
@@ -2902,11 +2966,11 @@ const convertToPrivate = (node) => {
2902
2966
  if (node.vname) vnodeData.name = node.vname;
2903
2967
  return h(node.vtag, vnodeData, ...node.vchildren || []);
2904
2968
  }
2905
- const vnode = newVNode(node.vtag, node.vtext);
2906
- vnode.$attrs$ = node.vattrs;
2907
- vnode.$children$ = node.vchildren;
2908
- vnode.$key$ = node.vkey;
2909
- vnode.$name$ = node.vname;
2969
+ const vnode = newVNode(node.vtag ?? null, node.vtext);
2970
+ vnode.$attrs$ = node.vattrs ?? null;
2971
+ vnode.$children$ = node.vchildren ?? null;
2972
+ vnode.$key$ = node.vkey ?? null;
2973
+ vnode.$name$ = node.vname ?? null;
2910
2974
  return vnode;
2911
2975
  };
2912
2976
  /**
@@ -3204,6 +3268,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
3204
3268
  const createSimpleVNode = (vnode) => ({
3205
3269
  $flags$: 0,
3206
3270
  $index$: "0",
3271
+ $children$: null,
3207
3272
  ...vnode
3208
3273
  });
3209
3274
  function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
@@ -3598,7 +3663,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
3598
3663
  else return shallowPart.trim();
3599
3664
  }).join(", ");
3600
3665
  };
3601
- const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
3666
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
3602
3667
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
3603
3668
  return processRules(cssText, (rule) => {
3604
3669
  let selector = rule.selector;
@@ -3717,8 +3782,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
3717
3782
  };
3718
3783
  //#endregion
3719
3784
  //#region src/runtime/mode.ts
3720
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
3721
- const setMode = (handler) => modeResolutionChain.push(handler);
3785
+ const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
3786
+ const setMode = (handler) => {
3787
+ modeResolver.length = 0;
3788
+ modeResolver.push(handler);
3789
+ };
3722
3790
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
3723
3791
  //#endregion
3724
3792
  //#region src/runtime/normalize-watchers.ts
@@ -3783,23 +3851,14 @@ const normalizeWatchers = (raw) => {
3783
3851
  *
3784
3852
  * @param propValue the new value to coerce to some type
3785
3853
  * @param propType the type of the prop, expressed as a binary number
3786
- * @param isFormAssociated whether the component is form-associated (optional)
3787
3854
  * @returns the parsed/coerced value
3788
3855
  */
3789
- const parsePropertyValue = (propValue, propType, isFormAssociated) => {
3856
+ const parsePropertyValue = (propValue, propType) => {
3790
3857
  if (propValue != null && !isComplexType(propValue)) {
3791
3858
  /**
3792
3859
  * ensure this value is of the correct prop type
3793
3860
  */
3794
- if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
3795
- /**
3796
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
3797
- * (regardless of its value, even "false") should make the property true.
3798
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3799
- */
3800
- if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3801
- else return propValue === "false" ? false : propValue === "" || !!propValue;
3802
- }
3861
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
3803
3862
  /**
3804
3863
  * force it to be a number
3805
3864
  */
@@ -3841,7 +3900,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3841
3900
  if (BUILD$1.signalBacking) {
3842
3901
  const sig = hostRef?.$signalValues$?.get(propName);
3843
3902
  if (sig !== void 0) {
3844
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
3903
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3845
3904
  if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
3846
3905
  const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
3847
3906
  applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
@@ -3859,7 +3918,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3859
3918
  const oldVal = hostRef.$instanceValues$.get(propName);
3860
3919
  const flags = hostRef.$flags$;
3861
3920
  const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
3862
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
3921
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3863
3922
  const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3864
3923
  if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3865
3924
  hostRef.$instanceValues$.set(propName, newVal);
@@ -3908,6 +3967,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3908
3967
  */
3909
3968
  const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
3910
3969
  /**
3970
+ * Hand values written to a lazy component's element before its instance existed to the
3971
+ * instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
3972
+ * whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
3973
+ *
3974
+ * @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
3975
+ * @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
3976
+ */
3977
+ const replayPendingSetterValues = (hostRef, cmpMeta) => {
3978
+ const instance = hostRef.$lazyInstance$;
3979
+ if (!instance) return;
3980
+ for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
3981
+ const pendingValue = hostRef.$instanceValues$.get(memberName);
3982
+ if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
3983
+ }
3984
+ };
3985
+ /**
3911
3986
  * Attach a series of runtime constructs to a compiled Stencil component
3912
3987
  * constructor, including getters and setters for the `@Prop` and `@State`
3913
3988
  * decorators, callbacks for when attributes change, and so on.
@@ -3964,9 +4039,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3964
4039
  if (BUILD$1.lazyLoad) {
3965
4040
  if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
3966
4041
  const ref = getHostRef(this);
3967
- const instance = ref ? ref.$lazyInstance$ : prototype;
3968
- if (!instance) return;
3969
- return instance[memberName];
4042
+ if (!ref) return prototype[memberName];
4043
+ return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
3970
4044
  }
3971
4045
  if (!BUILD$1.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
3972
4046
  },
@@ -3981,7 +4055,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3981
4055
  }
3982
4056
  if (origSetter) {
3983
4057
  if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
3984
- origSetter.apply(this, [parsePropertyValue(newValue, memberFlags, BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated))]);
4058
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
3985
4059
  newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
3986
4060
  setValue(this, memberName, newValue, cmpMeta);
3987
4061
  return;
@@ -3993,21 +4067,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3993
4067
  if (BUILD$1.lazyLoad) {
3994
4068
  if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
3995
4069
  setValue(this, memberName, newValue, cmpMeta);
3996
- if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
3997
- if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
3998
- });
3999
4070
  return;
4000
4071
  }
4001
- const setterSetVal = () => {
4072
+ const parsedValue = parsePropertyValue(newValue, memberFlags);
4073
+ if (ref.$lazyInstance$) {
4002
4074
  const currentValue = ref.$lazyInstance$[memberName];
4003
4075
  if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
4004
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags, BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4076
+ ref.$lazyInstance$[memberName] = parsedValue;
4005
4077
  setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
4006
- };
4007
- if (ref.$lazyInstance$) setterSetVal();
4008
- else ref.$fetchedCbList$.push(() => {
4009
- setterSetVal();
4010
- });
4078
+ } else ref.$instanceValues$.set(memberName, parsedValue);
4011
4079
  }
4012
4080
  } });
4013
4081
  } else if (BUILD$1.lazyLoad && BUILD$1.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
@@ -4059,7 +4127,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4059
4127
  const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4060
4128
  if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4061
4129
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4062
- if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4130
+ if (isBooleanTarget) {
4131
+ if (BUILD$1.isDev && newValue === "false") `${cmpMeta.$tagName$}${attrName}${propName}`;
4132
+ newValue = newValue !== null;
4133
+ }
4063
4134
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
4064
4135
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4065
4136
  });
@@ -4122,9 +4193,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4122
4193
  } catch (e) {
4123
4194
  consoleError(e, elm);
4124
4195
  }
4125
- if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4196
+ if (BUILD$1.member) {
4197
+ hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4198
+ replayPendingSetterValues(hostRef, cmpMeta);
4199
+ }
4126
4200
  endNewInstance();
4127
- if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4201
+ if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4128
4202
  if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4129
4203
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4130
4204
  if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
@@ -4224,9 +4298,16 @@ const connectedCallback = (elm) => {
4224
4298
  }
4225
4299
  if (BUILD$1.asyncLoading) {
4226
4300
  let ancestorComponent = elm;
4227
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) if (BUILD$1.hydrateClientSide && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
4228
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4229
- break;
4301
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
4302
+ if (BUILD$1.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
4303
+ ancestorComponent["s-p"] = [];
4304
+ ancestorComponent["s-rc"] = [];
4305
+ ancestorComponent["s-pc"] = [];
4306
+ }
4307
+ if (ancestorComponent["s-p"]) {
4308
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4309
+ break;
4310
+ }
4230
4311
  }
4231
4312
  }
4232
4313
  if (BUILD$1.prop && !BUILD$1.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
@@ -4342,48 +4423,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4342
4423
  `${modulePath}?s-hmr=${hmrVersionId}`
4343
4424
  );
4344
4425
  const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4345
- if (!NewClass) return;
4346
- const ctor = customElements.get(cmpMeta.$tagName$);
4347
- if (ctor) {
4348
- for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4349
- if (key === "constructor") continue;
4350
- Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4351
- }
4352
- const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4353
- if (styleDesc) {
4354
- Object.defineProperty(ctor, "style", styleDesc);
4355
- const newStyle = NewClass.style;
4356
- if (newStyle) {
4357
- const scopeId = getScopeId(cmpMeta);
4358
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4359
- console.log("[stencil-hmr] registerStyle", {
4360
- tag: cmpMeta.$tagName$,
4361
- scopeId,
4362
- isShadow,
4363
- cssLen: newStyle.length
4364
- });
4365
- registerStyle(scopeId, newStyle, isShadow);
4366
- }
4367
- }
4368
- }
4369
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4370
- document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4371
- const hostRef = getHostRef(el);
4372
- if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
4373
- hostRef.$rmListeners$.map((rmListener) => rmListener());
4374
- hostRef.$rmListeners$ = void 0;
4375
- addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4376
- }
4377
- if (!isShadow && hostRef) {
4378
- console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
4379
- attachStyles(hostRef);
4380
- }
4381
- forceUpdate(el);
4382
- });
4426
+ if (NewClass) hmrApplyClass(cmpMeta, NewClass);
4383
4427
  } catch (e) {
4384
4428
  console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
4385
4429
  }
4386
4430
  };
4431
+ /**
4432
+ * Patch a re-executed component class onto the registered one and re-render every live instance.
4433
+ * Shared by the standalone re-import above and bundlers that re-execute the module themselves
4434
+ * (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
4435
+ *
4436
+ * @param cmpMeta runtime metadata for the component
4437
+ * @param NewClass the component's newly executed class
4438
+ */
4439
+ const hmrApplyClass = (cmpMeta, NewClass) => {
4440
+ const ctor = customElements.get(cmpMeta.$tagName$);
4441
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4442
+ if (ctor && ctor !== NewClass) {
4443
+ for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4444
+ if (key === "constructor") continue;
4445
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4446
+ }
4447
+ const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4448
+ if (styleDesc) {
4449
+ Object.defineProperty(ctor, "style", styleDesc);
4450
+ const newStyle = NewClass.style;
4451
+ if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
4452
+ }
4453
+ }
4454
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4455
+ const hostRef = getHostRef(el);
4456
+ if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
4457
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4458
+ hostRef.$rmListeners$ = void 0;
4459
+ addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4460
+ }
4461
+ if (!isShadow && hostRef) attachStyles(hostRef);
4462
+ forceUpdate(el);
4463
+ });
4464
+ };
4387
4465
  //#endregion
4388
4466
  //#region src/runtime/bootstrap-standalone.ts
4389
4467
  const defineCustomElement = (Cstr, compactMeta) => {
@@ -4406,9 +4484,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4406
4484
  cmpMeta.$serializers$ = Cstr.$serializers$;
4407
4485
  }
4408
4486
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
4409
- if (BUILD$1.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4410
- hmrStart(this, cmpMeta, hmrVersionId);
4411
- };
4487
+ if (BUILD$1.hotModuleReplacement) {
4488
+ Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4489
+ hmrStart(this, cmpMeta, hmrVersionId);
4490
+ };
4491
+ Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
4492
+ }
4412
4493
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4413
4494
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4414
4495
  if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
@@ -4447,7 +4528,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4447
4528
  }
4448
4529
  connectedCallback(this);
4449
4530
  if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4450
- await awaitAncestorConnected(hostRef.$ancestorComponent$);
4531
+ await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
4451
4532
  if (!this.isConnected) return;
4452
4533
  }
4453
4534
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
@@ -4759,31 +4840,12 @@ function Mixin(...mixins) {
4759
4840
  //#region src/runtime/nonce.ts
4760
4841
  /**
4761
4842
  * Assigns the given value to the nonce property on the runtime platform object.
4762
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
4843
+ * During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
4763
4844
  * @param nonce The value to be assigned to the platform nonce property.
4764
4845
  * @returns void
4765
4846
  */
4766
4847
  const setNonce = (nonce) => plt.$nonce$ = nonce;
4767
4848
  //#endregion
4768
- //#region src/runtime/tag-transform.ts
4769
- let tagTransformer = void 0;
4770
- /**
4771
- * Transforms a tag name using the current tag transformer
4772
- * @param tag - the tag to transform e.g. `my-tag`
4773
- * @returns the transformed tag e.g. `new-my-tag`
4774
- */
4775
- function transformTag(tag) {
4776
- if (!tagTransformer) return tag;
4777
- return tagTransformer(tag);
4778
- }
4779
- /**
4780
- * Sets the tag transformer to be used when rendering custom elements
4781
- * @param transformer the transformer function to use. Must return a string
4782
- */
4783
- function setTagTransformer(transformer) {
4784
- tagTransformer = transformer;
4785
- }
4786
- //#endregion
4787
4849
  //#region src/runtime/vdom/jsx-runtime.ts
4788
4850
  function jsx(type, props, key) {
4789
4851
  const { children, ...rest } = props ?? {};
@@ -4998,7 +5060,7 @@ function proxyHostElement(elm, cstr) {
4998
5060
  const [[methodName]] = Object.entries(deserializer);
4999
5061
  attrPropVal = cstr.prototype[methodName](attrValue, memberName);
5000
5062
  }
5001
- else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
5063
+ else attrPropVal = parsePropertyValue(attrValue, memberFlags);
5002
5064
  }
5003
5065
  if (propValue !== void 0) {
5004
5066
  attrPropVal = propValue;
@@ -5065,8 +5127,9 @@ function forceUpdate$1() {}
5065
5127
  * @param results The results object to store the hydration results.
5066
5128
  * @param afterSsr The callback to be called after SSR is complete.
5067
5129
  * @param resolve The resolve function to be called when SSR is complete.
5130
+ * @param abortController The AbortController to use for aborting in-flight fetch() calls and other cancellable work when SSR times out.
5068
5131
  */
5069
- function ssrApp(win, opts, results, afterSsr, resolve) {
5132
+ function ssrApp(win, opts, results, afterSsr, resolve, abortController) {
5070
5133
  const connectedElements = /* @__PURE__ */ new Set();
5071
5134
  const createdElements = /* @__PURE__ */ new Set();
5072
5135
  const waitingElements = /* @__PURE__ */ new Set();
@@ -5076,10 +5139,20 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
5076
5139
  setScopedSsr(opts);
5077
5140
  let tmrId;
5078
5141
  let ranCompleted = false;
5142
+ let modeResolverSnapshot;
5143
+ const abortedPromise = new Promise((res) => {
5144
+ if (abortController.signal.aborted) res();
5145
+ else abortController.signal.addEventListener("abort", () => res(), { once: true });
5146
+ });
5079
5147
  function hydratedComplete() {
5080
5148
  $nativeClearTimeout(tmrId);
5081
5149
  createdElements.clear();
5082
5150
  connectedElements.clear();
5151
+ if (modeResolverSnapshot) {
5152
+ modeResolver.length = 0;
5153
+ modeResolver.push(...modeResolverSnapshot);
5154
+ modeResolverSnapshot = void 0;
5155
+ }
5083
5156
  if (!ranCompleted) {
5084
5157
  ranCompleted = true;
5085
5158
  try {
@@ -5095,6 +5168,7 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
5095
5168
  }
5096
5169
  function hydratedError(err) {
5097
5170
  renderCatchError(opts, results, err);
5171
+ abortController.abort();
5098
5172
  hydratedComplete();
5099
5173
  }
5100
5174
  function timeoutExceeded() {
@@ -5139,7 +5213,7 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
5139
5213
  if (isValidComponent(elm, opts) && results.hydratedCount < opts.maxHydrateCount) {
5140
5214
  if (!connectedElements.has(elm) && shouldHydrate(elm)) {
5141
5215
  connectedElements.add(elm);
5142
- return hydrateComponent.call(elm, win, results, elm.nodeName, elm, waitingElements);
5216
+ return hydrateComponent.call(elm, win, results, elm.nodeName, elm, waitingElements, abortedPromise);
5143
5217
  }
5144
5218
  }
5145
5219
  return resolved;
@@ -5162,13 +5236,17 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
5162
5236
  tmrId = $nativeSetTimeout(timeoutExceeded, opts.timeout);
5163
5237
  plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", win.document.baseURI).href;
5164
5238
  globalScripts();
5239
+ if (Array.isArray(opts.modes)) {
5240
+ modeResolverSnapshot = modeResolver.slice();
5241
+ opts.modes.forEach((mode) => setMode(mode));
5242
+ }
5165
5243
  patchChild(win.document.body);
5166
5244
  waitLoop().then(hydratedComplete).catch(hydratedError);
5167
5245
  } catch (e) {
5168
5246
  hydratedError(e);
5169
5247
  }
5170
5248
  }
5171
- async function hydrateComponent(win, results, tagName, elm, waitingElements) {
5249
+ async function hydrateComponent(win, results, tagName, elm, waitingElements, aborted) {
5172
5250
  tagName = tagName.toLowerCase();
5173
5251
  const Cstr = loadModule({
5174
5252
  $tagName$: tagName,
@@ -5183,16 +5261,17 @@ async function hydrateComponent(win, results, tagName, elm, waitingElements) {
5183
5261
  addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
5184
5262
  try {
5185
5263
  connectedCallback(elm);
5186
- await elm.componentOnReady();
5187
- results.hydratedCount++;
5188
- const ref = getHostRef(elm);
5189
- const modeName = !ref?.$modeName$ ? "$" : ref?.$modeName$;
5190
- if (!results.components.some((c) => c.tag === tagName && c.mode === modeName)) results.components.push({
5191
- tag: tagName,
5192
- mode: modeName,
5193
- count: 0,
5194
- depth: -1
5195
- });
5264
+ if (!await Promise.race([elm.componentOnReady().then(() => false), aborted.then(() => true)])) {
5265
+ results.hydratedCount++;
5266
+ const ref = getHostRef(elm);
5267
+ const modeName = !ref?.$modeName$ ? "$" : ref?.$modeName$;
5268
+ if (!results.components.some((c) => c.tag === tagName && c.mode === modeName)) results.components.push({
5269
+ tag: tagName,
5270
+ mode: modeName,
5271
+ count: 0,
5272
+ depth: -1
5273
+ });
5274
+ }
5196
5275
  } catch (e) {
5197
5276
  win.console.error(e);
5198
5277
  }
@@ -5338,7 +5417,7 @@ const isMemberInElement = (elm, memberName) => {
5338
5417
  const registerComponents = (Cstrs) => {
5339
5418
  for (const Cstr of Cstrs) {
5340
5419
  const exportName = Cstr.cmpMeta.$tagName$;
5341
- const transformedTagName = $stencilTagTransform.transformTag(exportName);
5420
+ const transformedTagName = transformTag(exportName);
5342
5421
  cmpModules.set(exportName, { [exportName]: Cstr });
5343
5422
  if (transformedTagName !== exportName) cmpModules.set(transformedTagName, { [transformedTagName]: Cstr });
5344
5423
  }
@@ -5414,14 +5493,9 @@ const registerHost = (elm, cmpMeta) => {
5414
5493
  elm.__s_ghr = () => hostRef;
5415
5494
  return hostRef;
5416
5495
  };
5417
- const Build = {
5418
- isDev: false,
5419
- isBrowser: false,
5420
- isServer: true,
5421
- isTesting: false
5422
- };
5496
+ const Build = { ...SERVER_BUILD_FLAGS };
5423
5497
  const styles = /* @__PURE__ */ new Map();
5424
- const modeResolutionChain = [];
5498
+ const modeResolver = [];
5425
5499
  /**
5426
5500
  * Server-side implementation of getAssetPath.
5427
5501
  *
@@ -5453,4 +5527,4 @@ const setScopedSsr = (opts) => {
5453
5527
  const needsScopedSSR = () => scopedSSR;
5454
5528
  let scopedSSR = false;
5455
5529
  //#endregion
5456
- export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, registerSideEffectStyleTarget, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
5530
+ export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, registerSideEffectStyleTarget, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };