This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import path from 'path';
import { IncrementalCache } from '../../server/lib/incremental-cache';
import { hasNextSupport } from '../../server/ci-info';
import { nodeFs } from '../../server/lib/node-fs-methods';
import { interopDefault } from '../../lib/interop-default';
import { formatDynamicImportPath } from '../../lib/format-dynamic-import-path';
import { initializeCacheHandlers, setCacheHandler } from '../../server/use-cache/handlers';
export async function createIncrementalCache({ cacheHandler, cacheMaxMemorySize, fetchCacheKeyPrefix, distDir, dir, flushToDisk, cacheHandlers, requestHeaders }) {
// Custom cache handler overrides.
let CacheHandler;
if (cacheHandler) {
CacheHandler = interopDefault(await import(formatDynamicImportPath(dir, cacheHandler)).then((mod)=>mod.default || mod));
}
if (cacheHandlers && initializeCacheHandlers(cacheMaxMemorySize)) {
for (const [kind, handler] of Object.entries(cacheHandlers)){
if (!handler) continue;
setCacheHandler(kind, interopDefault(await import(formatDynamicImportPath(dir, handler)).then((mod)=>mod.default || mod)));
}
}
const incrementalCache = new IncrementalCache({
dev: false,
requestHeaders: requestHeaders || {},
flushToDisk,
maxMemoryCacheSize: cacheMaxMemorySize,
fetchCacheKeyPrefix,
getPrerenderManifest: ()=>({
version: 4,
routes: {},
dynamicRoutes: {},
preview: {
previewModeEncryptionKey: '',
previewModeId: '',
previewModeSigningKey: ''
},
notFoundRoutes: []
}),
fs: nodeFs,
serverDistDir: path.join(distDir, 'server'),
CurCacheHandler: CacheHandler,
minimalMode: hasNextSupport
});
globalThis.__incrementalCache = incrementalCache;
return incrementalCache;
}
//# sourceMappingURL=create-incremental-cache.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/export/helpers/create-incremental-cache.ts"],"sourcesContent":["import path from 'path'\nimport { IncrementalCache } from '../../server/lib/incremental-cache'\nimport { hasNextSupport } from '../../server/ci-info'\nimport { nodeFs } from '../../server/lib/node-fs-methods'\nimport { interopDefault } from '../../lib/interop-default'\nimport { formatDynamicImportPath } from '../../lib/format-dynamic-import-path'\nimport {\n initializeCacheHandlers,\n setCacheHandler,\n} from '../../server/use-cache/handlers'\n\nexport async function createIncrementalCache({\n cacheHandler,\n cacheMaxMemorySize,\n fetchCacheKeyPrefix,\n distDir,\n dir,\n flushToDisk,\n cacheHandlers,\n requestHeaders,\n}: {\n cacheHandler?: string\n cacheMaxMemorySize: number\n fetchCacheKeyPrefix?: string\n distDir: string\n dir: string\n flushToDisk?: boolean\n requestHeaders?: Record<string, string | string[] | undefined>\n cacheHandlers?: Record<string, string | undefined>\n}) {\n // Custom cache handler overrides.\n let CacheHandler: any\n if (cacheHandler) {\n CacheHandler = interopDefault(\n await import(formatDynamicImportPath(dir, cacheHandler)).then(\n (mod) => mod.default || mod\n )\n )\n }\n\n if (cacheHandlers && initializeCacheHandlers(cacheMaxMemorySize)) {\n for (const [kind, handler] of Object.entries(cacheHandlers)) {\n if (!handler) continue\n\n setCacheHandler(\n kind,\n interopDefault(\n await import(formatDynamicImportPath(dir, handler)).then(\n (mod) => mod.default || mod\n )\n )\n )\n }\n }\n\n const incrementalCache = new IncrementalCache({\n dev: false,\n requestHeaders: requestHeaders || {},\n flushToDisk,\n maxMemoryCacheSize: cacheMaxMemorySize,\n fetchCacheKeyPrefix,\n getPrerenderManifest: () => ({\n version: 4,\n routes: {},\n dynamicRoutes: {},\n preview: {\n previewModeEncryptionKey: '',\n previewModeId: '',\n previewModeSigningKey: '',\n },\n notFoundRoutes: [],\n }),\n fs: nodeFs,\n serverDistDir: path.join(distDir, 'server'),\n CurCacheHandler: CacheHandler,\n minimalMode: hasNextSupport,\n })\n\n ;(globalThis as any).__incrementalCache = incrementalCache\n\n return incrementalCache\n}\n"],"names":["path","IncrementalCache","hasNextSupport","nodeFs","interopDefault","formatDynamicImportPath","initializeCacheHandlers","setCacheHandler","createIncrementalCache","cacheHandler","cacheMaxMemorySize","fetchCacheKeyPrefix","distDir","dir","flushToDisk","cacheHandlers","requestHeaders","CacheHandler","then","mod","default","kind","handler","Object","entries","incrementalCache","dev","maxMemoryCacheSize","getPrerenderManifest","version","routes","dynamicRoutes","preview","previewModeEncryptionKey","previewModeId","previewModeSigningKey","notFoundRoutes","fs","serverDistDir","join","CurCacheHandler","minimalMode","globalThis","__incrementalCache"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,MAAM,QAAQ,mCAAkC;AACzD,SAASC,cAAc,QAAQ,4BAA2B;AAC1D,SAASC,uBAAuB,QAAQ,uCAAsC;AAC9E,SACEC,uBAAuB,EACvBC,eAAe,QACV,kCAAiC;AAExC,OAAO,eAAeC,uBAAuB,EAC3CC,YAAY,EACZC,kBAAkB,EAClBC,mBAAmB,EACnBC,OAAO,EACPC,GAAG,EACHC,WAAW,EACXC,aAAa,EACbC,cAAc,EAUf;IACC,kCAAkC;IAClC,IAAIC;IACJ,IAAIR,cAAc;QAChBQ,eAAeb,eACb,MAAM,MAAM,CAACC,wBAAwBQ,KAAKJ,eAAeS,IAAI,CAC3D,CAACC,MAAQA,IAAIC,OAAO,IAAID;IAG9B;IAEA,IAAIJ,iBAAiBT,wBAAwBI,qBAAqB;QAChE,KAAK,MAAM,CAACW,MAAMC,QAAQ,IAAIC,OAAOC,OAAO,CAACT,eAAgB;YAC3D,IAAI,CAACO,SAAS;YAEdf,gBACEc,MACAjB,eACE,MAAM,MAAM,CAACC,wBAAwBQ,KAAKS,UAAUJ,IAAI,CACtD,CAACC,MAAQA,IAAIC,OAAO,IAAID;QAIhC;IACF;IAEA,MAAMM,mBAAmB,IAAIxB,iBAAiB;QAC5CyB,KAAK;QACLV,gBAAgBA,kBAAkB,CAAC;QACnCF;QACAa,oBAAoBjB;QACpBC;QACAiB,sBAAsB,IAAO,CAAA;gBAC3BC,SAAS;gBACTC,QAAQ,CAAC;gBACTC,eAAe,CAAC;gBAChBC,SAAS;oBACPC,0BAA0B;oBAC1BC,eAAe;oBACfC,uBAAuB;gBACzB;gBACAC,gBAAgB,EAAE;YACpB,CAAA;QACAC,IAAIlC;QACJmC,eAAetC,KAAKuC,IAAI,CAAC3B,SAAS;QAClC4B,iBAAiBvB;QACjBwB,aAAavC;IACf;IAEEwC,WAAmBC,kBAAkB,GAAGlB;IAE1C,OAAOA;AACT","ignoreList":[0]}
+31
View File
@@ -0,0 +1,31 @@
import { getRouteMatcher } from '../../shared/lib/router/utils/route-matcher';
import { getRouteRegex } from '../../shared/lib/router/utils/route-regex';
// The last page and matcher that this function handled.
let last = null;
/**
* Gets the params for the provided page.
* @param page the page that contains dynamic path parameters
* @param pathname the pathname to match
* @returns the matches that were found, throws otherwise
*/ export function getParams(page, pathname) {
// Because this is often called on the output of `getStaticPaths` or similar
// where the `page` here doesn't change, this will "remember" the last page
// it created the RegExp for. If it matches, it'll just re-use it.
let matcher;
if ((last == null ? void 0 : last.page) === page) {
matcher = last.matcher;
} else {
matcher = getRouteMatcher(getRouteRegex(page));
}
const params = matcher(pathname);
if (!params) {
throw Object.defineProperty(new Error(`The provided export path '${pathname}' doesn't match the '${page}' page.\nRead more: https://nextjs.org/docs/messages/export-path-mismatch`), "__NEXT_ERROR_CODE", {
value: "E20",
enumerable: false,
configurable: true
});
}
return params;
}
//# sourceMappingURL=get-params.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/export/helpers/get-params.ts"],"sourcesContent":["import {\n type RouteMatchFn,\n getRouteMatcher,\n} from '../../shared/lib/router/utils/route-matcher'\nimport { getRouteRegex } from '../../shared/lib/router/utils/route-regex'\n\n// The last page and matcher that this function handled.\nlet last: {\n page: string\n matcher: RouteMatchFn\n} | null = null\n\n/**\n * Gets the params for the provided page.\n * @param page the page that contains dynamic path parameters\n * @param pathname the pathname to match\n * @returns the matches that were found, throws otherwise\n */\nexport function getParams(page: string, pathname: string) {\n // Because this is often called on the output of `getStaticPaths` or similar\n // where the `page` here doesn't change, this will \"remember\" the last page\n // it created the RegExp for. If it matches, it'll just re-use it.\n let matcher: RouteMatchFn\n if (last?.page === page) {\n matcher = last.matcher\n } else {\n matcher = getRouteMatcher(getRouteRegex(page))\n }\n\n const params = matcher(pathname)\n if (!params) {\n throw new Error(\n `The provided export path '${pathname}' doesn't match the '${page}' page.\\nRead more: https://nextjs.org/docs/messages/export-path-mismatch`\n )\n }\n\n return params\n}\n"],"names":["getRouteMatcher","getRouteRegex","last","getParams","page","pathname","matcher","params","Error"],"mappings":"AAAA,SAEEA,eAAe,QACV,8CAA6C;AACpD,SAASC,aAAa,QAAQ,4CAA2C;AAEzE,wDAAwD;AACxD,IAAIC,OAGO;AAEX;;;;;CAKC,GACD,OAAO,SAASC,UAAUC,IAAY,EAAEC,QAAgB;IACtD,4EAA4E;IAC5E,2EAA2E;IAC3E,kEAAkE;IAClE,IAAIC;IACJ,IAAIJ,CAAAA,wBAAAA,KAAME,IAAI,MAAKA,MAAM;QACvBE,UAAUJ,KAAKI,OAAO;IACxB,OAAO;QACLA,UAAUN,gBAAgBC,cAAcG;IAC1C;IAEA,MAAMG,SAASD,QAAQD;IACvB,IAAI,CAACE,QAAQ;QACX,MAAM,qBAEL,CAFK,IAAIC,MACR,CAAC,0BAA0B,EAAEH,SAAS,qBAAqB,EAAED,KAAK,yEAAyE,CAAC,GADxI,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,OAAOG;AACT","ignoreList":[0]}
+7
View File
@@ -0,0 +1,7 @@
import { isDynamicServerError } from '../../client/components/hooks-server-context';
import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr';
import { isNextRouterError } from '../../client/components/is-next-router-error';
import { isDynamicPostpone } from '../../server/app-render/dynamic-rendering';
export const isDynamicUsageError = (err)=>isDynamicServerError(err) || isBailoutToCSRError(err) || isNextRouterError(err) || isDynamicPostpone(err);
//# sourceMappingURL=is-dynamic-usage-error.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/export/helpers/is-dynamic-usage-error.ts"],"sourcesContent":["import { isDynamicServerError } from '../../client/components/hooks-server-context'\nimport { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'\nimport { isNextRouterError } from '../../client/components/is-next-router-error'\nimport { isDynamicPostpone } from '../../server/app-render/dynamic-rendering'\n\nexport const isDynamicUsageError = (err: unknown) =>\n isDynamicServerError(err) ||\n isBailoutToCSRError(err) ||\n isNextRouterError(err) ||\n isDynamicPostpone(err)\n"],"names":["isDynamicServerError","isBailoutToCSRError","isNextRouterError","isDynamicPostpone","isDynamicUsageError","err"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,SAASC,iBAAiB,QAAQ,+CAA8C;AAChF,SAASC,iBAAiB,QAAQ,4CAA2C;AAE7E,OAAO,MAAMC,sBAAsB,CAACC,MAClCL,qBAAqBK,QACrBJ,oBAAoBI,QACpBH,kBAAkBG,QAClBF,kBAAkBE,KAAI","ignoreList":[0]}