Initial commit

This commit is contained in:
bilulib
2025-04-13 00:18:57 +02:00
parent cff009bb7c
commit d894249e61
18301 changed files with 2905442 additions and 3845 deletions

View File

@@ -0,0 +1,33 @@
import type { AppPageModule } from '../../server/route-modules/app-page/module';
import type { AppSegment } from '../segment-config/app/app-segments';
import type { StaticPathsResult } from './types';
import type { IncrementalCache } from '../../server/lib/incremental-cache';
import type { NextConfigComplete } from '../../server/config-shared';
/**
* Builds the static paths for an app using `generateStaticParams`.
*
* @param params - The parameters for the build.
* @returns The static paths.
*/
export declare function buildAppStaticPaths({ dir, page, distDir, dynamicIO, authInterrupts, segments, isrFlushToDisk, cacheHandler, cacheLifeProfiles, requestHeaders, cacheHandlers, maxMemoryCacheSize, fetchCacheKeyPrefix, nextConfigOutput, ComponentMod, isRoutePPREnabled, buildId, rootParamKeys, }: {
dir: string;
page: string;
dynamicIO: boolean;
authInterrupts: boolean;
segments: AppSegment[];
distDir: string;
isrFlushToDisk?: boolean;
fetchCacheKeyPrefix?: string;
cacheHandler?: string;
cacheHandlers?: NextConfigComplete['experimental']['cacheHandlers'];
cacheLifeProfiles?: {
[profile: string]: import('../../server/use-cache/cache-life').CacheLife;
};
maxMemoryCacheSize?: number;
requestHeaders: IncrementalCache['requestHeaders'];
nextConfigOutput: 'standalone' | 'export' | undefined;
ComponentMod: AppPageModule;
isRoutePPREnabled: boolean;
buildId: string;
rootParamKeys: readonly string[];
}): Promise<Partial<StaticPathsResult>>;

View File

