@stencil/core 5.0.0-beta.9 → 5.0.0-rc.0
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/app-data/index.js +1 -0
- package/dist/{client-BRu0GtRn.mjs → client-ClM4H9-P.mjs} +204 -76
- package/dist/compiler/browser.d.ts +120 -81
- package/dist/compiler/browser.js +964 -402
- package/dist/compiler/index.d.mts +110 -2
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +2 -2
- package/dist/compiler/utils/index.mjs +3 -3
- package/dist/{compiler-wLrjuSOK.mjs → compiler-DFanjq9z.mjs} +5300 -3005
- package/dist/declarations/stencil-public-compiler.d.ts +178 -133
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +81 -59
- package/dist/{index-BvF31nqP.d.mts → index-DvfFOkiJ.d.mts} +220 -133
- package/dist/{index-BXAcVN2j.d.ts → index-XQHZl0MW.d.ts} +70 -57
- package/dist/{index-BAP9T4CB.d.mts → index-aBMJC5F9.d.mts} +6 -2
- 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-DJP8JuAS.mjs} +42 -48
- package/dist/runtime/client/lazy.js +522 -262
- package/dist/runtime/client/runtime.d.ts +100 -68
- package/dist/runtime/client/runtime.js +522 -262
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +521 -261
- package/dist/runtime/server/index.d.mts +36 -12
- package/dist/runtime/server/index.mjs +635 -304
- package/dist/runtime/server/runner.d.mts +49 -6
- package/dist/runtime/server/runner.mjs +385 -87
- package/dist/signals/index.d.ts +11 -2
- package/dist/signals/index.js +15 -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 +152 -124
- package/dist/testing/index.mjs +535 -269
- package/dist/{util-IKfWWLJo.mjs → util-C-H1H84W.mjs} +8 -1
- package/dist/{validation-DAdGTrys.mjs → validation-ByYYKvnS.mjs} +37 -3
- package/package.json +8 -4
package/dist/testing/index.mjs
CHANGED
|
@@ -3,14 +3,15 @@ import { MockWindow, setupGlobal } from "@stencil/mock-doc";
|
|
|
3
3
|
import "typescript";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import "picomatch";
|
|
6
|
-
import
|
|
6
|
+
import * as SignalsCore from "@preact/signals-core";
|
|
7
7
|
import path, { basename, dirname } from "path";
|
|
8
|
+
import resolve from "resolve";
|
|
8
9
|
import "postcss";
|
|
9
|
-
import "postcss-
|
|
10
|
+
import "postcss-nesting";
|
|
10
11
|
import "postcss-selector-parser";
|
|
12
|
+
import "postcss-safe-parser";
|
|
11
13
|
import "magic-string";
|
|
12
14
|
import "rolldown";
|
|
13
|
-
import resolve from "resolve";
|
|
14
15
|
import "rolldown/utils";
|
|
15
16
|
import "terser";
|
|
16
17
|
import "css-what";
|
|
@@ -32,7 +33,7 @@ import "@rollup/pluginutils";
|
|
|
32
33
|
import { createHash } from "crypto";
|
|
33
34
|
import { afterAll, vi } from "vitest";
|
|
34
35
|
//#region src/version.ts
|
|
35
|
-
const version = "5.0.0-
|
|
36
|
+
const version = "5.0.0-rc.0";
|
|
36
37
|
const MEMBER_FLAGS = {
|
|
37
38
|
String: 1,
|
|
38
39
|
Number: 2,
|
|
@@ -259,7 +260,8 @@ const formatComponentRuntimeMeta = (compilerMeta, includeMethods) => {
|
|
|
259
260
|
hostListeners.length > 0 ? hostListeners : void 0,
|
|
260
261
|
Object.keys(watchers).length > 0 ? watchers : void 0,
|
|
261
262
|
Object.keys(serializers).length > 0 ? serializers : void 0,
|
|
262
|
-
Object.keys(deserializers).length > 0 ? deserializers : void 0
|
|
263
|
+
Object.keys(deserializers).length > 0 ? deserializers : void 0,
|
|
264
|
+
compilerMeta.encapsulation === "shadow" ? compilerMeta.shadowReferenceTarget : void 0
|
|
263
265
|
]);
|
|
264
266
|
};
|
|
265
267
|
/**
|
|
@@ -379,6 +381,10 @@ const trimFalsy = (data) => {
|
|
|
379
381
|
*/
|
|
380
382
|
const isDef = (v) => v != null && v !== void 0;
|
|
381
383
|
/**
|
|
384
|
+
* This is just a no-op, don't expect it to do anything.
|
|
385
|
+
*/
|
|
386
|
+
const noop = () => {};
|
|
387
|
+
/**
|
|
382
388
|
* Check whether a value is a 'complex type', defined here as an object or a
|
|
383
389
|
* function.
|
|
384
390
|
*
|
|
@@ -632,6 +638,7 @@ const BUILD = {
|
|
|
632
638
|
shadowSlotAssignmentManual: false,
|
|
633
639
|
shadowClonable: true,
|
|
634
640
|
shadowSerializable: true,
|
|
641
|
+
shadowReferenceTarget: true,
|
|
635
642
|
initializeNextTick: false,
|
|
636
643
|
asyncLoading: true,
|
|
637
644
|
asyncQueue: false
|
|
@@ -640,7 +647,7 @@ const Env = {};
|
|
|
640
647
|
//#endregion
|
|
641
648
|
//#region src/testing/platform/testing-constants.ts
|
|
642
649
|
const styles = /* @__PURE__ */ new Map();
|
|
643
|
-
const
|
|
650
|
+
const modeResolver = [];
|
|
644
651
|
/**
|
|
645
652
|
* A mapping of custom element tags (e.g. `my-component`) to their constructor
|
|
646
653
|
*/
|
|
@@ -1179,6 +1186,13 @@ const NODE_TYPE = {
|
|
|
1179
1186
|
const HYDRATE_ID = "s-id";
|
|
1180
1187
|
const HYDRATED_STYLE_ID = "sty-id";
|
|
1181
1188
|
const HYDRATE_CHILD_ID = "c-id";
|
|
1189
|
+
/**
|
|
1190
|
+
* Starts an attribute value written by the `ssr` output's `ssrProp()` on a server: a reference to
|
|
1191
|
+
* a value it put in the registry below, for the SSR runtime to take out and set as the prop.
|
|
1192
|
+
*/
|
|
1193
|
+
const SSR_PROP_REF_PREFIX = "__stencil_ssr_ref:";
|
|
1194
|
+
/** `Symbol.for()` key of the `ssrProp()` registry on the server's real global object. */
|
|
1195
|
+
const SSR_PROPS_REGISTRY_KEY = "stencil.ssrProps";
|
|
1182
1196
|
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
1183
1197
|
const STENCIL_DOC_DATA = "_stencilDocData";
|
|
1184
1198
|
const DEFAULT_DOC_DATA = {
|
|
@@ -1269,6 +1283,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
|
1269
1283
|
if (typeof slotName !== "undefined") return slottedNodes;
|
|
1270
1284
|
}
|
|
1271
1285
|
slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
|
|
1286
|
+
if (typeof slotName !== "undefined" && slottedNodes.length) return slottedNodes;
|
|
1272
1287
|
}
|
|
1273
1288
|
return slottedNodes;
|
|
1274
1289
|
}
|
|
@@ -1403,6 +1418,7 @@ const applyLightDomPatches = (hostElementPrototype) => {
|
|
|
1403
1418
|
patchSlotInsertAdjacentHTML(hostElementPrototype);
|
|
1404
1419
|
patchInsertBefore(hostElementPrototype);
|
|
1405
1420
|
patchTextContent(hostElementPrototype);
|
|
1421
|
+
patchInnerContentSetters(hostElementPrototype);
|
|
1406
1422
|
patchChildSlotNodes(hostElementPrototype);
|
|
1407
1423
|
patchSlotRemoveChild(hostElementPrototype);
|
|
1408
1424
|
};
|
|
@@ -1467,11 +1483,13 @@ const patchSlotAppendChild = (HostElementPrototype) => {
|
|
|
1467
1483
|
const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
|
|
1468
1484
|
if (slotNode) {
|
|
1469
1485
|
addSlotRelocateNode(newChild, slotNode);
|
|
1486
|
+
patchSlottedNode(newChild);
|
|
1470
1487
|
const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
|
|
1471
1488
|
const appendAfter = slotChildNodes[slotChildNodes.length - 1];
|
|
1489
|
+
const slotWasEmpty = slotChildNodes.every((node) => node["s-sr"]);
|
|
1472
1490
|
const insertedNode = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, appendAfter.nextSibling);
|
|
1473
1491
|
dispatchSlotChangeEvent(slotNode);
|
|
1474
|
-
updateFallbackSlotVisibility(this);
|
|
1492
|
+
if (slotWasEmpty) updateFallbackSlotVisibility(this);
|
|
1475
1493
|
return insertedNode;
|
|
1476
1494
|
}
|
|
1477
1495
|
return this.__appendChild(newChild);
|
|
@@ -1489,8 +1507,10 @@ const patchSlotRemoveChild = (ElementPrototype) => {
|
|
|
1489
1507
|
ElementPrototype.__removeChild = ElementPrototype.removeChild;
|
|
1490
1508
|
ElementPrototype.removeChild = function(toRemove) {
|
|
1491
1509
|
if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
|
|
1492
|
-
|
|
1493
|
-
|
|
1510
|
+
const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, toRemove["s-sn"])[0];
|
|
1511
|
+
if (slotNode && toRemove.isConnected) {
|
|
1512
|
+
removeSlottedNode(toRemove);
|
|
1513
|
+
dispatchSlotChangeEvent(slotNode);
|
|
1494
1514
|
updateFallbackSlotVisibility(this);
|
|
1495
1515
|
return;
|
|
1496
1516
|
}
|
|
@@ -1513,6 +1533,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1513
1533
|
const slotNode = getHostSlotNodes(internalCall(this, "childNodes"), this.tagName, slotName)[0];
|
|
1514
1534
|
if (slotNode) {
|
|
1515
1535
|
addSlotRelocateNode(newChild, slotNode, true);
|
|
1536
|
+
patchSlottedNode(newChild);
|
|
1516
1537
|
const appendAfter = getSlotChildSiblings(slotNode, slotName)[0];
|
|
1517
1538
|
const toReturn = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, internalCall(appendAfter, "nextSibling"));
|
|
1518
1539
|
dispatchSlotChangeEvent(slotNode);
|
|
@@ -1576,25 +1597,21 @@ const patchInsertBefore = (HostElementPrototype) => {
|
|
|
1576
1597
|
eleProto.__insertBefore = HostElementPrototype.insertBefore;
|
|
1577
1598
|
HostElementPrototype.insertBefore = function(newChild, currentChild) {
|
|
1578
1599
|
const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
|
|
1579
|
-
const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
|
|
1580
1600
|
if (slotNode) {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
dispatchSlotChangeEvent(slotNode);
|
|
1593
|
-
}
|
|
1594
|
-
return;
|
|
1601
|
+
if (currentChild === null) {
|
|
1602
|
+
this.appendChild(newChild);
|
|
1603
|
+
return newChild;
|
|
1604
|
+
}
|
|
1605
|
+
if ((this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).includes(currentChild)) {
|
|
1606
|
+
if (slotName !== currentChild["s-sn"]) this.appendChild(newChild);
|
|
1607
|
+
else {
|
|
1608
|
+
addSlotRelocateNode(newChild, slotNode);
|
|
1609
|
+
patchSlottedNode(newChild);
|
|
1610
|
+
internalCall(internalCall(currentChild, "parentNode"), "insertBefore")(newChild, currentChild);
|
|
1611
|
+
dispatchSlotChangeEvent(slotNode);
|
|
1595
1612
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1613
|
+
return newChild;
|
|
1614
|
+
}
|
|
1598
1615
|
}
|
|
1599
1616
|
/**
|
|
1600
1617
|
* Fixes an issue where slotted elements are dynamically relocated in React, such as after data fetch.
|
|
@@ -1621,18 +1638,55 @@ const patchTextContent = (hostElementPrototype) => {
|
|
|
1621
1638
|
Object.defineProperty(hostElementPrototype, "textContent", {
|
|
1622
1639
|
get: function() {
|
|
1623
1640
|
let text = "";
|
|
1624
|
-
(this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) =>
|
|
1641
|
+
(this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) => {
|
|
1642
|
+
if (node.nodeType !== NODE_TYPE.CommentNode) text += node.textContent || "";
|
|
1643
|
+
});
|
|
1625
1644
|
return text;
|
|
1626
1645
|
},
|
|
1627
1646
|
set: function(value) {
|
|
1628
|
-
(this
|
|
1629
|
-
|
|
1630
|
-
node.remove();
|
|
1631
|
-
});
|
|
1632
|
-
this.insertAdjacentHTML("beforeend", value);
|
|
1647
|
+
removeSlottedNodes(this);
|
|
1648
|
+
if (value != null && value !== "") this.append(this.ownerDocument.createTextNode(String(value)));
|
|
1633
1649
|
}
|
|
1634
1650
|
});
|
|
1635
1651
|
};
|
|
1652
|
+
/**
|
|
1653
|
+
* Patches the `innerHTML` and `innerText` setters of a scoped component so they replace only
|
|
1654
|
+
* the slotted content. Natively they would also remove the component's rendered nodes and its
|
|
1655
|
+
* content reference node, leaving nothing for the next render to relocate into the slot.
|
|
1656
|
+
* The getters are left as they are.
|
|
1657
|
+
*
|
|
1658
|
+
* @param hostElementPrototype the `Element` to be patched
|
|
1659
|
+
*/
|
|
1660
|
+
const patchInnerContentSetters = (hostElementPrototype) => {
|
|
1661
|
+
if (!globalThis.HTMLElement) return;
|
|
1662
|
+
const patchSetter = (proto, name, insert) => {
|
|
1663
|
+
const get = Object.getOwnPropertyDescriptor(proto, name)?.get;
|
|
1664
|
+
if (!get) return;
|
|
1665
|
+
Object.defineProperty(hostElementPrototype, name, {
|
|
1666
|
+
get,
|
|
1667
|
+
set: function(value) {
|
|
1668
|
+
removeSlottedNodes(this);
|
|
1669
|
+
Array.from(internalCall(this, "childNodes")).forEach((node) => {
|
|
1670
|
+
if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== this.tagName) node.remove();
|
|
1671
|
+
});
|
|
1672
|
+
insert(this, value ?? "");
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
};
|
|
1676
|
+
patchSetter(Element.prototype, "innerHTML", (host, value) => host.insertAdjacentHTML("beforeend", value));
|
|
1677
|
+
patchSetter(HTMLElement.prototype, "innerText", (host, value) => host.append(value));
|
|
1678
|
+
};
|
|
1679
|
+
/**
|
|
1680
|
+
* Removes the slotted nodes of a scoped component, along with their original location markers.
|
|
1681
|
+
*
|
|
1682
|
+
* @param host the host element of the component
|
|
1683
|
+
*/
|
|
1684
|
+
const removeSlottedNodes = (host) => {
|
|
1685
|
+
(host.__childNodes ? host.childNodes : getSlottedChildNodes(host.childNodes)).forEach((node) => {
|
|
1686
|
+
if (node["s-ol"]) node["s-ol"].remove();
|
|
1687
|
+
node.remove();
|
|
1688
|
+
});
|
|
1689
|
+
};
|
|
1636
1690
|
const patchChildSlotNodes = (elm) => {
|
|
1637
1691
|
class FakeNodeList extends Array {
|
|
1638
1692
|
item(n) {
|
|
@@ -1666,10 +1720,21 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1666
1720
|
} });
|
|
1667
1721
|
};
|
|
1668
1722
|
/**
|
|
1669
|
-
* Patches
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1723
|
+
* Patches a node slotted into a non-shadow component so it behaves as it would in a native slot:
|
|
1724
|
+
* - `parentNode` returns the host element
|
|
1725
|
+
* - `remove()` fires `slotchange` on the node's slot
|
|
1726
|
+
*
|
|
1727
|
+
* @param node the slotted node to be patched
|
|
1728
|
+
*/
|
|
1729
|
+
const patchSlottedNode = (node) => {
|
|
1730
|
+
patchParentNode(node);
|
|
1731
|
+
patchSlottedRemove(node);
|
|
1732
|
+
};
|
|
1733
|
+
/**
|
|
1734
|
+
* Patches a slotted node from SSR markup: everything {@link patchSlottedNode} does, plus its
|
|
1735
|
+
* sibling accessors, so whilst stepping through a non-shadow element's nodes only the mock
|
|
1736
|
+
* 'lightDOM' nodes are returned. Frameworks hydrating SSR output often reconcile their VDOM with
|
|
1737
|
+
* the real DOM by stepping through nodes with 'nextSibling' et al.
|
|
1673
1738
|
* - `nextSibling`
|
|
1674
1739
|
* - `nextElementSibling`
|
|
1675
1740
|
* - `previousSibling`
|
|
@@ -1677,11 +1742,11 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1677
1742
|
*
|
|
1678
1743
|
* @param node the slotted node to be patched
|
|
1679
1744
|
*/
|
|
1680
|
-
const
|
|
1745
|
+
const patchSsrSlottedNode = (node) => {
|
|
1681
1746
|
if (!node || node.__nextSibling !== void 0 || !globalThis.Node) return;
|
|
1682
1747
|
patchNextSibling(node);
|
|
1683
1748
|
patchPreviousSibling(node);
|
|
1684
|
-
|
|
1749
|
+
patchSlottedNode(node);
|
|
1685
1750
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1686
1751
|
patchNextElementSibling(node);
|
|
1687
1752
|
patchPreviousElementSibling(node);
|
|
@@ -1748,6 +1813,39 @@ const patchPreviousElementSibling = (element) => {
|
|
|
1748
1813
|
} });
|
|
1749
1814
|
};
|
|
1750
1815
|
/**
|
|
1816
|
+
* Detaches a slotted node from where it physically sits in the component's rendered DOM, through
|
|
1817
|
+
* the unpatched accessors. Not via `remove()`: mock-doc's `remove()` calls
|
|
1818
|
+
* `parentNode.removeChild()`, and a slotted node's patched `parentNode` is the host, whose patched
|
|
1819
|
+
* `removeChild()` would come straight back here.
|
|
1820
|
+
*
|
|
1821
|
+
* @param node the slotted node to detach
|
|
1822
|
+
*/
|
|
1823
|
+
const removeSlottedNode = (node) => {
|
|
1824
|
+
const parent = internalCall(node, "parentNode");
|
|
1825
|
+
if (parent) internalCall(parent, "removeChild")(node);
|
|
1826
|
+
};
|
|
1827
|
+
/**
|
|
1828
|
+
* Patches `remove()` on a node slotted into a non-shadow component, so that removing it fires
|
|
1829
|
+
* `slotchange` on its slot (and updates fallback content), as removing a node from a native slot
|
|
1830
|
+
* does. Stencil's own node moves, while `isTmpDisconnected` is set, don't fire it.
|
|
1831
|
+
*
|
|
1832
|
+
* @param node the slotted node to patch
|
|
1833
|
+
*/
|
|
1834
|
+
const patchSlottedRemove = (node) => {
|
|
1835
|
+
const child = node;
|
|
1836
|
+
if (!child || child.__remove || typeof child.remove !== "function") return;
|
|
1837
|
+
child.__remove = child.remove;
|
|
1838
|
+
child.remove = function() {
|
|
1839
|
+
const host = this["s-ol"]?.parentElement;
|
|
1840
|
+
const { slotNode } = findSlotFromSlottedNode(this);
|
|
1841
|
+
removeSlottedNode(this);
|
|
1842
|
+
if (slotNode && !(plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected)) {
|
|
1843
|
+
dispatchSlotChangeEvent(slotNode);
|
|
1844
|
+
updateFallbackSlotVisibility(host);
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
};
|
|
1848
|
+
/**
|
|
1751
1849
|
* Patches the `parentNode` accessor of a non-shadow slotted node
|
|
1752
1850
|
*
|
|
1753
1851
|
* @param node the slotted node to be patched
|
|
@@ -1966,13 +2064,15 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1966
2064
|
const appliedStyles = getAppliedStyles(styleContainerNode);
|
|
1967
2065
|
let styleElm;
|
|
1968
2066
|
const existingStyleElm = (BUILD.hydrateClientSide || BUILD.hotModuleReplacement) && styleContainerNode.querySelector(`[sty-id="${scopeId}"]`);
|
|
1969
|
-
if (existingStyleElm)
|
|
1970
|
-
|
|
2067
|
+
if (existingStyleElm) {
|
|
2068
|
+
if (BUILD.hotModuleReplacement) existingStyleElm.textContent = style;
|
|
2069
|
+
appliedStyles.add(scopeId);
|
|
2070
|
+
} else if (!appliedStyles.has(scopeId)) {
|
|
1971
2071
|
styleElm = win.document.createElement("style");
|
|
1972
2072
|
styleElm.textContent = style;
|
|
1973
2073
|
const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
|
|
1974
2074
|
if (nonce != null) styleElm.setAttribute("nonce", nonce);
|
|
1975
|
-
if (BUILD.hydrateServerSide
|
|
2075
|
+
if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
|
|
1976
2076
|
if (BUILD.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
|
|
1977
2077
|
/**
|
|
1978
2078
|
* attach styles at the end of the head tag if we render scoped components
|
|
@@ -2094,23 +2194,43 @@ const getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & C
|
|
|
2094
2194
|
*/
|
|
2095
2195
|
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^/]+)\*\/[^{]+\{/g, "$1{");
|
|
2096
2196
|
/**
|
|
2097
|
-
* Hydrate styles after SSR for components
|
|
2098
|
-
* and add them to a constructable stylesheet.
|
|
2197
|
+
* Hydrate styles after SSR for shadow components that were serialized as 'scoped' (not DSD).
|
|
2198
|
+
* Convert their 'scoped' styles back to 'shadow' and add them to a constructable stylesheet.
|
|
2199
|
+
*
|
|
2200
|
+
* Sheets of scoped and non-encapsulated components are left alone so they stay in the
|
|
2201
|
+
* document head, where `addStyle()` reuses them.
|
|
2099
2202
|
*
|
|
2100
|
-
* @
|
|
2203
|
+
* @param cmpMetas the components whose server-rendered styles may need converting
|
|
2101
2204
|
*/
|
|
2102
|
-
const hydrateScopedToShadow = () => {
|
|
2205
|
+
const hydrateScopedToShadow = (cmpMetas) => {
|
|
2103
2206
|
if (!win.document) return;
|
|
2104
|
-
const
|
|
2207
|
+
const styleElms = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
2105
2208
|
let i = 0;
|
|
2106
|
-
for (; i <
|
|
2107
|
-
const scopeId =
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2209
|
+
for (; i < styleElms.length; i++) {
|
|
2210
|
+
const scopeId = styleElms[i].getAttribute(HYDRATED_STYLE_ID);
|
|
2211
|
+
if (cmpMetas.some((cmpMeta) => {
|
|
2212
|
+
const cmpScopeId = "sc-" + cmpMeta.$tagName$;
|
|
2213
|
+
return cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation && (scopeId === cmpScopeId || BUILD.mode && cmpMeta.$flags$ & CMP_FLAGS.hasMode && scopeId.startsWith(cmpScopeId + "-"));
|
|
2214
|
+
})) {
|
|
2215
|
+
const existing = styles.get(scopeId);
|
|
2216
|
+
const allowCS = existing !== void 0 ? existing instanceof CSSStyleSheet : true;
|
|
2217
|
+
registerStyle(scopeId, convertScopedToShadow(styleElms[i].innerHTML), allowCS);
|
|
2218
|
+
}
|
|
2111
2219
|
}
|
|
2112
2220
|
};
|
|
2113
|
-
|
|
2221
|
+
//#endregion
|
|
2222
|
+
//#region src/runtime/signals-core.ts
|
|
2223
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
2224
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
2225
|
+
function signal(value, options) {
|
|
2226
|
+
return getCore().signal(value, options);
|
|
2227
|
+
}
|
|
2228
|
+
const getRegistry = () => globalThis.customElements;
|
|
2229
|
+
/**
|
|
2230
|
+
* @param elm a defined component host
|
|
2231
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
2232
|
+
*/
|
|
2233
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
2114
2234
|
//#endregion
|
|
2115
2235
|
//#region src/runtime/vdom/set-accessor.ts
|
|
2116
2236
|
/**
|
|
@@ -2154,7 +2274,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
2154
2274
|
attrMap.get(memberName)?.();
|
|
2155
2275
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
2156
2276
|
let prevVal = oldValue;
|
|
2157
|
-
attrMap.set(memberName, effect
|
|
2277
|
+
attrMap.set(memberName, effect(() => {
|
|
2158
2278
|
const curVal = newValue.value;
|
|
2159
2279
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
2160
2280
|
prevVal = curVal;
|
|
@@ -2234,10 +2354,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
2234
2354
|
const isComplex = isComplexType(newValue);
|
|
2235
2355
|
if (!BUILD.lazyLoad) {
|
|
2236
2356
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
2237
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
2357
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
2238
2358
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
2239
2359
|
elm["s-pp"].set(memberName, newValue);
|
|
2240
|
-
return;
|
|
2360
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
2241
2361
|
}
|
|
2242
2362
|
}
|
|
2243
2363
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -2264,7 +2384,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
2264
2384
|
xlink = true;
|
|
2265
2385
|
}
|
|
2266
2386
|
}
|
|
2267
|
-
if (newValue == null || newValue === false) {
|
|
2387
|
+
if (newValue == null || newValue === false || isComplex) {
|
|
2268
2388
|
if (newValue !== false || elm.getAttribute(memberName) === "" || flags & VNODE_FLAGS.isHost && !isEnumeratedAttribute(memberName)) {
|
|
2269
2389
|
if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
|
|
2270
2390
|
else elm.removeAttribute(memberName);
|
|
@@ -2355,8 +2475,10 @@ function sortedAttrNames(attrNames) {
|
|
|
2355
2475
|
let scopeId;
|
|
2356
2476
|
let contentRef;
|
|
2357
2477
|
let hostTagName;
|
|
2478
|
+
let hostRegistry;
|
|
2358
2479
|
let useNativeShadowDom = false;
|
|
2359
2480
|
let checkSlotFallbackVisibility = false;
|
|
2481
|
+
/** Whether the current render has slotted content to relocate. Set at the start of each render. */
|
|
2360
2482
|
let checkSlotRelocate = false;
|
|
2361
2483
|
let isSvgMode = false;
|
|
2362
2484
|
/**
|
|
@@ -2364,6 +2486,7 @@ let isSvgMode = false;
|
|
|
2364
2486
|
* These ensure that ref callbacks are called in the correct order:
|
|
2365
2487
|
* first all removal callbacks (with null), then all attachment callbacks (with elements).
|
|
2366
2488
|
*/
|
|
2489
|
+
const initialSlotChanges = /* @__PURE__ */ new Set();
|
|
2367
2490
|
const refCallbacksToRemove = [];
|
|
2368
2491
|
const refCallbacksToAttach = [];
|
|
2369
2492
|
/** Disposers for signal subscriptions on individual DOM nodes (text nodes, <s-show> wrappers). */
|
|
@@ -2371,16 +2494,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
2371
2494
|
const disposeSignalVNode = (vnode) => {
|
|
2372
2495
|
const elm = vnode.$elm$;
|
|
2373
2496
|
if (elm) {
|
|
2374
|
-
|
|
2375
|
-
if (dispose) {
|
|
2376
|
-
dispose();
|
|
2377
|
-
signalNodeDisposers.delete(elm);
|
|
2378
|
-
}
|
|
2497
|
+
disposeTextSignal(elm);
|
|
2379
2498
|
disposeAllSignalAttrs(elm);
|
|
2380
2499
|
}
|
|
2381
2500
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
2382
2501
|
};
|
|
2383
2502
|
/**
|
|
2503
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
2504
|
+
* @param textNode the text node to unsubscribe
|
|
2505
|
+
*/
|
|
2506
|
+
const disposeTextSignal = (textNode) => {
|
|
2507
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
2508
|
+
if (dispose) {
|
|
2509
|
+
dispose();
|
|
2510
|
+
signalNodeDisposers.delete(textNode);
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
/**
|
|
2514
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
2515
|
+
* @param textNode the text node to keep in sync
|
|
2516
|
+
* @param textSig the signal to subscribe to
|
|
2517
|
+
*/
|
|
2518
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
2519
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
2520
|
+
textNode.data = String(textSig.value);
|
|
2521
|
+
}));
|
|
2522
|
+
};
|
|
2523
|
+
/**
|
|
2384
2524
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
2385
2525
|
*
|
|
2386
2526
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -2402,13 +2542,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2402
2542
|
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`);
|
|
2403
2543
|
if (BUILD.vdomText && newVNode.$text$ != null) {
|
|
2404
2544
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
2405
|
-
if (BUILD.vdomSignals && newVNode.$signal$)
|
|
2406
|
-
const textSig = newVNode.$signal$;
|
|
2407
|
-
const textNode = elm;
|
|
2408
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
2409
|
-
textNode.data = String(textSig.value);
|
|
2410
|
-
}));
|
|
2411
|
-
}
|
|
2545
|
+
if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
2412
2546
|
} else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
2413
2547
|
elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
2414
2548
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -2417,8 +2551,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2417
2551
|
if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
2418
2552
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
2419
2553
|
const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
2420
|
-
const
|
|
2421
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
2554
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
2422
2555
|
elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
2423
2556
|
if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
2424
2557
|
if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2676,7 +2809,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2676
2809
|
}
|
|
2677
2810
|
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
2678
2811
|
elmToMove = oldCh[idxInOld];
|
|
2679
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2812
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2680
2813
|
else {
|
|
2681
2814
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2682
2815
|
oldCh[idxInOld] = void 0;
|
|
@@ -2769,7 +2902,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2769
2902
|
else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2770
2903
|
if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2771
2904
|
} else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2772
|
-
else if (BUILD.vdomText
|
|
2905
|
+
else if (BUILD.vdomText) {
|
|
2906
|
+
if (BUILD.vdomSignals && newVNode.$signal$) {
|
|
2907
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2908
|
+
disposeTextSignal(elm);
|
|
2909
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2910
|
+
}
|
|
2911
|
+
} else {
|
|
2912
|
+
if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2913
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2773
2916
|
};
|
|
2774
2917
|
/**
|
|
2775
2918
|
* Component-global information about nodes which are either currently being
|
|
@@ -2895,13 +3038,17 @@ const flushQueuedRefCallbacks = () => {
|
|
|
2895
3038
|
*/
|
|
2896
3039
|
const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
2897
3040
|
if (BUILD.slotRelocation) {
|
|
3041
|
+
if (parent?.["s-cr"]) checkSlotRelocate = true;
|
|
2898
3042
|
if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
|
|
2899
3043
|
else if (typeof newNode["s-sn"] === "string") {
|
|
2900
3044
|
const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
|
|
2901
|
-
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE)
|
|
3045
|
+
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
|
|
2902
3046
|
parent.insertBefore(newNode, reference);
|
|
2903
3047
|
const { slotNode } = findSlotFromSlottedNode(newNode);
|
|
2904
|
-
if (slotNode
|
|
3048
|
+
if (slotNode) {
|
|
3049
|
+
if (isInitialLoad) initialSlotChanges.add(slotNode);
|
|
3050
|
+
else dispatchSlotChangeEvent(slotNode);
|
|
3051
|
+
}
|
|
2905
3052
|
return newNode;
|
|
2906
3053
|
}
|
|
2907
3054
|
}
|
|
@@ -2957,6 +3104,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2957
3104
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2958
3105
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2959
3106
|
hostTagName = hostElm.tagName;
|
|
3107
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2960
3108
|
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2961
3109
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2962
3110
|
|
|
@@ -2993,6 +3141,7 @@ render() {
|
|
|
2993
3141
|
if (BUILD.slotRelocation) {
|
|
2994
3142
|
contentRef = hostElm["s-cr"];
|
|
2995
3143
|
checkSlotFallbackVisibility = false;
|
|
3144
|
+
checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
|
|
2996
3145
|
}
|
|
2997
3146
|
patch(oldVNode, rootVnode, isInitialLoad);
|
|
2998
3147
|
if (BUILD.slotRelocation) {
|
|
@@ -3056,8 +3205,13 @@ render() {
|
|
|
3056
3205
|
if (checkSlotFallbackVisibility) updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
3057
3206
|
plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
|
|
3058
3207
|
relocateNodes.length = 0;
|
|
3208
|
+
if (initialSlotChanges.size) {
|
|
3209
|
+
const slotNodes = [...initialSlotChanges];
|
|
3210
|
+
initialSlotChanges.clear();
|
|
3211
|
+
nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
|
|
3212
|
+
}
|
|
3059
3213
|
}
|
|
3060
|
-
if (BUILD.slotRelocation && !
|
|
3214
|
+
if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
|
|
3061
3215
|
const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
|
|
3062
3216
|
for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
|
|
3063
3217
|
if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
|
|
@@ -3109,11 +3263,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
3109
3263
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
3110
3264
|
*
|
|
3111
3265
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
3266
|
+
* @param registry the registry the waiting component is defined in
|
|
3112
3267
|
*/
|
|
3113
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
3268
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
3114
3269
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
3115
3270
|
if (!BUILD.lazyLoad && !ancestorHostRef) {
|
|
3116
|
-
await
|
|
3271
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
3117
3272
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
3118
3273
|
}
|
|
3119
3274
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -3469,8 +3624,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3469
3624
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3470
3625
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
3471
3626
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
3472
|
-
const
|
|
3473
|
-
const sig = signal(initialVal);
|
|
3627
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
3474
3628
|
hostRef.$signalValues$.set(memberName, sig);
|
|
3475
3629
|
let prevScheduleVal = sig.peek();
|
|
3476
3630
|
disposers.push(effect(() => {
|
|
@@ -3598,9 +3752,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3598
3752
|
if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3599
3753
|
}
|
|
3600
3754
|
}
|
|
3601
|
-
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
3602
|
-
- You are NOT using hostData() and <Host> in the same component.
|
|
3603
|
-
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
3755
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3604
3756
|
if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3605
3757
|
const vnode = newVNode(nodeName, null);
|
|
3606
3758
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3653,17 +3805,23 @@ const vdomFnUtils = {
|
|
|
3653
3805
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3654
3806
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3655
3807
|
*
|
|
3656
|
-
*
|
|
3808
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3809
|
+
* become text-only child nodes.
|
|
3810
|
+
*
|
|
3811
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3657
3812
|
* @returns a converted child node
|
|
3658
3813
|
*/
|
|
3659
|
-
const convertToPublic = (node) =>
|
|
3814
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3815
|
+
vtag: null,
|
|
3816
|
+
vtext: String(node)
|
|
3817
|
+
} : {
|
|
3660
3818
|
vattrs: node.$attrs$,
|
|
3661
3819
|
vchildren: node.$children$,
|
|
3662
3820
|
vkey: node.$key$,
|
|
3663
3821
|
vname: node.$name$,
|
|
3664
3822
|
vtag: node.$tag$,
|
|
3665
3823
|
vtext: node.$text$
|
|
3666
|
-
}
|
|
3824
|
+
};
|
|
3667
3825
|
/**
|
|
3668
3826
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3669
3827
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3680,11 +3838,11 @@ const convertToPrivate = (node) => {
|
|
|
3680
3838
|
if (node.vname) vnodeData.name = node.vname;
|
|
3681
3839
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3682
3840
|
}
|
|
3683
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3684
|
-
vnode.$attrs$ = node.vattrs;
|
|
3685
|
-
vnode.$children$ = node.vchildren;
|
|
3686
|
-
vnode.$key$ = node.vkey;
|
|
3687
|
-
vnode.$name$ = node.vname;
|
|
3841
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3842
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3843
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3844
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3845
|
+
vnode.$name$ = node.vname ?? null;
|
|
3688
3846
|
return vnode;
|
|
3689
3847
|
};
|
|
3690
3848
|
/**
|
|
@@ -3734,7 +3892,10 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3734
3892
|
hostElm.classList.add(scopeId + "-h");
|
|
3735
3893
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
3736
3894
|
}
|
|
3737
|
-
if (win.document &&
|
|
3895
|
+
if (win.document && !plt.$orgLocNodes$?.has(hostId)) {
|
|
3896
|
+
initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ ??= /* @__PURE__ */ new Map());
|
|
3897
|
+
plt.$orgLocNodes$.set(hostId, hostElm);
|
|
3898
|
+
}
|
|
3738
3899
|
hostElm[HYDRATE_ID] = hostId;
|
|
3739
3900
|
hostElm.removeAttribute(HYDRATE_ID);
|
|
3740
3901
|
hostRef.$vnode$ = clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId, slottedNodes);
|
|
@@ -3747,7 +3908,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3747
3908
|
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
3748
3909
|
const node = childRenderNode.$elm$;
|
|
3749
3910
|
if (!shadowRoot) {
|
|
3750
|
-
node["s-hn"] = transformTag(tagName).toUpperCase();
|
|
3911
|
+
if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
|
|
3751
3912
|
if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
|
|
3752
3913
|
} else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
|
|
3753
3914
|
const cmpMeta = getHostRef(childRenderNode.$elm$);
|
|
@@ -3797,14 +3958,10 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3797
3958
|
const siSlot = slottedItem.slot;
|
|
3798
3959
|
if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
|
|
3799
3960
|
if (!hostEle.shadowRoot || !shadowRoot) {
|
|
3800
|
-
if (!siSlot["s-cr"])
|
|
3801
|
-
siSlot["s-cr"] = hostEle["s-cr"];
|
|
3802
|
-
if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
|
|
3803
|
-
else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
|
|
3804
|
-
}
|
|
3961
|
+
if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
|
|
3805
3962
|
addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
|
|
3806
3963
|
if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
|
|
3807
|
-
if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)
|
|
3964
|
+
if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
|
|
3808
3965
|
}
|
|
3809
3966
|
currentPos = (siNode["s-oo"] || currentPos) + 1;
|
|
3810
3967
|
}
|
|
@@ -3864,7 +4021,7 @@ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes
|
|
|
3864
4021
|
const scopeId = hostElm["s-sc"];
|
|
3865
4022
|
if (node.nodeType === NODE_TYPE.ElementNode) {
|
|
3866
4023
|
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
3867
|
-
if (childNodeType) {
|
|
4024
|
+
if (childNodeType && node !== hostElm) {
|
|
3868
4025
|
childIdSplt = childNodeType.split(".");
|
|
3869
4026
|
if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
|
|
3870
4027
|
childVNode = createSimpleVNode({
|
|
@@ -3982,6 +4139,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3982
4139
|
const createSimpleVNode = (vnode) => ({
|
|
3983
4140
|
$flags$: 0,
|
|
3984
4141
|
$index$: "0",
|
|
4142
|
+
$children$: null,
|
|
3985
4143
|
...vnode
|
|
3986
4144
|
});
|
|
3987
4145
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -4045,6 +4203,11 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
4045
4203
|
* @returns the first corresponding node of the type
|
|
4046
4204
|
*/
|
|
4047
4205
|
const findCorrespondingNode = (node, type) => {
|
|
4206
|
+
if (type === NODE_TYPE.TextNode) {
|
|
4207
|
+
const next = node.nextSibling;
|
|
4208
|
+
if (next?.nodeType === NODE_TYPE.TextNode) return next;
|
|
4209
|
+
return node.parentNode.insertBefore(node.ownerDocument.createTextNode(""), next);
|
|
4210
|
+
}
|
|
4048
4211
|
let sibling = node;
|
|
4049
4212
|
do
|
|
4050
4213
|
sibling = sibling.nextSibling;
|
|
@@ -4365,7 +4528,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
4365
4528
|
else return shallowPart.trim();
|
|
4366
4529
|
}).join(", ");
|
|
4367
4530
|
};
|
|
4368
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
4531
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
4369
4532
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
4370
4533
|
return processRules(cssText, (rule) => {
|
|
4371
4534
|
let selector = rule.selector;
|
|
@@ -4484,7 +4647,7 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4484
4647
|
};
|
|
4485
4648
|
//#endregion
|
|
4486
4649
|
//#region src/runtime/mode.ts
|
|
4487
|
-
const computeMode = (elm) =>
|
|
4650
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4488
4651
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4489
4652
|
//#endregion
|
|
4490
4653
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4549,23 +4712,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4549
4712
|
*
|
|
4550
4713
|
* @param propValue the new value to coerce to some type
|
|
4551
4714
|
* @param propType the type of the prop, expressed as a binary number
|
|
4552
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4553
4715
|
* @returns the parsed/coerced value
|
|
4554
4716
|
*/
|
|
4555
|
-
const parsePropertyValue = (propValue, propType
|
|
4717
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4556
4718
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4557
4719
|
/**
|
|
4558
4720
|
* ensure this value is of the correct prop type
|
|
4559
4721
|
*/
|
|
4560
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4561
|
-
/**
|
|
4562
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4563
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4564
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4565
|
-
*/
|
|
4566
|
-
if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4567
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4568
|
-
}
|
|
4722
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4569
4723
|
/**
|
|
4570
4724
|
* force it to be a number
|
|
4571
4725
|
*/
|
|
@@ -4607,7 +4761,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4607
4761
|
if (BUILD.signalBacking) {
|
|
4608
4762
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4609
4763
|
if (sig !== void 0) {
|
|
4610
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4764
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4611
4765
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4612
4766
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4613
4767
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4625,7 +4779,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4625
4779
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4626
4780
|
const flags = hostRef.$flags$;
|
|
4627
4781
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4628
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4782
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4629
4783
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4630
4784
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4631
4785
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4674,6 +4828,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4674
4828
|
*/
|
|
4675
4829
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4676
4830
|
/**
|
|
4831
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4832
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4833
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4834
|
+
*
|
|
4835
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4836
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4837
|
+
*/
|
|
4838
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4839
|
+
const instance = hostRef.$lazyInstance$;
|
|
4840
|
+
if (!instance) return;
|
|
4841
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4842
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4843
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4844
|
+
}
|
|
4845
|
+
};
|
|
4846
|
+
/**
|
|
4677
4847
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4678
4848
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4679
4849
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4730,9 +4900,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4730
4900
|
if (BUILD.lazyLoad) {
|
|
4731
4901
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4732
4902
|
const ref = getHostRef(this);
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
return instance[memberName];
|
|
4903
|
+
if (!ref) return prototype[memberName];
|
|
4904
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4736
4905
|
}
|
|
4737
4906
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4738
4907
|
},
|
|
@@ -4747,7 +4916,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4747
4916
|
}
|
|
4748
4917
|
if (origSetter) {
|
|
4749
4918
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4750
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4919
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4751
4920
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4752
4921
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4753
4922
|
return;
|
|
@@ -4759,21 +4928,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4759
4928
|
if (BUILD.lazyLoad) {
|
|
4760
4929
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4761
4930
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4762
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4763
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4764
|
-
});
|
|
4765
4931
|
return;
|
|
4766
4932
|
}
|
|
4767
|
-
const
|
|
4933
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4934
|
+
if (ref.$lazyInstance$) {
|
|
4768
4935
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4769
4936
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4770
|
-
ref.$lazyInstance$[memberName] =
|
|
4937
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4771
4938
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4772
|
-
};
|
|
4773
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4774
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4775
|
-
setterSetVal();
|
|
4776
|
-
});
|
|
4939
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4777
4940
|
}
|
|
4778
4941
|
} });
|
|
4779
4942
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4815,7 +4978,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4815
4978
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4816
4979
|
(cmpMeta.$watchers$?.[attrName])?.forEach((watcher) => {
|
|
4817
4980
|
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4818
|
-
if (instance[watchMethodName] != null && (hostFlags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName](newValue, oldValue, attrName);
|
|
4981
|
+
if (instance?.[watchMethodName] != null && (hostFlags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName](newValue, oldValue, attrName);
|
|
4819
4982
|
});
|
|
4820
4983
|
}
|
|
4821
4984
|
return;
|
|
@@ -4825,9 +4988,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4825
4988
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4826
4989
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4827
4990
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4828
|
-
if (isBooleanTarget)
|
|
4991
|
+
if (isBooleanTarget) {
|
|
4992
|
+
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.`);
|
|
4993
|
+
newValue = newValue !== null;
|
|
4994
|
+
}
|
|
4829
4995
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4830
|
-
|
|
4996
|
+
const isUnchanged = newValue === this[propName] || newValue == null && this[propName] == null;
|
|
4997
|
+
if (!isSpuriousBooleanRemoval && !isUnchanged && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4831
4998
|
});
|
|
4832
4999
|
};
|
|
4833
5000
|
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
@@ -4888,9 +5055,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4888
5055
|
} catch (e) {
|
|
4889
5056
|
consoleError(e, elm);
|
|
4890
5057
|
}
|
|
4891
|
-
if (BUILD.member)
|
|
5058
|
+
if (BUILD.member) {
|
|
5059
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
5060
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
5061
|
+
}
|
|
4892
5062
|
endNewInstance();
|
|
4893
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
5063
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4894
5064
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4895
5065
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4896
5066
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4990,9 +5160,16 @@ const connectedCallback = (elm) => {
|
|
|
4990
5160
|
}
|
|
4991
5161
|
if (BUILD.asyncLoading) {
|
|
4992
5162
|
let ancestorComponent = elm;
|
|
4993
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4994
|
-
|
|
4995
|
-
|
|
5163
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
5164
|
+
if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
5165
|
+
ancestorComponent["s-p"] = [];
|
|
5166
|
+
ancestorComponent["s-rc"] = [];
|
|
5167
|
+
ancestorComponent["s-pc"] = [];
|
|
5168
|
+
}
|
|
5169
|
+
if (ancestorComponent["s-p"]) {
|
|
5170
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
5171
|
+
break;
|
|
5172
|
+
}
|
|
4996
5173
|
}
|
|
4997
5174
|
}
|
|
4998
5175
|
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -5108,48 +5285,112 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
5108
5285
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
5109
5286
|
);
|
|
5110
5287
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
5111
|
-
if (
|
|
5112
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
5113
|
-
if (ctor) {
|
|
5114
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
5115
|
-
if (key === "constructor") continue;
|
|
5116
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
5117
|
-
}
|
|
5118
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
5119
|
-
if (styleDesc) {
|
|
5120
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
5121
|
-
const newStyle = NewClass.style;
|
|
5122
|
-
if (newStyle) {
|
|
5123
|
-
const scopeId = getScopeId(cmpMeta);
|
|
5124
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
5125
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
5126
|
-
tag: cmpMeta.$tagName$,
|
|
5127
|
-
scopeId,
|
|
5128
|
-
isShadow,
|
|
5129
|
-
cssLen: newStyle.length
|
|
5130
|
-
});
|
|
5131
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
5132
|
-
}
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
5136
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
5137
|
-
const hostRef = getHostRef(el);
|
|
5138
|
-
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
5139
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
5140
|
-
hostRef.$rmListeners$ = void 0;
|
|
5141
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
5142
|
-
}
|
|
5143
|
-
if (!isShadow && hostRef) {
|
|
5144
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
5145
|
-
attachStyles(hostRef);
|
|
5146
|
-
}
|
|
5147
|
-
forceUpdate(el);
|
|
5148
|
-
});
|
|
5288
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
5149
5289
|
} catch (e) {
|
|
5150
5290
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
5151
5291
|
}
|
|
5152
5292
|
};
|
|
5293
|
+
/**
|
|
5294
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
5295
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
5296
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
5297
|
+
*
|
|
5298
|
+
* @param cmpMeta runtime metadata for the component
|
|
5299
|
+
* @param NewClass the component's newly executed class
|
|
5300
|
+
*/
|
|
5301
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
5302
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
5303
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
5304
|
+
if (ctor && ctor !== NewClass) {
|
|
5305
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
5306
|
+
if (key === "constructor") continue;
|
|
5307
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
5308
|
+
}
|
|
5309
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
5310
|
+
if (styleDesc) {
|
|
5311
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
5312
|
+
const newStyle = NewClass.style;
|
|
5313
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
5317
|
+
const hostRef = getHostRef(el);
|
|
5318
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
5319
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
5320
|
+
hostRef.$rmListeners$ = void 0;
|
|
5321
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
5322
|
+
}
|
|
5323
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
5324
|
+
forceUpdate(el);
|
|
5325
|
+
});
|
|
5326
|
+
};
|
|
5327
|
+
//#endregion
|
|
5328
|
+
//#region src/runtime/parse-gate.ts
|
|
5329
|
+
/**
|
|
5330
|
+
* SSR hosts connected while the HTML parser is still inside them (streamed documents),
|
|
5331
|
+
* in connection order - which is document order. Each is held until its subtree is
|
|
5332
|
+
* parsed so hydration sees its declarative shadow root and children.
|
|
5333
|
+
*/
|
|
5334
|
+
const pending = /* @__PURE__ */ new Set();
|
|
5335
|
+
let observer;
|
|
5336
|
+
const parentOf = (node) => node.parentNode ?? (node.nodeType === NODE_TYPE.DocumentFragment ? node.host : null);
|
|
5337
|
+
/**
|
|
5338
|
+
* The parser has finished with `elm` once it, or any ancestor, has a following sibling.
|
|
5339
|
+
* @param elm the element to check
|
|
5340
|
+
* @returns whether the element's subtree is fully parsed
|
|
5341
|
+
*/
|
|
5342
|
+
const isParsed = (elm) => {
|
|
5343
|
+
if (win.document.readyState !== "loading") return true;
|
|
5344
|
+
for (let n = elm; n; n = parentOf(n)) if (n.nextSibling) return true;
|
|
5345
|
+
return false;
|
|
5346
|
+
};
|
|
5347
|
+
const hasPendingAncestor = (elm) => {
|
|
5348
|
+
for (let n = parentOf(elm); n; n = parentOf(n)) if (pending.has(n)) return true;
|
|
5349
|
+
return false;
|
|
5350
|
+
};
|
|
5351
|
+
const flush = () => {
|
|
5352
|
+
for (const elm of pending) if (!elm.isConnected) pending.delete(elm);
|
|
5353
|
+
else if (isParsed(elm)) elm.__attachShadow?.();
|
|
5354
|
+
for (const elm of pending) if (isParsed(elm) && !hasPendingAncestor(elm)) {
|
|
5355
|
+
pending.delete(elm);
|
|
5356
|
+
elm.connectedCallback?.();
|
|
5357
|
+
}
|
|
5358
|
+
if (!pending.size) {
|
|
5359
|
+
observer?.disconnect();
|
|
5360
|
+
observer = void 0;
|
|
5361
|
+
}
|
|
5362
|
+
};
|
|
5363
|
+
/**
|
|
5364
|
+
* Whether the parser may still be adding children (including a declarative shadow root)
|
|
5365
|
+
* to `elm`: it was just created by the parser, or it's an SSR host the parser is still inside.
|
|
5366
|
+
* @param elm the host element
|
|
5367
|
+
* @returns `true` if the element's subtree may be incomplete
|
|
5368
|
+
*/
|
|
5369
|
+
const mayStillBeParsing = (elm) => win.document?.readyState === "loading" && (!elm.parentNode || elm.hasAttribute("s-id") && !isParsed(elm));
|
|
5370
|
+
/**
|
|
5371
|
+
* Holds back `elm`'s `connectedCallback` while it's an SSR host the parser hasn't finished
|
|
5372
|
+
* with, or one nested inside such a host. Its shadow root is attached once its own subtree
|
|
5373
|
+
* is parsed; `connectedCallback` is re-called once no ancestor host is still held.
|
|
5374
|
+
* @param elm the host element being connected
|
|
5375
|
+
* @returns `true` if processing was deferred
|
|
5376
|
+
*/
|
|
5377
|
+
const deferUntilParsed = (elm) => {
|
|
5378
|
+
if (pending.has(elm)) return true;
|
|
5379
|
+
if (!win.document || !elm.hasAttribute("s-id")) return false;
|
|
5380
|
+
const parsed = isParsed(elm);
|
|
5381
|
+
if (parsed && !hasPendingAncestor(elm)) return false;
|
|
5382
|
+
if (parsed) elm.__attachShadow?.();
|
|
5383
|
+
pending.add(elm);
|
|
5384
|
+
if (!observer) {
|
|
5385
|
+
observer = new MutationObserver(flush);
|
|
5386
|
+
observer.observe(win.document, {
|
|
5387
|
+
childList: true,
|
|
5388
|
+
subtree: true
|
|
5389
|
+
});
|
|
5390
|
+
win.document.addEventListener("DOMContentLoaded", flush, { once: true });
|
|
5391
|
+
}
|
|
5392
|
+
return true;
|
|
5393
|
+
};
|
|
5153
5394
|
//#endregion
|
|
5154
5395
|
//#region src/runtime/bootstrap-loader.ts
|
|
5155
5396
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
@@ -5172,7 +5413,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
5172
5413
|
Object.assign(plt, options);
|
|
5173
5414
|
if (BUILD.asyncQueue && options.syncQueue) plt.$flags$ |= PLATFORM_FLAGS.queueSync;
|
|
5174
5415
|
if (BUILD.hydrateClientSide) plt.$flags$ |= PLATFORM_FLAGS.appLoaded;
|
|
5175
|
-
if (BUILD.hydrateClientSide && BUILD.shadowDom)
|
|
5416
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) {
|
|
5417
|
+
const cmpMetas = [];
|
|
5418
|
+
lazyBundles.map((lazyBundle) => lazyBundle[1].map(([$flags$, $tagName$]) => cmpMetas.push({
|
|
5419
|
+
$flags$,
|
|
5420
|
+
$tagName$
|
|
5421
|
+
})));
|
|
5422
|
+
hydrateScopedToShadow(cmpMetas);
|
|
5423
|
+
}
|
|
5176
5424
|
lazyBundles.map((lazyBundle) => {
|
|
5177
5425
|
lazyBundle[1].map((compactMeta) => {
|
|
5178
5426
|
const cmpMeta = {
|
|
@@ -5189,7 +5437,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
5189
5437
|
cmpMeta.$serializers$ = compactMeta[5] ?? {};
|
|
5190
5438
|
cmpMeta.$deserializers$ = compactMeta[6] ?? {};
|
|
5191
5439
|
}
|
|
5440
|
+
if (BUILD.shadowReferenceTarget) cmpMeta.$referenceTarget$ = compactMeta[7];
|
|
5192
5441
|
const tagName = transformTag(cmpMeta.$tagName$);
|
|
5442
|
+
const attachShadowRoot = (elm) => {
|
|
5443
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) && !getShadowRoot(elm)) createShadowRoot.call(elm, cmpMeta);
|
|
5444
|
+
};
|
|
5193
5445
|
const HostElement = class extends HTMLElement {
|
|
5194
5446
|
["s-p"];
|
|
5195
5447
|
["s-rc"];
|
|
@@ -5198,14 +5450,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
5198
5450
|
super(self);
|
|
5199
5451
|
self = this;
|
|
5200
5452
|
registerHost(self, cmpMeta);
|
|
5201
|
-
if (BUILD.shadowDom &&
|
|
5202
|
-
if (!self.shadowRoot) createShadowRoot.call(self, cmpMeta);
|
|
5203
|
-
else if (BUILD.isDev && self.shadowRoot.mode !== "open") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but DSD shadow roots must use open mode.`);
|
|
5204
|
-
}
|
|
5453
|
+
if (BUILD.shadowDom && !(BUILD.hydrateClientSide && mayStillBeParsing(self))) attachShadowRoot(self);
|
|
5205
5454
|
}
|
|
5206
5455
|
connectedCallback() {
|
|
5207
5456
|
const hostRef = getHostRef(this);
|
|
5208
5457
|
if (!hostRef) return;
|
|
5458
|
+
if (BUILD.hydrateClientSide && deferUntilParsed(this)) return;
|
|
5459
|
+
if (BUILD.shadowDom) attachShadowRoot(this);
|
|
5209
5460
|
/**
|
|
5210
5461
|
* The `connectedCallback` lifecycle event can potentially be fired multiple times
|
|
5211
5462
|
* if the element is removed from the DOM and re-inserted. This is not a common use case,
|
|
@@ -5261,10 +5512,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
5261
5512
|
patchSlotInsertAdjacentHTML(HostElement.prototype);
|
|
5262
5513
|
patchInsertBefore(HostElement.prototype);
|
|
5263
5514
|
patchSlotRemoveChild(HostElement.prototype);
|
|
5515
|
+
patchInnerContentSetters(HostElement.prototype);
|
|
5264
5516
|
}
|
|
5265
5517
|
if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
|
|
5266
5518
|
}
|
|
5267
5519
|
}
|
|
5520
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) HostElement.prototype.__attachShadow = function() {
|
|
5521
|
+
attachShadowRoot(this);
|
|
5522
|
+
};
|
|
5268
5523
|
if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
5269
5524
|
if (BUILD.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
5270
5525
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
@@ -5504,7 +5759,10 @@ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
|
|
|
5504
5759
|
if (vnode != null) {
|
|
5505
5760
|
const hostId = ++docData.hostIds;
|
|
5506
5761
|
hostElm.setAttribute(HYDRATE_ID, hostId);
|
|
5507
|
-
if (hostElm["s-cr"] != null)
|
|
5762
|
+
if (hostElm["s-cr"] != null) {
|
|
5763
|
+
if (hostElm.shadowRoot) hostElm["s-cr"].remove();
|
|
5764
|
+
else hostElm["s-cr"].nodeValue = `r.${hostId}`;
|
|
5765
|
+
}
|
|
5508
5766
|
if (vnode.$children$ != null) {
|
|
5509
5767
|
const depth = 0;
|
|
5510
5768
|
vnode.$children$.forEach((vnodeChild, index) => {
|
|
@@ -5567,8 +5825,8 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
|
|
|
5567
5825
|
//#endregion
|
|
5568
5826
|
//#region src/testing/platform/index.ts
|
|
5569
5827
|
const setMode = (handler) => {
|
|
5570
|
-
|
|
5571
|
-
|
|
5828
|
+
modeResolver.length = 0;
|
|
5829
|
+
modeResolver.push(handler);
|
|
5572
5830
|
};
|
|
5573
5831
|
const needsScopedSSR = () => scopedSSR;
|
|
5574
5832
|
let scopedSSR = false;
|
|
@@ -5586,6 +5844,7 @@ function createShadowRoot(cmpMeta) {
|
|
|
5586
5844
|
}
|
|
5587
5845
|
if (BUILD.shadowClonable) opts.clonable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowClonable);
|
|
5588
5846
|
if (BUILD.shadowSerializable) opts.serializable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowSerializable);
|
|
5847
|
+
if (BUILD.shadowReferenceTarget && cmpMeta.$referenceTarget$) opts.referenceTarget = cmpMeta.$referenceTarget$;
|
|
5589
5848
|
const shadowRoot = this.attachShadow(opts);
|
|
5590
5849
|
if (BUILD.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
|
|
5591
5850
|
if (globalStyleSheet === void 0) globalStyleSheet = null;
|
|
@@ -5647,79 +5906,6 @@ const buildEvents = () => {
|
|
|
5647
5906
|
};
|
|
5648
5907
|
};
|
|
5649
5908
|
//#endregion
|
|
5650
|
-
//#region src/compiler/app-core/app-data.ts
|
|
5651
|
-
/**
|
|
5652
|
-
* Generate a {@link BuildFeatures} entity, based on the provided component metadata
|
|
5653
|
-
* @param cmps a collection of component compiler metadata, used to set values on the generated build features object
|
|
5654
|
-
* @returns the generated build features entity
|
|
5655
|
-
*/
|
|
5656
|
-
const getBuildFeatures = (cmps) => {
|
|
5657
|
-
const slot = cmps.some((c) => c.htmlTagNames.includes("slot"));
|
|
5658
|
-
const shadowDom = cmps.some((c) => c.encapsulation === "shadow");
|
|
5659
|
-
const slotRelocation = cmps.some((c) => c.encapsulation !== "shadow" && c.htmlTagNames.includes("slot"));
|
|
5660
|
-
const f = {
|
|
5661
|
-
allRenderFn: cmps.every((c) => c.hasRenderFn),
|
|
5662
|
-
formAssociated: cmps.some((c) => c.formAssociated),
|
|
5663
|
-
deserializer: cmps.some((c) => c.hasDeserializer),
|
|
5664
|
-
element: cmps.some((c) => c.hasElement),
|
|
5665
|
-
event: cmps.some((c) => c.hasEvent),
|
|
5666
|
-
hasRenderFn: cmps.some((c) => c.hasRenderFn),
|
|
5667
|
-
lifecycle: cmps.some((c) => c.hasLifecycle),
|
|
5668
|
-
asyncLoading: true,
|
|
5669
|
-
hostListener: cmps.some((c) => c.hasListener),
|
|
5670
|
-
hostListenerTargetWindow: cmps.some((c) => c.hasListenerTargetWindow),
|
|
5671
|
-
hostListenerTargetDocument: cmps.some((c) => c.hasListenerTargetDocument),
|
|
5672
|
-
hostListenerTargetBody: cmps.some((c) => c.hasListenerTargetBody),
|
|
5673
|
-
hostListenerTarget: cmps.some((c) => c.hasListenerTarget),
|
|
5674
|
-
member: cmps.some((c) => c.hasMember),
|
|
5675
|
-
method: cmps.some((c) => c.hasMethod),
|
|
5676
|
-
mode: cmps.some((c) => c.hasMode),
|
|
5677
|
-
observeAttribute: cmps.some((c) => c.hasAttribute || c.hasWatchCallback || c.hasDeserializer),
|
|
5678
|
-
prop: cmps.some((c) => c.hasProp),
|
|
5679
|
-
propBoolean: cmps.some((c) => c.hasPropBoolean),
|
|
5680
|
-
propChangeCallback: cmps.some((c) => c.hasWatchCallback || c.hasDeserializer || c.hasSerializer),
|
|
5681
|
-
propNumber: cmps.some((c) => c.hasPropNumber),
|
|
5682
|
-
propString: cmps.some((c) => c.hasPropString),
|
|
5683
|
-
propMutable: cmps.some((c) => c.hasPropMutable),
|
|
5684
|
-
reflect: cmps.some((c) => c.hasReflect || c.hasSerializer),
|
|
5685
|
-
scoped: cmps.some((c) => c.encapsulation === "scoped"),
|
|
5686
|
-
serializer: cmps.some((c) => c.hasSerializer),
|
|
5687
|
-
shadowDom,
|
|
5688
|
-
shadowDelegatesFocus: shadowDom && cmps.some((c) => c.shadowDelegatesFocus),
|
|
5689
|
-
shadowModeClosed: shadowDom && cmps.some((c) => c.shadowMode === "closed"),
|
|
5690
|
-
shadowSlotAssignmentManual: shadowDom && cmps.some((c) => c.slotAssignment === "manual"),
|
|
5691
|
-
shadowClonable: shadowDom && cmps.some((c) => c.shadowClonable),
|
|
5692
|
-
shadowSerializable: shadowDom && cmps.some((c) => c.shadowSerializable),
|
|
5693
|
-
slot,
|
|
5694
|
-
slotRelocation,
|
|
5695
|
-
state: cmps.some((c) => c.hasState),
|
|
5696
|
-
style: cmps.some((c) => c.hasStyle),
|
|
5697
|
-
svg: cmps.some((c) => c.htmlTagNames.includes("svg")),
|
|
5698
|
-
updatable: cmps.some((c) => c.isUpdateable),
|
|
5699
|
-
vdomAttribute: cmps.some((c) => c.hasVdomAttribute),
|
|
5700
|
-
vdomXlink: cmps.some((c) => c.hasVdomXlink),
|
|
5701
|
-
vdomClass: cmps.some((c) => c.hasVdomClass),
|
|
5702
|
-
vdomFunctional: cmps.some((c) => c.hasVdomFunctional),
|
|
5703
|
-
vdomKey: cmps.some((c) => c.hasVdomKey),
|
|
5704
|
-
vdomListener: cmps.some((c) => c.hasVdomListener),
|
|
5705
|
-
vdomPropOrAttr: cmps.some((c) => c.hasVdomPropOrAttr),
|
|
5706
|
-
vdomPropOrAttrPrefix: cmps.some((c) => c.hasVdomPropOrAttrPrefix),
|
|
5707
|
-
vdomRef: cmps.some((c) => c.hasVdomRef),
|
|
5708
|
-
vdomRender: cmps.some((c) => c.hasVdomRender),
|
|
5709
|
-
vdomStyle: cmps.some((c) => c.hasVdomStyle),
|
|
5710
|
-
vdomText: cmps.some((c) => c.hasVdomText),
|
|
5711
|
-
vdomSignals: cmps.some((c) => c.hasSignalsImport),
|
|
5712
|
-
taskQueue: true,
|
|
5713
|
-
patchAll: cmps.some((c) => c.hasPatchAll),
|
|
5714
|
-
patchChildren: cmps.some((c) => c.hasPatchChildren),
|
|
5715
|
-
patchClone: cmps.some((c) => c.hasPatchClone),
|
|
5716
|
-
patchInsert: cmps.some((c) => c.hasPatchInsert)
|
|
5717
|
-
};
|
|
5718
|
-
f.vdomAttribute = f.vdomAttribute || f.reflect;
|
|
5719
|
-
f.vdomPropOrAttr = f.vdomPropOrAttr || f.reflect;
|
|
5720
|
-
return f;
|
|
5721
|
-
};
|
|
5722
|
-
//#endregion
|
|
5723
5909
|
//#region src/compiler/sys/resolve/resolve-utils.ts
|
|
5724
5910
|
const getModuleId = (orgImport) => {
|
|
5725
5911
|
if (orgImport.startsWith("~")) orgImport = orgImport.substring(1);
|
|
@@ -5809,6 +5995,93 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
|
|
|
5809
5995
|
extensions: exts
|
|
5810
5996
|
};
|
|
5811
5997
|
};
|
|
5998
|
+
//#endregion
|
|
5999
|
+
//#region src/compiler/app-core/app-data.ts
|
|
6000
|
+
/**
|
|
6001
|
+
* Generate a {@link BuildFeatures} entity, based on the provided component metadata
|
|
6002
|
+
* @param cmps a collection of component compiler metadata, used to set values on the generated build features object
|
|
6003
|
+
* @returns the generated build features entity
|
|
6004
|
+
*/
|
|
6005
|
+
const getBuildFeatures = (cmps) => {
|
|
6006
|
+
const slot = cmps.some((c) => c.htmlTagNames.includes("slot"));
|
|
6007
|
+
const shadowDom = cmps.some((c) => c.encapsulation === "shadow");
|
|
6008
|
+
const slotRelocation = cmps.some((c) => c.encapsulation !== "shadow" && c.htmlTagNames.includes("slot"));
|
|
6009
|
+
const f = {
|
|
6010
|
+
allRenderFn: cmps.every((c) => c.hasRenderFn),
|
|
6011
|
+
formAssociated: cmps.some((c) => c.formAssociated),
|
|
6012
|
+
deserializer: cmps.some((c) => c.hasDeserializer),
|
|
6013
|
+
element: cmps.some((c) => c.hasElement),
|
|
6014
|
+
event: cmps.some((c) => c.hasEvent),
|
|
6015
|
+
hasRenderFn: cmps.some((c) => c.hasRenderFn),
|
|
6016
|
+
lifecycle: cmps.some((c) => c.hasLifecycle),
|
|
6017
|
+
asyncLoading: true,
|
|
6018
|
+
hostListener: cmps.some((c) => c.hasListener),
|
|
6019
|
+
hostListenerTargetWindow: cmps.some((c) => c.hasListenerTargetWindow),
|
|
6020
|
+
hostListenerTargetDocument: cmps.some((c) => c.hasListenerTargetDocument),
|
|
6021
|
+
hostListenerTargetBody: cmps.some((c) => c.hasListenerTargetBody),
|
|
6022
|
+
hostListenerTarget: cmps.some((c) => c.hasListenerTarget),
|
|
6023
|
+
member: cmps.some((c) => c.hasMember),
|
|
6024
|
+
method: cmps.some((c) => c.hasMethod),
|
|
6025
|
+
mode: cmps.some((c) => c.hasMode),
|
|
6026
|
+
observeAttribute: cmps.some((c) => c.hasAttribute || c.hasWatchCallback || c.hasDeserializer),
|
|
6027
|
+
prop: cmps.some((c) => c.hasProp),
|
|
6028
|
+
propBoolean: cmps.some((c) => c.hasPropBoolean),
|
|
6029
|
+
propChangeCallback: cmps.some((c) => c.hasWatchCallback || c.hasDeserializer || c.hasSerializer),
|
|
6030
|
+
propNumber: cmps.some((c) => c.hasPropNumber),
|
|
6031
|
+
propString: cmps.some((c) => c.hasPropString),
|
|
6032
|
+
propMutable: cmps.some((c) => c.hasPropMutable),
|
|
6033
|
+
reflect: cmps.some((c) => c.hasReflect || c.hasSerializer),
|
|
6034
|
+
scoped: cmps.some((c) => c.encapsulation === "scoped"),
|
|
6035
|
+
serializer: cmps.some((c) => c.hasSerializer),
|
|
6036
|
+
shadowDom,
|
|
6037
|
+
shadowDelegatesFocus: shadowDom && cmps.some((c) => c.shadowDelegatesFocus),
|
|
6038
|
+
shadowModeClosed: shadowDom && cmps.some((c) => c.shadowMode === "closed"),
|
|
6039
|
+
shadowSlotAssignmentManual: shadowDom && cmps.some((c) => c.slotAssignment === "manual"),
|
|
6040
|
+
shadowClonable: shadowDom && cmps.some((c) => c.shadowClonable),
|
|
6041
|
+
shadowSerializable: shadowDom && cmps.some((c) => c.shadowSerializable),
|
|
6042
|
+
shadowReferenceTarget: shadowDom && cmps.some((c) => !!c.shadowReferenceTarget),
|
|
6043
|
+
slot,
|
|
6044
|
+
slotRelocation,
|
|
6045
|
+
state: cmps.some((c) => c.hasState),
|
|
6046
|
+
style: cmps.some((c) => c.hasStyle),
|
|
6047
|
+
svg: cmps.some((c) => c.htmlTagNames.includes("svg")),
|
|
6048
|
+
updatable: cmps.some((c) => c.isUpdateable),
|
|
6049
|
+
vdomAttribute: cmps.some((c) => c.hasVdomAttribute),
|
|
6050
|
+
vdomXlink: cmps.some((c) => c.hasVdomXlink),
|
|
6051
|
+
vdomClass: cmps.some((c) => c.hasVdomClass),
|
|
6052
|
+
vdomFunctional: cmps.some((c) => c.hasVdomFunctional),
|
|
6053
|
+
vdomKey: cmps.some((c) => c.hasVdomKey),
|
|
6054
|
+
vdomListener: cmps.some((c) => c.hasVdomListener),
|
|
6055
|
+
vdomPropOrAttr: cmps.some((c) => c.hasVdomPropOrAttr),
|
|
6056
|
+
vdomPropOrAttrPrefix: cmps.some((c) => c.hasVdomPropOrAttrPrefix),
|
|
6057
|
+
vdomRef: cmps.some((c) => c.hasVdomRef),
|
|
6058
|
+
vdomRender: cmps.some((c) => c.hasVdomRender),
|
|
6059
|
+
vdomStyle: cmps.some((c) => c.hasVdomStyle),
|
|
6060
|
+
vdomText: cmps.some((c) => c.hasVdomText),
|
|
6061
|
+
vdomSignals: cmps.some((c) => c.hasSignalsImport),
|
|
6062
|
+
taskQueue: true,
|
|
6063
|
+
patchAll: cmps.some((c) => c.hasPatchAll),
|
|
6064
|
+
patchChildren: cmps.some((c) => c.hasPatchChildren),
|
|
6065
|
+
patchClone: cmps.some((c) => c.hasPatchClone),
|
|
6066
|
+
patchInsert: cmps.some((c) => c.hasPatchInsert)
|
|
6067
|
+
};
|
|
6068
|
+
f.vdomAttribute = f.vdomAttribute || f.reflect;
|
|
6069
|
+
f.vdomPropOrAttr = f.vdomPropOrAttr || f.reflect;
|
|
6070
|
+
return f;
|
|
6071
|
+
};
|
|
6072
|
+
//#endregion
|
|
6073
|
+
//#region src/compiler/style/component-global-styles.ts
|
|
6074
|
+
/**
|
|
6075
|
+
* Match `@import` of a `stencil-*` virtual import in any form CSS allows or a preprocessor emits:
|
|
6076
|
+
* quoted or not, bare or `url()`-wrapped, and with or without whitespace after `@import` (Sass's
|
|
6077
|
+
* compressed output drops it). Capture group 2 holds any trailing modifiers, e.g. `layer(name)`.
|
|
6078
|
+
* @param name the virtual import to match
|
|
6079
|
+
* @returns a global regex
|
|
6080
|
+
*/
|
|
6081
|
+
const stencilVirtualImportRe = (name) => new RegExp(`@import(?:\\s+|(?=['"]|url\\())(?:url\\(\\s*)?(['"]?)${name}(?![\\w-])\\1\\s*\\)?([^;]*);?`, "g");
|
|
6082
|
+
stencilVirtualImportRe("stencil-component-globals");
|
|
6083
|
+
stencilVirtualImportRe("stencil-hydrate");
|
|
6084
|
+
stencilVirtualImportRe("stencil-css-components");
|
|
5812
6085
|
new RegExp(`^(${[.../* @__PURE__ */ new Set([
|
|
5813
6086
|
"child_process",
|
|
5814
6087
|
"cluster",
|
|
@@ -5851,6 +6124,7 @@ new RegExp(`^(${[.../* @__PURE__ */ new Set([
|
|
|
5851
6124
|
"vm",
|
|
5852
6125
|
"zlib"
|
|
5853
6126
|
])].join("|")})$`);
|
|
6127
|
+
`${JSON.stringify(SSR_PROP_REF_PREFIX)}${JSON.stringify(SSR_PROPS_REGISTRY_KEY)}`;
|
|
5854
6128
|
promisify(execFile);
|
|
5855
6129
|
process.platform;
|
|
5856
6130
|
new Set([
|
|
@@ -7357,15 +7631,6 @@ const createSystem = (c) => {
|
|
|
7357
7631
|
}
|
|
7358
7632
|
return results;
|
|
7359
7633
|
};
|
|
7360
|
-
/**
|
|
7361
|
-
* `self` is the global namespace object used within a web worker.
|
|
7362
|
-
* `window` is the browser's global namespace object (I reorganized this to check the reference on that second)
|
|
7363
|
-
* `global` is Node's global namespace object. https://nodejs.org/api/globals.html#globals_global
|
|
7364
|
-
*
|
|
7365
|
-
* loading in this order should allow workers, which are most common, then browser,
|
|
7366
|
-
* then Node to grab the reference to fetch correctly.
|
|
7367
|
-
*/
|
|
7368
|
-
const fetch = typeof self !== "undefined" ? self?.fetch : typeof window !== "undefined" ? window?.fetch : typeof global !== "undefined" ? global?.fetch : void 0;
|
|
7369
7634
|
const writeFile = async (p, data) => writeFileSync(p, data);
|
|
7370
7635
|
const tmpDirSync = () => "/.tmp";
|
|
7371
7636
|
const tick = Promise.resolve();
|
|
@@ -7376,6 +7641,7 @@ const createSystem = (c) => {
|
|
|
7376
7641
|
if (typeof hashLength === "number") hashHex = hashHex.slice(0, hashLength);
|
|
7377
7642
|
return hashHex;
|
|
7378
7643
|
};
|
|
7644
|
+
const generateFileHash = async (filePath, hashLength) => generateContentHash(readFileSync(filePath), hashLength);
|
|
7379
7645
|
const copy = async (copyTasks, srcDir) => {
|
|
7380
7646
|
const results = {
|
|
7381
7647
|
diagnostics: [],
|
|
@@ -7385,9 +7651,6 @@ const createSystem = (c) => {
|
|
|
7385
7651
|
logger.info("todo, copy task", copyTasks.length, srcDir);
|
|
7386
7652
|
return results;
|
|
7387
7653
|
};
|
|
7388
|
-
const getEnvironmentVar = (key) => {
|
|
7389
|
-
return process$1?.env[key];
|
|
7390
|
-
};
|
|
7391
7654
|
const getLocalModulePath = (opts) => join(opts.rootDir, "node_modules", opts.moduleId, opts.path);
|
|
7392
7655
|
const getRemoteModuleUrl = (opts) => {
|
|
7393
7656
|
const npmBaseUrl = "https://cdn.jsdelivr.net/npm/";
|
|
@@ -7403,13 +7666,14 @@ const createSystem = (c) => {
|
|
|
7403
7666
|
access,
|
|
7404
7667
|
accessSync,
|
|
7405
7668
|
addDestroy,
|
|
7669
|
+
checkVersion: async () => noop,
|
|
7406
7670
|
copyFile,
|
|
7407
7671
|
createDir,
|
|
7408
7672
|
createDirSync,
|
|
7409
7673
|
homeDir,
|
|
7410
7674
|
isTTY,
|
|
7411
|
-
getEnvironmentVar,
|
|
7412
7675
|
destroy,
|
|
7676
|
+
dynamicImport: (p) => import(p),
|
|
7413
7677
|
encodeToBase64,
|
|
7414
7678
|
exit: async (exitCode) => logger.warn(`exit ${exitCode}`),
|
|
7415
7679
|
getCurrentDirectory,
|
|
@@ -7420,6 +7684,7 @@ const createSystem = (c) => {
|
|
|
7420
7684
|
isSymbolicLink,
|
|
7421
7685
|
nextTick,
|
|
7422
7686
|
normalizePath: normalize,
|
|
7687
|
+
onProcessInterrupt: noop,
|
|
7423
7688
|
platformPath: path,
|
|
7424
7689
|
readDir,
|
|
7425
7690
|
readDirSync,
|
|
@@ -7429,7 +7694,6 @@ const createSystem = (c) => {
|
|
|
7429
7694
|
realpathSync,
|
|
7430
7695
|
removeDestroy,
|
|
7431
7696
|
rename,
|
|
7432
|
-
fetch,
|
|
7433
7697
|
resolvePath,
|
|
7434
7698
|
removeDir,
|
|
7435
7699
|
removeDirSync,
|
|
@@ -7444,6 +7708,7 @@ const createSystem = (c) => {
|
|
|
7444
7708
|
writeFile,
|
|
7445
7709
|
writeFileSync,
|
|
7446
7710
|
generateContentHash,
|
|
7711
|
+
generateFileHash,
|
|
7447
7712
|
createWorkerController: null,
|
|
7448
7713
|
details: {
|
|
7449
7714
|
cpuModel: "",
|
|
@@ -7694,6 +7959,7 @@ const mockComponentMeta = (overrides = {}) => ({
|
|
|
7694
7959
|
shadowDelegatesFocus: false,
|
|
7695
7960
|
shadowClonable: false,
|
|
7696
7961
|
shadowSerializable: false,
|
|
7962
|
+
shadowReferenceTarget: null,
|
|
7697
7963
|
shadowMode: null,
|
|
7698
7964
|
slotAssignment: null,
|
|
7699
7965
|
sourceFilePath: "/some/stubbed/path/my-component.tsx",
|