@stencil/core 5.0.0-next.0 → 5.0.0-rc.1

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 (58) hide show
  1. package/README.md +94 -0
  2. package/bin/stencil.mjs +1 -1
  3. package/dist/app-data/index.d.ts +2 -0
  4. package/dist/{runtime/app-data → app-data}/index.js +23 -15
  5. package/dist/{runtime/app-globals → app-globals}/index.js +1 -2
  6. package/dist/client-BMtGBEQV.mjs +2498 -0
  7. package/dist/compiler/browser.d.ts +1573 -0
  8. package/dist/compiler/browser.js +16998 -0
  9. package/dist/compiler/index.d.mts +284 -7
  10. package/dist/compiler/index.mjs +3 -9
  11. package/dist/compiler/utils/index.d.mts +272 -3
  12. package/dist/compiler/utils/index.mjs +4 -5
  13. package/dist/{transpile-CJQcQEVa.mjs → compiler-C_Y38j4m.mjs} +20984 -15554
  14. package/dist/declarations/stencil-ext-modules.d.ts +8 -8
  15. package/dist/declarations/stencil-public-compiler.d.ts +1016 -840
  16. package/dist/declarations/stencil-public-compiler.js +3 -5
  17. package/dist/declarations/stencil-public-docs.d.ts +441 -376
  18. package/dist/declarations/stencil-public-docs.js +0 -0
  19. package/dist/declarations/stencil-public-runtime.d.ts +361 -113
  20. package/dist/fragment-Di1hWOC8.mjs +4 -0
  21. package/dist/helpers-pTCZhNi0.mjs +529 -0
  22. package/dist/{index-szczUd2l.d.mts → index-CFiy6MZ3.d.mts} +1471 -2044
  23. package/dist/index-CViiWNQ9.d.mts +104 -0
  24. package/dist/{stencil-private-Cgcr414u.d.ts → index-XQHZl0MW.d.ts} +308 -114
  25. package/dist/index.d.mts +14 -2
  26. package/dist/index.mjs +171 -4
  27. package/dist/jsx-runtime.d.mts +24 -0
  28. package/dist/jsx-runtime.mjs +3 -0
  29. package/dist/mock-doc.mjs +2 -3
  30. package/dist/{node-sys-BGURUNOZ.mjs → node-Bkq8vRnu.mjs} +176 -197
  31. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  32. package/dist/{client-DR9zhmKG.mjs → runtime/client/lazy.js} +3794 -2659
  33. package/dist/runtime/client/{index.d.ts → runtime.d.ts} +516 -227
  34. package/dist/runtime/client/{index.js → runtime.js} +3596 -2857
  35. package/dist/runtime/index.d.ts +90 -72
  36. package/dist/runtime/index.js +3528 -2897
  37. package/dist/runtime/server/index.d.mts +243 -219
  38. package/dist/runtime/server/index.mjs +3770 -3352
  39. package/dist/runtime/server/runner.d.mts +114 -47
  40. package/dist/runtime/server/runner.mjs +12710 -763
  41. package/dist/signals/index.d.ts +58 -0
  42. package/dist/signals/index.js +182 -0
  43. package/dist/sys/node/index.d.mts +1 -3
  44. package/dist/sys/node/index.mjs +2 -7
  45. package/dist/sys/node/worker.d.mts +1 -1
  46. package/dist/sys/node/worker.mjs +3 -12
  47. package/dist/testing/index.d.mts +4763 -12
  48. package/dist/testing/index.mjs +7945 -618
  49. package/dist/util-CP6-333M.mjs +731 -0
  50. package/dist/validation-C1mr0klL.mjs +825 -0
  51. package/package.json +91 -59
  52. package/dist/chunk-ClPoSABd.mjs +0 -21
  53. package/dist/index-Bxo2jCf6.d.mts +0 -77
  54. package/dist/runtime/app-data/index.d.ts +0 -30
  55. package/dist/serialize-BJvhE9aQ.mjs +0 -775
  56. package/dist/validation-BdcPruW_.mjs +0 -1451
  57. /package/{LICENSE.md → LICENSE} +0 -0
  58. /package/dist/{runtime/app-globals → app-globals}/index.d.ts +0 -0
@@ -1,30 +1,15 @@
1
- import { Readable } from "node:stream";
2
-
1
+ import "@stencil/core/app-data";
2
+ import "rolldown";
3
+ import "typescript";
3
4
  //#region src/server/runner/create-window.d.ts
