@markless/bundler 0.5.0 → 0.7.0

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.
@@ -3,6 +3,9 @@ import { joinURL } from "ufo";
3
3
  const MARKLESS_DEV_ERROR_EVENT = "markless:dev-error";
4
4
  const MARKLESS_DEV_ERROR_CLEAR_EVENT = "markless:dev-error-clear";
5
5
  const MARKLESS_DEV_ERROR_CLIENT_ID = "virtual:markless:dev-error-client";
6
+ const MARKLESS_DEV_RELOADS_EVENT = "markless:dev-reloads";
7
+ const MARKLESS_DEV_RELOADS_ATTRIBUTE = "data-markless-dev-reloads";
8
+ const MARKLESS_DEV_PAGE_EDIT_EVENT = "markless:dev-page-edit";
6
9
  const PLUGIN_CODE_KIND = "markless-dev-error";
7
10
  const PLUGIN_CODE_VERSION = 1;
8
11
  var MarklessCompileError = class extends Error {
@@ -171,4 +174,4 @@ const documentStyles = `
171
174
  .panel{width:min(60rem,100%);padding:clamp(1.25rem,3vw,2.5rem);border:1px solid color-mix(in srgb,CanvasText 20%,transparent);border-top:4px solid #c9362b;border-radius:.5rem;background:Canvas;box-shadow:0 1rem 3rem #0002}
172
175
  header{display:flex;flex-direction:column;gap:.6rem;margin-bottom:1rem}.badge{align-self:flex-start;padding:.15rem .45rem;border-radius:.25rem;background:color-mix(in srgb,#c9362b 14%,Canvas);color:#c9362b;font:600 .75rem ui-monospace,monospace}h1{margin:0;font-size:clamp(1.4rem,3vw,2rem);line-height:1.2}h2{margin:1rem 0 .25rem;font-size:.8rem;text-transform:uppercase;letter-spacing:.06em;color:color-mix(in srgb,CanvasText 65%,transparent)}p{margin:.3rem 0 1rem;line-height:1.55}a{color:LinkText}.location{display:inline-block;margin-bottom:.5rem;font:500 .9rem ui-monospace,monospace}.frame,details pre{overflow:auto;padding:1rem;border-radius:.35rem;background:color-mix(in srgb,CanvasText 7%,Canvas);font: .85rem/1.55 ui-monospace,monospace;white-space:pre}details{margin-top:1rem;border-top:1px solid color-mix(in srgb,CanvasText 15%,transparent);padding-top:1rem}summary{cursor:pointer;font-weight:600}.recovery{margin:1.5rem 0 0;color:color-mix(in srgb,CanvasText 65%,transparent);font-size:.9rem}`;
173
176
  //#endregion
174
- export { createCompileErrorPayload as a, renderMarklessDevErrorDocument as c, MarklessCompileError as i, renderMarklessDevErrorPlainText as l, MARKLESS_DEV_ERROR_CLIENT_ID as n, formatMarklessSourceFrame as o, MARKLESS_DEV_ERROR_EVENT as r, normalizeMarklessDevError as s, MARKLESS_DEV_ERROR_CLEAR_EVENT as t, serializeMarklessDevError as u };
177
+ export { MARKLESS_DEV_RELOADS_ATTRIBUTE as a, createCompileErrorPayload as c, renderMarklessDevErrorDocument as d, renderMarklessDevErrorPlainText as f, MARKLESS_DEV_PAGE_EDIT_EVENT as i, formatMarklessSourceFrame as l, MARKLESS_DEV_ERROR_CLIENT_ID as n, MARKLESS_DEV_RELOADS_EVENT as o, serializeMarklessDevError as p, MARKLESS_DEV_ERROR_EVENT as r, MarklessCompileError as s, MARKLESS_DEV_ERROR_CLEAR_EVENT as t, normalizeMarklessDevError as u };
@@ -3,6 +3,9 @@ import { CompilerDiagnostic, SourceSpan } from "@markless/compiler";
3
3
  export declare const MARKLESS_DEV_ERROR_EVENT = "markless:dev-error";
4
4
  export declare const MARKLESS_DEV_ERROR_CLEAR_EVENT = "markless:dev-error-clear";
5
5
  export declare const MARKLESS_DEV_ERROR_CLIENT_ID = "virtual:markless:dev-error-client";
6
+ export declare const MARKLESS_DEV_RELOADS_EVENT = "markless:dev-reloads";
7
+ export declare const MARKLESS_DEV_RELOADS_ATTRIBUTE = "data-markless-dev-reloads";
8
+ export declare const MARKLESS_DEV_PAGE_EDIT_EVENT = "markless:dev-page-edit";
6
9
  export interface MarklessDevDiagnostic {
7
10
  readonly code: string;
8
11
  readonly message: string;
package/dist/dev-error.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createCompileErrorPayload, c as renderMarklessDevErrorDocument, i as MarklessCompileError, l as renderMarklessDevErrorPlainText, n as MARKLESS_DEV_ERROR_CLIENT_ID, o as formatMarklessSourceFrame, r as MARKLESS_DEV_ERROR_EVENT, s as normalizeMarklessDevError, t as MARKLESS_DEV_ERROR_CLEAR_EVENT, u as serializeMarklessDevError } from "./dev-error-DRvO28Fd.js";
2
- export { MARKLESS_DEV_ERROR_CLEAR_EVENT, MARKLESS_DEV_ERROR_CLIENT_ID, MARKLESS_DEV_ERROR_EVENT, MarklessCompileError, createCompileErrorPayload, formatMarklessSourceFrame, normalizeMarklessDevError, renderMarklessDevErrorDocument, renderMarklessDevErrorPlainText, serializeMarklessDevError };
1
+ import { a as MARKLESS_DEV_RELOADS_ATTRIBUTE, c as createCompileErrorPayload, d as renderMarklessDevErrorDocument, f as renderMarklessDevErrorPlainText, i as MARKLESS_DEV_PAGE_EDIT_EVENT, l as formatMarklessSourceFrame, n as MARKLESS_DEV_ERROR_CLIENT_ID, o as MARKLESS_DEV_RELOADS_EVENT, p as serializeMarklessDevError, r as MARKLESS_DEV_ERROR_EVENT, s as MarklessCompileError, t as MARKLESS_DEV_ERROR_CLEAR_EVENT, u as normalizeMarklessDevError } from "./dev-error-BEduK_R3.js";
2
+ export { MARKLESS_DEV_ERROR_CLEAR_EVENT, MARKLESS_DEV_ERROR_CLIENT_ID, MARKLESS_DEV_ERROR_EVENT, MARKLESS_DEV_PAGE_EDIT_EVENT, MARKLESS_DEV_RELOADS_ATTRIBUTE, MARKLESS_DEV_RELOADS_EVENT, MarklessCompileError, createCompileErrorPayload, formatMarklessSourceFrame, normalizeMarklessDevError, renderMarklessDevErrorDocument, renderMarklessDevErrorPlainText, serializeMarklessDevError };
@@ -1,4 +1,4 @@
1
- import "./types-BqSoEVp6.js";
1
+ import "./types-iOUoceJ-.js";
2
2
  import "@markless/serializer";
3
3
  import "@markless/compiler";
4
4
  import "@markless/web/inline/resumer";
package/dist/preload.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as MarklessBundleGraph } from "./types-BqSoEVp6.js";
2
- import { i as prerenderWakeVirtualModuleSourceFile, o as symbolVirtualModuleSourceFile, t as isExecutionLogChunk } from "./execution-log-D9cex1i1.js";
1
+ import { o as MarklessBundleGraph } from "./types-iOUoceJ-.js";
2
+ import { i as prerenderWakeVirtualModuleSourceFile, o as symbolVirtualModuleSourceFile, t as isExecutionLogChunk } from "./execution-log-BL-7a77M.js";
3
3
  import { UserConfig } from "vite";
4
4
  //#region src/build/preload-plan.d.ts
