@stencil/core 5.0.0-alpha.4 → 5.0.0-alpha.5

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/{client-Dti6fFpE.mjs → client-Dnio47yQ.mjs} +81 -10
  2. package/dist/compiler/index.d.mts +2 -2
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-BYRrEeD-.mjs → compiler-Dxri2g8Z.mjs} +15313 -14822
  7. package/dist/declarations/stencil-public-compiler.d.ts +288 -132
  8. package/dist/declarations/stencil-public-compiler.js +2 -3
  9. package/dist/declarations/stencil-public-runtime.d.ts +2 -0
  10. package/dist/{index-hS-KBdAP.d.ts → index-D-XN9HW_.d.ts} +1 -1
  11. package/dist/{index-BwTaN1Nq.d.mts → index-D5zaocDq.d.mts} +357 -189
  12. package/dist/{index-CyrGY82h.d.ts → index-D61XZw0f.d.ts} +2 -2
  13. package/dist/{index-9LTuoSiw.d.mts → index-Dat4djoo.d.mts} +1 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/{jsx-runtime-DlDkTqps.d.ts → jsx-runtime-B3vQbWIW.d.ts} +1 -1
  16. package/dist/jsx-runtime.d.ts +1 -1
  17. package/dist/jsx-runtime.js +1 -1
  18. package/dist/{node-BF2jSfWg.mjs → node-pj6rF4Wt.mjs} +66 -69
  19. package/dist/{regular-expression-D5pGVpCu.mjs → regular-expression-D0_N0PGa.mjs} +44 -26
  20. package/dist/runtime/app-data/index.d.ts +1 -1
  21. package/dist/runtime/client/index.d.ts +41 -8
  22. package/dist/runtime/client/index.js +105 -31
  23. package/dist/runtime/index.d.ts +29 -5
  24. package/dist/runtime/index.js +2 -2
  25. package/dist/runtime/server/index.d.mts +56 -25
  26. package/dist/runtime/server/index.mjs +122 -37
  27. package/dist/runtime/server/runner.d.mts +40 -26
  28. package/dist/runtime/server/runner.mjs +28 -22
  29. package/dist/{runtime-COEYYPyw.js → runtime-CKyUrF4i.js} +104 -30
  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 +2 -2
  34. package/dist/testing/index.mjs +15 -15
  35. package/dist/{validation-Byxie0Uk.mjs → validation-BA8nzXu_.mjs} +82 -58
  36. package/package.json +11 -12
@@ -1094,7 +1094,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1094
1094
  styleElm.textContent = style;
1095
1095
  const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
1096
1096
  if (nonce != null) styleElm.setAttribute("nonce", nonce);
