@stencil/core 5.0.0-beta.33 → 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.
@@ -1057,6 +1057,7 @@ let hostTagName;
1057
1057
  let hostRegistry;
1058
1058
  let useNativeShadowDom = false;
1059
1059
  let checkSlotFallbackVisibility = false;
1060
+ /** Whether the current render has slotted content to relocate. Set at the start of each render. */
1060
1061
  let checkSlotRelocate = false;
1061
1062
  let isSvgMode = false;
1062
1063
  /**
@@ -1616,6 +1617,7 @@ const flushQueuedRefCallbacks = () => {
1616
1617
  */
1617
1618
  const insertBefore = (parent, newNode, reference, isInitialLoad) => {
1618
1619
  if (BUILD.slotRelocation) {
1620
+ if (parent?.["s-cr"]) checkSlotRelocate = true;
1619
1621
  if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
1620
1622
  else if (typeof newNode["s-sn"] === "string") {
1621
1623
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
@@ -1718,6 +1720,7 @@ render() {
1718
1720
  if (BUILD.slotRelocation) {
1719
1721
  contentRef = hostElm["s-cr"];
1720
1722
  checkSlotFallbackVisibility = false;
1723
+ checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
1721
1724
  }
1722
1725
  patch(oldVNode, rootVnode, isInitialLoad);
1723
1726
  if (BUILD.slotRelocation) {
@@ -1787,7 +1790,7 @@ render() {
1787
1790
  nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
1788
1791
  }
1789
1792
  }
1790
- if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
1793
+ if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
1791
1794
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1792
1795
  for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
1793
1796
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
@@ -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.33";
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-BY98wn8T.mjs";
2
- import { a as LOG_LEVELS, i as CustomElementsExportBehaviorOptions } from "../node-CPevTsN9.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
+ 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.
@@ -1,9 +1,9 @@
1
1
  import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import { E as SERVER_BUILD_FLAGS, T as HYDRATED_CSS, w as CLIENT_BUILD_FLAGS } from "./client-DIvBaMnB.mjs";
2
+ import { E as SERVER_BUILD_FLAGS, T as HYDRATED_CSS, w as CLIENT_BUILD_FLAGS } from "./client-UbH-XkYu.mjs";
3
3
  import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, E as COLLECTION_MANIFEST_FILE_NAME, J as STANDALONE, L as EVENT_FLAGS, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, T as COLLECTION_APP_DATA_FILE_NAME, U as LOADER_BUNDLE, X as STYLE_EXT, Y as STATS, a as isBoolean$1, b as unique, c as isFunction, d as isObject, et as WATCH_FLAGS, f as isString$1, g as sortBy, i as fromEntries, l as isIterable, m as noop, p as mergeIntoWith, r as flatOne, t as dashToPascalCase, u as isNumber$1, v as toDashCase, w as COLLECTION, y as toTitleCase, z as GLOBAL_STYLE } from "./helpers-Cpp3qc3u.mjs";
4
4
  import { E as escapeRegExpSpecialCharacters, S as formatComponentRuntimeMeta, T as byteSize, _ as loadRolldownDiagnostics, a as getSourceMappingUrlForEndOfFile, b as splitLineBreaks, c as err, f as augmentDiagnosticWithNode, g as isRolldownError, h as createOnWarnFn, i as getInlineSourceMappingUrlLinker, l as map, m as loadTypeScriptDiagnostics, n as validateComponentTag, p as loadTypeScriptDiagnostic, r as isRemoteUrl, s as rolldownToStencilSourceMap, t as validateComponentModes, u as ok, w as stringifyRuntimeData, x as isRootPath, y as normalizeDiagnostics } from "./validation-BlVm1Vu0.mjs";
5
5
  import { $ as buildWarn, A as isOutputTargetDocsVscode, B as isValidConfigOutputTarget, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetSsrWasm, G as normalizeFsPath, H as shouldExcludeComponent, I as isOutputTargetStandalone, J as relative$1, K as normalizeFsPathQuery, L as isOutputTargetStats, M as isOutputTargetLoaderBundle, N as isOutputTargetServerRenderer, O as isOutputTargetDocsJson, P as isOutputTargetSsr, Q as buildJsonFileError, R as isOutputTargetTypes, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, U as join$2, V as relativeImport, Y as resolve$2, Z as buildError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as catchError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, it as isGlob, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, nt as hasWarning, o as isDtsFile, p as readPackageJson, q as normalizePath, r as generatePreamble, t as addDocBlock, tt as hasError, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isOutputTargetWww } from "./util-C-H1H84W.mjs";
6
- import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-CPevTsN9.mjs";
6
+ import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-eg7pofz5.mjs";
7
7
  import ts, { default as ts$1 } from "typescript";
8
8
  import { readFileSync } from "node:fs";
9
9
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -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.33";
465
- const buildId = "1793922003";
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
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Build, S as setErrorHandler, _ as getAssetPath, a as transformTag, b as writeTask, c as Mixin, d as Host, f as h, g as getShadowRoot, h as getElement, i as setTagTransformer, l as getMode, m as getRenderingRef, o as render, p as forceUpdate, s as ReactiveControllerHost, u as setMode, v as setAssetPath, x as setPlatformHelpers, y as readTask } from "./client-DIvBaMnB.mjs";
1
+ import { C as Build, S as setErrorHandler, _ as getAssetPath, a as transformTag, b as writeTask, c as Mixin, d as Host, f as h, g as getShadowRoot, h as getElement, i as setTagTransformer, l as getMode, m as getRenderingRef, o as render, p as forceUpdate, s as ReactiveControllerHost, u as setMode, v as setAssetPath, x as setPlatformHelpers, y as readTask } from "./client-UbH-XkYu.mjs";
2
2
  import { t as Fragment } from "./fragment-Di1hWOC8.mjs";
3
3
  //#region src/client/client-decorators.ts
4
4
  /**
@@ -1,3 +1,3 @@
1
- import { n as jsxDEV, r as jsxs, t as jsx } from "./client-DIvBaMnB.mjs";
1
+ import { n as jsxDEV, r as jsxs, t as jsx } from "./client-UbH-XkYu.mjs";
2
2
  import { t as Fragment } from "./fragment-Di1hWOC8.mjs";
3
3
  export { Fragment, jsx, jsxDEV, jsxs };
@@ -1,5 +1,5 @@
1
1
  import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import "./client-DIvBaMnB.mjs";
2
+ import "./client-UbH-XkYu.mjs";
3
3
  import { c as isFunction, f as isString, m as noop, r as flatOne } from "./helpers-Cpp3qc3u.mjs";
4
4
  import { X as TASK_CANCELED_MSG, Z as buildError, et as catchError, it as isGlob, q as normalizePath, rt as shouldIgnoreError } from "./util-C-H1H84W.mjs";
5
5
  import fs from "node:fs";
@@ -2039,6 +2039,7 @@ let hostTagName;
2039
2039
  let hostRegistry;
2040
2040
  let useNativeShadowDom = false;
2041
2041
  let checkSlotFallbackVisibility = false;
2042
+ /** Whether the current render has slotted content to relocate. Set at the start of each render. */
2042
2043
  let checkSlotRelocate = false;
2043
2044
  let isSvgMode = false;
2044
2045
  /**
@@ -2598,6 +2599,7 @@ const flushQueuedRefCallbacks = () => {
2598
2599
  */
2599
2600
  const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2600
2601
  if (BUILD.slotRelocation) {
2602
+ if (parent?.["s-cr"]) checkSlotRelocate = true;
2601
2603
  if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2602
2604
  else if (typeof newNode["s-sn"] === "string") {
2603
2605
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
@@ -2700,6 +2702,7 @@ render() {
2700
2702
  if (BUILD.slotRelocation) {
2701
2703
  contentRef = hostElm["s-cr"];
2702
2704
  checkSlotFallbackVisibility = false;
2705
+ checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
2703
2706
  }
2704
2707
  patch(oldVNode, rootVnode, isInitialLoad);
2705
2708
  if (BUILD.slotRelocation) {
@@ -2769,7 +2772,7 @@ render() {
2769
2772
  nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
2770
2773
  }
2771
2774
  }
2772
- if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2775
+ if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2773
2776
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2774
2777
  for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2775
2778
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
@@ -3463,7 +3466,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3463
3466
  const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
3464
3467
  const node = childRenderNode.$elm$;
3465
3468
  if (!shadowRoot) {
3466
- node["s-hn"] = transformTag(tagName).toUpperCase();
3469
+ if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
3467
3470
  if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
3468
3471
  } else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
3469
3472
  const cmpMeta = getHostRef(childRenderNode.$elm$);
@@ -3513,11 +3516,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3513
3516
  const siSlot = slottedItem.slot;
3514
3517
  if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
3515
3518
  if (!hostEle.shadowRoot || !shadowRoot) {
3516
- if (!siSlot["s-cr"]) {
3517
- siSlot["s-cr"] = hostEle["s-cr"];
3518
- if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
3519
- else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
3520
- }
3519
+ if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
3521
3520
  addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
3522
3521
  if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
3523
3522
  if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
@@ -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
@@ -2033,6 +2033,7 @@ let hostTagName;
2033
2033
  let hostRegistry;
2034
2034
  let useNativeShadowDom = false;
2035
2035
  let checkSlotFallbackVisibility = false;
2036
+ /** Whether the current render has slotted content to relocate. Set at the start of each render. */
2036
2037
  let checkSlotRelocate = false;
2037
2038
  let isSvgMode = false;
2038
2039
  /**
@@ -2592,6 +2593,7 @@ const flushQueuedRefCallbacks = () => {
2592
2593
  */
2593
2594
  const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2594
2595
  if (BUILD$1.slotRelocation) {
2596
+ if (parent?.["s-cr"]) checkSlotRelocate = true;
2595
2597
  if (BUILD$1.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2596
2598
  else if (typeof newNode["s-sn"] === "string") {
2597
2599
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
@@ -2694,6 +2696,7 @@ render() {
2694
2696
  if (BUILD$1.slotRelocation) {
2695
2697
  contentRef = hostElm["s-cr"];
2696
2698
  checkSlotFallbackVisibility = false;
2699
+ checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
2697
2700
  }
2698
2701
  patch(oldVNode, rootVnode, isInitialLoad);
2699
2702
  if (BUILD$1.slotRelocation) {
@@ -2763,7 +2766,7 @@ render() {
2763
2766
  nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
2764
2767
  }
2765
2768
  }
2766
- if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2769
+ if (BUILD$1.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2767
2770
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2768
2771
  for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2769
2772
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
@@ -3457,7 +3460,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3457
3460
  const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
3458
3461
  const node = childRenderNode.$elm$;
3459
3462
  if (!shadowRoot) {
3460
- node["s-hn"] = transformTag(tagName).toUpperCase();
3463
+ if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
3461
3464
  if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
3462
3465
  } else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
3463
3466
  const cmpMeta = getHostRef(childRenderNode.$elm$);
@@ -3507,11 +3510,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3507
3510
  const siSlot = slottedItem.slot;
3508
3511
  if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
3509
3512
  if (!hostEle.shadowRoot || !shadowRoot) {
3510
- if (!siSlot["s-cr"]) {
3511
- siSlot["s-cr"] = hostEle["s-cr"];
3512
- if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
3513
- else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
3514
- }
3513
+ if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
3515
3514
  addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
3516
3515
  if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
3517
3516
  if (BUILD$1.lightDomPatches || BUILD$1.slotChildNodes || BUILD$1.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
@@ -1905,6 +1905,7 @@ let hostTagName;
1905
1905
  let hostRegistry;
1906
1906
  let useNativeShadowDom = false;
1907
1907
  let checkSlotFallbackVisibility = false;
1908
+ /** Whether the current render has slotted content to relocate. Set at the start of each render. */
1908
1909
  let checkSlotRelocate = false;
1909
1910
  let isSvgMode = false;
1910
1911
  /**
@@ -2464,6 +2465,7 @@ const flushQueuedRefCallbacks = () => {
2464
2465
  */
2465
2466
  const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2466
2467
  if (BUILD.slotRelocation) {
2468
+ if (parent?.["s-cr"]) checkSlotRelocate = true;
2467
2469
  if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2468
2470
  else if (typeof newNode["s-sn"] === "string") {
2469
2471
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
@@ -2566,6 +2568,7 @@ render() {
2566
2568
  if (BUILD.slotRelocation) {
2567
2569
  contentRef = hostElm["s-cr"];
2568
2570
  checkSlotFallbackVisibility = false;
2571
+ checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
2569
2572
  }
2570
2573
  patch(oldVNode, rootVnode, isInitialLoad);
2571
2574
  if (BUILD.slotRelocation) {
@@ -2635,7 +2638,7 @@ render() {
2635
2638
  nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
2636
2639
  }
2637
2640
  }
2638
- if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2641
+ if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2639
2642
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2640
2643
  for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2641
2644
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
@@ -3329,7 +3332,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3329
3332
  const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
3330
3333
  const node = childRenderNode.$elm$;
3331
3334
  if (!shadowRoot) {
3332
- node["s-hn"] = transformTag(tagName).toUpperCase();
3335
+ if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
3333
3336
  if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
3334
3337
  } else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
3335
3338
  const cmpMeta = getHostRef(childRenderNode.$elm$);
@@ -3379,11 +3382,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3379
3382
  const siSlot = slottedItem.slot;
3380
3383
  if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
3381
3384
  if (!hostEle.shadowRoot || !shadowRoot) {
3382
- if (!siSlot["s-cr"]) {
3383
- siSlot["s-cr"] = hostEle["s-cr"];
3384
- if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
3385
- else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
3386
- }
3385
+ if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
3387
3386
  addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
3388
3387
  if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
3389
3388
  if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
@@ -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;
@@ -1669,6 +1669,7 @@ let hostTagName;
1669
1669
  let hostRegistry;
1670
1670
  let useNativeShadowDom = false;
1671
1671
  let checkSlotFallbackVisibility = false;
1672
+ /** Whether the current render has slotted content to relocate. Set at the start of each render. */
1672
1673
  let checkSlotRelocate = false;
1673
1674
  let isSvgMode = false;
1674
1675
  /**
@@ -2228,6 +2229,7 @@ const flushQueuedRefCallbacks = () => {
2228
2229
  */
2229
2230
  const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2230
2231
  if (BUILD$1.slotRelocation) {
2232
+ if (parent?.["s-cr"]) checkSlotRelocate = true;
2231
2233
  if (BUILD$1.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2232
2234
  else if (typeof newNode["s-sn"] === "string") {
2233
2235
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
@@ -2330,6 +2332,7 @@ render() {
2330
2332
  if (BUILD$1.slotRelocation) {
2331
2333
  contentRef = hostElm["s-cr"];
2332
2334
  checkSlotFallbackVisibility = false;
2335
+ checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
2333
2336
  }
2334
2337
  patch(oldVNode, rootVnode, isInitialLoad);
2335
2338
  if (BUILD$1.slotRelocation) {
@@ -2399,7 +2402,7 @@ render() {
2399
2402
  nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
2400
2403
  }
2401
2404
  }
2402
- if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2405
+ if (BUILD$1.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2403
2406
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2404
2407
  for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2405
2408
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
@@ -3091,7 +3094,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3091
3094
  const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
3092
3095
  const node = childRenderNode.$elm$;
3093
3096
  if (!shadowRoot) {
3094
- node["s-hn"] = transformTag(tagName).toUpperCase();
3097
+ if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
3095
3098
  if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
3096
3099
  } else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
3097
3100
  const cmpMeta = getHostRef(childRenderNode.$elm$);
@@ -3141,11 +3144,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3141
3144
  const siSlot = slottedItem.slot;
3142
3145
  if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
3143
3146
  if (!hostEle.shadowRoot || !shadowRoot) {
3144
- if (!siSlot["s-cr"]) {
3145
- siSlot["s-cr"] = hostEle["s-cr"];
3146
- if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
3147
- else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
3148
- }
3147
+ if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
3149
3148
  addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
3150
3149
  if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
3151
3150
  if (BUILD$1.lightDomPatches || BUILD$1.slotChildNodes || BUILD$1.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
@@ -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,2 +1,2 @@
1
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-CPevTsN9.mjs";
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-eg7pofz5.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-BY98wn8T.mjs";
2
- import { t as createNodeSys } from "../../node-CPevTsN9.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-BpfMxpfR.mjs";
2
+ import { t as createNodeSys } from "../../node-eg7pofz5.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
5
5
  * Initialize a worker thread, setting up various machinery for managing
@@ -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.33";
36
+ const version = "5.0.0-beta.35";
37
37
  const MEMBER_FLAGS = {
38
38
  String: 1,
39
39
  Number: 2,
@@ -2424,6 +2424,7 @@ let hostTagName;
2424
2424
  let hostRegistry;
2425
2425
  let useNativeShadowDom = false;
2426
2426
  let checkSlotFallbackVisibility = false;
2427
+ /** Whether the current render has slotted content to relocate. Set at the start of each render. */
2427
2428
  let checkSlotRelocate = false;
2428
2429
  let isSvgMode = false;
2429
2430
  /**
@@ -2983,6 +2984,7 @@ const flushQueuedRefCallbacks = () => {
2983
2984
  */
2984
2985
  const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2985
2986
  if (BUILD.slotRelocation) {
2987
+ if (parent?.["s-cr"]) checkSlotRelocate = true;
2986
2988
  if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2987
2989
  else if (typeof newNode["s-sn"] === "string") {
2988
2990
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
@@ -3085,6 +3087,7 @@ render() {
3085
3087
  if (BUILD.slotRelocation) {
3086
3088
  contentRef = hostElm["s-cr"];
3087
3089
  checkSlotFallbackVisibility = false;
3090
+ checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
3088
3091
  }
3089
3092
  patch(oldVNode, rootVnode, isInitialLoad);
3090
3093
  if (BUILD.slotRelocation) {
@@ -3154,7 +3157,7 @@ render() {
3154
3157
  nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
3155
3158
  }
3156
3159
  }
3157
- if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
3160
+ if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
3158
3161
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
3159
3162
  for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
3160
3163
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
@@ -3848,7 +3851,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3848
3851
  const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
3849
3852
  const node = childRenderNode.$elm$;
3850
3853
  if (!shadowRoot) {
3851
- node["s-hn"] = transformTag(tagName).toUpperCase();
3854
+ if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
3852
3855
  if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
3853
3856
  } else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
3854
3857
  const cmpMeta = getHostRef(childRenderNode.$elm$);
@@ -3898,11 +3901,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3898
3901
  const siSlot = slottedItem.slot;
3899
3902
  if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
3900
3903
  if (!hostEle.shadowRoot || !shadowRoot) {
3901
- if (!siSlot["s-cr"]) {
3902
- siSlot["s-cr"] = hostEle["s-cr"];
3903
- if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
3904
- else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
3905
- }
3904
+ if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
3906
3905
  addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
3907
3906
  if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
3908
3907
  if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-beta.33",
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.33",
130
- "@stencil/dev-server": "5.0.0-beta.33",
131
- "@stencil/mock-doc": "5.0.0-beta.33"
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",