vinext 0.0.46 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +7 -5
  2. package/dist/build/prerender.d.ts +2 -1
  3. package/dist/build/prerender.js +70 -14
  4. package/dist/build/prerender.js.map +1 -1
  5. package/dist/build/report.d.ts +1 -1
  6. package/dist/build/route-classification-injector.d.ts +35 -0
  7. package/dist/build/route-classification-injector.js +61 -0
  8. package/dist/build/route-classification-injector.js.map +1 -0
  9. package/dist/build/route-classification-manifest.d.ts +1 -1
  10. package/dist/build/static-export.d.ts +1 -1
  11. package/dist/cli-args.d.ts +31 -0
  12. package/dist/cli-args.js +104 -0
  13. package/dist/cli-args.js.map +1 -0
  14. package/dist/cli.js +2 -19
  15. package/dist/cli.js.map +1 -1
  16. package/dist/cloudflare/kv-cache-handler.js +29 -9
  17. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  18. package/dist/config/next-config.d.ts +4 -2
  19. package/dist/config/next-config.js +3 -0
  20. package/dist/config/next-config.js.map +1 -1
  21. package/dist/entries/app-rsc-entry.d.ts +4 -3
  22. package/dist/entries/app-rsc-entry.js +373 -854
  23. package/dist/entries/app-rsc-entry.js.map +1 -1
  24. package/dist/entries/app-rsc-manifest.d.ts +1 -1
  25. package/dist/entries/app-rsc-manifest.js +2 -0
  26. package/dist/entries/app-rsc-manifest.js.map +1 -1
  27. package/dist/entries/pages-server-entry.js +5 -2
  28. package/dist/entries/pages-server-entry.js.map +1 -1
  29. package/dist/index.js +28 -51
  30. package/dist/index.js.map +1 -1
  31. package/dist/plugins/fonts.js +54 -32
  32. package/dist/plugins/fonts.js.map +1 -1
  33. package/dist/plugins/rsc-client-shim-excludes.js +1 -0
  34. package/dist/plugins/rsc-client-shim-excludes.js.map +1 -1
  35. package/dist/routing/app-route-graph.d.ts +109 -0
  36. package/dist/routing/app-route-graph.js +819 -0
  37. package/dist/routing/app-route-graph.js.map +1 -0
  38. package/dist/routing/app-router.d.ts +2 -88
  39. package/dist/routing/app-router.js +6 -694
  40. package/dist/routing/app-router.js.map +1 -1
  41. package/dist/server/app-browser-entry.js +86 -252
  42. package/dist/server/app-browser-entry.js.map +1 -1
  43. package/dist/server/app-browser-error.d.ts +3 -4
  44. package/dist/server/app-browser-error.js +8 -4
  45. package/dist/server/app-browser-error.js.map +1 -1
  46. package/dist/server/app-browser-navigation-controller.d.ts +73 -0
  47. package/dist/server/app-browser-navigation-controller.js +282 -0
  48. package/dist/server/app-browser-navigation-controller.js.map +1 -0
  49. package/dist/server/app-browser-state.d.ts +1 -1
  50. package/dist/server/app-elements.js +1 -5
  51. package/dist/server/app-elements.js.map +1 -1
  52. package/dist/server/app-fallback-renderer.d.ts +57 -0
  53. package/dist/server/app-fallback-renderer.js +79 -0
  54. package/dist/server/app-fallback-renderer.js.map +1 -0
  55. package/dist/server/app-hook-warning-suppression.d.ts +7 -0
  56. package/dist/server/app-hook-warning-suppression.js +12 -0
  57. package/dist/server/app-hook-warning-suppression.js.map +1 -0
  58. package/dist/server/app-mounted-slots-header.d.ts +17 -0
  59. package/dist/server/app-mounted-slots-header.js +21 -0
  60. package/dist/server/app-mounted-slots-header.js.map +1 -0
  61. package/dist/server/app-page-boundary-render.d.ts +2 -2
  62. package/dist/server/app-page-boundary-render.js.map +1 -1
  63. package/dist/server/app-page-cache.d.ts +18 -4
  64. package/dist/server/app-page-cache.js +53 -10
  65. package/dist/server/app-page-cache.js.map +1 -1
  66. package/dist/server/app-page-dispatch.d.ts +7 -4
  67. package/dist/server/app-page-dispatch.js +24 -8
  68. package/dist/server/app-page-dispatch.js.map +1 -1
  69. package/dist/server/app-page-element-builder.d.ts +61 -0
  70. package/dist/server/app-page-element-builder.js +139 -0
  71. package/dist/server/app-page-element-builder.js.map +1 -0
  72. package/dist/server/app-page-params.d.ts +2 -1
  73. package/dist/server/app-page-params.js +3 -3
  74. package/dist/server/app-page-params.js.map +1 -1
  75. package/dist/server/app-page-render.d.ts +5 -1
  76. package/dist/server/app-page-render.js +80 -27
  77. package/dist/server/app-page-render.js.map +1 -1
  78. package/dist/server/app-page-request.d.ts +19 -4
  79. package/dist/server/app-page-request.js +51 -6
  80. package/dist/server/app-page-request.js.map +1 -1
  81. package/dist/server/app-page-response.d.ts +1 -0
  82. package/dist/server/app-page-response.js +3 -7
  83. package/dist/server/app-page-response.js.map +1 -1
  84. package/dist/server/app-page-route-wiring.d.ts +15 -2
  85. package/dist/server/app-page-route-wiring.js.map +1 -1
  86. package/dist/server/app-post-middleware-context.d.ts +16 -0
  87. package/dist/server/app-post-middleware-context.js +28 -0
  88. package/dist/server/app-post-middleware-context.js.map +1 -0
  89. package/dist/server/app-request-context.d.ts +22 -0
  90. package/dist/server/app-request-context.js +30 -0
  91. package/dist/server/app-request-context.js.map +1 -0
  92. package/dist/server/app-route-handler-cache.d.ts +1 -0
  93. package/dist/server/app-route-handler-cache.js +5 -1
  94. package/dist/server/app-route-handler-cache.js.map +1 -1
  95. package/dist/server/app-route-handler-dispatch.d.ts +1 -0
  96. package/dist/server/app-route-handler-dispatch.js +2 -0
  97. package/dist/server/app-route-handler-dispatch.js.map +1 -1
  98. package/dist/server/app-route-handler-execution.d.ts +2 -1
  99. package/dist/server/app-route-handler-execution.js +2 -2
  100. package/dist/server/app-route-handler-execution.js.map +1 -1
  101. package/dist/server/app-route-handler-response.d.ts +4 -2
  102. package/dist/server/app-route-handler-response.js +8 -7
  103. package/dist/server/app-route-handler-response.js.map +1 -1
  104. package/dist/server/app-rsc-error-handler.d.ts +21 -0
  105. package/dist/server/app-rsc-error-handler.js +30 -0
  106. package/dist/server/app-rsc-error-handler.js.map +1 -0
  107. package/dist/server/app-rsc-handler.d.ts +117 -0
  108. package/dist/server/app-rsc-handler.js +260 -0
  109. package/dist/server/app-rsc-handler.js.map +1 -0
  110. package/dist/server/app-rsc-request-normalization.d.ts +40 -0
  111. package/dist/server/app-rsc-request-normalization.js +63 -0
  112. package/dist/server/app-rsc-request-normalization.js.map +1 -0
  113. package/dist/server/app-rsc-response-finalizer.d.ts +30 -0
  114. package/dist/server/app-rsc-response-finalizer.js +38 -0
  115. package/dist/server/app-rsc-response-finalizer.js.map +1 -0
  116. package/dist/server/app-segment-config.d.ts +33 -0
  117. package/dist/server/app-segment-config.js +86 -0
  118. package/dist/server/app-segment-config.js.map +1 -0
  119. package/dist/server/app-server-action-execution.d.ts +2 -0
  120. package/dist/server/app-server-action-execution.js +2 -0
  121. package/dist/server/app-server-action-execution.js.map +1 -1
  122. package/dist/server/cache-control.d.ts +24 -0
  123. package/dist/server/cache-control.js +33 -0
  124. package/dist/server/cache-control.js.map +1 -0
  125. package/dist/server/dev-error-overlay-store.d.ts +23 -0
  126. package/dist/server/dev-error-overlay-store.js +67 -0
  127. package/dist/server/dev-error-overlay-store.js.map +1 -0
  128. package/dist/server/dev-error-overlay.d.ts +15 -0
  129. package/dist/server/dev-error-overlay.js +548 -0
  130. package/dist/server/dev-error-overlay.js.map +1 -0
  131. package/dist/server/instrumentation-runtime.d.ts +44 -0
  132. package/dist/server/instrumentation-runtime.js +29 -0
  133. package/dist/server/instrumentation-runtime.js.map +1 -0
  134. package/dist/server/isr-cache.d.ts +2 -7
  135. package/dist/server/isr-cache.js +7 -10
  136. package/dist/server/isr-cache.js.map +1 -1
  137. package/dist/server/pages-page-data.d.ts +2 -1
  138. package/dist/server/pages-page-data.js +6 -5
  139. package/dist/server/pages-page-data.js.map +1 -1
  140. package/dist/server/pages-page-response.d.ts +2 -1
  141. package/dist/server/pages-page-response.js +3 -2
  142. package/dist/server/pages-page-response.js.map +1 -1
  143. package/dist/server/rsc-stream-hints.d.ts +3 -1
  144. package/dist/server/rsc-stream-hints.js +4 -1
  145. package/dist/server/rsc-stream-hints.js.map +1 -1
  146. package/dist/server/seed-cache.js +19 -8
  147. package/dist/server/seed-cache.js.map +1 -1
  148. package/dist/shims/cache-runtime.js +28 -11
  149. package/dist/shims/cache-runtime.js.map +1 -1
  150. package/dist/shims/cache.d.ts +15 -3
  151. package/dist/shims/cache.js +42 -15
  152. package/dist/shims/cache.js.map +1 -1
  153. package/dist/shims/error-boundary.d.ts +17 -1
  154. package/dist/shims/error-boundary.js +31 -1
  155. package/dist/shims/error-boundary.js.map +1 -1
  156. package/dist/shims/fetch-cache.d.ts +4 -1
  157. package/dist/shims/fetch-cache.js +55 -13
  158. package/dist/shims/fetch-cache.js.map +1 -1
  159. package/dist/shims/image.js +93 -5
  160. package/dist/shims/image.js.map +1 -1
  161. package/dist/shims/request-state-types.d.ts +1 -1
  162. package/dist/shims/unified-request-context.d.ts +1 -1
  163. package/dist/shims/unified-request-context.js +1 -0
  164. package/dist/shims/unified-request-context.js.map +1 -1
  165. package/dist/shims/use-merged-ref.d.ts +7 -0
  166. package/dist/shims/use-merged-ref.js +40 -0
  167. package/dist/shims/use-merged-ref.js.map +1 -0
  168. package/dist/utils/cache-control-metadata.d.ts +6 -0
  169. package/dist/utils/cache-control-metadata.js +16 -0
  170. package/dist/utils/cache-control-metadata.js.map +1 -0
  171. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ import { validateDevRequest } from "./server/dev-origin-check.js";
