@stencil/core 5.0.0-beta.2 → 5.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-data/index.d.ts +1 -1
- package/dist/{client-BRu0GtRn.mjs → client-CVXS3JZ-.mjs} +105 -60
- package/dist/compiler/browser.d.ts +110 -79
- package/dist/compiler/browser.js +542 -241
- 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-C8yf59oh.mjs → compiler-CUsOl_Kw.mjs} +4428 -2709
- package/dist/declarations/stencil-public-compiler.d.ts +144 -120
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +60 -58
- package/dist/{index-BopBfjPu.d.mts → index-B9-Byy8z.d.mts} +142 -118
- package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
- package/dist/{index-DmHmu3y0.d.mts → index-Dz1G9pWZ.d.mts} +2 -2
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-75gQKkFz.mjs → node-Bz2SOK7_.mjs} +6 -35
- package/dist/runtime/client/lazy.js +228 -180
- package/dist/runtime/client/runtime.d.ts +67 -66
- package/dist/runtime/client/runtime.js +228 -180
- package/dist/runtime/index.d.ts +4 -5
- package/dist/runtime/index.js +226 -178
- package/dist/runtime/server/index.d.mts +11 -11
- package/dist/runtime/server/index.mjs +287 -220
- 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 +11 -1
- 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 +129 -112
- package/dist/testing/index.mjs +244 -193
- package/package.json +8 -4
|
@@ -1,6 +1,105 @@
|
|
|
1
1
|
import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/app-data";
|
|
2
2
|
import { globalScripts, globalStyles } from "@stencil/core/app-globals";
|
|
3
|
-
import
|
|
3
|
+
import * as SignalsCore from "@preact/signals-core";
|
|
4
|
+
//#region src/runtime/runtime-constants.ts
|
|
5
|
+
/**
|
|
6
|
+
* Bit flags for recording various properties of VDom nodes
|
|
7
|
+
*/
|
|
8
|
+
const VNODE_FLAGS = {
|
|
9
|
+
/**
|
|
10
|
+
* Whether or not a vdom node is a slot reference
|
|
11
|
+
*/
|
|
12
|
+
isSlotReference: 1,
|
|
13
|
+
/**
|
|
14
|
+
* Whether or not a slot element has fallback content
|
|
15
|
+
*/
|
|
16
|
+
isSlotFallback: 2,
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not an element is a host element
|
|
19
|
+
*/
|
|
20
|
+
isHost: 4
|
|
21
|
+
};
|
|
22
|
+
const PROXY_FLAGS = {
|
|
23
|
+
isElementConstructor: 1,
|
|
24
|
+
proxyState: 2
|
|
25
|
+
};
|
|
26
|
+
const PLATFORM_FLAGS = {
|
|
27
|
+
/**
|
|
28
|
+
* designates a node in the DOM as being actively moved by the runtime
|
|
29
|
+
*/
|
|
30
|
+
isTmpDisconnected: 1,
|
|
31
|
+
appLoaded: 2,
|
|
32
|
+
queueSync: 4,
|
|
33
|
+
queueMask: 6
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
37
|
+
* values are based on the values which can possibly be returned by the
|
|
38
|
+
* `.nodeType` property of a DOM node. See here for details:
|
|
39
|
+
*
|
|
40
|
+
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
41
|
+
*/
|
|
42
|
+
const NODE_TYPE = {
|
|
43
|
+
ElementNode: 1,
|
|
44
|
+
TextNode: 3,
|
|
45
|
+
CommentNode: 8,
|
|
46
|
+
DocumentNode: 9,
|
|
47
|
+
DocumentTypeNode: 10,
|
|
48
|
+
DocumentFragment: 11
|
|
49
|
+
};
|
|
50
|
+
const HYDRATE_ID = "s-id";
|
|
51
|
+
const HYDRATED_STYLE_ID = "sty-id";
|
|
52
|
+
const HYDRATE_CHILD_ID = "c-id";
|
|
53
|
+
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
54
|
+
const STENCIL_DOC_DATA = "_stencilDocData";
|
|
55
|
+
const DEFAULT_DOC_DATA = {
|
|
56
|
+
hostIds: 0,
|
|
57
|
+
rootLevelIds: 0,
|
|
58
|
+
staticComponents: /* @__PURE__ */ new Set()
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
62
|
+
*
|
|
63
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
64
|
+
* support as of Stencil v4.
|
|
65
|
+
*/
|
|
66
|
+
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
67
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
68
|
+
/**
|
|
69
|
+
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
70
|
+
*/
|
|
71
|
+
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
72
|
+
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
73
|
+
"formAssociatedCallback",
|
|
74
|
+
"formResetCallback",
|
|
75
|
+
"formDisabledCallback",
|
|
76
|
+
"formStateRestoreCallback"
|
|
77
|
+
];
|
|
78
|
+
const SERVER_BUILD_FLAGS = {
|
|
79
|
+
isBrowser: false,
|
|
80
|
+
isServer: true,
|
|
81
|
+
isDev: false,
|
|
82
|
+
isTesting: false
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/runtime/tag-transform.ts
|
|
86
|
+
let tagTransformer = void 0;
|
|
87
|
+
/**
|
|
88
|
+
* Transforms a tag name using the current tag transformer
|
|
89
|
+
* @param tag - the tag to transform e.g. `my-tag`
|
|
90
|
+
* @returns the transformed tag e.g. `new-my-tag`
|
|
91
|
+
*/
|
|
92
|
+
function transformTag(tag) {
|
|
93
|
+
if (!tagTransformer) return tag;
|
|
94
|
+
return tagTransformer(tag);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Sets the tag transformer to be used when rendering custom elements
|
|
98
|
+
* @param transformer the transformer function to use. Must return a string
|
|
99
|
+
*/
|
|
100
|
+
function setTagTransformer(transformer) {
|
|
101
|
+
tagTransformer = transformer;
|
|
102
|
+
}
|
|
4
103
|
const MEMBER_FLAGS = {
|
|
5
104
|
String: 1,
|
|
6
105
|
Number: 2,
|
|
@@ -253,81 +352,6 @@ const reWireGetterSetter = (instance, hostRef) => {
|
|
|
253
352
|
});
|
|
254
353
|
};
|
|
255
354
|
//#endregion
|
|
256
|
-
//#region src/runtime/runtime-constants.ts
|
|
257
|
-
/**
|
|
258
|
-
* Bit flags for recording various properties of VDom nodes
|
|
259
|
-
*/
|
|
260
|
-
const VNODE_FLAGS = {
|
|
261
|
-
/**
|
|
262
|
-
* Whether or not a vdom node is a slot reference
|
|
263
|
-
*/
|
|
264
|
-
isSlotReference: 1,
|
|
265
|
-
/**
|
|
266
|
-
* Whether or not a slot element has fallback content
|
|
267
|
-
*/
|
|
268
|
-
isSlotFallback: 2,
|
|
269
|
-
/**
|
|
270
|
-
* Whether or not an element is a host element
|
|
271
|
-
*/
|
|
272
|
-
isHost: 4
|
|
273
|
-
};
|
|
274
|
-
const PROXY_FLAGS = {
|
|
275
|
-
isElementConstructor: 1,
|
|
276
|
-
proxyState: 2
|
|
277
|
-
};
|
|
278
|
-
const PLATFORM_FLAGS = {
|
|
279
|
-
/**
|
|
280
|
-
* designates a node in the DOM as being actively moved by the runtime
|
|
281
|
-
*/
|
|
282
|
-
isTmpDisconnected: 1,
|
|
283
|
-
appLoaded: 2,
|
|
284
|
-
queueSync: 4,
|
|
285
|
-
queueMask: 6
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
289
|
-
* values are based on the values which can possibly be returned by the
|
|
290
|
-
* `.nodeType` property of a DOM node. See here for details:
|
|
291
|
-
*
|
|
292
|
-
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
293
|
-
*/
|
|
294
|
-
const NODE_TYPE = {
|
|
295
|
-
ElementNode: 1,
|
|
296
|
-
TextNode: 3,
|
|
297
|
-
CommentNode: 8,
|
|
298
|
-
DocumentNode: 9,
|
|
299
|
-
DocumentTypeNode: 10,
|
|
300
|
-
DocumentFragment: 11
|
|
301
|
-
};
|
|
302
|
-
const HYDRATE_ID = "s-id";
|
|
303
|
-
const HYDRATED_STYLE_ID = "sty-id";
|
|
304
|
-
const HYDRATE_CHILD_ID = "c-id";
|
|
305
|
-
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
306
|
-
const STENCIL_DOC_DATA = "_stencilDocData";
|
|
307
|
-
const DEFAULT_DOC_DATA = {
|
|
308
|
-
hostIds: 0,
|
|
309
|
-
rootLevelIds: 0,
|
|
310
|
-
staticComponents: /* @__PURE__ */ new Set()
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
314
|
-
*
|
|
315
|
-
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
316
|
-
* support as of Stencil v4.
|
|
317
|
-
*/
|
|
318
|
-
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
319
|
-
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
320
|
-
/**
|
|
321
|
-
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
322
|
-
*/
|
|
323
|
-
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
324
|
-
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
325
|
-
"formAssociatedCallback",
|
|
326
|
-
"formResetCallback",
|
|
327
|
-
"formDisabledCallback",
|
|
328
|
-
"formStateRestoreCallback"
|
|
329
|
-
];
|
|
330
|
-
//#endregion
|
|
331
355
|
//#region src/utils/shadow-root.ts
|
|
332
356
|
let globalStyleSheet;
|
|
333
357
|
const GLOBAL_STYLE_ID = "sc-global";
|
|
@@ -1311,6 +1335,13 @@ const isComplexType = (o) => {
|
|
|
1311
1335
|
return o === "object" || o === "function";
|
|
1312
1336
|
};
|
|
1313
1337
|
//#endregion
|
|
1338
|
+
//#region src/runtime/signals-core.ts
|
|
1339
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
1340
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
1341
|
+
function signal(value, options) {
|
|
1342
|
+
return getCore().signal(value, options);
|
|
1343
|
+
}
|
|
1344
|
+
//#endregion
|
|
1314
1345
|
//#region src/runtime/event-emitter.ts
|
|
1315
1346
|
const createEvent = (ref, name, flags) => {
|
|
1316
1347
|
const elm = getElement(ref);
|
|
@@ -1337,6 +1368,11 @@ const emitEvent = (elm, name, opts) => {
|
|
|
1337
1368
|
return ev;
|
|
1338
1369
|
};
|
|
1339
1370
|
const getRegistry = () => customElements;
|
|
1371
|
+
/**
|
|
1372
|
+
* @param elm a defined component host
|
|
1373
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
1374
|
+
*/
|
|
1375
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
1340
1376
|
//#endregion
|
|
1341
1377
|
//#region src/runtime/vdom/set-accessor.ts
|
|
1342
1378
|
/**
|
|
@@ -1380,7 +1416,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1380
1416
|
attrMap.get(memberName)?.();
|
|
1381
1417
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
1382
1418
|
let prevVal = oldValue;
|
|
1383
|
-
attrMap.set(memberName, effect
|
|
1419
|
+
attrMap.set(memberName, effect(() => {
|
|
1384
1420
|
const curVal = newValue.value;
|
|
1385
1421
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
1386
1422
|
prevVal = curVal;
|
|
@@ -1460,10 +1496,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1460
1496
|
const isComplex = isComplexType(newValue);
|
|
1461
1497
|
if (!BUILD$1.lazyLoad) {
|
|
1462
1498
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1463
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1499
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1464
1500
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1465
1501
|
elm["s-pp"].set(memberName, newValue);
|
|
1466
|
-
return;
|
|
1502
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1467
1503
|
}
|
|
1468
1504
|
}
|
|
1469
1505
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -1581,6 +1617,7 @@ function sortedAttrNames(attrNames) {
|
|
|
1581
1617
|
let scopeId;
|
|
1582
1618
|
let contentRef;
|
|
1583
1619
|
let hostTagName;
|
|
1620
|
+
let hostRegistry;
|
|
1584
1621
|
let useNativeShadowDom = false;
|
|
1585
1622
|
let checkSlotFallbackVisibility = false;
|
|
1586
1623
|
let checkSlotRelocate = false;
|
|
@@ -1597,16 +1634,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
1597
1634
|
const disposeSignalVNode = (vnode) => {
|
|
1598
1635
|
const elm = vnode.$elm$;
|
|
1599
1636
|
if (elm) {
|
|
1600
|
-
|
|
1601
|
-
if (dispose) {
|
|
1602
|
-
dispose();
|
|
1603
|
-
signalNodeDisposers.delete(elm);
|
|
1604
|
-
}
|
|
1637
|
+
disposeTextSignal(elm);
|
|
1605
1638
|
disposeAllSignalAttrs(elm);
|
|
1606
1639
|
}
|
|
1607
1640
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
1608
1641
|
};
|
|
1609
1642
|
/**
|
|
1643
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
1644
|
+
* @param textNode the text node to unsubscribe
|
|
1645
|
+
*/
|
|
1646
|
+
const disposeTextSignal = (textNode) => {
|
|
1647
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
1648
|
+
if (dispose) {
|
|
1649
|
+
dispose();
|
|
1650
|
+
signalNodeDisposers.delete(textNode);
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
/**
|
|
1654
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
1655
|
+
* @param textNode the text node to keep in sync
|
|
1656
|
+
* @param textSig the signal to subscribe to
|
|
1657
|
+
*/
|
|
1658
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
1659
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
1660
|
+
textNode.data = String(textSig.value);
|
|
1661
|
+
}));
|
|
1662
|
+
};
|
|
1663
|
+
/**
|
|
1610
1664
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
1611
1665
|
*
|
|
1612
1666
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -1628,13 +1682,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1628
1682
|
if (BUILD$1.isDev && newVNode.$elm$) newVNode.$text$ !== null ? `${newVNode.$text$}` : `${String(newVNode.$tag$)}`;
|
|
1629
1683
|
if (BUILD$1.vdomText && newVNode.$text$ != null) {
|
|
1630
1684
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
1631
|
-
if (BUILD$1.vdomSignals && newVNode.$signal$)
|
|
1632
|
-
const textSig = newVNode.$signal$;
|
|
1633
|
-
const textNode = elm;
|
|
1634
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
1635
|
-
textNode.data = String(textSig.value);
|
|
1636
|
-
}));
|
|
1637
|
-
}
|
|
1685
|
+
if (BUILD$1.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
1638
1686
|
} else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
1639
1687
|
elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
1640
1688
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -1643,8 +1691,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1643
1691
|
if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
1644
1692
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
1645
1693
|
const tag = !useNativeShadowDom && BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
1646
|
-
const
|
|
1647
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
1694
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
1648
1695
|
elm = newVNode.$elm$ = BUILD$1.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
1649
1696
|
if (BUILD$1.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
1650
1697
|
if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -1902,7 +1949,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
1902
1949
|
}
|
|
1903
1950
|
if (BUILD$1.vdomKey && idxInOld >= 0) {
|
|
1904
1951
|
elmToMove = oldCh[idxInOld];
|
|
1905
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
1952
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
1906
1953
|
else {
|
|
1907
1954
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
1908
1955
|
oldCh[idxInOld] = void 0;
|
|
@@ -1995,7 +2042,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
1995
2042
|
else if (BUILD$1.hydrateClientSide && isInitialRender && BUILD$1.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
1996
2043
|
if (BUILD$1.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
1997
2044
|
} else if (BUILD$1.vdomText && BUILD$1.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
1998
|
-
else if (BUILD$1.vdomText
|
|
2045
|
+
else if (BUILD$1.vdomText) {
|
|
2046
|
+
if (BUILD$1.vdomSignals && newVNode.$signal$) {
|
|
2047
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2048
|
+
disposeTextSignal(elm);
|
|
2049
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2050
|
+
}
|
|
2051
|
+
} else {
|
|
2052
|
+
if (BUILD$1.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2053
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
1999
2056
|
};
|
|
2000
2057
|
/**
|
|
2001
2058
|
* Component-global information about nodes which are either currently being
|
|
@@ -2183,6 +2240,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2183
2240
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2184
2241
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2185
2242
|
hostTagName = hostElm.tagName;
|
|
2243
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2186
2244
|
if (BUILD$1.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2187
2245
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2188
2246
|
|
|
@@ -2335,11 +2393,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
2335
2393
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
2336
2394
|
*
|
|
2337
2395
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2396
|
+
* @param registry the registry the waiting component is defined in
|
|
2338
2397
|
*/
|
|
2339
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2398
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
2340
2399
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2341
2400
|
if (!BUILD$1.lazyLoad && !ancestorHostRef) {
|
|
2342
|
-
await
|
|
2401
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2343
2402
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
2344
2403
|
}
|
|
2345
2404
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -2695,8 +2754,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2695
2754
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2696
2755
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
2697
2756
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
2698
|
-
const
|
|
2699
|
-
const sig = signal(initialVal);
|
|
2757
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
2700
2758
|
hostRef.$signalValues$.set(memberName, sig);
|
|
2701
2759
|
let prevScheduleVal = sig.peek();
|
|
2702
2760
|
disposers.push(effect(() => {
|
|
@@ -3598,7 +3656,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
3598
3656
|
else return shallowPart.trim();
|
|
3599
3657
|
}).join(", ");
|
|
3600
3658
|
};
|
|
3601
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
3659
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
3602
3660
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
3603
3661
|
return processRules(cssText, (rule) => {
|
|
3604
3662
|
let selector = rule.selector;
|
|
@@ -3717,8 +3775,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
3717
3775
|
};
|
|
3718
3776
|
//#endregion
|
|
3719
3777
|
//#region src/runtime/mode.ts
|
|
3720
|
-
const computeMode = (elm) =>
|
|
3721
|
-
const setMode = (handler) =>
|
|
3778
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
3779
|
+
const setMode = (handler) => {
|
|
3780
|
+
modeResolver.length = 0;
|
|
3781
|
+
modeResolver.push(handler);
|
|
3782
|
+
};
|
|
3722
3783
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
3723
3784
|
//#endregion
|
|
3724
3785
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -3783,23 +3844,14 @@ const normalizeWatchers = (raw) => {
|
|
|
3783
3844
|
*
|
|
3784
3845
|
* @param propValue the new value to coerce to some type
|
|
3785
3846
|
* @param propType the type of the prop, expressed as a binary number
|
|
3786
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
3787
3847
|
* @returns the parsed/coerced value
|
|
3788
3848
|
*/
|
|
3789
|
-
const parsePropertyValue = (propValue, propType
|
|
3849
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
3790
3850
|
if (propValue != null && !isComplexType(propValue)) {
|
|
3791
3851
|
/**
|
|
3792
3852
|
* ensure this value is of the correct prop type
|
|
3793
3853
|
*/
|
|
3794
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
3795
|
-
/**
|
|
3796
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
3797
|
-
* (regardless of its value, even "false") should make the property true.
|
|
3798
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
3799
|
-
*/
|
|
3800
|
-
if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
3801
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
3802
|
-
}
|
|
3854
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
3803
3855
|
/**
|
|
3804
3856
|
* force it to be a number
|
|
3805
3857
|
*/
|
|
@@ -3841,7 +3893,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
3841
3893
|
if (BUILD$1.signalBacking) {
|
|
3842
3894
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3843
3895
|
if (sig !== void 0) {
|
|
3844
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
3896
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3845
3897
|
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3846
3898
|
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3847
3899
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -3859,7 +3911,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
3859
3911
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3860
3912
|
const flags = hostRef.$flags$;
|
|
3861
3913
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3862
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
3914
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3863
3915
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3864
3916
|
if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3865
3917
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -3908,6 +3960,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
3908
3960
|
*/
|
|
3909
3961
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
3910
3962
|
/**
|
|
3963
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
3964
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
3965
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
3966
|
+
*
|
|
3967
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
3968
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
3969
|
+
*/
|
|
3970
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
3971
|
+
const instance = hostRef.$lazyInstance$;
|
|
3972
|
+
if (!instance) return;
|
|
3973
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
3974
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
3975
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
3976
|
+
}
|
|
3977
|
+
};
|
|
3978
|
+
/**
|
|
3911
3979
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
3912
3980
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
3913
3981
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -3964,9 +4032,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3964
4032
|
if (BUILD$1.lazyLoad) {
|
|
3965
4033
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
3966
4034
|
const ref = getHostRef(this);
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
return instance[memberName];
|
|
4035
|
+
if (!ref) return prototype[memberName];
|
|
4036
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
3970
4037
|
}
|
|
3971
4038
|
if (!BUILD$1.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
3972
4039
|
},
|
|
@@ -3981,7 +4048,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3981
4048
|
}
|
|
3982
4049
|
if (origSetter) {
|
|
3983
4050
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
3984
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4051
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
3985
4052
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
3986
4053
|
setValue(this, memberName, newValue, cmpMeta);
|
|
3987
4054
|
return;
|
|
@@ -3993,21 +4060,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3993
4060
|
if (BUILD$1.lazyLoad) {
|
|
3994
4061
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
3995
4062
|
setValue(this, memberName, newValue, cmpMeta);
|
|
3996
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
3997
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
3998
|
-
});
|
|
3999
4063
|
return;
|
|
4000
4064
|
}
|
|
4001
|
-
const
|
|
4065
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4066
|
+
if (ref.$lazyInstance$) {
|
|
4002
4067
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4003
4068
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4004
|
-
ref.$lazyInstance$[memberName] =
|
|
4069
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4005
4070
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4006
|
-
};
|
|
4007
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4008
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4009
|
-
setterSetVal();
|
|
4010
|
-
});
|
|
4071
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4011
4072
|
}
|
|
4012
4073
|
} });
|
|
4013
4074
|
} else if (BUILD$1.lazyLoad && BUILD$1.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4059,7 +4120,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4059
4120
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4060
4121
|
if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4061
4122
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4062
|
-
if (isBooleanTarget)
|
|
4123
|
+
if (isBooleanTarget) {
|
|
4124
|
+
if (BUILD$1.isDev && newValue === "false") `${cmpMeta.$tagName$}${attrName}${propName}`;
|
|
4125
|
+
newValue = newValue !== null;
|
|
4126
|
+
}
|
|
4063
4127
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4064
4128
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4065
4129
|
});
|
|
@@ -4122,9 +4186,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4122
4186
|
} catch (e) {
|
|
4123
4187
|
consoleError(e, elm);
|
|
4124
4188
|
}
|
|
4125
|
-
if (BUILD$1.member)
|
|
4189
|
+
if (BUILD$1.member) {
|
|
4190
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4191
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4192
|
+
}
|
|
4126
4193
|
endNewInstance();
|
|
4127
|
-
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4194
|
+
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4128
4195
|
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4129
4196
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4130
4197
|
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4224,9 +4291,16 @@ const connectedCallback = (elm) => {
|
|
|
4224
4291
|
}
|
|
4225
4292
|
if (BUILD$1.asyncLoading) {
|
|
4226
4293
|
let ancestorComponent = elm;
|
|
4227
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4228
|
-
|
|
4229
|
-
|
|
4294
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
4295
|
+
if (BUILD$1.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
4296
|
+
ancestorComponent["s-p"] = [];
|
|
4297
|
+
ancestorComponent["s-rc"] = [];
|
|
4298
|
+
ancestorComponent["s-pc"] = [];
|
|
4299
|
+
}
|
|
4300
|
+
if (ancestorComponent["s-p"]) {
|
|
4301
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
4302
|
+
break;
|
|
4303
|
+
}
|
|
4230
4304
|
}
|
|
4231
4305
|
}
|
|
4232
4306
|
if (BUILD$1.prop && !BUILD$1.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -4342,48 +4416,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4342
4416
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4343
4417
|
);
|
|
4344
4418
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4345
|
-
if (
|
|
4346
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4347
|
-
if (ctor) {
|
|
4348
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4349
|
-
if (key === "constructor") continue;
|
|
4350
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4351
|
-
}
|
|
4352
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4353
|
-
if (styleDesc) {
|
|
4354
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4355
|
-
const newStyle = NewClass.style;
|
|
4356
|
-
if (newStyle) {
|
|
4357
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4358
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4359
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4360
|
-
tag: cmpMeta.$tagName$,
|
|
4361
|
-
scopeId,
|
|
4362
|
-
isShadow,
|
|
4363
|
-
cssLen: newStyle.length
|
|
4364
|
-
});
|
|
4365
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4366
|
-
}
|
|
4367
|
-
}
|
|
4368
|
-
}
|
|
4369
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4370
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4371
|
-
const hostRef = getHostRef(el);
|
|
4372
|
-
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4373
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4374
|
-
hostRef.$rmListeners$ = void 0;
|
|
4375
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4376
|
-
}
|
|
4377
|
-
if (!isShadow && hostRef) {
|
|
4378
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4379
|
-
attachStyles(hostRef);
|
|
4380
|
-
}
|
|
4381
|
-
forceUpdate(el);
|
|
4382
|
-
});
|
|
4419
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4383
4420
|
} catch (e) {
|
|
4384
4421
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4385
4422
|
}
|
|
4386
4423
|
};
|
|
4424
|
+
/**
|
|
4425
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4426
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4427
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4428
|
+
*
|
|
4429
|
+
* @param cmpMeta runtime metadata for the component
|
|
4430
|
+
* @param NewClass the component's newly executed class
|
|
4431
|
+
*/
|
|
4432
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4433
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4434
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4435
|
+
if (ctor && ctor !== NewClass) {
|
|
4436
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4437
|
+
if (key === "constructor") continue;
|
|
4438
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4439
|
+
}
|
|
4440
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4441
|
+
if (styleDesc) {
|
|
4442
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4443
|
+
const newStyle = NewClass.style;
|
|
4444
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4447
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4448
|
+
const hostRef = getHostRef(el);
|
|
4449
|
+
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4450
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4451
|
+
hostRef.$rmListeners$ = void 0;
|
|
4452
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4453
|
+
}
|
|
4454
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4455
|
+
forceUpdate(el);
|
|
4456
|
+
});
|
|
4457
|
+
};
|
|
4387
4458
|
//#endregion
|
|
4388
4459
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4389
4460
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4406,9 +4477,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4406
4477
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4407
4478
|
}
|
|
4408
4479
|
if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4409
|
-
if (BUILD$1.hotModuleReplacement)
|
|
4410
|
-
|
|
4411
|
-
|
|
4480
|
+
if (BUILD$1.hotModuleReplacement) {
|
|
4481
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4482
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4483
|
+
};
|
|
4484
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4485
|
+
}
|
|
4412
4486
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4413
4487
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4414
4488
|
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -4447,7 +4521,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4447
4521
|
}
|
|
4448
4522
|
connectedCallback(this);
|
|
4449
4523
|
if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4450
|
-
await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4524
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
4451
4525
|
if (!this.isConnected) return;
|
|
4452
4526
|
}
|
|
4453
4527
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
@@ -4759,31 +4833,12 @@ function Mixin(...mixins) {
|
|
|
4759
4833
|
//#region src/runtime/nonce.ts
|
|
4760
4834
|
/**
|
|
4761
4835
|
* Assigns the given value to the nonce property on the runtime platform object.
|
|
4762
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created
|
|
4836
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
|
|
4763
4837
|
* @param nonce The value to be assigned to the platform nonce property.
|
|
4764
4838
|
* @returns void
|
|
4765
4839
|
*/
|
|
4766
4840
|
const setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
4767
4841
|
//#endregion
|
|
4768
|
-
//#region src/runtime/tag-transform.ts
|
|
4769
|
-
let tagTransformer = void 0;
|
|
4770
|
-
/**
|
|
4771
|
-
* Transforms a tag name using the current tag transformer
|
|
4772
|
-
* @param tag - the tag to transform e.g. `my-tag`
|
|
4773
|
-
* @returns the transformed tag e.g. `new-my-tag`
|
|
4774
|
-
*/
|
|
4775
|
-
function transformTag(tag) {
|
|
4776
|
-
if (!tagTransformer) return tag;
|
|
4777
|
-
return tagTransformer(tag);
|
|
4778
|
-
}
|
|
4779
|
-
/**
|
|
4780
|
-
* Sets the tag transformer to be used when rendering custom elements
|
|
4781
|
-
* @param transformer the transformer function to use. Must return a string
|
|
4782
|
-
*/
|
|
4783
|
-
function setTagTransformer(transformer) {
|
|
4784
|
-
tagTransformer = transformer;
|
|
4785
|
-
}
|
|
4786
|
-
//#endregion
|
|
4787
4842
|
//#region src/runtime/vdom/jsx-runtime.ts
|
|
4788
4843
|
function jsx(type, props, key) {
|
|
4789
4844
|
const { children, ...rest } = props ?? {};
|
|
@@ -4998,7 +5053,7 @@ function proxyHostElement(elm, cstr) {
|
|
|
4998
5053
|
const [[methodName]] = Object.entries(deserializer);
|
|
4999
5054
|
attrPropVal = cstr.prototype[methodName](attrValue, memberName);
|
|
5000
5055
|
}
|
|
5001
|
-
else attrPropVal = parsePropertyValue(attrValue, memberFlags
|
|
5056
|
+
else attrPropVal = parsePropertyValue(attrValue, memberFlags);
|
|
5002
5057
|
}
|
|
5003
5058
|
if (propValue !== void 0) {
|
|
5004
5059
|
attrPropVal = propValue;
|
|
@@ -5065,8 +5120,9 @@ function forceUpdate$1() {}
|
|
|
5065
5120
|
* @param results The results object to store the hydration results.
|
|
5066
5121
|
* @param afterSsr The callback to be called after SSR is complete.
|
|
5067
5122
|
* @param resolve The resolve function to be called when SSR is complete.
|
|
5123
|
+
* @param abortController The AbortController to use for aborting in-flight fetch() calls and other cancellable work when SSR times out.
|
|
5068
5124
|
*/
|
|
5069
|
-
function ssrApp(win, opts, results, afterSsr, resolve) {
|
|
5125
|
+
function ssrApp(win, opts, results, afterSsr, resolve, abortController) {
|
|
5070
5126
|
const connectedElements = /* @__PURE__ */ new Set();
|
|
5071
5127
|
const createdElements = /* @__PURE__ */ new Set();
|
|
5072
5128
|
const waitingElements = /* @__PURE__ */ new Set();
|
|
@@ -5076,10 +5132,20 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
|
|
|
5076
5132
|
setScopedSsr(opts);
|
|
5077
5133
|
let tmrId;
|
|
5078
5134
|
let ranCompleted = false;
|
|
5135
|
+
let modeResolverSnapshot;
|
|
5136
|
+
const abortedPromise = new Promise((res) => {
|
|
5137
|
+
if (abortController.signal.aborted) res();
|
|
5138
|
+
else abortController.signal.addEventListener("abort", () => res(), { once: true });
|
|
5139
|
+
});
|
|
5079
5140
|
function hydratedComplete() {
|
|
5080
5141
|
$nativeClearTimeout(tmrId);
|
|
5081
5142
|
createdElements.clear();
|
|
5082
5143
|
connectedElements.clear();
|
|
5144
|
+
if (modeResolverSnapshot) {
|
|
5145
|
+
modeResolver.length = 0;
|
|
5146
|
+
modeResolver.push(...modeResolverSnapshot);
|
|
5147
|
+
modeResolverSnapshot = void 0;
|
|
5148
|
+
}
|
|
5083
5149
|
if (!ranCompleted) {
|
|
5084
5150
|
ranCompleted = true;
|
|
5085
5151
|
try {
|
|
@@ -5095,6 +5161,7 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
|
|
|
5095
5161
|
}
|
|
5096
5162
|
function hydratedError(err) {
|
|
5097
5163
|
renderCatchError(opts, results, err);
|
|
5164
|
+
abortController.abort();
|
|
5098
5165
|
hydratedComplete();
|
|
5099
5166
|
}
|
|
5100
5167
|
function timeoutExceeded() {
|
|
@@ -5139,7 +5206,7 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
|
|
|
5139
5206
|
if (isValidComponent(elm, opts) && results.hydratedCount < opts.maxHydrateCount) {
|
|
5140
5207
|
if (!connectedElements.has(elm) && shouldHydrate(elm)) {
|
|
5141
5208
|
connectedElements.add(elm);
|
|
5142
|
-
return hydrateComponent.call(elm, win, results, elm.nodeName, elm, waitingElements);
|
|
5209
|
+
return hydrateComponent.call(elm, win, results, elm.nodeName, elm, waitingElements, abortedPromise);
|
|
5143
5210
|
}
|
|
5144
5211
|
}
|
|
5145
5212
|
return resolved;
|
|
@@ -5162,13 +5229,17 @@ function ssrApp(win, opts, results, afterSsr, resolve) {
|
|
|
5162
5229
|
tmrId = $nativeSetTimeout(timeoutExceeded, opts.timeout);
|
|
5163
5230
|
plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", win.document.baseURI).href;
|
|
5164
5231
|
globalScripts();
|
|
5232
|
+
if (Array.isArray(opts.modes)) {
|
|
5233
|
+
modeResolverSnapshot = modeResolver.slice();
|
|
5234
|
+
opts.modes.forEach((mode) => setMode(mode));
|
|
5235
|
+
}
|
|
5165
5236
|
patchChild(win.document.body);
|
|
5166
5237
|
waitLoop().then(hydratedComplete).catch(hydratedError);
|
|
5167
5238
|
} catch (e) {
|
|
5168
5239
|
hydratedError(e);
|
|
5169
5240
|
}
|
|
5170
5241
|
}
|
|
5171
|
-
async function hydrateComponent(win, results, tagName, elm, waitingElements) {
|
|
5242
|
+
async function hydrateComponent(win, results, tagName, elm, waitingElements, aborted) {
|
|
5172
5243
|
tagName = tagName.toLowerCase();
|
|
5173
5244
|
const Cstr = loadModule({
|
|
5174
5245
|
$tagName$: tagName,
|
|
@@ -5183,16 +5254,17 @@ async function hydrateComponent(win, results, tagName, elm, waitingElements) {
|
|
|
5183
5254
|
addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
|
|
5184
5255
|
try {
|
|
5185
5256
|
connectedCallback(elm);
|
|
5186
|
-
await elm.componentOnReady()
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5257
|
+
if (!await Promise.race([elm.componentOnReady().then(() => false), aborted.then(() => true)])) {
|
|
5258
|
+
results.hydratedCount++;
|
|
5259
|
+
const ref = getHostRef(elm);
|
|
5260
|
+
const modeName = !ref?.$modeName$ ? "$" : ref?.$modeName$;
|
|
5261
|
+
if (!results.components.some((c) => c.tag === tagName && c.mode === modeName)) results.components.push({
|
|
5262
|
+
tag: tagName,
|
|
5263
|
+
mode: modeName,
|
|
5264
|
+
count: 0,
|
|
5265
|
+
depth: -1
|
|
5266
|
+
});
|
|
5267
|
+
}
|
|
5196
5268
|
} catch (e) {
|
|
5197
5269
|
win.console.error(e);
|
|
5198
5270
|
}
|
|
@@ -5338,7 +5410,7 @@ const isMemberInElement = (elm, memberName) => {
|
|
|
5338
5410
|
const registerComponents = (Cstrs) => {
|
|
5339
5411
|
for (const Cstr of Cstrs) {
|
|
5340
5412
|
const exportName = Cstr.cmpMeta.$tagName$;
|
|
5341
|
-
const transformedTagName =
|
|
5413
|
+
const transformedTagName = transformTag(exportName);
|
|
5342
5414
|
cmpModules.set(exportName, { [exportName]: Cstr });
|
|
5343
5415
|
if (transformedTagName !== exportName) cmpModules.set(transformedTagName, { [transformedTagName]: Cstr });
|
|
5344
5416
|
}
|
|
@@ -5414,14 +5486,9 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
5414
5486
|
elm.__s_ghr = () => hostRef;
|
|
5415
5487
|
return hostRef;
|
|
5416
5488
|
};
|
|
5417
|
-
const Build = {
|
|
5418
|
-
isDev: false,
|
|
5419
|
-
isBrowser: false,
|
|
5420
|
-
isServer: true,
|
|
5421
|
-
isTesting: false
|
|
5422
|
-
};
|
|
5489
|
+
const Build = { ...SERVER_BUILD_FLAGS };
|
|
5423
5490
|
const styles = /* @__PURE__ */ new Map();
|
|
5424
|
-
const
|
|
5491
|
+
const modeResolver = [];
|
|
5425
5492
|
/**
|
|
5426
5493
|
* Server-side implementation of getAssetPath.
|
|
5427
5494
|
*
|
|
@@ -5453,4 +5520,4 @@ const setScopedSsr = (opts) => {
|
|
|
5453
5520
|
const needsScopedSSR = () => scopedSSR;
|
|
5454
5521
|
let scopedSSR = false;
|
|
5455
5522
|
//#endregion
|
|
5456
|
-
export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule,
|
|
5523
|
+
export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, registerSideEffectStyleTarget, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
|