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

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-DIvBaMnB.mjs} +182 -70
  3. package/dist/compiler/browser.d.ts +114 -81
  4. package/dist/compiler/browser.js +743 -339
  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-BI12oAIV.mjs} +4840 -2899
  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 +62 -58
  12. package/dist/{index-DmHmu3y0.d.mts → index-BGUOG9Wc.d.mts} +6 -2
  13. package/dist/{index-BopBfjPu.d.mts → index-BogZpjP2.d.mts} +150 -127
  14. package/dist/{index-BXAcVN2j.d.ts → index-CicD4Pgn.d.ts} +59 -55
  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-D-21Ykxi.mjs} +41 -47
  20. package/dist/runtime/client/lazy.js +321 -200
  21. package/dist/runtime/client/runtime.d.ts +73 -66
  22. package/dist/runtime/client/runtime.js +321 -200
  23. package/dist/runtime/index.d.ts +4 -5
  24. package/dist/runtime/index.js +319 -198
  25. package/dist/runtime/server/index.d.mts +11 -11
  26. package/dist/runtime/server/index.mjs +371 -239
  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 +328 -212
  36. package/package.json +8 -4
@@ -139,7 +139,7 @@ interface SerializeDocumentOptions extends SsrDocumentOptions {
139
139
  * Note that this is "approximate", in that HTML may often not be able
140
140
  * to be split at an exact line width. Additionally, new lines created
141
141
  * is where HTML naturally already has whitespace, such as before an
142
- * attribute or spaces between words. Defaults to `100`.
142
+ * attribute or spaces between words. Defaults to no wrapping (`100` when prerendering).
143
143
  */
144
144
  approximateLineWidth?: number;
145
145
  /**
@@ -157,12 +157,12 @@ interface SerializeDocumentOptions extends SsrDocumentOptions {
157
157
  prettyHtml?: boolean;
158
158
  /**
159
159
  * Remove quotes from attribute values when possible.
160
- * Defaults to `true`.
160
+ * Defaults to `false` (`true` when prerendering).
161
161
  */
162
162
  removeAttributeQuotes?: boolean;
163
163
  /**
164
164
  * Remove the `=""` from standardized `boolean` attributes,
165
- * such as `hidden` or `checked`. Defaults to `true`.
165
+ * such as `hidden` or `checked`. Defaults to `false` (`true` when prerendering).
166
166
  */
167
167
  removeBooleanAttributeQuotes?: boolean;
168
168
  /**
@@ -171,7 +171,7 @@ interface SerializeDocumentOptions extends SsrDocumentOptions {
171
171
  */
172
172
  removeEmptyAttributes?: boolean;
173
173
  /**
174
- * Remove HTML comments. Defaults to `true`.
174
+ * Remove HTML comments. Defaults to `false` (`true` when prerendering).
175
175
  */
176
176
  removeHtmlComments?: boolean;
177
177
  /**
@@ -8047,10 +8047,12 @@ var MockTokenList = class {
8047
8047
  token = String(token);
8048
8048
  return getItems(this.elm, this.attr).includes(token);
8049
8049
  }
8050
- toggle(token) {
8050
+ toggle(token, force) {
8051
8051
  token = String(token);
8052
- if (this.contains(token) === true) this.remove(token);
8053
- else this.add(token);
8052
+ const shouldAdd = force === void 0 ? !this.contains(token) : !!force;
8053
+ if (shouldAdd) this.add(token);
8054
+ else this.remove(token);
8055
+ return shouldAdd;
8054
8056
  }
8055
8057
  get length() {
8056
8058
  return getItems(this.elm, this.attr).length;
@@ -11927,11 +11929,14 @@ function resetWindow(win) {
11927
11929
  if (win.document != null) try {
11928
11930
  win.document.defaultView = win;
11929
11931
  } catch {}
11930
- win.fetch = null;
11931
- win.Headers = null;
11932
- win.Request = null;
11933
- win.Response = null;
11934
- win.FetchError = null;
11932
+ const windowDestroyed = () => {
11933
+ throw new Error("MockWindow was already destroyed");
11934
+ };
11935
+ win.fetch = windowDestroyed;
11936
+ win.Headers = windowDestroyed;
11937
+ win.Request = windowDestroyed;
11938
+ win.Response = windowDestroyed;
11939
+ win.FetchError = windowDestroyed;
11935
11940
  }
11936
11941
  }
11937
11942
  function resetWindowDimensions(win) {
@@ -12254,39 +12259,6 @@ function createWindowFromHtml(templateHtml, uniqueId) {
12254
12259
  return cloneWindow(templateWindow);
12255
12260
  }
12256
12261
  //#endregion
12257
- //#region src/runtime/runtime-constants.ts
12258
- const HYDRATED_STYLE_ID = "sty-id";
12259
- const STENCIL_DOC_DATA = "_stencilDocData";
12260
- //#endregion
12261
- //#region src/utils/helpers.ts
12262
- const isString = (v) => typeof v === "string";
12263
- //#endregion
12264
- //#region src/runtime/mode.ts
12265
- const setMode = (handler) => modeResolutionChain.push(handler);
12266
- BUILD.lazyLoad || globalThis.HTMLElement;
12267
- //#endregion
12268
- //#region src/runtime/tag-transform.ts
12269
- let tagTransformer = void 0;
12270
- /**
12271
- * Transforms a tag name using the current tag transformer
12272
- * @param tag - the tag to transform e.g. `my-tag`
12273
- * @returns the transformed tag e.g. `new-my-tag`
12274
- */
12275
- function transformTag(tag) {
12276
- if (!tagTransformer) return tag;
12277
- return tagTransformer(tag);
12278
- }
12279
- /**
12280
- * Sets the tag transformer to be used when rendering custom elements
12281
- * @param transformer the transformer function to use. Must return a string
12282
- */
12283
- function setTagTransformer(transformer) {
12284
- tagTransformer = transformer;
12285
- }
12286
- //#endregion
12287
- //#region src/server/platform/index.ts
12288
- const modeResolutionChain = [];
12289
- //#endregion
12290
12262
  //#region src/compiler/html/canonical-link.ts
12291
12263
  const updateCanonicalLink = (doc, href) => {
12292
12264
  let canonicalLinkElm = doc.head.querySelector("link[rel=\"canonical\"]");
@@ -12313,6 +12285,9 @@ const relocateMetaCharset = (doc) => {
12313
12285
  head.insertBefore(charsetElm, head.firstChild);
12314
12286
  };
12315
12287
  //#endregion
12288
+ //#region src/utils/helpers.ts
12289
+ const isString = (v) => typeof v === "string";
12290
+ //#endregion
12316
12291
  //#region src/utils/message-utils.ts
12317
12292
  /**
12318
12293
  * Builds a diagnostic from an `Error`, appends it to the `diagnostics` parameter, and returns the created diagnostic
@@ -12355,6 +12330,39 @@ const TASK_CANCELED_MSG = `task canceled`;
12355
12330
  //#endregion
12356
12331
  //#region src/compiler/style/css-parser/parse-css.ts
12357
12332
  /**
12333
+ * Splits a selector list on top-level commas in a single pass: a comma only
12334
+ * splits when it's outside a quoted string and at paren depth 0, so commas in
12335
+ * `:is(:a,:has(:b))` or `[title="a,b"]` aren't treated as separators.
12336
+ * Backslash escapes (inside or outside a string) are skipped so they can't shift state,
12337
+ * so e.g. `[title="a\,b"]` is treated as a single selector.
12338
+ * @param selectors The selector list to split
12339
+ * @returns An array of selectors, with whitespace trimmed from each selector
12340
+ */
12341
+ const splitSelectorList = (selectors) => {
12342
+ const parts = [];
12343
+ let depth = 0;
12344
+ let quote = null;
12345
+ let start = 0;
12346
+ for (let i = 0; i < selectors.length; i++) {
12347
+ const ch = selectors[i];
12348
+ if (quote) {
12349
+ if (ch === "\\") i++;
12350
+ else if (ch === quote) quote = null;
12351
+ continue;
12352
+ }
12353
+ if (ch === "\"" || ch === "'") quote = ch;
12354
+ else if (ch === "\\") i++;
12355
+ else if (ch === "(") depth++;
12356
+ else if (ch === ")") depth = Math.max(0, depth - 1);
12357
+ else if (ch === "," && depth === 0) {
12358
+ parts.push(selectors.slice(start, i));
12359
+ start = i + 1;
12360
+ }
12361
+ }
12362
+ parts.push(selectors.slice(start));
12363
+ return parts.map((s) => s.trim());
12364
+ };
12365
+ /**
12358
12366
  * Parses CSS string input into an AST representation.
12359
12367
  * Used for minification, finding & resolving URLs and during SSR / prerendering, removing unused selectors.
12360
12368
  *
@@ -12479,11 +12487,8 @@ const parseCss = (css, filePath) => {
12479
12487
  const selector = () => {
12480
12488
  const m = match(/^([^{]+)/);
12481
12489
  if (!m) return null;
12482
- return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(str) {
12483
- return str.replace(/,/g, "‌");
12484
- }).split(/\s*(?![^(]*\)),\s*/).map(function(s) {
12485
- return s.replace(/\u200C/g, ",");
12486
- });
12490
+ const cleaned = trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "");
12491
+ return splitSelectorList(cleaned);
12487
12492
  };