@@ -0,0 +1,396 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "buildAppStaticPaths", {
enumerable: true,
get: function() {
return buildAppStaticPaths;
}
});
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
const _runwithafter = require("../../server/after/run-with-after");
const _workstore = require("../../server/async-storage/work-store");
const _fallback = require("../../lib/fallback");
const _routematcher = require("../../shared/lib/router/utils/route-matcher");
const _routeregex = require("../../shared/lib/router/utils/route-regex");
const _utils = require("./utils");
const _escapepathdelimiters = /*#__PURE__*/ _interop_require_default(require("../../shared/lib/router/utils/escape-path-delimiters"));
const _createincrementalcache = require("../../export/helpers/create-incremental-cache");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
/**
* Compares two parameters to see if they're equal.
*
* @param a - The first parameter.
* @param b - The second parameter.
* @returns Whether the parameters are equal.
*/ function areParamValuesEqual(a, b) {
// If they're equal, then we can return true.
if (a === b) {
return true;
}
// If they're both arrays, then we can return true if they have the same
// length and all the items are the same.
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) {
return false;
}
return a.every((item, index)=>item === b[index]);
}
// Otherwise, they're not equal.
return false;
}
/**
* Filters out duplicate parameters from a list of parameters.
*
* @param routeParamKeys - The keys of the parameters.
* @param routeParams - The list of parameters to filter.
* @returns The list of unique parameters.
*/ function filterUniqueParams(routeParamKeys, routeParams) {
const unique = [];
for (const params of routeParams){
let i = 0;
for(; i < unique.length; i++){
const item = unique[i];
let j = 0;
for(; j < routeParamKeys.length; j++){
const key = routeParamKeys[j];
// If the param is not the same, then we need to break out of the loop.
if (!areParamValuesEqual(item[key], params[key])) {
break;
}
}
// If we got to the end of the paramKeys array, then it means that we
// found a duplicate. Skip it.
if (j === routeParamKeys.length) {
break;
}
}
// If we didn't get to the end of the unique array, then it means that we
// found a duplicate. Skip it.
if (i < unique.length) {
continue;
}
unique.push(params);
}
return unique;
}
/**
* Filters out all combinations of root params from a list of parameters.
*
* Given the following root param ('lang'), and the following routeParams:
*
* ```
* [
* { lang: 'en', region: 'US', slug: ['home'] },
* { lang: 'en', region: 'US', slug: ['about'] },
* { lang: 'fr', region: 'CA', slug: ['about'] },
* ]
* ```
*
* The result will be:
*
* ```
* [
* { lang: 'en', region: 'US' },
* { lang: 'fr', region: 'CA' },
* ]
* ```
*
* @param rootParamKeys - The keys of the root params.
* @param routeParams - The list of parameters to filter.
* @returns The list of combinations of root params.
*/ function filterRootParamsCombinations(rootParamKeys, routeParams) {
const combinations = [];
for (const params of routeParams){
const combination = {};
// Collect all root params. As soon as we don't find a root param, break.
let i = 0;
for(; i < rootParamKeys.length; i++){
const key = rootParamKeys[i];
if (params[key]) {
combination[key] = params[key];
} else {
break;
}
}
// If we didn't find all root params, skip this combination. We only want to
// generate combinations that have all root params.
if (i < rootParamKeys.length) {
continue;
}
combinations.push(combination);
}
return combinations;
}
/**
* Validates the parameters to ensure they're accessible and have the correct
* types.
*
* @param page - The page to validate.
* @param regex - The route regex.
* @param isRoutePPREnabled - Whether the route has partial prerendering enabled.
* @param routeParamKeys - The keys of the parameters.
* @param rootParamKeys - The keys of the root params.
* @param routeParams - The list of parameters to validate.
* @returns The list of validated parameters.
*/ function validateParams(page, regex, isRoutePPREnabled, routeParamKeys, rootParamKeys, routeParams) {
const valid = [];
// Validate that if there are any root params, that the user has provided at
// least one value for them only if we're using partial prerendering.
if (isRoutePPREnabled && rootParamKeys.length > 0) {
if (routeParams.length === 0 || rootParamKeys.some((key)=>routeParams.some((params)=>!(key in params)))) {
if (rootParamKeys.length === 1) {
throw Object.defineProperty(new Error(`A required root parameter (${rootParamKeys[0]}) was not provided in generateStaticParams for ${page}, please provide at least one value.`), "__NEXT_ERROR_CODE", {
value: "E622",
enumerable: false,
configurable: true
});
}
throw Object.defineProperty(new Error(`Required root params (${rootParamKeys.join(', ')}) were not provided in generateStaticParams for ${page}, please provide at least one value for each.`), "__NEXT_ERROR_CODE", {
value: "E621",
enumerable: false,
configurable: true
});
}
}
for (const params of routeParams){
const item = {};
for (const key of routeParamKeys){
const { repeat, optional } = regex.groups[key];
let paramValue = params[key];
if (optional && params.hasOwnProperty(key) && (paramValue === null || paramValue === undefined || paramValue === false)) {
paramValue = [];
}
// A parameter is missing, so the rest of the params are not accessible.
// We only support this when the route has partial prerendering enabled.
// This will make it so that the remaining params are marked as missing so
// we can generate a fallback route for them.
if (!paramValue && isRoutePPREnabled) {
break;
}
// Perform validation for the parameter based on whether it's a repeat
// parameter or not.
if (repeat) {
if (!Array.isArray(paramValue)) {
throw Object.defineProperty(new Error(`A required parameter (${key}) was not provided as an array received ${typeof paramValue} in generateStaticParams for ${page}`), "__NEXT_ERROR_CODE", {
value: "E618",
enumerable: false,
configurable: true
});
}
} else {
if (typeof paramValue !== 'string') {
throw Object.defineProperty(new Error(`A required parameter (${key}) was not provided as a string received ${typeof paramValue} in generateStaticParams for ${page}`), "__NEXT_ERROR_CODE", {
value: "E617",
enumerable: false,
configurable: true
});
}
}
item[key] = paramValue;
}
valid.push(item);
}
return valid;
}
async function buildAppStaticPaths({ dir, page, distDir, dynamicIO, authInterrupts, segments, isrFlushToDisk, cacheHandler, cacheLifeProfiles, requestHeaders, cacheHandlers, maxMemoryCacheSize, fetchCacheKeyPrefix, nextConfigOutput, ComponentMod, isRoutePPREnabled = false, buildId, rootParamKeys }) {
if (segments.some((generate)=>{
var _generate_config;
return ((_generate_config = generate.config) == null ? void 0 : _generate_config.dynamicParams) === true;
}) && nextConfigOutput === 'export') {
throw Object.defineProperty(new Error('"dynamicParams: true" cannot be used with "output: export". See more info here: https://nextjs.org/docs/app/building-your-application/deploying/static-exports'), "__NEXT_ERROR_CODE", {
value: "E393",
enumerable: false,
configurable: true
});
}
ComponentMod.patchFetch();
const incrementalCache = await (0, _createincrementalcache.createIncrementalCache)({
dir,
distDir,
cacheHandler,
cacheHandlers,
requestHeaders,
fetchCacheKeyPrefix,
flushToDisk: isrFlushToDisk,
cacheMaxMemorySize: maxMemoryCacheSize
});
const regex = (0, _routeregex.getRouteRegex)(page);
const routeParamKeys = Object.keys((0, _routematcher.getRouteMatcher)(regex)(page) || {});
const afterRunner = new _runwithafter.AfterRunner();
const store = (0, _workstore.createWorkStore)({
page,
// We're discovering the parameters here, so we don't have any unknown
// ones.
fallbackRouteParams: null,
renderOpts: {
incrementalCache,
cacheLifeProfiles,
supportsDynamicResponse: true,
isRevalidate: false,
experimental: {
dynamicIO,
authInterrupts
},
waitUntil: afterRunner.context.waitUntil,
onClose: afterRunner.context.onClose,
onAfterTaskError: afterRunner.context.onTaskError
},
buildId,
previouslyRevalidatedTags: []
});
const routeParams = await ComponentMod.workAsyncStorage.run(store, async ()=>{
async function builtRouteParams(parentsParams = [], idx = 0) {
// If we don't have any more to process, then we're done.
if (idx === segments.length) return parentsParams;
const current = segments[idx];
if (typeof current.generateStaticParams !== 'function' && idx < segments.length) {
return builtRouteParams(parentsParams, idx + 1);
}
const params = [];
if (current.generateStaticParams) {
var _current_config;
// fetchCache can be used to inform the fetch() defaults used inside
// of generateStaticParams. revalidate and dynamic options don't come into
// play within generateStaticParams.
if (typeof ((_current_config = current.config) == null ? void 0 : _current_config.fetchCache) !== 'undefined') {
store.fetchCache = current.config.fetchCache;
}
if (parentsParams.length > 0) {
for (const parentParams of parentsParams){
const result = await current.generateStaticParams({
params: parentParams
});
for (const item of result){
params.push({
...parentParams,
...item
});
}
}
} else {
const result = await current.generateStaticParams({
params: {}
});
params.push(...result);
}
}
if (idx < segments.length) {
return builtRouteParams(params, idx + 1);
}
return params;
}
return builtRouteParams();
});
let lastDynamicSegmentHadGenerateStaticParams = false;
for (const segment of segments){
var _segment_config;
// Check to see if there are any missing params for segments that have
// dynamicParams set to false.
if (segment.param && segment.isDynamicSegment && ((_segment_config = segment.config) == null ? void 0 : _segment_config.dynamicParams) === false) {
for (const params of routeParams){
if (segment.param in params) continue;
const relative = segment.filePath ? _path.default.relative(dir, segment.filePath) : undefined;
throw Object.defineProperty(new Error(`Segment "${relative}" exports "dynamicParams: false" but the param "${segment.param}" is missing from the generated route params.`), "__NEXT_ERROR_CODE", {
value: "E280",
enumerable: false,
configurable: true
});
}
}
if (segment.isDynamicSegment && typeof segment.generateStaticParams !== 'function') {
lastDynamicSegmentHadGenerateStaticParams = false;
} else if (typeof segment.generateStaticParams === 'function') {
lastDynamicSegmentHadGenerateStaticParams = true;
}
}
// Determine if all the segments have had their parameters provided.
const hadAllParamsGenerated = routeParamKeys.length === 0 || routeParams.length > 0 && routeParams.every((params)=>{
for (const key of routeParamKeys){
if (key in params) continue;
return false;
}
return true;
});
// TODO: dynamic params should be allowed to be granular per segment but
// we need additional information stored/leveraged in the prerender
// manifest to allow this behavior.
const dynamicParams = segments.every((segment)=>{
var _segment_config;
return ((_segment_config = segment.config) == null ? void 0 : _segment_config.dynamicParams) !== false;
});
const supportsRoutePreGeneration = hadAllParamsGenerated || process.env.NODE_ENV === 'production';
const fallbackMode = dynamicParams ? supportsRoutePreGeneration ? isRoutePPREnabled ? _fallback.FallbackMode.PRERENDER : _fallback.FallbackMode.BLOCKING_STATIC_RENDER : undefined : _fallback.FallbackMode.NOT_FOUND;
const result = {
fallbackMode,
prerenderedRoutes: lastDynamicSegmentHadGenerateStaticParams ? [] : undefined
};
if (hadAllParamsGenerated || isRoutePPREnabled) {
if (isRoutePPREnabled) {
// Discover all unique combinations of the rootParams so we can generate
// shells for each of them if they're available.
routeParams.unshift(...filterRootParamsCombinations(rootParamKeys, routeParams));
result.prerenderedRoutes ??= [];
result.prerenderedRoutes.push({
pathname: page,
encodedPathname: page,
fallbackRouteParams: routeParamKeys,
fallbackMode: dynamicParams ? // perform a blocking static render.
rootParamKeys.length > 0 ? _fallback.FallbackMode.BLOCKING_STATIC_RENDER : fallbackMode : _fallback.FallbackMode.NOT_FOUND,
fallbackRootParams: rootParamKeys
});
}
filterUniqueParams(routeParamKeys, validateParams(page, regex, isRoutePPREnabled, routeParamKeys, rootParamKeys, routeParams)).forEach((params)=>{
let pathname = page;
let encodedPathname = page;
const fallbackRouteParams = [];
for (const key of routeParamKeys){
if (fallbackRouteParams.length > 0) {
// This is a partial route, so we should add the value to the
// fallbackRouteParams.
fallbackRouteParams.push(key);
continue;
}
let paramValue = params[key];
if (!paramValue) {
if (isRoutePPREnabled) {
// This is a partial route, so we should add the value to the
// fallbackRouteParams.
fallbackRouteParams.push(key);
continue;
} else {
// This route is not complete, and we aren't performing a partial
// prerender, so we should return, skipping this route.
return;
}
}
const { repeat, optional } = regex.groups[key];
let replaced = `[${repeat ? '...' : ''}${key}]`;
if (optional) {
replaced = `[${replaced}]`;
}
pathname = pathname.replace(replaced, (0, _utils.encodeParam)(paramValue, (value)=>(0, _escapepathdelimiters.default)(value, true)));
encodedPathname = encodedPathname.replace(replaced, (0, _utils.encodeParam)(paramValue, encodeURIComponent));
}
const fallbackRootParams = rootParamKeys.filter((param)=>fallbackRouteParams.includes(param));
result.prerenderedRoutes ??= [];
result.prerenderedRoutes.push({
pathname: (0, _utils.normalizePathname)(pathname),
encodedPathname: (0, _utils.normalizePathname)(encodedPathname),
fallbackRouteParams,
fallbackMode: dynamicParams ? // perform a blocking static render.
fallbackRootParams.length > 0 ? _fallback.FallbackMode.BLOCKING_STATIC_RENDER : fallbackMode : _fallback.FallbackMode.NOT_FOUND,
fallbackRootParams
});
});
}
await afterRunner.executeAfter();
return result;
}
//# sourceMappingURL=app.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { GetStaticPaths } from '../../types';
import type { StaticPathsResult } from './types';
export declare function buildPagesStaticPaths({ page, getStaticPaths, configFileName, locales, defaultLocale, }: {
page: string;
getStaticPaths: GetStaticPaths;
configFileName: string;
locales?: readonly string[];
defaultLocale?: string;
}): Promise<StaticPathsResult>;