23
23
  import { generateRscEntry } from "./entries/app-rsc-entry.js";
24
24
  import { generateSsrEntry } from "./entries/app-ssr-entry.js";
25
25
  import { generateBrowserEntry } from "./entries/app-browser-entry.js";
26
- import { buildGenerateBundleReplacement, buildReasonsReplacement, collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
27
- import { classifyLayoutByModuleGraph, isStaticModuleGraphResult, moduleGraphReason } from "./build/layout-classification.js";
26
+ import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
27
+ import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
28
28
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
29
29
  import { findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
30
30
  import { precompressAssets } from "./build/precompress.js";
@@ -747,6 +747,7 @@ function vinext(options = {}) {
747
747
  allowedOrigins: nextConfig?.serverActionsAllowedOrigins,
748
748
  allowedDevOrigins: nextConfig?.allowedDevOrigins,
749
749
  bodySizeLimit: nextConfig?.serverActionsBodySizeLimit,
750
+ expireTime: nextConfig?.expireTime,
750
751
  i18n: nextConfig?.i18n,
751
752
  hasPagesDir,
752
753
  publicFiles: scanPublicFileRoutes(root)
@@ -761,60 +762,36 @@ function vinext(options = {}) {
761
762
  if (this.environment?.name !== "rsc") return;
762
763
  if (!rscClassificationManifest) return;
763
764
  const enableClassificationDebug = Boolean(process.env.VINEXT_DEBUG_CLASSIFICATION);
764
- const stubRe = /function __VINEXT_CLASS\(routeIdx\)\s*\{\s*return null;?\s*\}/;
765
- const reasonsStubRe = /function __VINEXT_CLASS_REASONS\(routeIdx\)\s*\{\s*return null;?\s*\}/;
766
- const chunksMentioningStub = [];
767
- const chunksWithStubBody = [];
765
+ const chunks = [];
766
+ const chunksByFileName = /* @__PURE__ */ new Map();
768
767
  for (const chunk of Object.values(bundle)) {
769
768
  if (chunk.type !== "chunk") continue;
770
- if (!chunk.code.includes("__VINEXT_CLASS")) continue;
771
- chunksMentioningStub.push({
772
- chunk,
769
+ chunks.push({
770
+ code: chunk.code,
773
771
  fileName: chunk.fileName
774
772
  });
775
- if (stubRe.test(chunk.code)) chunksWithStubBody.push({
776
- chunk,
777
- fileName: chunk.fileName
778
- });
779
- }
780
- if (chunksMentioningStub.length === 0) return;
781
- if (chunksWithStubBody.length === 0) throw new Error(`vinext: build-time classification — __VINEXT_CLASS is referenced in ${chunksMentioningStub.map((c) => c.fileName).join(", ")} but no chunk contains the stub body. The generator and generateBundle have drifted.`);
782
- if (chunksWithStubBody.length > 1) throw new Error(`vinext: build-time classification — expected __VINEXT_CLASS stub in exactly one RSC chunk, found ${chunksWithStubBody.length}`);
783
- if (enableClassificationDebug && !reasonsStubRe.test(chunksWithStubBody[0].chunk.code)) throw new Error("vinext: build-time classification — __VINEXT_CLASS_REASONS stub is missing alongside __VINEXT_CLASS. The generator and generateBundle have drifted.");
784
- const moduleInfo = { getModuleInfo: (moduleId) => {
785
- const info = this.getModuleInfo(moduleId);
786
- if (!info) return null;
787
- return {
788
- importedIds: info.importedIds ?? [],
789
- dynamicImportedIds: info.dynamicallyImportedIds ?? []
790
- };
791
- } };
792
- const layer2PerRoute = /* @__PURE__ */ new Map();
793
- const graphCache = /* @__PURE__ */ new Map();
794
- for (let routeIdx = 0; routeIdx < rscClassificationManifest.routes.length; routeIdx++) {
795
- const route = rscClassificationManifest.routes[routeIdx];
796
- const perRoute = /* @__PURE__ */ new Map();
797
- for (let layoutIdx = 0; layoutIdx < route.layoutPaths.length; layoutIdx++) {
798
- if (route.layer1.has(layoutIdx)) continue;
799
- const layoutModuleId = canonicalize(route.layoutPaths[layoutIdx]);
800
- if (!moduleInfo.getModuleInfo(layoutModuleId)) continue;
801
- let graphResult = graphCache.get(layoutModuleId);
802
- if (graphResult === void 0) {
803
- graphResult = classifyLayoutByModuleGraph(layoutModuleId, dynamicShimPaths, moduleInfo);
804
- graphCache.set(layoutModuleId, graphResult);
805
- }
806
- if (isStaticModuleGraphResult(graphResult)) perRoute.set(layoutIdx, moduleGraphReason(graphResult));
807
- }
808
- if (perRoute.size > 0) layer2PerRoute.set(routeIdx, perRoute);
809
- }
810
- const patchedBody = `function __VINEXT_CLASS(routeIdx) { return (${buildGenerateBundleReplacement(rscClassificationManifest, layer2PerRoute)})(routeIdx); }`;
811
- const target = chunksWithStubBody[0].chunk;
812
- target.code = target.code.replace(stubRe, patchedBody);
813
- if (enableClassificationDebug) {
814
- const patchedReasonsBody = `function __VINEXT_CLASS_REASONS(routeIdx) { return (${buildReasonsReplacement(rscClassificationManifest, layer2PerRoute)})(routeIdx); }`;
815
- target.code = target.code.replace(reasonsStubRe, patchedReasonsBody);
773
+ chunksByFileName.set(chunk.fileName, chunk);
816
774
  }
817
- target.map = null;
775
+ const patchPlan = planRouteClassificationInjection({
776
+ canonicalizeLayoutPath: canonicalize,
777
+ chunks,
778
+ dynamicShimPaths,
779
+ enableDebugReasons: enableClassificationDebug,
780
+ manifest: rscClassificationManifest,
781
+ moduleInfo: { getModuleInfo: (moduleId) => {
782
+ const info = this.getModuleInfo(moduleId);
783
+ if (!info) return null;
784
+ return {
785
+ importedIds: info.importedIds ?? [],
786
+ dynamicImportedIds: info.dynamicallyImportedIds ?? []
787
+ };
788
+ } }
789
+ });
790
+ if (patchPlan.kind === "skip") return;
791
+ const target = chunksByFileName.get(patchPlan.fileName);
792
+ if (!target) throw new Error(`vinext: build-time classification — patch target ${patchPlan.fileName} disappeared from the RSC bundle`);
793
+ target.code = patchPlan.code;
794
+ target.map = patchPlan.map;
818
795
  rscClassificationManifest = null;
819
796
  }
820
797
  },