@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
@@ -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.
@@ -140,6 +140,16 @@ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
140
140
  (typeof window !== "undefined" ? window : {}).HTMLElement;
141
141
  BUILD.constructableCSS;
142
142
  //#endregion
143
+ //#region src/runtime/signals-core.ts
144
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
145
+ const batch = (fn) => getCore().batch(fn);
146
+ const computed = (fn, options) => getCore().computed(fn, options);
147
+ const effect = (fn, options) => getCore().effect(fn, options);
148
+ const untracked = (fn) => getCore().untracked(fn);
149
+ function signal(value, options) {
150
+ return getCore().signal(value, options);
151
+ }
152
+ //#endregion
143
153
  //#region src/runtime/signals.ts
144
154
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
145
155
  BUILD.lazyLoad || globalThis.HTMLElement;
@@ -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-B9-Byy8z.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-Bz2SOK7_.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-C8yf59oh.mjs";
2
- import { t as createNodeSys } from "../../node-75gQKkFz.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-CUsOl_Kw.mjs";
2
+ import { t as createNodeSys } from "../../node-Bz2SOK7_.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