@stencil/core 5.0.0-beta.3 → 5.0.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-BRu0GtRn.mjs → client-BYvfR_Hx.mjs} +127 -68
  3. package/dist/compiler/browser.d.ts +114 -81
  4. package/dist/compiler/browser.js +733 -336
  5. package/dist/compiler/index.d.mts +110 -2
  6. package/dist/compiler/index.mjs +3 -3
  7. package/dist/compiler/utils/index.d.mts +1 -1
  8. package/dist/{compiler-BPgV6bA4.mjs → compiler-6RhuOkQ0.mjs} +4829 -2895
  9. package/dist/declarations/stencil-public-compiler.d.ts +152 -129
  10. package/dist/declarations/stencil-public-docs.d.ts +23 -0
  11. package/dist/declarations/stencil-public-runtime.d.ts +60 -58
  12. package/dist/{index-DmHmu3y0.d.mts → index-BGUOG9Wc.d.mts} +6 -2
  13. package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
  14. package/dist/{index-BopBfjPu.d.mts → index-BogZpjP2.d.mts} +150 -127
  15. package/dist/index.d.mts +3 -0
  16. package/dist/index.mjs +1 -1
  17. package/dist/jsx-runtime.d.mts +6 -0
  18. package/dist/jsx-runtime.mjs +1 -1
  19. package/dist/{node-75gQKkFz.mjs → node-CvPPhnWO.mjs} +41 -47
  20. package/dist/runtime/client/lazy.js +252 -189
  21. package/dist/runtime/client/runtime.d.ts +71 -66
  22. package/dist/runtime/client/runtime.js +252 -189
  23. package/dist/runtime/index.d.ts +4 -5
  24. package/dist/runtime/index.js +250 -187
  25. package/dist/runtime/server/index.d.mts +11 -11
  26. package/dist/runtime/server/index.mjs +302 -228
  27. package/dist/runtime/server/runner.d.mts +4 -4
  28. package/dist/runtime/server/runner.mjs +82 -54
  29. package/dist/signals/index.d.ts +11 -2
  30. package/dist/signals/index.js +14 -35
  31. package/dist/sys/node/index.d.mts +1 -1
  32. package/dist/sys/node/index.mjs +1 -1
  33. package/dist/sys/node/worker.mjs +2 -2
  34. package/dist/testing/index.d.mts +136 -120
  35. package/dist/testing/index.mjs +259 -201
  36. package/package.json +8 -4
@@ -1,2 +1,2 @@
1
- import { n as Env, r as NAMESPACE, t as BUILD } from "../index-BXAcVN2j.js";
1
+ import { n as Env, r as NAMESPACE, t as BUILD } from "../index-BHciXst1.js";
2
2
  export { BUILD, Env, NAMESPACE };
@@ -1,5 +1,5 @@
1
1
  import { B as HOST_FLAGS, C as CMP_FLAGS, G as NODE_TYPES, Z as SVG_NS, o as isComplexType, s as isDef, x as queryNonceMetaTagContent } from "./helpers-Cpp3qc3u.mjs";
2
- import { effect } from "@preact/signals-core";
2
+ import * as SignalsCore from "@preact/signals-core";
3
3
  //#region src/app-data/index.ts
4
4
  /**
5
5
  * A collection of default build flags for a Stencil project.
@@ -104,41 +104,6 @@ const BUILD = {
104
104
  asyncQueue: false
105
105
  };
106
106
  //#endregion
107
- //#region src/client/client-build.ts
108
- const Build = {
109
- isDev: BUILD.isDev,
110
- isBrowser: true,
111
- isServer: false,
112
- isTesting: BUILD.isTesting
113
- };
114
- //#endregion
115
- //#region src/client/client-host-ref.ts
116
- /**
117
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
118
- *
119
- * @param ref the runtime ref of interest
120
- * @returns the Host reference (if found) or undefined
121
- */
122
- const getHostRef = (ref) => {
123
- if (ref.__s_ghr) return ref.__s_ghr();
124
- };
125
- const isMemberInElement = (elm, memberName) => memberName in elm;
126
- //#endregion
127
- //#region src/client/client-log.ts
128
- let customError;
129
- const consoleError = (e, el) => (customError || console.error)(e, el);
130
- const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
131
- const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
132
- const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
133
- const setErrorHandler = (handler) => customError = handler;
134
- //#endregion
135
- //#region src/client/client-load-module.ts
136
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
137
- //#endregion
138
- //#region src/client/client-style.ts
139
- const styles = /*@__PURE__*/ new Map();
140
- const modeResolutionChain = [];
141
- //#endregion
142
107
  //#region src/runtime/runtime-constants.ts