12488
12493
  const declaration = () => {
12489
12494
  const pos = position();
@@ -13103,6 +13108,37 @@ const removeUnusedStyleText = (usedSelectors, diagnostics, styleElm) => {
13103
13108
  }
13104
13109
  };
13105
13110
  //#endregion
13111
+ //#region src/runtime/runtime-constants.ts
13112
+ const HYDRATED_STYLE_ID = "sty-id";
13113
+ const STENCIL_DOC_DATA = "_stencilDocData";
13114
+ const SERVER_BUILD_FLAGS = {
13115
+ isBrowser: false,
13116
+ isServer: true,
13117
+ isDev: false,
13118
+ isTesting: false
13119
+ };
13120
+ //#endregion
13121
+ //#region src/runtime/tag-transform.ts
13122
+ let tagTransformer = void 0;
13123
+ /**
13124
+ * Transforms a tag name using the current tag transformer
13125
+ * @param tag - the tag to transform e.g. `my-tag`
13126
+ * @returns the transformed tag e.g. `new-my-tag`
13127
+ */
13128
+ function transformTag(tag) {
13129
+ if (!tagTransformer) return tag;
13130
+ return tagTransformer(tag);
13131
+ }
13132
+ /**
13133
+ * Sets the tag transformer to be used when rendering custom elements
13134
+ * @param transformer the transformer function to use. Must return a string
13135
+ */
13136
+ function setTagTransformer(transformer) {
13137
+ tagTransformer = transformer;
13138
+ }
13139
+ ({ ...SERVER_BUILD_FLAGS });
13140
+ BUILD.lazyLoad || globalThis.HTMLElement;
13141
+ //#endregion
13106
13142
  //#region src/server/runner/inspect-element.ts