4
5
  declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
5
6
  //#endregion
6
- //#region src/utils/serialize.d.ts
7
- /**
8
- * Serialize a value to a string that can be deserialized later.
9
- * @param {unknown} value - The value to serialize.
10
- * @returns {string} A string that can be deserialized later.
11
- * @deprecated will be removed in v5. Use `@PropSerialize()` decorator instead.
12
- */
13
- declare function serializeProperty(value: unknown): string | number | boolean;
14
- /**
15
- * Deserialize a value from a string that was serialized earlier.
16
- * @param {string} value - The string to deserialize.
17
- * @returns {unknown} The deserialized value.
18
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` decorator instead.
19
- */
20
- declare function deserializeProperty(value: string): any;
21
- //#endregion
22
7
  //#region src/declarations/stencil-public-runtime.d.ts
23
8
  type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
24
9
  type TagTransformer = (tag: string) => string;
25
10
  //#endregion
26
11
  //#region src/declarations/stencil-public-compiler.d.ts
27
- interface HydrateDocumentOptions {
12
+ interface SsrDocumentOptions {
28
13
  /**
29
14
  * Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
30
15
  * a random ID will be generated
@@ -41,7 +26,7 @@ interface HydrateDocumentOptions {
41
26
  * JavaScript to read the structure of the HTML and rebuild each
42
27
  * component. Defaults to `true`.
43
28
  */
44
- clientHydrateAnnotations?: boolean;
29
+ clientSsrAnnotations?: boolean;
45
30
  /**
46
31
  * Constrain `setTimeout()` to 1ms, but still async. Also
47
32
  * only allows `setInterval()` to fire once, also constrained to 1ms.
@@ -74,6 +59,16 @@ interface HydrateDocumentOptions {
74
59
  * Sets `document.referrer`
75
60
  */
76
61
  referrer?: string;
62
+ /**
63
+ * Render into one long-lived mock window, reset between renders, instead of creating a new one
64
+ * for every call. Skips evaluating the whole SSR platform (runtime and every component)
65
+ * on each render: most of the cost of rendering a small fragment, and a good part of a whole page.
66
+ *
67
+ * Applies to HTML string input (not a `Document`). One window per distinct `serializeShadowRoot` value,
68
+ * and renders sharing a window run one at a time.
69
+ * Defaults to `false`, except in the `ssr-wasm` output target, where it defaults to `true`.
70
+ */
71
+ reuseWindow?: boolean;
77
72
  /**
78
73
  * Removes every `<script>` element found in the `document`. Defaults to `false`.
79
74
  */
@@ -140,22 +135,30 @@ interface HydrateDocumentOptions {
140
135
  default: 'declarative-shadow-dom' | 'scoped';
141
136
  } | boolean;
142
137
  }
143
- interface SerializeDocumentOptions extends HydrateDocumentOptions {
138
+ interface SerializeDocumentOptions extends SsrDocumentOptions {
144
139
  /**
145
140
  * Runs after the `document` has been hydrated.
146
141
  */
142
+ afterSsr?(document: any): any | Promise<any>;
143
+ /**
144
+ * @deprecated Use `afterSsr` instead.
145
+ */
147
146
  afterHydrate?(document: any): any | Promise<any>;
148
147
  /**
149
148
  * Sets an approximate line width the HTML should attempt to stay within.
150
149
  * Note that this is "approximate", in that HTML may often not be able
151
150
  * to be split at an exact line width. Additionally, new lines created
152
151
  * is where HTML naturally already has whitespace, such as before an
153
- * attribute or spaces between words. Defaults to `100`.
152
+ * attribute or spaces between words. Defaults to no wrapping (`100` when prerendering).
154
153
  */
155
154
  approximateLineWidth?: number;
156
155
  /**
157
156
  * Runs before the `document` has been hydrated.
158
157
  */
158
+ beforeSsr?(document: any): any | Promise<any>;
159
+ /**
160
+ * @deprecated Use `beforeSsr` instead.
161
+ */
159
162
  beforeHydrate?(document: any): any | Promise<any>;
160
163
  /**
161
164
  * Format the HTML in a nicely indented format.
@@ -164,12 +167,12 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
164
167
  prettyHtml?: boolean;
165
168
  /**
166
169
  * Remove quotes from attribute values when possible.
167
- * Defaults to `true`.
170
+ * Defaults to `false` (`true` when prerendering).
168
171
  */
169
172
  removeAttributeQuotes?: boolean;
170
173
  /**
171
174
  * Remove the `=""` from standardized `boolean` attributes,
172
- * such as `hidden` or `checked`. Defaults to `true`.
175
+ * such as `hidden` or `checked`. Defaults to `false` (`true` when prerendering).
173
176
  */
174
177
  removeBooleanAttributeQuotes?: boolean;
175
178
  /**
@@ -178,7 +181,7 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
178
181
  */
179
182
  removeEmptyAttributes?: boolean;
180
183
  /**
181
- * Remove HTML comments. Defaults to `true`.
184
+ * Remove HTML comments. Defaults to `false` (`true` when prerendering).
182
185
  */
183
186
  removeHtmlComments?: boolean;
184
187
  /**
@@ -193,10 +196,16 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
193
196
  */
194
197
  modes?: ResolutionHandler[];
195
198
  }
196
- interface HydrateFactoryOptions extends SerializeDocumentOptions {
199
+ interface SsrFactoryOptions extends SerializeDocumentOptions {
197
200
  serializeToHtml: boolean;
198
201
  destroyWindow: boolean;
199
202
  destroyDocument: boolean;
203
+ /**
204
+ * A canonical key for `serializeShadowRoot`, set by the renderer. Renders with the same key
205
+ * render every component the same way, so they can share an SSR platform.
206
+ * @internal
207
+ */
208
+ serializeShadowRootKey?: string;
200
209
  }
201
210
  interface Diagnostic {
202
211
  absFilePath?: string | undefined;
@@ -221,7 +230,7 @@ interface PrintLine {
221
230
  errorCharStart: number;
222
231
  errorLength?: number;
223
232
  }
224
- interface HydrateResults {
233
+ interface SsrResults {
225
234
  buildId: string;
226
235
  diagnostics: Diagnostic[];
227
236
  url: string;
@@ -233,54 +242,98 @@ interface HydrateResults {
233
242
  search: string | null;
234
243
  hash: string | null;
235
244
  html: string | null;
236
- components: HydrateComponent[];
237
- anchors: HydrateAnchorElement[];
238
- imgs: HydrateImgElement[];
239
- scripts: HydrateScriptElement[];
240
- styles: HydrateStyleElement[];
241
- staticData: HydrateStaticData[];
245
+ components: SsrComponent[];
246
+ anchors: SsrAnchorElement[];
247
+ imgs: SsrImgElement[];
248
+ scripts: SsrScriptElement[];
249
+ styles: SsrStyleElement[];
250
+ staticData: SsrStaticData[];
242
251
  title: string | null;
243
252
  hydratedCount: number;
244
253
  httpStatus: number | null;
245
254
  }
246
- interface HydrateComponent {
255
+ interface SsrComponent {
247
256
  tag: string;
248
257
  mode: string;
249
258
  count: number;
250
259
  depth: number;
251
260
  }
252
- interface HydrateElement {
261
+ interface SsrElement {
253
262
  [attrName: string]: string | undefined;
254
263
  }
255
- interface HydrateAnchorElement extends HydrateElement {
264
+ interface SsrAnchorElement extends SsrElement {
256
265
  href?: string;
257
266
  target?: string;
258
267
  }
259
- interface HydrateImgElement extends HydrateElement {
268
+ interface SsrImgElement extends SsrElement {
260
269
  src?: string;
261
270
  }
262
- interface HydrateScriptElement extends HydrateElement {
271
+ interface SsrScriptElement extends SsrElement {
263
272
  src?: string;
264
273
  type?: string;
265
274
  }
266
- interface HydrateStyleElement extends HydrateElement {
275
+ interface SsrStyleElement extends SsrElement {
267
276
  id?: string;
268
277
  href?: string;
269
278
  content?: string;
270
279
  }
271
- interface HydrateStaticData {
280
+ interface SsrStaticData {
272
281
  id: string;
273
282
  type: string;
274
283
  content: string;
275
284
  }
276
285
  //#endregion
277
286
  //#region src/server/runner/render.d.ts
278
- declare function streamToString(html: string | any, option?: SerializeDocumentOptions): Readable;
279
- declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
280
- declare function renderToString(html: string | any, options: SerializeDocumentOptions | undefined, asStream: true): Readable;
281
- declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
282
- declare function hydrateDocument(doc: any | string, options: HydrateDocumentOptions | undefined, asStream?: boolean): Readable;
283
- declare function serializeDocumentToString(doc: Document, opts: HydrateFactoryOptions): string;
287
+ /**
288
+ * Renders HTML to a string, returning the full hydration results.
289
+ * This is the primary SSR function and is portable (no Node.js dependencies).
290
+ * @param html - the HTML string or document to render
291
+ * @param options - serialization options
292
+ * @returns the hydration results
293
+ */
294
+ declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<SsrResults>;
295
+ /**
296
+ * Renders HTML and returns a web-standard ReadableStream.
297
+ * Works in Node 22+, Cloudflare Workers, Deno, Bun, and any WinterCG-compatible runtime.
298
+ * @param html - the HTML string or document to render
299
+ * @param options - serialization options
300
+ * @returns a ReadableStream
301
+ */
302
+ declare function streamToString(html: string | any, options?: SerializeDocumentOptions): ReadableStream<string>;
303
+ /**
304
+ * Server side renders a document or HTML string, returning the full render results.
305
+ * This is portable (no Node.js dependencies).
306
+ * @param doc - the document or HTML string to render
307
+ * @param options - hydration options
308
+ * @returns the render results
309
+ */
310
+ declare function ssrDocument(doc: any | string, options?: SsrDocumentOptions): Promise<SsrResults>;
311
+ /**
312
+ * v4 Compat
313
+ * @alias
314
+ * @deprecated Use `ssrDocument()` instead
315
+ */
316
+ declare const hydrateDocument: typeof ssrDocument;
317
+ declare function serializeDocumentToString(doc: Document, opts: SsrFactoryOptions): string;
318
+ //#endregion
319
+ //#region src/server/runner/reusable-window.d.ts
320
+ /**
321
+ * Drop every reusable window and render queue. For hosts where a render can be abandoned without
322
+ * ever settling (the `ssr-wasm` plugin, when a call ends with a render still waiting), so the
323
+ * next render doesn't queue behind it forever.
324
+ */
325
+ declare function resetReusableWindows(): void;
326
+ //#endregion
327
+ //#region src/server/runner/window-initialize.d.ts
328
+ /**
329
+ * Restart the hydration ids used by fragment renders (`fullDocument: false`).
330
+ *
331
+ * Optional - ids only need to be unique within a page, and they are without it. Call it once at
332
+ * the start of each request that renders fragments, to get the same output for the same input.
333
+ * Never call it between fragments that end up in the same page, or their ids will collide.
334
+ * Full-document renders always start from 1 and aren't affected.
335
+ */
336
+ declare function resetSsrDocData(): void;
284
337
  //#endregion
285
338
  //#region src/runtime/tag-transform.d.ts
286
339
  /**
@@ -295,4 +348,18 @@ declare function transformTag<T extends string>(tag: T): T;
295
348
  */
296
349
  declare function setTagTransformer(transformer: TagTransformer): void;
297
350
  //#endregion
298
- export { createWindowFromHtml, deserializeProperty, hydrateDocument, renderToString, serializeDocumentToString, serializeProperty, setTagTransformer, streamToString, transformTag };
351
+ //#region src/server/runner/index.d.ts
352
+ /**
353
+ * Render components under transformed tag names, to match tag transformation on the client.
354
+ *
355
+ * Components are registered under their transformed names when a window's SSR platform is set up,
356
+ * so this also discards the reusable windows (see the `reuseWindow` option): later renders set up
357
+ * new ones that use the new transformer.
358
+ *
359
+ * (A function declaration with its own name, so the runtime's `setTagTransformer` keeps its name in
360
+ * the bundle - the SSR build looks for it - and this is hoisted.)
361
+ * @param transformer the tag transformer
362
+ */
363
+ declare function setTagTransformerForSsr(transformer: Parameters<typeof setTagTransformer>[0]): void;
364
+ //#endregion
365
+ export { createWindowFromHtml, hydrateDocument, renderToString, resetReusableWindows, resetSsrDocData, serializeDocumentToString, setTagTransformerForSsr as setTagTransformer, ssrDocument, streamToString, transformTag };