@stencil/core 5.0.0-beta.34 → 5.0.0-beta.35

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.
@@ -1843,7 +1843,7 @@ const validateComponentTag = (tag) => {
1843
1843
  };
1844
1844
  //#endregion
1845
1845
  //#region src/version.ts
1846
- const version = "5.0.0-beta.34";
1846
+ const version = "5.0.0-beta.35";
1847
1847
  //#endregion
1848
1848
  //#region src/compiler/events.ts
1849
1849
  const buildEvents = () => {
@@ -1,4 +1,4 @@
1
- import { $ as CompilerFsStats, $n as WorkerMainController, $t as OutputTargetBuild, A as BuildOverrides, An as ResolveModuleIdResults, At as HotModuleReplacement, B as CompilerEventBuildLog, Bn as SsrFactoryOptions, Bt as Logger, C as BuildEmitEvents, Cn as PluginTransformResults, Cr as JsonDocsStyle, Ct as DevServerEditor, D as BuildOnEventRemove, Dn as PrerenderResults, Dr as JsonDocsValue, Dt as HistoryApiFallback, E as BuildNoChangeResults, En as PrerenderOptions, Er as JsonDocsUsage, Et as FsWatchResults, F as Compiler, Fn as SerializeDocumentOptions, Ft as LazyRequire, G as CompilerEventFileAdd, Gn as TransformOptions, Gt as OptimizeCssInput, H as CompilerEventBuildStart, Hn as StencilDevServerConfig, Ht as LoggerTimeSpan, I as CompilerBuildResults, In as ServiceWorkerConfig, It as LightDomPatches, J as CompilerEventFsChange, Jn as TranspileResults, Jt as OptimizeJsOutput, K as CompilerEventFileDelete, Kn as TranspileOnlyResults, Kt as OptimizeCssOutput, L as CompilerBuildStart, Ln as SitemapXmpOpts, Lt as LoadConfigInit, M as CliInitOptions, Mn as RobotsTxtOpts, Mt as HydrateFactoryOptions, N as CompileScriptMinifyOptions, Nn as RobotsTxtResults, Nt as HydratedFlag, O as BuildOnEvents, On as PrerenderStartOptions, Or as StyleDoc, Ot as HmrGlobalStyleUpdate, P as CompileTarget, Pn as RolldownConfig, Pt as LOG_LEVELS, Q as CompilerFileWatcherEvent, Qn as WatcherCloseResults, Qt as OutputTargetBaseNext, R as CompilerDependency, Rn as SitemapXmpResults, Rt as LoadConfigResults, S as AutoprefixerOptions, Sn as PluginCtx, Sr as JsonDocsSlot, St as DevServerConfig, T as BuildLog, Tn as PrerenderHydrateOptions, Tr as JsonDocsTypeLibrary, Tt as DocsReadmeCustomColumn, U as CompilerEventDirAdd, Un as StencilDocsConfig, Ut as ModeConfig, V as CompilerEventBuildNoChange, Vn as StencilConfig, Vt as LoggerLineUpdater, W as CompilerEventDirDelete, Wn as SystemDetails, Wt as NodeResolveConfig, X as CompilerFileWatcher, Xn as ValidatedConfig, Xt as OutputTargetAssets, Y as CompilerEventName, Yn as UnvalidatedConfig, Yt as OutputTarget, Z as CompilerFileWatcherCallback, Zn as ValidatedOutputTargetWww, Zt as OutputTargetBase, _ as PrintLine, _n as OutputTargetWww, _r as JsonDocsListener, _t as CopyTask, a as ComponentCompilerEvent, an as OutputTargetDocsCustom, at as CompilerSystemRealpathResults, b as SsrResults, bn as PlatformPath, br as JsonDocsPart, bt as CustomElementsExportBehaviorOptions, c as ComponentCompilerMethod, cn as OutputTargetDocsReadme, ct as CompilerSystemRemoveFileResults, d as ComponentCompilerTypeReferences, dn as OutputTargetLoaderBundle, dr as JsonDocMethodParameter, dt as CompilerSystemWriteFileResults, en as OutputTargetCollection, er as WorkerOptions, et as CompilerRequest, f as ComponentGlobalStyle, fn as OutputTargetSsr, fr as JsonDocs, ft as CompilerWatcher, g as PrerenderUrlResults, gn as OutputTargetTypes, gr as JsonDocsEvent, gt as CopyResults, h as PackageJsonData, hn as OutputTargetStats, hr as JsonDocsDependencyGraph, ht as ConfigCompat, i as CompilerWorkerContext, in as OutputTargetDocsAgentSkill, it as CompilerSystemCreateDirectoryResults, j as BuildResultsComponentGraph, jn as ResolveModuleOptions, jt as HydrateDocumentOptions, k as BuildOutput, kn as ResolveModuleIdOptions, kr as FsWriteResults, kt as HmrStyleUpdate, l as ComponentCompilerProperty, ln as OutputTargetDocsVscode, lr as UserBuildConditionals, lt as CompilerSystemRenameResults, m as LazyBundlesRuntimeData, mn as OutputTargetStandalone, mr as JsonDocsCustomState, mt as ConfigBundle, nn as OutputTargetCustom, nt as CompilerSystem, o as ComponentCompilerListener, on as OutputTargetDocsCustomElementsManifest, ot as CompilerSystemRemoveDirectoryOptions, pn as OutputTargetSsrWasm, pr as JsonDocsComponent, pt as Config, q as CompilerEventFileUpdate, qn as TranspileOptions, qt as OptimizeJsInput, r as CompilerCtx, rn as OutputTargetDistLazy, rt as CompilerSystemCreateDirectoryOptions, s as ComponentCompilerMeta, sn as OutputTargetDocsJson, st as CompilerSystemRemoveDirectoryResults, t as BuildCtx, tn as OutputTargetCopy, tt as CompilerRequestResponse, u as ComponentCompilerState, un as OutputTargetGlobalStyle, ut as CompilerSystemRenamedPath, vn as PageReloadStrategy, vr as JsonDocsMethod, vt as Credentials, w as BuildEvents, wn as PrerenderConfig, wr as JsonDocsTag, wt as Diagnostic, x as WorkerMsgHandler, xn as Plugin, xr as JsonDocsProp, xt as DevServer, yn as ParsedPath, yr as JsonDocsMethodReturn, yt as CustomElementsExportBehavior, z as CompilerEventBuildFinish, zn as SsrDocumentOptions, zt as LogLevel } from "../index-B0NfYeIA.mjs";
1
+ import { $ as CompilerFsStats, $n as WorkerMainController, $t as OutputTargetBuild, A as BuildOverrides, An as ResolveModuleIdResults, At as HotModuleReplacement, B as CompilerEventBuildLog, Bn as SsrFactoryOptions, Bt as Logger, C as BuildEmitEvents, Cn as PluginTransformResults, Cr as JsonDocsStyle, Ct as DevServerEditor, D as BuildOnEventRemove, Dn as PrerenderResults, Dr as JsonDocsValue, Dt as HistoryApiFallback, E as BuildNoChangeResults, En as PrerenderOptions, Er as JsonDocsUsage, Et as FsWatchResults, F as Compiler, Fn as SerializeDocumentOptions, Ft as LazyRequire, G as CompilerEventFileAdd, Gn as TransformOptions, Gt as OptimizeCssInput, H as CompilerEventBuildStart, Hn as StencilDevServerConfig, Ht as LoggerTimeSpan, I as CompilerBuildResults, In as ServiceWorkerConfig, It as LightDomPatches, J as CompilerEventFsChange, Jn as TranspileResults, Jt as OptimizeJsOutput, K as CompilerEventFileDelete, Kn as TranspileOnlyResults, Kt as OptimizeCssOutput, L as CompilerBuildStart, Ln as SitemapXmpOpts, Lt as LoadConfigInit, M as CliInitOptions, Mn as RobotsTxtOpts, Mt as HydrateFactoryOptions, N as CompileScriptMinifyOptions, Nn as RobotsTxtResults, Nt as HydratedFlag, O as BuildOnEvents, On as PrerenderStartOptions, Or as StyleDoc, Ot as HmrGlobalStyleUpdate, P as CompileTarget, Pn as RolldownConfig, Pt as LOG_LEVELS, Q as CompilerFileWatcherEvent, Qn as WatcherCloseResults, Qt as OutputTargetBaseNext, R as CompilerDependency, Rn as SitemapXmpResults, Rt as LoadConfigResults, S as AutoprefixerOptions, Sn as PluginCtx, Sr as JsonDocsSlot, St as DevServerConfig, T as BuildLog, Tn as PrerenderHydrateOptions, Tr as JsonDocsTypeLibrary, Tt as DocsReadmeCustomColumn, U as CompilerEventDirAdd, Un as StencilDocsConfig, Ut as ModeConfig, V as CompilerEventBuildNoChange, Vn as StencilConfig, Vt as LoggerLineUpdater, W as CompilerEventDirDelete, Wn as SystemDetails, Wt as NodeResolveConfig, X as CompilerFileWatcher, Xn as ValidatedConfig, Xt as OutputTargetAssets, Y as CompilerEventName, Yn as UnvalidatedConfig, Yt as OutputTarget, Z as CompilerFileWatcherCallback, Zn as ValidatedOutputTargetWww, Zt as OutputTargetBase, _ as PrintLine, _n as OutputTargetWww, _r as JsonDocsListener, _t as CopyTask, a as ComponentCompilerEvent, an as OutputTargetDocsCustom, at as CompilerSystemRealpathResults, b as SsrResults, bn as PlatformPath, br as JsonDocsPart, bt as CustomElementsExportBehaviorOptions, c as ComponentCompilerMethod, cn as OutputTargetDocsReadme, ct as CompilerSystemRemoveFileResults, d as ComponentCompilerTypeReferences, dn as OutputTargetLoaderBundle, dr as JsonDocMethodParameter, dt as CompilerSystemWriteFileResults, en as OutputTargetCollection, er as WorkerOptions, et as CompilerRequest, f as ComponentGlobalStyle, fn as OutputTargetSsr, fr as JsonDocs, ft as CompilerWatcher, g as PrerenderUrlResults, gn as OutputTargetTypes, gr as JsonDocsEvent, gt as CopyResults, h as PackageJsonData, hn as OutputTargetStats, hr as JsonDocsDependencyGraph, ht as ConfigCompat, i as CompilerWorkerContext, in as OutputTargetDocsAgentSkill, it as CompilerSystemCreateDirectoryResults, j as BuildResultsComponentGraph, jn as ResolveModuleOptions, jt as HydrateDocumentOptions, k as BuildOutput, kn as ResolveModuleIdOptions, kr as FsWriteResults, kt as HmrStyleUpdate, l as ComponentCompilerProperty, ln as OutputTargetDocsVscode, lr as UserBuildConditionals, lt as CompilerSystemRenameResults, m as LazyBundlesRuntimeData, mn as OutputTargetStandalone, mr as JsonDocsCustomState, mt as ConfigBundle, nn as OutputTargetCustom, nt as CompilerSystem, o as ComponentCompilerListener, on as OutputTargetDocsCustomElementsManifest, ot as CompilerSystemRemoveDirectoryOptions, pn as OutputTargetSsrWasm, pr as JsonDocsComponent, pt as Config, q as CompilerEventFileUpdate, qn as TranspileOptions, qt as OptimizeJsInput, r as CompilerCtx, rn as OutputTargetDistLazy, rt as CompilerSystemCreateDirectoryOptions, s as ComponentCompilerMeta, sn as OutputTargetDocsJson, st as CompilerSystemRemoveDirectoryResults, t as BuildCtx, tn as OutputTargetCopy, tt as CompilerRequestResponse, u as ComponentCompilerState, un as OutputTargetGlobalStyle, ut as CompilerSystemRenamedPath, vn as PageReloadStrategy, vr as JsonDocsMethod, vt as Credentials, w as BuildEvents, wn as PrerenderConfig, wr as JsonDocsTag, wt as Diagnostic, x as WorkerMsgHandler, xn as Plugin, xr as JsonDocsProp, xt as DevServer, yn as ParsedPath, yr as JsonDocsMethodReturn, yt as CustomElementsExportBehavior, z as CompilerEventBuildFinish, zn as SsrDocumentOptions, zt as LogLevel } from "../index-DG4wtfhx.mjs";
2
2
  import ts from "typescript";
3
3
  import { Plugin as Plugin$1 } from "rolldown";
4
4
  //#region src/version.d.ts
@@ -1,3 +1,3 @@
1
- import { A as version, C as hasStencilHydrateImport, D as parseCssOnlyComponents, E as replaceStencilHydrateImport, M as scopeCss, O as buildId, S as hasStencilGlobalsImport, T as replaceStencilGlobalsImport, _ as cmpMetaToDocsComponent, a as createPrerenderer, b as buildHydrateCss, c as createWorkerContext, d as nodeRequire, f as optimizeCss, g as generateManifest, h as generateComponentTypesFile, i as createSystem, j as versions, k as vermoji, l as createWorkerMessageHandler, m as validateHydrated, n as transpile, o as loadConfig, p as validateConfig, r as transpileSync, s as createCompiler, t as ts, u as optimizeJs, v as getScopeId, w as replaceStencilCssComponentsImport, x as hasStencilCssComponentsImport, y as foldBuildFlags } from "../compiler-CVL510L-.mjs";
1
+ import { A as version, C as hasStencilHydrateImport, D as parseCssOnlyComponents, E as replaceStencilHydrateImport, M as scopeCss, O as buildId, S as hasStencilGlobalsImport, T as replaceStencilGlobalsImport, _ as cmpMetaToDocsComponent, a as createPrerenderer, b as buildHydrateCss, c as createWorkerContext, d as nodeRequire, f as optimizeCss, g as generateManifest, h as generateComponentTypesFile, i as createSystem, j as versions, k as vermoji, l as createWorkerMessageHandler, m as validateHydrated, n as transpile, o as loadConfig, p as validateConfig, r as transpileSync, s as createCompiler, t as ts, u as optimizeJs, v as getScopeId, w as replaceStencilCssComponentsImport, x as hasStencilCssComponentsImport, y as foldBuildFlags } from "../compiler-BpfMxpfR.mjs";
2
2
  import { a as LOG_LEVELS, i as CustomElementsExportBehaviorOptions } from "../node-eg7pofz5.mjs";
3
3
  export { CustomElementsExportBehaviorOptions, LOG_LEVELS, buildHydrateCss, buildId, cmpMetaToDocsComponent, createCompiler, createPrerenderer, createSystem, createWorkerContext, createWorkerMessageHandler, foldBuildFlags, generateComponentTypesFile, generateManifest, getScopeId, hasStencilCssComponentsImport, hasStencilGlobalsImport, hasStencilHydrateImport, loadConfig, nodeRequire, optimizeCss, optimizeJs, parseCssOnlyComponents, replaceStencilCssComponentsImport, replaceStencilGlobalsImport, replaceStencilHydrateImport, scopeCss, transpile, transpileSync, ts, validateConfig, validateHydrated, vermoji, version, versions };
@@ -1,4 +1,4 @@
1
- import { $i as COPY, $r as filterActiveTargets, Ai as buildJsonFileError, Ar as ModeValidationError, Bi as loadTypeScriptDiagnostic, Br as isJsFile, Ca as SVG_NS, Ci as isOutputTargetTypes, Da as WWW, Di as shouldExcludeComponent, Ea as WATCH_FLAGS, Ei as relativeImport, Fi as shouldIgnoreError, Fr as createJsVarName, Gi as formatComponentRuntimeMeta, Gr as readOnlyArrayHasStringMember, Hi as createOnWarnFn, Hr as isTsFile, Ii as escapeHtml, Ir as generatePreamble, Ji as ASSETS, Jr as getSourceMappingUrlForEndOfFile, Ki as formatLazyBundleRuntimeMeta, Kr as readPackageJson, Li as normalizeDiagnostics, Lr as getTextDocs, Mi as catchError, Mr as validateComponentTag, Ni as hasError, Nr as ParsePackageJsonResult, Oa as XLINK_NS, Oi as TASK_CANCELED_MSG, Pi as hasWarning, Pr as addDocBlock, Qi as COLLECTION_MANIFEST_FILE_NAME, Qr as FilterComponentsResult, Ri as splitLineBreaks, Rr as hasDependency, Sa as STYLE_EXT, Si as isOutputTargetStats, Ta as VALID_CONFIG_OUTPUT_TARGETS, Ti as isValidConfigOutputTarget, Ui as isRolldownError, Ur as isTsxFile, Vi as loadTypeScriptDiagnostics, Vr as isJsxFile, Wi as loadRolldownDiagnostics, Wr as parsePackageJson, Xi as COLLECTION, Xr as rolldownToStencilSourceMap, Yi as CMP_FLAGS, Yr as getSourceMappingUrlLinker, Zi as COLLECTION_APP_DATA_FILE_NAME, Zr as result_d_exports, _a as NODE_TYPES, _i as isOutputTargetLoaderBundle, aa as DOCS_CUSTOM_ELEMENTS_MANIFEST, ai as isOutputTargetCollection, ba as STANDALONE, bi as isOutputTargetSsrWasm, ca as DOCS_VSCODE, ci as isOutputTargetDistLazy, da as GLOBAL_STYLE, di as isOutputTargetDocsCustom, ea as CUSTOM, ei as filterExcludedComponents, fa as HOST_FLAGS, fi as isOutputTargetDocsCustomElementsManifest, ga as MEMBER_FLAGS, gi as isOutputTargetGlobalStyle, ha as LOADER_BUNDLE, hi as isOutputTargetDocsVscode, ia as DOCS_CUSTOM, ii as isOutputTargetAssets, ji as buildWarn, jr as validateComponentModes, ki as buildError, la as EVENT_FLAGS, li as isOutputTargetDocs, ma as LISTENER_FLAGS, mi as isOutputTargetDocsReadme, na as DIST_LAZY, ni as getComponentsDtsTypesFilePath, oa as DOCS_JSON, oi as isOutputTargetCopy, pa as HTML_NS, pi as isOutputTargetDocsJson, qi as stringifyRuntimeData, qr as getInlineSourceMappingUrlLinker, ra as DOCS_AGENT_SKILL, ri as getComponentsFromModules, sa as DOCS_README, si as isOutputTargetCustom, ta as DEFAULT_STYLE_MODE, ti as getComponentsDtsSrcFilePath, ua as GENERATED_DTS, ui as isOutputTargetDocsAgentSkill, va as SSR, vi as isOutputTargetServerRenderer, wa as TYPES, wi as isOutputTargetWww, xa as STATS, xi as isOutputTargetStandalone, ya as SSR_WASM, yi as isOutputTargetSsr, zi as augmentDiagnosticWithNode, zr as isDtsFile } from "../../index-B0NfYeIA.mjs";
1
+ import { $i as COPY, $r as filterActiveTargets, Ai as buildJsonFileError, Ar as ModeValidationError, Bi as loadTypeScriptDiagnostic, Br as isJsFile, Ca as SVG_NS, Ci as isOutputTargetTypes, Da as WWW, Di as shouldExcludeComponent, Ea as WATCH_FLAGS, Ei as relativeImport, Fi as shouldIgnoreError, Fr as createJsVarName, Gi as formatComponentRuntimeMeta, Gr as readOnlyArrayHasStringMember, Hi as createOnWarnFn, Hr as isTsFile, Ii as escapeHtml, Ir as generatePreamble, Ji as ASSETS, Jr as getSourceMappingUrlForEndOfFile, Ki as formatLazyBundleRuntimeMeta, Kr as readPackageJson, Li as normalizeDiagnostics, Lr as getTextDocs, Mi as catchError, Mr as validateComponentTag, Ni as hasError, Nr as ParsePackageJsonResult, Oa as XLINK_NS, Oi as TASK_CANCELED_MSG, Pi as hasWarning, Pr as addDocBlock, Qi as COLLECTION_MANIFEST_FILE_NAME, Qr as FilterComponentsResult, Ri as splitLineBreaks, Rr as hasDependency, Sa as STYLE_EXT, Si as isOutputTargetStats, Ta as VALID_CONFIG_OUTPUT_TARGETS, Ti as isValidConfigOutputTarget, Ui as isRolldownError, Ur as isTsxFile, Vi as loadTypeScriptDiagnostics, Vr as isJsxFile, Wi as loadRolldownDiagnostics, Wr as parsePackageJson, Xi as COLLECTION, Xr as rolldownToStencilSourceMap, Yi as CMP_FLAGS, Yr as getSourceMappingUrlLinker, Zi as COLLECTION_APP_DATA_FILE_NAME, Zr as result_d_exports, _a as NODE_TYPES, _i as isOutputTargetLoaderBundle, aa as DOCS_CUSTOM_ELEMENTS_MANIFEST, ai as isOutputTargetCollection, ba as STANDALONE, bi as isOutputTargetSsrWasm, ca as DOCS_VSCODE, ci as isOutputTargetDistLazy, da as GLOBAL_STYLE, di as isOutputTargetDocsCustom, ea as CUSTOM, ei as filterExcludedComponents, fa as HOST_FLAGS, fi as isOutputTargetDocsCustomElementsManifest, ga as MEMBER_FLAGS, gi as isOutputTargetGlobalStyle, ha as LOADER_BUNDLE, hi as isOutputTargetDocsVscode, ia as DOCS_CUSTOM, ii as isOutputTargetAssets, ji as buildWarn, jr as validateComponentModes, ki as buildError, la as EVENT_FLAGS, li as isOutputTargetDocs, ma as LISTENER_FLAGS, mi as isOutputTargetDocsReadme, na as DIST_LAZY, ni as getComponentsDtsTypesFilePath, oa as DOCS_JSON, oi as isOutputTargetCopy, pa as HTML_NS, pi as isOutputTargetDocsJson, qi as stringifyRuntimeData, qr as getInlineSourceMappingUrlLinker, ra as DOCS_AGENT_SKILL, ri as getComponentsFromModules, sa as DOCS_README, si as isOutputTargetCustom, ta as DEFAULT_STYLE_MODE, ti as getComponentsDtsSrcFilePath, ua as GENERATED_DTS, ui as isOutputTargetDocsAgentSkill, va as SSR, vi as isOutputTargetServerRenderer, wa as TYPES, wi as isOutputTargetWww, xa as STATS, xi as isOutputTargetStandalone, ya as SSR_WASM, yi as isOutputTargetSsr, zi as augmentDiagnosticWithNode, zr as isDtsFile } from "../../index-DG4wtfhx.mjs";
2
2
  //#region src/utils/byte-size.d.ts
3
3
  /**
4
4
  * Used to learn the size of a string in bytes.
@@ -461,9 +461,9 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
461
461
  };
462
462
  //#endregion
463
463
  //#region src/version.ts
464
- const version = "5.0.0-beta.34";
465
- const buildId = "1793980027";
466
- const vermoji = "🦀";
464
+ const version = "5.0.0-beta.35";
465
+ const buildId = "1794002503";
466
+ const vermoji = "🚅";
467
467
  /**
468
468
  * Get the installed version of a tool/dependency.
469
469
  * Handles packages with exports maps that point to subdirectories.
@@ -12527,7 +12527,39 @@ var $nativeClearTimeout = (typeof globalThis !== 'undefined' ? globalThis : glob
12527
12527
  // Used to abort in-flight fetch() calls and to call any user defined AbortControllers when ssr times out.
12528
12528
  var $stencilNativeAbortController = AbortController;
12529
12529
 
12530
+ // Evaluated SSR platforms, per window and per serializeShadowRoot mode. Evaluating the platform
12531
+ // (runtime, vdom and every component class) is the main fixed cost of a render, so a window that's
12532
+ // rendered into again (see the \`reuseWindow\` option) reuses it. A new window gets a new platform.
12533
+ var $stencilSsrApps = new WeakMap();
12534
+
12530
12535
  export function ssrFactory($stencilWindow, $stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve) {
12536
+ // Rendering shadow components as scoped permanently changes their metadata inside the platform,
12537
+ // so a platform is only shared by renders whose serializeShadowRoot marks the same components as
12538
+ // scoped: keyed by the canonical key the renderer computes for it.
12539
+ var $stencilShadowModeKey = $stencilHydrateOpts.serializeShadowRootKey;
12540
+ var $stencilApp;
12541
+ if (typeof $stencilShadowModeKey !== 'string') {
12542
+ $stencilApp = $stencilCreateSsrApp($stencilWindow);
12543
+ } else {
12544
+ var $stencilWindowApps = $stencilSsrApps.get($stencilWindow);
12545
+ if (!$stencilWindowApps) {
12546
+ $stencilWindowApps = new Map();
12547
+ $stencilSsrApps.set($stencilWindow, $stencilWindowApps);
12548
+ }
12549
+ $stencilApp = $stencilWindowApps.get($stencilShadowModeKey);
12550
+ if (!$stencilApp) {
12551
+ $stencilApp = $stencilCreateSsrApp($stencilWindow);
12552
+ $stencilWindowApps.set($stencilShadowModeKey, $stencilApp);
12553
+ }
12554
+ }
12555
+ $stencilApp($stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve);
12556
+ }
12557
+
12558
+ /**
12559
+ * Evaluates the SSR platform for a window, and returns a function that renders with it.
12560
+ * Renders using the same platform must run one at a time.
12561
+ */
12562
+ function $stencilCreateSsrApp($stencilWindow) {
12531
12563
  var globalThis = $stencilWindow;
12532
12564
  var self = $stencilWindow;
12533
12565
  var top = $stencilWindow;
@@ -12616,7 +12648,9 @@ export function ssrFactory($stencilWindow, $stencilHydrateOpts, $stencilHydrateR
12616
12648
  // Aborted when the render times out or errors, so in-flight fetch() calls
12617
12649
  // made by component code stop holding the render's window/results alive
12618
12650
  // instead of running to completion against a torn-down window. See #6864.
12619
- var $stencilAbortController = new $stencilNativeAbortController();
12651
+ // A new one is created for every render (see the function returned below),
12652
+ // so one render's timeout never cancels the next render's work.
12653
+ var $stencilAbortController;
12620
12654
 
12621
12655
  // Any AbortController a component creates itself is transparently wired to
12622
12656
  // cascade-abort when the render times out too, so component code using the
@@ -12688,10 +12722,19 @@ export function ssrFactory($stencilWindow, $stencilHydrateOpts, $stencilHydrateR
12688
12722
  `;
12689
12723
  const SSR_FACTORY_OUTRO = `
12690
12724
  /*hydrateAppClosure end*/
12691
- ssrApp(window, $stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve, $stencilAbortController);
12725
+ return function ($stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve) {
12726
+ $stencilAbortController = new $stencilNativeAbortController();
12727
+ // a reused window is reset between renders, which removes these; put them back
12728
+ $stencilWindow.fetch = fetch;
12729
+ $stencilWindow.FetchError = FetchError;
12730
+ $stencilWindow.Headers = Headers;
12731
+ $stencilWindow.Request = Request;
12732
+ $stencilWindow.Response = Response;
12733
+ ssrApp(window, $stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve, $stencilAbortController);
12734
+ };
12692
12735
  }
12693
12736
 
12694
- hydrateAppClosure($stencilWindow);
12737
+ return hydrateAppClosure($stencilWindow);
12695
12738
  }
12696
12739
  `;
12697
12740
  //#endregion
@@ -13081,9 +13124,17 @@ const SSR_WASM_INTERFACE = `declare module "main" {
13081
13124
  export function resetSsrDocData(): void;
13082
13125
  }\n`;
13083
13126
  const SSR_WASM_OUTRO = `
13127
+ // Whether a renderToString call is in progress. Still true at the start of a call means the last
13128
+ // call ended with its render waiting on work that never resolved (see below).
13129
+ var $stencilWasmRenderInProgress = false;
13130
+
13084
13131
  module.exports = {
13085
13132
  renderToString: async function() {
13086
13133
  try {
13134
+ if ($stencilWasmRenderInProgress && typeof resetReusableWindows === 'function') {
13135
+ // That render will never finish, so it would hold its reusable window and queue forever.
13136
+ resetReusableWindows();
13137
+ }
13087
13138
  if (typeof renderToString !== 'function') {
13088
13139
  Host.outputString(JSON.stringify({ __error: 'renderToString is ' + typeof renderToString }));
13089
13140
  return;
@@ -13095,15 +13146,20 @@ module.exports = {
13095
13146
  // silence, then overwrite it once renderToString() actually resolves.
13096
13147
  Host.outputString(JSON.stringify({ __error: 'renderToString did not complete - a component may be waiting on work that never resolves' }));
13097
13148
  var opts = inp.options || {};
13149
+ // A plugin instance runs one call at a time, so its renders can always share one window
13150
+ // (see the reuseWindow option). Skips re-evaluating the whole platform on every call.
13151
+ if (typeof opts.reuseWindow !== 'boolean') opts.reuseWindow = true;
13098
13152
  var budget = typeof opts.timeout === 'number' ? opts.timeout : 15000;
13099
13153
  var timers = globalThis.__stencilSsrWasmTimers;
13100
13154
  var render = timers && timers.start(budget, function() {
13101
13155
  Host.outputString(JSON.stringify({ __error: 'renderToString did not complete within the ' + budget + 'ms timeout - a component may be waiting on work that never resolves, on a timer due after the timeout, or on timers it schedules forever' }));
13102
13156
  });
13103
13157
  var result;
13158
+ $stencilWasmRenderInProgress = true;
13104
13159
  try {
13105
- result = await renderToString(inp.html, inp.options);
13160
+ result = await renderToString(inp.html, opts);
13106
13161
  } finally {
13162
+ $stencilWasmRenderInProgress = false;
13107
13163
  if (render) timers.stop(render);
13108
13164
  }
13109
13165
  // renderToString reports some failures (e.g. input that isn't an HTML string) as an
@@ -13129,6 +13185,9 @@ module.exports = {
13129
13185
  var m = mappings.find(function(x) { return x.from === tag; });
13130
13186
  return m ? m.to : tag;
13131
13187
  });
13188
+ // Platforms register components under their transformed tags when they're set up, so the
13189
+ // reused windows' platforms have to be set up again.
13190
+ if (typeof resetReusableWindows === 'function') resetReusableWindows();
13132
13191
  },
13133
13192
  resetSsrDocData: function() {
13134
13193
  resetSsrDocData();
@@ -2536,6 +2536,16 @@ interface SsrDocumentOptions {
2536
2536
  * Sets `document.referrer`
2537
2537
  */
2538
2538
  referrer?: string;
2539
+ /**
2540
+ * Render into one long-lived mock window, reset between renders, instead of creating a new one
2541
+ * for every call. Skips evaluating the whole SSR platform (runtime and every component)
2542
+ * on each render: most of the cost of rendering a small fragment, and a good part of a whole page.
2543
+ *
2544
+ * Applies to HTML string input (not a `Document`). One window per distinct `serializeShadowRoot` value,
2545
+ * and renders sharing a window run one at a time.
2546
+ * Defaults to `false`, except in the `ssr-wasm` output target, where it defaults to `true`.
2547
+ */
2548
+ reuseWindow?: boolean;
2539
2549
  /**
2540
2550
  * Removes every `<script>` element found in the `document`. Defaults to `false`.
2541
2551
  */
@@ -2672,6 +2682,12 @@ interface SsrFactoryOptions extends SerializeDocumentOptions {
2672
2682
  serializeToHtml: boolean;
2673
2683
  destroyWindow: boolean;
2674
2684
  destroyDocument: boolean;
2685
+ /**
2686
+ * A canonical key for `serializeShadowRoot`, set by the renderer. Renders with the same key
2687
+ * render every component the same way, so they can share an SSR platform.
2688
+ * @internal
2689
+ */
2690
+ serializeShadowRootKey?: string;
2675
2691
  }
2676
2692
  /**
2677
2693
  * Backwards compat for v4
@@ -1,4 +1,4 @@
1
- import { ar as RafCallback, cr as TagTransformer, lr as UserBuildConditionals, n as ChildType, nr as ErrorHandler, p as HostElement, rr as FunctionalComponent, sr as ResolutionHandler, ur as VNode, v as PropsType, y as RuntimeRef } from "./index-B0NfYeIA.mjs";
1
+ import { ar as RafCallback, cr as TagTransformer, lr as UserBuildConditionals, n as ChildType, nr as ErrorHandler, p as HostElement, rr as FunctionalComponent, sr as ResolutionHandler, ur as VNode, v as PropsType, y as RuntimeRef } from "./index-DG4wtfhx.mjs";
2
2
  //#region src/client/client-build.d.ts
3
3
  /**
4
4
  * `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
@@ -2583,6 +2583,16 @@ interface SsrDocumentOptions {
2583
2583
  * Sets `document.referrer`
2584
2584
  */
2585
2585
  referrer?: string;
2586
+ /**
2587
+ * Render into one long-lived mock window, reset between renders, instead of creating a new one
2588
+ * for every call. Skips evaluating the whole SSR platform (runtime and every component)
2589
+ * on each render: most of the cost of rendering a small fragment, and a good part of a whole page.
2590
+ *
2591
+ * Applies to HTML string input (not a `Document`). One window per distinct `serializeShadowRoot` value,
2592
+ * and renders sharing a window run one at a time.
2593
+ * Defaults to `false`, except in the `ssr-wasm` output target, where it defaults to `true`.
2594
+ */
2595
+ reuseWindow?: boolean;
2586
2596
  /**
2587
2597
  * Removes every `<script>` element found in the `document`. Defaults to `false`.
2588
2598
  */
@@ -2719,6 +2729,12 @@ interface SsrFactoryOptions extends SerializeDocumentOptions {
2719
2729
  serializeToHtml: boolean;
2720
2730
  destroyWindow: boolean;
2721
2731
  destroyDocument: boolean;
2732
+ /**
2733
+ * A canonical key for `serializeShadowRoot`, set by the renderer. Renders with the same key
2734
+ * render every component the same way, so they can share an SSR platform.
2735
+ * @internal
2736
+ */
2737
+ serializeShadowRootKey?: string;
2722
2738
  }
2723
2739
  /**
2724
2740
  * Backwards compat for v4
@@ -1413,6 +1413,16 @@ interface SsrDocumentOptions {
1413
1413
  * Sets `document.referrer`
1414
1414
  */
1415
1415
  referrer?: string;
1416
+ /**
1417
+ * Render into one long-lived mock window, reset between renders, instead of creating a new one
1418
+ * for every call. Skips evaluating the whole SSR platform (runtime and every component)
1419
+ * on each render: most of the cost of rendering a small fragment, and a good part of a whole page.
1420
+ *
1421
+ * Applies to HTML string input (not a `Document`). One window per distinct `serializeShadowRoot` value,
1422
+ * and renders sharing a window run one at a time.
1423
+ * Defaults to `false`, except in the `ssr-wasm` output target, where it defaults to `true`.
1424
+ */
1425
+ reuseWindow?: boolean;
1416
1426
  /**
1417
1427
  * Removes every `<script>` element found in the `document`. Defaults to `false`.
1418
1428
  */
@@ -1544,6 +1554,12 @@ interface SsrFactoryOptions extends SerializeDocumentOptions {
1544
1554
  serializeToHtml: boolean;
1545
1555
  destroyWindow: boolean;
1546
1556
  destroyDocument: boolean;
1557
+ /**
1558
+ * A canonical key for `serializeShadowRoot`, set by the renderer. Renders with the same key
1559
+ * render every component the same way, so they can share an SSR platform.
1560
+ * @internal
1561
+ */
1562
+ serializeShadowRootKey?: string;
1547
1563
  }
1548
1564
  //#endregion
1549
1565
  //#region src/declarations/stencil-private.d.ts
@@ -218,6 +218,16 @@ interface SsrDocumentOptions {
218
218
  * Sets `document.referrer`
219
219
  */
220
220
  referrer?: string;
221
+ /**
222
+ * Render into one long-lived mock window, reset between renders, instead of creating a new one
223
+ * for every call. Skips evaluating the whole SSR platform (runtime and every component)
224
+ * on each render: most of the cost of rendering a small fragment, and a good part of a whole page.
225
+ *
226
+ * Applies to HTML string input (not a `Document`). One window per distinct `serializeShadowRoot` value,
227
+ * and renders sharing a window run one at a time.
228
+ * Defaults to `false`, except in the `ssr-wasm` output target, where it defaults to `true`.
229
+ */
230
+ reuseWindow?: boolean;
221
231
  /**
222
232
  * Removes every `<script>` element found in the `document`. Defaults to `false`.
223
233
  */
@@ -349,6 +359,12 @@ interface SsrFactoryOptions extends SerializeDocumentOptions {
349
359
  serializeToHtml: boolean;
350
360
  destroyWindow: boolean;
351
361
  destroyDocument: boolean;
362
+ /**
363
+ * A canonical key for `serializeShadowRoot`, set by the renderer. Renders with the same key
364
+ * render every component the same way, so they can share an SSR platform.
365
+ * @internal
366
+ */
367
+ serializeShadowRootKey?: string;
352
368
  }
353
369
  interface Diagnostic {
354
370
  absFilePath?: string | undefined;
@@ -59,6 +59,16 @@ interface SsrDocumentOptions {
59
59
  * Sets `document.referrer`
60
60
  */
61
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;
62
72
  /**
63
73
  * Removes every `<script>` element found in the `document`. Defaults to `false`.
64
74
  */
@@ -190,6 +200,12 @@ interface SsrFactoryOptions extends SerializeDocumentOptions {
190
200
  serializeToHtml: boolean;
191
201
  destroyWindow: boolean;
192
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;
193
209
  }
194
210
  interface Diagnostic {
195
211
  absFilePath?: string | undefined;
@@ -300,6 +316,14 @@ declare function ssrDocument(doc: any | string, options?: SsrDocumentOptions): P
300
316
  declare const hydrateDocument: typeof ssrDocument;
301
317
  declare function serializeDocumentToString(doc: Document, opts: SsrFactoryOptions): string;
302
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
303
327
  //#region src/server/runner/window-initialize.d.ts
304
328
  /**
305
329
  * Restart the hydration ids used by fragment renders (`fullDocument: false`).
@@ -324,4 +348,18 @@ declare function transformTag<T extends string>(tag: T): T;
324
348
  */
325
349
  declare function setTagTransformer(transformer: TagTransformer): void;
326
350
  //#endregion
327
- export { createWindowFromHtml, hydrateDocument, renderToString, resetSsrDocData, serializeDocumentToString, setTagTransformer, ssrDocument, 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 };
@@ -11910,6 +11910,77 @@ function constrainTimeouts(win) {
11910
11910
  win.__allowInterval = false;
11911
11911
  win.__maxTimeout = 0;
11912
11912
  }
11913
+ /**
11914
+ * Reset a window so the same object can be used for another render, then parse `html` into its
11915
+ * document.
11916
+ *
11917
+ * Code that captured the window's sub-objects (e.g. an SSR platform holding `win.location`,
11918
+ * `win.console` or `win.document`) keeps working: those objects are kept and reset in place,
11919
+ * rather than replaced. Everything else on the window - including anything a previous render
11920
+ * added - is removed.
11921
+ * @param win the window to reset
11922
+ * @param html the HTML for the next render
11923
+ */
11924
+ function resetWindowForReuse(win, html) {
11925
+ const retained = {
11926
+ console: win.console,
11927
+ document: win.document,
11928
+ eventCounts: win.performance.eventCounts,
11929
+ history: win.history,
11930
+ localStorage: win.localStorage,
11931
+ location: win.location,
11932
+ navigator: win.navigator,
11933
+ orientation: win.screen.orientation,
11934
+ performance: win.performance,
11935
+ screen: win.screen,
11936
+ sessionStorage: win.sessionStorage
11937
+ };
11938
+ if (win.__timeouts) win.__timeouts.forEach((timeoutId) => {
11939
+ nativeClearInterval(timeoutId);
11940
+ nativeClearTimeout(timeoutId);
11941
+ });
11942
+ resetObject(retained.console, createConsole());
11943
+ resetObject(retained.history, new MockHistory());
11944
+ resetObject(retained.location, new MockLocation());
11945
+ resetObject(retained.navigator, new MockNavigator());
11946
+ retained.localStorage.clear();
11947
+ retained.sessionStorage.clear();
11948
+ retained.eventCounts.clear();
11949
+ resetObject(retained.performance, {
11950
+ eventCounts: retained.eventCounts,
11951
+ interactionCount: 0,
11952
+ timeOrigin: Date.now()
11953
+ });
11954
+ for (const key of Reflect.ownKeys(win)) delete win[key];
11955
+ resetWindowDefaults(win);
11956
+ resetWindowDimensions(win);
11957
+ const defaultScreen = win.screen;
11958
+ resetObject(retained.orientation, defaultScreen.orientation);
11959
+ resetObject(retained.screen, {
11960
+ ...defaultScreen,
11961
+ orientation: retained.orientation
11962
+ });
11963
+ win.console = retained.console;
11964
+ win.customElements = null;
11965
+ win.document = retained.document;
11966
+ win.history = retained.history;
11967
+ win.localStorage = retained.localStorage;
11968
+ win.location = retained.location;
11969
+ win.navigator = retained.navigator;
11970
+ win.performance = retained.performance;
11971
+ win.screen = retained.screen;
11972
+ win.sessionStorage = retained.sessionStorage;
11973
+ resetDocumentForReuse(retained.document, win, html);
11974
+ }
11975
+ /**
11976
+ * Replace every own property of `target` with those of `defaults`, keeping the object itself.
11977
+ * @param target the object to reset in place
11978
+ * @param defaults the properties it should have afterwards
11979
+ */
11980
+ function resetObject(target, defaults) {
11981
+ for (const key of Reflect.ownKeys(target)) delete target[key];
11982
+ Object.assign(target, defaults);
11983
+ }
11913
11984
  function resetWindow(win) {
11914
11985
  if (win != null) {
11915
11986
  if (win.__timeouts) {
@@ -12210,6 +12281,37 @@ function resetDocument(doc) {
12210
12281
  } catch {}
12211
12282
  }
12212
12283
  }
12284
+ /**
12285
+ * Reset a document so the same object can be used for another render, then parse `html` into
12286
+ * it. The document object itself is kept (code holding a reference to it stays valid), but its
12287
+ * whole element tree is replaced with freshly parsed elements - so caches keyed on elements, like
12288
+ * the runtime's applied-styles cache keyed on `<head>`, start empty.
12289
+ * @param doc the document to reset
12290
+ * @param win the window that owns the document
12291
+ * @param html the HTML to parse into the document
12292
+ */
12293
+ function resetDocumentForReuse(doc, win, html) {
12294
+ resetDocument(doc);
12295
+ for (const key of Reflect.ownKeys(doc)) if (typeof key !== "string" || !REUSABLE_DOC_KEY_KEEPERS.has(key)) delete doc[key];
12296
+ doc.defaultView = win;
12297
+ doc.documentElement = parseDocumentUtil(doc, html).documentElement;
12298
+ }
12299
+ /** Structural document properties kept by {@link resetDocumentForReuse}; everything else is per-render state. */
12300
+ const REUSABLE_DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
12301
+ "_nodeValue",
12302
+ "nodeName",
12303
+ "nodeType",
12304
+ "ownerDocument",
12305
+ "parentNode",
12306
+ "_childNodes",
12307
+ "__namespaceURI",
12308
+ "__localName",
12309
+ "defaultView",
12310
+ "cookie",
12311
+ "referrer",
12312
+ "compatMode",
12313
+ "contentType"
12314
+ ]);
12213
12315
  const DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
12214
12316
  "nodeName",
12215
12317
  "nodeType",
@@ -13360,6 +13462,90 @@ function renderCatchError(results, err) {
13360
13462
  return diagnostic;
13361
13463
  }
13362
13464
  //#endregion
13465
+ //#region src/server/runner/reusable-window.ts
13466
+ /**
13467
+ * A canonical key for a `serializeShadowRoot` value: values that render every component the same
13468
+ * way get the same key.
13469
+ *
13470
+ * Rendering shadow components as scoped permanently changes their metadata inside the SSR platform
13471
+ * that rendered them, so a platform (and a reusable window) can only be shared by renders whose
13472
+ * `serializeShadowRoot` marks the same components as scoped. Which components that is depends
13473
+ * only on this value: for the object form, on `default` and the two tag lists - so those are
13474
+ * normalized (lowercased, de-duplicated, sorted) to give equivalent objects one key.
13475
+ * @param serializeShadowRoot the render's `serializeShadowRoot` option
13476
+ * @returns the key
13477
+ */
13478
+ function serializeShadowRootKey(serializeShadowRoot) {
13479
+ if (serializeShadowRoot === null || typeof serializeShadowRoot !== "object") return `${typeof serializeShadowRoot}:${serializeShadowRoot}`;
13480
+ const opts = serializeShadowRoot;
13481
+ const tags = (list) => Array.isArray(list) ? [...new Set(list.map((tag) => String(tag).toLowerCase()))].sort().join(",") : "";
13482
+ return `object:default=${opts.default};dsd=${tags(opts["declarative-shadow-dom"])};scoped=${tags(opts.scoped)}`;
13483
+ }
13484
+ /** The most reusable windows kept at once (one per distinct `serializeShadowRoot` key). */
13485
+ const MAX_REUSABLE_WINDOWS = 16;
13486
+ /** Long-lived windows used by `reuseWindow` renders, by `serializeShadowRoot` key. */
13487
+ const reusableWindows = /* @__PURE__ */ new Map();
13488
+ /** Renders sharing a reusable window must not overlap, so each key has a queue. */
13489
+ const renderQueues = /* @__PURE__ */ new Map();
13490
+ const NOOP$1 = () => {};
13491
+ /**
13492
+ * Run `render` once every earlier render using the same reusable window has finished.
13493
+ * @param key the render's {@link serializeShadowRootKey}
13494
+ * @param render the render to run
13495
+ * @returns the render's result
13496
+ */
13497
+ function enqueueReusableRender(key, render) {
13498
+ const queued = (renderQueues.get(key) ?? Promise.resolve()).then(render, render);
13499
+ renderQueues.set(key, queued.then(NOOP$1, NOOP$1));
13500
+ return queued;
13501
+ }
13502
+ /**
13503
+ * Get the reusable window for a `serializeShadowRoot` key, reset and holding `html`.
13504
+ * @param html the HTML to render
13505
+ * @param key the render's {@link serializeShadowRootKey}
13506
+ * @returns the window to render into
13507
+ */
13508
+ function getReusableWindow(html, key) {
13509
+ let win = reusableWindows.get(key);
13510
+ if (!win) {
13511
+ if (reusableWindows.size >= MAX_REUSABLE_WINDOWS) reusableWindows.delete(reusableWindows.keys().next().value);
13512
+ win = new MockWindow(html);
13513
+ reusableWindows.set(key, win);
13514
+ return win;
13515
+ }
13516
+ try {
13517
+ resetWindowForReuse(win, html);
13518
+ return win;
13519
+ } catch (e) {
13520
+ discardReusableWindow(key);
13521
+ throw e;
13522
+ }
13523
+ }
13524
+ /**
13525
+ * Stop reusing the window for a key, e.g. after a render failed and may have left it in a bad
13526
+ * state. The next render with that key creates a new one.
13527
+ * @param key the render's {@link serializeShadowRootKey}
13528
+ */
13529
+ function discardReusableWindow(key) {
13530
+ const win = reusableWindows.get(key);
13531
+ reusableWindows.delete(key);
13532
+ try {
13533
+ win?.close();
13534
+ } catch {}
13535
+ }
13536
+ /**
13537
+ * Drop every reusable window and render queue. For hosts where a render can be abandoned without
13538
+ * ever settling (the `ssr-wasm` plugin, when a call ends with a render still waiting), so the
13539
+ * next render doesn't queue behind it forever.
13540
+ */
13541
+ function resetReusableWindows() {
13542
+ for (const win of reusableWindows.values()) try {
13543
+ win.close();
13544
+ } catch {}
13545
+ reusableWindows.clear();
13546
+ renderQueues.clear();
13547
+ }
13548
+ //#endregion
13363
13549
  //#region src/server/runner/runtime-log.ts
13364
13550
  function runtimeLogging(win, opts, results) {
13365
13551
  try {
@@ -13464,6 +13650,29 @@ function initializeWindow(win, doc, opts, results) {
13464
13650
  //#region src/server/runner/render.ts
13465
13651
  const NOOP = () => {};
13466
13652
  /**
13653
+ * Render into the long-lived window for this render's `serializeShadowRoot` mode, once any
13654
+ * earlier render using that window has finished. See the `reuseWindow` option.
13655
+ * @param html the HTML to render
13656
+ * @param opts the normalized render options
13657
+ * @param results the results object to fill in
13658
+ * @returns the render results
13659
+ */
13660
+ function renderInReusableWindow(html, opts, results) {
13661
+ opts.destroyWindow = false;
13662
+ opts.destroyDocument = false;
13663
+ const key = opts.serializeShadowRootKey;
13664
+ const run = async () => {
13665
+ try {
13666
+ await render(getReusableWindow(html, key), opts, results);
13667
+ } catch (e) {
13668
+ discardReusableWindow(key);
13669
+ renderCatchError(results, e);
13670
+ }
13671
+ return results;
13672
+ };
13673
+ return enqueueReusableRender(key, run);
13674
+ }
13675
+ /**
13467
13676
  * Renders HTML to a string, returning the full hydration results.
13468
13677
  * This is the primary SSR function and is portable (no Node.js dependencies).
13469
13678
  * @param html - the HTML string or document to render
@@ -13516,9 +13725,11 @@ function ssrDocument(doc, options) {
13516
13725
  * Defines whether we render the shadow root as a declarative shadow root or as scoped shadow root.
13517
13726
  */
13518
13727
  opts.serializeShadowRoot = typeof opts.serializeShadowRoot === "undefined" ? "declarative-shadow-dom" : opts.serializeShadowRoot;
13728
+ opts.serializeShadowRootKey = serializeShadowRootKey(opts.serializeShadowRoot);
13519
13729
  let win = null;
13520
13730
  const results = generateHydrateResults(opts);
13521
13731
  if (hasError(results.diagnostics)) return Promise.resolve(results);
13732
+ if (typeof doc === "string" && opts.reuseWindow) return renderInReusableWindow(doc, opts, results);
13522
13733
  if (typeof doc === "string") try {
13523
13734
  opts.destroyWindow = true;
13524
13735
  opts.destroyDocument = true;
@@ -13682,4 +13893,21 @@ function removeScripts(elm) {
13682
13893
  }
13683
13894
  }
13684
13895
  //#endregion
13685
- export { createWindowFromHtml, hydrateDocument, renderToString, resetSsrDocData, serializeDocumentToString, setTagTransformer, ssrDocument, streamToString, transformTag };
13896
+ //#region src/server/runner/index.ts
13897
+ /**
13898
+ * Render components under transformed tag names, to match tag transformation on the client.
13899
+ *
13900
+ * Components are registered under their transformed names when a window's SSR platform is set up,
13901
+ * so this also discards the reusable windows (see the `reuseWindow` option): later renders set up
13902
+ * new ones that use the new transformer.
13903
+ *
13904
+ * (A function declaration with its own name, so the runtime's `setTagTransformer` keeps its name in
13905
+ * the bundle - the SSR build looks for it - and this is hoisted.)
13906
+ * @param transformer the tag transformer
13907
+ */
13908
+ function setTagTransformerForSsr(transformer) {
13909
+ setTagTransformer(transformer);
13910
+ resetReusableWindows();
13911
+ }
13912
+ //#endregion
13913
+ export { createWindowFromHtml, hydrateDocument, renderToString, resetReusableWindows, resetSsrDocData, serializeDocumentToString, setTagTransformerForSsr as setTagTransformer, ssrDocument, streamToString, transformTag };
@@ -1,4 +1,4 @@
1
- import { Bt as Logger, nt as CompilerSystem } from "../../index-B0NfYeIA.mjs";
1
+ import { Bt as Logger, nt as CompilerSystem } from "../../index-DG4wtfhx.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,4 +1,4 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-CVL510L-.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-BpfMxpfR.mjs";
2
2
  import { t as createNodeSys } from "../../node-eg7pofz5.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
@@ -33,7 +33,7 @@ import "@rollup/pluginutils";
33
33
  import { createHash } from "crypto";
34
34
  import { afterAll, vi } from "vitest";
35
35
  //#region src/version.ts
36
- const version = "5.0.0-beta.34";
36
+ const version = "5.0.0-beta.35";
37
37
  const MEMBER_FLAGS = {
38
38
  String: 1,
39
39
  Number: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-beta.34",
3
+ "version": "5.0.0-beta.35",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -126,9 +126,9 @@
126
126
  "terser": "^5.50.0",
127
127
  "tinyglobby": "^0.2.17",
128
128
  "typescript": ">5.0.0 <7.0.0",
129
- "@stencil/cli": "5.0.0-beta.34",
130
- "@stencil/dev-server": "5.0.0-beta.34",
131
- "@stencil/mock-doc": "5.0.0-beta.34"
129
+ "@stencil/cli": "5.0.0-beta.35",
130
+ "@stencil/dev-server": "5.0.0-beta.35",
131
+ "@stencil/mock-doc": "5.0.0-beta.35"
132
132
  },
133
133
  "devDependencies": {
134
134
  "@ionic/prettier-config": "^4.0.0",