@stencil/core 5.0.0-beta.2 → 5.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-BRu0GtRn.mjs → client-CVXS3JZ-.mjs} +105 -60
  3. package/dist/compiler/browser.d.ts +110 -79
  4. package/dist/compiler/browser.js +542 -241
  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-C8yf59oh.mjs → compiler-CUsOl_Kw.mjs} +4428 -2709
  9. package/dist/declarations/stencil-public-compiler.d.ts +144 -120
  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-BopBfjPu.d.mts → index-B9-Byy8z.d.mts} +142 -118
  13. package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
  14. package/dist/{index-DmHmu3y0.d.mts → index-Dz1G9pWZ.d.mts} +2 -2
  15. package/dist/index.d.mts +3 -0
  16. package/dist/index.mjs +1 -1
  17. package/dist/jsx-runtime.mjs +1 -1
  18. package/dist/{node-75gQKkFz.mjs → node-Bz2SOK7_.mjs} +6 -35
  19. package/dist/runtime/client/lazy.js +228 -180
  20. package/dist/runtime/client/runtime.d.ts +67 -66
  21. package/dist/runtime/client/runtime.js +228 -180
  22. package/dist/runtime/index.d.ts +4 -5
  23. package/dist/runtime/index.js +226 -178
  24. package/dist/runtime/server/index.d.mts +11 -11
  25. package/dist/runtime/server/index.mjs +287 -220
  26. package/dist/runtime/server/runner.d.mts +4 -4
  27. package/dist/runtime/server/runner.mjs +82 -54
  28. package/dist/signals/index.d.ts +11 -2
  29. package/dist/signals/index.js +11 -1
  30. package/dist/sys/node/index.d.mts +1 -1
  31. package/dist/sys/node/index.mjs +1 -1
  32. package/dist/sys/node/worker.mjs +2 -2
  33. package/dist/testing/index.d.mts +129 -112
  34. package/dist/testing/index.mjs +244 -193
  35. 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,54 @@ 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
+ const Build = {
176
+ ...CLIENT_BUILD_FLAGS,
177
+ isDev: BUILD.isDev,
178
+ isTesting: BUILD.isTesting
179
+ };
180
+ //#endregion
181
+ //#region src/client/client-host-ref.ts
182
+ /**
183
+ * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
184
+ *
185
+ * @param ref the runtime ref of interest
186
+ * @returns the Host reference (if found) or undefined
187
+ */
188
+ const getHostRef = (ref) => {
189
+ if (ref.__s_ghr) return ref.__s_ghr();
190
+ };
191
+ const isMemberInElement = (elm, memberName) => memberName in elm;
192
+ //#endregion
193
+ //#region src/client/client-log.ts
194
+ let customError;
195
+ const consoleError = (e, el) => (customError || console.error)(e, el);
196
+ const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
197
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
198
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
199
+ const setErrorHandler = (handler) => customError = handler;
200
+ //#endregion
201
+ //#region src/client/client-load-module.ts
202
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
203
+ //#endregion
204
+ //#region src/client/client-style.ts
205
+ const styles = /*@__PURE__*/ new Map();
206
+ const modeResolver = [];
194
207
  //#endregion
195
208
  //#region src/client/client-window.ts
196
209
  const win = typeof window !== "undefined" ? window : {};
@@ -223,7 +236,7 @@ let queuePending = false;
223
236
  const queueDomReads = [];
224
237
  const queueDomWrites = [];
225
238
  const queueDomWritesLow = [];
