main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { MiddlewareConfig } from '../../../analysis/get-page-static-info';
import { RouteKind } from '../../../../server/future/route-kind';
type RouteLoaderOptionsPagesAPIInput = {
kind: RouteKind.PAGES_API;
page: string;
preferredRegion: string | string[] | undefined;
absolutePagePath: string;
middlewareConfig: MiddlewareConfig;
};
type RouteLoaderOptionsPagesInput = {
kind: RouteKind.PAGES;
page: string;
pages: {
[page: string]: string;
};
preferredRegion: string | string[] | undefined;
absolutePagePath: string;
middlewareConfig: MiddlewareConfig;
};
type RouteLoaderOptionsInput = RouteLoaderOptionsPagesInput | RouteLoaderOptionsPagesAPIInput;
type RouteLoaderPagesAPIOptions = {
kind: RouteKind.PAGES_API;
/**
* The page name for this particular route.
*/
page: string;
/**
* The preferred region for this route.
*/
preferredRegion: string | string[] | undefined;
/**
* The absolute path to the userland page file.
*/
absolutePagePath: string;
/**
* The middleware config for this route.
*/
middlewareConfigBase64: string;
};
type RouteLoaderPagesOptions = {
kind: RouteKind.PAGES;
/**
* The page name for this particular route.
*/
page: string;
/**
* The preferred region for this route.
*/
preferredRegion: string | string[] | undefined;
/**
* The absolute path to the userland page file.
*/
absolutePagePath: string;
/**
* The absolute paths to the app path file.
*/
absoluteAppPath: string;
/**
* The absolute paths to the document path file.
*/
absoluteDocumentPath: string;
/**
* The middleware config for this route.
*/
middlewareConfigBase64: string;
};
/**
* The options for the route loader.
*/
type RouteLoaderOptions = RouteLoaderPagesOptions | RouteLoaderPagesAPIOptions;
/**
* Returns the loader entry for a given page.
*
* @param options the options to create the loader entry
* @returns the encoded loader entry
*/
export declare function getRouteLoaderEntry(options: RouteLoaderOptionsInput): string;
/**
* Handles the `next-route-loader` options.
* @returns the loader definition function
*/
declare const loader: webpack.LoaderDefinitionFunction<RouteLoaderOptions>;
export default loader;

View File

@@ -0,0 +1,129 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getRouteLoaderEntry: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getRouteLoaderEntry: function() {
return getRouteLoaderEntry;
},
default: function() {
return _default;
}
});
const _querystring = require("querystring");
const _getmodulebuildinfo = require("../get-module-build-info");
const _routekind = require("../../../../server/future/route-kind");
const _normalizepagepath = require("../../../../shared/lib/page-path/normalize-page-path");
const _utils = require("../utils");
const _worker = require("../../../worker");
const _loadentrypoint = require("../../../load-entrypoint");
function getRouteLoaderEntry(options) {
switch(options.kind){
case _routekind.RouteKind.PAGES:
{
const query = {
kind: options.kind,
page: options.page,
preferredRegion: options.preferredRegion,
absolutePagePath: options.absolutePagePath,
// These are the path references to the internal components that may be
// overridden by userland components.
absoluteAppPath: options.pages["/_app"],
absoluteDocumentPath: options.pages["/_document"],
middlewareConfigBase64: (0, _utils.encodeToBase64)(options.middlewareConfig)
};
return `next-route-loader?${(0, _querystring.stringify)(query)}!`;
}
case _routekind.RouteKind.PAGES_API:
{
const query = {
kind: options.kind,
page: options.page,
preferredRegion: options.preferredRegion,
absolutePagePath: options.absolutePagePath,
middlewareConfigBase64: (0, _utils.encodeToBase64)(options.middlewareConfig)
};
return `next-route-loader?${(0, _querystring.stringify)(query)}!`;
}
default:
{
throw new Error("Invariant: Unexpected route kind");
}
}
}
const loadPages = async ({ page, absolutePagePath, absoluteDocumentPath, absoluteAppPath, preferredRegion, middlewareConfigBase64 }, buildInfo)=>{
const middlewareConfig = (0, _utils.decodeFromBase64)(middlewareConfigBase64);
// Attach build info to the module.
buildInfo.route = {
page,
absolutePagePath,
preferredRegion,
middlewareConfig
};
let file = await (0, _loadentrypoint.loadEntrypoint)("pages", {
VAR_USERLAND: absolutePagePath,
VAR_MODULE_DOCUMENT: absoluteDocumentPath,
VAR_MODULE_APP: absoluteAppPath,
VAR_DEFINITION_PAGE: (0, _normalizepagepath.normalizePagePath)(page),
VAR_DEFINITION_PATHNAME: page
});
if ((0, _worker.isInstrumentationHookFile)(page)) {
// When we're building the instrumentation page (only when the
// instrumentation file conflicts with a page also labeled
// /instrumentation) hoist the `register` method.
file += '\nexport const register = hoist(userland, "register")';
}
return file;
};
const loadPagesAPI = async ({ page, absolutePagePath, preferredRegion, middlewareConfigBase64 }, buildInfo)=>{
const middlewareConfig = (0, _utils.decodeFromBase64)(middlewareConfigBase64);
// Attach build info to the module.
buildInfo.route = {
page,
absolutePagePath,
preferredRegion,
middlewareConfig
};
return await (0, _loadentrypoint.loadEntrypoint)("pages-api", {
VAR_USERLAND: absolutePagePath,
VAR_DEFINITION_PAGE: (0, _normalizepagepath.normalizePagePath)(page),
VAR_DEFINITION_PATHNAME: page
});
};
/**
* Handles the `next-route-loader` options.
* @returns the loader definition function
*/ const loader = async function() {
if (!this._module) {
throw new Error("Invariant: expected this to reference a module");
}
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(this._module);
const opts = this.getOptions();
switch(opts.kind){
case _routekind.RouteKind.PAGES:
{
return await loadPages(opts, buildInfo);
}
case _routekind.RouteKind.PAGES_API:
{
return await loadPagesAPI(opts, buildInfo);
}
default:
{
throw new Error("Invariant: Unexpected route kind");
}
}
};
const _default = loader;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-route-loader/index.ts"],"names":["getRouteLoaderEntry","options","kind","RouteKind","PAGES","query","page","preferredRegion","absolutePagePath","absoluteAppPath","pages","absoluteDocumentPath","middlewareConfigBase64","encodeToBase64","middlewareConfig","stringify","PAGES_API","Error","loadPages","buildInfo","decodeFromBase64","route","file","loadEntrypoint","VAR_USERLAND","VAR_MODULE_DOCUMENT","VAR_MODULE_APP","VAR_DEFINITION_PAGE","normalizePagePath","VAR_DEFINITION_PATHNAME","isInstrumentationHookFile","loadPagesAPI","loader","_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