View File

@@ -0,0 +1,163 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "buildPagesStaticPaths", {
enumerable: true,
get: function() {
return buildPagesStaticPaths;
}
});
const _normalizelocalepath = require("../../shared/lib/i18n/normalize-locale-path");
const _fallback = require("../../lib/fallback");
const _escapepathdelimiters = /*#__PURE__*/ _interop_require_default(require("../../shared/lib/router/utils/escape-path-delimiters"));
const _removetrailingslash = require("../../shared/lib/router/utils/remove-trailing-slash");
const _routematcher = require("../../shared/lib/router/utils/route-matcher");
const _routeregex = require("../../shared/lib/router/utils/route-regex");
const _utils = require("./utils");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
async function buildPagesStaticPaths({ page, getStaticPaths, configFileName, locales, defaultLocale }) {
const prerenderedRoutes = [];
const _routeRegex = (0, _routeregex.getRouteRegex)(page);
const _routeMatcher = (0, _routematcher.getRouteMatcher)(_routeRegex);
// Get the default list of allowed params.
const routeParameterKeys = Object.keys(_routeMatcher(page));
const staticPathsResult = await getStaticPaths({
// We create a copy here to avoid having the types of `getStaticPaths`
// change. This ensures that users can't mutate this array and have it
// poison the reference.
locales: [
...locales ?? []
],
defaultLocale
});
const expectedReturnVal = `Expected: { paths: [], fallback: boolean }\n` + `See here for more info: https://nextjs.org/docs/messages/invalid-getstaticpaths-value`;
if (!staticPathsResult || typeof staticPathsResult !== 'object' || Array.isArray(staticPathsResult)) {
throw Object.defineProperty(new Error(`Invalid value returned from getStaticPaths in ${page}. Received ${typeof staticPathsResult} ${expectedReturnVal}`), "__NEXT_ERROR_CODE", {
value: "E241",
enumerable: false,
configurable: true
});
}
const invalidStaticPathKeys = Object.keys(staticPathsResult).filter((key)=>!(key === 'paths' || key === 'fallback'));
if (invalidStaticPathKeys.length > 0) {
throw Object.defineProperty(new Error(`Extra keys returned from getStaticPaths in ${page} (${invalidStaticPathKeys.join(', ')}) ${expectedReturnVal}`), "__NEXT_ERROR_CODE", {
value: "E38",
enumerable: false,
configurable: true
});
}
if (!(typeof staticPathsResult.fallback === 'boolean' || staticPathsResult.fallback === 'blocking')) {
throw Object.defineProperty(new Error(`The \`fallback\` key must be returned from getStaticPaths in ${page}.\n` + expectedReturnVal), "__NEXT_ERROR_CODE", {
value: "E243",
enumerable: false,
configurable: true
});
}
const toPrerender = staticPathsResult.paths;
if (!Array.isArray(toPrerender)) {
throw Object.defineProperty(new Error(`Invalid \`paths\` value returned from getStaticPaths in ${page}.\n` + `\`paths\` must be an array of strings or objects of shape { params: [key: string]: string }`), "__NEXT_ERROR_CODE", {
value: "E83",
enumerable: false,
configurable: true
});
}
toPrerender.forEach((entry)=>{
// For a string-provided path, we must make sure it matches the dynamic
// route.
if (typeof entry === 'string') {
entry = (0, _removetrailingslash.removeTrailingSlash)(entry);
const localePathResult = (0, _normalizelocalepath.normalizeLocalePath)(entry, locales);
let cleanedEntry = entry;
if (localePathResult.detectedLocale) {
cleanedEntry = entry.slice(localePathResult.detectedLocale.length + 1);
} else if (defaultLocale) {
entry = `/${defaultLocale}${entry}`;
}
const result = _routeMatcher(cleanedEntry);
if (!result) {
throw Object.defineProperty(new Error(`The provided path \`${cleanedEntry}\` does not match the page: \`${page}\`.`), "__NEXT_ERROR_CODE", {
value: "E481",
enumerable: false,
configurable: true
});
}
// If leveraging the string paths variant the entry should already be
// encoded so we decode the segments ensuring we only escape path
// delimiters
prerenderedRoutes.push({
pathname: entry.split('/').map((segment)=>(0, _escapepathdelimiters.default)(decodeURIComponent(segment), true)).join('/'),
encodedPathname: entry,
fallbackRouteParams: undefined,
fallbackMode: (0, _fallback.parseStaticPathsResult)(staticPathsResult.fallback),
fallbackRootParams: undefined
});
} else {
const invalidKeys = Object.keys(entry).filter((key)=>key !== 'params' && key !== 'locale');
if (invalidKeys.length) {
throw Object.defineProperty(new Error(`Additional keys were returned from \`getStaticPaths\` in page "${page}". ` + `URL Parameters intended for this dynamic route must be nested under the \`params\` key, i.e.:` + `\n\n\treturn { params: { ${routeParameterKeys.map((k)=>`${k}: ...`).join(', ')} } }` + `\n\nKeys that need to be moved: ${invalidKeys.join(', ')}.\n`), "__NEXT_ERROR_CODE", {
value: "E322",
enumerable: false,
configurable: true
});
}
const { params = {} } = entry;
let builtPage = page;
let encodedBuiltPage = page;
routeParameterKeys.forEach((validParamKey)=>{
const { repeat, optional } = _routeRegex.groups[validParamKey];
let paramValue = params[validParamKey];
if (optional && params.hasOwnProperty(validParamKey) && (paramValue === null || paramValue === undefined || paramValue === false)) {
paramValue = [];
}
if (repeat && !Array.isArray(paramValue) || !repeat && typeof paramValue !== 'string' || typeof paramValue === 'undefined') {
throw Object.defineProperty(new Error(`A required parameter (${validParamKey}) was not provided as ${repeat ? 'an array' : 'a string'} received ${typeof paramValue} in getStaticPaths for ${page}`), "__NEXT_ERROR_CODE", {
value: "E620",
enumerable: false,
configurable: true
});
}
let replaced = `[${repeat ? '...' : ''}${validParamKey}]`;
if (optional) {
replaced = `[${replaced}]`;
}
builtPage = builtPage.replace(replaced, (0, _utils.encodeParam)(paramValue, (value)=>(0, _escapepathdelimiters.default)(value, true)));
encodedBuiltPage = encodedBuiltPage.replace(replaced, (0, _utils.encodeParam)(paramValue, encodeURIComponent));
});
if (!builtPage && !encodedBuiltPage) {
return;
}
if (entry.locale && !(locales == null ? void 0 : locales.includes(entry.locale))) {
throw Object.defineProperty(new Error(`Invalid locale returned from getStaticPaths for ${page}, the locale ${entry.locale} is not specified in ${configFileName}`), "__NEXT_ERROR_CODE", {
value: "E358",
enumerable: false,
configurable: true
});
}
const curLocale = entry.locale || defaultLocale || '';
prerenderedRoutes.push({
pathname: (0, _utils.normalizePathname)(`${curLocale ? `/${curLocale}` : ''}${curLocale && builtPage === '/' ? '' : builtPage}`),
encodedPathname: (0, _utils.normalizePathname)(`${curLocale ? `/${curLocale}` : ''}${curLocale && encodedBuiltPage === '/' ? '' : encodedBuiltPage}`),
fallbackRouteParams: undefined,
fallbackMode: (0, _fallback.parseStaticPathsResult)(staticPathsResult.fallback),
fallbackRootParams: undefined
});
}
});
const seen = new Set();
return {
fallbackMode: (0, _fallback.parseStaticPathsResult)(staticPathsResult.fallback),
prerenderedRoutes: prerenderedRoutes.filter((route)=>{
if (seen.has(route.pathname)) return false;
// Filter out duplicate paths.
seen.add(route.pathname);
return true;
})
};
}
//# sourceMappingURL=pages.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
import type { FallbackMode } from '../../lib/fallback';
type StaticPrerenderedRoute = {
pathname: string;
encodedPathname: string;
fallbackRouteParams: undefined;
fallbackMode: FallbackMode | undefined;
fallbackRootParams: undefined;
};
type FallbackPrerenderedRoute = {
pathname: string;
encodedPathname: string;
fallbackRouteParams: readonly string[];
fallbackMode: FallbackMode | undefined;
fallbackRootParams: readonly string[];
};
export type PrerenderedRoute = StaticPrerenderedRoute | FallbackPrerenderedRoute;
export type StaticPathsResult = {
fallbackMode: FallbackMode;
prerenderedRoutes: PrerenderedRoute[];
};
export {};

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}