143
108
  /**
144
109
  * Bit flags for recording various properties of VDom nodes
@@ -191,6 +156,62 @@ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
191
156
  */
192
157
  const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
193
158
  const XLINK_NS = "http://www.w3.org/1999/xlink";
159
+ /**
160
+ * `Build` values fixed per platform. Shared by each runtime's `Build` export and the compiler's
161
+ * `Build.*` folding (`compiler/bundle/build-flags-plugin.ts`), so the two can't disagree.
162
+ */
163
+ const CLIENT_BUILD_FLAGS = {
164
+ isBrowser: true,
165
+ isServer: false
166
+ };
167
+ const SERVER_BUILD_FLAGS = {
168
+ isBrowser: false,
169
+ isServer: true,
170
+ isDev: false,
171
+ isTesting: false
172
+ };
173
+ //#endregion
174
+ //#region src/client/client-build.ts
175
+ /**
176
+ * `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
177
+ * sets `BUILD.*` overrides from each component module, which runs after this module is evaluated.
178
+ */
179
+ const Build = {
180
+ ...CLIENT_BUILD_FLAGS,
181
+ get isDev() {
182
+ return BUILD.isDev;
183
+ },
184
+ get isTesting() {
185
+ return BUILD.isTesting;
186
+ }
187
+ };
188
+ //#endregion
189
+ //#region src/client/client-host-ref.ts
190
+ /**
191
+ * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
192
+ *
193
+ * @param ref the runtime ref of interest
194
+ * @returns the Host reference (if found) or undefined
195
+ */
196
+ const getHostRef = (ref) => {
197
+ if (ref.__s_ghr) return ref.__s_ghr();
198
+ };
199
+ const isMemberInElement = (elm, memberName) => memberName in elm;
200
+ //#endregion
201
+ //#region src/client/client-log.ts
202
+ let customError;
203
+ const consoleError = (e, el) => (customError || console.error)(e, el);
204
+ const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
205
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
206
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
207
+ const setErrorHandler = (handler) => customError = handler;
208
+ //#endregion
209
+ //#region src/client/client-load-module.ts
210
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
211
+ //#endregion
212
+ //#region src/client/client-style.ts
213
+ const styles = /*@__PURE__*/ new Map();
214
+ const modeResolver = [];
194
215
  //#endregion
195
216
  //#region src/client/client-window.ts
196
217
  const win = typeof window !== "undefined" ? window : {};
@@ -223,7 +244,7 @@ let queuePending = false;
223
244
  const queueDomReads = [];
224
245
  const queueDomWrites = [];
225
246
  const queueDomWritesLow = [];