1097
- if ((BUILD$1.hydrateServerSide || BUILD$1.hotModuleReplacement) && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1097
+ if (BUILD$1.hydrateServerSide && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) || BUILD$1.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1098
+ if (BUILD$1.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
1098
1099
  /**
1099
1100
  * attach styles at the end of the head tag if we render scoped components
1100
1101
  */
@@ -2197,6 +2198,46 @@ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) =>
2197
2198
  const setMode = (handler) => modeResolutionChain.push(handler);
2198
2199
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
2199
2200
  //#endregion
2201
+ //#region src/runtime/normalize-watchers.ts
2202
+ /**
2203
+ * Normalizes watcher metadata to the current `{ [methodName]: flags }[]` format.
2204
+ *
2205
+ * Prior to Stencil 4.39.x (PR #6484), the `@Watch()` compiler emitted watcher
2206
+ * handlers as a plain string array: `{ "min": ["minChanged"] }`. The new format
2207
+ * wraps each entry in an object that carries option flags (e.g. `immediate`):
2208
+ * `{ "min": [{ "minChanged": 0 }] }`.
2209
+ *
2210
+ * When a library (e.g. Ionic Framework) was compiled with an older Stencil compiler
2211
+ * but consumed by an app using a newer Stencil runtime, the runtime's
2212
+ * `Object.entries(watcher)` call receives a string and misinterprets its character
2213
+ * indices as method names, causing:
2214
+ * `TypeError: instance[watchMethodName] is not a function`
2215
+ *
2216
+ * This helper should be used at `$watchers$` assignment sites that need to
2217
+ * accept both legacy and current compiler metadata so downstream code on those
2218
+ * paths can safely assume the new object format.
2219
+ *
2220
+ * @param raw The raw watcher map from compiled metadata (new or legacy format).
2221
+ * @returns A normalized watcher map in the `{ [methodName]: flags }[]` format, or `undefined` if `raw` is `undefined` or empty.
2222
+ */
2223
+ const normalizeWatchers = (raw) => {
2224
+ if (!raw) return void 0;
2225
+ const keys = Object.keys(raw);
2226
+ if (keys.length === 0) return void 0;
2227
+ let hasLegacy = false;
2228
+ for (const propName of keys) {
2229
+ if (hasLegacy) break;
2230
+ for (const h of raw[propName]) if (typeof h === "string") {
2231
+ hasLegacy = true;
2232
+ break;
2233
+ }
2234
+ }
2235
+ if (!hasLegacy) return raw;
2236
+ const out = {};
2237
+ for (const propName of keys) out[propName] = raw[propName].map((h) => typeof h === "string" ? { [h]: 0 } : h);
2238
+ return out;
2239
+ };
2240
+ //#endregion
2200
2241
  //#region src/runtime/parse-property-value.ts
2201
2242
  /**
2202
2243
  * Parse a new property value for a given property type.
@@ -3547,7 +3588,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3547
3588
  });
3548
3589
  if (BUILD$1.member && cmpMeta.$members$ || BUILD$1.propChangeCallback) {
3549
3590
  if (BUILD$1.propChangeCallback) {
3550
- if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = Cstr.watchers;
3591
+ if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
3551
3592
  if (Cstr.deserializers && !cmpMeta.$deserializers$) cmpMeta.$deserializers$ = Cstr.deserializers;
3552
3593
  if (Cstr.serializers && !cmpMeta.$serializers$) cmpMeta.$serializers$ = Cstr.serializers;
3553
3594
  }
@@ -3697,7 +3738,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3697
3738
  if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
3698
3739
  if (BUILD$1.member && !Cstr.isProxied) {
3699
3740
  if (BUILD$1.propChangeCallback) {
3700
- cmpMeta.$watchers$ = Cstr.watchers;
3741
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
3701
3742
  cmpMeta.$serializers$ = Cstr.serializers;
3702
3743
  cmpMeta.$deserializers$ = Cstr.deserializers;
3703
3744
  }
@@ -3873,7 +3914,59 @@ const disconnectedCallback = async (elm) => {
3873
3914
  if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) rootAppliedStyles.delete(elm.shadowRoot);
3874
3915
  };
3875
3916
  //#endregion
3876
- //#region src/runtime/bootstrap-custom-element.ts
3917
+ //#region src/runtime/hmr-component.ts
3918
+ /**
3919
+ * Kick off hot-module-replacement for a component. In order to replace the
3920
+ * component in-place we:
3921
+ *
3922
+ * 1. get a reference to the {@link d.HostRef} for the element
3923
+ * 2. reset the element's runtime flags
3924
+ * 3. re-run the initialization logic for the element (via
3925
+ * {@link initializeComponent})
3926
+ *
3927
+ * For standalone (non-lazy) builds, we instead re-import the component module
3928
+ * and patch the prototype of the registered constructor in-place, then
3929
+ * force a re-render of all existing instances in the DOM.
3930
+ *
3931
+ * @param hostElement the host element for the component which we want to start
3932
+ * doing HMR
3933
+ * @param cmpMeta runtime metadata for the component
3934
+ * @param hmrVersionId the current HMR version ID
3935
+ */
3936
+ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
3937
+ if (BUILD$1.lazyLoad) {
3938
+ const hostRef = getHostRef(hostElement);
3939
+ if (!hostRef) return;
3940
+ hostRef.$flags$ = HOST_FLAGS.hasConnected;
3941
+ initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
3942
+ } else hmrStandalone(hostElement, cmpMeta, hmrVersionId);
3943
+ };
3944
+ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
3945
+ const modulePath = hostElement.constructor.__stencil_module__;
3946
+ console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
3947
+ if (!modulePath) {
3948
+ console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor — was this built with devMode?`);
3949
+ return;
3950
+ }
3951
+ try {
3952
+ const newModule = await import(
3953
+ /* @vite-ignore */
3954
+ `${modulePath}?s-hmr=${hmrVersionId}`
3955
+ );
3956
+ const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
3957
+ if (!NewClass) return;
3958
+ const ctor = customElements.get(cmpMeta.$tagName$);
3959
+ if (ctor) for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
3960
+ if (key === "constructor") continue;
3961
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
3962
+ }
3963
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => forceUpdate(el));
3964
+ } catch (e) {
3965
+ console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
3966
+ }
3967
+ };
3968
+ //#endregion
3969
+ //#region src/runtime/bootstrap-standalone.ts
3877
3970
  const defineCustomElement = (Cstr, compactMeta) => {
3878
3971
  customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
3879
3972
  };
@@ -3887,12 +3980,15 @@ const proxyCustomElement = (Cstr, compactMeta) => {
3887
3980
  if (BUILD$1.member) cmpMeta.$members$ = compactMeta[2];
3888
3981
  if (BUILD$1.hostListener) cmpMeta.$listeners$ = compactMeta[3];
3889
3982
  if (BUILD$1.propChangeCallback) {
3890
- cmpMeta.$watchers$ = Cstr.$watchers$;
3983
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.$watchers$);
3891
3984
  cmpMeta.$deserializers$ = Cstr.$deserializers$;
3892
3985
  cmpMeta.$serializers$ = Cstr.$serializers$;
3893
3986
  }
3894
3987
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
3895
3988
  if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
3989
+ if (BUILD$1.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
3990
+ hmrStart(this, cmpMeta, hmrVersionId);
3991
+ };
3896
3992
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.experimentalSlotFixes || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) patchPseudoShadowDom(Cstr.prototype);
3897
3993
  else {
3898
3994
  if (BUILD$1.slotChildNodesFix || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
@@ -3973,29 +4069,7 @@ const forceModeUpdate = (elm) => {
3973
4069
  }
3974
4070
  };
3975
4071
  //#endregion
3976
- //#region src/runtime/hmr-component.ts
3977
- /**
3978
- * Kick off hot-module-replacement for a component. In order to replace the
3979
- * component in-place we:
3980
- *
3981
- * 1. get a reference to the {@link d.HostRef} for the element
3982
- * 2. reset the element's runtime flags
3983
- * 3. re-run the initialization logic for the element (via
3984
- * {@link initializeComponent})
3985
- *
3986
- * @param hostElement the host element for the component which we want to start
3987
- * doing HMR
3988
- * @param cmpMeta runtime metadata for the component
3989
- * @param hmrVersionId the current HMR version ID
3990
- */
3991
- const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
3992
- const hostRef = getHostRef(hostElement);
3993
- if (!hostRef) return;
3994
- hostRef.$flags$ = HOST_FLAGS.hasConnected;
3995
- initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
3996
- };
3997
- //#endregion
3998
- //#region src/runtime/bootstrap-lazy.ts
4072
+ //#region src/runtime/bootstrap-loader.ts
3999
4073
  const bootstrapLazy = (lazyBundles, options = {}) => {
4000
4074
  if (BUILD$1.profile && performance.mark) performance.mark("st:app:start");
4001
4075
  installDevTools();
@@ -4029,7 +4103,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4029
4103
  if (BUILD$1.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4030
4104
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
4031
4105
  if (BUILD$1.propChangeCallback) {
4032
- cmpMeta.$watchers$ = compactMeta[4] ?? {};
4106
+ cmpMeta.$watchers$ = normalizeWatchers(compactMeta[4]);
4033
4107
  cmpMeta.$serializers$ = compactMeta[5] ?? {};
4034
4108
  cmpMeta.$deserializers$ = compactMeta[6] ?? {};
4035
4109
  }
@@ -4481,15 +4555,26 @@ function componentOnReady() {
4481
4555
  }
4482
4556
  function forceUpdate$1() {}
4483
4557
  //#endregion
4484
- //#region src/server/platform/hydrate-app.ts
4485
- function hydrateApp(win, opts, results, afterHydrate, resolve) {
4558
+ //#region src/server/platform/ssr-app.ts
4559
+ /**
4560
+ * SSR a Document by patching the DOM APIs to wait for components to be connected and hydrated
4561
+ * before allowing them to be added to the document.
4562
+ * Once all components are hydrated, the `afterSsr` callback is called so that the caller can serialize
4563
+ * the document to HTML and send it back to the client.
4564
+ * @param win The window to use for SSR. This should be a patched window created by `patchDomImplementation`.
4565
+ * @param opts The options to use for SSR. This is used to configure which components should be hydrated, how long to wait for hydration, etc.
4566
+ * @param results The results object to store the hydration results.
4567
+ * @param afterSsr The callback to be called after SSR is complete.
4568
+ * @param resolve The resolve function to be called when SSR is complete.
4569
+ */
4570
+ function ssrApp(win, opts, results, afterSsr, resolve) {
4486
4571
  const connectedElements = /* @__PURE__ */ new Set();
4487
4572
  const createdElements = /* @__PURE__ */ new Set();
4488
4573
  const waitingElements = /* @__PURE__ */ new Set();
4489
4574
  const orgDocumentCreateElement = win.document.createElement;
4490
4575
  const orgDocumentCreateElementNS = win.document.createElementNS;
4491
4576
  const resolved = Promise.resolve();
4492
- setScopedSSR(opts);
4577
+ setScopedSsr(opts);
4493
4578
  let tmrId;
4494
4579
  let ranCompleted = false;
4495
4580
  function hydratedComplete() {
@@ -4499,7 +4584,7 @@ function hydrateApp(win, opts, results, afterHydrate, resolve) {
4499
4584
  if (!ranCompleted) {
4500
4585
  ranCompleted = true;
4501
4586
  try {
4502
- if (opts.clientHydrateAnnotations) insertVdomAnnotations(win.document, opts.staticComponents);
4587
+ if (opts.clientSsrAnnotations) insertVdomAnnotations(win.document, opts.staticComponents);
4503
4588
  win.dispatchEvent(new win.Event("DOMContentLoaded"));
4504
4589
  win.document.createElement = orgDocumentCreateElement;
4505
4590
  win.document.createElementNS = orgDocumentCreateElementNS;
@@ -4507,7 +4592,7 @@ function hydrateApp(win, opts, results, afterHydrate, resolve) {
4507
4592
  renderCatchError(opts, results, e);
4508
4593
  }
4509
4594
  }
4510
- afterHydrate(win, opts, results, resolve);
4595
+ afterSsr(win, opts, results, resolve);
4511
4596
  }
4512
4597
  function hydratedError(err) {
4513
4598
  renderCatchError(opts, results, err);
@@ -4853,7 +4938,7 @@ const getAssetPath = (path) => {
4853
4938
  };
4854
4939
  /**
4855
4940
  * Sets the base URL for resolving asset paths in the server/hydrate context.
4856
- * @param path - The base URL to use for resolving asset paths. This should typically be set to the same value as the `resourcesUrl` option passed to `hydrateDocument` to ensure that asset paths are resolved correctly in the server/hydrate context.
4941
+ * @param path - The base URL to use for resolving asset paths. This should typically be set to the same value as the `resourcesUrl` option passed to `ssrDocument` to ensure that asset paths are resolved correctly in the server/hydrate context.
4857
4942
  * If not set, it defaults to './', which is a reasonable default for server-side rendering.
4858
4943
  * @returns void
4859
4944
  */
@@ -4862,10 +4947,10 @@ const setAssetPath = (path) => plt.$resourcesUrl$ = path;
4862
4947
  * Checks to see any components are rendered with `scoped`
4863
4948
  * @param opts - SSR options
4864
4949
  */
4865
- const setScopedSSR = (opts) => {
4950
+ const setScopedSsr = (opts) => {
4866
4951
  scopedSSR = BUILD$1.shadowDom && opts.serializeShadowRoot !== false && opts.serializeShadowRoot !== "declarative-shadow-dom";
4867
4952
  };
4868
4953
  const needsScopedSSR = () => scopedSSR;
4869
4954
  let scopedSSR = false;
4870
4955
  //#endregion
4871
- export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getValue, hAsync as h, hydrateApp, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
4956
+ export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
@@ -7,7 +7,7 @@ type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
7
7
  type TagTransformer = (tag: string) => string;
8
8
  //#endregion
9
9
  //#region src/declarations/stencil-public-compiler.d.ts
10
- interface HydrateDocumentOptions {
10
+ interface SsrDocumentOptions {
11
11
  /**
12
12
  * Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
13
13
  * a random ID will be generated
@@ -24,7 +24,7 @@ interface HydrateDocumentOptions {
24
24
  * JavaScript to read the structure of the HTML and rebuild each
25
25
  * component. Defaults to `true`.
26
26
  */
27
- clientHydrateAnnotations?: boolean;
27
+ clientSsrAnnotations?: boolean;
28
28
  /**
29
29
  * Constrain `setTimeout()` to 1ms, but still async. Also
30
30
  * only allows `setInterval()` to fire once, also constrained to 1ms.
@@ -123,10 +123,14 @@ interface HydrateDocumentOptions {
123
123
  default: 'declarative-shadow-dom' | 'scoped';
124
124
  } | boolean;
125
125
  }
126
- interface SerializeDocumentOptions extends HydrateDocumentOptions {
126
+ interface SerializeDocumentOptions extends SsrDocumentOptions {
127
127
  /**
128
128
  * Runs after the `document` has been hydrated.
129
129
  */
130
+ afterSsr?(document: any): any | Promise<any>;
131
+ /**
132
+ * @deprecated Use `afterSsr` instead.
133
+ */
130
134
  afterHydrate?(document: any): any | Promise<any>;
131
135
  /**
132
136
  * Sets an approximate line width the HTML should attempt to stay within.
@@ -139,6 +143,10 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
139
143
  /**
140
144
  * Runs before the `document` has been hydrated.
141
145
  */
146
+ beforeSsr?(document: any): any | Promise<any>;
147
+ /**
148
+ * @deprecated Use `beforeSsr` instead.
149
+ */
142
150
  beforeHydrate?(document: any): any | Promise<any>;
143
151
  /**
144
152
  * Format the HTML in a nicely indented format.
@@ -176,7 +184,7 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
176
184
  */
177
185
  modes?: ResolutionHandler[];
178
186
  }
179
- interface HydrateFactoryOptions extends SerializeDocumentOptions {
187
+ interface SsrFactoryOptions extends SerializeDocumentOptions {
180
188
  serializeToHtml: boolean;
181
189
  destroyWindow: boolean;
182
190
  destroyDocument: boolean;
@@ -204,7 +212,7 @@ interface PrintLine {
204
212
  errorCharStart: number;
205
213
  errorLength?: number;
206
214
  }
207
- interface HydrateResults {
215
+ interface SsrResults {
208
216
  buildId: string;
209
217
  diagnostics: Diagnostic[];
210
218
  url: string;
@@ -216,42 +224,42 @@ interface HydrateResults {
216
224
  search: string | null;
217
225
  hash: string | null;
218
226
  html: string | null;
219
- components: HydrateComponent[];
220
- anchors: HydrateAnchorElement[];
221
- imgs: HydrateImgElement[];
222
- scripts: HydrateScriptElement[];
223
- styles: HydrateStyleElement[];
224
- staticData: HydrateStaticData[];
227
+ components: SsrComponent[];
228
+ anchors: SsrAnchorElement[];
229
+ imgs: SsrImgElement[];
230
+ scripts: SsrScriptElement[];
231
+ styles: SsrStyleElement[];
232
+ staticData: SsrStaticData[];
225
233
  title: string | null;
226
234
  hydratedCount: number;
227
235
  httpStatus: number | null;
228
236
  }
229
- interface HydrateComponent {
237
+ interface SsrComponent {
230
238
  tag: string;
231
239
  mode: string;
232
240
  count: number;
233
241
  depth: number;
234
242
  }
235
- interface HydrateElement {
243
+ interface SsrElement {
236
244
  [attrName: string]: string | undefined;
237
245
  }
238
- interface HydrateAnchorElement extends HydrateElement {
246
+ interface SsrAnchorElement extends SsrElement {
239
247
  href?: string;
240
248
  target?: string;
241
249
  }
242
- interface HydrateImgElement extends HydrateElement {
250
+ interface SsrImgElement extends SsrElement {
243
251
  src?: string;
244
252
  }
245
- interface HydrateScriptElement extends HydrateElement {
253
+ interface SsrScriptElement extends SsrElement {
246
254
  src?: string;
247
255
  type?: string;
248
256
  }
249
- interface HydrateStyleElement extends HydrateElement {
257
+ interface SsrStyleElement extends SsrElement {
250
258
  id?: string;
251
259
  href?: string;
252
260
  content?: string;
253
261
  }
254
- interface HydrateStaticData {
262
+ interface SsrStaticData {
255
263
  id: string;
256
264
  type: string;
257
265
  content: string;
@@ -265,7 +273,7 @@ interface HydrateStaticData {
265
273
  * @param options - serialization options
266
274
  * @returns the hydration results
267
275
  */
268
- declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
276
+ declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<SsrResults>;
269
277
  /**
270
278
  * Renders HTML and returns a Node.js Readable stream.
271
279
  * This is a Node.js-specific convenience wrapper around renderToString.
@@ -276,20 +284,26 @@ declare function renderToString(html: string | any, options?: SerializeDocumentO
276
284
  */
277
285
  declare function streamToString(html: string | any, options?: SerializeDocumentOptions): Readable;
278
286
  /**
279
- * Hydrates a document or HTML string, returning the full hydration results.
287
+ * Server side renders a document or HTML string, returning the full render results.
280
288
  * This is portable (no Node.js dependencies).
281
- * @param doc - the document or HTML string to hydrate
289
+ * @param doc - the document or HTML string to render
282
290
  * @param options - hydration options
283
- * @returns the hydration results
291
+ * @returns the render results
292
+ */
293
+ declare function ssrDocument(doc: any | string, options?: SsrDocumentOptions): Promise<SsrResults>;
294
+ /**
295
+ * v4 Compat
296
+ * @alias
297
+ * @deprecated Use `ssrDocument()` instead
284
298
  */
285
- declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
286
- declare function serializeDocumentToString(doc: Document, opts: HydrateFactoryOptions): string;
299
+ declare const hydrateDocument: typeof ssrDocument;
300
+ declare function serializeDocumentToString(doc: Document, opts: SsrFactoryOptions): string;
287
301
  //#endregion
288
302
  //#region src/server/runner/window-initialize.d.ts
289
303
  /**
290
304
  * Reset the docData counters. Useful for testing to ensure deterministic IDs.
291
305
  */
292
- declare function resetHydrateDocData(): void;
306
+ declare function resetSsrDocData(): void;
293
307
  //#endregion
294
308
  //#region src/runtime/tag-transform.d.ts
295
309
  /**
@@ -304,4 +318,4 @@ declare function transformTag<T extends string>(tag: T): T;
304
318
  */
305
319
  declare function setTagTransformer(transformer: TagTransformer): void;
306
320
  //#endregion
307
- export { createWindowFromHtml, hydrateDocument, renderToString, resetHydrateDocData, serializeDocumentToString, setTagTransformer, streamToString, transformTag };
321
+ export { createWindowFromHtml, hydrateDocument, renderToString, resetSsrDocData, serializeDocumentToString, setTagTransformer, ssrDocument, streamToString, transformTag };
@@ -1,5 +1,5 @@
1
1
  import { Readable } from "node:stream";
2
- import { hydrateFactory } from "@stencil/core/runtime/server/hydrate-factory";
2
+ import { ssrFactory } from "@stencil/core/runtime/server/ssr-factory";
3
3
  import { BUILD } from "@stencil/core/runtime/app-data";
4
4
  //#region ../../node_modules/.pnpm/parse5@7.2.1/node_modules/parse5/dist/common/unicode.js
5
5
  const UNDEFINED_CODE_POINTS = new Set([
@@ -8899,7 +8899,7 @@ function insertBefore(parentNode, newNode, referenceNode) {
8899
8899
  var MockHTMLElement = class extends MockElement {
8900
8900
  __namespaceURI = "http://www.w3.org/1999/xhtml";
8901
8901
  constructor(ownerDocument, nodeName) {
8902
- super(ownerDocument, typeof nodeName === "string" ? nodeName.toUpperCase() : null);
8902
+ super(ownerDocument, nodeName ? nodeName.toUpperCase() : null);
8903
8903
  }
8904
8904
  get tagName() {
8905
8905
  return this.nodeName ?? "";
@@ -13300,7 +13300,7 @@ function normalizeHydrateOptions(inputOpts) {
13300
13300
  destroyWindow: false,
13301
13301
  destroyDocument: false
13302
13302
  }, inputOpts || {});
13303
- if (typeof outputOpts.clientHydrateAnnotations !== "boolean") outputOpts.clientHydrateAnnotations = true;
13303
+ if (typeof outputOpts.clientSsrAnnotations !== "boolean") outputOpts.clientSsrAnnotations = true;
13304
13304
  if (typeof outputOpts.constrainTimeouts !== "boolean") outputOpts.constrainTimeouts = true;
13305
13305
  if (typeof outputOpts.maxHydrateCount !== "number") outputOpts.maxHydrateCount = 300;
13306
13306
  if (typeof outputOpts.runtimeLogging !== "boolean") outputOpts.runtimeLogging = false;
@@ -13319,7 +13319,7 @@ function mapValidTags(tag) {
13319
13319
  }
13320
13320
  function generateHydrateResults(opts) {
13321
13321
  if (typeof opts.url !== "string") opts.url = `https://hydrate.stenciljs.com/`;
13322
- if (typeof opts.buildId !== "string") opts.buildId = createHydrateBuildId();
13322
+ if (typeof opts.buildId !== "string") opts.buildId = createSsrBuildId();
13323
13323
  const results = {
13324
13324
  buildId: opts.buildId,
13325
13325
  diagnostics: [],
@@ -13357,7 +13357,7 @@ function generateHydrateResults(opts) {
13357
13357
  }
13358
13358
  return results;
13359
13359
  }
13360
- const createHydrateBuildId = () => {
13360
+ const createSsrBuildId = () => {
13361
13361
  let chars = "abcdefghijklmnopqrstuvwxyz";
13362
13362
  let buildId = "";
13363
13363
  while (buildId.length < 8) {
@@ -13447,7 +13447,7 @@ const docData = {
13447
13447
  /**
13448
13448
  * Reset the docData counters. Useful for testing to ensure deterministic IDs.
13449
13449
  */
13450
- function resetHydrateDocData() {
13450
+ function resetSsrDocData() {
13451
13451
  docData.hostIds = 0;
13452
13452
  docData.rootLevelIds = 0;
13453
13453
  docData.staticComponents.clear();
@@ -13510,7 +13510,7 @@ function renderToString(html, options) {
13510
13510
  * Make sure we wait for components to be hydrated.
13511
13511
  */
13512
13512
  opts.constrainTimeouts = false;
13513
- return hydrateDocument(html, opts);
13513
+ return ssrDocument(html, opts);
13514
13514
  }
13515
13515
  /**
13516
13516
  * Renders HTML and returns a Node.js Readable stream.
@@ -13527,13 +13527,13 @@ function streamToString(html, options) {
13527
13527
  return Readable.from(generateStream());
13528
13528
  }
13529
13529
  /**
13530
- * Hydrates a document or HTML string, returning the full hydration results.
13530
+ * Server side renders a document or HTML string, returning the full render results.
13531
13531
  * This is portable (no Node.js dependencies).
13532
- * @param doc - the document or HTML string to hydrate
13532
+ * @param doc - the document or HTML string to render
13533
13533
  * @param options - hydration options
13534
- * @returns the hydration results
13534
+ * @returns the render results
13535
13535
  */
13536
- function hydrateDocument(doc, options) {
13536
+ function ssrDocument(doc, options) {
13537
13537
  const opts = normalizeHydrateOptions(options);
13538
13538
  /**
13539
13539
  * Defines whether we render the shadow root as a declarative shadow root or as scoped shadow root.
@@ -13566,6 +13566,12 @@ function hydrateDocument(doc, options) {
13566
13566
  renderBuildError(results, `Invalid html or document. Must be either a valid "html" string, or DOM "document".`);
13567
13567
  return Promise.resolve(results);
13568
13568
  }
13569
+ /**
13570
+ * v4 Compat
13571
+ * @alias
13572
+ * @deprecated Use `ssrDocument()` instead
13573
+ */
13574
+ const hydrateDocument = ssrDocument;
13569
13575
  async function render(win, opts, results) {
13570
13576
  if ("process" in globalThis && typeof process.on === "function" && !process.__stencilErrors) {
13571
13577
  process.__stencilErrors = true;
@@ -13574,7 +13580,7 @@ async function render(win, opts, results) {
13574
13580
  });
13575
13581
  }
13576
13582
  initializeWindow(win, win.document, opts, results);
13577
- const beforeHydrateFn = typeof opts.beforeHydrate === "function" ? opts.beforeHydrate : NOOP;
13583
+ const beforeHydrateFn = typeof (opts.beforeSsr || opts.beforeHydrate) === "function" ? opts.beforeSsr || opts.beforeHydrate : NOOP;
13578
13584
  try {
13579
13585
  await Promise.resolve(beforeHydrateFn(win.document));
13580
13586
  return new Promise((resolve) => {
@@ -13586,24 +13592,24 @@ async function render(win, opts, results) {
13586
13592
  modeResolutionChain.length = 0;
13587
13593
  opts.modes.forEach((mode) => setMode(mode));
13588
13594
  }
13589
- return hydrateFactory(win, opts, results, afterHydrate, resolve);
13595
+ return ssrFactory(win, opts, results, afterSsr, resolve);
13590
13596
  });
13591
13597
  } catch (e) {
13592
13598
  renderCatchError(results, e);
13593
- return finalizeHydrate(win, win.document, opts, results);
13599
+ return finalizeSsr(win, win.document, opts, results);
13594
13600
  }
13595
13601
  }
13596
- async function afterHydrate(win, opts, results, resolve) {
13597
- const afterHydrateFn = typeof opts.afterHydrate === "function" ? opts.afterHydrate : NOOP;
13602
+ async function afterSsr(win, opts, results, resolve) {
13603
+ const afterSsrFn = typeof (opts.afterSsr || opts.afterHydrate) === "function" ? opts.afterSsr || opts.afterHydrate : NOOP;
13598
13604
  try {
13599
- await Promise.resolve(afterHydrateFn(win.document));
13600
- return resolve(finalizeHydrate(win, win.document, opts, results));
13605
+ await Promise.resolve(afterSsrFn(win.document));
13606
+ return resolve(finalizeSsr(win, win.document, opts, results));
13601
13607
  } catch (e) {
13602
13608
  renderCatchError(results, e);
13603
- return resolve(finalizeHydrate(win, win.document, opts, results));
13609
+ return resolve(finalizeSsr(win, win.document, opts, results));
13604
13610
  }
13605
13611
  }
13606
- function finalizeHydrate(win, doc, opts, results) {
13612
+ function finalizeSsr(win, doc, opts, results) {
13607
13613
  try {
13608
13614
  inspectElement(results, doc.documentElement, 0);
13609
13615
  if (opts.removeUnusedStyles !== false) try {
@@ -13642,7 +13648,7 @@ function finalizeHydrate(win, doc, opts, results) {
13642
13648
  } catch (e) {
13643
13649
  renderCatchError(results, e);
13644
13650
  }
13645
- if (opts.clientHydrateAnnotations) doc.documentElement.classList.add("hydrated");
13651
+ if (opts.clientSsrAnnotations) doc.documentElement.classList.add("hydrated");
13646
13652
  if (opts.serializeToHtml) results.html = serializeDocumentToString(doc, opts);
13647
13653
  } catch (e) {
13648
13654
  renderCatchError(results, e);
@@ -13687,4 +13693,4 @@ function removeScripts(elm) {
13687
13693
  }
13688
13694
  }
13689
13695
  //#endregion
13690
- export { createWindowFromHtml, hydrateDocument, renderToString, resetHydrateDocData, serializeDocumentToString, setTagTransformer, streamToString, transformTag };
13696
+ export { createWindowFromHtml, hydrateDocument, renderToString, resetSsrDocData, serializeDocumentToString, setTagTransformer, ssrDocument, streamToString, transformTag };