13107
13143
  function inspectElement(results, elm, depth) {
13108
13144
  const children = [...Array.from(elm.children), ...Array.from(elm.shadowRoot ? elm.shadowRoot.children : [])];
@@ -13513,14 +13549,6 @@ async function render(win, opts, results) {
13513
13549
  try {
13514
13550
  await Promise.resolve(beforeHydrateFn(win.document));
13515
13551
  return new Promise((resolve) => {
13516
- if (Array.isArray(opts.modes)) {
13517
- /**
13518
- * Reset the mode resolution chain as we expect every `renderToString` call to render
13519
- * the components in new environment/document.
13520
- */
13521
- modeResolutionChain.length = 0;
13522
- opts.modes.forEach((mode) => setMode(mode));
13523
- }
13524
13552
  return ssrFactory(win, opts, results, afterSsr, resolve);
13525
13553
  });
13526
13554
  } catch (e) {
@@ -1,6 +1,15 @@
1
- import { ReadonlySignal, ReadonlySignal as ReadonlySignal$1, Signal, batch, computed, effect, signal, untracked } from "@preact/signals-core";
1
+ import * as SignalsCore from "@preact/signals-core";
2
+ import { ReadonlySignal, Signal } from "@preact/signals-core";
2
3
  import "rolldown";
3
4
  import "typescript";
5
+ //#region src/runtime/signals-core.d.ts
6
+ declare const batch: typeof SignalsCore.batch;
7
+ declare const computed: typeof SignalsCore.computed;
8
+ declare const effect: typeof SignalsCore.effect;
9
+ declare const untracked: typeof SignalsCore.untracked;
10
+ declare function signal<T>(value: T, options?: SignalsCore.SignalOptions<T>): SignalsCore.Signal<T>;
11
+ declare function signal<T = undefined>(): SignalsCore.Signal<T | undefined>;
12
+ //#endregion
4
13
  //#region src/runtime/signals.d.ts
5
14
  declare const STENCIL_SIGNALS_SYMBOL: unique symbol;
6
15
  //#endregion
@@ -22,7 +31,7 @@ declare const STENCIL_SIGNALS_SYMBOL: unique symbol;
22
31
  * @param prop - the `@Prop` member name
23
32
  * @returns the `ReadonlySignal` for the prop, or `null` if not found / not signal-backed
24
33
  */
25
- declare const getSignal: <T = unknown>(elm: Element, prop: string) => ReadonlySignal$1<T> | null;
34
+ declare const getSignal: <T = unknown>(elm: Element, prop: string) => ReadonlySignal<T> | null;
26
35
  /**
27
36
  * Marks a class method as a reactive effect. Wraps the method in `effect()` after
28
37
  * signal initialization and registers cleanup on disconnect. Dependencies are
@@ -1,4 +1,4 @@
1
- import { batch, computed, effect, signal, untracked } from "@preact/signals-core";
1
+ import * as SignalsCore from "@preact/signals-core";
2
2
  //#region src/app-data/index.ts
3
3
  /**
4
4
  * A collection of default build flags for a Stencil project.
@@ -102,36 +102,6 @@ const BUILD = {
102
102
  asyncLoading: true,
103
103
  asyncQueue: false
104
104
  };
105
- BUILD.isDev, BUILD.isTesting;
106
- const MEMBER_FLAGS = {
107
- String: 1,
108
- Number: 2,
109
- Boolean: 4,
110
- Any: 8,
111
- Unknown: 16,
112
- State: 32,
113
- Method: 64,
114
- Event: 128,
115
- Element: 256,
116
- ReflectAttr: 512,
117
- Mutable: 1024,
118
- Getter: 2048,
119
- Setter: 4096,
120
- Prop: 31,
121
- HasAttribute: 31,
122
- PropLike: 63
123
- };
124
- //#endregion
125
- //#region src/client/client-host-ref.ts
126
- /**
127
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
128
- *
129
- * @param ref the runtime ref of interest
130
- * @returns the Host reference (if found) or undefined
131
- */
132
- const getHostRef = (ref) => {
133
- if (ref.__s_ghr) return ref.__s_ghr();
134
- };
135
105
  //#endregion
136
106
  //#region src/client/client-log.ts
137
107
  const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
@@ -140,6 +110,16 @@ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
140
110
  (typeof window !== "undefined" ? window : {}).HTMLElement;
141
111
  BUILD.constructableCSS;
142
112
  //#endregion
113
+ //#region src/runtime/signals-core.ts
114
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
115
+ const batch = (fn) => getCore().batch(fn);
116
+ const computed = (fn, options) => getCore().computed(fn, options);
117
+ const effect = (fn, options) => getCore().effect(fn, options);
118
+ const untracked = (fn) => getCore().untracked(fn);
119
+ function signal(value, options) {
120
+ return getCore().signal(value, options);
121
+ }
122
+ //#endregion
143
123
  //#region src/runtime/signals.ts
144
124
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
145
125
  BUILD.lazyLoad || globalThis.HTMLElement;
@@ -163,13 +143,12 @@ BUILD.lazyLoad || globalThis.HTMLElement;
163
143
  * @returns the `ReadonlySignal` for the prop, or `null` if not found / not signal-backed
164
144
  */
165
145
  const getSignal = (elm, prop) => {
166
- const hostRef = getHostRef(elm);
167
- if (!hostRef?.$signalValues$) {
146
+ const signals = elm[STENCIL_SIGNALS_SYMBOL];
147
+ if (!signals) {
168
148
  if (BUILD.isDev) consoleDevWarn(`getSignal('${prop}'): element <${elm.tagName.toLowerCase()}> is not signal-backed. Ensure signalBacking is true in stencil.config.ts.`);
169
149
  return null;
170
150
  }
171
- if (!((hostRef.$cmpMeta$?.$members$?.[prop]?.[0] ?? 0) & MEMBER_FLAGS.Prop)) return null;
172
- return hostRef.$signalValues$.get(prop) ?? null;
151
+ return signals.get(prop) ?? null;
173
152
  };
174
153
  /**
175
154
  * Marks a class method as a reactive effect. Wraps the method in `effect()` after
@@ -1,4 +1,4 @@
1
- import { J as CompilerSystem, jt as Logger } from "../../index-BopBfjPu.mjs";
1
+ import { Bt as Logger, nt as CompilerSystem } from "../../index-BogZpjP2.mjs";
2
2
  //#region src/sys/node/logger/index.d.ts
3
3
  /**
4
4
  * Create a logger to run in a Node environment
@@ -1,2 +1,2 @@
1
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-75gQKkFz.mjs";
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-D-21Ykxi.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-BPgV6bA4.mjs";
2
- import { t as createNodeSys } from "../../node-75gQKkFz.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-BI12oAIV.mjs";
2
+ import { t as createNodeSys } from "../../node-D-21Ykxi.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
5
5
  * Initialize a worker thread, setting up various machinery for managing