226
- const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
239
+ const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
227
240
  const queueTask = (queue, write) => (cb) => {
228
241
  queue.push(cb);
229
242
  if (!queuePending) {
@@ -722,6 +735,10 @@ const attachStyles = (hostRef) => {
722
735
  */
723
736
  const getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & CMP_FLAGS.hasMode ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
724
737
  //#endregion
738
+ //#region src/runtime/signals-core.ts
739
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
740
+ const effect = (fn, options) => getCore().effect(fn, options);
741
+ //#endregion
725
742
  //#region src/runtime/event-emitter.ts
726
743
  /**
727
744
  * Helper function to create & dispatch a custom Event on a provided target
@@ -736,6 +753,11 @@ const emitEvent = (elm, name, opts) => {
736
753
  return ev;
737
754
  };
738
755
  const getRegistry = () => customElements;
756
+ /**
757
+ * @param elm a defined component host
758
+ * @returns the registry the host's class was defined in, else the active registry
759
+ */
760
+ const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
739
761
  //#endregion
740
762
  //#region src/runtime/vdom/set-accessor.ts
741
763
  /**
@@ -859,10 +881,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
859
881
  const isComplex = isComplexType(newValue);
860
882
  if (!BUILD.lazyLoad) {
861
883
  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())) {
884
+ if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
863
885
  if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
864
886
  elm["s-pp"].set(memberName, newValue);
865
- return;
887
+ if (isComplex || /[A-Z]/.test(memberName)) return;
866
888
  }
867
889
  }
868
890
  if ((isProp || isComplex && newValue !== null) && !isSvg) try {
@@ -980,6 +1002,7 @@ function sortedAttrNames(attrNames) {
980
1002
  let scopeId;
981
1003
  let contentRef;
982
1004
  let hostTagName;
1005
+ let hostRegistry;
983
1006
  let useNativeShadowDom = false;
984
1007
  let checkSlotFallbackVisibility = false;
985
1008
  let checkSlotRelocate = false;
@@ -996,16 +1019,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
996
1019
  const disposeSignalVNode = (vnode) => {
997
1020
  const elm = vnode.$elm$;
998
1021
  if (elm) {
999
- const dispose = signalNodeDisposers.get(elm);
1000
- if (dispose) {
1001
- dispose();
1002
- signalNodeDisposers.delete(elm);
1003
- }
1022
+ disposeTextSignal(elm);
1004
1023
  disposeAllSignalAttrs(elm);
1005
1024
  }
1006
1025
  vnode.$children$?.forEach(disposeSignalVNode);
1007
1026
  };
1008
1027
  /**
1028
+ * Tear down a text node's signal subscription, if it has one.
1029
+ * @param textNode the text node to unsubscribe
1030
+ */
1031
+ const disposeTextSignal = (textNode) => {
1032
+ const dispose = signalNodeDisposers.get(textNode);
1033
+ if (dispose) {
1034
+ dispose();
1035
+ signalNodeDisposers.delete(textNode);
1036
+ }
1037
+ };
1038
+ /**
1039
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
1040
+ * @param textNode the text node to keep in sync
1041
+ * @param textSig the signal to subscribe to
1042
+ */
1043
+ const wireTextSignal = (textNode, textSig) => {
1044
+ signalNodeDisposers.set(textNode, effect(() => {
1045
+ textNode.data = String(textSig.value);
1046
+ }));
1047
+ };
1048
+ /**
1009
1049
  * Create a DOM Node corresponding to one of the children of a given VNode.
1010
1050
  *
1011
1051
  * @param oldParentVNode the parent VNode from the previous render
@@ -1027,13 +1067,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1027
1067
  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
1068
  if (BUILD.vdomText && newVNode.$text$ != null) {
1029
1069
  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
- }
1070
+ if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
1037
1071
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1038
1072
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1039
1073
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -1042,8 +1076,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1042
1076
  if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
1043
1077
  if (!win.document) throw new Error("No DOM environment available for rendering.");
1044
1078
  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;
1079
+ const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
1047
1080
  elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
1048
1081
  if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
1049
1082
  if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
@@ -1301,7 +1334,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
1301
1334
  }
1302
1335
  if (BUILD.vdomKey && idxInOld >= 0) {
1303
1336
  elmToMove = oldCh[idxInOld];
1304
- if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
1337
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1305
1338
  else {
1306
1339
  patch(elmToMove, newStartVnode, isInitialRender);
1307
1340
  oldCh[idxInOld] = void 0;
@@ -1394,7 +1427,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
1394
1427
  else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
1395
1428
  if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
1396
1429
  } 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;
1430
+ else if (BUILD.vdomText) {
1431
+ if (BUILD.vdomSignals && newVNode.$signal$) {
1432
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
1433
+ disposeTextSignal(elm);
1434
+ wireTextSignal(elm, newVNode.$signal$);
1435
+ }
1436
+ } else {
1437
+ if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
1438
+ if (oldVNode.$text$ !== text) elm.data = text;
1439
+ }
1440
+ }
1398
1441
  };
1399
1442
  /**
1400
1443
  * Component-global information about nodes which are either currently being
@@ -1582,6 +1625,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1582
1625
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1583
1626
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1584
1627
  hostTagName = hostElm.tagName;
1628
+ hostRegistry = getHostRegistry(hostElm);
1585
1629
  if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
1586
1630
  Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1587
1631
 
@@ -2097,9 +2141,7 @@ const h = (nodeName, vnodeData, ...children) => {
2097
2141
  if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
2098
2142
  }
2099
2143
  }
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.`);
2144
+ if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
2103
2145
  if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
2104
2146
  const vnode = newVNode(nodeName, null);
2105
2147
  vnode.$attrs$ = vnodeData;
@@ -2203,7 +2245,10 @@ const validateInputProperties = (inputElm) => {
2203
2245
  };
2204
2246
  //#endregion
2205
2247
  //#region src/runtime/mode.ts
2206
- const setMode = (handler) => modeResolutionChain.push(handler);
2248
+ const setMode = (handler) => {
2249
+ modeResolver.length = 0;
2250
+ modeResolver.push(handler);
2251
+ };
2207
2252
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
2208
2253
  //#endregion
2209
2254
  //#region src/runtime/mixin.ts
@@ -2365,4 +2410,4 @@ function hasKeys(obj) {
2365
2410
  return false;
2366
2411
  }
2367
2412
  //#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 };
2413
+ 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 };
@@ -1,11 +1,77 @@
1
1
  import ts from "typescript";
2
2
  import "rolldown";
3
3
  //#region src/declarations/stencil-public-docs.d.ts
4
+ /**
5
+ * A descriptor for a single JSDoc tag found in a block comment
6
+ */
7
+ interface JsonDocsTag {
8
+ /**
9
+ * The tag name (immediately following the '@')
10
+ */
11
+ name: string;
12
+ /**
13
+ * The description that immediately follows the tag name
14
+ */
15
+ text?: string;
16
+ }
4
17
  interface JsonDocMethodParameter {
5
18
  name: string;
6
19
  type: string;
7
20
  docs: string;
8
21
  }
22
+ /**
23
+ * A descriptor for a Custom State defined via @AttachInternals({ states: {...} })
24
+ *
25
+ * Custom states are exposed via the ElementInternals.states CustomStateSet
26
+ * and can be targeted with the CSS `:state()` pseudo-class.
27
+ *
28
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet
29
+ */
30
+ interface JsonDocsCustomState {
31
+ /**
32
+ * The name of the custom state (without dashes)
33
+ */
34
+ name: string;
35
+ /**
36
+ * The initial/default value of the state
37
+ */
38
+ initialValue: boolean;
39
+ /**
40
+ * A textual description of the custom state
41
+ */
42
+ docs: string;
43
+ }
44
+ /**
45
+ * Represents a parsed block comment in a CSS, Sass, etc. file for a custom property.
46
+ */
47
+ interface StyleDoc {
48
+ /**
49
+ * The name of the CSS property
50
+ */
51
+ name: string;
52
+ /**
53
+ * The user-defined description of the CSS property
54
+ */
55
+ docs: string;
56
+ /**
57
+ * The JSDoc-style annotation (e.g. `@prop`) that was used in the block comment to detect the comment.
58
+ * Used to inform Stencil where the start of a new property's description starts (and where the previous description
59
+ * ends).
60
+ */
61
+ annotation: 'prop';
62
+ /**
63
+ * The Stencil style-mode that is associated with this property.
64
+ */
65
+ mode: string | undefined;
66
+ /**
67
+ * The CSS `syntax` descriptor, if this property was registered via a native `@property` at-rule.
68
+ */
69
+ syntax?: string;
70
+ /**
71
+ * The `initial-value` descriptor, if this property was registered via a native `@property` at-rule.
72
+ */
73
+ default?: string;
74
+ }
9
75
  //#endregion
10
76
  //#region src/declarations/stencil-public-runtime.d.ts
11
77
  type ListenTargetOptions = 'body' | 'document' | 'window';
@@ -25,7 +91,7 @@ interface CompilerSystem {
25
91
  name: 'node' | 'in-memory';
26
92
  version: string;
27
93
  events?: BuildEvents;
28
- details?: SystemDetails;
94
+ details: SystemDetails;
29
95
  /**
30
96
  * Add a callback which will be ran when destroy() is called.
31
97
  */
@@ -38,14 +104,15 @@ interface CompilerSystem {
38
104
  * SYNC! Always returns a boolean, does not throw.
39
105
  */
40
106
  accessSync(p: string): boolean;
41
- applyGlobalPatch?(fromDir: string): Promise<void>;
42
107
  applyPrerenderGlobalPatch?(opts: {
43
108
  devServerHostUrl: string;
44
109
  window: any;
45
110
  }): void;
46
- cacheStorage?: CacheStorage;
47
- checkVersion?: (logger: Logger, currentVersion: string) => Promise<() => void>;
48
- copy?(copyTasks: Required<CopyTask>[], srcDir: string): Promise<CopyResults>;
111
+ /**
112
+ * Check npm for a newer Stencil version. Resolves a function that logs the result.
113
+ */
114
+ checkVersion(logger: Logger, currentVersion: string): Promise<() => void>;
115
+ copy(copyTasks: Required<CopyTask>[], srcDir: string): Promise<CopyResults>;
49
116
  /**
50
117
  * Always returns a boolean if the files were copied or not. Does not throw.
51
118
  */
@@ -70,7 +137,7 @@ interface CompilerSystem {
70
137
  /**
71
138
  * Each platform has a different way to dynamically import modules.
72
139
  */
73
- dynamicImport?(p: string): Promise<any>;
140
+ dynamicImport(p: string): Promise<any>;
74
141
  /**
75
142
  * Creates the worker controller for the current system.
76
143
  *
@@ -84,20 +151,14 @@ interface CompilerSystem {
84
151
  * process.exit()
85
152
  */
86
153
  exit(exitCode: number): Promise<void>;
87
- /**
88
- * Optionally provide a fetch() function rather than using the built-in fetch().
89
- * First arg is a url string or Request object (RequestInfo).
90
- * Second arg is the RequestInit. Returns the Response object
91
- */
92
- fetch?(input: string | any, init?: any): Promise<any>;
93
154
  /**
94
155
  * Generates a sha1 digest encoded as HEX
95
156
  */
96
- generateContentHash?(content: string | any, length?: number): Promise<string>;
157
+ generateContentHash(content: string | any, length?: number): Promise<string>;
97
158
  /**
98
159
  * Generates a sha1 digest encoded as HEX from a file path
99
160
  */
100
- generateFileHash?(filePath: string | any, length?: number): Promise<string>;
161
+ generateFileHash(filePath: string | any, length?: number): Promise<string>;
101
162
  /**
102
163
  * Get the current directory.
103
164
  */
@@ -106,7 +167,6 @@ interface CompilerSystem {
106
167
  * The compiler's executing path.
107
168
  */
108
169
  getCompilerExecutingPath(): string;
109
- getEnvironmentVar?(key: string): string;
110
170
  /**
111
171
  * Gets the absolute file path when for a dependency module.
112
172
  */
@@ -145,11 +205,7 @@ interface CompilerSystem {
145
205
  * Normalize file system path.
146
206
  */
147
207
  normalizePath(p: string): string;
148
- onProcessInterrupt?(cb: () => void): void;
149
- parseYarnLockFile?: (content: string) => {
150
- type: 'success' | 'merge' | 'conflict';
151
- object: any;
152
- };
208
+ onProcessInterrupt(cb: () => void): void;
153
209
  platformPath: PlatformPath;
154
210
  /**
155
211
  * All return paths are full normalized paths, not just the basenames. Always returns an array, does not throw.
@@ -185,6 +241,9 @@ interface CompilerSystem {
185
241
  * Rename old path to new path. Does not throw.
186
242
  */
187
243
  rename(oldPath: string, newPath: string): Promise<CompilerSystemRenameResults>;
244
+ /**
245
+ * Assigned by the compiler. Used by plugins (e.g. `@stencil/sass`) to resolve `~` imports.
246
+ */
188
247
  resolveModuleId?(opts: ResolveModuleIdOptions): Promise<ResolveModuleIdResults>;
189
248
  resolvePath(p: string): string;
190
249
  /**
@@ -367,6 +426,7 @@ interface CompilerBuildResults {
367
426
  buildId: number;
368
427
  componentGraph?: BuildResultsComponentGraph;
369
428
  components: ComponentCompilerMeta[];
429
+ cssOnlyComponents: ComponentCompilerMeta[];
370
430
  diagnostics: Diagnostic[];
371
431
  dirsAdded: string[];
372
432
  dirsDeleted: string[];
@@ -383,6 +443,15 @@ interface CompilerBuildResults {
383
443
  namespace: string;
384
444
  fsNamespace: string;
385
445
  outputs: BuildOutput[];
446
+ /**
447
+ * Absolute paths to every global stylesheet, in cascade order: each `global-style` output
448
+ * target's compiled CSS in the order those targets are declared in `config.outputTargets` - or,
449
+ * with none configured, the generated `{fsNamespace}.css` holding Stencil's auto-placed CSS (when
450
+ * emitted). Unlike `outputs`, which groups files by type and sorts them alphabetically, this
451
+ * preserves author-intended order for consumers like the dev-server's auto-generated component
452
+ * preview.
453
+ */
454
+ globalStyleFiles: string[];
386
455
  rootDir: string;
387
456
  srcDir: string;
388
457
  timestamp: string;
@@ -398,6 +467,7 @@ interface HotModuleReplacement {
398
467
  componentsUpdated?: string[];
399
468
  excludeHmr?: string[];
400
469
  externalStylesUpdated?: string[];
470
+ globalStylesUpdated?: HmrGlobalStyleUpdate[];
401
471
  imagesUpdated?: string[];
402
472
  indexHtmlUpdated?: boolean;
403
473
  inlineStylesUpdated?: HmrStyleUpdate[];
@@ -412,6 +482,15 @@ interface HmrStyleUpdate {
412
482
  styleTag: string;
413
483
  styleText: string;
414
484
  }
485
+ /**
486
+ * A live-reload update for a `global-style` output target's CSS. Applied on
487
+ * the client by matching `fileName` against the `<link>` that loads it and
488
+ * inserting/updating an adjacent `<style>` override
489
+ */
490
+ interface HmrGlobalStyleUpdate {
491
+ fileName: string;
492
+ styleText: string;
493
+ }
415
494
  type BuildOnEventRemove = () => boolean;
416
495
  interface BuildEvents extends BuildOnEvents, BuildEmitEvents {
417
496
  unsubscribeAll(): void;
@@ -689,10 +768,6 @@ interface Diagnostic {
689
768
  relFilePath?: string | undefined;
690
769
  type: string;
691
770
  }
692
- interface CacheStorage {
693
- get(key: string): Promise<any>;
694
- set(key: string, value: any): Promise<void>;
695
- }
696
771
  interface LazyRequire {
697
772
  ensure(fromDir: string, moduleIds: string[]): Promise<Diagnostic[]>;
698
773
  require(fromDir: string, moduleId: string): any;
@@ -839,6 +914,12 @@ interface TranspileOptions {
839
914
  * that the specified flags take effect for this component at runtime.
840
915
  */
841
916
  buildOverrides?: BuildOverrides;
917
+ /**
918
+ * When `true`, a `.css`/`.scss` transpile also collects CSS custom-property docs
919
+ * onto {@link TranspileResults.styleDocs}. Off by default, since it costs an extra parse
920
+ * of the style text.
921
+ */
922
+ docs?: boolean;
842
923
  }
843
924
  /**
844
925
  * Keys of {@link BuildConditionals} that can be meaningfully overridden at
@@ -864,6 +945,7 @@ interface TranspileResults {
864
945
  inputFilePath: string;
865
946
  map: any;
866
947
  outputFilePath: string;
948
+ styleDocs?: StyleDoc[];
867
949
  }
868
950
  //#endregion
869
951
  //#region src/declarations/stencil-private.d.ts
@@ -1070,7 +1152,7 @@ interface ComponentCompilerMeta extends ComponentCompilerFeatures {
1070
1152
  * Custom states to initialize on the ElementInternals.states CustomStateSet.
1071
1153
  * These are defined via @AttachInternals({ states: {...} }).
1072
1154
  */
1073
- attachInternalsCustomStates: ComponentCompilerCustomState[];
1155
+ attachInternalsCustomStates: JsonDocsCustomState[];
1074
1156
  componentClassName: string;
1075
1157
  /**
1076
1158
  * A list of web component tag names that are either:
@@ -1140,7 +1222,7 @@ interface ComponentCompilerMeta extends ComponentCompilerFeatures {
1140
1222
  sourceFilePath: string;
1141
1223
  sourceMapPath: string;
1142
1224
  states: ComponentCompilerState[];
1143
- styleDocs: CompilerStyleDoc[];
1225
+ styleDocs: StyleDoc[];
1144
1226
  styles: StyleCompiler[];
1145
1227
  globalStyles: ComponentGlobalStyle[];
1146
1228
  tagName: string;
@@ -1324,20 +1406,6 @@ interface ComponentCompilerState {
1324
1406
  * Custom states are exposed via the ElementInternals.states CustomStateSet
1325
1407
  * and can be targeted with the CSS :state() pseudo-class.
1326
1408
  */
1327
- interface ComponentCompilerCustomState {
1328
- /**
1329
- * The name of the custom state (without dashes)
1330
- */
1331
- name: string;
1332
- /**
1333
- * The initial value of the state
1334
- */
1335
- initialValue: boolean;
1336
- /**
1337
- * Optional JSDoc description for the state
1338
- */
1339
- docs: string;
1340
- }
1341
1409
  /**
1342
1410
  * Representation of JSDoc that is pulled off a node in the AST
1343
1411
  */
@@ -1349,44 +1417,7 @@ interface CompilerJsDoc {
1349
1417
  /**
1350
1418
  * Tags included in the JSDoc
1351
1419
  */
1352
- tags: CompilerJsDocTagInfo[];
1353
- }
1354
- /**
1355
- * Representation of a tag that exists in a JSDoc
1356
- */
1357
- interface CompilerJsDocTagInfo {
1358
- /**
1359
- * The name of the tag - e.g. `@deprecated`
1360
- */
1361
- name: string;
1362
- /**
1363
- * Additional text that is associated with the tag - e.g. `@deprecated use v2 of this API`
1364
- */
1365
- text?: string;
1366
- }
1367
- /**
1368
- * The (internal) representation of a CSS block comment in a CSS, Sass, etc. file. This data structure is used during
1369
- * the initial compilation phases of Stencil, as a piece of {@link ComponentCompilerMeta}.
1370
- */
1371
- interface CompilerStyleDoc {
1372
- /**
1373
- * The name of the CSS property
1374
- */
1375
- name: string;
1376
- /**
1377
- * The user-defined description of the CSS property
1378
- */
1379
- docs: string;
1380
- /**
1381
- * The JSDoc-style annotation (e.g. `@prop`) that was used in the block comment to detect the comment.
1382
- * Used to inform Stencil where the start of a new property's description starts (and where the previous description
1383
- * ends).
1384
- */
1385
- annotation: 'prop';
1386
- /**
1387
- * The Stencil style-mode that is associated with this property.
1388
- */
1389
- mode: string;
1420
+ tags: JsonDocsTag[];
1390
1421
  }
1391
1422
  interface CompilerAssetDir {
1392
1423
  absolutePath?: string;
@@ -1526,7 +1557,7 @@ declare const transpileSync: (code: string, opts?: TranspileOptions) => Transpil
1526
1557
  * @param cmp the metadata for the component that a type definition string is generated for
1527
1558
  * @param typeImportData locally/imported/globally used type names, which may be used to prevent naming collisions
1528
1559
  * @param areTypesInternal `true` if types being generated are for a project's internal purposes, `false` otherwise
1529
- * @param signalBacking `true` if the component is using signal backing for its props; includes the signals map on the element interface
1560
+ * @param signalBacking `true` if the component is using signal backing for its props; includes the signals map on the element interface and unions JSX prop types with `ReadonlySignal<T>`
1530
1561
  * @returns the generated types string alongside additional metadata
1531
1562
  */
1532
1563
  declare const generateComponentTypes: (cmp: ComponentCompilerMeta, typeImportData: TypesImportData, areTypesInternal: boolean, signalBacking?: boolean) => TypesModule;