@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
package/dist/runtime/index.js
CHANGED
|
@@ -1,12 +1,89 @@
|
|
|
1
1
|
import { BUILD } from "../app-data/index.js";
|
|
2
2
|
import "../app-globals/index.js";
|
|
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.isDev,
|
|
7
79
|
isBrowser: true,
|
|
8
80
|
isServer: false,
|
|
9
|
-
|
|
81
|
+
get isDev() {
|
|
82
|
+
return BUILD.isDev;
|
|
83
|
+
},
|
|
84
|
+
get isTesting() {
|
|
85
|
+
return BUILD.isTesting;
|
|
86
|
+
}
|
|
10
87
|
};
|
|
11
88
|
const MEMBER_FLAGS = {
|
|
12
89
|
String: 1,
|
|
@@ -371,78 +448,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
371
448
|
//#endregion
|
|
372
449
|
//#region src/client/client-style.ts
|
|
373
450
|
const styles = /*@__PURE__*/ new Map();
|
|
374
|
-
const
|
|
451
|
+
const modeResolver = [];
|
|
375
452
|
const needsScopedSSR = () => false;
|
|
376
453
|
//#endregion
|
|
377
|
-
//#region src/runtime/runtime-constants.ts
|
|
378
|
-
/**
|
|
379
|
-
* Bit flags for recording various properties of VDom nodes
|
|
380
|
-
*/
|
|
381
|
-
const VNODE_FLAGS = {
|
|
382
|
-
/**
|
|
383
|
-
* Whether or not a vdom node is a slot reference
|
|
384
|
-
*/
|
|
385
|
-
isSlotReference: 1,
|
|
386
|
-
/**
|
|
387
|
-
* Whether or not a slot element has fallback content
|
|
388
|
-
*/
|
|
389
|
-
isSlotFallback: 2,
|
|
390
|
-
/**
|
|
391
|
-
* Whether or not an element is a host element
|
|
392
|
-
*/
|
|
393
|
-
isHost: 4
|
|
394
|
-
};
|
|
395
|
-
const PROXY_FLAGS = {
|
|
396
|
-
isElementConstructor: 1,
|
|
397
|
-
proxyState: 2
|
|
398
|
-
};
|
|
399
|
-
const PLATFORM_FLAGS = {
|
|
400
|
-
/**
|
|
401
|
-
* designates a node in the DOM as being actively moved by the runtime
|
|
402
|
-
*/
|
|
403
|
-
isTmpDisconnected: 1,
|
|
404
|
-
appLoaded: 2,
|
|
405
|
-
queueSync: 4,
|
|
406
|
-
queueMask: 6
|
|
407
|
-
};
|
|
408
|
-
/**
|
|
409
|
-
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
410
|
-
* values are based on the values which can possibly be returned by the
|
|
411
|
-
* `.nodeType` property of a DOM node. See here for details:
|
|
412
|
-
*
|
|
413
|
-
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
414
|
-
*/
|
|
415
|
-
const NODE_TYPE = {
|
|
416
|
-
ElementNode: 1,
|
|
417
|
-
TextNode: 3,
|
|
418
|
-
CommentNode: 8,
|
|
419
|
-
DocumentNode: 9,
|
|
420
|
-
DocumentTypeNode: 10,
|
|
421
|
-
DocumentFragment: 11
|
|
422
|
-
};
|
|
423
|
-
const HYDRATE_ID = "s-id";
|
|
424
|
-
const HYDRATED_STYLE_ID = "sty-id";
|
|
425
|
-
const HYDRATE_CHILD_ID = "c-id";
|
|
426
|
-
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
427
|
-
/**
|
|
428
|
-
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
429
|
-
*
|
|
430
|
-
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
431
|
-
* support as of Stencil v4.
|
|
432
|
-
*/
|
|
433
|
-
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
434
|
-
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
435
|
-
/**
|
|
436
|
-
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
437
|
-
*/
|
|
438
|
-
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
439
|
-
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
440
|
-
"formAssociatedCallback",
|
|
441
|
-
"formResetCallback",
|
|
442
|
-
"formDisabledCallback",
|
|
443
|
-
"formStateRestoreCallback"
|
|
444
|
-
];
|
|
445
|
-
//#endregion
|
|
446
454
|
//#region src/client/client-window.ts
|
|
447
455
|
const win = typeof window !== "undefined" ? window : {};
|
|
448
456
|
win.HTMLElement;
|
|
@@ -480,7 +488,7 @@ let queuePending = false;
|
|
|
480
488
|
const queueDomReads = [];
|
|
481
489
|
const queueDomWrites = [];
|
|
482
490
|
const queueDomWritesLow = [];
|
|
483
|
-
const scheduleFlush = () => win.document?.hidden ?
|
|
491
|
+
const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
|
|
484
492
|
const queueTask = (queue, write) => (cb) => {
|
|
485
493
|
queue.push(cb);
|
|
486
494
|
if (!queuePending) {
|
|
@@ -1557,6 +1565,13 @@ const isComplexType = (o) => {
|
|
|
1557
1565
|
return o === "object" || o === "function";
|
|
1558
1566
|
};
|
|
1559
1567
|
//#endregion
|
|
1568
|
+
//#region src/runtime/signals-core.ts
|
|
1569
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
1570
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
1571
|
+
function signal(value, options) {
|
|
1572
|
+
return getCore().signal(value, options);
|
|
1573
|
+
}
|
|
1574
|
+
//#endregion
|
|
1560
1575
|
//#region src/runtime/event-emitter.ts
|
|
1561
1576
|
const createEvent = (ref, name, flags) => {
|
|
1562
1577
|
const elm = getElement(ref);
|
|
@@ -1589,6 +1604,11 @@ const setRegistry = (registry) => {
|
|
|
1589
1604
|
_registry = registry;
|
|
1590
1605
|
};
|
|
1591
1606
|
const getRegistry = () => _registry ?? customElements;
|
|
1607
|
+
/**
|
|
1608
|
+
* @param elm a defined component host
|
|
1609
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
1610
|
+
*/
|
|
1611
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
1592
1612
|
//#endregion
|
|
1593
1613
|
//#region src/runtime/vdom/set-accessor.ts
|
|
1594
1614
|
/**
|
|
@@ -1632,7 +1652,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1632
1652
|
attrMap.get(memberName)?.();
|
|
1633
1653
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
1634
1654
|
let prevVal = oldValue;
|
|
1635
|
-
attrMap.set(memberName, effect
|
|
1655
|
+
attrMap.set(memberName, effect(() => {
|
|
1636
1656
|
const curVal = newValue.value;
|
|
1637
1657
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
1638
1658
|
prevVal = curVal;
|
|
@@ -1712,10 +1732,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1712
1732
|
const isComplex = isComplexType(newValue);
|
|
1713
1733
|
if (!BUILD.lazyLoad) {
|
|
1714
1734
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1715
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1735
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1716
1736
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1717
1737
|
elm["s-pp"].set(memberName, newValue);
|
|
1718
|
-
return;
|
|
1738
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1719
1739
|
}
|
|
1720
1740
|
}
|
|
1721
1741
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -1833,6 +1853,7 @@ function sortedAttrNames(attrNames) {
|
|
|
1833
1853
|
let scopeId;
|
|
1834
1854
|
let contentRef;
|
|
1835
1855
|
let hostTagName;
|
|
1856
|
+
let hostRegistry;
|
|
1836
1857
|
let useNativeShadowDom = false;
|
|
1837
1858
|
let checkSlotFallbackVisibility = false;
|
|
1838
1859
|
let checkSlotRelocate = false;
|
|
@@ -1849,16 +1870,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
1849
1870
|
const disposeSignalVNode = (vnode) => {
|
|
1850
1871
|
const elm = vnode.$elm$;
|
|
1851
1872
|
if (elm) {
|
|
1852
|
-
|
|
1853
|
-
if (dispose) {
|
|
1854
|
-
dispose();
|
|
1855
|
-
signalNodeDisposers.delete(elm);
|
|
1856
|
-
}
|
|
1873
|
+
disposeTextSignal(elm);
|
|
1857
1874
|
disposeAllSignalAttrs(elm);
|
|
1858
1875
|
}
|
|
1859
1876
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
1860
1877
|
};
|
|
1861
1878
|
/**
|
|
1879
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
1880
|
+
* @param textNode the text node to unsubscribe
|
|
1881
|
+
*/
|
|
1882
|
+
const disposeTextSignal = (textNode) => {
|
|
1883
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
1884
|
+
if (dispose) {
|
|
1885
|
+
dispose();
|
|
1886
|
+
signalNodeDisposers.delete(textNode);
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
/**
|
|
1890
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
1891
|
+
* @param textNode the text node to keep in sync
|
|
1892
|
+
* @param textSig the signal to subscribe to
|
|
1893
|
+
*/
|
|
1894
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
1895
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
1896
|
+
textNode.data = String(textSig.value);
|
|
1897
|
+
}));
|
|
1898
|
+
};
|
|
1899
|
+
/**
|
|
1862
1900
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
1863
1901
|
*
|
|
1864
1902
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -1880,13 +1918,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1880
1918
|
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`);
|
|
1881
1919
|
if (BUILD.vdomText && newVNode.$text$ != null) {
|
|
1882
1920
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
1883
|
-
if (BUILD.vdomSignals && newVNode.$signal$)
|
|
1884
|
-
const textSig = newVNode.$signal$;
|
|
1885
|
-
const textNode = elm;
|
|
1886
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
1887
|
-
textNode.data = String(textSig.value);
|
|
1888
|
-
}));
|
|
1889
|
-
}
|
|
1921
|
+
if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
1890
1922
|
} else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
1891
1923
|
elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
1892
1924
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -1895,8 +1927,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1895
1927
|
if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
1896
1928
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
1897
1929
|
const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
1898
|
-
const
|
|
1899
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
1930
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
1900
1931
|
elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
1901
1932
|
if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
1902
1933
|
if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2154,7 +2185,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2154
2185
|
}
|
|
2155
2186
|
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
2156
2187
|
elmToMove = oldCh[idxInOld];
|
|
2157
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2188
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2158
2189
|
else {
|
|
2159
2190
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2160
2191
|
oldCh[idxInOld] = void 0;
|
|
@@ -2247,7 +2278,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2247
2278
|
else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2248
2279
|
if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2249
2280
|
} else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2250
|
-
else if (BUILD.vdomText
|
|
2281
|
+
else if (BUILD.vdomText) {
|
|
2282
|
+
if (BUILD.vdomSignals && newVNode.$signal$) {
|
|
2283
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2284
|
+
disposeTextSignal(elm);
|
|
2285
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2286
|
+
}
|
|
2287
|
+
} else {
|
|
2288
|
+
if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2289
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2251
2292
|
};
|
|
2252
2293
|
/**
|
|
2253
2294
|
* Component-global information about nodes which are either currently being
|
|
@@ -2435,6 +2476,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2435
2476
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2436
2477
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2437
2478
|
hostTagName = hostElm.tagName;
|
|
2479
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2438
2480
|
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2439
2481
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2440
2482
|
|
|
@@ -2587,11 +2629,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
2587
2629
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
2588
2630
|
*
|
|
2589
2631
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2632
|
+
* @param registry the registry the waiting component is defined in
|
|
2590
2633
|
*/
|
|
2591
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2634
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
2592
2635
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2593
2636
|
if (!BUILD.lazyLoad && !ancestorHostRef) {
|
|
2594
|
-
await
|
|
2637
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2595
2638
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
2596
2639
|
}
|
|
2597
2640
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -2947,8 +2990,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2947
2990
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2948
2991
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
2949
2992
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
2950
|
-
const
|
|
2951
|
-
const sig = signal(initialVal);
|
|
2993
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
2952
2994
|
hostRef.$signalValues$.set(memberName, sig);
|
|
2953
2995
|
let prevScheduleVal = sig.peek();
|
|
2954
2996
|
disposers.push(effect(() => {
|
|
@@ -3076,9 +3118,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3076
3118
|
if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3077
3119
|
}
|
|
3078
3120
|
}
|
|
3079
|
-
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
3080
|
-
- You are NOT using hostData() and <Host> in the same component.
|
|
3081
|
-
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
3121
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3082
3122
|
if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3083
3123
|
const vnode = newVNode(nodeName, null);
|
|
3084
3124
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3131,17 +3171,23 @@ const vdomFnUtils = {
|
|
|
3131
3171
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3132
3172
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3133
3173
|
*
|
|
3134
|
-
*
|
|
3174
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3175
|
+
* become text-only child nodes.
|
|
3176
|
+
*
|
|
3177
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3135
3178
|
* @returns a converted child node
|
|
3136
3179
|
*/
|
|
3137
|
-
const convertToPublic = (node) =>
|
|
3180
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3181
|
+
vtag: null,
|
|
3182
|
+
vtext: String(node)
|
|
3183
|
+
} : {
|
|
3138
3184
|
vattrs: node.$attrs$,
|
|
3139
3185
|
vchildren: node.$children$,
|
|
3140
3186
|
vkey: node.$key$,
|
|
3141
3187
|
vname: node.$name$,
|
|
3142
3188
|
vtag: node.$tag$,
|
|
3143
3189
|
vtext: node.$text$
|
|
3144
|
-
}
|
|
3190
|
+
};
|
|
3145
3191
|
/**
|
|
3146
3192
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3147
3193
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3158,11 +3204,11 @@ const convertToPrivate = (node) => {
|
|
|
3158
3204
|
if (node.vname) vnodeData.name = node.vname;
|
|
3159
3205
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3160
3206
|
}
|
|
3161
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3162
|
-
vnode.$attrs$ = node.vattrs;
|
|
3163
|
-
vnode.$children$ = node.vchildren;
|
|
3164
|
-
vnode.$key$ = node.vkey;
|
|
3165
|
-
vnode.$name$ = node.vname;
|
|
3207
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3208
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3209
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3210
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3211
|
+
vnode.$name$ = node.vname ?? null;
|
|
3166
3212
|
return vnode;
|
|
3167
3213
|
};
|
|
3168
3214
|
/**
|
|
@@ -3460,6 +3506,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3460
3506
|
const createSimpleVNode = (vnode) => ({
|
|
3461
3507
|
$flags$: 0,
|
|
3462
3508
|
$index$: "0",
|
|
3509
|
+
$children$: null,
|
|
3463
3510
|
...vnode
|
|
3464
3511
|
});
|
|
3465
3512
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -3854,7 +3901,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
3854
3901
|
else return shallowPart.trim();
|
|
3855
3902
|
}).join(", ");
|
|
3856
3903
|
};
|
|
3857
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
3904
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
3858
3905
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
3859
3906
|
return processRules(cssText, (rule) => {
|
|
3860
3907
|
let selector = rule.selector;
|
|
@@ -3973,8 +4020,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
3973
4020
|
};
|
|
3974
4021
|
//#endregion
|
|
3975
4022
|
//#region src/runtime/mode.ts
|
|
3976
|
-
const computeMode = (elm) =>
|
|
3977
|
-
const setMode = (handler) =>
|
|
4023
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4024
|
+
const setMode = (handler) => {
|
|
4025
|
+
modeResolver.length = 0;
|
|
4026
|
+
modeResolver.push(handler);
|
|
4027
|
+
};
|
|
3978
4028
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
3979
4029
|
//#endregion
|
|
3980
4030
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4039,23 +4089,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4039
4089
|
*
|
|
4040
4090
|
* @param propValue the new value to coerce to some type
|
|
4041
4091
|
* @param propType the type of the prop, expressed as a binary number
|
|
4042
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4043
4092
|
* @returns the parsed/coerced value
|
|
4044
4093
|
*/
|
|
4045
|
-
const parsePropertyValue = (propValue, propType
|
|
4094
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4046
4095
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4047
4096
|
/**
|
|
4048
4097
|
* ensure this value is of the correct prop type
|
|
4049
4098
|
*/
|
|
4050
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4051
|
-
/**
|
|
4052
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4053
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4054
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4055
|
-
*/
|
|
4056
|
-
if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4057
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4058
|
-
}
|
|
4099
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4059
4100
|
/**
|
|
4060
4101
|
* force it to be a number
|
|
4061
4102
|
*/
|
|
@@ -4097,7 +4138,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4097
4138
|
if (BUILD.signalBacking) {
|
|
4098
4139
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4099
4140
|
if (sig !== void 0) {
|
|
4100
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4141
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4101
4142
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4102
4143
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4103
4144
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4115,7 +4156,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4115
4156
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4116
4157
|
const flags = hostRef.$flags$;
|
|
4117
4158
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4118
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4159
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4119
4160
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4120
4161
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4121
4162
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4164,6 +4205,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4164
4205
|
*/
|
|
4165
4206
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4166
4207
|
/**
|
|
4208
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4209
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4210
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4211
|
+
*
|
|
4212
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4213
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4214
|
+
*/
|
|
4215
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4216
|
+
const instance = hostRef.$lazyInstance$;
|
|
4217
|
+
if (!instance) return;
|
|
4218
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4219
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4220
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4221
|
+
}
|
|
4222
|
+
};
|
|
4223
|
+
/**
|
|
4167
4224
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4168
4225
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4169
4226
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4220,9 +4277,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4220
4277
|
if (BUILD.lazyLoad) {
|
|
4221
4278
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4222
4279
|
const ref = getHostRef(this);
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
return instance[memberName];
|
|
4280
|
+
if (!ref) return prototype[memberName];
|
|
4281
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4226
4282
|
}
|
|
4227
4283
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4228
4284
|
},
|
|
@@ -4237,7 +4293,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4237
4293
|
}
|
|
4238
4294
|
if (origSetter) {
|
|
4239
4295
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4240
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4296
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4241
4297
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4242
4298
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4243
4299
|
return;
|
|
@@ -4249,21 +4305,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4249
4305
|
if (BUILD.lazyLoad) {
|
|
4250
4306
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4251
4307
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4252
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4253
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4254
|
-
});
|
|
4255
4308
|
return;
|
|
4256
4309
|
}
|
|
4257
|
-
const
|
|
4310
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4311
|
+
if (ref.$lazyInstance$) {
|
|
4258
4312
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4259
4313
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4260
|
-
ref.$lazyInstance$[memberName] =
|
|
4314
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4261
4315
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4262
|
-
};
|
|
4263
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4264
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4265
|
-
setterSetVal();
|
|
4266
|
-
});
|
|
4316
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4267
4317
|
}
|
|
4268
4318
|
} });
|
|
4269
4319
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4315,7 +4365,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4315
4365
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4316
4366
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4317
4367
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4318
|
-
if (isBooleanTarget)
|
|
4368
|
+
if (isBooleanTarget) {
|
|
4369
|
+
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.`);
|
|
4370
|
+
newValue = newValue !== null;
|
|
4371
|
+
}
|
|
4319
4372
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4320
4373
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4321
4374
|
});
|
|
@@ -4378,9 +4431,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4378
4431
|
} catch (e) {
|
|
4379
4432
|
consoleError(e, elm);
|
|
4380
4433
|
}
|
|
4381
|
-
if (BUILD.member)
|
|
4434
|
+
if (BUILD.member) {
|
|
4435
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4436
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4437
|
+
}
|
|
4382
4438
|
endNewInstance();
|
|
4383
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4439
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4384
4440
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4385
4441
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4386
4442
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4480,9 +4536,16 @@ const connectedCallback = (elm) => {
|
|
|
4480
4536
|
}
|
|
4481
4537
|
if (BUILD.asyncLoading) {
|
|
4482
4538
|
let ancestorComponent = elm;
|
|
4483
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4484
|
-
|
|
4485
|
-
|
|
4539
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
4540
|
+
if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
4541
|
+
ancestorComponent["s-p"] = [];
|
|
4542
|
+
ancestorComponent["s-rc"] = [];
|
|
4543
|
+
ancestorComponent["s-pc"] = [];
|
|
4544
|
+
}
|
|
4545
|
+
if (ancestorComponent["s-p"]) {
|
|
4546
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
4547
|
+
break;
|
|
4548
|
+
}
|
|
4486
4549
|
}
|
|
4487
4550
|
}
|
|
4488
4551
|
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -4598,48 +4661,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4598
4661
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4599
4662
|
);
|
|
4600
4663
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4601
|
-
if (
|
|
4602
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4603
|
-
if (ctor) {
|
|
4604
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4605
|
-
if (key === "constructor") continue;
|
|
4606
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4607
|
-
}
|
|
4608
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4609
|
-
if (styleDesc) {
|
|
4610
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4611
|
-
const newStyle = NewClass.style;
|
|
4612
|
-
if (newStyle) {
|
|
4613
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4614
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4615
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4616
|
-
tag: cmpMeta.$tagName$,
|
|
4617
|
-
scopeId,
|
|
4618
|
-
isShadow,
|
|
4619
|
-
cssLen: newStyle.length
|
|
4620
|
-
});
|
|
4621
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4622
|
-
}
|
|
4623
|
-
}
|
|
4624
|
-
}
|
|
4625
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4626
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4627
|
-
const hostRef = getHostRef(el);
|
|
4628
|
-
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4629
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4630
|
-
hostRef.$rmListeners$ = void 0;
|
|
4631
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4632
|
-
}
|
|
4633
|
-
if (!isShadow && hostRef) {
|
|
4634
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4635
|
-
attachStyles(hostRef);
|
|
4636
|
-
}
|
|
4637
|
-
forceUpdate(el);
|
|
4638
|
-
});
|
|
4664
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4639
4665
|
} catch (e) {
|
|
4640
4666
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4641
4667
|
}
|
|
4642
4668
|
};
|
|
4669
|
+
/**
|
|
4670
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4671
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4672
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4673
|
+
*
|
|
4674
|
+
* @param cmpMeta runtime metadata for the component
|
|
4675
|
+
* @param NewClass the component's newly executed class
|
|
4676
|
+
*/
|
|
4677
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4678
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4679
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4680
|
+
if (ctor && ctor !== NewClass) {
|
|
4681
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4682
|
+
if (key === "constructor") continue;
|
|
4683
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4684
|
+
}
|
|
4685
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4686
|
+
if (styleDesc) {
|
|
4687
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4688
|
+
const newStyle = NewClass.style;
|
|
4689
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4693
|
+
const hostRef = getHostRef(el);
|
|
4694
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4695
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4696
|
+
hostRef.$rmListeners$ = void 0;
|
|
4697
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4698
|
+
}
|
|
4699
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4700
|
+
forceUpdate(el);
|
|
4701
|
+
});
|
|
4702
|
+
};
|
|
4643
4703
|
//#endregion
|
|
4644
4704
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4645
4705
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4662,9 +4722,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4662
4722
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4663
4723
|
}
|
|
4664
4724
|
if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4665
|
-
if (BUILD.hotModuleReplacement)
|
|
4666
|
-
|
|
4667
|
-
|
|
4725
|
+
if (BUILD.hotModuleReplacement) {
|
|
4726
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4727
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4728
|
+
};
|
|
4729
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4730
|
+
}
|
|
4668
4731
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4669
4732
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4670
4733
|
if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -4703,7 +4766,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4703
4766
|
}
|
|
4704
4767
|
connectedCallback(this);
|
|
4705
4768
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4706
|
-
await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4769
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
4707
4770
|
if (!this.isConnected) return;
|
|
4708
4771
|
}
|
|
4709
4772
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
@@ -5018,7 +5081,7 @@ function Mixin(...mixins) {
|
|
|
5018
5081
|
//#region src/runtime/nonce.ts
|
|
5019
5082
|
/**
|
|
5020
5083
|
* Assigns the given value to the nonce property on the runtime platform object.
|
|
5021
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created
|
|
5084
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
|
|
5022
5085
|
* @param nonce The value to be assigned to the platform nonce property.
|
|
5023
5086
|
* @returns void
|
|
5024
5087
|
*/
|