@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,12 +1,89 @@
|
|
|
1
1
|
import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } 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
|
+
//#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
|
+
/**
|
|
55
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
56
|
+
*
|
|
57
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
58
|
+
* support as of Stencil v4.
|
|
59
|
+
*/
|
|
60
|
+
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
61
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
62
|
+
/**
|
|
63
|
+
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
64
|
+
*/
|
|
65
|
+
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
66
|
+
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
67
|
+
"formAssociatedCallback",
|
|
68
|
+
"formResetCallback",
|
|
69
|
+
"formDisabledCallback",
|
|
70
|
+
"formStateRestoreCallback"
|
|
71
|
+
];
|
|
72
|
+
//#endregion
|
|
4
73
|
//#region src/client/client-build.ts
|
|
74
|
+
/**
|
|
75
|
+
* `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
|
|
76
|
+
* sets `BUILD.*` overrides from each component module, which runs after this module is evaluated.
|
|
77
|
+
*/
|
|
5
78
|
const Build = {
|
|
6
|
-
isDev: BUILD$1.isDev,
|
|
7
79
|
isBrowser: true,
|
|
8
80
|
isServer: false,
|
|
9
|
-
|
|
81
|
+
get isDev() {
|
|
82
|
+
return BUILD$1.isDev;
|
|
83
|
+
},
|
|
84
|
+
get isTesting() {
|
|
85
|
+
return BUILD$1.isTesting;
|
|
86
|
+
}
|
|
10
87
|
};
|
|
11
88
|
//#endregion
|
|
12
89
|
//#region src/client/client-decorators.ts
|
|
@@ -488,79 +565,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
488
565
|
//#endregion
|
|
489
566
|
//#region src/client/client-style.ts
|
|
490
567
|
const styles = /*@__PURE__*/ new Map();
|
|
491
|
-
const
|
|
492
|
-
const
|
|
568
|
+
const modeResolver = [];
|
|
569
|
+
const setScopedSSR = (_opts) => {};
|
|
493
570
|
const needsScopedSSR = () => false;
|
|
494
571
|
//#endregion
|
|
495
|
-
//#region src/runtime/runtime-constants.ts
|
|
496
|
-
/**
|
|
497
|
-
* Bit flags for recording various properties of VDom nodes
|
|
498
|
-
*/
|
|
499
|
-
const VNODE_FLAGS = {
|
|
500
|
-
/**
|
|
501
|
-
* Whether or not a vdom node is a slot reference
|
|
502
|
-
*/
|
|
503
|
-
isSlotReference: 1,
|
|
504
|
-
/**
|
|
505
|
-
* Whether or not a slot element has fallback content
|
|
506
|
-
*/
|
|
507
|
-
isSlotFallback: 2,
|
|
508
|
-
/**
|
|
509
|
-
* Whether or not an element is a host element
|
|
510
|
-
*/
|
|
511
|
-
isHost: 4
|
|
512
|
-
};
|
|
513
|
-
const PROXY_FLAGS = {
|
|
514
|
-
isElementConstructor: 1,
|
|
515
|
-
proxyState: 2
|
|
516
|
-
};
|
|
517
|
-
const PLATFORM_FLAGS = {
|
|
518
|
-
/**
|
|
519
|
-
* designates a node in the DOM as being actively moved by the runtime
|
|
520
|
-
*/
|
|
521
|
-
isTmpDisconnected: 1,
|
|
522
|
-
appLoaded: 2,
|
|
523
|
-
queueSync: 4,
|
|
524
|
-
queueMask: 6
|
|
525
|
-
};
|
|
526
|
-
/**
|
|
527
|
-
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
528
|
-
* values are based on the values which can possibly be returned by the
|
|
529
|
-
* `.nodeType` property of a DOM node. See here for details:
|
|
530
|
-
*
|
|
531
|
-
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
532
|
-
*/
|
|
533
|
-
const NODE_TYPE = {
|
|
534
|
-
ElementNode: 1,
|
|
535
|
-
TextNode: 3,
|
|
536
|
-
CommentNode: 8,
|
|
537
|
-
DocumentNode: 9,
|
|
538
|
-
DocumentTypeNode: 10,
|
|
539
|
-
DocumentFragment: 11
|
|
540
|
-
};
|
|
541
|
-
const HYDRATE_ID = "s-id";
|
|
542
|
-
const HYDRATED_STYLE_ID = "sty-id";
|
|
543
|
-
const HYDRATE_CHILD_ID = "c-id";
|
|
544
|
-
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
545
|
-
/**
|
|
546
|
-
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
547
|
-
*
|
|
548
|
-
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
549
|
-
* support as of Stencil v4.
|
|
550
|
-
*/
|
|
551
|
-
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
552
|
-
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
553
|
-
/**
|
|
554
|
-
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
555
|
-
*/
|
|
556
|
-
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
557
|
-
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
558
|
-
"formAssociatedCallback",
|
|
559
|
-
"formResetCallback",
|
|
560
|
-
"formDisabledCallback",
|
|
561
|
-
"formStateRestoreCallback"
|
|
562
|
-
];
|
|
563
|
-
//#endregion
|
|
564
572
|
//#region src/client/client-window.ts
|
|
565
573
|
const win = typeof window !== "undefined" ? window : {};
|
|
566
574
|
const H = win.HTMLElement || class {};
|
|
@@ -601,7 +609,7 @@ let queuePending = false;
|
|
|
601
609
|
const queueDomReads = [];
|
|
602
610
|
const queueDomWrites = [];
|
|
603
611
|
const queueDomWritesLow = [];
|
|
604
|
-
const scheduleFlush = () => win.document?.hidden ?
|
|
612
|
+
const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
|
|
605
613
|
const queueTask = (queue, write) => (cb) => {
|
|
606
614
|
queue.push(cb);
|
|
607
615
|
if (!queuePending) {
|
|
@@ -1685,6 +1693,13 @@ const isComplexType = (o) => {
|
|
|
1685
1693
|
return o === "object" || o === "function";
|
|
1686
1694
|
};
|
|
1687
1695
|
//#endregion
|
|
1696
|
+
//#region src/runtime/signals-core.ts
|
|
1697
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
1698
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
1699
|
+
function signal(value, options) {
|
|
1700
|
+
return getCore().signal(value, options);
|
|
1701
|
+
}
|
|
1702
|
+
//#endregion
|
|
1688
1703
|
//#region src/runtime/event-emitter.ts
|
|
1689
1704
|
const createEvent = (ref, name, flags) => {
|
|
1690
1705
|
const elm = getElement(ref);
|
|
@@ -1717,6 +1732,11 @@ const setRegistry = (registry) => {
|
|
|
1717
1732
|
_registry = registry;
|
|
1718
1733
|
};
|
|
1719
1734
|
const getRegistry = () => _registry ?? customElements;
|
|
1735
|
+
/**
|
|
1736
|
+
* @param elm a defined component host
|
|
1737
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
1738
|
+
*/
|
|
1739
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
1720
1740
|
//#endregion
|
|
1721
1741
|
//#region src/runtime/vdom/set-accessor.ts
|
|
1722
1742
|
/**
|
|
@@ -1760,7 +1780,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1760
1780
|
attrMap.get(memberName)?.();
|
|
1761
1781
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
1762
1782
|
let prevVal = oldValue;
|
|
1763
|
-
attrMap.set(memberName, effect
|
|
1783
|
+
attrMap.set(memberName, effect(() => {
|
|
1764
1784
|
const curVal = newValue.value;
|
|
1765
1785
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
1766
1786
|
prevVal = curVal;
|
|
@@ -1840,10 +1860,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1840
1860
|
const isComplex = isComplexType(newValue);
|
|
1841
1861
|
if (!BUILD$1.lazyLoad) {
|
|
1842
1862
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1843
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1863
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1844
1864
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1845
1865
|
elm["s-pp"].set(memberName, newValue);
|
|
1846
|
-
return;
|
|
1866
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1847
1867
|
}
|
|
1848
1868
|
}
|
|
1849
1869
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -1961,6 +1981,7 @@ function sortedAttrNames(attrNames) {
|
|
|
1961
1981
|
let scopeId;
|
|
1962
1982
|
let contentRef;
|
|
1963
1983
|
let hostTagName;
|
|
1984
|
+
let hostRegistry;
|
|
1964
1985
|
let useNativeShadowDom = false;
|
|
1965
1986
|
let checkSlotFallbackVisibility = false;
|
|
1966
1987
|
let checkSlotRelocate = false;
|
|
@@ -1977,16 +1998,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
1977
1998
|
const disposeSignalVNode = (vnode) => {
|
|
1978
1999
|
const elm = vnode.$elm$;
|
|
1979
2000
|
if (elm) {
|
|
1980
|
-
|
|
1981
|
-
if (dispose) {
|
|
1982
|
-
dispose();
|
|
1983
|
-
signalNodeDisposers.delete(elm);
|
|
1984
|
-
}
|
|
2001
|
+
disposeTextSignal(elm);
|
|
1985
2002
|
disposeAllSignalAttrs(elm);
|
|
1986
2003
|
}
|
|
1987
2004
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
1988
2005
|
};
|
|
1989
2006
|
/**
|
|
2007
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
2008
|
+
* @param textNode the text node to unsubscribe
|
|
2009
|
+
*/
|
|
2010
|
+
const disposeTextSignal = (textNode) => {
|
|
2011
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
2012
|
+
if (dispose) {
|
|
2013
|
+
dispose();
|
|
2014
|
+
signalNodeDisposers.delete(textNode);
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
/**
|
|
2018
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
2019
|
+
* @param textNode the text node to keep in sync
|
|
2020
|
+
* @param textSig the signal to subscribe to
|
|
2021
|
+
*/
|
|
2022
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
2023
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
2024
|
+
textNode.data = String(textSig.value);
|
|
2025
|
+
}));
|
|
2026
|
+
};
|
|
2027
|
+
/**
|
|
1990
2028
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
1991
2029
|
*
|
|
1992
2030
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -2008,13 +2046,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2008
2046
|
if (BUILD$1.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`);
|
|
2009
2047
|
if (BUILD$1.vdomText && newVNode.$text$ != null) {
|
|
2010
2048
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
2011
|
-
if (BUILD$1.vdomSignals && newVNode.$signal$)
|
|
2012
|
-
const textSig = newVNode.$signal$;
|
|
2013
|
-
const textNode = elm;
|
|
2014
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
2015
|
-
textNode.data = String(textSig.value);
|
|
2016
|
-
}));
|
|
2017
|
-
}
|
|
2049
|
+
if (BUILD$1.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
2018
2050
|
} else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
2019
2051
|
elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
2020
2052
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -2023,8 +2055,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2023
2055
|
if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
2024
2056
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
2025
2057
|
const tag = !useNativeShadowDom && BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
2026
|
-
const
|
|
2027
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
2058
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
2028
2059
|
elm = newVNode.$elm$ = BUILD$1.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
2029
2060
|
if (BUILD$1.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
2030
2061
|
if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2282,7 +2313,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2282
2313
|
}
|
|
2283
2314
|
if (BUILD$1.vdomKey && idxInOld >= 0) {
|
|
2284
2315
|
elmToMove = oldCh[idxInOld];
|
|
2285
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2316
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2286
2317
|
else {
|
|
2287
2318
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2288
2319
|
oldCh[idxInOld] = void 0;
|
|
@@ -2375,7 +2406,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2375
2406
|
else if (BUILD$1.hydrateClientSide && isInitialRender && BUILD$1.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2376
2407
|
if (BUILD$1.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2377
2408
|
} else if (BUILD$1.vdomText && BUILD$1.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2378
|
-
else if (BUILD$1.vdomText
|
|
2409
|
+
else if (BUILD$1.vdomText) {
|
|
2410
|
+
if (BUILD$1.vdomSignals && newVNode.$signal$) {
|
|
2411
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2412
|
+
disposeTextSignal(elm);
|
|
2413
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2414
|
+
}
|
|
2415
|
+
} else {
|
|
2416
|
+
if (BUILD$1.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2417
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2379
2420
|
};
|
|
2380
2421
|
/**
|
|
2381
2422
|
* Component-global information about nodes which are either currently being
|
|
@@ -2563,6 +2604,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2563
2604
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2564
2605
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2565
2606
|
hostTagName = hostElm.tagName;
|
|
2607
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2566
2608
|
if (BUILD$1.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2567
2609
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2568
2610
|
|
|
@@ -2715,11 +2757,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
2715
2757
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
2716
2758
|
*
|
|
2717
2759
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2760
|
+
* @param registry the registry the waiting component is defined in
|
|
2718
2761
|
*/
|
|
2719
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2762
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
2720
2763
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2721
2764
|
if (!BUILD$1.lazyLoad && !ancestorHostRef) {
|
|
2722
|
-
await
|
|
2765
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2723
2766
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
2724
2767
|
}
|
|
2725
2768
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -3075,8 +3118,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3075
3118
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3076
3119
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
3077
3120
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
3078
|
-
const
|
|
3079
|
-
const sig = signal(initialVal);
|
|
3121
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
3080
3122
|
hostRef.$signalValues$.set(memberName, sig);
|
|
3081
3123
|
let prevScheduleVal = sig.peek();
|
|
3082
3124
|
disposers.push(effect(() => {
|
|
@@ -3204,9 +3246,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3204
3246
|
if (classData && !(BUILD$1.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3205
3247
|
}
|
|
3206
3248
|
}
|
|
3207
|
-
if (BUILD$1.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
3208
|
-
- You are NOT using hostData() and <Host> in the same component.
|
|
3209
|
-
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
3249
|
+
if (BUILD$1.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3210
3250
|
if (BUILD$1.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3211
3251
|
const vnode = newVNode(nodeName, null);
|
|
3212
3252
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3259,17 +3299,23 @@ const vdomFnUtils = {
|
|
|
3259
3299
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3260
3300
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3261
3301
|
*
|
|
3262
|
-
*
|
|
3302
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3303
|
+
* become text-only child nodes.
|
|
3304
|
+
*
|
|
3305
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3263
3306
|
* @returns a converted child node
|
|
3264
3307
|
*/
|
|
3265
|
-
const convertToPublic = (node) =>
|
|
3308
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3309
|
+
vtag: null,
|
|
3310
|
+
vtext: String(node)
|
|
3311
|
+
} : {
|
|
3266
3312
|
vattrs: node.$attrs$,
|
|
3267
3313
|
vchildren: node.$children$,
|
|
3268
3314
|
vkey: node.$key$,
|
|
3269
3315
|
vname: node.$name$,
|
|
3270
3316
|
vtag: node.$tag$,
|
|
3271
3317
|
vtext: node.$text$
|
|
3272
|
-
}
|
|
3318
|
+
};
|
|
3273
3319
|
/**
|
|
3274
3320
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3275
3321
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3286,11 +3332,11 @@ const convertToPrivate = (node) => {
|
|
|
3286
3332
|
if (node.vname) vnodeData.name = node.vname;
|
|
3287
3333
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3288
3334
|
}
|
|
3289
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3290
|
-
vnode.$attrs$ = node.vattrs;
|
|
3291
|
-
vnode.$children$ = node.vchildren;
|
|
3292
|
-
vnode.$key$ = node.vkey;
|
|
3293
|
-
vnode.$name$ = node.vname;
|
|
3335
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3336
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3337
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3338
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3339
|
+
vnode.$name$ = node.vname ?? null;
|
|
3294
3340
|
return vnode;
|
|
3295
3341
|
};
|
|
3296
3342
|
/**
|
|
@@ -3588,6 +3634,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3588
3634
|
const createSimpleVNode = (vnode) => ({
|
|
3589
3635
|
$flags$: 0,
|
|
3590
3636
|
$index$: "0",
|
|
3637
|
+
$children$: null,
|
|
3591
3638
|
...vnode
|
|
3592
3639
|
});
|
|
3593
3640
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -3982,7 +4029,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
3982
4029
|
else return shallowPart.trim();
|
|
3983
4030
|
}).join(", ");
|
|
3984
4031
|
};
|
|
3985
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
4032
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
3986
4033
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
3987
4034
|
return processRules(cssText, (rule) => {
|
|
3988
4035
|
let selector = rule.selector;
|
|
@@ -4101,8 +4148,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4101
4148
|
};
|
|
4102
4149
|
//#endregion
|
|
4103
4150
|
//#region src/runtime/mode.ts
|
|
4104
|
-
const computeMode = (elm) =>
|
|
4105
|
-
const setMode = (handler) =>
|
|
4151
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4152
|
+
const setMode = (handler) => {
|
|
4153
|
+
modeResolver.length = 0;
|
|
4154
|
+
modeResolver.push(handler);
|
|
4155
|
+
};
|
|
4106
4156
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4107
4157
|
//#endregion
|
|
4108
4158
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4167,23 +4217,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4167
4217
|
*
|
|
4168
4218
|
* @param propValue the new value to coerce to some type
|
|
4169
4219
|
* @param propType the type of the prop, expressed as a binary number
|
|
4170
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4171
4220
|
* @returns the parsed/coerced value
|
|
4172
4221
|
*/
|
|
4173
|
-
const parsePropertyValue = (propValue, propType
|
|
4222
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4174
4223
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4175
4224
|
/**
|
|
4176
4225
|
* ensure this value is of the correct prop type
|
|
4177
4226
|
*/
|
|
4178
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4179
|
-
/**
|
|
4180
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4181
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4182
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4183
|
-
*/
|
|
4184
|
-
if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4185
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4186
|
-
}
|
|
4227
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4187
4228
|
/**
|
|
4188
4229
|
* force it to be a number
|
|
4189
4230
|
*/
|
|
@@ -4225,7 +4266,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4225
4266
|
if (BUILD$1.signalBacking) {
|
|
4226
4267
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4227
4268
|
if (sig !== void 0) {
|
|
4228
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4269
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4229
4270
|
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4230
4271
|
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4231
4272
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4243,7 +4284,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4243
4284
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4244
4285
|
const flags = hostRef.$flags$;
|
|
4245
4286
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4246
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4287
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4247
4288
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4248
4289
|
if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4249
4290
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4292,6 +4333,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4292
4333
|
*/
|
|
4293
4334
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4294
4335
|
/**
|
|
4336
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4337
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4338
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4339
|
+
*
|
|
4340
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4341
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4342
|
+
*/
|
|
4343
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4344
|
+
const instance = hostRef.$lazyInstance$;
|
|
4345
|
+
if (!instance) return;
|
|
4346
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4347
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4348
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4349
|
+
}
|
|
4350
|
+
};
|
|
4351
|
+
/**
|
|
4295
4352
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4296
4353
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4297
4354
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4348,9 +4405,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4348
4405
|
if (BUILD$1.lazyLoad) {
|
|
4349
4406
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4350
4407
|
const ref = getHostRef(this);
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
return instance[memberName];
|
|
4408
|
+
if (!ref) return prototype[memberName];
|
|
4409
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4354
4410
|
}
|
|
4355
4411
|
if (!BUILD$1.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4356
4412
|
},
|
|
@@ -4365,7 +4421,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4365
4421
|
}
|
|
4366
4422
|
if (origSetter) {
|
|
4367
4423
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4368
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4424
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4369
4425
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4370
4426
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4371
4427
|
return;
|
|
@@ -4377,21 +4433,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4377
4433
|
if (BUILD$1.lazyLoad) {
|
|
4378
4434
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4379
4435
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4380
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4381
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4382
|
-
});
|
|
4383
4436
|
return;
|
|
4384
4437
|
}
|
|
4385
|
-
const
|
|
4438
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4439
|
+
if (ref.$lazyInstance$) {
|
|
4386
4440
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4387
4441
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4388
|
-
ref.$lazyInstance$[memberName] =
|
|
4442
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4389
4443
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4390
|
-
};
|
|
4391
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4392
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4393
|
-
setterSetVal();
|
|
4394
|
-
});
|
|
4444
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4395
4445
|
}
|
|
4396
4446
|
} });
|
|
4397
4447
|
} else if (BUILD$1.lazyLoad && BUILD$1.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4443,7 +4493,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4443
4493
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4444
4494
|
if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4445
4495
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4446
|
-
if (isBooleanTarget)
|
|
4496
|
+
if (isBooleanTarget) {
|
|
4497
|
+
if (BUILD$1.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.`);
|
|
4498
|
+
newValue = newValue !== null;
|
|
4499
|
+
}
|
|
4447
4500
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4448
4501
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4449
4502
|
});
|
|
@@ -4506,9 +4559,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4506
4559
|
} catch (e) {
|
|
4507
4560
|
consoleError(e, elm);
|
|
4508
4561
|
}
|
|
4509
|
-
if (BUILD$1.member)
|
|
4562
|
+
if (BUILD$1.member) {
|
|
4563
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4564
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4565
|
+
}
|
|
4510
4566
|
endNewInstance();
|
|
4511
|
-
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4567
|
+
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4512
4568
|
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4513
4569
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4514
4570
|
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4608,9 +4664,16 @@ const connectedCallback = (elm) => {
|
|
|
4608
4664
|
}
|
|
4609
4665
|
if (BUILD$1.asyncLoading) {
|
|
4610
4666
|
let ancestorComponent = elm;
|
|
4611
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4612
|
-
|
|
4613
|
-
|
|
4667
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
4668
|
+
if (BUILD$1.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
4669
|
+
ancestorComponent["s-p"] = [];
|
|
4670
|
+
ancestorComponent["s-rc"] = [];
|
|
4671
|
+
ancestorComponent["s-pc"] = [];
|
|
4672
|
+
}
|
|
4673
|
+
if (ancestorComponent["s-p"]) {
|
|
4674
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
4675
|
+
break;
|
|
4676
|
+
}
|
|
4614
4677
|
}
|
|
4615
4678
|
}
|
|
4616
4679
|
if (BUILD$1.prop && !BUILD$1.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -4726,48 +4789,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4726
4789
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4727
4790
|
);
|
|
4728
4791
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4729
|
-
if (
|
|
4730
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4731
|
-
if (ctor) {
|
|
4732
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4733
|
-
if (key === "constructor") continue;
|
|
4734
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4735
|
-
}
|
|
4736
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4737
|
-
if (styleDesc) {
|
|
4738
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4739
|
-
const newStyle = NewClass.style;
|
|
4740
|
-
if (newStyle) {
|
|
4741
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4742
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4743
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4744
|
-
tag: cmpMeta.$tagName$,
|
|
4745
|
-
scopeId,
|
|
4746
|
-
isShadow,
|
|
4747
|
-
cssLen: newStyle.length
|
|
4748
|
-
});
|
|
4749
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4750
|
-
}
|
|
4751
|
-
}
|
|
4752
|
-
}
|
|
4753
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4754
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4755
|
-
const hostRef = getHostRef(el);
|
|
4756
|
-
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4757
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4758
|
-
hostRef.$rmListeners$ = void 0;
|
|
4759
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4760
|
-
}
|
|
4761
|
-
if (!isShadow && hostRef) {
|
|
4762
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4763
|
-
attachStyles(hostRef);
|
|
4764
|
-
}
|
|
4765
|
-
forceUpdate(el);
|
|
4766
|
-
});
|
|
4792
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4767
4793
|
} catch (e) {
|
|
4768
4794
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4769
4795
|
}
|
|
4770
4796
|
};
|
|
4797
|
+
/**
|
|
4798
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4799
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4800
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4801
|
+
*
|
|
4802
|
+
* @param cmpMeta runtime metadata for the component
|
|
4803
|
+
* @param NewClass the component's newly executed class
|
|
4804
|
+
*/
|
|
4805
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4806
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4807
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4808
|
+
if (ctor && ctor !== NewClass) {
|
|
4809
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4810
|
+
if (key === "constructor") continue;
|
|
4811
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4812
|
+
}
|
|
4813
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4814
|
+
if (styleDesc) {
|
|
4815
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4816
|
+
const newStyle = NewClass.style;
|
|
4817
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4821
|
+
const hostRef = getHostRef(el);
|
|
4822
|
+
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4823
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4824
|
+
hostRef.$rmListeners$ = void 0;
|
|
4825
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4826
|
+
}
|
|
4827
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4828
|
+
forceUpdate(el);
|
|
4829
|
+
});
|
|
4830
|
+
};
|
|
4771
4831
|
//#endregion
|
|
4772
4832
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4773
4833
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4790,9 +4850,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4790
4850
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4791
4851
|
}
|
|
4792
4852
|
if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4793
|
-
if (BUILD$1.hotModuleReplacement)
|
|
4794
|
-
|
|
4795
|
-
|
|
4853
|
+
if (BUILD$1.hotModuleReplacement) {
|
|
4854
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4855
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4856
|
+
};
|
|
4857
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4858
|
+
}
|
|
4796
4859
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4797
4860
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4798
4861
|
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -4831,7 +4894,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4831
4894
|
}
|
|
4832
4895
|
connectedCallback(this);
|
|
4833
4896
|
if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4834
|
-
await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4897
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
4835
4898
|
if (!this.isConnected) return;
|
|
4836
4899
|
}
|
|
4837
4900
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
@@ -5146,7 +5209,7 @@ function Mixin(...mixins) {
|
|
|
5146
5209
|
//#region src/runtime/nonce.ts
|
|
5147
5210
|
/**
|
|
5148
5211
|
* Assigns the given value to the nonce property on the runtime platform object.
|
|
5149
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created
|
|
5212
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
|
|
5150
5213
|
* @param nonce The value to be assigned to the platform nonce property.
|
|
5151
5214
|
* @returns void
|
|
5152
5215
|
*/
|
|
@@ -5308,4 +5371,4 @@ function hasKeys(obj) {
|
|
|
5308
5371
|
return false;
|
|
5309
5372
|
}
|
|
5310
5373
|
//#endregion
|
|
5311
|
-
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,
|
|
5374
|
+
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 };
|