@stencil/core 5.0.0-rc.15 → 5.0.0-rc.16
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 +0 -1
- package/dist/{client-Cpehp9QL.mjs → client-nVB5tHhh.mjs} +60 -14
- package/dist/compiler/browser.d.ts +0 -2
- package/dist/compiler/browser.js +136 -37
- package/dist/compiler/index.d.mts +1 -1
- package/dist/compiler/index.mjs +2 -2
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-D92bSZzV.mjs → compiler-D6kG51sR.mjs} +308 -90
- package/dist/declarations/stencil-public-compiler.d.ts +0 -2
- package/dist/{index-BDAZsQzV.d.mts → index-BOBfOxcK.d.mts} +0 -2
- package/dist/{index-BS1JKKvz.d.mts → index-CamUaPx1.d.mts} +1 -1
- package/dist/{index-CWPcrnEJ.d.ts → index-DaYfl65k.d.ts} +0 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-C6N23fLr.mjs → node-IRt_dGbC.mjs} +1 -1
- package/dist/runtime/client/lazy.js +87 -18
- package/dist/runtime/client/runtime.js +87 -18
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +87 -18
- package/dist/runtime/server/index.mjs +87 -18
- package/dist/runtime/server/runner.mjs +80 -66
- package/dist/signals/index.js +0 -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 +0 -2
- package/dist/testing/index.mjs +88 -22
- package/package.json +4 -8
|
@@ -724,7 +724,6 @@ interface BuildFeatures {
|
|
|
724
724
|
patchInsert: boolean;
|
|
725
725
|
slot: boolean;
|
|
726
726
|
svg: boolean;
|
|
727
|
-
element: boolean;
|
|
728
727
|
event: boolean;
|
|
729
728
|
hostListener: boolean;
|
|
730
729
|
hostListenerTargetWindow: boolean;
|
|
@@ -1094,7 +1093,6 @@ interface ComponentCompilerFeatures {
|
|
|
1094
1093
|
hasConnectedCallbackFn: boolean;
|
|
1095
1094
|
hasDeserializer: boolean;
|
|
1096
1095
|
hasDisconnectedCallbackFn: boolean;
|
|
1097
|
-
hasElement: boolean;
|
|
1098
1096
|
hasEvent: boolean;
|
|
1099
1097
|
hasLifecycle: boolean;
|
|
1100
1098
|
hasListener: boolean;
|
|
@@ -4729,7 +4729,6 @@ interface BuildFeatures {
|
|
|
4729
4729
|
patchInsert: boolean;
|
|
4730
4730
|
slot: boolean;
|
|
4731
4731
|
svg: boolean;
|
|
4732
|
-
element: boolean;
|
|
4733
4732
|
event: boolean;
|
|
4734
4733
|
hostListener: boolean;
|
|
4735
4734
|
hostListenerTargetWindow: boolean;
|
|
@@ -5099,7 +5098,6 @@ interface ComponentCompilerFeatures {
|
|
|
5099
5098
|
hasConnectedCallbackFn: boolean;
|
|
5100
5099
|
hasDeserializer: boolean;
|
|
5101
5100
|
hasDisconnectedCallbackFn: boolean;
|
|
5102
|
-
hasElement: boolean;
|
|
5103
5101
|
hasEvent: boolean;
|
|
5104
5102
|
hasLifecycle: boolean;
|
|
5105
5103
|
hasListener: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cr as ResolutionHandler, dr as VNode, ir as FunctionalComponent, lr as TagTransformer, n as ChildType, or as RafCallback, p as HostElement, rr as ErrorHandler, ur as UserBuildConditionals, v as PropsType, y as RuntimeRef } from "./index-
|
|
1
|
+
import { cr as ResolutionHandler, dr as VNode, ir as FunctionalComponent, lr as TagTransformer, n as ChildType, or as RafCallback, p as HostElement, rr as ErrorHandler, ur as UserBuildConditionals, v as PropsType, y as RuntimeRef } from "./index-BOBfOxcK.mjs";
|
|
2
2
|
//#region src/client/client-build.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Build, S as setErrorHandler, _ as getAssetPath, a as transformTag, b as writeTask, c as Mixin, d as Host, f as h, g as getShadowRoot, h as getElement, i as setTagTransformer, l as getMode, m as getRenderingRef, o as render, p as forceUpdate, s as ReactiveControllerHost, u as setMode, v as setAssetPath, x as setPlatformHelpers, y as readTask } from "./client-
|
|
1
|
+
import { C as Build, S as setErrorHandler, _ as getAssetPath, a as transformTag, b as writeTask, c as Mixin, d as Host, f as h, g as getShadowRoot, h as getElement, i as setTagTransformer, l as getMode, m as getRenderingRef, o as render, p as forceUpdate, s as ReactiveControllerHost, u as setMode, v as setAssetPath, x as setPlatformHelpers, y as readTask } from "./client-nVB5tHhh.mjs";
|
|
2
2
|
import { t as Fragment } from "./fragment-Di1hWOC8.mjs";
|
|
3
3
|
//#region src/client/client-decorators.ts
|
|
4
4
|
/**
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import "./client-
|
|
2
|
+
import "./client-nVB5tHhh.mjs";
|
|
3
3
|
import { c as isFunction, f as isString, m as noop, r as flatOne } from "./helpers-k8xQHE77.mjs";
|
|
4
4
|
import { X as TASK_CANCELED_MSG, Z as buildError, et as catchError, it as isGlob, q as normalizePath, rt as shouldIgnoreError } from "./util-Cj2D3x_h.mjs";
|
|
5
5
|
import fs from "node:fs";
|
|
@@ -781,19 +781,28 @@ const getSlottedChildNodes = (childNodes) => {
|
|
|
781
781
|
* @returns a reference to the slot node that matches the provided name, `null` otherwise
|
|
782
782
|
*/
|
|
783
783
|
function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
784
|
+
const slotNodes = [];
|
|
785
|
+
collectHostSlotNodes(childNodes, hostName, slotName, slotNodes);
|
|
786
|
+
return slotNodes;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Pre-order walk for {@link getHostSlotNodes}, appending to `out`.
|
|
790
|
+
* @param childNodes the nodes to search
|
|
791
|
+
* @param hostName the host name of the slot to match on
|
|
792
|
+
* @param slotName the name of the slot to match on; stops at the first match when given
|
|
793
|
+
* @param out the matching slot nodes, in document order
|
|
794
|
+
* @returns true once a named slot has been found
|
|
795
|
+
*/
|
|
796
|
+
function collectHostSlotNodes(childNodes, hostName, slotName, out) {
|
|
797
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
798
|
+
const childNode = childNodes[i];
|
|
789
799
|
if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
|
|
790
|
-
|
|
791
|
-
if (
|
|
800
|
+
out.push(childNode);
|
|
801
|
+
if (slotName !== void 0) return true;
|
|
792
802
|
}
|
|
793
|
-
|
|
794
|
-
if (typeof slotName !== "undefined" && slottedNodes.length) return slottedNodes;
|
|
803
|
+
if (collectHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName, out) && slotName !== void 0) return true;
|
|
795
804
|
}
|
|
796
|
-
return
|
|
805
|
+
return false;
|
|
797
806
|
}
|
|
798
807
|
/**
|
|
799
808
|
* Get all 'child' sibling nodes of a slot node
|
|
@@ -912,11 +921,40 @@ function findSlotFromSlottedNode(slottedNode, parentHost) {
|
|
|
912
921
|
slotName: ""
|
|
913
922
|
};
|
|
914
923
|
const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
|
|
924
|
+
let hostSlots = slotNodeCache.get(parentHost);
|
|
925
|
+
const cached = hostSlots?.get(slotName);
|
|
926
|
+
if (cached && isHostSlot(cached, parentHost, slotName)) return {
|
|
927
|
+
slotNode: cached,
|
|
928
|
+
slotName
|
|
929
|
+
};
|
|
930
|
+
const slotNode = getHostSlotNodes(internalCall(parentHost, "childNodes"), parentHost.tagName, slotName)[0];
|
|
931
|
+
if (slotNode) {
|
|
932
|
+
if (!hostSlots) slotNodeCache.set(parentHost, hostSlots = /* @__PURE__ */ new Map());
|
|
933
|
+
hostSlots.set(slotName, slotNode);
|
|
934
|
+
}
|
|
915
935
|
return {
|
|
916
|
-
slotNode
|
|
936
|
+
slotNode,
|
|
917
937
|
slotName
|
|
918
938
|
};
|
|
919
939
|
}
|
|
940
|
+
/**
|
|
941
|
+
* The slot node last found per host and slot name. Each slotted child of a host looks up its
|
|
942
|
+
* slot, and a full search walks the host's whole internal tree, so a host with many slotted
|
|
943
|
+
* children would otherwise cost O(children × tree).
|
|
944
|
+
*/
|
|
945
|
+
const slotNodeCache = /* @__PURE__ */ new WeakMap();
|
|
946
|
+
/**
|
|
947
|
+
* Whether a cached slot node is still the host's slot of that name.
|
|
948
|
+
* @param slotNode the cached slot node
|
|
949
|
+
* @param host the host element
|
|
950
|
+
* @param slotName the slot name
|
|
951
|
+
* @returns true if `slotNode` is still a slot of `host` named `slotName`, inside its internal tree
|
|
952
|
+
*/
|
|
953
|
+
const isHostSlot = (slotNode, host, slotName) => {
|
|
954
|
+
if (!slotNode["s-sr"] || slotNode["s-hn"] !== host.tagName || getSlotName(slotNode) !== slotName) return false;
|
|
955
|
+
for (let n = internalCall(slotNode, "parentNode"); n; n = internalCall(n, "parentNode")) if (n === host) return true;
|
|
956
|
+
return false;
|
|
957
|
+
};
|
|
920
958
|
//#endregion
|
|
921
959
|
//#region src/runtime/dom-extras.ts
|
|
922
960
|
const applyLightDomPatches = (hostElementPrototype) => {
|
|
@@ -2698,8 +2736,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2698
2736
|
if (parent?.["s-cr"]) checkSlotRelocate = true;
|
|
2699
2737
|
if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
|
|
2700
2738
|
else if (typeof newNode["s-sn"] === "string") {
|
|
2701
|
-
|
|
2702
|
-
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);
|
|
2739
|
+
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostPatchesAll(newNode, parent)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
|
|
2703
2740
|
parent.insertBefore(newNode, reference);
|
|
2704
2741
|
const { slotNode } = findSlotFromSlottedNode(newNode);
|
|
2705
2742
|
if (slotNode) {
|
|
@@ -2713,6 +2750,16 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2713
2750
|
else return parent?.insertBefore(newNode, reference);
|
|
2714
2751
|
};
|
|
2715
2752
|
/**
|
|
2753
|
+
* Whether the host a slotted node belongs to opted into `patchAll`.
|
|
2754
|
+
* @param newNode the slotted node
|
|
2755
|
+
* @param parent the node it is being inserted into
|
|
2756
|
+
* @returns true if the host component has the `patchAll` flag
|
|
2757
|
+
*/
|
|
2758
|
+
const hostPatchesAll = (newNode, parent) => {
|
|
2759
|
+
const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
|
|
2760
|
+
return !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll);
|
|
2761
|
+
};
|
|
2762
|
+
/**
|
|
2716
2763
|
* Adds or removes a scoped class to the parent element of a slotted node.
|
|
2717
2764
|
* This is used for styling slotted content (e.g. with `::scoped(...) {...}` selectors )
|
|
2718
2765
|
* in `scoped: true` components.
|
|
@@ -4208,7 +4255,7 @@ const insertPolyfillHostInCssText = (cssText) => {
|
|
|
4208
4255
|
const _colonHostContextRe = createSupportsRuleRe(":host-context");
|
|
4209
4256
|
cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
|
|
4210
4257
|
supportsBlocks.forEach((originalSelector, index) => {
|
|
4211
|
-
cssText = cssText.replace(`__supports_${index}__`, originalSelector);
|
|
4258
|
+
cssText = cssText.replace(`__supports_${index}__`, () => originalSelector);
|
|
4212
4259
|
});
|
|
4213
4260
|
return cssText;
|
|
4214
4261
|
};
|
|
@@ -4441,11 +4488,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4441
4488
|
const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
|
|
4442
4489
|
cssText = [scoped.cssText, ...commentsWithHash].join("\n");
|
|
4443
4490
|
if (commentOriginalSelector) orgSelectors.forEach(({ placeholder, comment }) => {
|
|
4444
|
-
cssText = cssText.replace(placeholder, comment);
|
|
4491
|
+
cssText = cssText.replace(placeholder, () => comment);
|
|
4445
4492
|
});
|
|
4446
4493
|
scoped.slottedSelectors.forEach((slottedSelector) => {
|
|
4447
4494
|
const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector) + "(?=\\s*[,{]|$)", "g");
|
|
4448
|
-
cssText = cssText.replace(regex, slottedSelector.updatedSelector);
|
|
4495
|
+
cssText = cssText.replace(regex, () => slottedSelector.updatedSelector);
|
|
4449
4496
|
});
|
|
4450
4497
|
cssText = expandPartSelectors(cssText);
|
|
4451
4498
|
return cssText;
|
|
@@ -4690,6 +4737,28 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4690
4737
|
};
|
|
4691
4738
|
//#endregion
|
|
4692
4739
|
//#region src/runtime/initialize-component.ts
|
|
4740
|
+
/** Distinct style texts kept; an app has one per component and mode. */
|
|
4741
|
+
const SSR_CSS_CACHE_MAX = 1e3;
|
|
4742
|
+
/**
|
|
4743
|
+
* Memoizes a server-side rewrite of a component's style text. The rewrites are pure, but the
|
|
4744
|
+
* platform (and its `styles` registry) is rebuilt per render, so without this they'd rerun on
|
|
4745
|
+
* every render.
|
|
4746
|
+
* @param style the component's style text
|
|
4747
|
+
* @param key what the rewrite depends on besides the text
|
|
4748
|
+
* @param rewrite computes the result
|
|
4749
|
+
* @returns the rewritten style
|
|
4750
|
+
*/
|
|
4751
|
+
const ssrCachedCss = (style, key, rewrite) => {
|
|
4752
|
+
if (typeof $stencilSsrCssCache === "undefined" || typeof style !== "string") return rewrite();
|
|
4753
|
+
let byKey = $stencilSsrCssCache.get(style);
|
|
4754
|
+
if (!byKey) {
|
|
4755
|
+
if ($stencilSsrCssCache.size >= SSR_CSS_CACHE_MAX) $stencilSsrCssCache.clear();
|
|
4756
|
+
$stencilSsrCssCache.set(style, byKey = /* @__PURE__ */ new Map());
|
|
4757
|
+
}
|
|
4758
|
+
let result = byKey.get(key);
|
|
4759
|
+
if (result === void 0) byKey.set(key, result = rewrite());
|
|
4760
|
+
return result;
|
|
4761
|
+
};
|
|
4693
4762
|
/**
|
|
4694
4763
|
* Initialize a Stencil component given a reference to its host element, its
|
|
4695
4764
|
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
@@ -4790,8 +4859,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4790
4859
|
if (!styles.has(scopeId) || BUILD.hotModuleReplacement && hmrVersionId) {
|
|
4791
4860
|
const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
|
|
4792
4861
|
if (BUILD.hydrateServerSide && BUILD.shadowDom) {
|
|
4793
|
-
if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = scopeCss(style, scopeId, true);
|
|
4794
|
-
else if (needsScopedSSR()) style = expandPartSelectors(style);
|
|
4862
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = ssrCachedCss(style, `s:${scopeId}`, () => scopeCss(style, scopeId, true));
|
|
4863
|
+
else if (needsScopedSSR()) style = ssrCachedCss(style, "p", () => expandPartSelectors(style));
|
|
4795
4864
|
}
|
|
4796
4865
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation));
|
|
4797
4866
|
endRegisterStyles();
|
|
@@ -775,19 +775,28 @@ const getSlottedChildNodes = (childNodes) => {
|
|
|
775
775
|
* @returns a reference to the slot node that matches the provided name, `null` otherwise
|
|
776
776
|
*/
|
|
777
777
|
function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
778
|
+
const slotNodes = [];
|
|
779
|
+
collectHostSlotNodes(childNodes, hostName, slotName, slotNodes);
|
|
780
|
+
return slotNodes;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Pre-order walk for {@link getHostSlotNodes}, appending to `out`.
|
|
784
|
+
* @param childNodes the nodes to search
|
|
785
|
+
* @param hostName the host name of the slot to match on
|
|
786
|
+
* @param slotName the name of the slot to match on; stops at the first match when given
|
|
787
|
+
* @param out the matching slot nodes, in document order
|
|
788
|
+
* @returns true once a named slot has been found
|
|
789
|
+
*/
|
|
790
|
+
function collectHostSlotNodes(childNodes, hostName, slotName, out) {
|
|
791
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
792
|
+
const childNode = childNodes[i];
|
|
783
793
|
if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
|
|
784
|
-
|
|
785
|
-
if (
|
|
794
|
+
out.push(childNode);
|
|
795
|
+
if (slotName !== void 0) return true;
|
|
786
796
|
}
|
|
787
|
-
|
|
788
|
-
if (typeof slotName !== "undefined" && slottedNodes.length) return slottedNodes;
|
|
797
|
+
if (collectHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName, out) && slotName !== void 0) return true;
|
|
789
798
|
}
|
|
790
|
-
return
|
|
799
|
+
return false;
|
|
791
800
|
}
|
|
792
801
|
/**
|
|
793
802
|
* Get all 'child' sibling nodes of a slot node
|
|
@@ -906,11 +915,40 @@ function findSlotFromSlottedNode(slottedNode, parentHost) {
|
|
|
906
915
|
slotName: ""
|
|
907
916
|
};
|
|
908
917
|
const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
|
|
918
|
+
let hostSlots = slotNodeCache.get(parentHost);
|
|
919
|
+
const cached = hostSlots?.get(slotName);
|
|
920
|
+
if (cached && isHostSlot(cached, parentHost, slotName)) return {
|
|
921
|
+
slotNode: cached,
|
|
922
|
+
slotName
|
|
923
|
+
};
|
|
924
|
+
const slotNode = getHostSlotNodes(internalCall(parentHost, "childNodes"), parentHost.tagName, slotName)[0];
|
|
925
|
+
if (slotNode) {
|
|
926
|
+
if (!hostSlots) slotNodeCache.set(parentHost, hostSlots = /* @__PURE__ */ new Map());
|
|
927
|
+
hostSlots.set(slotName, slotNode);
|
|
928
|
+
}
|
|
909
929
|
return {
|
|
910
|
-
slotNode
|
|
930
|
+
slotNode,
|
|
911
931
|
slotName
|
|
912
932
|
};
|
|
913
933
|
}
|
|
934
|
+
/**
|
|
935
|
+
* The slot node last found per host and slot name. Each slotted child of a host looks up its
|
|
936
|
+
* slot, and a full search walks the host's whole internal tree, so a host with many slotted
|
|
937
|
+
* children would otherwise cost O(children × tree).
|
|
938
|
+
*/
|
|
939
|
+
const slotNodeCache = /* @__PURE__ */ new WeakMap();
|
|
940
|
+
/**
|
|
941
|
+
* Whether a cached slot node is still the host's slot of that name.
|
|
942
|
+
* @param slotNode the cached slot node
|
|
943
|
+
* @param host the host element
|
|
944
|
+
* @param slotName the slot name
|
|
945
|
+
* @returns true if `slotNode` is still a slot of `host` named `slotName`, inside its internal tree
|
|
946
|
+
*/
|
|
947
|
+
const isHostSlot = (slotNode, host, slotName) => {
|
|
948
|
+
if (!slotNode["s-sr"] || slotNode["s-hn"] !== host.tagName || getSlotName(slotNode) !== slotName) return false;
|
|
949
|
+
for (let n = internalCall(slotNode, "parentNode"); n; n = internalCall(n, "parentNode")) if (n === host) return true;
|
|
950
|
+
return false;
|
|
951
|
+
};
|
|
914
952
|
//#endregion
|
|
915
953
|
//#region src/runtime/dom-extras.ts
|
|
916
954
|
const applyLightDomPatches = (hostElementPrototype) => {
|
|
@@ -2692,8 +2730,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2692
2730
|
if (parent?.["s-cr"]) checkSlotRelocate = true;
|
|
2693
2731
|
if (BUILD$1.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
|
|
2694
2732
|
else if (typeof newNode["s-sn"] === "string") {
|
|
2695
|
-
|
|
2696
|
-
if ((BUILD$1.lightDomPatches || BUILD$1.slotChildNodes || BUILD$1.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
|
|
2733
|
+
if ((BUILD$1.lightDomPatches || BUILD$1.slotChildNodes || BUILD$1.patchAll && hostPatchesAll(newNode, parent)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
|
|
2697
2734
|
parent.insertBefore(newNode, reference);
|
|
2698
2735
|
const { slotNode } = findSlotFromSlottedNode(newNode);
|
|
2699
2736
|
if (slotNode) {
|
|
@@ -2707,6 +2744,16 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2707
2744
|
else return parent?.insertBefore(newNode, reference);
|
|
2708
2745
|
};
|
|
2709
2746
|
/**
|
|
2747
|
+
* Whether the host a slotted node belongs to opted into `patchAll`.
|
|
2748
|
+
* @param newNode the slotted node
|
|
2749
|
+
* @param parent the node it is being inserted into
|
|
2750
|
+
* @returns true if the host component has the `patchAll` flag
|
|
2751
|
+
*/
|
|
2752
|
+
const hostPatchesAll = (newNode, parent) => {
|
|
2753
|
+
const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
|
|
2754
|
+
return !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll);
|
|
2755
|
+
};
|
|
2756
|
+
/**
|
|
2710
2757
|
* Adds or removes a scoped class to the parent element of a slotted node.
|
|
2711
2758
|
* This is used for styling slotted content (e.g. with `::scoped(...) {...}` selectors )
|
|
2712
2759
|
* in `scoped: true` components.
|
|
@@ -4202,7 +4249,7 @@ const insertPolyfillHostInCssText = (cssText) => {
|
|
|
4202
4249
|
const _colonHostContextRe = createSupportsRuleRe(":host-context");
|
|
4203
4250
|
cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
|
|
4204
4251
|
supportsBlocks.forEach((originalSelector, index) => {
|
|
4205
|
-
cssText = cssText.replace(`__supports_${index}__`, originalSelector);
|
|
4252
|
+
cssText = cssText.replace(`__supports_${index}__`, () => originalSelector);
|
|
4206
4253
|
});
|
|
4207
4254
|
return cssText;
|
|
4208
4255
|
};
|
|
@@ -4435,11 +4482,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4435
4482
|
const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
|
|
4436
4483
|
cssText = [scoped.cssText, ...commentsWithHash].join("\n");
|
|
4437
4484
|
if (commentOriginalSelector) orgSelectors.forEach(({ placeholder, comment }) => {
|
|
4438
|
-
cssText = cssText.replace(placeholder, comment);
|
|
4485
|
+
cssText = cssText.replace(placeholder, () => comment);
|
|
4439
4486
|
});
|
|
4440
4487
|
scoped.slottedSelectors.forEach((slottedSelector) => {
|
|
4441
4488
|
const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector) + "(?=\\s*[,{]|$)", "g");
|
|
4442
|
-
cssText = cssText.replace(regex, slottedSelector.updatedSelector);
|
|
4489
|
+
cssText = cssText.replace(regex, () => slottedSelector.updatedSelector);
|
|
4443
4490
|
});
|
|
4444
4491
|
cssText = expandPartSelectors(cssText);
|
|
4445
4492
|
return cssText;
|
|
@@ -4684,6 +4731,28 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4684
4731
|
};
|
|
4685
4732
|
//#endregion
|
|
4686
4733
|
//#region src/runtime/initialize-component.ts
|
|
4734
|
+
/** Distinct style texts kept; an app has one per component and mode. */
|
|
4735
|
+
const SSR_CSS_CACHE_MAX = 1e3;
|
|
4736
|
+
/**
|
|
4737
|
+
* Memoizes a server-side rewrite of a component's style text. The rewrites are pure, but the
|
|
4738
|
+
* platform (and its `styles` registry) is rebuilt per render, so without this they'd rerun on
|
|
4739
|
+
* every render.
|
|
4740
|
+
* @param style the component's style text
|
|
4741
|
+
* @param key what the rewrite depends on besides the text
|
|
4742
|
+
* @param rewrite computes the result
|
|
4743
|
+
* @returns the rewritten style
|
|
4744
|
+
*/
|
|
4745
|
+
const ssrCachedCss = (style, key, rewrite) => {
|
|
4746
|
+
if (typeof $stencilSsrCssCache === "undefined" || typeof style !== "string") return rewrite();
|
|
4747
|
+
let byKey = $stencilSsrCssCache.get(style);
|
|
4748
|
+
if (!byKey) {
|
|
4749
|
+
if ($stencilSsrCssCache.size >= SSR_CSS_CACHE_MAX) $stencilSsrCssCache.clear();
|
|
4750
|
+
$stencilSsrCssCache.set(style, byKey = /* @__PURE__ */ new Map());
|
|
4751
|
+
}
|
|
4752
|
+
let result = byKey.get(key);
|
|
4753
|
+
if (result === void 0) byKey.set(key, result = rewrite());
|
|
4754
|
+
return result;
|
|
4755
|
+
};
|
|
4687
4756
|
/**
|
|
4688
4757
|
* Initialize a Stencil component given a reference to its host element, its
|
|
4689
4758
|
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
@@ -4784,8 +4853,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4784
4853
|
if (!styles.has(scopeId) || BUILD$1.hotModuleReplacement && hmrVersionId) {
|
|
4785
4854
|
const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
|
|
4786
4855
|
if (BUILD$1.hydrateServerSide && BUILD$1.shadowDom) {
|
|
4787
|
-
if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = scopeCss(style, scopeId, true);
|
|
4788
|
-
else if (needsScopedSSR()) style = expandPartSelectors(style);
|
|
4856
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = ssrCachedCss(style, `s:${scopeId}`, () => scopeCss(style, scopeId, true));
|
|
4857
|
+
else if (needsScopedSSR()) style = ssrCachedCss(style, "p", () => expandPartSelectors(style));
|
|
4789
4858
|
}
|
|
4790
4859
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation));
|
|
4791
4860
|
endRegisterStyles();
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ReactiveControllerHostInterface, E as VNode, S as MixedInCtor, T as TagTransformer, _ as ComponentInterface, a as ComponentConstructor, b as HTMLStencilElement, c as ComponentRuntimeMeta, d as HostRef, f as LazyBundlesRuntimeData, g as RuntimeRef, h as RenderNode, i as ChildType, l as ComponentRuntimeMetaCompact, m as PropsType, o as ComponentConstructorChangeHandlers, p as PlatformRuntime, s as ComponentRuntimeHostListener, u as HostElement, v as CustomElementsDefineOptions, w as ResolutionHandler, x as JSXBase, y as FunctionalComponent } from "../index-
|
|
1
|
+
import { C as ReactiveControllerHostInterface, E as VNode, S as MixedInCtor, T as TagTransformer, _ as ComponentInterface, a as ComponentConstructor, b as HTMLStencilElement, c as ComponentRuntimeMeta, d as HostRef, f as LazyBundlesRuntimeData, g as RuntimeRef, h as RenderNode, i as ChildType, l as ComponentRuntimeMetaCompact, m as PropsType, o as ComponentConstructorChangeHandlers, p as PlatformRuntime, s as ComponentRuntimeHostListener, u as HostElement, v as CustomElementsDefineOptions, w as ResolutionHandler, x as JSXBase, y as FunctionalComponent } from "../index-DaYfl65k.js";
|
|
2
2
|
//#region src/runtime/asset-path.d.ts
|
|
3
3
|
declare const getAssetPath: (path: string) => string;
|
|
4
4
|
declare const setAssetPath: (path: string) => string;
|
package/dist/runtime/index.js
CHANGED
|
@@ -647,19 +647,28 @@ const getSlottedChildNodes = (childNodes) => {
|
|
|
647
647
|
* @returns a reference to the slot node that matches the provided name, `null` otherwise
|
|
648
648
|
*/
|
|
649
649
|
function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
650
|
+
const slotNodes = [];
|
|
651
|
+
collectHostSlotNodes(childNodes, hostName, slotName, slotNodes);
|
|
652
|
+
return slotNodes;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Pre-order walk for {@link getHostSlotNodes}, appending to `out`.
|
|
656
|
+
* @param childNodes the nodes to search
|
|
657
|
+
* @param hostName the host name of the slot to match on
|
|
658
|
+
* @param slotName the name of the slot to match on; stops at the first match when given
|
|
659
|
+
* @param out the matching slot nodes, in document order
|
|
660
|
+
* @returns true once a named slot has been found
|
|
661
|
+
*/
|
|
662
|
+
function collectHostSlotNodes(childNodes, hostName, slotName, out) {
|
|
663
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
664
|
+
const childNode = childNodes[i];
|
|
655
665
|
if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
|
|
656
|
-
|
|
657
|
-
if (
|
|
666
|
+
out.push(childNode);
|
|
667
|
+
if (slotName !== void 0) return true;
|
|
658
668
|
}
|
|
659
|
-
|
|
660
|
-
if (typeof slotName !== "undefined" && slottedNodes.length) return slottedNodes;
|
|
669
|
+
if (collectHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName, out) && slotName !== void 0) return true;
|
|
661
670
|
}
|
|
662
|
-
return
|
|
671
|
+
return false;
|
|
663
672
|
}
|
|
664
673
|
/**
|
|
665
674
|
* Get all 'child' sibling nodes of a slot node
|
|
@@ -778,11 +787,40 @@ function findSlotFromSlottedNode(slottedNode, parentHost) {
|
|
|
778
787
|
slotName: ""
|
|
779
788
|
};
|
|
780
789
|
const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
|
|
790
|
+
let hostSlots = slotNodeCache.get(parentHost);
|
|
791
|
+
const cached = hostSlots?.get(slotName);
|
|
792
|
+
if (cached && isHostSlot(cached, parentHost, slotName)) return {
|
|
793
|
+
slotNode: cached,
|
|
794
|
+
slotName
|
|
795
|
+
};
|
|
796
|
+
const slotNode = getHostSlotNodes(internalCall(parentHost, "childNodes"), parentHost.tagName, slotName)[0];
|
|
797
|
+
if (slotNode) {
|
|
798
|
+
if (!hostSlots) slotNodeCache.set(parentHost, hostSlots = /* @__PURE__ */ new Map());
|
|
799
|
+
hostSlots.set(slotName, slotNode);
|
|
800
|
+
}
|
|
781
801
|
return {
|
|
782
|
-
slotNode
|
|
802
|
+
slotNode,
|
|
783
803
|
slotName
|
|
784
804
|
};
|
|
785
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* The slot node last found per host and slot name. Each slotted child of a host looks up its
|
|
808
|
+
* slot, and a full search walks the host's whole internal tree, so a host with many slotted
|
|
809
|
+
* children would otherwise cost O(children × tree).
|
|
810
|
+
*/
|
|
811
|
+
const slotNodeCache = /* @__PURE__ */ new WeakMap();
|
|
812
|
+
/**
|
|
813
|
+
* Whether a cached slot node is still the host's slot of that name.
|
|
814
|
+
* @param slotNode the cached slot node
|
|
815
|
+
* @param host the host element
|
|
816
|
+
* @param slotName the slot name
|
|
817
|
+
* @returns true if `slotNode` is still a slot of `host` named `slotName`, inside its internal tree
|
|
818
|
+
*/
|
|
819
|
+
const isHostSlot = (slotNode, host, slotName) => {
|
|
820
|
+
if (!slotNode["s-sr"] || slotNode["s-hn"] !== host.tagName || getSlotName(slotNode) !== slotName) return false;
|
|
821
|
+
for (let n = internalCall(slotNode, "parentNode"); n; n = internalCall(n, "parentNode")) if (n === host) return true;
|
|
822
|
+
return false;
|
|
823
|
+
};
|
|
786
824
|
//#endregion
|
|
787
825
|
//#region src/runtime/dom-extras.ts
|
|
788
826
|
const applyLightDomPatches = (hostElementPrototype) => {
|
|
@@ -2564,8 +2602,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2564
2602
|
if (parent?.["s-cr"]) checkSlotRelocate = true;
|
|
2565
2603
|
if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
|
|
2566
2604
|
else if (typeof newNode["s-sn"] === "string") {
|
|
2567
|
-
|
|
2568
|
-
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);
|
|
2605
|
+
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostPatchesAll(newNode, parent)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
|
|
2569
2606
|
parent.insertBefore(newNode, reference);
|
|
2570
2607
|
const { slotNode } = findSlotFromSlottedNode(newNode);
|
|
2571
2608
|
if (slotNode) {
|
|
@@ -2579,6 +2616,16 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
|
2579
2616
|
else return parent?.insertBefore(newNode, reference);
|
|
2580
2617
|
};
|
|
2581
2618
|
/**
|
|
2619
|
+
* Whether the host a slotted node belongs to opted into `patchAll`.
|
|
2620
|
+
* @param newNode the slotted node
|
|
2621
|
+
* @param parent the node it is being inserted into
|
|
2622
|
+
* @returns true if the host component has the `patchAll` flag
|
|
2623
|
+
*/
|
|
2624
|
+
const hostPatchesAll = (newNode, parent) => {
|
|
2625
|
+
const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
|
|
2626
|
+
return !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll);
|
|
2627
|
+
};
|
|
2628
|
+
/**
|
|
2582
2629
|
* Adds or removes a scoped class to the parent element of a slotted node.
|
|
2583
2630
|
* This is used for styling slotted content (e.g. with `::scoped(...) {...}` selectors )
|
|
2584
2631
|
* in `scoped: true` components.
|
|
@@ -4074,7 +4121,7 @@ const insertPolyfillHostInCssText = (cssText) => {
|
|
|
4074
4121
|
const _colonHostContextRe = createSupportsRuleRe(":host-context");
|
|
4075
4122
|
cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
|
|
4076
4123
|
supportsBlocks.forEach((originalSelector, index) => {
|
|
4077
|
-
cssText = cssText.replace(`__supports_${index}__`, originalSelector);
|
|
4124
|
+
cssText = cssText.replace(`__supports_${index}__`, () => originalSelector);
|
|
4078
4125
|
});
|
|
4079
4126
|
return cssText;
|
|
4080
4127
|
};
|
|
@@ -4307,11 +4354,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4307
4354
|
const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
|
|
4308
4355
|
cssText = [scoped.cssText, ...commentsWithHash].join("\n");
|
|
4309
4356
|
if (commentOriginalSelector) orgSelectors.forEach(({ placeholder, comment }) => {
|
|
4310
|
-
cssText = cssText.replace(placeholder, comment);
|
|
4357
|
+
cssText = cssText.replace(placeholder, () => comment);
|
|
4311
4358
|
});
|
|
4312
4359
|
scoped.slottedSelectors.forEach((slottedSelector) => {
|
|
4313
4360
|
const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector) + "(?=\\s*[,{]|$)", "g");
|
|
4314
|
-
cssText = cssText.replace(regex, slottedSelector.updatedSelector);
|
|
4361
|
+
cssText = cssText.replace(regex, () => slottedSelector.updatedSelector);
|
|
4315
4362
|
});
|
|
4316
4363
|
cssText = expandPartSelectors(cssText);
|
|
4317
4364
|
return cssText;
|
|
@@ -4556,6 +4603,28 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4556
4603
|
};
|
|
4557
4604
|
//#endregion
|
|
4558
4605
|
//#region src/runtime/initialize-component.ts
|
|
4606
|
+
/** Distinct style texts kept; an app has one per component and mode. */
|
|
4607
|
+
const SSR_CSS_CACHE_MAX = 1e3;
|
|
4608
|
+
/**
|
|
4609
|
+
* Memoizes a server-side rewrite of a component's style text. The rewrites are pure, but the
|
|
4610
|
+
* platform (and its `styles` registry) is rebuilt per render, so without this they'd rerun on
|
|
4611
|
+
* every render.
|
|
4612
|
+
* @param style the component's style text
|
|
4613
|
+
* @param key what the rewrite depends on besides the text
|
|
4614
|
+
* @param rewrite computes the result
|
|
4615
|
+
* @returns the rewritten style
|
|
4616
|
+
*/
|
|
4617
|
+
const ssrCachedCss = (style, key, rewrite) => {
|
|
4618
|
+
if (typeof $stencilSsrCssCache === "undefined" || typeof style !== "string") return rewrite();
|
|
4619
|
+
let byKey = $stencilSsrCssCache.get(style);
|
|
4620
|
+
if (!byKey) {
|
|
4621
|
+
if ($stencilSsrCssCache.size >= SSR_CSS_CACHE_MAX) $stencilSsrCssCache.clear();
|
|
4622
|
+
$stencilSsrCssCache.set(style, byKey = /* @__PURE__ */ new Map());
|
|
4623
|
+
}
|
|
4624
|
+
let result = byKey.get(key);
|
|
4625
|
+
if (result === void 0) byKey.set(key, result = rewrite());
|
|
4626
|
+
return result;
|
|
4627
|
+
};
|
|
4559
4628
|
/**
|
|
4560
4629
|
* Initialize a Stencil component given a reference to its host element, its
|
|
4561
4630
|
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
@@ -4656,8 +4725,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4656
4725
|
if (!styles.has(scopeId) || BUILD.hotModuleReplacement && hmrVersionId) {
|
|
4657
4726
|
const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
|
|
4658
4727
|
if (BUILD.hydrateServerSide && BUILD.shadowDom) {
|
|
4659
|
-
if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = scopeCss(style, scopeId, true);
|
|
4660
|
-
else if (needsScopedSSR()) style = expandPartSelectors(style);
|
|
4728
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) style = ssrCachedCss(style, `s:${scopeId}`, () => scopeCss(style, scopeId, true));
|
|
4729
|
+
else if (needsScopedSSR()) style = ssrCachedCss(style, "p", () => expandPartSelectors(style));
|
|
4661
4730
|
}
|
|
4662
4731
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation));
|
|
4663
4732
|
endRegisterStyles();
|