View File

@@ -0,0 +1,15 @@
/**
* Encodes a parameter value using the provided encoder.
*
* @param value - The value to encode.
* @param encoder - The encoder to use.
* @returns The encoded value.
*/
export declare function encodeParam(value: string | string[], encoder: (value: string) => string): string;
/**
* Normalizes a pathname to a consistent format.
*
* @param pathname - The pathname to normalize.
* @returns The normalized pathname.
*/
export declare function normalizePathname(pathname: string): string;

View File

@@ -0,0 +1,42 @@
/**
* Encodes a parameter value using the provided encoder.
*
* @param value - The value to encode.
* @param encoder - The encoder to use.
* @returns The encoded value.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
encodeParam: null,
normalizePathname: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
encodeParam: function() {
return encodeParam;
},
normalizePathname: function() {
return normalizePathname;
}
});
function encodeParam(value, encoder) {
let replaceValue;
if (Array.isArray(value)) {
replaceValue = value.map(encoder).join('/');
} else {
replaceValue = encoder(value);
}
return replaceValue;
}
function normalizePathname(pathname) {
return pathname.replace(/\\/g, '/').replace(/(?!^)\/$/, '');
}
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/build/static-paths/utils.ts"],"sourcesContent":["/**\n * Encodes a parameter value using the provided encoder.\n *\n * @param value - The value to encode.\n * @param encoder - The encoder to use.\n * @returns The encoded value.\n */\nexport function encodeParam(\n value: string | string[],\n encoder: (value: string) => string\n) {\n let replaceValue: string\n if (Array.isArray(value)) {\n replaceValue = value.map(encoder).join('/')\n } else {\n replaceValue = encoder(value)\n }\n\n return replaceValue\n}\n\n/**\n * Normalizes a pathname to a consistent format.\n *\n * @param pathname - The pathname to normalize.\n * @returns The normalized pathname.\n */\nexport function normalizePathname(pathname: string) {\n return pathname.replace(/\\\\/g, '/').replace(/(?!^)\\/$/, '')\n}\n"],"names":["encodeParam","normalizePathname","value","encoder","replaceValue","Array","isArray","map","join","pathname","replace"],"mappings":"AAAA;;;;;;CAMC;;;;;;;;;;;;;;;IACeA,WAAW;eAAXA;;IAoBAC,iBAAiB;eAAjBA;;;AApBT,SAASD,YACdE,KAAwB,EACxBC,OAAkC;IAElC,IAAIC;IACJ,IAAIC,MAAMC,OAAO,CAACJ,QAAQ;QACxBE,eAAeF,MAAMK,GAAG,CAACJ,SAASK,IAAI,CAAC;IACzC,OAAO;QACLJ,eAAeD,QAAQD;IACzB;IAEA,OAAOE;AACT;AAQO,SAASH,kBAAkBQ,QAAgB;IAChD,OAAOA,SAASC,OAAO,CAAC,OAAO,KAAKA,OAAO,CAAC,YAAY;AAC1D"}