@evoscientist/webui 0.2.9 → 0.3.1
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.
- package/dist/.next/BUILD_ID +1 -1
- package/dist/.next/build-manifest.json +6 -6
- package/dist/.next/prerender-manifest.json +6 -6
- package/dist/.next/server/app/_global-error/page/build-manifest.json +3 -3
- package/dist/.next/server/app/_global-error/page.js +3 -3
- package/dist/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/dist/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_global-error.html +1 -1
- package/dist/.next/server/app/_global-error.meta +8 -0
- package/dist/.next/server/app/_global-error.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found/page/build-manifest.json +3 -3
- package/dist/.next/server/app/_not-found/page.js +3 -3
- package/dist/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.meta +8 -0
- package/dist/.next/server/app/_not-found.rsc +2 -2
- package/dist/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/dist/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/dist/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/dist/.next/server/app/api/evosci-config/route.js +1 -1
- package/dist/.next/server/app/api/evosci-config/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/evosci-config/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/memory/executions/route.js +1 -1
- package/dist/.next/server/app/api/memory/executions/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/memory/executions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/memory/observations/route.js +1 -1
- package/dist/.next/server/app/api/memory/observations/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/memory/observations/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/memory/route.js +1 -1
- package/dist/.next/server/app/api/memory/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/memory/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/skills/catalog/route.js +1 -1
- package/dist/.next/server/app/api/skills/catalog/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/catalog/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/skills/detail/route.js +1 -1
- package/dist/.next/server/app/api/skills/detail/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/detail/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/skills/install/route.js +1 -1
- package/dist/.next/server/app/api/skills/install/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/skills/route.js +1 -1
- package/dist/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/workspace/download/route.js +1 -1
- package/dist/.next/server/app/api/workspace/download/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/workspace/download/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/workspace/file/route.js +1 -1
- package/dist/.next/server/app/api/workspace/file/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/workspace/file/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/workspace/route.js +1 -1
- package/dist/.next/server/app/api/workspace/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/workspace/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/workspace/upload/route.js +1 -1
- package/dist/.next/server/app/api/workspace/upload/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/workspace/upload/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/icon.png/route.js +1 -1
- package/dist/.next/server/app/icon.png/route.js.nft.json +1 -1
- package/dist/.next/server/app/icon.png.meta +1 -1
- package/dist/.next/server/app/index.html +1 -1
- package/dist/.next/server/app/index.meta +8 -0
- package/dist/.next/server/app/index.rsc +3 -3
- package/dist/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/dist/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/dist/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/dist/.next/server/app/page/build-manifest.json +3 -3
- package/dist/.next/server/app/page.js +3 -3
- package/dist/.next/server/app/page.js.nft.json +1 -1
- package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/chunks/{[externals]__0l8ei7u._.js → [externals]__12s2uxr._.js} +2 -2
- package/dist/.next/server/chunks/[root-of-the-server]__0239a1s._.js +1 -1
- package/dist/.next/server/chunks/[root-of-the-server]__0l3yhx4._.js +2 -2
- package/dist/.next/server/chunks/{[root-of-the-server]__0c_9zoh._.js → [root-of-the-server]__0lmbd-x._.js} +1 -1
- package/dist/.next/server/chunks/{[root-of-the-server]__08gtyud._.js → [root-of-the-server]__0o8rrlw._.js} +1 -1
- package/dist/.next/server/chunks/{[root-of-the-server]__0dsauq5._.js → [root-of-the-server]__0tsmn4o._.js} +1 -1
- package/dist/.next/server/chunks/[root-of-the-server]__1301wm3._.js +6 -0
- package/dist/.next/server/chunks/[root-of-the-server]__13z7yld._.js +3 -0
- package/dist/.next/server/chunks/[root-of-the-server]__1csj9d7._.js +6 -0
- package/dist/.next/server/chunks/[root-of-the-server]__1lhglnn._.js +6 -0
- package/dist/.next/server/chunks/[root-of-the-server]__21ai51o._.js +6 -0
- package/dist/.next/server/chunks/_00r_7g_._.js +1 -1
- package/dist/.next/server/chunks/_042sj8j._.js +1 -1
- package/dist/.next/server/chunks/_0lp3ten._.js +1 -1
- package/dist/.next/server/chunks/_0m7b81h._.js +1 -1
- package/dist/.next/server/chunks/_13lro7d._.js +1 -1
- package/dist/.next/server/chunks/_154zcbx._.js +1 -1
- package/dist/.next/server/chunks/_1_oz68h._.js +1 -1
- package/dist/.next/server/chunks/_1lqtgjk._.js +1 -1
- package/dist/.next/server/chunks/ssr/{[root-of-the-server]__0xpcv9w._.js → [root-of-the-server]__0gz0l81._.js} +4 -4
- package/dist/.next/server/chunks/ssr/{[root-of-the-server]__0o0ct70._.js → [root-of-the-server]__0ofckpb._.js} +2 -2
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__1q-wcrf._.js +4 -4
- package/dist/.next/server/chunks/ssr/{node_modules_1rsc-gt._.js → node_modules_0-5losv._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1i5ml3x._.js → node_modules_0-uwdov._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_0zzr3iv._.js → node_modules_003l9s_._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1xgltz7._.js → node_modules_01lxr8w._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0u5o24a._.js → node_modules_06d96_7._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0gmj-7m._.js → node_modules_078ku58._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0z53q9t._.js → node_modules_0b_h7uo._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_0s436hr._.js → node_modules_0f8ss6x._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_042csl2._.js → node_modules_0gorpj1._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_0_n1n9u._.js → node_modules_0ibftfb._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1wvft2t._.js → node_modules_0if76xt._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0j6b-p5._.js → node_modules_0kim9kf._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_0bnt8d5._.js → node_modules_0na2xfw._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_1bompw4._.js → node_modules_0rrx3v9._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_03mz3d2._.js → node_modules_0svpaox._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1y4f8cf._.js → node_modules_0t_f7hd._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0mhroki._.js → node_modules_0ygb0yl._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_14j-r2i._.js → node_modules_15h3mt3._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_16ih6qm._.js → node_modules_15sdrja._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_18frml9._.js → node_modules_16u9hvv._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_14_5zct._.js → node_modules_19nwszm._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1z39zs4._.js → node_modules_1fe5i2w._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1wn8qu0._.js → node_modules_1i7ymbt._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1jpkt5_._.js → node_modules_1peqwpp._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0-3gk4n._.js → node_modules_1qo98iu._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0_3n1hi._.js → node_modules_1yd27ha._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1ti62ba._.js → node_modules_1z-i33h._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_1b08rf0._.js → node_modules_207k920._.js} +2 -2
- package/dist/.next/server/chunks/ssr/{node_modules_1bddg7x._.js → node_modules_20f84v9._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_0pimgwq._.js → node_modules_20mk7cs._.js} +1 -1
- package/dist/.next/server/chunks/ssr/{node_modules_katex_dist_katex_mjs_16enqn_._.js → node_modules_katex_dist_katex_mjs_1zkqvut._.js} +1 -1
- package/dist/.next/server/chunks/ssr/node_modules_mermaid_dist_chunks_mermaid_core_chunk-DU6HZSFF_mjs_20hsuk9._.js +2 -2
- package/dist/.next/server/chunks/ssr/node_modules_next_dist_0nkkbfv._.js +6 -0
- package/dist/.next/server/middleware-build-manifest.js +6 -6
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/server-reference-manifest.js +1 -1
- package/dist/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/static/chunks/04hyl-myn66lr.css +3 -0
- package/dist/.next/static/chunks/13ss71zqoc3if.js +122 -0
- package/dist/.next/static/chunks/1pp43a1pyu2lp.js +13 -0
- package/dist/.next/static/chunks/{02g89o135esk3.js → 36z02g61bmnkq.js} +1 -1
- package/dist/.next/static/chunks/{2zf625u-tcwdn.js → 3gwb465dhjxo9.js} +1 -1
- package/dist/.next/static/chunks/{3fg_vuz1xt14w.js → 45asonyfr0kfy.js} +1 -1
- package/dist/.next/static/chunks/{turbopack-3cm-eevva8ksw.js → turbopack-3it-vrv5uq3no.js} +1 -1
- package/dist/node_modules/@next/env/package.json +1 -1
- package/dist/node_modules/next/dist/build/swc/index.js +1 -1
- package/dist/node_modules/next/dist/compiled/hash.js/sha256/256.js +1 -0
- package/dist/node_modules/next/dist/compiled/hash.js/sha256/package.json +1 -0
- package/dist/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +17 -17
- package/dist/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +18 -18
- package/dist/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +3 -3
- package/dist/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +13 -13
- package/dist/node_modules/next/dist/experimental/testmode/fetch.js +10 -2
- package/dist/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/dist/node_modules/next/dist/lib/typescript/runTypeScriptCli.js +2 -2
- package/dist/node_modules/next/dist/lib/verify-typescript-setup.js +3 -1
- package/dist/node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js +2 -1
- package/dist/node_modules/next/dist/server/base-server.js +1 -2
- package/dist/node_modules/next/dist/server/config.js +1 -1
- package/dist/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
- package/dist/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/node_modules/next/dist/server/image-optimizer.js +281 -55
- package/dist/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- package/dist/node_modules/next/dist/server/lib/disk-lru-cache.external.js +7 -1
- package/dist/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +177 -19
- package/dist/node_modules/next/dist/server/lib/incremental-cache/index.js +36 -17
- package/dist/node_modules/next/dist/server/lib/incremental-cache/shared-cache-controls.external.js +14 -6
- package/dist/node_modules/next/dist/server/lib/match-next-data-pathname.js +3 -1
- package/dist/node_modules/next/dist/server/lib/node-fs-methods.js +14 -0
- package/dist/node_modules/next/dist/server/lib/route-cache-key.js +77 -0
- package/dist/node_modules/next/dist/server/lib/router-utils/block-cross-site-dev.js +9 -11
- package/dist/node_modules/next/dist/server/lib/start-server.js +1 -1
- package/dist/node_modules/next/dist/server/mcp/get-mcp-middleware.js +4 -2
- package/dist/node_modules/next/dist/server/next-server.js +7 -3
- package/dist/node_modules/next/dist/server/response-cache/index.js +32 -16
- package/dist/node_modules/next/dist/server/route-matcher-providers/app-page-route-matcher-provider.js +2 -2
- package/dist/node_modules/next/dist/server/route-modules/pages/pages-handler.js +6 -1
- package/dist/node_modules/next/dist/server/route-modules/route-module.js +9 -2
- package/dist/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +36 -30
- package/dist/node_modules/next/dist/shared/lib/router/utils/app-paths.js +18 -1
- package/dist/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
- package/dist/node_modules/next/dist/telemetry/events/version.js +2 -2
- package/dist/node_modules/next/package.json +11 -11
- package/dist/package.json +3 -2
- package/package.json +3 -2
- package/dist/.next/server/chunks/[root-of-the-server]__01e0ekn._.js +0 -6
- package/dist/.next/server/chunks/[root-of-the-server]__0d2jr7j._.js +0 -3
- package/dist/.next/server/chunks/[root-of-the-server]__0om1fsa._.js +0 -6
- package/dist/.next/server/chunks/[root-of-the-server]__19l67fj._.js +0 -6
- package/dist/.next/server/chunks/[root-of-the-server]__1nb3ezt._.js +0 -6
- package/dist/.next/server/chunks/ssr/node_modules_next_dist_1n3w9lb._.js +0 -6
- package/dist/.next/static/chunks/2dmr54jagfdwa.css +0 -3
- package/dist/.next/static/chunks/3r4zv-ypmltqz.js +0 -13
- package/dist/.next/static/chunks/3zgnmu3cnahk0.js +0 -122
- /package/dist/.next/static/{jymT8vIg_gKraNQQCXVtL → wE9WfZ70fPpTyIBVT_vgk}/_buildManifest.js +0 -0
- /package/dist/.next/static/{jymT8vIg_gKraNQQCXVtL → wE9WfZ70fPpTyIBVT_vgk}/_clientMiddlewareManifest.js +0 -0
- /package/dist/.next/static/{jymT8vIg_gKraNQQCXVtL → wE9WfZ70fPpTyIBVT_vgk}/_ssgManifest.js +0 -0
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return FileSystemCache;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _routecachekey = require("../route-cache-key");
|
|
11
12
|
const _responsecache = require("../../response-cache");
|
|
12
13
|
const _path = /*#__PURE__*/ _interop_require_default(require("../../../shared/lib/isomorphic/path"));
|
|
13
14
|
const _constants = require("../../../lib/constants");
|
|
@@ -21,6 +22,7 @@ function _interop_require_default(obj) {
|
|
|
21
22
|
}
|
|
22
23
|
class FileSystemCache {
|
|
23
24
|
static #_ = this.debug = !!process.env.NEXT_PRIVATE_DEBUG_CACHE;
|
|
25
|
+
static #_2 = this.seedReads = new Map();
|
|
24
26
|
constructor(ctx){
|
|
25
27
|
this.fs = ctx.fs;
|
|
26
28
|
this.flushToDisk = ctx.flushToDisk;
|
|
@@ -40,6 +42,32 @@ class FileSystemCache {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
resetRequestCache() {}
|
|
45
|
+
getSeedReadState(key) {
|
|
46
|
+
return FileSystemCache.seedReads.get(`${this.serverDistDir}:${key}`);
|
|
47
|
+
}
|
|
48
|
+
beginSeedRead(key) {
|
|
49
|
+
const stateKey = `${this.serverDistDir}:${key}`;
|
|
50
|
+
let state = FileSystemCache.seedReads.get(stateKey);
|
|
51
|
+
if (!state) {
|
|
52
|
+
state = {
|
|
53
|
+
readers: 0,
|
|
54
|
+
version: 0
|
|
55
|
+
};
|
|
56
|
+
FileSystemCache.seedReads.set(stateKey, state);
|
|
57
|
+
}
|
|
58
|
+
state.readers++;
|
|
59
|
+
return {
|
|
60
|
+
stateKey,
|
|
61
|
+
state,
|
|
62
|
+
version: state.version
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
finishSeedRead(stateKey, state) {
|
|
66
|
+
state.readers--;
|
|
67
|
+
if (state.readers === 0 && !state.promotion) {
|
|
68
|
+
FileSystemCache.seedReads.delete(stateKey);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
43
71
|
async revalidateTag(tags, durations) {
|
|
44
72
|
tags = typeof tags === 'string' ? [
|
|
45
73
|
tags
|
|
@@ -75,10 +103,18 @@ class FileSystemCache {
|
|
|
75
103
|
}
|
|
76
104
|
}
|
|
77
105
|
async get(...args) {
|
|
78
|
-
var _FileSystemCache_memoryCache, _data_value, _data_value1, _data_value2, _data_value3;
|
|
106
|
+
var _FileSystemCache_memoryCache, _this_getSeedReadState, _data_value, _data_value1, _data_value2, _data_value3;
|
|
79
107
|
const [key, ctx] = args;
|
|
80
108
|
const { kind } = ctx;
|
|
109
|
+
let readKey = key;
|
|
110
|
+
let seedRead;
|
|
81
111
|
let data = (_FileSystemCache_memoryCache = FileSystemCache.memoryCache) == null ? void 0 : _FileSystemCache_memoryCache.get(key);
|
|
112
|
+
const activePromotion = (_this_getSeedReadState = this.getSeedReadState(key)) == null ? void 0 : _this_getSeedReadState.promotion;
|
|
113
|
+
if (!data && activePromotion) {
|
|
114
|
+
var _FileSystemCache_memoryCache1;
|
|
115
|
+
await activePromotion;
|
|
116
|
+
data = (_FileSystemCache_memoryCache1 = FileSystemCache.memoryCache) == null ? void 0 : _FileSystemCache_memoryCache1.get(key);
|
|
117
|
+
}
|
|
82
118
|
if (FileSystemCache.debug) {
|
|
83
119
|
if (kind === _responsecache.IncrementalCacheKind.FETCH) {
|
|
84
120
|
console.log('FileSystemCache: get', key, ctx.tags, kind, !!data);
|
|
@@ -86,16 +122,40 @@ class FileSystemCache {
|
|
|
86
122
|
console.log('FileSystemCache: get', key, kind, !!data);
|
|
87
123
|
}
|
|
88
124
|
}
|
|
89
|
-
|
|
125
|
+
const isResponse = kind === _responsecache.IncrementalCacheKind.PAGES || kind === _responsecache.IncrementalCacheKind.APP_PAGE || kind === _responsecache.IncrementalCacheKind.APP_ROUTE;
|
|
126
|
+
if (!data && isResponse && key.startsWith(`/${_routecachekey.ROUTE_CACHE_DIRECTORY}/`) && process.env.NEXT_RUNTIME !== 'edge') {
|
|
127
|
+
const primaryPath = this.getFilePath(kind === _responsecache.IncrementalCacheKind.APP_ROUTE ? `${key}.body` : `${key}.html`, kind);
|
|
128
|
+
if (!this.fs.existsSync(primaryPath)) {
|
|
129
|
+
const marker = key.indexOf('/$/');
|
|
130
|
+
if (marker !== -1) {
|
|
131
|
+
const legacyKey = key.slice(marker + 2);
|
|
132
|
+
const legacyMetaPath = this.getFilePath(`${legacyKey}${_constants.NEXT_META_SUFFIX}`, kind);
|
|
133
|
+
try {
|
|
134
|
+
var _meta_routeCache;
|
|
135
|
+
const meta = JSON.parse(this.fs.readFileSync(legacyMetaPath, 'utf8'));
|
|
136
|
+
const namespaceEnd = key.indexOf('/$/');
|
|
137
|
+
const ownerKey = meta.routeCache ? (0, _routecachekey.getRouteCacheKey)('/', meta.routeCache.owner) : undefined;
|
|
138
|
+
if (((_meta_routeCache = meta.routeCache) == null ? void 0 : _meta_routeCache.key) === key && (meta.routeCache.isFallback === Boolean(ctx.isFallback) || // PPR also reads fallback shells through ordinary response and
|
|
139
|
+
// navigation resume-data lookups, which set isFallback: false.
|
|
140
|
+
kind === _responsecache.IncrementalCacheKind.APP_PAGE && ctx.isRoutePPREnabled && meta.postponed != null) && (ownerKey == null ? void 0 : ownerKey.slice(0, ownerKey.indexOf('/$/'))) === key.slice(0, namespaceEnd)) {
|
|
141
|
+
readKey = legacyKey;
|
|
142
|
+
seedRead = this.beginSeedRead(key);
|
|
143
|
+
}
|
|
144
|
+
} catch {}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Check the scoped disk entry first, or a verified immutable build seed
|
|
149
|
+
// only when its scoped primary payload is genuinely absent.
|
|
90
150
|
if (!data && process.env.NEXT_RUNTIME !== 'edge') {
|
|
91
151
|
try {
|
|
92
152
|
if (kind === _responsecache.IncrementalCacheKind.APP_ROUTE) {
|
|
93
|
-
const filePath = this.getFilePath(`${
|
|
153
|
+
const filePath = this.getFilePath(`${readKey}.body`, _responsecache.IncrementalCacheKind.APP_ROUTE);
|
|
94
154
|
const fileData = await this.fs.readFile(filePath);
|
|
95
155
|
const { mtime } = await this.fs.stat(filePath);
|
|
96
156
|
const meta = JSON.parse(await this.fs.readFile(filePath.replace(/\.body$/, _constants.NEXT_META_SUFFIX), 'utf8'));
|
|
97
157
|
data = {
|
|
98
|
-
lastModified: mtime.getTime(),
|
|
158
|
+
lastModified: meta.routeCacheLastModified ?? mtime.getTime(),
|
|
99
159
|
value: {
|
|
100
160
|
kind: _responsecache.CachedRouteKind.APP_ROUTE,
|
|
101
161
|
body: fileData,
|
|
@@ -104,7 +164,7 @@ class FileSystemCache {
|
|
|
104
164
|
}
|
|
105
165
|
};
|
|
106
166
|
} else {
|
|
107
|
-
const filePath = this.getFilePath(kind === _responsecache.IncrementalCacheKind.FETCH ?
|
|
167
|
+
const filePath = this.getFilePath(kind === _responsecache.IncrementalCacheKind.FETCH ? readKey : `${readKey}.html`, kind);
|
|
108
168
|
const fileData = await this.fs.readFile(filePath, 'utf8');
|
|
109
169
|
const { mtime } = await this.fs.stat(filePath);
|
|
110
170
|
if (kind === _responsecache.IncrementalCacheKind.FETCH) {
|
|
@@ -136,12 +196,10 @@ class FileSystemCache {
|
|
|
136
196
|
}
|
|
137
197
|
}
|
|
138
198
|
} else if (kind === _responsecache.IncrementalCacheKind.APP_PAGE) {
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
meta = JSON.parse(await this.fs.readFile(filePath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), 'utf8'));
|
|
144
|
-
} catch {}
|
|
199
|
+
// Metadata is required for both normal entries and fallback shells.
|
|
200
|
+
// Promoted entries publish their primary payload last, so a missing
|
|
201
|
+
// sidecar means the scoped entry is incomplete.
|
|
202
|
+
const meta = JSON.parse(await this.fs.readFile(filePath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), 'utf8'));
|
|
145
203
|
let maybeSegmentData;
|
|
146
204
|
if (meta == null ? void 0 : meta.segmentPaths) {
|
|
147
205
|
// Collect all the segment data for this page.
|
|
@@ -151,7 +209,7 @@ class FileSystemCache {
|
|
|
151
209
|
// identical regardless.
|
|
152
210
|
const segmentData = new Map();
|
|
153
211
|
maybeSegmentData = segmentData;
|
|
154
|
-
const segmentsDir =
|
|
212
|
+
const segmentsDir = readKey + _constants.RSC_SEGMENTS_DIR_SUFFIX;
|
|
155
213
|
await Promise.all(meta.segmentPaths.map(async (segmentPath)=>{
|
|
156
214
|
const segmentDataFilePath = this.getFilePath(segmentsDir + segmentPath + _constants.RSC_SEGMENT_SUFFIX, _responsecache.IncrementalCacheKind.APP_PAGE);
|
|
157
215
|
try {
|
|
@@ -165,10 +223,10 @@ class FileSystemCache {
|
|
|
165
223
|
}
|
|
166
224
|
let rscData;
|
|
167
225
|
if (!ctx.isFallback && (!ctx.isRoutePPREnabled || (meta == null ? void 0 : meta.postponed) == null)) {
|
|
168
|
-
rscData = await this.fs.readFile(this.getFilePath(`${
|
|
226
|
+
rscData = await this.fs.readFile(this.getFilePath(`${readKey}${_constants.RSC_SUFFIX}`, _responsecache.IncrementalCacheKind.APP_PAGE));
|
|
169
227
|
}
|
|
170
228
|
data = {
|
|
171
|
-
lastModified: mtime.getTime(),
|
|
229
|
+
lastModified: meta.routeCacheLastModified ?? mtime.getTime(),
|
|
172
230
|
value: {
|
|
173
231
|
kind: _responsecache.CachedRouteKind.APP_PAGE,
|
|
174
232
|
html: fileData,
|
|
@@ -180,13 +238,13 @@ class FileSystemCache {
|
|
|
180
238
|
}
|
|
181
239
|
};
|
|
182
240
|
} else if (kind === _responsecache.IncrementalCacheKind.PAGES) {
|
|
183
|
-
|
|
241
|
+
const meta = JSON.parse(await this.fs.readFile(filePath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), 'utf8'));
|
|
184
242
|
let pageData = {};
|
|
185
243
|
if (!ctx.isFallback) {
|
|
186
|
-
pageData = JSON.parse(await this.fs.readFile(this.getFilePath(`${
|
|
244
|
+
pageData = JSON.parse(await this.fs.readFile(this.getFilePath(`${readKey}${_constants.NEXT_DATA_SUFFIX}`, _responsecache.IncrementalCacheKind.PAGES), 'utf8'));
|
|
187
245
|
}
|
|
188
246
|
data = {
|
|
189
|
-
lastModified: mtime.getTime(),
|
|
247
|
+
lastModified: meta.routeCacheLastModified ?? mtime.getTime(),
|
|
190
248
|
value: {
|
|
191
249
|
kind: _responsecache.CachedRouteKind.PAGES,
|
|
192
250
|
html: fileData,
|
|
@@ -204,10 +262,15 @@ class FileSystemCache {
|
|
|
204
262
|
}
|
|
205
263
|
}
|
|
206
264
|
if (data) {
|
|
207
|
-
|
|
208
|
-
|
|
265
|
+
if (!seedRead) {
|
|
266
|
+
var _FileSystemCache_memoryCache2;
|
|
267
|
+
(_FileSystemCache_memoryCache2 = FileSystemCache.memoryCache) == null ? void 0 : _FileSystemCache_memoryCache2.set(key, data);
|
|
268
|
+
}
|
|
209
269
|
}
|
|
210
270
|
} catch {
|
|
271
|
+
if (seedRead) {
|
|
272
|
+
this.finishSeedRead(seedRead.stateKey, seedRead.state);
|
|
273
|
+
}
|
|
211
274
|
return null;
|
|
212
275
|
}
|
|
213
276
|
}
|
|
@@ -223,6 +286,9 @@ class FileSystemCache {
|
|
|
223
286
|
if (FileSystemCache.debug) {
|
|
224
287
|
console.log('FileSystemCache: expired tags', cacheTags);
|
|
225
288
|
}
|
|
289
|
+
if (seedRead) {
|
|
290
|
+
this.finishSeedRead(seedRead.stateKey, seedRead.state);
|
|
291
|
+
}
|
|
226
292
|
return null;
|
|
227
293
|
}
|
|
228
294
|
}
|
|
@@ -246,10 +312,88 @@ class FileSystemCache {
|
|
|
246
312
|
return null;
|
|
247
313
|
}
|
|
248
314
|
}
|
|
315
|
+
if (seedRead && data) {
|
|
316
|
+
const { stateKey, state, version } = seedRead;
|
|
317
|
+
try {
|
|
318
|
+
if (state.version === version) {
|
|
319
|
+
var _FileSystemCache_memoryCache3;
|
|
320
|
+
await this.promoteSeed(key, readKey, data, ctx, stateKey, state, version);
|
|
321
|
+
if (state.version === version && !((_FileSystemCache_memoryCache3 = FileSystemCache.memoryCache) == null ? void 0 : _FileSystemCache_memoryCache3.get(key))) {
|
|
322
|
+
var _FileSystemCache_memoryCache4;
|
|
323
|
+
(_FileSystemCache_memoryCache4 = FileSystemCache.memoryCache) == null ? void 0 : _FileSystemCache_memoryCache4.set(key, data);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
} finally{
|
|
327
|
+
this.finishSeedRead(stateKey, state);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
249
330
|
return data ?? null;
|
|
250
331
|
}
|
|
332
|
+
async promoteSeed(key, seedKey, data, ctx, stateKey, state, version) {
|
|
333
|
+
const writeFileAtomic = this.fs.writeFileAtomic;
|
|
334
|
+
if (!this.flushToDisk || !writeFileAtomic || !data.value) return;
|
|
335
|
+
if (state.promotion) {
|
|
336
|
+
await state.promotion;
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const promotion = (async ()=>{
|
|
340
|
+
const value = data.value;
|
|
341
|
+
if (!value || state.version !== version || value.kind !== _responsecache.CachedRouteKind.PAGES && value.kind !== _responsecache.CachedRouteKind.APP_PAGE && value.kind !== _responsecache.CachedRouteKind.APP_ROUTE) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const kind = ctx.kind;
|
|
345
|
+
const primaryPath = this.getFilePath(value.kind === _responsecache.CachedRouteKind.APP_ROUTE ? `${key}.body` : `${key}.html`, kind);
|
|
346
|
+
if (this.fs.existsSync(primaryPath)) return;
|
|
347
|
+
const seedPrimaryPath = this.getFilePath(value.kind === _responsecache.CachedRouteKind.APP_ROUTE ? `${seedKey}.body` : `${seedKey}.html`, kind);
|
|
348
|
+
const seedMetaPath = seedPrimaryPath.replace(value.kind === _responsecache.CachedRouteKind.APP_ROUTE ? /\.body$/ : /\.html$/, _constants.NEXT_META_SUFFIX);
|
|
349
|
+
const meta = JSON.parse(await this.fs.readFile(seedMetaPath, 'utf8'));
|
|
350
|
+
meta.routeCacheLastModified = data.lastModified;
|
|
351
|
+
// Copy every ancillary seed file first. The scoped primary payload is
|
|
352
|
+
// the publication marker and is written only after metadata is complete.
|
|
353
|
+
const ancillaryFiles = [];
|
|
354
|
+
if (value.kind === _responsecache.CachedRouteKind.PAGES && !ctx.isFallback) {
|
|
355
|
+
ancillaryFiles.push({
|
|
356
|
+
path: this.getFilePath(`${key}${_constants.NEXT_DATA_SUFFIX}`, kind),
|
|
357
|
+
data: await this.fs.readFile(this.getFilePath(`${seedKey}${_constants.NEXT_DATA_SUFFIX}`, kind))
|
|
358
|
+
});
|
|
359
|
+
} else if (value.kind === _responsecache.CachedRouteKind.APP_PAGE) {
|
|
360
|
+
if (!ctx.isFallback && (!ctx.isRoutePPREnabled || meta.postponed == null)) {
|
|
361
|
+
ancillaryFiles.push({
|
|
362
|
+
path: this.getFilePath(`${key}${_constants.RSC_SUFFIX}`, kind),
|
|
363
|
+
data: await this.fs.readFile(this.getFilePath(`${seedKey}${_constants.RSC_SUFFIX}`, kind))
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
ancillaryFiles.push(...await Promise.all((meta.segmentPaths ?? []).map(async (segmentPath)=>({
|
|
367
|
+
path: this.getFilePath(key + _constants.RSC_SEGMENTS_DIR_SUFFIX + segmentPath + _constants.RSC_SEGMENT_SUFFIX, kind),
|
|
368
|
+
data: await this.fs.readFile(this.getFilePath(seedKey + _constants.RSC_SEGMENTS_DIR_SUFFIX + segmentPath + _constants.RSC_SEGMENT_SUFFIX, kind))
|
|
369
|
+
}))));
|
|
370
|
+
}
|
|
371
|
+
const writer = new _multifilewriter.MultiFileWriter(this.fs);
|
|
372
|
+
for (const file of ancillaryFiles)writer.append(file.path, file.data);
|
|
373
|
+
await writer.wait();
|
|
374
|
+
if (state.version !== version) return;
|
|
375
|
+
const metaPath = primaryPath.replace(value.kind === _responsecache.CachedRouteKind.APP_ROUTE ? /\.body$/ : /\.html$/, _constants.NEXT_META_SUFFIX);
|
|
376
|
+
await this.fs.mkdir(_path.default.dirname(metaPath));
|
|
377
|
+
await this.fs.writeFile(metaPath, JSON.stringify(meta));
|
|
378
|
+
if (state.version !== version || this.fs.existsSync(primaryPath)) return;
|
|
379
|
+
await writeFileAtomic.call(this.fs, primaryPath, await this.fs.readFile(seedPrimaryPath));
|
|
380
|
+
})();
|
|
381
|
+
state.promotion = promotion.catch((error)=>{
|
|
382
|
+
if (FileSystemCache.debug) {
|
|
383
|
+
console.log('FileSystemCache: failed to promote build seed', error);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
try {
|
|
387
|
+
await state.promotion;
|
|
388
|
+
} finally{
|
|
389
|
+
if (state.promotion) state.promotion = undefined;
|
|
390
|
+
if (state.readers === 0) FileSystemCache.seedReads.delete(stateKey);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
251
393
|
async set(key, data, ctx) {
|
|
252
394
|
var _FileSystemCache_memoryCache;
|
|
395
|
+
const seedState = this.getSeedReadState(key);
|
|
396
|
+
if (seedState) seedState.version++;
|
|
253
397
|
(_FileSystemCache_memoryCache = FileSystemCache.memoryCache) == null ? void 0 : _FileSystemCache_memoryCache.set(key, {
|
|
254
398
|
value: data,
|
|
255
399
|
lastModified: Date.now()
|
|
@@ -258,6 +402,7 @@ class FileSystemCache {
|
|
|
258
402
|
console.log('FileSystemCache: set', key);
|
|
259
403
|
}
|
|
260
404
|
if (!this.flushToDisk || !data) return;
|
|
405
|
+
await (seedState == null ? void 0 : seedState.promotion);
|
|
261
406
|
// Create a new writer that will prepare to write all the files to disk
|
|
262
407
|
// after their containing directory is created.
|
|
263
408
|
const writer = new _multifilewriter.MultiFileWriter(this.fs);
|
|
@@ -299,6 +444,15 @@ class FileSystemCache {
|
|
|
299
444
|
prefetchHints: undefined
|
|
300
445
|
};
|
|
301
446
|
writer.append(htmlPath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), JSON.stringify(meta));
|
|
447
|
+
} else {
|
|
448
|
+
const meta = {
|
|
449
|
+
headers: data.headers,
|
|
450
|
+
status: data.status,
|
|
451
|
+
postponed: undefined,
|
|
452
|
+
segmentPaths: undefined,
|
|
453
|
+
prefetchHints: undefined
|
|
454
|
+
};
|
|
455
|
+
writer.append(htmlPath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), JSON.stringify(meta));
|
|
302
456
|
}
|
|
303
457
|
} else if (data.kind === _responsecache.CachedRouteKind.FETCH) {
|
|
304
458
|
const filePath = this.getFilePath(key, _responsecache.IncrementalCacheKind.FETCH);
|
|
@@ -333,6 +487,10 @@ class FileSystemCache {
|
|
|
333
487
|
configurable: true
|
|
334
488
|
});
|
|
335
489
|
}
|
|
490
|
+
// Scoped response artifacts live outside the compiled route and ASO files.
|
|
491
|
+
if ((kind === _responsecache.IncrementalCacheKind.PAGES || kind === _responsecache.IncrementalCacheKind.APP_PAGE || kind === _responsecache.IncrementalCacheKind.APP_ROUTE) && key.startsWith(`/${_routecachekey.ROUTE_CACHE_DIRECTORY}/`)) {
|
|
492
|
+
rootDir = _path.default.join(this.serverDistDir, '.');
|
|
493
|
+
}
|
|
336
494
|
const filePath = _path.default.join(rootDir, key);
|
|
337
495
|
if (!(filePath.startsWith(rootDir + _path.default.sep) || filePath === rootDir)) {
|
|
338
496
|
throw Object.defineProperty(new Error(`Invalid file path: ${filePath}`), "__NEXT_ERROR_CODE", {
|
|
@@ -20,11 +20,10 @@ _export(exports, {
|
|
|
20
20
|
return IncrementalCache;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
const _routecachekey = require("../route-cache-key");
|
|
23
24
|
const _responsecache = require("../../response-cache");
|
|
24
25
|
const _filesystemcache = /*#__PURE__*/ _interop_require_default(require("./file-system-cache"));
|
|
25
|
-
const _normalizepagepath = require("../../../shared/lib/page-path/normalize-page-path");
|
|
26
26
|
const _constants = require("../../../lib/constants");
|
|
27
|
-
const _toroute = require("../to-route");
|
|
28
27
|
const _sharedcachecontrolsexternal = require("./shared-cache-controls.external");
|
|
29
28
|
const _workunitasyncstorageexternal = require("../../app-render/work-unit-async-storage.external");
|
|
30
29
|
const _invarianterror = require("../../../shared/lib/invariant-error");
|
|
@@ -89,7 +88,7 @@ async function hashString(cacheString) {
|
|
|
89
88
|
const MAIN_KEY_PREFIX = 'v4';
|
|
90
89
|
class IncrementalCache {
|
|
91
90
|
static #_ = this.debug = !!process.env.NEXT_PRIVATE_DEBUG_CACHE;
|
|
92
|
-
constructor({ fs, dev, flushToDisk, minimalMode, serverDistDir, requestHeaders, maxMemoryCacheSize, getPrerenderManifest, fetchCacheKeyPrefix, CurCacheHandler, allowedRevalidateHeaderKeys }){
|
|
91
|
+
constructor({ fs, dev, flushToDisk, minimalMode, serverDistDir, requestHeaders, maxMemoryCacheSize, getPrerenderManifest, fetchCacheKeyPrefix, CurCacheHandler, allowedRevalidateHeaderKeys, locales }){
|
|
93
92
|
var _this_prerenderManifest_preview, _this_prerenderManifest;
|
|
94
93
|
this.locks = new Map();
|
|
95
94
|
this.hasCustomCacheHandler = Boolean(CurCacheHandler);
|
|
@@ -127,7 +126,8 @@ class IncrementalCache {
|
|
|
127
126
|
this.requestHeaders = requestHeaders;
|
|
128
127
|
this.allowedRevalidateHeaderKeys = allowedRevalidateHeaderKeys;
|
|
129
128
|
this.prerenderManifest = getPrerenderManifest();
|
|
130
|
-
this.
|
|
129
|
+
this.locales = locales;
|
|
130
|
+
this.cacheControls = new _sharedcachecontrolsexternal.SharedCacheControls(this.prerenderManifest, locales);
|
|
131
131
|
this.fetchCacheKeyPrefix = fetchCacheKeyPrefix;
|
|
132
132
|
let revalidatedTags = [];
|
|
133
133
|
if (requestHeaders[_constants.PRERENDER_REVALIDATE_HEADER] === ((_this_prerenderManifest = this.prerenderManifest) == null ? void 0 : (_this_prerenderManifest_preview = _this_prerenderManifest.preview) == null ? void 0 : _this_prerenderManifest_preview.previewModeId)) {
|
|
@@ -150,20 +150,16 @@ class IncrementalCache {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
calculateRevalidate(
|
|
153
|
+
calculateRevalidate(cacheControl, fromTime, dev, isFallback) {
|
|
154
154
|
// in development we don't have a prerender-manifest
|
|
155
155
|
// and default to always revalidating to allow easier debugging
|
|
156
156
|
if (dev) return Math.floor(performance.timeOrigin + performance.now() - 1000);
|
|
157
|
-
const cacheControl = this.cacheControls.get((0, _toroute.toRoute)(pathname));
|
|
158
157
|
// if an entry isn't present in routes we fallback to a default
|
|
159
158
|
// of revalidating after 1 second unless it's a fallback request.
|
|
160
159
|
const initialRevalidateSeconds = cacheControl ? cacheControl.revalidate : isFallback ? false : 1;
|
|
161
160
|
const revalidateAfter = typeof initialRevalidateSeconds === 'number' ? initialRevalidateSeconds * 1000 + fromTime : initialRevalidateSeconds;
|
|
162
161
|
return revalidateAfter;
|
|
163
162
|
}
|
|
164
|
-
_getPathname(pathname, fetchCache) {
|
|
165
|
-
return fetchCache ? pathname : (0, _normalizepagepath.normalizePagePath)(pathname);
|
|
166
|
-
}
|
|
167
163
|
resetRequestCache() {
|
|
168
164
|
var _this_cacheHandler_resetRequestCache, _this_cacheHandler;
|
|
169
165
|
(_this_cacheHandler = this.cacheHandler) == null ? void 0 : (_this_cacheHandler_resetRequestCache = _this_cacheHandler.resetRequestCache) == null ? void 0 : _this_cacheHandler_resetRequestCache.call(_this_cacheHandler);
|
|
@@ -307,6 +303,9 @@ class IncrementalCache {
|
|
|
307
303
|
}
|
|
308
304
|
async get(cacheKey, ctx) {
|
|
309
305
|
var _this_cacheHandler, _cacheData_value;
|
|
306
|
+
if (ctx.kind === _responsecache.IncrementalCacheKind.IMAGE) {
|
|
307
|
+
throw new _invarianterror.InvariantError('Images must use the image optimizer cache');
|
|
308
|
+
}
|
|
310
309
|
// Unlike other caches if we have a resume data cache, we use it even if
|
|
311
310
|
// testmode would normally disable it or if requestHeaders say 'no-cache'.
|
|
312
311
|
if (ctx.kind === _responsecache.IncrementalCacheKind.FETCH) {
|
|
@@ -355,8 +354,16 @@ class IncrementalCache {
|
|
|
355
354
|
if (this.disableForTestmode || this.dev && (ctx.kind !== _responsecache.IncrementalCacheKind.FETCH || this.requestHeaders['cache-control'] === 'no-cache')) {
|
|
356
355
|
return null;
|
|
357
356
|
}
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
let storageKey = cacheKey;
|
|
358
|
+
let handlerContext = ctx;
|
|
359
|
+
if (ctx.kind !== _responsecache.IncrementalCacheKind.FETCH) {
|
|
360
|
+
// Ownership scopes the key and metadata inside Next.js. Storage handlers
|
|
361
|
+
// only need the resulting key and the existing cache options.
|
|
362
|
+
const { route, ...responseContext } = ctx;
|
|
363
|
+
storageKey = (0, _routecachekey.getRouteCacheKey)(cacheKey, route);
|
|
364
|
+
handlerContext = responseContext;
|
|
365
|
+
}
|
|
366
|
+
const cacheData = await ((_this_cacheHandler = this.cacheHandler) == null ? void 0 : _this_cacheHandler.get(storageKey, handlerContext));
|
|
360
367
|
if (ctx.kind === _responsecache.IncrementalCacheKind.FETCH) {
|
|
361
368
|
var _cacheData_value1;
|
|
362
369
|
if (!cacheData) {
|
|
@@ -429,7 +436,7 @@ class IncrementalCache {
|
|
|
429
436
|
}
|
|
430
437
|
let entry = null;
|
|
431
438
|
const { isFallback } = ctx;
|
|
432
|
-
const cacheControl = this.cacheControls.get(
|
|
439
|
+
const cacheControl = this.cacheControls.get(cacheKey, ctx.route);
|
|
433
440
|
let isStale;
|
|
434
441
|
let revalidateAfter;
|
|
435
442
|
if ((cacheData == null ? void 0 : cacheData.lastModified) === -1) {
|
|
@@ -438,7 +445,7 @@ class IncrementalCache {
|
|
|
438
445
|
} else {
|
|
439
446
|
const now = performance.timeOrigin + performance.now();
|
|
440
447
|
const lastModified = (cacheData == null ? void 0 : cacheData.lastModified) || now;
|
|
441
|
-
revalidateAfter = this.calculateRevalidate(
|
|
448
|
+
revalidateAfter = this.calculateRevalidate(cacheControl, lastModified, this.dev ?? false, ctx.isFallback);
|
|
442
449
|
// If the route's `expire` time has passed, force a blocking revalidation
|
|
443
450
|
// by signalling `isStale = -1`. The response cache treats `-1` as "skip
|
|
444
451
|
// the early SWR resolve" and awaits a fresh render before the user sees a
|
|
@@ -476,7 +483,7 @@ class IncrementalCache {
|
|
|
476
483
|
isFallback
|
|
477
484
|
};
|
|
478
485
|
}
|
|
479
|
-
if (!cacheData && this.prerenderManifest.notFoundRoutes.includes(cacheKey)) {
|
|
486
|
+
if (!cacheData && this.prerenderManifest.notFoundRoutes.includes(cacheKey) && (0, _routecachekey.isRouteCacheOwner)(cacheKey, ctx.route, this.prerenderManifest.routes[cacheKey], this.locales)) {
|
|
480
487
|
// for the first hit after starting the server the cache
|
|
481
488
|
// may not have a way to save notFound: true so if
|
|
482
489
|
// the prerender-manifest marks this as notFound then we
|
|
@@ -497,6 +504,9 @@ class IncrementalCache {
|
|
|
497
504
|
return entry;
|
|
498
505
|
}
|
|
499
506
|
async set(pathname, data, ctx) {
|
|
507
|
+
if ('kind' in ctx && ctx.kind === _responsecache.IncrementalCacheKind.IMAGE) {
|
|
508
|
+
throw new _invarianterror.InvariantError('Images must use the image optimizer cache');
|
|
509
|
+
}
|
|
500
510
|
// Even if we otherwise disable caching for testMode or if no fetchCache is
|
|
501
511
|
// configured we still always stash results in the resume data cache if one
|
|
502
512
|
// exists. This is because this is a transient in memory cache that
|
|
@@ -513,7 +523,16 @@ class IncrementalCache {
|
|
|
513
523
|
}
|
|
514
524
|
}
|
|
515
525
|
if (this.disableForTestmode || this.dev && !ctx.fetchCache) return;
|
|
516
|
-
|
|
526
|
+
let storageKey = pathname;
|
|
527
|
+
let handlerContext = ctx;
|
|
528
|
+
if (!ctx.fetchCache) {
|
|
529
|
+
const { route, ...responseContext } = ctx;
|
|
530
|
+
if (!route) {
|
|
531
|
+
throw new _invarianterror.InvariantError('Response cache requires a source route');
|
|
532
|
+
}
|
|
533
|
+
storageKey = (0, _routecachekey.getRouteCacheKey)(pathname, route);
|
|
534
|
+
handlerContext = responseContext;
|
|
535
|
+
}
|
|
517
536
|
// FetchCache has upper limit of 2MB per-entry currently
|
|
518
537
|
const itemSize = JSON.stringify(data).length;
|
|
519
538
|
if (ctx.fetchCache && itemSize > 2 * 1024 * 1024 && // We ignore the size limit when custom cache handler is being used, as it
|
|
@@ -535,9 +554,9 @@ class IncrementalCache {
|
|
|
535
554
|
try {
|
|
536
555
|
var _this_cacheHandler;
|
|
537
556
|
if (!ctx.fetchCache && ctx.cacheControl) {
|
|
538
|
-
this.cacheControls.set(
|
|
557
|
+
this.cacheControls.set(storageKey, ctx.cacheControl);
|
|
539
558
|
}
|
|
540
|
-
await ((_this_cacheHandler = this.cacheHandler) == null ? void 0 : _this_cacheHandler.set(
|
|
559
|
+
await ((_this_cacheHandler = this.cacheHandler) == null ? void 0 : _this_cacheHandler.set(storageKey, data, handlerContext));
|
|
541
560
|
} catch (error) {
|
|
542
561
|
console.warn('Failed to update prerender cache for', pathname, error);
|
|
543
562
|
}
|
package/dist/node_modules/next/dist/server/lib/incremental-cache/shared-cache-controls.external.js
CHANGED
|
@@ -8,6 +8,9 @@ Object.defineProperty(exports, "SharedCacheControls", {
|
|
|
8
8
|
return SharedCacheControls;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _routecachekey = require("../route-cache-key");
|
|
12
|
+
const _normalizelocalepath = require("../../../shared/lib/i18n/normalize-locale-path");
|
|
13
|
+
const _routekind = require("../../route-kind");
|
|
11
14
|
class SharedCacheControls {
|
|
12
15
|
static #_ = /**
|
|
13
16
|
* The in-memory cache of cache lives for routes. This cache is populated when
|
|
@@ -16,8 +19,9 @@ class SharedCacheControls {
|
|
|
16
19
|
constructor(/**
|
|
17
20
|
* The prerender manifest that contains the initial cache controls for
|
|
18
21
|
* routes.
|
|
19
|
-
*/ prerenderManifest){
|
|
22
|
+
*/ prerenderManifest, locales){
|
|
20
23
|
this.prerenderManifest = prerenderManifest;
|
|
24
|
+
this.locales = locales;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* Try to get the cache control value for a route. This will first try to get
|
|
@@ -25,16 +29,17 @@ class SharedCacheControls {
|
|
|
25
29
|
* in-memory cache, it will be sourced from the prerender manifest.
|
|
26
30
|
*
|
|
27
31
|
* @param route the route to get the cache control for
|
|
32
|
+
* @param owner the source route that owns the response
|
|
28
33
|
* @returns the cache control for the route, or undefined if the values
|
|
29
34
|
* are not present in the in-memory cache or the prerender manifest
|
|
30
|
-
*/ get(route) {
|
|
35
|
+
*/ get(route, owner) {
|
|
31
36
|
// This is a copy on write cache that is updated when the cache is updated.
|
|
32
37
|
// If the cache is never written to, then the values will be sourced from
|
|
33
38
|
// the prerender manifest.
|
|
34
|
-
let cacheControl = SharedCacheControls.cacheControls.get(route);
|
|
39
|
+
let cacheControl = SharedCacheControls.cacheControls.get((0, _routecachekey.getRouteCacheKey)(route, owner));
|
|
35
40
|
if (cacheControl) return cacheControl;
|
|
36
41
|
let prerenderData = this.prerenderManifest.routes[route];
|
|
37
|
-
if (prerenderData) {
|
|
42
|
+
if (prerenderData && (0, _routecachekey.isRouteCacheOwner)(route, owner, prerenderData, this.locales)) {
|
|
38
43
|
const { initialRevalidateSeconds, initialExpireSeconds } = prerenderData;
|
|
39
44
|
if (typeof initialRevalidateSeconds !== 'undefined') {
|
|
40
45
|
return {
|
|
@@ -43,8 +48,9 @@ class SharedCacheControls {
|
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
51
|
+
const dynamicPathname = owner.kind === _routekind.RouteKind.PAGES ? (0, _normalizelocalepath.normalizeLocalePath)(route, this.locales).pathname : route;
|
|
52
|
+
const dynamicPrerenderData = this.prerenderManifest.dynamicRoutes[dynamicPathname];
|
|
53
|
+
if (dynamicPrerenderData && (0, _routecachekey.isRouteCacheOwner)(route, owner, dynamicPrerenderData, this.locales)) {
|
|
48
54
|
const { fallbackRevalidate, fallbackExpire } = dynamicPrerenderData;
|
|
49
55
|
if (typeof fallbackRevalidate !== 'undefined') {
|
|
50
56
|
return {
|
|
@@ -53,6 +59,8 @@ class SharedCacheControls {
|
|
|
53
59
|
};
|
|
54
60
|
}
|
|
55
61
|
}
|
|
62
|
+
// A new runtime pathname has no initial lifetime. Its own render supplies
|
|
63
|
+
// one instead of borrowing a sibling route's build-time metadata.
|
|
56
64
|
return undefined;
|
|
57
65
|
}
|
|
58
66
|
/**
|
|
@@ -9,7 +9,9 @@ Object.defineProperty(exports, "matchNextDataPathname", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _pathmatch = require("../../shared/lib/router/utils/path-match");
|
|
12
|
-
const matcher = (0, _pathmatch.getPathMatch)('/_next/data/:path*'
|
|
12
|
+
const matcher = (0, _pathmatch.getPathMatch)('/_next/data/:path*', {
|
|
13
|
+
sensitive: true
|
|
14
|
+
});
|
|
13
15
|
function matchNextDataPathname(pathname) {
|
|
14
16
|
if (typeof pathname !== 'string') return false;
|
|
15
17
|
return matcher(pathname);
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "nodeFs", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _nodecrypto = require("node:crypto");
|
|
12
13
|
function _interop_require_default(obj) {
|
|
13
14
|
return obj && obj.__esModule ? obj : {
|
|
14
15
|
default: obj
|
|
@@ -19,6 +20,19 @@ const nodeFs = {
|
|
|
19
20
|
readFile: _fs.default.promises.readFile,
|
|
20
21
|
readFileSync: _fs.default.readFileSync,
|
|
21
22
|
writeFile: (f, d)=>_fs.default.promises.writeFile(f, d),
|
|
23
|
+
writeFileAtomic: async (f, d)=>{
|
|
24
|
+
const temporary = `${f}.${(0, _nodecrypto.randomUUID)()}.tmp`;
|
|
25
|
+
try {
|
|
26
|
+
await _fs.default.promises.writeFile(temporary, d);
|
|
27
|
+
await _fs.default.promises.link(temporary, f);
|
|
28
|
+
return true;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error.code === 'EEXIST') return false;
|
|
31
|
+
throw error;
|
|
32
|
+
} finally{
|
|
33
|
+
await _fs.default.promises.unlink(temporary).catch(()=>{});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
22
36
|
mkdir: (dir)=>_fs.default.promises.mkdir(dir, {
|
|
23
37
|
recursive: true
|
|
24
38
|
}),
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
ROUTE_CACHE_DIRECTORY: null,
|
|
7
|
+
getResponseCacheOwner: null,
|
|
8
|
+
getRouteCacheKey: null,
|
|
9
|
+
isRouteCacheOwner: null
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: all[name]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
ROUTE_CACHE_DIRECTORY: function() {
|
|
19
|
+
return ROUTE_CACHE_DIRECTORY;
|
|
20
|
+
},
|
|
21
|
+
getResponseCacheOwner: function() {
|
|
22
|
+
return getResponseCacheOwner;
|
|
23
|
+
},
|
|
24
|
+
getRouteCacheKey: function() {
|
|
25
|
+
return getRouteCacheKey;
|
|
26
|
+
},
|
|
27
|
+
isRouteCacheOwner: function() {
|
|
28
|
+
return isRouteCacheOwner;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _normalizepagepath = require("../../shared/lib/page-path/normalize-page-path");
|
|
32
|
+
const _normalizelocalepath = require("../../shared/lib/i18n/normalize-locale-path");
|
|
33
|
+
const _invarianterror = require("../../shared/lib/invariant-error");
|
|
34
|
+
const _apppathnamenormalizer = require("../normalizers/built/app/app-pathname-normalizer");
|
|
35
|
+
const _routekind = require("../route-kind");
|
|
36
|
+
const ROUTE_CACHE_DIRECTORY = 'route-cache';
|
|
37
|
+
const appPathnameNormalizer = new _apppathnamenormalizer.AppPathnameNormalizer();
|
|
38
|
+
function getResponseCacheOwner(definition) {
|
|
39
|
+
return {
|
|
40
|
+
kind: definition.kind,
|
|
41
|
+
// Pages module names can include a trailing /index in Turbopack. Their
|
|
42
|
+
// pathname matches the manifest's source in both bundlers. App modules
|
|
43
|
+
// retain groups and parallel slots in their cache identity.
|
|
44
|
+
sourceRoute: definition.kind === _routekind.RouteKind.PAGES ? definition.pathname : definition.page
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function isRouteCacheOwner(pathname, owner, prerender, locales) {
|
|
48
|
+
if (!prerender) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// Pages have JSON data routes, App Pages have RSC data routes, and App
|
|
52
|
+
// Route Handlers have no separate data route.
|
|
53
|
+
const kind = prerender.dataRoute === null ? _routekind.RouteKind.APP_ROUTE : prerender.dataRoute.endsWith('.json') ? _routekind.RouteKind.PAGES : prerender.dataRoute.endsWith('.rsc') ? _routekind.RouteKind.APP_PAGE : undefined;
|
|
54
|
+
if (kind !== owner.kind) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const source = 'srcRoute' in prerender ? prerender.srcRoute : prerender.fallbackSourceRoute;
|
|
58
|
+
const prerenderOwner = source ?? (kind === _routekind.RouteKind.PAGES ? (0, _normalizelocalepath.normalizeLocalePath)(pathname, locales).pathname : pathname);
|
|
59
|
+
return prerenderOwner === (kind === _routekind.RouteKind.PAGES ? owner.sourceRoute : appPathnameNormalizer.normalize(owner.sourceRoute));
|
|
60
|
+
}
|
|
61
|
+
function getRouteCacheKey(pathname, owner) {
|
|
62
|
+
if (!owner) {
|
|
63
|
+
throw new _invarianterror.InvariantError('Response cache requires a source route');
|
|
64
|
+
}
|
|
65
|
+
const { sourceRoute } = owner;
|
|
66
|
+
let source;
|
|
67
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
68
|
+
const sha256 = require('next/dist/compiled/hash.js/sha256');
|
|
69
|
+
source = sha256().update(new TextEncoder().encode(sourceRoute)).digest('hex');
|
|
70
|
+
} else {
|
|
71
|
+
const { createHash } = require('crypto');
|
|
72
|
+
source = createHash('sha256').update(sourceRoute).digest('hex');
|
|
73
|
+
}
|
|
74
|
+
return `/${ROUTE_CACHE_DIRECTORY}/${owner.kind}/${source}/$${(0, _normalizepagepath.normalizePagePath)(pathname)}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=route-cache-key.js.map
|