5
5
  type ModulePreloadPlanInput = {
@@ -89,10 +89,15 @@ export declare function isResumeSourceRequest(id: string): boolean;
89
89
  export declare function isRenderDataSourceRequest(id: string): boolean;
90
90
  export declare function isRouteNavigationSourceRequest(id: string): boolean;
91
91
  export declare function isClientPrimarySourceRequest(id: string): boolean;
92
+ export declare function resolverVirtualModuleSourceFile(id: string): string | null;
92
93
  //#endregion
93
94
  //#region src/build/planned-landing.d.ts
94
95
  export declare function plannedLandingFiles(bundle: Readonly<Record<string, unknown>>): Map<string, ReadonlySet<string>> | undefined;
95
96
  //#endregion
97
+ //#region src/build/warm-packs.d.ts
98
+ /** The packs a chunk evaluates a task after it runs, read from `warmPacksSuffix` before or after minifying. */
99
+ export declare function warmEvaluatedImports(code: string): string[];
100
+ //#endregion
96
101
  //#region src/build/route-pack-groups.d.ts
97
102
  export declare const MARKLESS_DEFERRED_PACK = "markless-deferred";
98
103
  export declare const MARKLESS_NAVIGATION_PACK_PREFIX = "navigation:";
package/dist/preload.js CHANGED
@@ -1,4 +1,4 @@
1
- import { At as isExecutionLogChunk, E as isRouteNavigationSourceRequest, Nt as planModulePreloadUrls, O as isSymbolOnlySourceRequest, Pt as planModulePreloads, T as isResumeSourceRequest, b as isClientPrimarySourceRequest, d as plannedLandingFiles, i as isMarklessNavigationPack, l as startupPackOfLazy, mt as prerenderWakeVirtualModuleSourceFile, n as MARKLESS_NAVIGATION_PACK_PREFIX, o as lazyStartupPackName, r as isMarklessDeferredPack, s as marklessDeferredChunkFileNames, t as MARKLESS_DEFERRED_PACK, w as isRenderDataSourceRequest, xt as symbolVirtualModuleSourceFile } from "./route-pack-groups-BpefyjrE.js";
1
+ import { A as isSymbolOnlySourceRequest, D as isResumeSourceRequest, E as isRenderDataSourceRequest, I as resolverVirtualModuleSourceFile, It as planModulePreloadUrls, Lt as planModulePreloads, Nt as isExecutionLogChunk, O as isRouteNavigationSourceRequest, S as isClientPrimarySourceRequest, _t as prerenderWakeVirtualModuleSourceFile, i as isMarklessNavigationPack, l as startupPackOfLazy, n as MARKLESS_NAVIGATION_PACK_PREFIX, o as lazyStartupPackName, p as plannedLandingFiles, r as isMarklessDeferredPack, s as marklessDeferredChunkFileNames, t as MARKLESS_DEFERRED_PACK, u as warmEvaluatedImports, wt as symbolVirtualModuleSourceFile } from "./route-pack-groups-BXc755qH.js";
2
2
  import { r as optimizedDepsToInclude } from "./optimized-deps-BfzxSm6C.js";
3
3
  //#region src/build/module-preload-dom.ts
4
4
  const PRIORITY_RANK = {
@@ -73,4 +73,4 @@ function rememberHref(seen, href, baseURI) {
73
73
  if (baseURI) seen.add(new URL(href, baseURI).href);
74
74
  }
75
75
  //#endregion
76
- export { MARKLESS_DEFERRED_PACK, MARKLESS_NAVIGATION_PACK_PREFIX, isClientPrimarySourceRequest, isExecutionLogChunk, isMarklessDeferredPack, isMarklessNavigationPack, isRenderDataSourceRequest, isResumeSourceRequest, isRouteNavigationSourceRequest, isSymbolOnlySourceRequest, lazyStartupPackName, marklessDeferredChunkFileNames, optimizedDepsToInclude, planModulePreloadUrls, planModulePreloads, plannedLandingFiles, preloadLazySymbolModules, prerenderWakeVirtualModuleSourceFile, startupPackOfLazy, symbolVirtualModuleSourceFile };
76
+ export { MARKLESS_DEFERRED_PACK, MARKLESS_NAVIGATION_PACK_PREFIX, isClientPrimarySourceRequest, isExecutionLogChunk, isMarklessDeferredPack, isMarklessNavigationPack, isRenderDataSourceRequest, isResumeSourceRequest, isRouteNavigationSourceRequest, isSymbolOnlySourceRequest, lazyStartupPackName, marklessDeferredChunkFileNames, optimizedDepsToInclude, planModulePreloadUrls, planModulePreloads, plannedLandingFiles, preloadLazySymbolModules, prerenderWakeVirtualModuleSourceFile, resolverVirtualModuleSourceFile, startupPackOfLazy, symbolVirtualModuleSourceFile, warmEvaluatedImports };
@@ -1,13 +1,13 @@
1
- import { a as createCompileErrorPayload, i as MarklessCompileError } from "./dev-error-DRvO28Fd.js";
2
- import { $ as MARKLESS_EXECUTION_DEMAND, A as normalizeVirtualId$2, B as sourceForSymbolVirtualImporter, C as isRelativeImport, Ct as EXECUTION_LOG_DISPATCH_MODULE_IDS, D as isScalarPlanSourceRequest, Dt as executionLogVirtualModuleSource, E as isRouteNavigationSourceRequest, Et as executionLogActivationInjection, F as serverSharedSourceRequest, G as emitPrerenderTriggerGroupModule, H as stripBuildPrefix, I as sharedReachedRenderDataRequest, J as adaptImportedCaptureResolver, K as planPrerenderTriggerGroups, L as sourceForPrerenderWakeVirtualImporter, M as renderDataReachedFromQuery, Mt as requalifyExecutionLogModuleHook, N as resolveVirtualId, O as isSymbolOnlySourceRequest, Ot as hasExecutionLogModuleHook, P as resolverVirtualModuleSourceFile, Pt as planModulePreloads, Q as MARKLESS_BYTE_ATTRIBUTION, R as sourceForResumeVirtualImporter, S as isPrerenderWakeSourceRequest, St as withoutFirstUse, T as isResumeSourceRequest, Tt as MARKLESS_EXECUTION_LOG_MODULE_ID, U as virtualModuleSourceForLoad, V as sourceForTriggerGroupVirtualImporter, W as emitPrerenderBoundaryRendererModule, X as MARKLESS_BUILD_PREFIX, Z as MARKLESS_BUNDLE_GRAPH, _ as devBrowserVirtualModuleUrl, _t as scopedSymbolExportName, a as isStartupPack, b as isClientPrimarySourceRequest, bt as symbolVirtualModuleId, c as planRoutePackGroups, ct as emitResumeModule, dt as encodedSymbolSource, et as MARKLESS_EXECUTION_SIZES, f as MARKLESS_ROUTE_SOURCE_QUERY_RE, ft as payloadModule, g as devBrowserSourceModuleUrl, gt as rewriteSymbolModuleExport, h as clientSymbolEntries, ht as resumeVirtualModuleId, j as pathname$1, jt as normalizeExecutionLogMode, k as materializedReachedRenderDataSource, kt as injectExecutionLogModuleHook, l as startupPackOfLazy, lt as emitSettleModule, m as clientRouteArtifactReference, nt as outputDefaults, ot as demandsOverlay, p as TSRX_SOURCE_FILE$1, pt as prerenderWakeVirtualModuleId, q as triggerGroupVirtualModuleId, rt as MARKLESS_VIRTUAL_PREFIX, s as marklessDeferredChunkFileNames, st as emitOverlayLoaderInstall, tt as MARKLESS_INTERACTION_CLOSURES, u as MARKLESS_INTERACTION_CLOSURES_ASSET, ut as emitSourceModule, v as emittedBundleModuleIds, vt as settleVirtualModuleId, w as isRenderDataSourceRequest, wt as MARKLESS_EXECUTION_LOG_GLOBAL, x as isMarklessRuntimeModule, xt as symbolVirtualModuleSourceFile, y as executionLogRuntimeModuleId, yt as symbolEntryVirtualModuleId, z as sourceForSettleVirtualImporter } from "./route-pack-groups-BpefyjrE.js";
1
+ import { c as createCompileErrorPayload, s as MarklessCompileError } from "./dev-error-BEduK_R3.js";
2
+ import { $ as MARKLESS_BUNDLE_GRAPH, A as isSymbolOnlySourceRequest, At as executionLogVirtualModuleSource, B as sourceForResumeVirtualImporter, C as isMarklessRuntimeModule, Ct as symbolVirtualModuleId, D as isResumeSourceRequest, Dt as MARKLESS_EXECUTION_LOG_GLOBAL, E as isRenderDataSourceRequest, Et as EXECUTION_LOG_DISPATCH_MODULE_IDS, F as resolveVirtualId, Ft as requalifyExecutionLogModuleHook, G as virtualModuleSourceForLoad, H as sourceForSymbolVirtualImporter, I as resolverVirtualModuleSourceFile, J as planPrerenderTriggerGroups, K as emitPrerenderBoundaryRendererModule, L as serverSharedSourceRequest, Lt as planModulePreloads, M as normalizeVirtualId$2, Mt as injectExecutionLogModuleHook, N as pathname$1, O as isRouteNavigationSourceRequest, Ot as MARKLESS_EXECUTION_LOG_MODULE_ID, P as renderDataReachedFromQuery, Pt as normalizeExecutionLogMode, Q as MARKLESS_BUILD_PREFIX, R as sharedReachedRenderDataRequest, S as isClientPrimarySourceRequest, St as symbolEntryVirtualModuleId, T as isRelativeImport, Tt as withoutFirstUse, U as sourceForTriggerGroupVirtualImporter, V as sourceForSettleVirtualImporter, W as stripBuildPrefix, X as adaptImportedCaptureResolver, Y as triggerGroupVirtualModuleId, Z as MARKLESS_BUILD_METADATA_FILES, _ as clientSymbolEntries, a as isStartupPack, at as outputDefaults, b as emittedBundleModuleIds, bt as scopedSymbolExportName, c as planRoutePackGroups, d as warmPacksSuffix, dt as emitResumeModule, et as MARKLESS_BYTE_ATTRIBUTION, f as MARKLESS_INTERACTION_CLOSURES_ASSET, ft as emitSettleModule, g as clientRouteArtifactReference, gt as prerenderWakeVirtualModuleId, h as TSRX_SOURCE_FILE$1, ht as payloadModule, it as MARKLESS_PUBLIC_BUILD_METADATA_FILES, j as materializedReachedRenderDataSource, jt as hasExecutionLogModuleHook, k as isScalarPlanSourceRequest, kt as executionLogActivationInjection, l as startupPackOfLazy, lt as demandsOverlay, m as MARKLESS_ROUTE_SOURCE_QUERY_RE, mt as encodedSymbolSource, nt as MARKLESS_EXECUTION_SIZES, ot as MARKLESS_VIRTUAL_PREFIX, pt as emitSourceModule, q as emitPrerenderTriggerGroupModule, rt as MARKLESS_INTERACTION_CLOSURES, s as marklessDeferredChunkFileNames, tt as MARKLESS_EXECUTION_DEMAND, ut as emitOverlayLoaderInstall, v as devBrowserSourceModuleUrl, vt as resumeVirtualModuleId, w as isPrerenderWakeSourceRequest, wt as symbolVirtualModuleSourceFile, x as executionLogRuntimeModuleId, xt as settleVirtualModuleId, y as devBrowserVirtualModuleUrl, yt as rewriteSymbolModuleExport, z as sourceForPrerenderWakeVirtualImporter } from "./route-pack-groups-BXc755qH.js";
3
3
  import { joinURL, parsePath, withLeadingSlash, withQuery, withoutLeadingSlash } from "ufo";
4
4
  import { PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, createStorageSeedMetadataFromGraphNodeId, jsonSourceWithNonFiniteNumbers } from "@markless/serializer";
5
5
  import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
6
- import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from "pathe";
7
- import { DEBUGGING_PLAYBOOK_HINT, LEAN_DISPATCH_MARKER_MODULES, RUNTIME_CAPABILITY_MODULE_IDS, artifactChildCandidates, callsImportedOrFreeName, collectTsrxModuleDiagnostics, compileTsrxModule, compileTsrxModuleLinkArtifact, componentEdgeSymbolRoutes, computeExecutionAttribution, computeLinkedInterfaces, delegateChildRenderPlan, delegateChildRendering, delegateChildResolutionRequests, delegateMaterializationScope, emitSymbolResolverModule, evaluateModuleConstants, importedRowComponentMints, importedRowSlotReaders, importedSymbolRoutes, linkBarrelComponents, linkClaimManifests, linkDelegateChildren, linkImportedModules, linkedChildrenHaveBrowserTriggers, linkedImportedClaimsMissing, linkedImportedSymbolInputs, linkedManifestHasBrowserTriggers, linkedModuleChildDiagnostics, linkedModuleChildKey, linkedModuleClaimPlan, linkedModuleImportRequests, linkedModuleLoadSource, linkedRenderDataBoundarySymbols, linkedRenderDataOnlyChange, linkedRenderDataReachRoot, linkedResolverClaimVerdict, linkedRouteArtifactRegistration, linkedSymbolRouteRequests, moduleInterfaceHash, moduleLinkResolutionKey, overlayBarrelInterfaces, parseJavaScriptModule, planDelegateChildren, planEmittedClaimOwnership, planLinkedModuleChildren, planRenderDataModule, planTransformRequest, prerenderInterfacesComplete, renderDataClaimManifest, renderDataReachImportSources, uniqueLinkedModuleChildren } from "@markless/compiler";
6
+ import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "pathe";
7
+ import { DEBUGGING_PLAYBOOK_HINT, LEAN_DISPATCH_MARKER_MODULES, RUNTIME_CAPABILITY_MODULE_IDS, artifactChildCandidates, callsImportedOrFreeName, collectTsrxModuleDiagnostics, compileTsrxModule, compileTsrxModuleLinkArtifact, componentEdgeSymbolRoutes, computeExecutionAttribution, computeLinkedInterfaces, delegateChildRenderPlan, delegateChildRendering, delegateChildResolutionRequests, delegateMaterializationScope, emitSymbolResolverModule, evaluateModuleConstants, importedNestedRepeats, importedRowComponentMints, importedRowSlotReaders, importedRowTemplateMints, importedSymbolRoutes, linkBarrelComponents, linkClaimManifests, linkDelegateChildren, linkImportedModules, linkedChildrenHaveBrowserTriggers, linkedImportedClaimsMissing, linkedImportedSymbolInputs, linkedManifestHasBrowserTriggers, linkedModuleChildDiagnostics, linkedModuleChildKey, linkedModuleClaimPlan, linkedModuleImportRequests, linkedModuleLoadSource, linkedRenderDataBoundarySymbols, linkedRenderDataOnlyChange, linkedRenderDataReachRoot, linkedResolverClaimVerdict, linkedRouteArtifactRegistration, linkedSymbolRouteRequests, moduleInterfaceHash, moduleLinkResolutionKey, overlayBarrelInterfaces, parseJavaScriptModule, planDelegateChildren, planEmittedClaimOwnership, planLinkedModuleChildren, planRenderDataModule, planTransformRequest, prerenderInterfacesComplete, renderDataClaimManifest, renderDataReachImportSources, uniqueLinkedModuleChildren } from "@markless/compiler";
8
8
  import { PRERENDER_INLINE_EVENT_NAMES_TOKEN, createInlineResumerDebugRegistrationSource, createInlineResumerSelfWakeSource, createInlineResumerSource, createPrerenderInlineResumerSource, createPrerenderSettleInlineResumerSource } from "@markless/web/inline/resumer";
9
9
  import { parse, parseSync } from "rolldown/experimental";
10
- import { mkdir, readFile, rename, rm, rmdir } from "node:fs/promises";
10
+ import { copyFile, mkdir, readFile, readdir, rename, rm, rmdir } from "node:fs/promises";
11
11
  import { defDGraph } from "@thi.ng/dgraph";
12
12
  import { RolldownMagicString } from "rolldown";
13
13
  import { isAbsolute as isAbsolute$1 } from "node:path";
@@ -594,6 +594,10 @@ const PROTOCOL_IDLE_EVENT_NAME$1 = "idle";
594
594
  */
595
595
  const PROTOCOL_LOCATOR_PATHS_ATTRIBUTE = "data-markless-paths";
596
596
  //#endregion
597
+ //#region ../serializer/src/protocol-page-markers.ts
598
+ const PROTOCOL_CONTAINER_START_COMMENT = "markless:page-start";
599
+ const PROTOCOL_CONTAINER_END_COMMENT = "markless:page-end";
600
+ //#endregion
597
601
  //#region ../web/src/inline/defer.ts
598
602
  /**
599
603
  * The one startup helper deferred triggers share. Serialized whole into a served
@@ -601,12 +605,20 @@ const PROTOCOL_LOCATOR_PATHS_ATTRIBUTE = "data-markless-paths";
601
605
  * from compiler-emitted DOM-order indexes, index 0 being the container itself,
602
606
  * which hands records the runtime owns (arms, rows) to the runtime.
603
607
  */
604
- function createMarklessDefer(loadModule, pathsAttribute) {
608
+ function createMarklessDefer(loadModule, pageStart, pageEnd, pathsAttribute) {
605
609
  const scope = globalThis;
606
610
  const clockOf = (root) => root.__mClock || {
607
611
  frame: (run) => requestAnimationFrame(run),
608
612
  idle: (run) => scope.scheduler?.postTask ? scope.scheduler.postTask(run, { priority: "background" }) : typeof requestIdleCallback === "function" ? requestIdleCallback(run, { timeout: 2e3 }) : setTimeout(run, 200)
609
613
  };
614
+ const census = (root) => {
615
+ const live = [root];
616
+ const walker = document.createTreeWalker(root, 129);
617
+ for (let next = walker.nextNode(); next; next = walker.nextNode()) if (next.nodeType !== 8) live.push(next);
618
+ else if (next.data === pageStart) live.length = 1;
619
+ else if (next.data === pageEnd) break;
620
+ return live;
621
+ };
610
622
  const idle = (root, run) => {
611
623
  const clock = clockOf(root);
612
624
  const next = () => clock.idle(() => root.__marklessArmRegistering?.size ? next() : run());
@@ -627,7 +639,8 @@ function createMarklessDefer(loadModule, pathsAttribute) {
627
639
  root,
628
640
  event: {
629
641
  type: eventName,
630
- target: host
642
+ target: host,
643
+ bubbles: false
631
644
  },
632
645
  element: host
633
646
  };
@@ -635,20 +648,20 @@ function createMarklessDefer(loadModule, pathsAttribute) {
635
648
  if (!queue && root.__marklessDelegatedDispatch === true) return idle(root, () => claim(host));
636
649
  claimed.add(host);
637
650
  if (lane !== "visible") fired.add(host);
638
- root.__marklessCensus ||= [root, ...root.getElementsByTagName("*")];
651
+ root.__marklessCensus ||= census(root);
639
652
  root.__marklessDelegatedDispatch ||= eventName;
640
653
  pending++;
641
- (queue ? Promise.resolve(queue(input)) : loadModule(url).then((module) => module.resumeContainerEvent(input))).then(() => {
654
+ (queue ? Promise.resolve(queue(input)) : (root.__mResume ||= loadModule(url)).then((module) => module.resumeContainerEvent(input))).then(() => {
642
655
  if (root.__asyncResumeRuntimeStarted) return;
643
656
  fired.add(host);
644
657
  if (!--pending && root.__marklessDelegatedDispatch === eventName) root.__marklessDelegatedDispatch = void 0;
645
658
  });
646
659
  };
647
- const all = root.getElementsByTagName("*");
660
+ const all = root.__marklessCensus ?? census(root);
648
661
  const paths = pathsAttribute && root.getAttribute?.(pathsAttribute);
649
- if (paths && parseInt(paths) !== all.length + 1) root.__marklessShifted = 1;
662
+ if (paths && parseInt(paths) !== all.length) root.__marklessShifted = 1;
650
663
  const hosts = root.__marklessShifted ? [root] : hostIndexes.flatMap((index) => {
651
- const host = index ? all[index - 1] : root;
664
+ const host = all[index];
652
665
  return host ? [host] : [];
653
666
  });
654
667
  if (lane === "idle") return idle(root, () => hosts.forEach(claim));
@@ -665,7 +678,7 @@ function createMarklessDefer(loadModule, pathsAttribute) {
665
678
  const INLINE_DEFER_LOADER_SOURCE = "(url) => import(/* @vite-ignore */ url)";
666
679
  /** An expression that installs the helper once per document and evaluates to it; a build passes the factory minified. */
667
680
  function inlineDeferSource(factory = createMarklessDefer.toString()) {
668
- return `(globalThis.__mDefer||=(${factory})(${INLINE_DEFER_LOADER_SOURCE},${JSON.stringify(PROTOCOL_LOCATOR_PATHS_ATTRIBUTE)}))`;
681
+ return `(globalThis.__mDefer||=(${factory})(${INLINE_DEFER_LOADER_SOURCE},${JSON.stringify(PROTOCOL_CONTAINER_START_COMMENT)},${JSON.stringify(PROTOCOL_CONTAINER_END_COMMENT)},${JSON.stringify(PROTOCOL_LOCATOR_PATHS_ATTRIBUTE)}))`;
669
682
  }
670
683
  /** One lane's registration, appended only to a served page whose records name that lane's event. */
671
684
  function createInlineDeferTriggerSource(lane, hostIndexes) {
@@ -1058,6 +1071,7 @@ async function transformTsrxModuleWithPrerenderWakeClosure(input, linkedChildHas
1058
1071
  const styleCss = compiled.publicRenderPlan.styleScopes.map((scope) => scope.cssText).join("\n");
1059
1072
  const styleId = compiled.publicRenderPlan.styleScopes.length > 0 ? `${MARKLESS_VIRTUAL_PREFIX}style:${encodedModuleId}.css` : null;
1060
1073
  const rosterDerivation = compiled.moduleGraphInterface.render.components.some((component) => component.rosterDerivation === true);
1074
+ const storageCells = compiled.moduleGraphInterface.render.components.some((component) => component.storageCells === true);
1061
1075
  const prerenderClosureNeedsWake = needsFullResume(compiled.protocolState, compiled.protocolView, compiled.runtimeDemandMap) || input.prerenderRecords === true && linkedChildHasBrowserTriggers;
1062
1076
  const emitsPrerenderWakeVariant = input.prerenderWakeVariant === true && compiled.publicRenderModule.renderDataModuleSource !== void 0 && prerenderInterfacesComplete(compiled, input) && prerenderClosureNeedsWake;
1063
1077
  const emitsPrerenderWakeFacade = input.prerenderWakeFacade === true && input.prerenderWakeVariant === true && compiled.publicRenderModule.renderDataModuleSource !== void 0 && prerenderInterfacesComplete(compiled, input) && prerenderClosureNeedsWake;
@@ -1139,7 +1153,10 @@ async function transformTsrxModuleWithPrerenderWakeClosure(input, linkedChildHas
1139
1153
  renderDataId: canonicalRenderData && compiled.publicRenderModule.renderDataModuleSource ? renderDataId : void 0,
1140
1154
  linkedRowSlotReaders: importedRowSlotReaders(input.importedModuleInterfaces),
1141
1155
  linkedRowComponents: importedRowComponentMints(input.importedModuleInterfaces),
1156
+ linkedRowTemplates: importedRowTemplateMints(input.importedModuleInterfaces),
1157
+ linkedNestedRepeats: importedNestedRepeats(input.importedModuleInterfaces),
1142
1158
  rosterDerivation,
1159
+ storageCells,
1143
1160
  hasBoundSymbols: compiled.boundSymbolResolver.rows.length > 0,
1144
1161
  boundSymbolDescriptors,
1145
1162
  symbols: symbolRows,
@@ -1166,6 +1183,7 @@ async function transformTsrxModuleWithPrerenderWakeClosure(input, linkedChildHas
1166
1183
  moduleId: triggerGroupVirtualModuleId(input.filename, index)
1167
1184
  })),
1168
1185
  rosterDerivation,
1186
+ storageCells,
1169
1187
  installResumeSummary: true,
1170
1188
  recordsOnly: true,
1171
1189
  hasBoundSymbols: compiled.boundSymbolResolver.rows.length > 0,
@@ -1246,6 +1264,8 @@ async function transformTsrxModuleWithPrerenderWakeClosure(input, linkedChildHas
1246
1264
  environment: input.environment ?? "lib",
1247
1265
  linkedRowSlotReaders: importedRowSlotReaders(input.importedModuleInterfaces),
1248
1266
  linkedRowComponents: importedRowComponentMints(input.importedModuleInterfaces),
1267
+ linkedRowTemplates: importedRowTemplateMints(input.importedModuleInterfaces),
1268
+ linkedNestedRepeats: importedNestedRepeats(input.importedModuleInterfaces),
1249
1269
  clientOutput: input.clientOutput ?? "full",
1250
1270
  executionLog: input.executionLog,
1251
1271
  headInjections: headInjections.length > 0 ? headInjections : void 0,
@@ -1421,6 +1441,7 @@ async function compileWithBlockingDiagnostics(input, resolverId) {
1421
1441
  moduleId: input.moduleId,
1422
1442
  source: input.source,
1423
1443
  ...input.serverOnlyProps?.length ? { serverOnlyProps: input.serverOnlyProps } : {},
1444
+ ...input.routeRoot ? { routeRoot: true } : {},
1424
1445
  buildId: input.buildId,
1425
1446
  resolverId,
1426
1447
  symbols: input.symbols ?? [],
@@ -1507,6 +1528,7 @@ function withServedScalarDemand(map, served) {
1507
1528
  return {
1508
1529
  ...action,
1509
1530
  runtimeModuleIds: union(action.runtimeModuleIds, lean.runtimeModuleIds),
1531
+ ...lean.firstUse ? { firstUse: lean.firstUse } : {},
1510
1532
  ...lean.plan?.kind === "closure" ? { plan: lean.plan } : {}
1511
1533
  };
1512
1534
  })
@@ -2135,6 +2157,10 @@ function unmappedChunkSpecifiers(bundle) {
2135
2157
  function marklessBuildManifestDir(clientOutDir) {
2136
2158
  return join(dirname(clientOutDir), ".markless", basename(clientOutDir));
2137
2159
  }
2160
+ /** Where a build metadata file such as `build/bundle-graph.json` lands for a client output. */
2161
+ function marklessBuildManifestPath(clientOutDir, metadataFile) {
2162
+ return join(marklessBuildManifestDir(clientOutDir), basename(metadataFile));
2163
+ }
2138
2164
  /** The chunk import map a packed client build hands to the server that renders its documents. */
2139
2165
  function marklessImportMapPath(clientOutDir) {
2140
2166
  return join(marklessBuildManifestDir(clientOutDir), "import-map.json");
@@ -2148,6 +2174,17 @@ async function moveImportMapOutOfClientOutput(clientOutDir, emitted) {
2148
2174
  await rename(written, target);
2149
2175
  await rmdir(dirname(written)).catch(() => void 0);
2150
2176
  }
2177
+ async function moveBuildMetadataOutOfClientOutput(clientOutDir, emitted, options) {
2178
+ const served = new Set(options.executionLogActive ? MARKLESS_PUBLIC_BUILD_METADATA_FILES : []);
2179
+ for (const file of MARKLESS_BUILD_METADATA_FILES) {
2180
+ const target = marklessBuildManifestPath(clientOutDir, file);
2181
+ await rm(target, { force: true });
2182
+ if (!emitted.has(file)) continue;
2183
+ const written = join(clientOutDir, file);
2184
+ await mkdir(dirname(target), { recursive: true });
2185
+ await (served.has(file) ? copyFile(written, target) : rename(written, target));
2186
+ }
2187
+ }
2151
2188
  //#endregion
2152
2189
  //#region src/build/bundle-graph.ts
2153
2190
  const SLOW_BUNDLE_TOTAL = 19200;
@@ -2768,7 +2805,7 @@ function collapseLazyModuleFacades(bundle, onEdit, options = {}) {
2768
2805
  eagerImports.set(evaluator.fileName, [...eagerImports.get(evaluator.fileName) ?? [], target]);
2769
2806
  }
2770
2807
  }
2771
- for (const [fileName, loaders] of registered) additions.get(fileName).push(`(globalThis.${PACK_REGISTRY}??={})[import.meta.url]={${[...loaders].join(",")}};`);
2808
+ for (const [fileName, loaders] of registered) additions.get(fileName).push(`${PACK_REGISTRATION}={${[...loaders].join(",")}};`);
2772
2809
  for (const chunk of chunks.values()) {
2773
2810
  if (facades.has(chunk.fileName)) continue;
2774
2811
  const replacements = [];
@@ -2800,10 +2837,10 @@ function collapseLazyModuleFacades(bundle, onEdit, options = {}) {
2800
2837
  }),
2801
2838
  ...additions.get(chunk.fileName) ?? [],
2802
2839
  ...lookup && replacements.some(({ source }) => source.startsWith("__marklessPackLoad")) ? [PACK_LOAD_SOURCE] : [],
2803
- ...evaluated.size ? [`setTimeout(()=>{for(const pack of[${[...evaluated].map((target) => {
2840
+ ...evaluated.size ? [warmPacksSuffix([...evaluated].map((target) => {
2804
2841
  const path = relative(dirname(chunk.fileName), target.fileName);
2805
- return `import(${JSON.stringify(path.startsWith(".") ? path : `./${path}`)})`;
2806
- }).join(",")}])pack.catch(()=>{})});`] : []
2842
+ return path.startsWith(".") ? path : `./${path}`;
2843
+ }))] : []
2807
2844
  ].join("\n");
2808
2845
  if (replacements.length || suffix) onEdit?.(chunk, replacements, suffix);
2809
2846
  const pieces = [];
@@ -2823,6 +2860,7 @@ function collapseLazyModuleFacades(bundle, onEdit, options = {}) {
2823
2860
  return { removed: [...facades.keys()] };
2824
2861
  }
2825
2862
  const PACK_REGISTRY = "__marklessPacks";
2863
+ const PACK_REGISTRATION = `(globalThis.${PACK_REGISTRY}??={})[import.meta.url]`;
2826
2864
  const PACKED_NAME_PATTERN = /\$ml[\w$]*|__marklessNamespace[\w$]*/g;
2827
2865
  const PACK_LOAD = "__marklessPackLoad";
2828
2866
  const PACK_LOAD_SOURCE = `function ${PACK_LOAD}(specifier,loader,load){const pack=globalThis.${PACK_REGISTRY}?.[import.meta.resolve?.(specifier)];return pack?Promise.resolve().then(pack[loader]):load().then(module=>module[loader]())}`;
@@ -3679,6 +3717,9 @@ const RUNS_WITHOUT_INPUT = {
3679
3717
  overlay: true
3680
3718
  };
3681
3719
  const LEAN_DISPATCH_MODULE_IDS = new Set(Object.values(LEAN_DISPATCH_MARKER_MODULES).flat());
3720
+ function isLeanAction(runtimeModuleIds) {
3721
+ return [...runtimeModuleIds].some((id) => LEAN_DISPATCH_MODULE_IDS.has(id));
3722
+ }
3682
3723
  function computeInteractionClosures(input) {
3683
3724
  const { modules } = input;
3684
3725
  const sources = [...input.demand];
@@ -3793,10 +3834,14 @@ function computeInteractionClosures(input) {
3793
3834
  };
3794
3835
  for (const file of files) for (const symbolId of demand.get(file).landingSymbols) seedSymbol(file, symbolId);
3795
3836
  if (resume !== "unknown") for (const [owner, symbolIds] of resume.symbols) for (const symbolId of symbolIds) seedSymbol(owner, symbolId);
3837
+ const bootBound = resume !== "unknown" && [...files].every((file) => {
3838
+ const merged = demand.get(file);
3839
+ return merged.landingSymbols.size === 0 && merged.landingRuntimeModuleIds.size === 0 && [...merged.actions.values()].every((action) => isLeanAction(action.runtimeModuleIds) && !(action.lean ?? action).unknown);
3840
+ }) ? { runtimeIds: new Set(resume.runtimeModuleIds) } : {};
3796
3841
  const consumers = [{
3797
3842
  key: "boot",
3798
3843
  kind: "boot",
3799
- modules: bootBounded ? useClosure(route, reach, bootSeeds, {}, bootSeeds) : useClosure(route, reach, bootRoots)
3844
+ modules: bootBounded ? useClosure(route, reach, bootSeeds, bootBound, bootSeeds) : useClosure(route, reach, bootRoots)
3800
3845
  }, ...renderRoots.length ? [{
3801
3846
  key: "render",
3802
3847
  kind: "render",
@@ -3806,12 +3851,14 @@ function computeInteractionClosures(input) {
3806
3851
  const merged = demand.get(file);
3807
3852
  const fileSymbols = symbolsByFile.get(file) ?? [];
3808
3853
  for (const [actionKey, action] of [...merged.actions].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
3809
- const firstUse = merged.replaced ? null : action.firstUse;
3854
+ const lean = isLeanAction(action.runtimeModuleIds);
3855
+ const served = lean && action.lean || action;
3856
+ const firstUse = merged.replaced ? null : served.firstUse;
3810
3857
  const joined = firstUse ? joinPage([...firstUse.map((reach) => ({
3811
3858
  file,
3812
3859
  reach
3813
3860
  })), ...page.resume], page) : null;
3814
- if (action.unknown || joined === "unknown") {
3861
+ if (served.unknown || joined === "unknown") {
3815
3862
  consumers.push({
3816
3863
  key: `action:${display(file, input.root)}#${actionKey}`,
3817
3864
  kind: "action",
@@ -3847,7 +3894,7 @@ function computeInteractionClosures(input) {
3847
3894
  else widen("unresolved-symbol");
3848
3895
  }
3849
3896
  }
3850
- const runtimeIds = /* @__PURE__ */ new Set([...action.runtimeModuleIds, ...joined?.runtimeModuleIds ?? []]);
3897
+ const runtimeIds = /* @__PURE__ */ new Set([...lean && joined ? [] : action.runtimeModuleIds, ...joined?.runtimeModuleIds ?? []]);
3851
3898
  if (merged.replaced || !firstUse && [...action.recordKinds].some((kind) => CARRIES_UNLISTED_RECORDS[kind])) {
3852
3899
  widen("unlisted-records");
3853
3900
  for (const id of merged.unknownRecordModuleIds) runtimeIds.add(id);
@@ -3857,7 +3904,7 @@ function computeInteractionClosures(input) {
3857
3904
  key: `action:${display(file, input.root)}#${actionKey}`,
3858
3905
  kind: "action",
3859
3906
  ...conservative ? { conservative } : {},
3860
- ...[...action.runtimeModuleIds].some((id) => LEAN_DISPATCH_MODULE_IDS.has(id)) ? { lean: true } : {},
3907
+ ...lean ? { lean: true } : {},
3861
3908
  modules: useClosure(route, reach, seeds, { runtimeIds }, seeds)
3862
3909
  });
3863
3910
  }
@@ -3937,6 +3984,7 @@ function mergeDemand(sources, landingArmsServed) {
3937
3984
  replaced: false,
3938
3985
  records: /* @__PURE__ */ new Map(),
3939
3986
  landingSymbols: /* @__PURE__ */ new Set(),
3987
+ landingRuntimeModuleIds: /* @__PURE__ */ new Set(),
3940
3988
  actions: /* @__PURE__ */ new Map(),
3941
3989
  unknownRecordModuleIds: /* @__PURE__ */ new Set(),
3942
3990
  page: {
@@ -3959,7 +4007,9 @@ function mergeDemand(sources, landingArmsServed) {
3959
4007
  entry.records.set(record.recordId, symbols);
3960
4008
  if (landingArmsServed && record.kind === "async-boundary") continue;
3961
4009
  for (const id of record.symbolIds ?? []) symbols.add(id);
3962
- if (RUNS_WITHOUT_INPUT[record.kind]) for (const id of record.symbolIds ?? []) entry.landingSymbols.add(id);
4010
+ if (!RUNS_WITHOUT_INPUT[record.kind]) continue;
4011
+ for (const id of record.symbolIds ?? []) entry.landingSymbols.add(id);
4012
+ for (const id of record.runtimeModuleIds) entry.landingRuntimeModuleIds.add(id);
3963
4013
  }
3964
4014
  for (const action of [...map.actions, ...map.armActions ?? []]) {
3965
4015
  const key = `${action.hostNodeId}:${action.eventName}`;
@@ -3972,9 +4022,14 @@ function mergeDemand(sources, landingArmsServed) {
3972
4022
  firstUse: action.firstUse ? [] : null,
3973
4023
  unknown: false
3974
4024
  };
3975
- if (action.firstUse === "unknown") existing.unknown = true;
3976
- else if (!action.firstUse) existing.firstUse = null;
3977
- else existing.firstUse?.push(action.firstUse);
4025
+ const views = [existing];
4026
+ if (isLeanAction(action.runtimeModuleIds)) views.push(existing.lean ??= {
4027
+ firstUse: action.firstUse ? [] : null,
4028
+ unknown: false
4029
+ });
4030
+ for (const view of views) if (action.firstUse === "unknown") view.unknown = true;
4031
+ else if (!action.firstUse) view.firstUse = null;
4032
+ else view.firstUse?.push(action.firstUse);
3978
4033
  for (const kind of action.recordKinds) existing.recordKinds.add(kind);
3979
4034
  for (const id of action.payloadRecordIds) existing.recordIds.add(id);
3980
4035
  for (const id of action.runtimeModuleIds) existing.runtimeModuleIds.add(id);
@@ -4699,7 +4754,8 @@ function throwLinkedModuleChildDiagnostics(metadata, children, parentManifest) {
4699
4754
  captureMetadataForSource: (source) => metadata.captureMetadataForSource(source),
4700
4755
  parentCaptureMetadataForSource: (parent) => parentManifest?.captureMetadata ?? metadata.captureMetadataForSource(pathname$1(parent))
4701
4756
  });
4702
- if (diagnostic) throw new Error(diagnostic.message);
4757
+ if (!diagnostic) return;
4758
+ throw (diagnostic.source === void 0 ? void 0 : metadata.compileFailure(diagnostic.source)) ?? new Error(diagnostic.message);
4703
4759
  }
4704
4760
  //#endregion
4705
4761
  //#region src/build/linked-interfaces.ts
@@ -4949,6 +5005,13 @@ var ModuleMetadataRegistry = class ModuleMetadataRegistry {
4949
5005
  publication.pending.delete(emittedModule);
4950
5006
  ModuleMetadataRegistry.#changed(publication);
4951
5007
  }
5008
+ /** The error the source's latest compile threw, in any environment, if nothing has published since. */
5009
+ compileFailure(source) {
5010
+ for (const [key, publication] of this.#sourceClaimPublications) {
5011
+ if (key.slice(key.indexOf("\0") + 1) !== source) continue;
5012
+ for (const failure of publication.failed.values()) return failure;
5013
+ }
5014
+ }
4952
5015
  /**
4953
5016
  * Drops an edited module's claims and the ledger entry that remembers it ever
4954
5017
  * published them, so the transform that recompiles it counts as a first
@@ -5058,6 +5121,7 @@ var ModuleMetadataRegistry = class ModuleMetadataRegistry {
5058
5121
  const publication = this.#sourceClaimPublications.get(publicationKey(environment, source));
5059
5122
  if (!publication || ModuleMetadataRegistry.#complete(publication)) return;
5060
5123
  const unpublished = [...publication.begun].filter((emittedModule) => !publication.published.has(emittedModule));
5124
+ ModuleMetadataRegistry.#throwFailure(publication, unpublished);
5061
5125
  throw new Error(`MARKLESS_SOURCE_SYMBOL_CLAIMS_UNSEALED: Source ${JSON.stringify(source)} claims were consumed before final publication completed. Emitted variants that have not published: ${unpublished.map((emittedModule) => JSON.stringify(emittedModule)).join(", ")}.`);
5062
5126
  }
5063
5127
  emittedSymbolClaimMap(emittedModules) {
@@ -6731,7 +6795,30 @@ function stripImportedVitePreloadHelper(code) {
6731
6795
  const withoutImport = code.slice(0, helper.importStart) + helper.keptImport + code.slice(helper.importEnd);
6732
6796
  if (preloadStillCalled(code, withoutImport, helper)) return code;
6733
6797
  const initCall = `${escapeRegExp$1(helper.initFunction)}\\(\\)`;
6734
- return withoutImport.replace(new RegExp(String.raw`,${initCall},`, "g"), ",").replace(new RegExp(String.raw`\{${initCall},`, "g"), "{").replace(new RegExp(String.raw`,${initCall},`, "g"), ",").replace(new RegExp(String.raw`,${initCall}\}`, "g"), "}").replace(new RegExp(String.raw`\{${initCall}\}`, "g"), "{}");
6798
+ return withoutInitStatements(withoutImport.replace(new RegExp(String.raw`,${initCall},`, "g"), ",").replace(new RegExp(String.raw`\{${initCall},`, "g"), "{").replace(new RegExp(String.raw`,${initCall},`, "g"), ",").replace(new RegExp(String.raw`,${initCall}\}`, "g"), "}").replace(new RegExp(String.raw`\{${initCall}\}`, "g"), "{}"), helper.initFunction) ?? code;
6799
+ }
6800
+ function withoutInitStatements(code, name) {
6801
+ const offsets = calleeOffsets(code, name);
6802
+ if (offsets.length === 0) return code;
6803
+ const program = tryParseJavaScriptModule(code);
6804
+ if (!program) return void 0;
6805
+ const statements = [];
6806
+ walkReferenceScopes(program, [], {
6807
+ removedImports: /* @__PURE__ */ new Set(),
6808
+ offsets
6809
+ }, (node, scopes) => {
6810
+ const call = node.type === "ExpressionStatement" ? node.expression : void 0;
6811
+ if (call?.type !== "CallExpression" || identifierName$1(call.callee) !== name || asNodes$1(call.arguments).length > 0 || isDeclaredInScope(name, scopes)) return;
6812
+ statements.push(node);
6813
+ });
6814
+ let next = code;
6815
+ for (const { start, end } of statements.sort((left, right) => right.start - left.start)) {
6816
+ const before = next.slice(0, start).trimEnd();
6817
+ const own = before === "" || /[;{]$/.test(before);
6818
+ next = next.slice(0, start) + (own ? "" : ";") + next.slice(end);
6819
+ }
6820
+ const after = tryParseJavaScriptModule(next);
6821
+ return after && !callsFreeName(next, after, name, /* @__PURE__ */ new Set()) ? next : void 0;
6735
6822
  }
6736
6823
  function findImportedVitePreloadHelper(code) {
6737
6824
  if (!code.includes("__vitePreload") || !code.includes("init_preload_helper")) return void 0;
@@ -8183,7 +8270,8 @@ async function loadHook(ctx, pluginContext, id) {
8183
8270
  const normalizedId = normalizeVirtualId$2(id);
8184
8271
  const resolverSource = resolverVirtualModuleSourceFile(normalizedId);
8185
8272
  const symbolSource = symbolVirtualModuleSourceFile(normalizedId);
8186
- const ownerSource = resolverSource ?? symbolSource;
8273
+ const renderDataSource = normalizedId.startsWith(`virtual:markless:render-data:`) ? marklessVirtualModuleSourceFile(normalizedId, ctx.getRoot()) : null;
8274
+ const ownerSource = resolverSource ?? symbolSource ?? renderDataSource;
8187
8275
  if (ownerSource) await moduleMetadata.awaitSourceClaimsPublished(ctx.getEnvironment(pluginContext), ownerSource);
8188
8276
  if (resolverSource && ctx.getEnvironment(pluginContext) === "client" && internalOptions.dev !== true && internalOptions.prerenderWakeChannel === true && typeof pluginContext.getModuleInfo === "function") {
8189
8277
  const queryClaimSources = [
@@ -8537,6 +8625,7 @@ function planTransformHookRequest(ctx, pluginContext, code, id, currentEnvironme
8537
8625
  moduleId: moduleIdFor(source, ctx.getRoot()),
8538
8626
  source: code,
8539
8627
  serverOnlyProps: internalOptions.serverOnlyProps?.(moduleIdFor(source, ctx.getRoot())),
8628
+ routeRoot: internalOptions.unimportedRouteModule?.(moduleIdFor(source, ctx.getRoot())) === true,
8540
8629
  dev: plan.dev,
8541
8630
  buildId: internalOptions.buildId,
8542
8631
  executionLog: normalizeExecutionLogMode(internalOptions.executionLog),
@@ -8977,6 +9066,52 @@ async function importedConstantsUnchanged(pluginContext, importer, input) {
8977
9066
  return JSON.stringify(current) === JSON.stringify(known);
8978
9067
  }
8979
9068
  //#endregion
9069
+ //#region src/composed-route-modules.ts
9070
+ const SCANNED = /* @__PURE__ */ new Set([
9071
+ ".ts",
9072
+ ".tsx",
9073
+ ".mts",
9074
+ ".js",
9075
+ ".jsx",
9076
+ ".mjs",
9077
+ ".tsrx",
9078
+ ".mdx"
9079
+ ]);
9080
+ const SKIPPED_DIRS = /* @__PURE__ */ new Set([
9081
+ "node_modules",
9082
+ "dist",
9083
+ ".output",
9084
+ ".nitro",
9085
+ ".git"
9086
+ ]);
9087
+ const SPECIFIER = /(?:\bfrom|\bimport|\bimport\s*\()\s*['"]([^'"]*\.(?:tsrx|mdx)(?:\?[^'"]*)?)['"]/g;
9088
+ /**
9089
+ * The page modules some file in the app imports. A page nothing imports is
9090
+ * rendered only by the router, so its props never change in the browser; one
9091
+ * that is imported may be rendered as a child whose props can.
9092
+ */
9093
+ async function importedRouteModules(input) {
9094
+ const imported = /* @__PURE__ */ new Set();
9095
+ const visit = async (dir) => {
9096
+ const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
9097
+ await Promise.all(entries.map(async (entry) => {
9098
+ const path = join(dir, entry.name);
9099
+ if (entry.isDirectory()) {
9100
+ if (!SKIPPED_DIRS.has(entry.name) && !entry.name.startsWith(".")) await visit(path);
9101
+ return;
9102
+ }
9103
+ if (!SCANNED.has(extname(entry.name))) return;
9104
+ const source = await readFile(path, "utf8").catch(() => "");
9105
+ for (const [, specifier] of source.matchAll(SPECIFIER)) {
9106
+ const file = (await input.resolve(specifier, path))?.split("?")[0];
9107
+ if (file && file !== path && input.isRoute(file)) imported.add(file);
9108
+ }
9109
+ }));
9110
+ };
9111
+ await visit(input.root);
9112
+ return imported;
9113
+ }
9114
+ //#endregion
8980
9115
  //#region src/rolldown.ts
8981
9116
  const marklessClient = (options = {}) => createMarklessRolldownPlugin({
8982
9117
  environment: "client",
@@ -9050,6 +9185,9 @@ function createMarklessRolldownPlugin(input) {
9050
9185
  },
9051
9186
  declareServerOnlyProps: (resolve) => {
9052
9187
  internalOptions.serverOnlyProps = resolve;
9188
+ },
9189
+ declareRouteModules: (isRoute) => {
9190
+ internalOptions.routeModules = isRoute;
9053
9191
  }
9054
9192
  },
9055
9193
  name,
@@ -9067,6 +9205,16 @@ function createMarklessRolldownPlugin(input) {
9067
9205
  dev.reset();
9068
9206
  clearParsedChunkCode();
9069
9207
  const currentRoot = getRoot();
9208
+ const isRoute = internalOptions.routeModules;
9209
+ if (isRoute && internalOptions.dev !== true && currentRoot) {
9210
+ const imported = await importedRouteModules({
9211
+ root: currentRoot,
9212
+ isRoute: (file) => isRoute(moduleIdFor(file, currentRoot)),
9213
+ resolve: async (specifier, importer) => (await this.resolve(specifier, importer, { skipSelf: true }).catch(() => null))?.id
9214
+ });
9215
+ const importedIds = new Set([...imported].map((file) => moduleIdFor(file, currentRoot)));
9216
+ internalOptions.unimportedRouteModule = (moduleId) => isRoute(moduleId) && !importedIds.has(moduleId);
9217
+ } else internalOptions.unimportedRouteModule = void 0;
9070
9218
  if (getEnvironment(this) === "client") for (const source of clientSymbolEntries(input.input, currentRoot)) clientSymbolEntrySources.add(source);
9071
9219
  },
9072
9220
  buildEnd: packing?.buildEnd,
@@ -9104,7 +9252,10 @@ function createMarklessRolldownPlugin(input) {
9104
9252
  if (stale.length > 0) this.error(staleChunkNamesMessage(stale));
9105
9253
  const unmapped = unmappedChunkSpecifiers(bundle);
9106
9254
  if (unmapped.length > 0) this.error(`Markless emitted chunks that import specifiers its import map does not resolve to an emitted chunk: ${unmapped.join(", ")}. A plugin changed chunk code or file names after the Markless finalize pass. ${DEBUGGING_PLAYBOOK_HINT}`);
9107
- if (output.dir) await moveImportMapOutOfClientOutput(output.dir, MARKLESS_IMPORT_MAP_ASSET in bundle);
9255
+ if (output.dir) {
9256
+ await moveImportMapOutOfClientOutput(output.dir, MARKLESS_IMPORT_MAP_ASSET in bundle);
9257
+ await moveBuildMetadataOutOfClientOutput(output.dir, new Set(Object.keys(bundle)), { executionLogActive: executionLogActivationInjection(internalOptions.executionLog) !== null });
9258
+ }
9108
9259
  }
9109
9260
  };
9110
9261
  }
@@ -9113,4 +9264,4 @@ function pluginName(environment) {
9113
9264
  return `markless:rolldown:${environment}`;
9114
9265
  }
9115
9266
  //#endregion
9116
- export { inlineDeferSource as A, importMapScript as C, transformTsrxModule as D, preflightTsrxModuleDiagnostics as E, INLINE_DEFER_LOADER_SOURCE as O, MARKLESS_IMPORT_MAP_ASSET as S, prefetchChunkParses as T, createPreloadGraphAdder as _, collapseInitFacadeImports as a, marklessImportMapPath as b, collectHeadLinkInjections as c, nativePackingEnabled as d, nativePackingPlugins as f, convertManifestToBundleGraph as g, withUndemandedReExportDoors as h, marklessServer as i, createInlineDeferTriggerSource as k, marklessRuntimeSpecifierId as l, undemandedRuntimeModules as m, marklessClient as n, unwrapAsyncImportWrappers as o, isReExportDoor as p, marklessLib as r, createBuildMetadata as s, createMarklessRolldownPlugin as t, DEPRECATED_NATIVE_PACKING_WARNING as u, runtimeModuleIdFromOrigin as v, insertImportMapScript as w, MARKLESS_CHUNK_SPECIFIER_PREFIX as x, marklessBuildManifestDir as y };
9267
+ export { createInlineDeferTriggerSource as A, MARKLESS_IMPORT_MAP_ASSET as C, preflightTsrxModuleDiagnostics as D, prefetchChunkParses as E, moduleIdFor as M, transformTsrxModule as O, MARKLESS_CHUNK_SPECIFIER_PREFIX as S, insertImportMapScript as T, createPreloadGraphAdder as _, collapseInitFacadeImports as a, marklessBuildManifestPath as b, collectHeadLinkInjections as c, nativePackingEnabled as d, nativePackingPlugins as f, convertManifestToBundleGraph as g, withUndemandedReExportDoors as h, marklessServer as i, inlineDeferSource as j, INLINE_DEFER_LOADER_SOURCE as k, marklessRuntimeSpecifierId as l, undemandedRuntimeModules as m, marklessClient as n, unwrapAsyncImportWrappers as o, isReExportDoor as p, marklessLib as r, createBuildMetadata as s, createMarklessRolldownPlugin as t, DEPRECATED_NATIVE_PACKING_WARNING as u, runtimeModuleIdFromOrigin as v, importMapScript as w, marklessImportMapPath as x, marklessBuildManifestDir as y };
@@ -1,5 +1,5 @@
1
- import { _ as TransformTsrxModuleInput, a as MarklessBundle, c as MarklessEnvironment, d as MarklessRolldownPluginApi, f as MarklessTransformManifest, g as PreloadGraphEntriesAdder, h as PreloadGraphEntries, i as MarklessBuildMetadata, l as MarklessManifest, m as PreloadGraphContext, n as GlobalInjections, o as MarklessBundleGraph, p as MarklessVirtualModule, r as MarklessAsset, s as MarklessDevServer, t as BundleGraphAdder, u as MarklessRolldownOptions, v as TransformTsrxModuleResult } from "./types-BqSoEVp6.js";
2
- import { a as resumeVirtualModuleId, n as MARKLESS_VIRTUAL_PREFIX, r as prerenderWakeVirtualModuleId } from "./execution-log-D9cex1i1.js";
1
+ import { _ as TransformTsrxModuleInput, a as MarklessBundle, c as MarklessEnvironment, d as MarklessRolldownPluginApi, f as MarklessTransformManifest, g as PreloadGraphEntriesAdder, h as PreloadGraphEntries, i as MarklessBuildMetadata, l as MarklessManifest, m as PreloadGraphContext, n as GlobalInjections, o as MarklessBundleGraph, p as MarklessVirtualModule, r as MarklessAsset, s as MarklessDevServer, t as BundleGraphAdder, u as MarklessRolldownOptions, v as TransformTsrxModuleResult } from "./types-iOUoceJ-.js";
2
+ import { a as resumeVirtualModuleId, n as MARKLESS_VIRTUAL_PREFIX, r as prerenderWakeVirtualModuleId } from "./execution-log-BL-7a77M.js";
3
3
  import { ProtocolStatePayload, ProtocolViewPayload } from "@markless/serializer";
4
4
  import { ArtifactChildMaterialization, CompilerDiagnostic, ModuleGraphInterfaceArtifact, SemanticGraphInput } from "@markless/compiler";
5
5
  import "@markless/web/inline/resumer";
@@ -18,6 +18,7 @@ type Environment = MarklessEnvironment | ((context: unknown) => MarklessEnvironm
18
18
  export declare const MARKLESS_BUILD_PREFIX = "build/";
19
19
  export declare const MARKLESS_BUNDLE_GRAPH = "build/bundle-graph.json";
20
20
  export declare const MARKLESS_BUILD_METADATA_FILES: readonly ["build/bundle-graph.json", "build/execution-sizes.json", "build/execution-demand.json", "build/interaction-closures.json", "build/byte-attribution.json"];
21
+ export declare const MARKLESS_PUBLIC_BUILD_METADATA_FILES: readonly ["build/execution-sizes.json"];
21
22
  export declare function outputDefaults(output: OutputOptions, environment: MarklessEnvironment): OutputOptions;
22
23
  //#endregion
23
24
  //#region src/build/build-metadata.d.ts
@@ -76,6 +77,8 @@ export declare function collectHeadLinkInjections(bundle: HeadLinkBundle, option
76
77
  //#region src/build/build-manifests.d.ts
77
78
  /** Where build-time hand-off files for a client output live: beside it, never inside the directory a host serves. */
78
79
  export declare function marklessBuildManifestDir(clientOutDir: string): string;
80
+ /** Where a build metadata file such as `build/bundle-graph.json` lands for a client output. */
81
+ export declare function marklessBuildManifestPath(clientOutDir: string, metadataFile: string): string;
79
82
  /** The chunk import map a packed client build hands to the server that renders its documents. */
80
83
  export declare function marklessImportMapPath(clientOutDir: string): string;
81
84
  //#endregion
package/dist/rolldown.js CHANGED
@@ -1,3 +1,3 @@
1
- import { X as MARKLESS_BUILD_PREFIX, Y as MARKLESS_BUILD_METADATA_FILES, Z as MARKLESS_BUNDLE_GRAPH, ht as resumeVirtualModuleId, nt as outputDefaults, pt as prerenderWakeVirtualModuleId, rt as MARKLESS_VIRTUAL_PREFIX } from "./route-pack-groups-BpefyjrE.js";
2
- import { C as importMapScript, D as transformTsrxModule, S as MARKLESS_IMPORT_MAP_ASSET, _ as createPreloadGraphAdder, b as marklessImportMapPath, c as collectHeadLinkInjections, g as convertManifestToBundleGraph, i as marklessServer, n as marklessClient, r as marklessLib, s as createBuildMetadata, t as createMarklessRolldownPlugin, w as insertImportMapScript, x as MARKLESS_CHUNK_SPECIFIER_PREFIX, y as marklessBuildManifestDir } from "./rolldown-BciZw5hZ.js";
3
- export { MARKLESS_BUILD_METADATA_FILES, MARKLESS_BUILD_PREFIX, MARKLESS_BUNDLE_GRAPH, MARKLESS_CHUNK_SPECIFIER_PREFIX, MARKLESS_IMPORT_MAP_ASSET, MARKLESS_VIRTUAL_PREFIX, collectHeadLinkInjections, convertManifestToBundleGraph, createBuildMetadata, createMarklessRolldownPlugin, createPreloadGraphAdder, importMapScript, insertImportMapScript, marklessBuildManifestDir, marklessClient, marklessImportMapPath, marklessLib, marklessServer, outputDefaults, prerenderWakeVirtualModuleId, resumeVirtualModuleId, transformTsrxModule };
1
+ import { $ as MARKLESS_BUNDLE_GRAPH, Q as MARKLESS_BUILD_PREFIX, Z as MARKLESS_BUILD_METADATA_FILES, at as outputDefaults, gt as prerenderWakeVirtualModuleId, it as MARKLESS_PUBLIC_BUILD_METADATA_FILES, ot as MARKLESS_VIRTUAL_PREFIX, vt as resumeVirtualModuleId } from "./route-pack-groups-BXc755qH.js";
2
+ import { C as MARKLESS_IMPORT_MAP_ASSET, O as transformTsrxModule, S as MARKLESS_CHUNK_SPECIFIER_PREFIX, T as insertImportMapScript, _ as createPreloadGraphAdder, b as marklessBuildManifestPath, c as collectHeadLinkInjections, g as convertManifestToBundleGraph, i as marklessServer, n as marklessClient, r as marklessLib, s as createBuildMetadata, t as createMarklessRolldownPlugin, w as importMapScript, x as marklessImportMapPath, y as marklessBuildManifestDir } from "./rolldown-DpkfQO1h.js";
3
+ export { MARKLESS_BUILD_METADATA_FILES, MARKLESS_BUILD_PREFIX, MARKLESS_BUNDLE_GRAPH, MARKLESS_CHUNK_SPECIFIER_PREFIX, MARKLESS_IMPORT_MAP_ASSET, MARKLESS_PUBLIC_BUILD_METADATA_FILES, MARKLESS_VIRTUAL_PREFIX, collectHeadLinkInjections, convertManifestToBundleGraph, createBuildMetadata, createMarklessRolldownPlugin, createPreloadGraphAdder, importMapScript, insertImportMapScript, marklessBuildManifestDir, marklessBuildManifestPath, marklessClient, marklessImportMapPath, marklessLib, marklessServer, outputDefaults, prerenderWakeVirtualModuleId, resumeVirtualModuleId, transformTsrxModule };