@stencil/core 5.0.0-beta.2 → 5.0.0-beta.20

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 (35) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-BRu0GtRn.mjs → client-CVXS3JZ-.mjs} +105 -60
  3. package/dist/compiler/browser.d.ts +110 -79
  4. package/dist/compiler/browser.js +542 -241
  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-C8yf59oh.mjs → compiler-CUsOl_Kw.mjs} +4428 -2709
  9. package/dist/declarations/stencil-public-compiler.d.ts +144 -120
  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-BopBfjPu.d.mts → index-B9-Byy8z.d.mts} +142 -118
  13. package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
  14. package/dist/{index-DmHmu3y0.d.mts → index-Dz1G9pWZ.d.mts} +2 -2
  15. package/dist/index.d.mts +3 -0
  16. package/dist/index.mjs +1 -1
  17. package/dist/jsx-runtime.mjs +1 -1
  18. package/dist/{node-75gQKkFz.mjs → node-Bz2SOK7_.mjs} +6 -35
  19. package/dist/runtime/client/lazy.js +228 -180
  20. package/dist/runtime/client/runtime.d.ts +67 -66
  21. package/dist/runtime/client/runtime.js +228 -180
  22. package/dist/runtime/index.d.ts +4 -5
  23. package/dist/runtime/index.js +226 -178
  24. package/dist/runtime/server/index.d.mts +11 -11
  25. package/dist/runtime/server/index.mjs +287 -220
  26. package/dist/runtime/server/runner.d.mts +4 -4
  27. package/dist/runtime/server/runner.mjs +82 -54
  28. package/dist/signals/index.d.ts +11 -2
  29. package/dist/signals/index.js +11 -1
  30. package/dist/sys/node/index.d.mts +1 -1
  31. package/dist/sys/node/index.mjs +1 -1
  32. package/dist/sys/node/worker.mjs +2 -2
  33. package/dist/testing/index.d.mts +129 -112
  34. package/dist/testing/index.mjs +244 -193
  35. package/package.json +8 -4
@@ -1,17 +1,86 @@
1
1
  import { BUILD as BUILD$1, Env, NAMESPACE } from "@stencil/core/app-data";