226
- const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
247
+ const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
227
248
  const queueTask = (queue, write) => (cb) => {
228
249
  queue.push(cb);
229
250
  if (!queuePending) {
@@ -722,6 +743,10 @@ const attachStyles = (hostRef) => {
722
743
  */
723
744
  const getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & CMP_FLAGS.hasMode ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
724
745
  //#endregion
746
+ //#region src/runtime/signals-core.ts
747
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
748
+ const effect = (fn, options) => getCore().effect(fn, options);
749
+ //#endregion
725
750
  //#region src/runtime/event-emitter.ts
726
751
  /**
727
752
  * Helper function to create & dispatch a custom Event on a provided target
@@ -736,6 +761,11 @@ const emitEvent = (elm, name, opts) => {
736
761
  return ev;
737
762
  };
738
763
  const getRegistry = () => customElements;
764
+ /**
765
+ * @param elm a defined component host
766
+ * @returns the registry the host's class was defined in, else the active registry
767
+ */
768
+ const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
739
769
  //#endregion
740
770
  //#region src/runtime/vdom/set-accessor.ts
741
771
  /**
@@ -859,10 +889,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
859
889
  const isComplex = isComplexType(newValue);
860
890
  if (!BUILD.lazyLoad) {
861
891
  const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
862
- if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && typeof customElements !== "undefined" && !customElements.get(elm.tagName.toLowerCase())) {
892
+ if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
863
893
  if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
864
894
  elm["s-pp"].set(memberName, newValue);
865
- return;
895
+ if (isComplex || /[A-Z]/.test(memberName)) return;
866
896
  }
867
897
  }
868
898
  if ((isProp || isComplex && newValue !== null) && !isSvg) try {
@@ -980,6 +1010,7 @@ function sortedAttrNames(attrNames) {
980
1010
  let scopeId;
981
1011
  let contentRef;
982
1012
  let hostTagName;
1013
+ let hostRegistry;
983
1014
  let useNativeShadowDom = false;
984
1015
  let checkSlotFallbackVisibility = false;
985
1016
  let checkSlotRelocate = false;
@@ -996,16 +1027,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
996
1027
  const disposeSignalVNode = (vnode) => {
997
1028
  const elm = vnode.$elm$;
998
1029
  if (elm) {
999
- const dispose = signalNodeDisposers.get(elm);
1000
- if (dispose) {
1001
- dispose();
1002
- signalNodeDisposers.delete(elm);
1003
- }
1030
+ disposeTextSignal(elm);
1004
1031
  disposeAllSignalAttrs(elm);
1005
1032
  }
1006
1033
  vnode.$children$?.forEach(disposeSignalVNode);
1007
1034
  };
1008
1035
  /**
1036
+ * Tear down a text node's signal subscription, if it has one.
1037
+ * @param textNode the text node to unsubscribe
1038
+ */
1039
+ const disposeTextSignal = (textNode) => {
1040
+ const dispose = signalNodeDisposers.get(textNode);
1041
+ if (dispose) {
1042
+ dispose();
1043
+ signalNodeDisposers.delete(textNode);
1044
+ }
1045
+ };
1046
+ /**
1047
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
1048
+ * @param textNode the text node to keep in sync
1049
+ * @param textSig the signal to subscribe to
1050
+ */
1051
+ const wireTextSignal = (textNode, textSig) => {
1052
+ signalNodeDisposers.set(textNode, effect(() => {
1053
+ textNode.data = String(textSig.value);
1054
+ }));
1055
+ };
1056
+ /**
1009
1057
  * Create a DOM Node corresponding to one of the children of a given VNode.
1010
1058
  *
1011
1059
  * @param oldParentVNode the parent VNode from the previous render
@@ -1027,13 +1075,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1027
1075
  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`);
1028
1076
  if (BUILD.vdomText && newVNode.$text$ != null) {
1029
1077
  elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
1030
- if (BUILD.vdomSignals && newVNode.$signal$) {
1031
- const textSig = newVNode.$signal$;
1032
- const textNode = elm;
1033
- signalNodeDisposers.set(textNode, effect(() => {
1034
- textNode.data = String(textSig.value);
1035
- }));
1036
- }
1078
+ if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
1037
1079
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1038
1080
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1039
1081
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -1042,8 +1084,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1042
1084
  if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
1043
1085
  if (!win.document) throw new Error("No DOM environment available for rendering.");
1044
1086
  const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
1045
- const _reg = getRegistry();
1046
- const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
1087
+ const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
1047
1088
  elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
1048
1089
  if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
1049
1090
  if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
@@ -1301,7 +1342,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
1301
1342
  }
1302
1343
  if (BUILD.vdomKey && idxInOld >= 0) {
1303
1344
  elmToMove = oldCh[idxInOld];
1304
- if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
1345
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1305
1346
  else {
1306
1347
  patch(elmToMove, newStartVnode, isInitialRender);
1307
1348
  oldCh[idxInOld] = void 0;
@@ -1394,7 +1435,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
1394
1435
  else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
1395
1436
  if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
1396
1437
  } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
1397
- else if (BUILD.vdomText && oldVNode.$text$ !== text) elm.data = text;
1438
+ else if (BUILD.vdomText) {
1439
+ if (BUILD.vdomSignals && newVNode.$signal$) {
1440
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
1441
+ disposeTextSignal(elm);
1442
+ wireTextSignal(elm, newVNode.$signal$);
1443
+ }
1444
+ } else {
1445
+ if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
1446
+ if (oldVNode.$text$ !== text) elm.data = text;
1447
+ }
1448
+ }
1398
1449
  };
1399
1450
  /**
1400
1451
  * Component-global information about nodes which are either currently being
@@ -1582,6 +1633,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1582
1633
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1583
1634
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1584
1635
  hostTagName = hostElm.tagName;
1636
+ hostRegistry = getHostRegistry(hostElm);
1585
1637
  if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
1586
1638
  Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1587
1639
 
@@ -2097,9 +2149,7 @@ const h = (nodeName, vnodeData, ...children) => {
2097
2149
  if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
2098
2150
  }
2099
2151
  }
2100
- if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component. Make sure:
2101
- - You are NOT using hostData() and <Host> in the same component.
2102
- - <Host> is used once, and it's the single root component of the render() function.`);
2152
+ if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
2103
2153
  if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
2104
2154
  const vnode = newVNode(nodeName, null);
2105
2155
  vnode.$attrs$ = vnodeData;
@@ -2152,17 +2202,23 @@ const vdomFnUtils = {
2152
2202
  * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
2153
2203
  * friendlier public interface (hence, 'convertToPublic').
2154
2204
  *
2155
- * @param node the virtual DOM node to convert
2205
+ * Functional components receive primitive children unwrapped, so those
2206
+ * become text-only child nodes.
2207
+ *
2208
+ * @param node the virtual DOM node (or primitive child) to convert
2156
2209
  * @returns a converted child node
2157
2210
  */
2158
- const convertToPublic = (node) => ({
2211
+ const convertToPublic = (node) => typeof node !== "object" ? {
2212
+ vtag: null,
2213
+ vtext: String(node)
2214
+ } : {
2159
2215
  vattrs: node.$attrs$,
2160
2216
  vchildren: node.$children$,
2161
2217
  vkey: node.$key$,
2162
2218
  vname: node.$name$,
2163
2219
  vtag: node.$tag$,
2164
2220
  vtext: node.$text$
2165
- });
2221
+ };
2166
2222
  /**
2167
2223
  * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
2168
2224
  * order to use the resulting object in the virtual DOM. The initial object was
@@ -2179,11 +2235,11 @@ const convertToPrivate = (node) => {
2179
2235
  if (node.vname) vnodeData.name = node.vname;
2180
2236
  return h(node.vtag, vnodeData, ...node.vchildren || []);
2181
2237
  }
2182
- const vnode = newVNode(node.vtag, node.vtext);
2183
- vnode.$attrs$ = node.vattrs;
2184
- vnode.$children$ = node.vchildren;
2185
- vnode.$key$ = node.vkey;
2186
- vnode.$name$ = node.vname;
2238
+ const vnode = newVNode(node.vtag ?? null, node.vtext);
2239
+ vnode.$attrs$ = node.vattrs ?? null;
2240
+ vnode.$children$ = node.vchildren ?? null;
2241
+ vnode.$key$ = node.vkey ?? null;
2242
+ vnode.$name$ = node.vname ?? null;
2187
2243
  return vnode;
2188
2244
  };
2189
2245
  /**
@@ -2203,7 +2259,10 @@ const validateInputProperties = (inputElm) => {
2203
2259
  };
2204
2260
  //#endregion
2205
2261
  //#region src/runtime/mode.ts
2206
- const setMode = (handler) => modeResolutionChain.push(handler);
2262
+ const setMode = (handler) => {
2263
+ modeResolver.length = 0;
2264
+ modeResolver.push(handler);
2265
+ };
2207
2266
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
2208
2267
  //#endregion
2209
2268
  //#region src/runtime/mixin.ts
@@ -2365,4 +2424,4 @@ function hasKeys(obj) {
2365
2424
  return false;
2366
2425
  }
2367
2426
  //#endregion
2368
- export { setErrorHandler as C, HYDRATED_CSS as S, getAssetPath as _, transformTag as a, writeTask as b, Mixin as c, Host as d, h as f, getShadowRoot as g, getElement as h, setTagTransformer as i, getMode as l, getRenderingRef as m, jsxDEV as n, render as o, forceUpdate as p, jsxs as r, ReactiveControllerHost as s, jsx as t, setMode as u, setAssetPath as v, Build as w, setPlatformHelpers as x, readTask as y };
2427
+ export { Build as C, SERVER_BUILD_FLAGS as E, setErrorHandler as S, HYDRATED_CSS as T, getAssetPath as _, transformTag as a, writeTask as b, Mixin as c, Host as d, h as f, getShadowRoot as g, getElement as h, setTagTransformer as i, getMode as l, getRenderingRef as m, jsxDEV as n, render as o, forceUpdate as p, jsxs as r, ReactiveControllerHost as s, jsx as t, setMode as u, setAssetPath as v, CLIENT_BUILD_FLAGS as w, setPlatformHelpers as x, readTask as y };