@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.
- package/dist/app-data/index.d.ts +1 -1
- package/dist/{client-BRu0GtRn.mjs → client-BYvfR_Hx.mjs} +127 -68
- package/dist/compiler/browser.d.ts +114 -81
- package/dist/compiler/browser.js +733 -336
- package/dist/compiler/index.d.mts +110 -2
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-BPgV6bA4.mjs → compiler-6RhuOkQ0.mjs} +4829 -2895
- package/dist/declarations/stencil-public-compiler.d.ts +152 -129
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +60 -58
- package/dist/{index-DmHmu3y0.d.mts → index-BGUOG9Wc.d.mts} +6 -2
- package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
- package/dist/{index-BopBfjPu.d.mts → index-BogZpjP2.d.mts} +150 -127
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.d.mts +6 -0
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-75gQKkFz.mjs → node-CvPPhnWO.mjs} +41 -47
- package/dist/runtime/client/lazy.js +252 -189
- package/dist/runtime/client/runtime.d.ts +71 -66
- package/dist/runtime/client/runtime.js +252 -189
- package/dist/runtime/index.d.ts +4 -5
- package/dist/runtime/index.js +250 -187
- package/dist/runtime/server/index.d.mts +11 -11
- package/dist/runtime/server/index.mjs +302 -228
- package/dist/runtime/server/runner.d.mts +4 -4
- package/dist/runtime/server/runner.mjs +82 -54
- package/dist/signals/index.d.ts +11 -2
- package/dist/signals/index.js +14 -35
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.d.mts +136 -120
- package/dist/testing/index.mjs +259 -201
- package/package.json +8 -4
|
@@ -1,18 +1,95 @@
|
|
|
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
|
|
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
|
|
80
|
+
/**
|
|
81
|
+
* `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
|
|
82
|
+
* sets `BUILD.*` overrides from each component module, which runs after this module is evaluated.
|
|
83
|
+
*/
|
|
11
84
|
const Build = {
|
|
12
|
-
isDev: BUILD.isDev,
|
|
13
85
|
isBrowser: true,
|
|
14
86
|
isServer: false,
|
|
15
|
-
|
|
87
|
+
get isDev() {
|
|
88
|
+
return BUILD.isDev;
|
|
89
|
+
},
|
|
90
|
+
get isTesting() {
|
|
91
|
+
return BUILD.isTesting;
|
|
92
|
+
}
|
|
16
93
|
};
|
|
17
94
|
//#endregion
|
|
18
95
|
//#region src/client/client-decorators.ts
|
|
@@ -494,79 +571,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
494
571
|
//#endregion
|
|
495
572
|
//#region src/client/client-style.ts
|
|
496
573
|
const styles = /*@__PURE__*/ new Map();
|
|
497
|
-
const
|
|
498
|
-
const
|
|
574
|
+
const modeResolver = [];
|
|
575
|
+
const setScopedSSR = (_opts) => {};
|
|
499
576
|
const needsScopedSSR = () => false;
|
|
500
577
|
//#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
578
|
//#region src/client/client-window.ts
|
|
571
579
|
const win = typeof window !== "undefined" ? window : {};
|
|
572
580
|
const H = win.HTMLElement || class {};
|
|
@@ -607,7 +615,7 @@ let queuePending = false;
|
|
|
607
615
|
const queueDomReads = [];
|
|
608
616
|
const queueDomWrites = [];
|
|
609
617
|
const queueDomWritesLow = [];
|
|
610
|
-
const scheduleFlush = () => win.document?.hidden ?
|
|
618
|
+
const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
|
|
611
619
|
const queueTask = (queue, write) => (cb) => {
|
|
612
620
|
queue.push(cb);
|
|
613
621
|
if (!queuePending) {
|
|
@@ -1691,6 +1699,13 @@ const isComplexType = (o) => {
|
|
|
1691
1699
|
return o === "object" || o === "function";
|
|
1692
1700
|
};
|
|
1693
1701
|
//#endregion
|
|
1702
|
+
//#region src/runtime/signals-core.ts
|
|
1703
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
1704
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
1705
|
+
function signal(value, options) {
|
|
1706
|
+
return getCore().signal(value, options);
|
|
1707
|
+
}
|
|
1708
|
+
//#endregion
|
|
1694
1709
|
//#region src/runtime/event-emitter.ts
|
|
1695
1710
|
const createEvent = (ref, name, flags) => {
|
|
1696
1711
|
const elm = getElement(ref);
|
|
@@ -1723,6 +1738,11 @@ const setRegistry = (registry) => {
|
|
|
1723
1738
|
_registry = registry;
|
|
1724
1739
|
};
|
|
1725
1740
|
const getRegistry = () => _registry ?? customElements;
|
|
1741
|
+
/**
|
|
1742
|
+
* @param elm a defined component host
|
|
1743
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
1744
|
+
*/
|
|
1745
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
1726
1746
|
//#endregion
|
|
1727
1747
|
//#region src/runtime/vdom/set-accessor.ts
|
|
1728
1748
|
/**
|
|
@@ -1766,7 +1786,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1766
1786
|
attrMap.get(memberName)?.();
|
|
1767
1787
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
1768
1788
|
let prevVal = oldValue;
|
|
1769
|
-
attrMap.set(memberName, effect
|
|
1789
|
+
attrMap.set(memberName, effect(() => {
|
|
1770
1790
|
const curVal = newValue.value;
|
|
1771
1791
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
1772
1792
|
prevVal = curVal;
|
|
@@ -1846,10 +1866,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1846
1866
|
const isComplex = isComplexType(newValue);
|
|
1847
1867
|
if (!BUILD.lazyLoad) {
|
|
1848
1868
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1849
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1869
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1850
1870
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1851
1871
|
elm["s-pp"].set(memberName, newValue);
|
|
1852
|
-
return;
|
|
1872
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1853
1873
|
}
|
|
1854
1874
|
}
|
|
1855
1875
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -1967,6 +1987,7 @@ function sortedAttrNames(attrNames) {
|
|
|
1967
1987
|
let scopeId;
|
|
1968
1988
|
let contentRef;
|
|
1969
1989
|
let hostTagName;
|
|
1990
|
+
let hostRegistry;
|
|
1970
1991
|
let useNativeShadowDom = false;
|
|
1971
1992
|
let checkSlotFallbackVisibility = false;
|
|
1972
1993
|
let checkSlotRelocate = false;
|
|
@@ -1983,16 +2004,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
1983
2004
|
const disposeSignalVNode = (vnode) => {
|
|
1984
2005
|
const elm = vnode.$elm$;
|
|
1985
2006
|
if (elm) {
|
|
1986
|
-
|
|
1987
|
-
if (dispose) {
|
|
1988
|
-
dispose();
|
|
1989
|
-
signalNodeDisposers.delete(elm);
|
|
1990
|
-
}
|
|
2007
|
+
disposeTextSignal(elm);
|
|
1991
2008
|
disposeAllSignalAttrs(elm);
|
|
1992
2009
|
}
|
|
1993
2010
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
1994
2011
|
};
|
|
1995
2012
|
/**
|
|
2013
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
2014
|
+
* @param textNode the text node to unsubscribe
|
|
2015
|
+
*/
|
|
2016
|
+
const disposeTextSignal = (textNode) => {
|
|
2017
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
2018
|
+
if (dispose) {
|
|
2019
|
+
dispose();
|
|
2020
|
+
signalNodeDisposers.delete(textNode);
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
/**
|
|
2024
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
2025
|
+
* @param textNode the text node to keep in sync
|
|
2026
|
+
* @param textSig the signal to subscribe to
|
|
2027
|
+
*/
|
|
2028
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
2029
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
2030
|
+
textNode.data = String(textSig.value);
|
|
2031
|
+
}));
|
|
2032
|
+
};
|
|
2033
|
+
/**
|
|
1996
2034
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
1997
2035
|
*
|
|
1998
2036
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -2014,13 +2052,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2014
2052
|
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
2053
|
if (BUILD.vdomText && newVNode.$text$ != null) {
|
|
2016
2054
|
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
|
-
}
|
|
2055
|
+
if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
2024
2056
|
} else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
2025
2057
|
elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
2026
2058
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -2029,8 +2061,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2029
2061
|
if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
2030
2062
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
2031
2063
|
const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
2032
|
-
const
|
|
2033
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
2064
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
2034
2065
|
elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
2035
2066
|
if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
2036
2067
|
if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2288,7 +2319,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2288
2319
|
}
|
|
2289
2320
|
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
2290
2321
|
elmToMove = oldCh[idxInOld];
|
|
2291
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2322
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2292
2323
|
else {
|
|
2293
2324
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2294
2325
|
oldCh[idxInOld] = void 0;
|
|
@@ -2381,7 +2412,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2381
2412
|
else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2382
2413
|
if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2383
2414
|
} else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2384
|
-
else if (BUILD.vdomText
|
|
2415
|
+
else if (BUILD.vdomText) {
|
|
2416
|
+
if (BUILD.vdomSignals && newVNode.$signal$) {
|
|
2417
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2418
|
+
disposeTextSignal(elm);
|
|
2419
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2420
|
+
}
|
|
2421
|
+
} else {
|
|
2422
|
+
if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2423
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2385
2426
|
};
|
|
2386
2427
|
/**
|
|
2387
2428
|
* Component-global information about nodes which are either currently being
|
|
@@ -2569,6 +2610,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2569
2610
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2570
2611
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2571
2612
|
hostTagName = hostElm.tagName;
|
|
2613
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2572
2614
|
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2573
2615
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2574
2616
|
|
|
@@ -2721,11 +2763,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
2721
2763
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
2722
2764
|
*
|
|
2723
2765
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2766
|
+
* @param registry the registry the waiting component is defined in
|
|
2724
2767
|
*/
|
|
2725
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2768
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
2726
2769
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2727
2770
|
if (!BUILD.lazyLoad && !ancestorHostRef) {
|
|
2728
|
-
await
|
|
2771
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2729
2772
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
2730
2773
|
}
|
|
2731
2774
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -3081,8 +3124,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3081
3124
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3082
3125
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
3083
3126
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
3084
|
-
const
|
|
3085
|
-
const sig = signal(initialVal);
|
|
3127
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
3086
3128
|
hostRef.$signalValues$.set(memberName, sig);
|
|
3087
3129
|
let prevScheduleVal = sig.peek();
|
|
3088
3130
|
disposers.push(effect(() => {
|
|
@@ -3210,9 +3252,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3210
3252
|
if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3211
3253
|
}
|
|
3212
3254
|
}
|
|
3213
|
-
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
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.`);
|
|
3255
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3216
3256
|
if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3217
3257
|
const vnode = newVNode(nodeName, null);
|
|
3218
3258
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3265,17 +3305,23 @@ const vdomFnUtils = {
|
|
|
3265
3305
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3266
3306
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3267
3307
|
*
|
|
3268
|
-
*
|
|
3308
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3309
|
+
* become text-only child nodes.
|
|
3310
|
+
*
|
|
3311
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3269
3312
|
* @returns a converted child node
|
|
3270
3313
|
*/
|
|
3271
|
-
const convertToPublic = (node) =>
|
|
3314
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3315
|
+
vtag: null,
|
|
3316
|
+
vtext: String(node)
|
|
3317
|
+
} : {
|
|
3272
3318
|
vattrs: node.$attrs$,
|
|
3273
3319
|
vchildren: node.$children$,
|
|
3274
3320
|
vkey: node.$key$,
|
|
3275
3321
|
vname: node.$name$,
|
|
3276
3322
|
vtag: node.$tag$,
|
|
3277
3323
|
vtext: node.$text$
|
|
3278
|
-
}
|
|
3324
|
+
};
|
|
3279
3325
|
/**
|
|
3280
3326
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3281
3327
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3292,11 +3338,11 @@ const convertToPrivate = (node) => {
|
|
|
3292
3338
|
if (node.vname) vnodeData.name = node.vname;
|
|
3293
3339
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3294
3340
|
}
|
|
3295
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3296
|
-
vnode.$attrs$ = node.vattrs;
|
|
3297
|
-
vnode.$children$ = node.vchildren;
|
|
3298
|
-
vnode.$key$ = node.vkey;
|
|
3299
|
-
vnode.$name$ = node.vname;
|
|
3341
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3342
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3343
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3344
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3345
|
+
vnode.$name$ = node.vname ?? null;
|
|
3300
3346
|
return vnode;
|
|
3301
3347
|
};
|
|
3302
3348
|
/**
|
|
@@ -3594,6 +3640,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3594
3640
|
const createSimpleVNode = (vnode) => ({
|
|
3595
3641
|
$flags$: 0,
|
|
3596
3642
|
$index$: "0",
|
|
3643
|
+
$children$: null,
|
|
3597
3644
|
...vnode
|
|
3598
3645
|
});
|
|
3599
3646
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -3988,7 +4035,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
3988
4035
|
else return shallowPart.trim();
|
|
3989
4036
|
}).join(", ");
|
|
3990
4037
|
};
|
|
3991
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
4038
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
3992
4039
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
3993
4040
|
return processRules(cssText, (rule) => {
|
|
3994
4041
|
let selector = rule.selector;
|
|
@@ -4107,8 +4154,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4107
4154
|
};
|
|
4108
4155
|
//#endregion
|
|
4109
4156
|
//#region src/runtime/mode.ts
|
|
4110
|
-
const computeMode = (elm) =>
|
|
4111
|
-
const setMode = (handler) =>
|
|
4157
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4158
|
+
const setMode = (handler) => {
|
|
4159
|
+
modeResolver.length = 0;
|
|
4160
|
+
modeResolver.push(handler);
|
|
4161
|
+
};
|
|
4112
4162
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4113
4163
|
//#endregion
|
|
4114
4164
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4173,23 +4223,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4173
4223
|
*
|
|
4174
4224
|
* @param propValue the new value to coerce to some type
|
|
4175
4225
|
* @param propType the type of the prop, expressed as a binary number
|
|
4176
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4177
4226
|
* @returns the parsed/coerced value
|
|
4178
4227
|
*/
|
|
4179
|
-
const parsePropertyValue = (propValue, propType
|
|
4228
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4180
4229
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4181
4230
|
/**
|
|
4182
4231
|
* ensure this value is of the correct prop type
|
|
4183
4232
|
*/
|
|
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
|
-
}
|
|
4233
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4193
4234
|
/**
|
|
4194
4235
|
* force it to be a number
|
|
4195
4236
|
*/
|
|
@@ -4231,7 +4272,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4231
4272
|
if (BUILD.signalBacking) {
|
|
4232
4273
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4233
4274
|
if (sig !== void 0) {
|
|
4234
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4275
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4235
4276
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4236
4277
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4237
4278
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4249,7 +4290,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4249
4290
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4250
4291
|
const flags = hostRef.$flags$;
|
|
4251
4292
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4252
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4293
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4253
4294
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4254
4295
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4255
4296
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4298,6 +4339,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4298
4339
|
*/
|
|
4299
4340
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4300
4341
|
/**
|
|
4342
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4343
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4344
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4345
|
+
*
|
|
4346
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4347
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4348
|
+
*/
|
|
4349
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4350
|
+
const instance = hostRef.$lazyInstance$;
|
|
4351
|
+
if (!instance) return;
|
|
4352
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4353
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4354
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4355
|
+
}
|
|
4356
|
+
};
|
|
4357
|
+
/**
|
|
4301
4358
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4302
4359
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4303
4360
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4354,9 +4411,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4354
4411
|
if (BUILD.lazyLoad) {
|
|
4355
4412
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4356
4413
|
const ref = getHostRef(this);
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
return instance[memberName];
|
|
4414
|
+
if (!ref) return prototype[memberName];
|
|
4415
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4360
4416
|
}
|
|
4361
4417
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4362
4418
|
},
|
|
@@ -4371,7 +4427,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4371
4427
|
}
|
|
4372
4428
|
if (origSetter) {
|
|
4373
4429
|
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
|
|
4430
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4375
4431
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4376
4432
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4377
4433
|
return;
|
|
@@ -4383,21 +4439,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4383
4439
|
if (BUILD.lazyLoad) {
|
|
4384
4440
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4385
4441
|
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
4442
|
return;
|
|
4390
4443
|
}
|
|
4391
|
-
const
|
|
4444
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4445
|
+
if (ref.$lazyInstance$) {
|
|
4392
4446
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4393
4447
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4394
|
-
ref.$lazyInstance$[memberName] =
|
|
4448
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4395
4449
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4396
|
-
};
|
|
4397
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4398
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4399
|
-
setterSetVal();
|
|
4400
|
-
});
|
|
4450
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4401
4451
|
}
|
|
4402
4452
|
} });
|
|
4403
4453
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4449,7 +4499,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4449
4499
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4450
4500
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4451
4501
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4452
|
-
if (isBooleanTarget)
|
|
4502
|
+
if (isBooleanTarget) {
|
|
4503
|
+
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.`);
|
|
4504
|
+
newValue = newValue !== null;
|
|
4505
|
+
}
|
|
4453
4506
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4454
4507
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4455
4508
|
});
|
|
@@ -4512,9 +4565,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4512
4565
|
} catch (e) {
|
|
4513
4566
|
consoleError(e, elm);
|
|
4514
4567
|
}
|
|
4515
|
-
if (BUILD.member)
|
|
4568
|
+
if (BUILD.member) {
|
|
4569
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4570
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4571
|
+
}
|
|
4516
4572
|
endNewInstance();
|
|
4517
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4573
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4518
4574
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4519
4575
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4520
4576
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4614,9 +4670,16 @@ const connectedCallback = (elm) => {
|
|
|
4614
4670
|
}
|
|
4615
4671
|
if (BUILD.asyncLoading) {
|
|
4616
4672
|
let ancestorComponent = elm;
|
|
4617
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4618
|
-
|
|
4619
|
-
|
|
4673
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
4674
|
+
if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
4675
|
+
ancestorComponent["s-p"] = [];
|
|
4676
|
+
ancestorComponent["s-rc"] = [];
|
|
4677
|
+
ancestorComponent["s-pc"] = [];
|
|
4678
|
+
}
|
|
4679
|
+
if (ancestorComponent["s-p"]) {
|
|
4680
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
4681
|
+
break;
|
|
4682
|
+
}
|
|
4620
4683
|
}
|
|
4621
4684
|
}
|
|
4622
4685
|
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -4732,48 +4795,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4732
4795
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4733
4796
|
);
|
|
4734
4797
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4735
|
-
if (
|
|
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
|
-
});
|
|
4798
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4773
4799
|
} catch (e) {
|
|
4774
4800
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4775
4801
|
}
|
|
4776
4802
|
};
|
|
4803
|
+
/**
|
|
4804
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4805
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4806
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4807
|
+
*
|
|
4808
|
+
* @param cmpMeta runtime metadata for the component
|
|
4809
|
+
* @param NewClass the component's newly executed class
|
|
4810
|
+
*/
|
|
4811
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4812
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4813
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4814
|
+
if (ctor && ctor !== NewClass) {
|
|
4815
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4816
|
+
if (key === "constructor") continue;
|
|
4817
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4818
|
+
}
|
|
4819
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4820
|
+
if (styleDesc) {
|
|
4821
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4822
|
+
const newStyle = NewClass.style;
|
|
4823
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4827
|
+
const hostRef = getHostRef(el);
|
|
4828
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4829
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4830
|
+
hostRef.$rmListeners$ = void 0;
|
|
4831
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4832
|
+
}
|
|
4833
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4834
|
+
forceUpdate(el);
|
|
4835
|
+
});
|
|
4836
|
+
};
|
|
4777
4837
|
//#endregion
|
|
4778
4838
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4779
4839
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4796,9 +4856,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4796
4856
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4797
4857
|
}
|
|
4798
4858
|
if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4799
|
-
if (BUILD.hotModuleReplacement)
|
|
4800
|
-
|
|
4801
|
-
|
|
4859
|
+
if (BUILD.hotModuleReplacement) {
|
|
4860
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4861
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4862
|
+
};
|
|
4863
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4864
|
+
}
|
|
4802
4865
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4803
4866
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4804
4867
|
if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -4837,7 +4900,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4837
4900
|
}
|
|
4838
4901
|
connectedCallback(this);
|
|
4839
4902
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4840
|
-
await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4903
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
4841
4904
|
if (!this.isConnected) return;
|
|
4842
4905
|
}
|
|
4843
4906
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
@@ -5152,7 +5215,7 @@ function Mixin(...mixins) {
|
|
|
5152
5215
|
//#region src/runtime/nonce.ts
|
|
5153
5216
|
/**
|
|
5154
5217
|
* 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
|
|
5218
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
|
|
5156
5219
|
* @param nonce The value to be assigned to the platform nonce property.
|
|
5157
5220
|
* @returns void
|
|
5158
5221
|
*/
|
|
@@ -5314,4 +5377,4 @@ function hasKeys(obj) {
|
|
|
5314
5377
|
return false;
|
|
5315
5378
|
}
|
|
5316
5379
|
//#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,
|
|
5380
|
+
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 };
|