2
2
  import { 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
4
  //#region src/app-data/lazy.ts
5
5
  const BUILD = {
6
6
  ...BUILD$1,
7
7
  lazyLoad: true
8
8
  };
9
9
  //#endregion
10
+ //#region src/runtime/runtime-constants.ts
11
+ /**
12
+ * Bit flags for recording various properties of VDom nodes
13
+ */
14
+ const VNODE_FLAGS = {
15
+ /**
16
+ * Whether or not a vdom node is a slot reference
17
+ */
18
+ isSlotReference: 1,
19
+ /**
20
+ * Whether or not a slot element has fallback content
21
+ */
22
+ isSlotFallback: 2,
23
+ /**
24
+ * Whether or not an element is a host element
25
+ */
26
+ isHost: 4
27
+ };
28
+ const PROXY_FLAGS = {
29
+ isElementConstructor: 1,
30
+ proxyState: 2
31
+ };
32
+ const PLATFORM_FLAGS = {
33
+ /**
34
+ * designates a node in the DOM as being actively moved by the runtime
35
+ */
36
+ isTmpDisconnected: 1,
37
+ appLoaded: 2,
38
+ queueSync: 4,
39
+ queueMask: 6
40
+ };
41
+ /**
42
+ * A (subset) of node types which are relevant for the Stencil runtime. These
43
+ * values are based on the values which can possibly be returned by the
44
+ * `.nodeType` property of a DOM node. See here for details:
45
+ *
46
+ * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
47
+ */
48
+ const NODE_TYPE = {
49
+ ElementNode: 1,
50
+ TextNode: 3,
51
+ CommentNode: 8,
52
+ DocumentNode: 9,
53
+ DocumentTypeNode: 10,
54
+ DocumentFragment: 11
55
+ };
56
+ const HYDRATE_ID = "s-id";
57
+ const HYDRATED_STYLE_ID = "sty-id";
58
+ const HYDRATE_CHILD_ID = "c-id";
59
+ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
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
+ //#endregion
10
79
  //#region src/client/client-build.ts
11
80
  const Build = {
12
- isDev: BUILD.isDev,
13
81
  isBrowser: true,
14
82
  isServer: false,
83
+ isDev: BUILD.isDev,
15
84
  isTesting: BUILD.isTesting
16
85
  };
17
86
  //#endregion
@@ -494,79 +563,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
494
563
  //#endregion
495
564
  //#region src/client/client-style.ts
496
565
  const styles = /*@__PURE__*/ new Map();
497
- const modeResolutionChain = [];
498
- const setScopedSsr = (_opts) => {};
566
+ const modeResolver = [];
567
+ const setScopedSSR = (_opts) => {};
499
568
  const needsScopedSSR = () => false;
500
569
  //#endregion
501
- //#region src/runtime/runtime-constants.ts
502
- /**
503
- * Bit flags for recording various properties of VDom nodes
504
- */
505
- const VNODE_FLAGS = {
506
- /**
507
- * Whether or not a vdom node is a slot reference
508
- */
509
- isSlotReference: 1,
510
- /**
511
- * Whether or not a slot element has fallback content
512
- */
513
- isSlotFallback: 2,
514
- /**
515
- * Whether or not an element is a host element
516
- */
517
- isHost: 4
518
- };
519
- const PROXY_FLAGS = {
520
- isElementConstructor: 1,
521
- proxyState: 2
522
- };
523
- const PLATFORM_FLAGS = {
524
- /**
525
- * designates a node in the DOM as being actively moved by the runtime
526
- */
527
- isTmpDisconnected: 1,
528
- appLoaded: 2,
529
- queueSync: 4,
530
- queueMask: 6
531
- };
532
- /**
533
- * A (subset) of node types which are relevant for the Stencil runtime. These
534
- * values are based on the values which can possibly be returned by the
535
- * `.nodeType` property of a DOM node. See here for details:
536
- *
537
- * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
538
- */
539
- const NODE_TYPE = {
540
- ElementNode: 1,
541
- TextNode: 3,
542
- CommentNode: 8,
543
- DocumentNode: 9,
544
- DocumentTypeNode: 10,
545
- DocumentFragment: 11
546
- };
547
- const HYDRATE_ID = "s-id";
548
- const HYDRATED_STYLE_ID = "sty-id";
549
- const HYDRATE_CHILD_ID = "c-id";
550
- const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
551
- /**
552
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
553
- *
554
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
555
- * support as of Stencil v4.
556
- */
557
- const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
558
- const XLINK_NS = "http://www.w3.org/1999/xlink";
559
- /**
560
- * Minimum delay, in milliseconds, before retrying a failed lazy component load.
561
- */
562
- const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
563
- const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
564
- "formAssociatedCallback",
565
- "formResetCallback",
566
- "formDisabledCallback",
567
- "formStateRestoreCallback"
568
- ];
569
- //#endregion
570
570
  //#region src/client/client-window.ts
571
571
  const win = typeof window !== "undefined" ? window : {};
572
572
  const H = win.HTMLElement || class {};
@@ -607,7 +607,7 @@ let queuePending = false;
607
607
  const queueDomReads = [];
608
608
  const queueDomWrites = [];
609
609
  const queueDomWritesLow = [];
610
- const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
610
+ const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
611
611
  const queueTask = (queue, write) => (cb) => {
612
612
  queue.push(cb);
613
613
  if (!queuePending) {
@@ -1691,6 +1691,13 @@ const isComplexType = (o) => {
1691
1691
  return o === "object" || o === "function";
1692
1692
  };
1693
1693
  //#endregion
1694
+ //#region src/runtime/signals-core.ts
1695
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
1696
+ const effect = (fn, options) => getCore().effect(fn, options);
1697
+ function signal(value, options) {
1698
+ return getCore().signal(value, options);
1699
+ }
1700
+ //#endregion
1694
1701
  //#region src/runtime/event-emitter.ts
1695
1702
  const createEvent = (ref, name, flags) => {
1696
1703
  const elm = getElement(ref);
@@ -1723,6 +1730,11 @@ const setRegistry = (registry) => {
1723
1730
  _registry = registry;
1724
1731
  };
1725
1732
  const getRegistry = () => _registry ?? customElements;
1733
+ /**
1734
+ * @param elm a defined component host
1735
+ * @returns the registry the host's class was defined in, else the active registry
1736
+ */
1737
+ const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
1726
1738
  //#endregion
1727
1739
  //#region src/runtime/vdom/set-accessor.ts
1728
1740
  /**
@@ -1766,7 +1778,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1766
1778
  attrMap.get(memberName)?.();
1767
1779
  if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
1768
1780
  let prevVal = oldValue;
1769
- attrMap.set(memberName, effect$1(() => {
1781
+ attrMap.set(memberName, effect(() => {
1770
1782
  const curVal = newValue.value;
1771
1783
  setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
1772
1784
  prevVal = curVal;
@@ -1846,10 +1858,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1846
1858
  const isComplex = isComplexType(newValue);
1847
1859
  if (!BUILD.lazyLoad) {
1848
1860
  const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
1849
- if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && typeof customElements !== "undefined" && !customElements.get(elm.tagName.toLowerCase())) {
1861
+ if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
1850
1862
  if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
1851
1863
  elm["s-pp"].set(memberName, newValue);
1852
- return;
1864
+ if (isComplex || /[A-Z]/.test(memberName)) return;
1853
1865
  }
1854
1866
  }
1855
1867
  if ((isProp || isComplex && newValue !== null) && !isSvg) try {
@@ -1967,6 +1979,7 @@ function sortedAttrNames(attrNames) {
1967
1979
  let scopeId;
1968
1980
  let contentRef;
1969
1981
  let hostTagName;
1982
+ let hostRegistry;
1970
1983
  let useNativeShadowDom = false;
1971
1984
  let checkSlotFallbackVisibility = false;
1972
1985
  let checkSlotRelocate = false;
@@ -1983,16 +1996,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
1983
1996
  const disposeSignalVNode = (vnode) => {
1984
1997
  const elm = vnode.$elm$;
1985
1998
  if (elm) {
1986
- const dispose = signalNodeDisposers.get(elm);
1987
- if (dispose) {
1988
- dispose();
1989
- signalNodeDisposers.delete(elm);
1990
- }
1999
+ disposeTextSignal(elm);
1991
2000
  disposeAllSignalAttrs(elm);
1992
2001
  }
1993
2002
  vnode.$children$?.forEach(disposeSignalVNode);
1994
2003
  };
1995
2004
  /**
2005
+ * Tear down a text node's signal subscription, if it has one.
2006
+ * @param textNode the text node to unsubscribe
2007
+ */
2008
+ const disposeTextSignal = (textNode) => {
2009
+ const dispose = signalNodeDisposers.get(textNode);
2010
+ if (dispose) {
2011
+ dispose();
2012
+ signalNodeDisposers.delete(textNode);
2013
+ }
2014
+ };
2015
+ /**
2016
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
2017
+ * @param textNode the text node to keep in sync
2018
+ * @param textSig the signal to subscribe to
2019
+ */
2020
+ const wireTextSignal = (textNode, textSig) => {
2021
+ signalNodeDisposers.set(textNode, effect(() => {
2022
+ textNode.data = String(textSig.value);
2023
+ }));
2024
+ };
2025
+ /**
1996
2026
  * Create a DOM Node corresponding to one of the children of a given VNode.
1997
2027
  *
1998
2028
  * @param oldParentVNode the parent VNode from the previous render
@@ -2014,13 +2044,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
2014
2044
  if (BUILD.isDev && newVNode.$elm$) consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${String(newVNode.$tag$)}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
2015
2045
  if (BUILD.vdomText && newVNode.$text$ != null) {
2016
2046
  elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
2017
- if (BUILD.vdomSignals && newVNode.$signal$) {
2018
- const textSig = newVNode.$signal$;
2019
- const textNode = elm;
2020
- signalNodeDisposers.set(textNode, effect$1(() => {
2021
- textNode.data = String(textSig.value);
2022
- }));
2023
- }
2047
+ if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
2024
2048
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
2025
2049
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
2026
2050
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -2029,8 +2053,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
2029
2053
  if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
2030
2054
  if (!win.document) throw new Error("No DOM environment available for rendering.");
2031
2055
  const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
2032
- const _reg = getRegistry();
2033
- const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
2056
+ const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
2034
2057
  elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
2035
2058
  if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
2036
2059
  if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
@@ -2288,7 +2311,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
2288
2311
  }
2289
2312
  if (BUILD.vdomKey && idxInOld >= 0) {
2290
2313
  elmToMove = oldCh[idxInOld];
2291
- if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
2314
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
2292
2315
  else {
2293
2316
  patch(elmToMove, newStartVnode, isInitialRender);
2294
2317
  oldCh[idxInOld] = void 0;
@@ -2381,7 +2404,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
2381
2404
  else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
2382
2405
  if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
2383
2406
  } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
2384
- else if (BUILD.vdomText && oldVNode.$text$ !== text) elm.data = text;
2407
+ else if (BUILD.vdomText) {
2408
+ if (BUILD.vdomSignals && newVNode.$signal$) {
2409
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
2410
+ disposeTextSignal(elm);
2411
+ wireTextSignal(elm, newVNode.$signal$);
2412
+ }
2413
+ } else {
2414
+ if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
2415
+ if (oldVNode.$text$ !== text) elm.data = text;
2416
+ }
2417
+ }
2385
2418
  };
2386
2419
  /**
2387
2420
  * Component-global information about nodes which are either currently being
@@ -2569,6 +2602,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2569
2602
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2570
2603
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2571
2604
  hostTagName = hostElm.tagName;
2605
+ hostRegistry = getHostRegistry(hostElm);
2572
2606
  if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
2573
2607
  Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2574
2608
 
@@ -2721,11 +2755,12 @@ const markFirstConnected = (hostRef) => {
2721
2755
  * autoloader, where the ancestor tag may not be defined yet.
2722
2756
  *
2723
2757
  * @param ancestorElm the nearest Stencil ancestor element
2758
+ * @param registry the registry the waiting component is defined in
2724
2759
  */
2725
- const awaitAncestorConnected = async (ancestorElm) => {
2760
+ const awaitAncestorConnected = async (ancestorElm, registry) => {
2726
2761
  let ancestorHostRef = getHostRef(ancestorElm);
2727
2762
  if (!BUILD.lazyLoad && !ancestorHostRef) {
2728
- await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2763
+ await registry.whenDefined(ancestorElm.tagName.toLowerCase());
2729
2764
  ancestorHostRef = getHostRef(ancestorElm);
2730
2765
  }
2731
2766
  if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
@@ -3081,8 +3116,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3081
3116
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3082
3117
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
3083
3118
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
3084
- const initialVal = hostRef.$instanceValues$.get(memberName);
3085
- const sig = signal(initialVal);
3119
+ const sig = signal(hostRef.$instanceValues$.get(memberName));
3086
3120
  hostRef.$signalValues$.set(memberName, sig);
3087
3121
  let prevScheduleVal = sig.peek();
3088
3122
  disposers.push(effect(() => {
@@ -3210,9 +3244,7 @@ const h = (nodeName, vnodeData, ...children) => {
3210
3244
  if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
3211
3245
  }
3212
3246
  }
3213
- if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component. Make sure:
3214
- - You are NOT using hostData() and <Host> in the same component.
3215
- - <Host> is used once, and it's the single root component of the render() function.`);
3247
+ if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
3216
3248
  if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
3217
3249
  const vnode = newVNode(nodeName, null);
3218
3250
  vnode.$attrs$ = vnodeData;
@@ -3988,7 +4020,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
3988
4020
  else return shallowPart.trim();
3989
4021
  }).join(", ");
3990
4022
  };
3991
- const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
4023
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
3992
4024
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
3993
4025
  return processRules(cssText, (rule) => {
3994
4026
  let selector = rule.selector;
@@ -4107,8 +4139,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
4107
4139
  };
4108
4140
  //#endregion
4109
4141
  //#region src/runtime/mode.ts
4110
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
4111
- const setMode = (handler) => modeResolutionChain.push(handler);
4142
+ const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
4143
+ const setMode = (handler) => {
4144
+ modeResolver.length = 0;
4145
+ modeResolver.push(handler);
4146
+ };
4112
4147
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
4113
4148
  //#endregion
4114
4149
  //#region src/runtime/normalize-watchers.ts
@@ -4173,23 +4208,14 @@ const normalizeWatchers = (raw) => {
4173
4208
  *
4174
4209
  * @param propValue the new value to coerce to some type
4175
4210
  * @param propType the type of the prop, expressed as a binary number
4176
- * @param isFormAssociated whether the component is form-associated (optional)
4177
4211
  * @returns the parsed/coerced value
4178
4212
  */
4179
- const parsePropertyValue = (propValue, propType, isFormAssociated) => {
4213
+ const parsePropertyValue = (propValue, propType) => {
4180
4214
  if (propValue != null && !isComplexType(propValue)) {
4181
4215
  /**
4182
4216
  * ensure this value is of the correct prop type
4183
4217
  */
4184
- if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) {
4185
- /**
4186
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
4187
- * (regardless of its value, even "false") should make the property true.
4188
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
4189
- */
4190
- if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
4191
- else return propValue === "false" ? false : propValue === "" || !!propValue;
4192
- }
4218
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
4193
4219
  /**
4194
4220
  * force it to be a number
4195
4221
  */
@@ -4231,7 +4257,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4231
4257
  if (BUILD.signalBacking) {
4232
4258
  const sig = hostRef?.$signalValues$?.get(propName);
4233
4259
  if (sig !== void 0) {
4234
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4260
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4235
4261
  if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
4236
4262
  const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
4237
4263
  applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
@@ -4249,7 +4275,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4249
4275
  const oldVal = hostRef.$instanceValues$.get(propName);
4250
4276
  const flags = hostRef.$flags$;
4251
4277
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
4252
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4278
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4253
4279
  const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
4254
4280
  if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
4255
4281
  hostRef.$instanceValues$.set(propName, newVal);
@@ -4298,6 +4324,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4298
4324
  */
4299
4325
  const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
4300
4326
  /**
4327
+ * Hand values written to a lazy component's element before its instance existed to the
4328
+ * instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
4329
+ * whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
4330
+ *
4331
+ * @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
4332
+ * @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
4333
+ */
4334
+ const replayPendingSetterValues = (hostRef, cmpMeta) => {
4335
+ const instance = hostRef.$lazyInstance$;
4336
+ if (!instance) return;
4337
+ for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
4338
+ const pendingValue = hostRef.$instanceValues$.get(memberName);
4339
+ if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
4340
+ }
4341
+ };
4342
+ /**
4301
4343
  * Attach a series of runtime constructs to a compiled Stencil component
4302
4344
  * constructor, including getters and setters for the `@Prop` and `@State`
4303
4345
  * decorators, callbacks for when attributes change, and so on.
@@ -4354,9 +4396,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4354
4396
  if (BUILD.lazyLoad) {
4355
4397
  if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
4356
4398
  const ref = getHostRef(this);
4357
- const instance = ref ? ref.$lazyInstance$ : prototype;
4358
- if (!instance) return;
4359
- return instance[memberName];
4399
+ if (!ref) return prototype[memberName];
4400
+ return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
4360
4401
  }
4361
4402
  if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
4362
4403
  },
@@ -4371,7 +4412,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4371
4412
  }
4372
4413
  if (origSetter) {
4373
4414
  if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
4374
- origSetter.apply(this, [parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated))]);
4415
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
4375
4416
  newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
4376
4417
  setValue(this, memberName, newValue, cmpMeta);
4377
4418
  return;
@@ -4383,21 +4424,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4383
4424
  if (BUILD.lazyLoad) {
4384
4425
  if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
4385
4426
  setValue(this, memberName, newValue, cmpMeta);
4386
- if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
4387
- if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
4388
- });
4389
4427
  return;
4390
4428
  }
4391
- const setterSetVal = () => {
4429
+ const parsedValue = parsePropertyValue(newValue, memberFlags);
4430
+ if (ref.$lazyInstance$) {
4392
4431
  const currentValue = ref.$lazyInstance$[memberName];
4393
4432
  if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
4394
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4433
+ ref.$lazyInstance$[memberName] = parsedValue;
4395
4434
  setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
4396
- };
4397
- if (ref.$lazyInstance$) setterSetVal();
4398
- else ref.$fetchedCbList$.push(() => {
4399
- setterSetVal();
4400
- });
4435
+ } else ref.$instanceValues$.set(memberName, parsedValue);
4401
4436
  }
4402
4437
  } });
4403
4438
  } else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
@@ -4449,7 +4484,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4449
4484
  const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4450
4485
  if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4451
4486
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4452
- if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4487
+ if (isBooleanTarget) {
4488
+ if (BUILD.isDev && newValue === "false") consoleDevWarn(`<${cmpMeta.$tagName$} ${attrName}="false">: boolean attributes are true when present, regardless of value. Remove the attribute or set the "${propName}" property to false instead.`);
4489
+ newValue = newValue !== null;
4490
+ }
4453
4491
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
4454
4492
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4455
4493
  });
@@ -4512,9 +4550,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4512
4550
  } catch (e) {
4513
4551
  consoleError(e, elm);
4514
4552
  }
4515
- if (BUILD.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4553
+ if (BUILD.member) {
4554
+ hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4555
+ replayPendingSetterValues(hostRef, cmpMeta);
4556
+ }
4516
4557
  endNewInstance();
4517
- if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4558
+ if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4518
4559
  if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4519
4560
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4520
4561
  if (BUILD.asyncLoading) markFirstConnected(hostRef);
@@ -4614,9 +4655,16 @@ const connectedCallback = (elm) => {
4614
4655
  }
4615
4656
  if (BUILD.asyncLoading) {
4616
4657
  let ancestorComponent = elm;
4617
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) if (BUILD.hydrateClientSide && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
4618
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4619
- break;
4658
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
4659
+ if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
4660
+ ancestorComponent["s-p"] = [];
4661
+ ancestorComponent["s-rc"] = [];
4662
+ ancestorComponent["s-pc"] = [];
4663
+ }
4664
+ if (ancestorComponent["s-p"]) {
4665
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4666
+ break;
4667
+ }
4620
4668
  }
4621
4669
  }
4622
4670
  if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
@@ -4732,48 +4780,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4732
4780
  `${modulePath}?s-hmr=${hmrVersionId}`
4733
4781
  );
4734
4782
  const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4735
- if (!NewClass) return;
4736
- const ctor = customElements.get(cmpMeta.$tagName$);
4737
- if (ctor) {
4738
- for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4739
- if (key === "constructor") continue;
4740
- Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4741
- }
4742
- const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4743
- if (styleDesc) {
4744
- Object.defineProperty(ctor, "style", styleDesc);
4745
- const newStyle = NewClass.style;
4746
- if (newStyle) {
4747
- const scopeId = getScopeId(cmpMeta);
4748
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4749
- console.log("[stencil-hmr] registerStyle", {
4750
- tag: cmpMeta.$tagName$,
4751
- scopeId,
4752
- isShadow,
4753
- cssLen: newStyle.length
4754
- });
4755
- registerStyle(scopeId, newStyle, isShadow);
4756
- }
4757
- }
4758
- }
4759
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4760
- document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4761
- const hostRef = getHostRef(el);
4762
- if (BUILD.hostListener && hostRef?.$rmListeners$) {
4763
- hostRef.$rmListeners$.map((rmListener) => rmListener());
4764
- hostRef.$rmListeners$ = void 0;
4765
- addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4766
- }
4767
- if (!isShadow && hostRef) {
4768
- console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
4769
- attachStyles(hostRef);
4770
- }
4771
- forceUpdate(el);
4772
- });
4783
+ if (NewClass) hmrApplyClass(cmpMeta, NewClass);
4773
4784
  } catch (e) {
4774
4785
  console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
4775
4786
  }
4776
4787
  };
4788
+ /**
4789
+ * Patch a re-executed component class onto the registered one and re-render every live instance.
4790
+ * Shared by the standalone re-import above and bundlers that re-execute the module themselves
4791
+ * (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
4792
+ *
4793
+ * @param cmpMeta runtime metadata for the component
4794
+ * @param NewClass the component's newly executed class
4795
+ */
4796
+ const hmrApplyClass = (cmpMeta, NewClass) => {
4797
+ const ctor = customElements.get(cmpMeta.$tagName$);
4798
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4799
+ if (ctor && ctor !== NewClass) {
4800
+ for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4801
+ if (key === "constructor") continue;
4802
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4803
+ }
4804
+ const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4805
+ if (styleDesc) {
4806
+ Object.defineProperty(ctor, "style", styleDesc);
4807
+ const newStyle = NewClass.style;
4808
+ if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
4809
+ }
4810
+ }
4811
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4812
+ const hostRef = getHostRef(el);
4813
+ if (BUILD.hostListener && hostRef?.$rmListeners$) {
4814
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4815
+ hostRef.$rmListeners$ = void 0;
4816
+ addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4817
+ }
4818
+ if (!isShadow && hostRef) attachStyles(hostRef);
4819
+ forceUpdate(el);
4820
+ });
4821
+ };
4777
4822
  //#endregion
4778
4823
  //#region src/runtime/bootstrap-standalone.ts
4779
4824
  const defineCustomElement = (Cstr, compactMeta) => {
@@ -4796,9 +4841,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4796
4841
  cmpMeta.$serializers$ = Cstr.$serializers$;
4797
4842
  }
4798
4843
  if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
4799
- if (BUILD.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4800
- hmrStart(this, cmpMeta, hmrVersionId);
4801
- };
4844
+ if (BUILD.hotModuleReplacement) {
4845
+ Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4846
+ hmrStart(this, cmpMeta, hmrVersionId);
4847
+ };
4848
+ Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
4849
+ }
4802
4850
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4803
4851
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4804
4852
  if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
@@ -4837,7 +4885,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4837
4885
  }
4838
4886
  connectedCallback(this);
4839
4887
  if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4840
- await awaitAncestorConnected(hostRef.$ancestorComponent$);
4888
+ await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
4841
4889
  if (!this.isConnected) return;
4842
4890
  }
4843
4891
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
@@ -5152,7 +5200,7 @@ function Mixin(...mixins) {
5152
5200
  //#region src/runtime/nonce.ts
5153
5201
  /**
5154
5202
  * Assigns the given value to the nonce property on the runtime platform object.
5155
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
5203
+ * During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
5156
5204
  * @param nonce The value to be assigned to the platform nonce property.
5157
5205
  * @returns void
5158
5206
  */
@@ -5314,4 +5362,4 @@ function hasKeys(obj) {
5314
5362
  return false;
5315
5363
  }
5316
5364
  //#endregion
5317
- export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
5365
+ export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };