create project

This commit is contained in:
ismailsosic
2022-12-27 12:05:56 +01:00
parent 2a33a2d3de
commit cd2143287c
16035 changed files with 2489703 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
class CssSyntaxError extends Error {
constructor(error){
super(error);
const { reason , line , column } = error;
this.name = "CssSyntaxError";
// Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
// We don't need `plugin` and `file` properties.
this.message = `${this.name}\n\n`;
if (typeof line !== "undefined") {
this.message += `(${line}:${column}) `;
}
this.message += `${reason}`;
const code = error.showSourceCode();
if (code) {
this.message += `\n\n${code}\n`;
}
// We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
this.stack = false;
}
}
exports.default = CssSyntaxError;
//# sourceMappingURL=CssSyntaxError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/css-loader/src/CssSyntaxError.js"],"names":["CssSyntaxError","Error","constructor","error","reason","line","column","name","message","code","showSourceCode","stack"],"mappings":"AAAA;;;;;AAAe,MAAMA,cAAc,SAASC,KAAK;IAC/CC,YAAYC,KAAK,CAAE;QACjB,KAAK,CAACA,KAAK,CAAC;QAEZ,MAAM,EAAEC,MAAM,CAAA,EAAEC,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGH,KAAK;QAEtC,IAAI,CAACI,IAAI,GAAG,gBAAgB;QAE5B,wFAAwF;QACxF,gDAAgD;QAChD,IAAI,CAACC,OAAO,GAAG,CAAC,EAAE,IAAI,CAACD,IAAI,CAAC,IAAI,CAAC;QAEjC,IAAI,OAAOF,IAAI,KAAK,WAAW,EAAE;YAC/B,IAAI,CAACG,OAAO,IAAI,CAAC,CAAC,EAAEH,IAAI,CAAC,CAAC,EAAEC,MAAM,CAAC,EAAE,CAAC;SACvC;QAED,IAAI,CAACE,OAAO,IAAI,CAAC,EAAEJ,MAAM,CAAC,CAAC;QAE3B,MAAMK,IAAI,GAAGN,KAAK,CAACO,cAAc,EAAE;QAEnC,IAAID,IAAI,EAAE;YACR,IAAI,CAACD,OAAO,IAAI,CAAC,IAAI,EAAEC,IAAI,CAAC,EAAE,CAAC;SAChC;QAED,wIAAwI;QACxI,IAAI,CAACE,KAAK,GAAG,KAAK;KACnB;CACF;kBA3BoBX,cAAc"}

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/*
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ const preserveCamelCase = (string, locale)=>{
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
for(let i = 0; i < string.length; i++){
const character = string[i];
if (isLastCharLower && /[\p{Lu}]/u.test(character)) {
string = string.slice(0, i) + "-" + string.slice(i);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
i++;
} else if (isLastCharUpper && isLastLastCharUpper && /[\p{Ll}]/u.test(character)) {
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower = character.toLocaleLowerCase(locale) === character && character.toLocaleUpperCase(locale) !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = character.toLocaleUpperCase(locale) === character && character.toLocaleLowerCase(locale) !== character;
}
}
return string;
};
const preserveConsecutiveUppercase = (input)=>{
return input.replace(/^[\p{Lu}](?![\p{Lu}])/gu, (m1)=>m1.toLowerCase());
};
const postProcess = (input, options)=>{
return input.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1)=>p1.toLocaleUpperCase(options.locale)).replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, (m)=>m.toLocaleUpperCase(options.locale));
};
const camelCase = (input, options)=>{
if (!(typeof input === "string" || Array.isArray(input))) {
throw new TypeError("Expected the input to be `string | string[]`");
}
options = {
pascalCase: false,
preserveConsecutiveUppercase: false,
...options
};
if (Array.isArray(input)) {
input = input.map((x)=>x.trim()).filter((x)=>x.length).join("-");
} else {
input = input.trim();
}
if (input.length === 0) {
return "";
}
if (input.length === 1) {
return options.pascalCase ? input.toLocaleUpperCase(options.locale) : input.toLocaleLowerCase(options.locale);
}
const hasUpperCase = input !== input.toLocaleLowerCase(options.locale);
if (hasUpperCase) {
input = preserveCamelCase(input, options.locale);
}
input = input.replace(/^[_.\- ]+/, "");
if (options.preserveConsecutiveUppercase) {
input = preserveConsecutiveUppercase(input);
} else {
input = input.toLocaleLowerCase();
}
if (options.pascalCase) {
input = input.charAt(0).toLocaleUpperCase(options.locale) + input.slice(1);
}
return postProcess(input, options);
};
var _default = camelCase;
exports.default = _default;
//# sourceMappingURL=camelcase.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/css-loader/src/camelcase.js"],"names":["preserveCamelCase","string","locale","isLastCharLower","isLastCharUpper","isLastLastCharUpper","i","length","character","test","slice","toLocaleLowerCase","toLocaleUpperCase","preserveConsecutiveUppercase","input","replace","m1","toLowerCase","postProcess","options","_","p1","m","camelCase","Array","isArray","TypeError","pascalCase","map","x","trim","filter","join","hasUpperCase","charAt"],"mappings":"AAYA;;;;;AAZA;;;;;;;;;;EAUE,CAEF,MAAMA,iBAAiB,GAAG,CAACC,MAAM,EAAEC,MAAM,GAAK;IAC5C,IAAIC,eAAe,GAAG,KAAK;IAC3B,IAAIC,eAAe,GAAG,KAAK;IAC3B,IAAIC,mBAAmB,GAAG,KAAK;IAE/B,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACM,MAAM,EAAED,CAAC,EAAE,CAAE;QACtC,MAAME,SAAS,GAAGP,MAAM,CAACK,CAAC,CAAC;QAE3B,IAAIH,eAAe,IAAI,YAAYM,IAAI,CAACD,SAAS,CAAC,EAAE;YAClDP,MAAM,GAAGA,MAAM,CAACS,KAAK,CAAC,CAAC,EAAEJ,CAAC,CAAC,GAAG,GAAG,GAAGL,MAAM,CAACS,KAAK,CAACJ,CAAC,CAAC;YACnDH,eAAe,GAAG,KAAK;YACvBE,mBAAmB,GAAGD,eAAe;YACrCA,eAAe,GAAG,IAAI;YACtBE,CAAC,EAAE;SACJ,MAAM,IACLF,eAAe,IACfC,mBAAmB,IACnB,YAAYI,IAAI,CAACD,SAAS,CAAC,EAC3B;YACAP,MAAM,GAAGA,MAAM,CAACS,KAAK,CAAC,CAAC,EAAEJ,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAGL,MAAM,CAACS,KAAK,CAACJ,CAAC,GAAG,CAAC,CAAC;YAC3DD,mBAAmB,GAAGD,eAAe;YACrCA,eAAe,GAAG,KAAK;YACvBD,eAAe,GAAG,IAAI;SACvB,MAAM;YACLA,eAAe,GACbK,SAAS,CAACG,iBAAiB,CAACT,MAAM,CAAC,KAAKM,SAAS,IACjDA,SAAS,CAACI,iBAAiB,CAACV,MAAM,CAAC,KAAKM,SAAS;Y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KAAK,CAACgB,IAAI,EAAE;KACrB;IAED,IAAIhB,KAAK,CAACP,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO,EAAE,CAAA;KACV;IAED,IAAIO,KAAK,CAACP,MAAM,KAAK,CAAC,EAAE;QACtB,OAAOY,OAAO,CAACQ,UAAU,GACrBb,KAAK,CAACF,iBAAiB,CAACO,OAAO,CAACjB,MAAM,CAAC,GACvCY,KAAK,CAACH,iBAAiB,CAACQ,OAAO,CAACjB,MAAM,CAAC,CAAA;KAC5C;IAED,MAAM+B,YAAY,GAAGnB,KAAK,KAAKA,KAAK,CAACH,iBAAiB,CAACQ,OAAO,CAACjB,MAAM,CAAC;IAEtE,IAAI+B,YAAY,EAAE;QAChBnB,KAAK,GAAGd,iBAAiB,CAACc,KAAK,EAAEK,OAAO,CAACjB,MAAM,CAAC;KACjD;IAEDY,KAAK,GAAGA,KAAK,CAACC,OAAO,cAAc,EAAE,CAAC;IAEtC,IAAII,OAAO,CAACN,4BAA4B,EAAE;QACxCC,KAAK,GAAGD,4BAA4B,CAACC,KAAK,CAAC;KAC5C,MAAM;QACLA,KAAK,GAAGA,KAAK,CAACH,iBAAiB,EAAE;KAClC;IAED,IAAIQ,OAAO,CAACQ,UAAU,EAAE;QACtBb,KAAK,GAAGA,KAAK,CAACoB,MAAM,CAAC,CAAC,CAAC,CAACtB,iBAAiB,CAACO,OAAO,CAACjB,MAAM,CAAC,GAAGY,KAAK,CAACJ,KAAK,CAAC,CAAC,CAAC;KAC3E;IAED,OAAOQ,WAAW,CAACJ,KAAK,EAAEK,OAAO,CAAC,CAAA;CACnC;eAEcI,SAAS"}

View File

@@ -0,0 +1,254 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loader;
var _cssSyntaxError = _interopRequireDefault(require("./CssSyntaxError"));
var _warning = _interopRequireDefault(require("../../postcss-loader/src/Warning"));
var _stringifyRequest = require("../../../stringify-request");
async function loader(content, map, meta) {
const rawOptions = this.getOptions();
const plugins = [];
const callback = this.async();
const loaderSpan = this.currentTraceSpan.traceChild("css-loader");
loaderSpan.traceAsyncFn(async ()=>{
let options;
try {
options = normalizeOptions(rawOptions, this);
} catch (error) {
throw error;
}
const { postcss } = await rawOptions.postcss();
const { shouldUseModulesPlugins , shouldUseImportPlugin , shouldUseURLPlugin , shouldUseIcssPlugin , getPreRequester , getExportCode , getFilter , getImportCode , getModuleCode , getModulesPlugins , normalizeSourceMap , sort , } = require("./utils");
const { icssParser , importParser , urlParser } = require("./plugins");
const replacements = [];
// if it's a font loader next-font-loader will have exports that should be exported as is
const exports = options.fontLoader ? meta.exports : [];
if (shouldUseModulesPlugins(options)) {
plugins.push(...getModulesPlugins(options, this, meta));
}
const importPluginImports = [];
const importPluginApi = [];
if (shouldUseImportPlugin(options)) {
const resolver = this.getResolve({
conditionNames: [
"style"
],
extensions: [
".css"
],
mainFields: [
"css",
"style",
"main",
"..."
],
mainFiles: [
"index",
"..."
],
restrictions: [
/\.css$/i
]
});
plugins.push(importParser({
imports: importPluginImports,
api: importPluginApi,
context: this.context,
rootContext: this.rootContext,
filter: getFilter(options.import, this.resourcePath),
resolver,
urlHandler: (url)=>(0, _stringifyRequest).stringifyRequest(this, getPreRequester(this)(options.importLoaders) + url)
}));
}
const urlPluginImports = [];
if (shouldUseURLPlugin(options)) {
const urlResolver = this.getResolve({
conditionNames: [
"asset"
],
mainFields: [
"asset"
],
mainFiles: [],
extensions: []
});
plugins.push(urlParser({
imports: urlPluginImports,
replacements,
context: this.context,
rootContext: this.rootContext,
filter: getFilter(options.url, this.resourcePath),
resolver: urlResolver,
urlHandler: (url)=>(0, _stringifyRequest).stringifyRequest(this, url)
}));
}
const icssPluginImports = [];
const icssPluginApi = [];
if (shouldUseIcssPlugin(options)) {
const icssResolver = this.getResolve({
conditionNames: [
"style"
],
extensions: [],
mainFields: [
"css",
"style",
"main",
"..."
],
mainFiles: [
"index",
"..."
]
});
plugins.push(icssParser({
imports: icssPluginImports,
api: icssPluginApi,
replacements,
exports,
context: this.context,
rootContext: this.rootContext,
resolver: icssResolver,
urlHandler: (url)=>(0, _stringifyRequest).stringifyRequest(this, getPreRequester(this)(options.importLoaders) + url)
}));
}
// Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
if (meta) {
const { ast } = meta;
if (ast && ast.type === "postcss") {
// eslint-disable-next-line no-param-reassign
content = ast.root;
loaderSpan.setAttribute("astUsed", "true");
}
}
const { resourcePath } = this;
let result;
try {
result = await postcss(plugins).process(content, {
from: resourcePath,
to: resourcePath,
map: options.sourceMap ? {
prev: map ? normalizeSourceMap(map, resourcePath) : null,
inline: false,
annotation: false
} : false
});
} catch (error1) {
if (error1.file) {
this.addDependency(error1.file);
}
throw error1.name === "CssSyntaxError" ? new _cssSyntaxError.default(error1) : error1;
}
for (const warning of result.warnings()){
this.emitWarning(new _warning.default(warning));
}
const imports = [].concat(icssPluginImports.sort(sort)).concat(importPluginImports.sort(sort)).concat(urlPluginImports.sort(sort));
const api = [].concat(importPluginApi.sort(sort)).concat(icssPluginApi.sort(sort));
if (options.modules.exportOnlyLocals !== true) {
imports.unshift({
importName: "___CSS_LOADER_API_IMPORT___",
url: (0, _stringifyRequest).stringifyRequest(this, require.resolve("./runtime/api"))
});
}
const importCode = getImportCode(imports, options);
const moduleCode = getModuleCode(result, api, replacements, options, this);
const exportCode = getExportCode(exports, replacements, options);
return `${importCode}${moduleCode}${exportCode}`;
}).then((code)=>{
callback(null, code);
}, (err)=>{
callback(err);
});
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const moduleRegExp = /\.module\.\w+$/i;
function getModulesOptions(rawOptions, loaderContext) {
const { resourcePath } = loaderContext;
if (typeof rawOptions.modules === "undefined") {
const isModules = moduleRegExp.test(resourcePath);
if (!isModules) {
return false;
}
} else if (typeof rawOptions.modules === "boolean" && rawOptions.modules === false) {
return false;
}
let modulesOptions = {
compileType: rawOptions.icss ? "icss" : "module",
auto: true,
mode: "local",
exportGlobals: false,
localIdentName: "[hash:base64]",
localIdentContext: loaderContext.rootContext,
localIdentHashPrefix: "",
// eslint-disable-next-line no-undefined
localIdentRegExp: undefined,
namedExport: false,
exportLocalsConvention: "asIs",
exportOnlyLocals: false
};
if (typeof rawOptions.modules === "boolean" || typeof rawOptions.modules === "string") {
modulesOptions.mode = typeof rawOptions.modules === "string" ? rawOptions.modules : "local";
} else {
if (rawOptions.modules) {
if (typeof rawOptions.modules.auto === "boolean") {
const isModules = rawOptions.modules.auto && moduleRegExp.test(resourcePath);
if (!isModules) {
return false;
}
} else if (rawOptions.modules.auto instanceof RegExp) {
const isModules = rawOptions.modules.auto.test(resourcePath);
if (!isModules) {
return false;
}
} else if (typeof rawOptions.modules.auto === "function") {
const isModule = rawOptions.modules.auto(resourcePath);
if (!isModule) {
return false;
}
}
if (rawOptions.modules.namedExport === true && typeof rawOptions.modules.exportLocalsConvention === "undefined") {
modulesOptions.exportLocalsConvention = "camelCaseOnly";
}
}
modulesOptions = {
...modulesOptions,
...rawOptions.modules || {}
};
}
if (typeof modulesOptions.mode === "function") {
modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath);
}
if (modulesOptions.namedExport === true) {
if (rawOptions.esModule === false) {
throw new Error('The "modules.namedExport" option requires the "esModules" option to be enabled');
}
if (modulesOptions.exportLocalsConvention !== "camelCaseOnly") {
throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly"');
}
}
return modulesOptions;
}
function normalizeOptions(rawOptions, loaderContext) {
if (rawOptions.icss) {
loaderContext.emitWarning(new Error('The "icss" option is deprecated, use "modules.compileType: "icss"" instead'));
}
const modulesOptions = getModulesOptions(rawOptions, loaderContext);
return {
url: typeof rawOptions.url === "undefined" ? true : rawOptions.url,
import: typeof rawOptions.import === "undefined" ? true : rawOptions.import,
modules: modulesOptions,
// TODO remove in the next major release
icss: typeof rawOptions.icss === "undefined" ? false : rawOptions.icss,
sourceMap: typeof rawOptions.sourceMap === "boolean" ? rawOptions.sourceMap : loaderContext.sourceMap,
importLoaders: typeof rawOptions.importLoaders === "string" ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
esModule: typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule,
fontLoader: rawOptions.fontLoader
};
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "importParser", {
enumerable: true,
get: function() {
return _postcssImportParser.default;
}
});
Object.defineProperty(exports, "icssParser", {
enumerable: true,
get: function() {
return _postcssIcssParser.default;
}
});
Object.defineProperty(exports, "urlParser", {
enumerable: true,
get: function() {
return _postcssUrlParser.default;
}
});
var _postcssImportParser = _interopRequireDefault(require("./postcss-import-parser"));
var _postcssIcssParser = _interopRequireDefault(require("./postcss-icss-parser"));
var _postcssUrlParser = _interopRequireDefault(require("./postcss-url-parser"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/plugins/index.js"],"names":["importParser","icssParser","urlParser"],"mappings":"AAAA;;;;+BAISA,cAAY;;;eAAZA,oBAAY,QAAA;;;+BAAEC,YAAU;;;eAAVA,kBAAU,QAAA;;;+BAAEC,WAAS;;;eAATA,iBAAS,QAAA;;;AAJnB,IAAA,oBAAyB,kCAAzB,yBAAyB,EAAA;AAC3B,IAAA,kBAAuB,kCAAvB,uBAAuB,EAAA;AACxB,IAAA,iBAAsB,kCAAtB,sBAAsB,EAAA"}

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _icssUtils = require("next/dist/compiled/icss-utils");
var _utils = require("../utils");
const plugin = (options = {})=>{
return {
postcssPlugin: "postcss-icss-parser",
async OnceExit (root) {
const importReplacements = Object.create(null);
const { icssImports , icssExports } = (0, _icssUtils).extractICSS(root);
const imports = new Map();
const tasks = [];
// eslint-disable-next-line guard-for-in
for(const url in icssImports){
const tokens = icssImports[url];
if (Object.keys(tokens).length === 0) {
continue;
}
let normalizedUrl = url;
let prefix = "";
const queryParts = normalizedUrl.split("!");
if (queryParts.length > 1) {
normalizedUrl = queryParts.pop();
prefix = queryParts.join("!");
}
const request = (0, _utils).requestify((0, _utils).normalizeUrl(normalizedUrl, true), options.rootContext);
const doResolve = async ()=>{
const { resolver , context } = options;
const resolvedUrl = await (0, _utils).resolveRequests(resolver, context, [
...new Set([
normalizedUrl,
request
]),
]);
if (!resolvedUrl) {
return;
}
// eslint-disable-next-line consistent-return
return {
url: resolvedUrl,
prefix,
tokens
};
};
tasks.push(doResolve());
}
const results = await Promise.all(tasks);
for(let index = 0; index <= results.length - 1; index++){
const item = results[index];
if (!item) {
continue;
}
const newUrl = item.prefix ? `${item.prefix}!${item.url}` : item.url;
const importKey = newUrl;
let importName = imports.get(importKey);
if (!importName) {
importName = `___CSS_LOADER_ICSS_IMPORT_${imports.size}___`;
imports.set(importKey, importName);
options.imports.push({
type: "icss_import",
importName,
url: options.urlHandler(newUrl),
icss: true,
index
});
options.api.push({
importName,
dedupe: true,
index
});
}
for (const [replacementIndex, token] of Object.keys(item.tokens).entries()){
const replacementName = `___CSS_LOADER_ICSS_IMPORT_${index}_REPLACEMENT_${replacementIndex}___`;
const localName = item.tokens[token];
importReplacements[token] = replacementName;
options.replacements.push({
replacementName,
importName,
localName
});
}
}
if (Object.keys(importReplacements).length > 0) {
(0, _icssUtils).replaceSymbols(root, importReplacements);
}
for (const name of Object.keys(icssExports)){
const value = (0, _icssUtils).replaceValueSymbols(icssExports[name], importReplacements);
options.exports.push({
name,
value
});
}
}
};
};
plugin.postcss = true;
var _default = plugin;
exports.default = _default;
//# sourceMappingURL=postcss-icss-parser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/plugins/postcss-icss-parser.js"],"names":["plugin","options","postcssPlugin","OnceExit","root","importReplacements","Object","create","icssImports","icssExports","extractICSS","imports","Map","tasks","url","tokens","keys","length","normalizedUrl","prefix","queryParts","split","pop","join","request","requestify","normalizeUrl","rootContext","doResolve","resolver","context","resolvedUrl","resolveRequests","Set","push","results","Promise","all","index","item","newUrl","importKey","importName","get","size","set","type","urlHandler","icss","api","dedupe","replacementIndex","token","entries","replacementName","localName","replacements","replaceSymbols","name","value","replaceValueSymbols","exports","postcss"],"mappings":"AAAA;;;;;AAIO,IAAA,UAA+B,WAA/B,+BAA+B,CAAA;AAEoB,IAAA,MAAU,WAAV,UAAU,CAAA;AAEpE,MAAMA,MAAM,GAAG,CAACC,OAAO,GAAG,EAAE,GAAK;IAC/B,OAAO;QACLC,aAAa,EAAE,qBAAqB;QACpC,MAAMC,QAAQ,EAACC,IAAI,EAAE;YACnB,MAAMC,kBAAkB,GAAGC,MAAM,CAACC,MAAM,CAAC,IAAI,CAAC;YAC9C,MAAM,EAAEC,WAAW,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGC,CAAAA,GAAAA,UAAW,AAAM,CAAA,YAAN,CAACN,IAAI,CAAC;YACtD,MAAMO,OAAO,GAAG,IAAIC,GAAG,EAAE;YACzB,MAAMC,KAAK,GAAG,EAAE;YAEhB,wCAAwC;YACxC,IAAK,MAAMC,GAAG,IAAIN,WAAW,CAAE;gBAC7B,MAAMO,MAAM,GAAGP,WAAW,CAACM,GAAG,CAAC;gBAE/B,IAAIR,MAAM,CAACU,IAAI,CAACD,MAAM,CAAC,CAACE,MAAM,KAAK,CAAC,EAAE;oBAEpC,SAAQ;iBACT;gBAED,IAAIC,aAAa,GAAGJ,GAAG;gBACvB,IAAIK,MAAM,GAAG,EAAE;gBAEf,MAAMC,UAAU,GAAGF,aAAa,CAACG,KAAK,CAAC,GAAG,CAAC;gBAE3C,IAAID,UAAU,CAACH,MAAM,GAAG,CAAC,EAAE;oBACzBC,aAAa,GAAGE,UAAU,CAACE,GAAG,EAAE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CAAC;aACzC;YAED,KAAK,MAAMqD,IAAI,IAAIpD,MAAM,CAACU,IAAI,CAACP,WAAW,CAAC,CAAE;gBAC3C,MAAMkD,KAAK,GAAGC,CAAAA,GAAAA,UAAmB,AAAuC,CAAA,oBAAvC,CAACnD,WAAW,CAACiD,IAAI,CAAC,EAAErD,kBAAkB,CAAC;gBAExEJ,OAAO,CAAC4D,OAAO,CAAC3B,IAAI,CAAC;oBAAEwB,IAAI;oBAAEC,KAAK;iBAAE,CAAC;aACtC;SACF;KACF,CAAA;CACF;AAED3D,MAAM,CAAC8D,OAAO,GAAG,IAAI;eAEN9D,MAAM"}

View File

@@ -0,0 +1,202 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssValueParser = _interopRequireDefault(require("next/dist/compiled/postcss-value-parser"));
var _utils = require("../utils");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function parseNode(atRule, key) {
// Convert only top-level @import
if (atRule.parent.type !== "root") {
return;
}
if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched && matched[2] === "true") {
return;
}
}
const prevNode = atRule.prev();
if (prevNode && prevNode.type === "comment") {
const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched && matched[2] === "true") {
return;
}
}
// Nodes do not exists - `@import url('http://') :root {}`
if (atRule.nodes) {
const error = new Error("It looks like you didn't end your @import statement correctly. Child nodes are attached to it.");
error.node = atRule;
throw error;
}
const { nodes: paramsNodes } = (0, _postcssValueParser).default(atRule[key]);
// No nodes - `@import ;`
// Invalid type - `@import foo-bar;`
if (paramsNodes.length === 0 || paramsNodes[0].type !== "string" && paramsNodes[0].type !== "function") {
const error = new Error(`Unable to find uri in "${atRule.toString()}"`);
error.node = atRule;
throw error;
}
let isStringValue;
let url;
if (paramsNodes[0].type === "string") {
isStringValue = true;
url = paramsNodes[0].value;
} else {
// Invalid function - `@import nourl(test.css);`
if (paramsNodes[0].value.toLowerCase() !== "url") {
const error = new Error(`Unable to find uri in "${atRule.toString()}"`);
error.node = atRule;
throw error;
}
isStringValue = paramsNodes[0].nodes.length !== 0 && paramsNodes[0].nodes[0].type === "string";
url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
}
url = (0, _utils).normalizeUrl(url, isStringValue);
const isRequestable = (0, _utils).isUrlRequestable(url);
let prefix;
if (isRequestable) {
const queryParts = url.split("!");
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
}
// Empty url - `@import "";` or `@import url();`
if (url.trim().length === 0) {
const error = new Error(`Unable to find uri in "${atRule.toString()}"`);
error.node = atRule;
throw error;
}
const mediaNodes = paramsNodes.slice(1);
let media;
if (mediaNodes.length > 0) {
media = _postcssValueParser.default.stringify(mediaNodes).trim().toLowerCase();
}
// eslint-disable-next-line consistent-return
return {
atRule,
prefix,
url,
media,
isRequestable
};
}
const plugin = (options = {})=>{
return {
postcssPlugin: "postcss-import-parser",
prepare (result) {
const parsedAtRules = [];
return {
AtRule: {
import (atRule) {
let parsedAtRule;
try {
parsedAtRule = parseNode(atRule, "params", result);
} catch (error) {
result.warn(error.message, {
node: error.node
});
}
if (!parsedAtRule) {
return;
}
parsedAtRules.push(parsedAtRule);
}
},
async OnceExit () {
if (parsedAtRules.length === 0) {
return;
}
const resolvedAtRules = await Promise.all(parsedAtRules.map(async (parsedAtRule)=>{
const { atRule , isRequestable , prefix , url , media } = parsedAtRule;
if (options.filter) {
const needKeep = await options.filter(url, media);
if (!needKeep) {
return;
}
}
if (isRequestable) {
const request = (0, _utils).requestify(url, options.rootContext);
const { resolver , context } = options;
const resolvedUrl = await (0, _utils).resolveRequests(resolver, context, [
...new Set([
request,
url
]),
]);
if (!resolvedUrl) {
return;
}
if (resolvedUrl === options.resourcePath) {
atRule.remove();
return;
}
atRule.remove();
// eslint-disable-next-line consistent-return
return {
url: resolvedUrl,
media,
prefix,
isRequestable
};
}
atRule.remove();
// eslint-disable-next-line consistent-return
return {
url,
media,
prefix,
isRequestable
};
}));
const urlToNameMap = new Map();
for(let index = 0; index <= resolvedAtRules.length - 1; index++){
const resolvedAtRule = resolvedAtRules[index];
if (!resolvedAtRule) {
continue;
}
const { url , isRequestable , media } = resolvedAtRule;
if (!isRequestable) {
options.api.push({
url,
media,
index
});
continue;
}
const { prefix } = resolvedAtRule;
const newUrl = prefix ? `${prefix}!${url}` : url;
let importName = urlToNameMap.get(newUrl);
if (!importName) {
importName = `___CSS_LOADER_AT_RULE_IMPORT_${urlToNameMap.size}___`;
urlToNameMap.set(newUrl, importName);
options.imports.push({
type: "rule_import",
importName,
url: options.urlHandler(newUrl),
index
});
}
options.api.push({
importName,
media,
index
});
}
}
};
}
};
};
plugin.postcss = true;
var _default = plugin;
exports.default = _default;
//# sourceMappingURL=postcss-import-parser.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,323 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssValueParser = _interopRequireDefault(require("next/dist/compiled/postcss-value-parser"));
var _utils = require("../utils");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const isUrlFunc = /url/i;
const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
const needParseDeclaration = /(?:url|(?:-webkit-)?image-set)\(/i;
function getNodeFromUrlFunc(node) {
return node.nodes && node.nodes[0];
}
function getWebpackIgnoreCommentValue(index, nodes, inBetween) {
if (index === 0 && typeof inBetween !== "undefined") {
return inBetween;
}
let prevValueNode = nodes[index - 1];
if (!prevValueNode) {
// eslint-disable-next-line consistent-return
return;
}
if (prevValueNode.type === "space") {
if (!nodes[index - 2]) {
// eslint-disable-next-line consistent-return
return;
}
prevValueNode = nodes[index - 2];
}
if (prevValueNode.type !== "comment") {
// eslint-disable-next-line consistent-return
return;
}
const matched = prevValueNode.value.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
return matched && matched[2] === "true";
}
function shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL) {
if (url.length === 0) {
result.warn(`Unable to find uri in '${declaration.toString()}'`, {
node: declaration
});
return false;
}
if ((0, _utils).isDataUrl(url) && isSupportDataURLInNewURL) {
try {
decodeURIComponent(url);
} catch (ignoreError) {
return false;
}
return true;
}
if (!(0, _utils).isUrlRequestable(url)) {
return false;
}
return true;
}
function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
if (!needParseDeclaration.test(declaration[key])) {
return;
}
const parsed = (0, _postcssValueParser).default(declaration.raws && declaration.raws.value && declaration.raws.value.raw ? declaration.raws.value.raw : declaration[key]);
let inBetween;
if (declaration.raws && declaration.raws.between) {
const lastCommentIndex = declaration.raws.between.lastIndexOf("/*");
const matched = declaration.raws.between.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched) {
inBetween = matched[2] === "true";
}
}
let isIgnoreOnDeclaration = false;
const prevNode = declaration.prev();
if (prevNode && prevNode.type === "comment") {
const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched) {
isIgnoreOnDeclaration = matched[2] === "true";
}
}
let needIgnore;
const parsedURLs = [];
parsed.walk((valueNode, index, valueNodes)=>{
if (valueNode.type !== "function") {
return;
}
if (isUrlFunc.test(valueNode.value)) {
needIgnore = getWebpackIgnoreCommentValue(index, valueNodes, inBetween);
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
if (needIgnore) {
// eslint-disable-next-line no-undefined
needIgnore = undefined;
}
return;
}
const { nodes } = valueNode;
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
let url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
url = (0, _utils).normalizeUrl(url, isStringValue);
// Do not traverse inside `url`
if (!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)) {
// eslint-disable-next-line consistent-return
return false;
}
const queryParts = url.split("!");
let prefix;
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
parsedURLs.push({
declaration,
parsed,
node: getNodeFromUrlFunc(valueNode),
prefix,
url,
needQuotes: false
});
// eslint-disable-next-line consistent-return
return false;
} else if (isImageSetFunc.test(valueNode.value)) {
for (const [innerIndex, nNode] of valueNode.nodes.entries()){
const { type , value } = nNode;
if (type === "function" && isUrlFunc.test(value)) {
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
if (needIgnore) {
// eslint-disable-next-line no-undefined
needIgnore = undefined;
}
continue;
}
const { nodes } = nNode;
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
let url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
url = (0, _utils).normalizeUrl(url, isStringValue);
// Do not traverse inside `url`
if (!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)) {
// eslint-disable-next-line consistent-return
return false;
}
const queryParts = url.split("!");
let prefix;
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
parsedURLs.push({
declaration,
parsed,
node: getNodeFromUrlFunc(nNode),
prefix,
url,
needQuotes: false
});
} else if (type === "string") {
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
if (needIgnore) {
// eslint-disable-next-line no-undefined
needIgnore = undefined;
}
continue;
}
let url = (0, _utils).normalizeUrl(value, true);
// Do not traverse inside `url`
if (!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)) {
// eslint-disable-next-line consistent-return
return false;
}
const queryParts = url.split("!");
let prefix;
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
parsedURLs.push({
declaration,
parsed,
node: nNode,
prefix,
url,
needQuotes: true
});
}
}
// Do not traverse inside `image-set`
// eslint-disable-next-line consistent-return
return false;
}
});
// eslint-disable-next-line consistent-return
return parsedURLs;
}
const plugin = (options = {})=>{
return {
postcssPlugin: "postcss-url-parser",
prepare (result) {
const parsedDeclarations = [];
return {
Declaration (declaration) {
const { isSupportDataURLInNewURL } = options;
const parsedURL = parseDeclaration(declaration, "value", result, isSupportDataURLInNewURL);
if (!parsedURL) {
return;
}
parsedDeclarations.push(...parsedURL);
},
async OnceExit () {
if (parsedDeclarations.length === 0) {
return;
}
const resolvedDeclarations = await Promise.all(parsedDeclarations.map(async (parsedDeclaration)=>{
const { url } = parsedDeclaration;
if (options.filter) {
const needKeep = await options.filter(url);
if (!needKeep) {
// eslint-disable-next-line consistent-return
return;
}
}
if ((0, _utils).isDataUrl(url)) {
// eslint-disable-next-line consistent-return
return parsedDeclaration;
}
const splittedUrl = url.split(/(\?)?#/);
const [pathname, query, hashOrQuery] = splittedUrl;
let hash = query ? "?" : "";
hash += hashOrQuery ? `#${hashOrQuery}` : "";
const { needToResolveURL , rootContext } = options;
const request = (0, _utils).requestify(pathname, rootContext, needToResolveURL);
if (!needToResolveURL) {
// eslint-disable-next-line consistent-return
return {
...parsedDeclaration,
url: request,
hash
};
}
const { resolver , context } = options;
const resolvedUrl = await (0, _utils).resolveRequests(resolver, context, [
...new Set([
request,
url
]),
]);
if (!resolvedUrl) {
// eslint-disable-next-line consistent-return
return;
}
// eslint-disable-next-line consistent-return
return {
...parsedDeclaration,
url: resolvedUrl,
hash
};
}));
const urlToNameMap = new Map();
const urlToReplacementMap = new Map();
let hasUrlImportHelper = false;
for(let index = 0; index <= resolvedDeclarations.length - 1; index++){
const item = resolvedDeclarations[index];
if (!item) {
continue;
}
if (!hasUrlImportHelper) {
options.imports.push({
type: "get_url_import",
importName: "___CSS_LOADER_GET_URL_IMPORT___",
url: options.urlHandler(require.resolve("../runtime/getUrl.js")),
index: -1
});
hasUrlImportHelper = true;
}
const { url , prefix } = item;
const newUrl = prefix ? `${prefix}!${url}` : url;
let importName = urlToNameMap.get(newUrl);
if (!importName) {
importName = `___CSS_LOADER_URL_IMPORT_${urlToNameMap.size}___`;
urlToNameMap.set(newUrl, importName);
options.imports.push({
type: "url",
importName,
url: options.needToResolveURL ? options.urlHandler(newUrl) : JSON.stringify(newUrl),
index
});
}
const { hash , needQuotes } = item;
const replacementKey = JSON.stringify({
newUrl,
hash,
needQuotes
});
let replacementName = urlToReplacementMap.get(replacementKey);
if (!replacementName) {
replacementName = `___CSS_LOADER_URL_REPLACEMENT_${urlToReplacementMap.size}___`;
urlToReplacementMap.set(replacementKey, replacementName);
options.replacements.push({
replacementName,
importName,
hash,
needQuotes
});
}
// eslint-disable-next-line no-param-reassign
item.node.type = "word";
// eslint-disable-next-line no-param-reassign
item.node.value = replacementName;
// eslint-disable-next-line no-param-reassign
item.declaration.value = item.parsed.toString();
}
}
};
}
};
};
plugin.postcss = true;
var _default = plugin;
exports.default = _default;
//# sourceMappingURL=postcss-url-parser.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,88 @@
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/ // css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function(useSourceMap) {
var list = [] // return the list of modules as css string
;
list.toString = function toString() {
return this.map(function(item) {
var content = cssWithMappingToString(item, useSourceMap);
if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}
return content;
}).join("");
} // import a list of modules into the list
;
// eslint-disable-next-line func-names
list.i = function(modules, mediaQuery, dedupe) {
if (typeof modules === "string") {
// eslint-disable-next-line no-param-reassign
modules = [
[
null,
modules,
""
]
];
}
var alreadyImportedModules = {};
if (dedupe) {
for(var i = 0; i < this.length; i++){
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for(var _i = 0; _i < modules.length; _i++){
var item = [].concat(modules[_i]);
if (dedupe && alreadyImportedModules[item[0]]) {
continue;
}
if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}
list.push(item);
}
};
return list;
};
function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || "" // eslint-disable-next-line prefer-destructuring
;
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (useSourceMap && typeof btoa === "function") {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function(source) {
return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
});
return [
content
].concat(sourceURLs).concat([
sourceMapping
]).join("\n");
}
return [
content
].join("\n");
} // Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
return "/*# ".concat(data, " */");
}
//# sourceMappingURL=api.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/runtime/api.js"],"names":["module","exports","useSourceMap","list","toString","map","item","content","cssWithMappingToString","concat","join","i","modules","mediaQuery","dedupe","alreadyImportedModules","length","id","_i","push","cssMapping","btoa","sourceMapping","toComment","sourceURLs","sources","source","sourceRoot","sourceMap","base64","unescape","encodeURIComponent","JSON","stringify","data"],"mappings":"AAMAA;AANA;;;EAGE,CACF,4CAA4C;AAC5C,sCAAsC;AACtCA,MAAM,CAACC,OAAO,GAAG,SAAUC,YAAY,EAAE;IACvC,IAAIC,IAAI,GAAG,EAAE,CAAC,2CAA2C;IAA5C;IAEbA,IAAI,CAACC,QAAQ,GAAG,SAASA,QAAQ,GAAG;QAClC,OAAO,IAAI,CAACC,GAAG,CAAC,SAAUC,IAAI,EAAE;YAC9B,IAAIC,OAAO,GAAGC,sBAAsB,CAACF,IAAI,EAAEJ,YAAY,CAAC;YAExD,IAAII,IAAI,C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AC;IAC1E,IAAIM,IAAI,GACN,8DAA8D,CAACzB,MAAM,CACnEoB,MAAM,CACP;IACH,OAAO,MAAM,CAACpB,MAAM,CAACyB,IAAI,EAAE,KAAK,CAAC,CAAA;CAClC"}

View File

@@ -0,0 +1,26 @@
"use strict";
module.exports = function(url, options) {
if (!options) {
// eslint-disable-next-line no-param-reassign
options = {};
} // eslint-disable-next-line no-underscore-dangle, no-param-reassign
url = url && url.__esModule ? url.default : url;
if (typeof url !== "string") {
return url;
} // If url is already wrapped in quotes, remove them
if (/^['"].*['"]$/.test(url)) {
// eslint-disable-next-line no-param-reassign
url = url.slice(1, -1);
}
if (options.hash) {
// eslint-disable-next-line no-param-reassign
url += options.hash;
} // Should url be wrapped?
// See https://drafts.csswg.org/css-values-3/#urls
if (/["'() \t\n]/.test(url) || options.needQuotes) {
return '"'.concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), '"');
}
return url;
};
//# sourceMappingURL=getUrl.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/runtime/getUrl.js"],"names":["module","exports","url","options","__esModule","default","test","slice","hash","needQuotes","concat","replace"],"mappings":"AAAAA;AAAAA,MAAM,CAACC,OAAO,GAAG,SAAUC,GAAG,EAAEC,OAAO,EAAE;IACvC,IAAI,CAACA,OAAO,EAAE;QACZ,6CAA6C;QAC7CA,OAAO,GAAG,EAAE;KACb,CAAC,mEAAmE;IAErED,GAAG,GAAGA,GAAG,IAAIA,GAAG,CAACE,UAAU,GAAGF,GAAG,CAACG,OAAO,GAAGH,GAAG;IAE/C,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAOA,GAAG,CAAA;KACX,CAAC,mDAAmD;IAErD,IAAI,eAAeI,IAAI,CAACJ,GAAG,CAAC,EAAE;QAC5B,6CAA6C;QAC7CA,GAAG,GAAGA,GAAG,CAACK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACvB;IAED,IAAIJ,OAAO,CAACK,IAAI,EAAE;QAChB,6CAA6C;QAC7CN,GAAG,IAAIC,OAAO,CAACK,IAAI;KACpB,CAAC,yBAAyB;IAC3B,kDAAkD;IAElD,IAAI,cAAcF,IAAI,CAACJ,GAAG,CAAC,IAAIC,OAAO,CAACM,UAAU,EAAE;QACjD,OAAO,GAAG,CAACC,MAAM,CAACR,GAAG,CAACS,OAAO,OAAO,KAAK,CAAC,CAACA,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG,CAAC,CAAA;KACvE;IAED,OAAOT,GAAG,CAAA;CACX"}

View File

@@ -0,0 +1,387 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isDataUrl = exports.sort = exports.isUrlRequestable = exports.resolveRequests = exports.getExportCode = exports.getModuleCode = exports.getImportCode = exports.getPreRequester = exports.normalizeSourceMap = exports.getModulesPlugins = exports.shouldUseIcssPlugin = exports.shouldUseModulesPlugins = exports.shouldUseURLPlugin = exports.shouldUseImportPlugin = exports.getFilter = exports.requestify = exports.normalizeUrl = void 0;
var _url = require("url");
var _path = _interopRequireDefault(require("path"));
var _loaderUtils3 = require("next/dist/compiled/loader-utils3");
var _postcssModulesValues = _interopRequireDefault(require("next/dist/compiled/postcss-modules-values"));
var _postcssModulesLocalByDefault = _interopRequireDefault(require("next/dist/compiled/postcss-modules-local-by-default"));
var _postcssModulesExtractImports = _interopRequireDefault(require("next/dist/compiled/postcss-modules-extract-imports"));
var _postcssModulesScope = _interopRequireDefault(require("next/dist/compiled/postcss-modules-scope"));
var _camelcase = _interopRequireDefault(require("./camelcase"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const whitespace = "[\\x20\\t\\r\\n\\f]";
const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, "ig");
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
function unescape(str) {
return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace)=>{
const high = `0x${escaped}` - 0x10000;
/* eslint-disable line-comment-position */ // NaN means non-codepoint
// Workaround erroneous numeric interpretation of +"0x"
// eslint-disable-next-line no-self-compare
return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 0x10000) : // eslint-disable-next-line no-bitwise
String.fromCharCode(high >> 10 | 0xd800, high & 0x3ff | 0xdc00);
/* eslint-enable line-comment-position */ });
}
function normalizePath(file) {
return _path.default.sep === "\\" ? file.replace(/\\/g, "/") : file;
}
function fixedEncodeURIComponent(str) {
return str.replace(/[!'()*]/g, (c)=>`%${c.charCodeAt(0).toString(16)}`);
}
function normalizeUrl(url, isStringValue) {
let normalizedUrl = url;
if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, "");
}
if (matchNativeWin32Path.test(url)) {
try {
normalizedUrl = decodeURIComponent(normalizedUrl);
} catch (error) {
// Ignores invalid and broken URLs and try to resolve them as is
}
return normalizedUrl;
}
normalizedUrl = unescape(normalizedUrl);
if (isDataUrl(url)) {
return fixedEncodeURIComponent(normalizedUrl);
}
try {
normalizedUrl = decodeURI(normalizedUrl);
} catch (error) {
// Ignores invalid and broken URLs and try to resolve them as is
}
return normalizedUrl;
}
function requestify(url, rootContext) {
if (/^file:/i.test(url)) {
return (0, _url).fileURLToPath(url);
}
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return url;
}
return url.charAt(0) === "/" ? (0, _loaderUtils3).urlToRequest(url, rootContext) : (0, _loaderUtils3).urlToRequest(url);
}
function getFilter(filter, resourcePath) {
return (...args)=>{
if (typeof filter === "function") {
return filter(...args, resourcePath);
}
return true;
};
}
function shouldUseImportPlugin(options) {
if (options.modules.exportOnlyLocals) {
return false;
}
if (typeof options.import === "boolean") {
return options.import;
}
return true;
}
function shouldUseURLPlugin(options) {
if (options.modules.exportOnlyLocals) {
return false;
}
if (typeof options.url === "boolean") {
return options.url;
}
return true;
}
function shouldUseModulesPlugins(options) {
return options.modules.compileType === "module";
}
function shouldUseIcssPlugin(options) {
return options.icss === true || Boolean(options.modules);
}
function getModulesPlugins(options, loaderContext, meta) {
const { mode , getLocalIdent , localIdentName , localIdentContext , localIdentHashPrefix , localIdentRegExp , } = options.modules;
let plugins = [];
try {
plugins = [
_postcssModulesValues.default,
(0, _postcssModulesLocalByDefault).default({
mode
}),
(0, _postcssModulesExtractImports).default(),
(0, _postcssModulesScope).default({
generateScopedName (exportName) {
return getLocalIdent(loaderContext, localIdentName, exportName, {
context: localIdentContext,
hashPrefix: localIdentHashPrefix,
regExp: localIdentRegExp
}, meta);
},
exportGlobals: options.modules.exportGlobals
}),
];
} catch (error) {
loaderContext.emitError(error);
}
return plugins;
}
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i;
function getURLType(source) {
if (source[0] === "/") {
if (source[1] === "/") {
return "scheme-relative";
}
return "path-absolute";
}
if (IS_NATIVE_WIN32_PATH.test(source)) {
return "path-absolute";
}
return ABSOLUTE_SCHEME.test(source) ? "absolute" : "path-relative";
}
function normalizeSourceMap(map, resourcePath) {
let newMap = map;
// Some loader emit source map as string
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
if (typeof newMap === "string") {
newMap = JSON.parse(newMap);
}
delete newMap.file;
const { sourceRoot } = newMap;
delete newMap.sourceRoot;
if (newMap.sources) {
// Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)
// We should normalize path because previous loaders like `sass-loader` using backslash when generate source map
newMap.sources = newMap.sources.map((source)=>{
// Non-standard syntax from `postcss`
if (source.indexOf("<") === 0) {
return source;
}
const sourceType = getURLType(source);
// Do no touch `scheme-relative` and `absolute` URLs
if (sourceType === "path-relative" || sourceType === "path-absolute") {
const absoluteSource = sourceType === "path-relative" && sourceRoot ? _path.default.resolve(sourceRoot, normalizePath(source)) : normalizePath(source);
return _path.default.relative(_path.default.dirname(resourcePath), absoluteSource);
}
return source;
});
}
return newMap;
}
function getPreRequester({ loaders , loaderIndex }) {
const cache = Object.create(null);
return (number)=>{
if (cache[number]) {
return cache[number];
}
if (number === false) {
cache[number] = "";
} else {
const loadersRequest = loaders.slice(loaderIndex, loaderIndex + 1 + (typeof number !== "number" ? 0 : number)).map((x)=>x.request).join("!");
cache[number] = `-!${loadersRequest}!`;
}
return cache[number];
};
}
function getImportCode(imports, options) {
let code = "";
for (const item of imports){
const { importName , url , icss } = item;
if (options.esModule) {
if (icss && options.modules.namedExport) {
code += `import ${options.modules.exportOnlyLocals ? "" : `${importName}, `}* as ${importName}_NAMED___ from ${url};\n`;
} else {
code += `import ${importName} from ${url};\n`;
}
} else {
code += `var ${importName} = require(${url});\n`;
}
}
return code ? `// Imports\n${code}` : "";
}
function normalizeSourceMapForRuntime(map, loaderContext) {
const resultMap = map ? map.toJSON() : null;
if (resultMap) {
delete resultMap.file;
resultMap.sourceRoot = "";
resultMap.sources = resultMap.sources.map((source)=>{
// Non-standard syntax from `postcss`
if (source.indexOf("<") === 0) {
return source;
}
const sourceType = getURLType(source);
if (sourceType !== "path-relative") {
return source;
}
const resourceDirname = _path.default.dirname(loaderContext.resourcePath);
const absoluteSource = _path.default.resolve(resourceDirname, source);
const contextifyPath = normalizePath(_path.default.relative(loaderContext.rootContext, absoluteSource));
return `webpack://${contextifyPath}`;
});
}
return JSON.stringify(resultMap);
}
function getModuleCode(result, api, replacements, options, loaderContext) {
if (options.modules.exportOnlyLocals === true) {
return "";
}
const sourceMapValue = options.sourceMap ? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}` : "";
let code = JSON.stringify(result.css);
let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${options.sourceMap});\n`;
for (const item of api){
const { url , media , dedupe } = item;
beforeCode += url ? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(`@import url(${url});`)}${media ? `, ${JSON.stringify(media)}` : ""}]);\n` : `___CSS_LOADER_EXPORT___.i(${item.importName}${media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ""}${dedupe ? ", true" : ""});\n`;
}
for (const item1 of replacements){
const { replacementName , importName , localName } = item1;
if (localName) {
code = code.replace(new RegExp(replacementName, "g"), ()=>options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase).default(localName))}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
} else {
const { hash , needQuotes } = item1;
const getUrlOptions = [].concat(hash ? [
`hash: ${JSON.stringify(hash)}`
] : []).concat(needQuotes ? "needQuotes: true" : []);
const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(", ")} }` : "";
beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`;
code = code.replace(new RegExp(replacementName, "g"), ()=>`" + ${replacementName} + "`);
}
}
return `${beforeCode}// Module\n___CSS_LOADER_EXPORT___.push([module.id, ${code}, ""${sourceMapValue}]);\n`;
}
function dashesCamelCase(str) {
return str.replace(/-+(\w)/g, (match, firstLetter)=>firstLetter.toUpperCase());
}
function getExportCode(exports, replacements, options) {
let code = "// Exports\n";
let localsCode = "";
const addExportToLocalsCode = (name, value)=>{
if (options.modules.namedExport) {
localsCode += `export const ${(0, _camelcase).default(name)} = ${JSON.stringify(value)};\n`;
} else {
if (localsCode) {
localsCode += `,\n`;
}
localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`;
}
};
for (const { name: name1 , value: value1 } of exports){
switch(options.modules.exportLocalsConvention){
case "camelCase":
{
addExportToLocalsCode(name1, value1);
const modifiedName = (0, _camelcase).default(name1);
if (modifiedName !== name1) {
addExportToLocalsCode(modifiedName, value1);
}
break;
}
case "camelCaseOnly":
{
addExportToLocalsCode((0, _camelcase).default(name1), value1);
break;
}
case "dashes":
{
addExportToLocalsCode(name1, value1);
const modifiedName = dashesCamelCase(name1);
if (modifiedName !== name1) {
addExportToLocalsCode(modifiedName, value1);
}
break;
}
case "dashesOnly":
{
addExportToLocalsCode(dashesCamelCase(name1), value1);
break;
}
case "asIs":
default:
addExportToLocalsCode(name1, value1);
break;
}
}
for (const item of replacements){
const { replacementName , localName } = item;
if (localName) {
const { importName } = item;
localsCode = localsCode.replace(new RegExp(replacementName, "g"), ()=>{
if (options.modules.namedExport) {
return `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase).default(localName))}] + "`;
} else if (options.modules.exportOnlyLocals) {
return `" + ${importName}[${JSON.stringify(localName)}] + "`;
}
return `" + ${importName}.locals[${JSON.stringify(localName)}] + "`;
});
} else {
localsCode = localsCode.replace(new RegExp(replacementName, "g"), ()=>`" + ${replacementName} + "`);
}
}
if (options.modules.exportOnlyLocals) {
code += options.modules.namedExport ? localsCode : `${options.esModule ? "export default" : "module.exports ="} {\n${localsCode}\n};\n`;
return code;
}
if (localsCode) {
code += options.modules.namedExport ? localsCode : `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`;
}
code += `${options.esModule ? "export default" : "module.exports ="} ___CSS_LOADER_EXPORT___;\n`;
return code;
}
async function resolveRequests(resolve, context, possibleRequests) {
return resolve(context, possibleRequests[0]).then((result)=>{
return result;
}).catch((error)=>{
const [, ...tailPossibleRequests] = possibleRequests;
if (tailPossibleRequests.length === 0) {
throw error;
}
return resolveRequests(resolve, context, tailPossibleRequests);
});
}
function isUrlRequestable(url) {
// Protocol-relative URLs
if (/^\/\//.test(url)) {
return false;
}
// `file:` protocol
if (/^file:/i.test(url)) {
return true;
}
// Absolute URLs
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return true;
}
// `#` URLs
if (/^#/.test(url)) {
return false;
}
return true;
}
function sort(a, b) {
return a.index - b.index;
}
function isDataUrl(url) {
if (/^data:/i.test(url)) {
return true;
}
return false;
}
exports.normalizeUrl = normalizeUrl;
exports.requestify = requestify;
exports.getFilter = getFilter;
exports.shouldUseImportPlugin = shouldUseImportPlugin;
exports.shouldUseURLPlugin = shouldUseURLPlugin;
exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
exports.shouldUseIcssPlugin = shouldUseIcssPlugin;
exports.getModulesPlugins = getModulesPlugins;
exports.normalizeSourceMap = normalizeSourceMap;
exports.getPreRequester = getPreRequester;
exports.getImportCode = getImportCode;
exports.getModuleCode = getModuleCode;
exports.getExportCode = getExportCode;
exports.resolveRequests = resolveRequests;
exports.isUrlRequestable = isUrlRequestable;
exports.sort = sort;
exports.isDataUrl = isDataUrl;
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
declare const ErrorLoader: webpack.LoaderDefinitionFunction;
export default ErrorLoader;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const ErrorLoader = function() {
var ref, ref1, ref2;
// @ts-ignore exists
const options = this.getOptions() || {};
const { reason ="An unknown error has occurred" } = options;
// @ts-expect-error
const resource = ((ref = this._module) == null ? void 0 : (ref1 = ref.issuer) == null ? void 0 : ref1.resource) ?? null;
const context = this.rootContext ?? ((ref2 = this._compiler) == null ? void 0 : ref2.context);
const issuer = resource ? context ? _path.default.relative(context, resource) : resource : null;
const err = new Error(reason + (issuer ? `\nLocation: ${_chalk.default.cyan(issuer)}` : ""));
this.emitError(err);
};
var _default = ErrorLoader;
exports.default = _default;
//# sourceMappingURL=error-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/error-loader.ts"],"names":["ErrorLoader","options","getOptions","reason","resource","_module","issuer","context","rootContext","_compiler","path","relative","err","Error","chalk","cyan","emitError"],"mappings":"AAAA;;;;;AAAkB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC3B,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAGvB,MAAMA,WAAW,GAAqC,WAAY;QAO/C,GAAY,QACO,IAAc;IAPlD,oBAAoB;IACpB,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,EAAE,IAAK,EAAE,AAAQ;IAEhD,MAAM,EAAEC,MAAM,EAAG,+BAA+B,CAAA,EAAE,GAAGF,OAAO;IAE5D,mBAAmB;IACnB,MAAMG,QAAQ,GAAG,CAAA,CAAA,GAAY,GAAZ,IAAI,CAACC,OAAO,SAAQ,GAApB,KAAA,CAAoB,GAApB,QAAA,GAAY,CAAEC,MAAM,SAAA,GAApB,KAAA,CAAoB,QAAEF,QAAQ,AAAV,CAAA,IAAc,IAAI;IACvD,MAAMG,OAAO,GAAG,IAAI,CAACC,WAAW,IAAI,CAAA,CAAA,IAAc,GAAd,IAAI,CAACC,SAAS,SAAS,GAAvB,KAAA,CAAuB,GAAvB,IAAc,CAAEF,OAAO,CAAA;IAE3D,MAAMD,MAAM,GAAGF,QAAQ,GACnBG,OAAO,GACLG,KAAI,QAAA,CAACC,QAAQ,CAACJ,OAAO,EAAEH,QAAQ,CAAC,GAChCA,QAAQ,GACV,IAAI;IAER,MAAMQ,GAAG,GAAG,IAAIC,KAAK,CACnBV,MAAM,GAAG,CAACG,MAAM,GAAG,CAAC,YAAY,EAAEQ,MAAK,QAAA,CAACC,IAAI,CAACT,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAC7D;IACD,IAAI,CAACU,SAAS,CAACJ,GAAG,CAAC;CACpB;eAEcZ,WAAW"}

View File

@@ -0,0 +1,40 @@
import type { MiddlewareMatcher, RSCModuleType } from '../../analysis/get-page-static-info';
import { webpack } from 'next/dist/compiled/webpack/webpack';
/**
* A getter for module build info that casts to the type it should have.
* We also expose here types to make easier to use it.
*/
export declare function getModuleBuildInfo(webpackModule: webpack.Module): {
nextEdgeMiddleware?: EdgeMiddlewareMeta | undefined;
nextEdgeApiFunction?: EdgeMiddlewareMeta | undefined;
nextEdgeSSR?: EdgeSSRMeta | undefined;
nextUsedEnvVars?: Set<string> | undefined;
nextWasmMiddlewareBinding?: AssetBinding | undefined;
nextAssetMiddlewareBinding?: AssetBinding | undefined;
usingIndirectEval?: boolean | Set<string> | undefined;
route?: RouteMeta | undefined;
importLocByPath?: Map<string, any> | undefined;
rootDir?: string | undefined;
rsc?: RSCMeta | undefined;
};
export interface RSCMeta {
type?: RSCModuleType;
requests?: string[];
}
export interface RouteMeta {
page: string;
absolutePagePath: string;
}
export interface EdgeMiddlewareMeta {
page: string;
matchers?: MiddlewareMatcher[];
}
export interface EdgeSSRMeta {
isServerComponent: boolean;
isAppDir?: boolean;
page: string;
}
export interface AssetBinding {
filePath: string;
name: string;
}

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getModuleBuildInfo = getModuleBuildInfo;
function getModuleBuildInfo(webpackModule) {
return webpackModule.buildInfo;
}
//# sourceMappingURL=get-module-build-info.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/get-module-build-info.ts"],"names":["getModuleBuildInfo","webpackModule","buildInfo"],"mappings":"AAAA;;;;QAUgBA,kBAAkB,GAAlBA,kBAAkB;AAA3B,SAASA,kBAAkB,CAACC,aAA6B,EAAE;IAChE,OAAOA,aAAa,CAACC,SAAS,CAY7B;CACF"}

View File

@@ -0,0 +1,28 @@
import type webpack from 'webpack';
import type { ValueOf } from '../../../shared/lib/constants';
declare const FILE_TYPES: {
readonly layout: "layout";
readonly template: "template";
readonly error: "error";
readonly loading: "loading";
readonly head: "head";
readonly 'not-found': "not-found";
};
declare type ComponentModule = () => any;
declare type ModuleReference = [componentModule: ComponentModule, filePath: string];
export declare type ComponentsType = {
readonly [componentKey in ValueOf<typeof FILE_TYPES>]?: ModuleReference;
} & {
readonly page?: ModuleReference;
};
declare const nextAppLoader: webpack.LoaderDefinitionFunction<{
name: string;
pagePath: string;
appDir: string;
appPaths: string[] | null;
pageExtensions: string[];
rootDir?: string;
tsconfigPath?: string;
isDev?: boolean;
}>;
export default nextAppLoader;

View File

@@ -0,0 +1,241 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _webpackConfig = require("../../webpack-config");
var _getModuleBuildInfo = require("./get-module-build-info");
var _path = require("path");
var _verifyRootLayout = require("../../../lib/verifyRootLayout");
var Log = _interopRequireWildcard(require("../../../build/output/log"));
var _constants = require("../../../lib/constants");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
const FILE_TYPES = {
layout: "layout",
template: "template",
error: "error",
loading: "loading",
head: "head",
"not-found": "not-found"
};
const GLOBAL_ERROR_FILE_TYPE = "global-error";
const PAGE_SEGMENT = "page$";
async function createTreeCodeFromPath({ pagePath , resolve , resolveParallelSegments }) {
const splittedPath = pagePath.split(/[\\/]/);
const appDirPrefix = splittedPath[0];
const pages = [];
let rootLayout;
let globalError;
async function createSubtreePropsFromSegmentPath(segments) {
const segmentPath = segments.join("/");
// Existing tree are the children of the current segment
const props = {};
// We need to resolve all parallel routes in this level.
const parallelSegments = [];
if (segments.length === 0) {
parallelSegments.push([
"children",
""
]);
} else {
parallelSegments.push(...resolveParallelSegments(segmentPath));
}
for (const [parallelKey, parallelSegment] of parallelSegments){
if (parallelSegment === PAGE_SEGMENT) {
const matchedPagePath = `${appDirPrefix}${segmentPath}/page`;
const resolvedPagePath = await resolve(matchedPagePath);
if (resolvedPagePath) pages.push(resolvedPagePath);
// Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it.
props[parallelKey] = `['', {}, {
page: [() => import(/* webpackMode: "eager" */ ${JSON.stringify(resolvedPagePath)}), ${JSON.stringify(resolvedPagePath)}]}]`;
continue;
}
const parallelSegmentPath = segmentPath + "/" + parallelSegment;
const subtree = await createSubtreePropsFromSegmentPath([
...segments,
parallelSegment,
]);
// `page` is not included here as it's added above.
const filePaths = await Promise.all(Object.values(FILE_TYPES).map(async (file)=>{
return [
file,
await resolve(`${appDirPrefix}${parallelSegmentPath}/${file}`),
];
}));
if (!rootLayout) {
var ref;
rootLayout = (ref = filePaths.find(([type, path])=>type === "layout" && !!path)) == null ? void 0 : ref[1];
}
if (!globalError) {
globalError = await resolve(`${appDirPrefix}${parallelSegmentPath}/${GLOBAL_ERROR_FILE_TYPE}`);
}
props[parallelKey] = `[
'${parallelSegment}',
${subtree},
{
${filePaths.filter(([, filePath])=>filePath !== undefined).map(([file, filePath])=>{
if (filePath === undefined) {
return "";
}
return `'${file}': [() => import(/* webpackMode: "eager" */ ${JSON.stringify(filePath)}), ${JSON.stringify(filePath)}],`;
}).join("\n")}
}
]`;
}
return `{
${Object.entries(props).map(([key, value])=>`${key}: ${value}`).join(",\n")}
}`;
}
const tree = await createSubtreePropsFromSegmentPath([]);
return [
`const tree = ${tree}.children;`,
pages,
rootLayout,
globalError
];
}
function createAbsolutePath(appDir, pathToTurnAbsolute) {
return pathToTurnAbsolute// Replace all POSIX path separators with the current OS path separator
.replace(/\//g, _path.sep).replace(/^private-next-app-dir/, appDir);
}
const nextAppLoader = async function nextAppLoader() {
const { name , appDir , appPaths , pagePath , pageExtensions , rootDir , tsconfigPath , isDev , } = this.getOptions() || {};
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.route = {
page: name.replace(/^app/, ""),
absolutePagePath: createAbsolutePath(appDir, pagePath)
};
const extensions = pageExtensions.map((extension)=>`.${extension}`);
const resolveOptions = {
..._webpackConfig.NODE_RESOLVE_OPTIONS,
extensions
};
const resolve = this.getResolve(resolveOptions);
const normalizedAppPaths = typeof appPaths === "string" ? [
appPaths
] : appPaths || [];
const resolveParallelSegments = (pathname)=>{
const matched = {};
for (const path of normalizedAppPaths){
if (path.startsWith(pathname + "/")) {
const rest = path.slice(pathname.length + 1).split("/");
let matchedSegment = rest[0];
// It is the actual page, mark it sepcially.
if (rest.length === 1 && matchedSegment === "page") {
matchedSegment = PAGE_SEGMENT;
}
const matchedKey = matchedSegment.startsWith("@") ? matchedSegment.slice(1) : "children";
matched[matchedKey] = matchedSegment;
}
}
return Object.entries(matched);
};
const resolver = async (pathname)=>{
try {
const resolved = await resolve(this.rootContext, pathname);
this.addDependency(resolved);
return resolved;
} catch (err) {
const absolutePath = createAbsolutePath(appDir, pathname);
for (const ext of extensions){
const absolutePathWithExtension = `${absolutePath}${ext}`;
this.addMissingDependency(absolutePathWithExtension);
}
if (err.message.includes("Can't resolve")) {
return undefined;
}
throw err;
}
};
const [treeCode, pages, rootLayout, globalError] = await createTreeCodeFromPath({
pagePath,
resolve: resolver,
resolveParallelSegments
});
if (!rootLayout) {
const errorMessage = `${_chalk.default.bold(pagePath.replace(`${_constants.APP_DIR_ALIAS}/`, ""))} doesn't have a root layout. To fix this error, make sure every page has a root layout.`;
if (!isDev) {
// If we're building and missing a root layout, exit the build
Log.error(errorMessage);
process.exit(1);
} else {
// In dev we'll try to create a root layout
const createdRootLayout = await (0, _verifyRootLayout).verifyRootLayout({
appDir: appDir,
dir: rootDir,
tsconfigPath: tsconfigPath,
pagePath,
pageExtensions
});
if (!createdRootLayout) {
throw new Error(errorMessage);
}
}
}
const result = `
export ${treeCode}
export const pages = ${JSON.stringify(pages)}
export { default as AppRouter } from 'next/dist/client/components/app-router'
export { default as LayoutRouter } from 'next/dist/client/components/layout-router'
export { default as RenderFromTemplateContext } from 'next/dist/client/components/render-from-template-context'
export { default as GlobalError } from ${JSON.stringify(globalError || "next/dist/client/components/error-boundary")}
export { staticGenerationAsyncStorage } from 'next/dist/client/components/static-generation-async-storage'
export { requestAsyncStorage } from 'next/dist/client/components/request-async-storage'
export * as serverHooks from 'next/dist/client/components/hooks-server-context'
export { renderToReadableStream } from 'next/dist/compiled/react-server-dom-webpack/server.browser'
export const __next_app_webpack_require__ = __webpack_require__
`;
return result;
};
var _default = nextAppLoader;
exports.default = _default;
//# sourceMappingURL=next-app-loader.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
export declare type ClientPagesLoaderOptions = {
absolutePagePath: string;
page: string;
};
declare function nextClientPagesLoader(this: any): any;
export default nextClientPagesLoader;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _stringifyRequest = require("../stringify-request");
// this parameter: https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters
function nextClientPagesLoader() {
const pagesLoaderSpan = this.currentTraceSpan.traceChild("next-client-pages-loader");
return pagesLoaderSpan.traceFn(()=>{
const { absolutePagePath , page } = this.getOptions();
pagesLoaderSpan.setAttribute("absolutePagePath", absolutePagePath);
const stringifiedPageRequest = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const stringifiedPage = JSON.stringify(page);
return `
(window.__NEXT_P = window.__NEXT_P || []).push([
${stringifiedPage},
function () {
return require(${stringifiedPageRequest});
}
]);
if(module.hot) {
module.hot.dispose(function () {
window.__NEXT_P.push([${stringifiedPage}])
});
}
`;
});
}
var _default = nextClientPagesLoader;
exports.default = _default;
//# sourceMappingURL=next-client-pages-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-client-pages-loader.ts"],"names":["nextClientPagesLoader","pagesLoaderSpan","currentTraceSpan","traceChild","traceFn","absolutePagePath","page","getOptions","setAttribute","stringifiedPageRequest","stringifyRequest","stringifiedPage","JSON","stringify"],"mappings":"AAAA;;;;;AAAiC,IAAA,iBAAsB,WAAtB,sBAAsB,CAAA;AAOvD,8FAA8F;AAC9F,SAASA,qBAAqB,GAAY;IACxC,MAAMC,eAAe,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CACtD,0BAA0B,CAC3B;IAED,OAAOF,eAAe,CAACG,OAAO,CAAC,IAAM;QACnC,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,IAAI,CAAA,EAAE,GAC9B,IAAI,CAACC,UAAU,EAAE,AAA4B;QAE/CN,eAAe,CAACO,YAAY,CAAC,kBAAkB,EAAEH,gBAAgB,CAAC;QAElE,MAAMI,sBAAsB,GAAGC,CAAAA,GAAAA,iBAAgB,AAAwB,CAAA,iBAAxB,CAAC,IAAI,EAAEL,gBAAgB,CAAC;QACvE,MAAMM,eAAe,GAAGC,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC;QAE5C,OAAO,CAAC;;MAEN,EAAEK,eAAe,CAAC;;uBAED,EAAEF,sBAAsB,CAAC;;;;;8BAKlB,EAAEE,eAAe,CAAC;;;EAG9C,CAAC,CAAA;KACA,CAAC,CAAA;CACH;eAEcX,qBAAqB"}

View File

@@ -0,0 +1,6 @@
export declare type EdgeFunctionLoaderOptions = {
absolutePagePath: string;
page: string;
rootDir: string;
};
export default function middlewareLoader(this: any): string;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = middlewareLoader;
var _getModuleBuildInfo = require("./get-module-build-info");
var _stringifyRequest = require("../stringify-request");
function middlewareLoader() {
const { absolutePagePath , page , rootDir } = this.getOptions();
const stringifiedPagePath = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextEdgeApiFunction = {
page: page || "/"
};
buildInfo.rootDir = rootDir;
return `
import { adapter, enhanceGlobals } from 'next/dist/esm/server/web/adapter'
enhanceGlobals()
var mod = require(${stringifiedPagePath})
var handler = mod.middleware || mod.default;
if (typeof handler !== 'function') {
throw new Error('The Edge Function "pages${page}" must export a \`default\` function');
}
export default function (opts) {
return adapter({
...opts,
page: ${JSON.stringify(page)},
handler,
})
}
`;
}
//# sourceMappingURL=next-edge-function-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-edge-function-loader.ts"],"names":["middlewareLoader","absolutePagePath","page","rootDir","getOptions","stringifiedPagePath","stringifyRequest","buildInfo","getModuleBuildInfo","_module","nextEdgeApiFunction","JSON","stringify"],"mappings":"AAAA;;;;kBASwBA,gBAAgB;AATL,IAAA,mBAAyB,WAAzB,yBAAyB,CAAA;AAC3B,IAAA,iBAAsB,WAAtB,sBAAsB,CAAA;AAQxC,SAASA,gBAAgB,GAAY;IAClD,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAE,GACvC,IAAI,CAACC,UAAU,EAAE;IACnB,MAAMC,mBAAmB,GAAGC,CAAAA,GAAAA,iBAAgB,AAAwB,CAAA,iBAAxB,CAAC,IAAI,EAAEL,gBAAgB,CAAC;IACpE,MAAMM,SAAS,GAAGC,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClDF,SAAS,CAACG,mBAAmB,GAAG;QAC9BR,IAAI,EAAEA,IAAI,IAAI,GAAG;KAClB;IACDK,SAAS,CAACJ,OAAO,GAAGA,OAAO;IAE3B,OAAO,CAAC;;;;;0BAKgB,EAAEE,mBAAmB,CAAC;;;;mDAIG,EAAEH,IAAI,CAAC;;;;;;oBAMtC,EAAES,IAAI,CAACC,SAAS,CAACV,IAAI,CAAC,CAAC;;;;IAIvC,CAAC,CAAA;CACJ"}

View File

@@ -0,0 +1,17 @@
export declare type EdgeSSRLoaderQuery = {
absolute500Path: string;
absoluteAppPath: string;
absoluteDocumentPath: string;
absoluteErrorPath: string;
absolutePagePath: string;
buildId: string;
dev: boolean;
isServerComponent: boolean;
page: string;
stringifiedConfig: string;
appDirLoader?: string;
pagesType: 'app' | 'pages' | 'root';
sriEnabled: boolean;
hasFontLoaders: boolean;
};
export default function edgeSSRLoader(this: any): Promise<string>;

View File

@@ -0,0 +1,102 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = edgeSSRLoader;
var _getModuleBuildInfo = require("../get-module-build-info");
var _stringifyRequest = require("../../stringify-request");
async function edgeSSRLoader() {
const { dev , page , buildId , absolutePagePath , absoluteAppPath , absoluteDocumentPath , absolute500Path , absoluteErrorPath , isServerComponent , stringifiedConfig , appDirLoader: appDirLoaderBase64 , pagesType , sriEnabled , hasFontLoaders , } = this.getOptions();
const appDirLoader = Buffer.from(appDirLoaderBase64 || "", "base64").toString();
const isAppDir = pagesType === "app";
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextEdgeSSR = {
isServerComponent: isServerComponent === "true",
page: page,
isAppDir
};
buildInfo.route = {
page,
absolutePagePath
};
const stringifiedPagePath = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const stringifiedAppPath = (0, _stringifyRequest).stringifyRequest(this, swapDistFolderWithEsmDistFolder(absoluteAppPath));
const stringifiedErrorPath = (0, _stringifyRequest).stringifyRequest(this, swapDistFolderWithEsmDistFolder(absoluteErrorPath));
const stringifiedDocumentPath = (0, _stringifyRequest).stringifyRequest(this, swapDistFolderWithEsmDistFolder(absoluteDocumentPath));
const stringified500Path = absolute500Path ? (0, _stringifyRequest).stringifyRequest(this, absolute500Path) : null;
const pageModPath = `${appDirLoader}${stringifiedPagePath.substring(1, stringifiedPagePath.length - 1)}${isAppDir ? "?__edge_ssr_entry__" : ""}`;
const transformed = `
import { adapter, enhanceGlobals } from 'next/dist/esm/server/web/adapter'
import { getRender } from 'next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render'
enhanceGlobals()
const pageType = ${JSON.stringify(pagesType)}
${isAppDir ? `
import { renderToHTMLOrFlight as appRenderToHTML } from 'next/dist/esm/server/app-render'
import * as pageMod from ${JSON.stringify(pageModPath)}
const Document = null
const pagesRenderToHTML = null
const appMod = null
const errorMod = null
const error500Mod = null
` : `
import Document from ${stringifiedDocumentPath}
import { renderToHTML as pagesRenderToHTML } from 'next/dist/esm/server/render'
import * as pageMod from ${stringifiedPagePath}
import * as appMod from ${stringifiedAppPath}
import * as errorMod from ${stringifiedErrorPath}
${stringified500Path ? `import * as error500Mod from ${stringified500Path}` : `const error500Mod = null`}
const appRenderToHTML = null
`}
const buildManifest = self.__BUILD_MANIFEST
const reactLoadableManifest = self.__REACT_LOADABLE_MANIFEST
const rscManifest = self.__RSC_MANIFEST
const rscCssManifest = self.__RSC_CSS_MANIFEST
const subresourceIntegrityManifest = ${sriEnabled ? "self.__SUBRESOURCE_INTEGRITY_MANIFEST" : "undefined"}
const fontLoaderManifest = ${hasFontLoaders ? "self.__FONT_LOADER_MANIFEST" : "undefined"}
const render = getRender({
pageType,
dev: ${dev},
page: ${JSON.stringify(page)},
appMod,
pageMod,
errorMod,
error500Mod,
Document,
buildManifest,
appRenderToHTML,
pagesRenderToHTML,
reactLoadableManifest,
serverComponentManifest: ${isServerComponent} ? rscManifest : null,
serverCSSManifest: ${isServerComponent} ? rscCssManifest : null,
subresourceIntegrityManifest,
config: ${stringifiedConfig},
buildId: ${JSON.stringify(buildId)},
fontLoaderManifest,
})
export const ComponentMod = pageMod
export default function(opts) {
return adapter({
...opts,
handler: render
})
}`;
return transformed;
}
/*
For pages SSR'd at the edge, we bundle them with the ESM version of Next in order to
benefit from the better tree-shaking and thus, smaller bundle sizes.
The absolute paths for _app, _error and _document, used in this loader, link to the regular CJS modules.
They are generated in `createPagesMapping` where we don't have access to `isEdgeRuntime`,
so we have to do it here. It's not that bad because it keeps all references to ESM modules magic in this place.
*/ function swapDistFolderWithEsmDistFolder(path) {
return path.replace("next/dist/pages", "next/dist/esm/pages");
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-edge-ssr-loader/index.ts"],"names":["edgeSSRLoader","dev","page","buildId","absolutePagePath","absoluteAppPath","absoluteDocumentPath","absolute500Path","absoluteErrorPath","isServerComponent","stringifiedConfig","appDirLoader","appDirLoaderBase64","pagesType","sriEnabled","hasFontLoaders","getOptions","Buffer","from","toString","isAppDir","buildInfo","getModuleBuildInfo","_module","nextEdgeSSR","route","stringifiedPagePath","stringifyRequest","stringifiedAppPath","swapDistFolderWithEsmDistFolder","stringifiedErrorPath","stringifiedDocumentPath","stringified500Path","pageModPath","substring","length","transformed","JSON","stringify","path","replace"],"mappings":"AAAA;;;;kBAgC8BA,aAAa;AAhCR,IAAA,mBAA0B,WAA1B,0BAA0B,CAAA;AAC5B,IAAA,iBAAyB,WAAzB,yBAAyB,CAAA;AA+B3C,eAAeA,aAAa,GAAY;IACrD,MAAM,EACJC,GAAG,CAAA,EACHC,IAAI,CAAA,EACJC,OAAO,CAAA,EACPC,gBAAgB,CAAA,EAChBC,eAAe,CAAA,EACfC,oBAAoB,CAAA,EACpBC,eAAe,CAAA,EACfC,iBAAiB,CAAA,EACjBC,iBAAiB,CAAA,EACjBC,iBAAiB,CAAA,EACjBC,YAAY,EAAEC,kBAAkB,CAAA,EAChCC,SAAS,CAAA,EACTC,UAAU,CAAA,EACVC,cAAc,CAAA,IACf,GAAG,IAAI,CAACC,UAAU,EAAE;IAErB,MAAML,YAAY,GAAGM,MAAM,CAACC,IAAI,CAC9BN,kBAAkB,IAAI,EAAE,EACxB,QAAQ,CACT,CAACO,QAAQ,EAAE;IACZ,MAAMC,QAAQ,GAAGP,SAAS,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O,QAAQ,GACJ,CAAC;;+BAEoB,EAAEiB,IAAI,CAACC,SAAS,CAACL,WAAW,CAAC,CAAC;;;;;;IAMzD,CAAC,GACK,CAAC;2BACgB,EAAEF,uBAAuB,CAAC;;+BAEtB,EAAEL,mBAAmB,CAAC;8BACvB,EAAEE,kBAAkB,CAAC;gCACnB,EAAEE,oBAAoB,CAAC;MACjD,EACEE,kBAAkB,GACd,CAAC,6BAA6B,EAAEA,kBAAkB,CAAC,CAAC,GACpD,CAAC,wBAAwB,CAAC,CAC/B;;IAEH,CAAC,CACA;;;;;;yCAMoC,EACnClB,UAAU,GAAG,uCAAuC,GAAG,WAAW,CACnE;+BAC0B,EACzBC,cAAc,GAAG,6BAA6B,GAAG,WAAW,CAC7D;;;;WAIM,EAAEd,GAAG,CAAC;YACL,EAAEoC,IAAI,CAACC,SAAS,CAACpC,IAAI,CAAC,CAAC;;;;;;;;;;+BAUJ,EAAEO,iBAAiB,CAAC;yBAC1B,EAAEA,iBAAiB,CAAC;;cAE/B,EAAEC,iBAAiB,CAAC;eACnB,EAAE2B,IAAI,CAACC,SAAS,CAACnC,OAAO,CAAC,CAAC;;;;;;;;;;;KAWpC,CAAC;IAEJ,OAAOiC,WAAW,CAAA;CACnB;AAhJD;;;;;;;EAOE,CACF,SAASP,+BAA+B,CAACU,IAAY,EAAE;IACrD,OAAOA,IAAI,CAACC,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAA;CAC9D"}

View File

@@ -0,0 +1,26 @@
import type { NextConfig } from '../../../../server/config-shared';
import type { DocumentType } from '../../../../shared/lib/utils';
import type { BuildManifest } from '../../../../server/get-page-files';
import type { ReactLoadableManifest } from '../../../../server/load-components';
import type { FontLoaderManifest } from '../../plugins/font-loader-manifest-plugin';
export declare function getRender({ dev, page, appMod, pageMod, errorMod, error500Mod, pagesType, Document, buildManifest, reactLoadableManifest, appRenderToHTML, pagesRenderToHTML, serverComponentManifest, subresourceIntegrityManifest, serverCSSManifest, config, buildId, fontLoaderManifest, }: {
pagesType: 'app' | 'pages' | 'root';
dev: boolean;
page: string;
appMod: any;
pageMod: any;
errorMod: any;
error500Mod: any;
appRenderToHTML: any;
pagesRenderToHTML: any;
Document: DocumentType;
buildManifest: BuildManifest;
reactLoadableManifest: ReactLoadableManifest;
subresourceIntegrityManifest?: Record<string, string>;
serverComponentManifest: any;
serverCSSManifest: any;
appServerMod: any;
config: NextConfig;
buildId: string;
fontLoaderManifest: FontLoaderManifest;
}): (request: Request) => Promise<Response>;

View File

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getRender = getRender;
var _webServer = _interopRequireDefault(require("../../../../server/web-server"));
var _web = require("../../../../server/base-http/web");
var _constants = require("../../../../lib/constants");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getRender({ dev , page , appMod , pageMod , errorMod , error500Mod , pagesType , Document , buildManifest , reactLoadableManifest , appRenderToHTML , pagesRenderToHTML , serverComponentManifest , subresourceIntegrityManifest , serverCSSManifest , config , buildId , fontLoaderManifest }) {
const isAppPath = pagesType === "app";
const baseLoadComponentResult = {
dev,
buildManifest,
reactLoadableManifest,
subresourceIntegrityManifest,
fontLoaderManifest,
Document,
App: appMod == null ? void 0 : appMod.default
};
const server = new _webServer.default({
dev,
conf: config,
minimalMode: true,
webServerConfig: {
page,
pagesType,
extendRenderOpts: {
buildId,
runtime: _constants.SERVER_RUNTIME.experimentalEdge,
supportsDynamicHTML: true,
disableOptimizedLoading: true,
serverComponentManifest,
serverCSSManifest
},
appRenderToHTML,
pagesRenderToHTML,
loadComponent: async (pathname)=>{
if (isAppPath) return null;
if (pathname === page) {
return {
...baseLoadComponentResult,
Component: pageMod.default,
pageConfig: pageMod.config || {},
getStaticProps: pageMod.getStaticProps,
getServerSideProps: pageMod.getServerSideProps,
getStaticPaths: pageMod.getStaticPaths,
ComponentMod: pageMod,
pathname
};
}
// If there is a custom 500 page, we need to handle it separately.
if (pathname === "/500" && error500Mod) {
return {
...baseLoadComponentResult,
Component: error500Mod.default,
pageConfig: error500Mod.config || {},
getStaticProps: error500Mod.getStaticProps,
getServerSideProps: error500Mod.getServerSideProps,
getStaticPaths: error500Mod.getStaticPaths,
ComponentMod: error500Mod,
pathname
};
}
if (pathname === "/_error") {
return {
...baseLoadComponentResult,
Component: errorMod.default,
pageConfig: errorMod.config || {},
getStaticProps: errorMod.getStaticProps,
getServerSideProps: errorMod.getServerSideProps,
getStaticPaths: errorMod.getStaticPaths,
ComponentMod: errorMod,
pathname
};
}
return null;
}
}
});
const requestHandler = server.getRequestHandler();
return async function render(request) {
const extendedReq = new _web.WebNextRequest(request);
const extendedRes = new _web.WebNextResponse();
requestHandler(extendedReq, extendedRes);
return await extendedRes.toResponse();
};
}
//# sourceMappingURL=render.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-edge-ssr-loader/render.ts"],"names":["getRender","dev","page","appMod","pageMod","errorMod","error500Mod","pagesType","Document","buildManifest","reactLoadableManifest","appRenderToHTML","pagesRenderToHTML","serverComponentManifest","subresourceIntegrityManifest","serverCSSManifest","config","buildId","fontLoaderManifest","isAppPath","baseLoadComponentResult","App","default","server","WebServer","conf","minimalMode","webServerConfig","extendRenderOpts","runtime","SERVER_RUNTIME","experimentalEdge","supportsDynamicHTML","disableOptimizedLoading","loadComponent","pathname","Component","pageConfig","getStaticProps","getServerSideProps","getStaticPaths","ComponentMod","requestHandler","getRequestHandler","render","request","extendedReq","WebNextRequest","extendedRes","WebNextResponse","toResponse"],"mappings":"AAAA;;;;QAcgBA,SAAS,GAATA,SAAS;AAPH,IAAA,UAA+B,kCAA/B,+BAA+B,EAAA;AAI9C,IAAA,IAAkC,WAAlC,kCAAkC,CAAA;AACV,IAAA,UAA2B,WAA3B,2BAA2B,CAAA;;;;;;AAEnD,SAASA,SAAS,CAAC,EACxBC,GAAG,CAAA,EACHC,IAAI,CAAA,EACJC,MAAM,CAAA,EACNC,OAAO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,OAAO,MAAMA,WAAW,CAACE,UAAU,EAAE,CAAA;KACtC,CAAA;CACF"}

View File

@@ -0,0 +1,8 @@
export declare type ClientComponentImports = string[];
export declare type CssImports = Record<string, string[]>;
export declare type NextFlightClientEntryLoaderOptions = {
modules: ClientComponentImports;
/** This is transmitted as a string to `getOptions` */
server: boolean | 'true' | 'false';
};
export default function transformSource(this: any): Promise<string>;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transformSource;
var _constants = require("../../../shared/lib/constants");
var _getModuleBuildInfo = require("./get-module-build-info");
var _utils = require("./utils");
async function transformSource() {
let { modules , server } = this.getOptions();
const isServer = server === "true";
if (!Array.isArray(modules)) {
modules = modules ? [
modules
] : [];
}
const requests = modules;
const code = requests// Filter out css files on the server
.filter((request)=>isServer ? !_utils.regexCSS.test(request) : true).map((request)=>_utils.regexCSS.test(request) ? `(() => import(/* webpackMode: "lazy" */ ${JSON.stringify(request)}))` : `import(/* webpackMode: "eager" */ ${JSON.stringify(request)})`).join(";\n");
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
const resolve = this.getResolve();
// Resolve to absolute resource url for flight manifest to collect and use to determine client components
const resolvedRequests = await Promise.all(requests.map(async (r)=>await resolve(this.rootContext, r)));
buildInfo.rsc = {
type: _constants.RSC_MODULE_TYPES.client,
requests: resolvedRequests
};
return code;
}
//# sourceMappingURL=next-flight-client-entry-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-flight-client-entry-loader.ts"],"names":["transformSource","modules","server","getOptions","isServer","Array","isArray","requests","code","filter","request","regexCSS","test","map","JSON","stringify","join","buildInfo","getModuleBuildInfo","_module","resolve","getResolve","resolvedRequests","Promise","all","r","rootContext","rsc","type","RSC_MODULE_TYPES","client"],"mappings":"AAAA;;;;kBAa8BA,eAAe;AAbZ,IAAA,UAA+B,WAA/B,+BAA+B,CAAA;AAC7B,IAAA,mBAAyB,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B,iBAAA,CAACC,MAAM;QAC7BvB,QAAQ,EAAEe,gBAAgB;KAC3B;IAED,OAAOd,IAAI,CAAA;CACZ"}

View File

@@ -0,0 +1,8 @@
/**
* For server-side CSS imports, we need to ignore the actual module content but
* still trigger the hot-reloading diff mechanism. So here we put the content
* inside a comment.
*/
export declare function pitch(this: any): void;
declare const NextServerCSSLoader: (this: any, content: string) => string;
export default NextServerCSSLoader;

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pitch = pitch;
exports.default = void 0;
var _crypto = _interopRequireDefault(require("crypto"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function pitch() {
if (process.env.NODE_ENV !== "production") {
const content = this.fs.readFileSync(this.resourcePath);
this.data.__checksum = _crypto.default.createHash("sha256").update(typeof content === "string" ? Buffer.from(content) : content).digest().toString("hex");
}
}
const NextServerCSSLoader = function(content) {
this.cacheable && this.cacheable();
// Only add the checksum during development.
if (process.env.NODE_ENV !== "production") {
const isCSSModule = this.resourcePath.match(/\.module\.(css|sass|scss)$/);
const checksum = _crypto.default.createHash("sha256").update(this.data.__checksum + (typeof content === "string" ? Buffer.from(content) : content)).digest().toString("hex").substring(0, 12);
if (isCSSModule) {
return content + "\nmodule.exports.__checksum = " + JSON.stringify(checksum);
}
return `export default ${JSON.stringify(checksum)}`;
}
return content;
};
var _default = NextServerCSSLoader;
exports.default = _default;
//# sourceMappingURL=next-flight-css-dev-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-flight-css-dev-loader.ts"],"names":["pitch","process","env","NODE_ENV","content","fs","readFileSync","resourcePath","data","__checksum","crypto","createHash","update","Buffer","from","digest","toString","NextServerCSSLoader","cacheable","isCSSModule","match","checksum","substring","JSON","stringify"],"mappings":"AAMA;;;;QAEgBA,KAAK,GAALA,KAAK;;AAFF,IAAA,OAAQ,kCAAR,QAAQ,EAAA;;;;;;AAEpB,SAAS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BAAmB"}

View File

@@ -0,0 +1 @@
export default function transformSource(this: any, source: string, sourceMap: any): Promise<any>;

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transformSource;
var _constants = require("../../../../shared/lib/constants");
var _warnOnce = require("../../../../shared/lib/utils/warn-once");
var _getPageStaticInfo = require("../../../analysis/get-page-static-info");
var _getModuleBuildInfo = require("../get-module-build-info");
async function transformSource(source, sourceMap) {
var ref;
// Avoid buffer to be consumed
if (typeof source !== "string") {
throw new Error("Expected source to have been transformed to a string.");
}
const callback = this.async();
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
const rscType = (0, _getPageStaticInfo).getRSCModuleType(source);
// Assign the RSC meta information to buildInfo.
// Exclude next internal files which are not marked as client files
buildInfo.rsc = {
type: rscType
};
if (((ref = buildInfo.rsc) == null ? void 0 : ref.type) === _constants.RSC_MODULE_TYPES.client) {
return callback(null, source, sourceMap);
}
if (noopHeadPath === this.resourcePath) {
(0, _warnOnce).warnOnce(`Warning: You're using \`next/head\` inside app directory, please migrate to \`head.js\`. Checkout https://beta.nextjs.org/docs/api-reference/file-conventions/head for details.`);
}
return callback(null, source, sourceMap);
}
const noopHeadPath = require.resolve("next/dist/client/components/noop-head");
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-flight-loader/index.ts"],"names":["transformSource","source","sourceMap","buildInfo","Error","callback","async","getModuleBuildInfo","_module","rscType","getRSCModuleType","rsc","type","RSC_MODULE_TYPES","client","noopHeadPath","resourcePath","warnOnce","require","resolve"],"mappings":"AAAA;;;;kBAO8BA,eAAe;AAPZ,IAAA,UAAkC,WAAlC,kCAAkC,CAAA;AAC1C,IAAA,SAAwC,WAAxC,wCAAwC,CAAA;AAChC,IAAA,kBAAwC,WAAxC,wCAAwC,CAAA;AACtC,IAAA,mBAA0B,WAA1B,0BAA0B,CAAA;AAI9C,eAAeA,eAAe,CAE3CC,MAAc,EACdC,SAAc,EACd;QAcIC,GAAa;IAbjB,8BAA8B;IAC9B,IAAI,OAAOF,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAIG,KAAK,CAAC,uDAAuD,CAAC,CAAA;KACzE;IAED,MAAMC,QAAQ,GAAG,IAAI,CAACC,KAAK,EAAE;IAC7B,MAAMH,SAAS,GAAGI,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClD,MAAMC,OAAO,GAAGC,CAAAA,GAAAA,kBAAgB,AAAQ,CAAA,iBAAR,CAACT,MAAM,CAAC;IAExC,gDAAgD;IAChD,mEAAmE;IACnEE,SAAS,CAACQ,GAAG,GAAG;QAAEC,IAAI,EAAEH,OAAO;KAAE;IAEjC,IAAIN,CAAAA,CAAAA,GAAa,GAAbA,SAAS,CAACQ,GAAG,SAAM,GAAnBR,KAAAA,CAAmB,GAAnBA,GAAa,CAAES,IAAI,CAAA,KAAKC,UAAgB,iBAAA,CAACC,MAAM,EAAE;QACnD,OAAOT,QAAQ,CAAC,IAAI,EAAEJ,MAAM,EAAEC,SAAS,CAAC,CAAA;KACzC;IAED,IAAIa,YAAY,KAAK,IAAI,CAACC,YAAY,EAAE;QACtCC,CAAAA,GAAAA,SAAQ,AAEP,CAAA,SAFO,CACN,CAAC,+KAA+K,CAAC,CAClL;KACF;IACD,OAAOZ,QAAQ,CAAC,IAAI,EAAEJ,MAAM,EAAEC,SAAS,CAAC,CAAA;CACzC;AA9BD,MAAMa,YAAY,GAAGG,OAAO,CAACC,OAAO,CAAC,uCAAuC,CAAC"}

View File

@@ -0,0 +1,7 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare function createProxy(moduleId: string): object;

View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createProxy = createProxy;
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/ // Modified from https://github.com/facebook/react/blob/main/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js
const MODULE_REFERENCE = Symbol.for("react.module.reference");
const PROMISE_PROTOTYPE = Promise.prototype;
const proxyHandlers = {
get: function(target, name, _receiver) {
switch(name){
// These names are read by the Flight runtime if you end up using the exports object.
case "$$typeof":
// These names are a little too common. We should probably have a way to
// have the Flight runtime extract the inner target instead.
return target.$$typeof;
case "filepath":
return target.filepath;
case "name":
return target.name;
case "async":
return target.async;
// We need to special case this because createElement reads it if we pass this
// reference.
case "defaultProps":
return undefined;
case "__esModule":
// Something is conditionally checking which export to use. We'll pretend to be
// an ESM compat module but then we'll check again on the client.
target.default = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
// This a placeholder value that tells the client to conditionally use the
// whole object or just the default export.
name: "",
async: target.async
};
return true;
case "then":
if (!target.async) {
// If this module is expected to return a Promise (such as an AsyncModule) then
// we should resolve that with a client reference that unwraps the Promise on
// the client.
const then = function then(resolve, _reject) {
const moduleReference = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
name: "*",
async: true
};
return Promise.resolve(resolve(new Proxy(moduleReference, proxyHandlers)));
};
// If this is not used as a Promise but is treated as a reference to a `.then`
// export then we should treat it as a reference to that name.
then.$$typeof = MODULE_REFERENCE;
then.filepath = target.filepath;
// then.name is conveniently already "then" which is the export name we need.
// This will break if it's minified though.
return then;
}
break;
default:
break;
}
let cachedReference = target[name];
if (!cachedReference) {
cachedReference = target[name] = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
name: name,
async: target.async
};
}
return cachedReference;
},
getPrototypeOf (_target) {
// Pretend to be a Promise in case anyone asks.
return PROMISE_PROTOTYPE;
},
set: function() {
throw new Error("Cannot assign to a client module from a server module.");
}
};
function createProxy(moduleId) {
const moduleReference = {
$$typeof: MODULE_REFERENCE,
filepath: moduleId,
name: "*",
async: false
};
return new Proxy(moduleReference, proxyHandlers);
}
//# sourceMappingURL=module-proxy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-flight-loader/module-proxy.ts"],"names":["createProxy","MODULE_REFERENCE","Symbol","for","PROMISE_PROTOTYPE","Promise","prototype","proxyHandlers","get","target","name","_receiver","$$typeof","filepath","async","undefined","default","then","resolve","_reject","moduleReference","Proxy","cachedReference","getPrototypeOf","_target","set","Error","moduleId"],"mappings":"AASA;;;;QAoFgBA,WAAW,GAAXA,WAAW;AA7F3B;;;;;GAKG,CAEH,oIAAoI;AAEpI,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC;AAC7D,MAAMC,iBAAiB,GAAGC,OAAO,CAACC,SAAS;AAE3C,MAAMC,aAAa,GAAyB;IAC1CC,GAAG,EAAE,SAAUC,MAAW,EAAEC,IAAY,EAAEC,SAAc,EAAE;QACxD,OAAQD,IAAI;YACV,qFAAqF;YACrF,KAAK,UAAU;gBACb,wEAAwE;gBACxE,4DAA4D;gBAC5D,OAAOD,MAAM,CAACG,QAAQ,CAAA;YACxB,KAAK,UAAU;gBACb,OAAOH,MAAM,CAACI,QAAQ,CAAA;YACxB,KAAK,MAAM;gBACT,OAAOJ,MAAM,CAACC,IAAI,CAAA;YACpB,KAAK,OAAO;gBACV,OAAOD,MAAM,CAACK,KAAK,CAAA;YACrB,8EAA8E;YAC9E,aAAa;YACb,KAAK,cAAc;gBACjB,OAAOC,SAAS,CAAA;YAClB,KAAK,YAAY;gBACf,+EAA+E;gBAC/E,iEAAiE;gBACjEN,MAAM,CAACO,OAAO,GAAG;oBACfJ,QAAQ,EAAEX,gBAAgB;oBAC1BY,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;oBACzB,0EAA0E;oBAC1E,2CAA2C;oBAC3CH,IAAI,EAAE,EAAE;oBACRI,KAAK,EAAEL,MAAM,CAACK,KAAK;iBACpB;gBACD,OAA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,EAAE;IAC5C,MAAMP,eAAe,GAAG;QACtBR,QAAQ,EAAEX,gBAAgB;QAC1BY,QAAQ,EAAEc,QAAQ;QAClBjB,IAAI,EAAE,GAAG;QACTI,KAAK,EAAE,KAAK;KACb;IACD,OAAO,IAAIO,KAAK,CAACD,eAAe,EAAEb,aAAa,CAAC,CAAA;CACjD"}

View File

@@ -0,0 +1 @@
export default function nextFontLoader(this: any): Promise<any>;

View File

@@ -0,0 +1,101 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nextFontLoader;
var _fs = require("fs");
var _path = _interopRequireDefault(require("path"));
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _loaderUtils3 = _interopRequireDefault(require("next/dist/compiled/loader-utils3"));
var _postcssNextFont = _interopRequireDefault(require("./postcss-next-font"));
var _util = require("util");
var _constants = require("../../../../shared/lib/constants");
async function nextFontLoader() {
const fontLoaderSpan = this.currentTraceSpan.traceChild("next-font-loader");
return fontLoaderSpan.traceAsyncFn(async ()=>{
const callback = this.async();
// next-swc next_font_loaders turns each font loader call into JSON
const { path: relativeFilePathFromRoot , import: functionName , arguments: data , variableName , } = JSON.parse(this.resourceQuery.slice(1));
// Throw error if @next/font is used in _document.js
if (/pages[\\/]_document\./.test(relativeFilePathFromRoot)) {
const err = new Error(`${_chalk.default.bold("Cannot")} be used within ${_chalk.default.cyan("pages/_document.js")}.`);
err.name = "NextFontError";
callback(err);
return;
}
const { isDev , isServer , assetPrefix , fontLoaderOptions , postcss: getPostcss , } = this.getOptions();
const nextConfigPaths = _constants.CONFIG_FILES.map((config)=>_path.default.join(this.rootContext, config));
// Add next.config.js as a dependency, loaders must rerun in case options changed
await Promise.all(nextConfigPaths.map(async (configPath)=>{
const hasConfig = await _fs.promises.access(configPath).then(()=>true, ()=>false);
if (hasConfig) {
this.addDependency(configPath);
} else {
this.addMissingDependency(configPath);
}
}));
const emitFontFile = (content, ext, preload)=>{
const opts = {
context: this.rootContext,
content
};
const interpolatedName = _loaderUtils3.default.interpolateName(this, // Font files ending with .p.(woff|woff2|eot|ttf|otf) are preloaded
`static/media/[hash]${preload ? ".p" : ""}.${ext}`, opts);
const outputPath = `${assetPrefix}/_next/${interpolatedName}`;
if (!isServer) {
this.emitFile(interpolatedName, content, null);
}
return outputPath;
};
try {
const fontLoader = require(_path.default.join(this.resourcePath, "../loader.js")).default;
let { css , fallbackFonts , adjustFontFallback , weight , style , variable } = await fontLoader({
functionName,
variableName,
data,
config: fontLoaderOptions,
emitFontFile,
resolve: (src)=>(0, _util).promisify(this.resolve)(_path.default.dirname(_path.default.join(this.rootContext, relativeFilePathFromRoot)), src.startsWith(".") ? src : `./${src}`),
isDev,
isServer,
loaderContext: this
});
const { postcss } = await getPostcss();
// Exports will be exported as is from css-loader instead of a CSS module export
const exports = [];
const fontFamilyHash = _loaderUtils3.default.getHashDigest(Buffer.from(css), "md5", "hex", 6);
// Add CSS classes, exports and make the font-family localy scoped by turning it unguessable
const result = await postcss((0, _postcssNextFont).default({
exports,
fontFamilyHash,
fallbackFonts,
weight,
style,
adjustFontFallback,
variable
})).process(css, {
from: undefined
});
// Reuse ast in css-loader
const ast = {
type: "postcss",
version: result.processor.version,
root: result.root
};
callback(null, result.css, null, {
exports,
ast,
fontFamilyHash
});
} catch (err) {
callback(err);
}
});
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-font-loader/index.ts"],"names":["nextFontLoader","fontLoaderSpan","currentTraceSpan","traceChild","traceAsyncFn","callback","async","path","relativeFilePathFromRoot","import","functionName","arguments","data","variableName","JSON","parse","resourceQuery","slice","test","err","Error","chalk","bold","cyan","name","isDev","isServer","assetPrefix","fontLoaderOptions","postcss","getPostcss","getOptions","nextConfigPaths","CONFIG_FILES","map","config","join","rootContext","Promise","all","configPath","hasConfig","fs","access","then","addDependency","addMissingDependency","emitFontFile","content","ext","preload","opts","context","interpolatedName","loaderUtils","interpolateName","outputPath","emitFile","fontLoader","require","resourcePath","default","css","fallbackFonts","adjustFontFallback","weight","style","variable","resolve","src","promisify","dirname","startsWith","loaderContext","exports","fontFamilyHash","getHashDigest","Buffer","from","result","postcssNextFontPlugin","process","undefined","ast","type","version","processor","root"],"mappings":"AAAA;;;;kBAU8BA,cAAc;AARb,IAAA,GAAI,WAAJ,IAAI,CAAA;AAClB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACL,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AACpB,IAAA,aAAkC,kCAAlC,kCAAkC,EAAA;AACxB,IAAA,gBAAqB,kCAArB,qBAAqB,EAAA;AAC7B,IAAA,KAAM,WAAN,MAAM,CAAA;AACH,IAAA,UAAkC,WAAlC,kCAAkC,CAAA;AAEhD,eAAeA,cAAc,GAAY;IACtD,MAAMC,cAAc,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CAAC,kBAAkB,CAAC;IAC3E,OAAOF,cAAc,CAACG,YAAY,CAAC,UAAY;QAC7C,MAAMC,QAAQ,GAAG,IAAI,CAACC,KAAK,EAAE;QAE7B,mEAAmE;QACnE,MAAM,EACJC,IAAI,EAAEC,wBAAwB,CAAA,EAC9BC,MAAM,EAAEC,YAAY,CAAA,EACpBC,SAAS,EAAEC,IAAI,CAAA,EACfC,YAAY,CAAA,IACb,GAAGC,IAAI,CAACC,KAAK,CAAC,IAAI,CAACC,aAAa,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE3C,oDAAoD;QACpD,IAAI,wBAAwBC,IAAI,CAACV,wBAAwB,CAAC,EAAE;YAC1D,MAAMW,GAAG,GAAG,IAAIC,KAAK,CACnB,CAAC,EAAEC,MAAK,QAAA,CAACC,IAAI,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAED,MAAK,QAAA,CAACE,IAAI,CAClD,oBAAoB,CACrB,CAAC,CAAC,CAAC,CACL;YACDJ,GAAG,CAACK,IAAI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CAAC;gBACpBN,OAAO;gBACPC,cAAc;gBACdZ,aAAa;gBACbE,MAAM;gBACNC,KAAK;gBACLF,kBAAkB;gBAClBG,QAAQ;aACT,CAAC,CACH,CAACc,OAAO,CAACnB,GAAG,EAAE;gBACbgB,IAAI,EAAEI,SAAS;aAChB,CAAC;YAEF,0BAA0B;YAC1B,MAAMC,GAAG,GAAG;gBACVC,IAAI,EAAE,SAAS;gBACfC,OAAO,EAAEN,MAAM,CAACO,SAAS,CAACD,OAAO;gBACjCE,IAAI,EAAER,MAAM,CAACQ,IAAI;aAClB;YACDlF,QAAQ,CAAC,IAAI,EAAE0E,MAAM,CAACjB,GAAG,EAAE,IAAI,EAAE;gBAC/BY,OAAO;gBACPS,GAAG;gBACHR,cAAc;aACf,CAAC;SACH,CAAC,OAAOxD,GAAG,EAAO;YACjBd,QAAQ,CAACc,GAAG,CAAC;SACd;KACF,CAAC,CAAA;CACH"}

View File

@@ -0,0 +1,20 @@
import type { AdjustFontFallback } from '../../../../font';
declare const postcssNextFontPlugin: {
({ exports, fontFamilyHash, fallbackFonts, adjustFontFallback, variable, weight, style, }: {
exports: {
name: any;
value: any;
}[];
fontFamilyHash: string;
fallbackFonts?: string[] | undefined;
adjustFontFallback?: AdjustFontFallback | undefined;
variable?: string | undefined;
weight?: string | undefined;
style?: string | undefined;
}): {
postcssPlugin: string;
Once(root: any): void;
};
postcss: boolean;
};
export default postcssNextFontPlugin;

View File

@@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcss = _interopRequireDefault(require("postcss"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const postcssNextFontPlugin = ({ exports , fontFamilyHash , fallbackFonts =[] , adjustFontFallback , variable , weight , style })=>{
return {
postcssPlugin: "postcss-next-font",
Once (root) {
let fontFamily;
const normalizeFamily = (family)=>{
return family.replace(/['"]/g, "");
};
const formatFamily = (family)=>{
// Turn the font family unguessable to make it localy scoped
return `'__${family.replace(/ /g, "_")}_${fontFamilyHash}'`;
};
// Hash font-family names
for (const node of root.nodes){
if (node.type === "atrule" && node.name === "font-face") {
const familyNode = node.nodes.find((decl)=>decl.prop === "font-family");
if (!familyNode) {
continue;
}
if (!fontFamily) {
fontFamily = normalizeFamily(familyNode.value);
}
familyNode.value = formatFamily(fontFamily);
}
}
if (!fontFamily) {
throw new Error("Font loaders must return one or more @font-face's");
}
// Add fallback font with override values
let adjustFontFallbackFamily;
if (adjustFontFallback) {
adjustFontFallbackFamily = formatFamily(`${fontFamily} Fallback`);
const fallbackFontFace = _postcss.default.atRule({
name: "font-face"
});
const { fallbackFont , ascentOverride , descentOverride , lineGapOverride , sizeAdjust , } = adjustFontFallback;
fallbackFontFace.nodes = [
new _postcss.default.Declaration({
prop: "font-family",
value: adjustFontFallbackFamily
}),
new _postcss.default.Declaration({
prop: "src",
value: `local("${fallbackFont}")`
}),
...ascentOverride ? [
new _postcss.default.Declaration({
prop: "ascent-override",
value: ascentOverride
}),
] : [],
...descentOverride ? [
new _postcss.default.Declaration({
prop: "descent-override",
value: descentOverride
}),
] : [],
...lineGapOverride ? [
new _postcss.default.Declaration({
prop: "line-gap-override",
value: lineGapOverride
}),
] : [],
...sizeAdjust ? [
new _postcss.default.Declaration({
prop: "size-adjust",
value: sizeAdjust
}),
] : [],
];
root.nodes.push(fallbackFontFace);
}
// Variable fonts can define ranges of values
const isRange = (value)=>value.trim().includes(" ");
const formattedFontFamilies = [
formatFamily(fontFamily),
...adjustFontFallbackFamily ? [
adjustFontFallbackFamily
] : [],
...fallbackFonts,
].join(", ");
// Add class with family, weight and style
const classRule = new _postcss.default.Rule({
selector: ".className"
});
classRule.nodes = [
new _postcss.default.Declaration({
prop: "font-family",
value: formattedFontFamilies
}),
...weight && !isRange(weight) ? [
new _postcss.default.Declaration({
prop: "font-weight",
value: weight
}),
] : [],
...style && !isRange(style) ? [
new _postcss.default.Declaration({
prop: "font-style",
value: style
}),
] : [],
];
root.nodes.push(classRule);
// Add class that defines a variable with the font family
if (variable) {
const varialbeRule = new _postcss.default.Rule({
selector: ".variable"
});
varialbeRule.nodes = [
new _postcss.default.Declaration({
prop: variable,
value: formattedFontFamilies
}),
];
root.nodes.push(varialbeRule);
}
// Export @font-face values as is
exports.push({
name: "style",
value: {
fontFamily: formattedFontFamilies,
fontWeight: !Number.isNaN(Number(weight)) ? Number(weight) : undefined,
fontStyle: style && !isRange(style) ? style : undefined
}
});
}
};
};
postcssNextFontPlugin.postcss = true;
var _default = postcssNextFontPlugin;
exports.default = _default;
//# sourceMappingURL=postcss-next-font.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-font-loader/postcss-next-font.ts"],"names":["postcssNextFontPlugin","exports","fontFamilyHash","fallbackFonts","adjustFontFallback","variable","weight","style","postcssPlugin","Once","root","fontFamily","normalizeFamily","family","replace","formatFamily","node","nodes","type","name","familyNode","find","decl","prop","value","Error","adjustFontFallbackFamily","fallbackFontFace","postcss","atRule","fallbackFont","ascentOverride","descentOverride","lineGapOverride","sizeAdjust","Declaration","push","isRange","trim","includes","formattedFontFamilies","join","classRule","Rule","selector","varialbeRule","fontWeight","Number","isNaN","undefined","fontStyle"],"mappings":"AAAA;;;;;AACqC,IAAA,QAAS,kCAAT,SAAS,EAAA;;;;;;AAE9C,MAAMA,qBAAqB,GAAG,CAAC,EAC7BC,OAAO,CAAA,EACPC,cAAc,CAAA,EACdC,aAAa,EAAG,EAAE,CAAA,EAClBC,kBAAkB,CAAA,EAClBC,QAAQ,CAAA,EACRC,MAAM,CAAA,EACNC,KAAK,CAAA,EASN,GAAK;IACJ,OAAO;QACLC,aAAa,EAAE,mBAAmB;QAClCC,IAAI,EAACC,IAAS,EAAE;YACd,IAAIC,UAAU,AAAoB;YAElC,MAAMC,eAAe,GAAG,CAACC,MAAc,GAAK;gBAC1C,OAAOA,MAAM,CAACC,OAAO,UAAU,EAAE,CAAC,CAAA;aACnC;YAED,MAAMC,YAA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,CAACzC,MAAM,CAAC,GACd2C,SAAS;oBACbC,SAAS,EAAE3C,KAAK,IAAI,CAAC8B,OAAO,CAAC9B,KAAK,CAAC,GAAGA,KAAK,GAAG0C,SAAS;iBACxD;aACF,CAAC;SACH;KACF,CAAA;CACF;AAEDjD,qBAAqB,CAAC4B,OAAO,GAAG,IAAI;eAErB5B,qBAAqB"}

View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
declare function nextImageLoader(this: any, content: Buffer): any;
export declare const raw = true;
export default nextImageLoader;

View File

@@ -0,0 +1,105 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.raw = void 0;
var _isAnimated = _interopRequireDefault(require("next/dist/compiled/is-animated"));
var _loaderUtils3 = _interopRequireDefault(require("next/dist/compiled/loader-utils3"));
var _imageOptimizer = require("../../../server/image-optimizer");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const BLUR_IMG_SIZE = 8;
const BLUR_QUALITY = 70;
const VALID_BLUR_EXT = [
"jpeg",
"png",
"webp",
"avif"
] // should match next/client/image.tsx
;
function nextImageLoader(content) {
const imageLoaderSpan = this.currentTraceSpan.traceChild("next-image-loader");
return imageLoaderSpan.traceAsyncFn(async ()=>{
const options = this.getOptions();
const { isServer , isDev , assetPrefix , basePath } = options;
const context = this.rootContext;
const opts = {
context,
content
};
const interpolatedName = _loaderUtils3.default.interpolateName(this, "/static/media/[name].[hash:8].[ext]", opts);
const outputPath = assetPrefix + "/_next" + interpolatedName;
let extension = _loaderUtils3.default.interpolateName(this, "[ext]", opts);
if (extension === "jpg") {
extension = "jpeg";
}
const imageSizeSpan = imageLoaderSpan.traceChild("image-size-calculation");
const imageSize = await imageSizeSpan.traceAsyncFn(()=>(0, _imageOptimizer).getImageSize(content, extension).catch((err)=>err));
if (imageSize instanceof Error) {
const err = imageSize;
err.name = "InvalidImageFormatError";
throw err;
}
let blurDataURL;
let blurWidth;
let blurHeight;
if (VALID_BLUR_EXT.includes(extension)) {
// Shrink the image's largest dimension
if (imageSize.width >= imageSize.height) {
blurWidth = BLUR_IMG_SIZE;
blurHeight = Math.max(Math.round(imageSize.height / imageSize.width * BLUR_IMG_SIZE), 1);
} else {
blurWidth = Math.max(Math.round(imageSize.width / imageSize.height * BLUR_IMG_SIZE), 1);
blurHeight = BLUR_IMG_SIZE;
}
if (isDev) {
// During `next dev`, we don't want to generate blur placeholders with webpack
// because it can delay starting the dev server. Instead, we inline a
// special url to lazily generate the blur placeholder at request time.
const prefix = "http://localhost";
const url = new URL(`${basePath || ""}/_next/image`, prefix);
url.searchParams.set("url", outputPath);
url.searchParams.set("w", String(blurWidth));
url.searchParams.set("q", String(BLUR_QUALITY));
blurDataURL = url.href.slice(prefix.length);
} else {
const resizeImageSpan = imageLoaderSpan.traceChild("image-resize");
const resizedImage = await resizeImageSpan.traceAsyncFn(()=>{
if ((0, _isAnimated).default(content)) {
return content;
}
return (0, _imageOptimizer).optimizeImage({
buffer: content,
width: blurWidth,
height: blurHeight,
contentType: `image/${extension}`,
quality: BLUR_QUALITY
});
});
const blurDataURLSpan = imageLoaderSpan.traceChild("image-base64-tostring");
blurDataURL = blurDataURLSpan.traceFn(()=>`data:image/${extension};base64,${resizedImage.toString("base64")}`);
}
}
const stringifiedData = imageLoaderSpan.traceChild("image-data-stringify").traceFn(()=>JSON.stringify({
src: outputPath,
height: imageSize.height,
width: imageSize.width,
blurDataURL,
blurWidth,
blurHeight
}));
if (isServer) {
this.emitFile(`../${isDev ? "" : "../"}${interpolatedName}`, content, null);
}
return `export default ${stringifiedData};`;
});
}
const raw = true;
exports.raw = raw;
var _default = nextImageLoader;
exports.default = _default;
//# sourceMappingURL=next-image-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-image-loader.ts"],"names":["BLUR_IMG_SIZE","BLUR_QUALITY","VALID_BLUR_EXT","nextImageLoader","content","imageLoaderSpan","currentTraceSpan","traceChild","traceAsyncFn","options","getOptions","isServer","isDev","assetPrefix","basePath","context","rootContext","opts","interpolatedName","loaderUtils","interpolateName","outputPath","extension","imageSizeSpan","imageSize","getImageSize","catch","err","Error","name","blurDataURL","blurWidth","blurHeight","includes","width","height","Math","max","round","prefix","url","URL","searchParams","set","String","href","slice","length","resizeImageSpan","resizedImage","isAnimated","optimizeImage","buffer","contentType","quality","blurDataURLSpan","traceFn","toString","stringifiedData","JSON","stringify","src","emitFile","raw"],"mappings":"AAAA;;;;;AAAuB,IAAA,WAAgC,kCAAhC,gCAAgC,EAAA;AAC/B,IAAA,aAAkC,kCAAlC,kCAAkC,EAAA;AACd,IAAA,eAAiC,WAAjC,iCAAiC,CAAA;;;;;;AAE7E,MAAMA,aAAa,GAAG,CAAC;AACvB,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,cAAc,GAAG;IAAC,MAAM;IAAE,KAAK;IAAE,MAAM;IAAE,MAAM;CAAC,CAAC,qCAAqC;AAAtC;AAStD,SAASC,eAAe,CAAYC,OAAe,EAAE;IACnD,MAAMC,eAAe,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CAAC,mBAAmB,CAAC;IAC7E,OAAOF,eAAe,CAACG,YAAY,CAAC,UAAY;QAC9C,MAAMC,OAAO,GAAY,IAAI,CAACC,UAAU,EAAE;QAC1C,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGL,OAAO;QAC1D,MAAMM,OAAO,GAAG,IAAI,CAACC,WAAW;QAChC,MAAMC,IAAI,GAAG;YAAEF,OAAO;YAAEX,OAAO;SAAE;QACjC,MAAMc,gBAAgB,GAAGC,aAAW,QAAA,CAACC,eAAe,CAClD,IAAI,EACJ,qCAAqC,EACrCH,IAAI,CACL;QACD,MAAMI,UAAU,GAAGR,WAAW,GAAG,QAAQ,GAAGK,gBAAgB;QAC5D,IAAII,SAAS,GAAGH,aAAW,QAAA,CAACC,eAAe,CAAC,IAAI,EA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E,UAAU,CAAC,sBAAsB,CAAC,CAClCiD,OAAO,CAAC,IACPG,IAAI,CAACC,SAAS,CAAC;gBACbC,GAAG,EAAExC,UAAU;gBACfc,MAAM,EAAEX,SAAS,CAACW,MAAM;gBACxBD,KAAK,EAAEV,SAAS,CAACU,KAAK;gBACtBJ,WAAW;gBACXC,SAAS;gBACTC,UAAU;aACX,CAAC,CACH;QAEH,IAAIrB,QAAQ,EAAE;YACZ,IAAI,CAACmD,QAAQ,CACX,CAAC,GAAG,EAAElD,KAAK,GAAG,EAAE,GAAG,KAAK,CAAC,EAAEM,gBAAgB,CAAC,CAAC,EAC7Cd,OAAO,EACP,IAAI,CACL;SACF;QAED,OAAO,CAAC,eAAe,EAAEsD,eAAe,CAAC,CAAC,CAAC,CAAA;KAC5C,CAAC,CAAA;CACH;AACM,MAAMK,GAAG,GAAG,IAAI;QAAVA,GAAG,GAAHA,GAAG;eACD5D,eAAe"}

View File

@@ -0,0 +1,3 @@
/// <reference types="node" />
export default function MiddlewareAssetLoader(this: any, source: Buffer): string;
export declare const raw = true;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = MiddlewareAssetLoader;
exports.raw = void 0;
var _loaderUtils3 = _interopRequireDefault(require("next/dist/compiled/loader-utils3"));
var _getModuleBuildInfo = require("./get-module-build-info");
function MiddlewareAssetLoader(source) {
const name = _loaderUtils3.default.interpolateName(this, "[name].[hash].[ext]", {
context: this.rootContext,
content: source
});
const filePath = `edge-chunks/asset_${name}`;
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextAssetMiddlewareBinding = {
filePath: `server/${filePath}`,
name
};
this.emitFile(filePath, source);
return `module.exports = ${JSON.stringify(`blob:${name}`)}`;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const raw = true;
exports.raw = raw;
//# sourceMappingURL=next-middleware-asset-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-middleware-asset-loader.ts"],"names":["MiddlewareAssetLoader","source","name","loaderUtils","interpolateName","context","rootContext","content","filePath","buildInfo","getModuleBuildInfo","_module","nextAssetMiddlewareBinding","emitFile","JSON","stringify","raw"],"mappings":"AAAA;;;;kBAGwBA,qBAAqB;;AAHrB,IAAA,aAAkC,kCAAlC,kCAAkC,EAAA;AACvB,IAAA,mBAAyB,WAAzB,yBAAyB,CAAA;AAE7C,SAASA,qBAAqB,CAAYC,MAAc,EAAE;IACvE,MAAMC,IAAI,GAAGC,aAAW,QAAA,CAACC,eAAe,CAAC,IAAI,EAAE,qBAAqB,EAAE;QACpEC,OAAO,EAAE,IAAI,CAACC,WAAW;QACzBC,OAAO,EAAEN,MAAM;KAChB,CAAC;IACF,MAAMO,QAAQ,GAAG,CAAC,kBAAkB,EAAEN,IAAI,CAAC,CAAC;IAC5C,MAAMO,SAAS,GAAGC,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClDF,SAAS,CAACG,0BAA0B,GAAG;QACrCJ,QAAQ,EAAE,CAAC,OAAO,EAAEA,QAAQ,CAAC,CAAC;QAC9BN,IAAI;KACL;IACD,IAAI,CAACW,QAAQ,CAACL,QAAQ,EAAEP,MAAM,CAAC;IAC/B,OAAO,CAAC,iBAAiB,EAAEa,IAAI,CAACC,SAAS,CAAC,CAAC,KAAK,EAAEb,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5D;;;;;;AAEM,MAAMc,GAAG,GAAG,IAAI;QAAVA,GAAG,GAAHA,GAAG"}

View File

@@ -0,0 +1,10 @@
import type { MiddlewareMatcher } from '../../analysis/get-page-static-info';
export declare type MiddlewareLoaderOptions = {
absolutePagePath: string;
page: string;
rootDir: string;
matchers?: string;
};
export declare function encodeMatchers(matchers: MiddlewareMatcher[]): string;
export declare function decodeMatchers(encodedMatchers: string): MiddlewareMatcher[];
export default function middlewareLoader(this: any): string;

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = middlewareLoader;
exports.encodeMatchers = encodeMatchers;
exports.decodeMatchers = decodeMatchers;
var _getModuleBuildInfo = require("./get-module-build-info");
var _stringifyRequest = require("../stringify-request");
var _constants = require("../../../lib/constants");
function middlewareLoader() {
const { absolutePagePath , page , rootDir , matchers: encodedMatchers , } = this.getOptions();
const matchers = encodedMatchers ? decodeMatchers(encodedMatchers) : undefined;
const stringifiedPagePath = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextEdgeMiddleware = {
matchers,
page: page.replace(new RegExp(`/${_constants.MIDDLEWARE_LOCATION_REGEXP}$`), "") || "/"
};
buildInfo.rootDir = rootDir;
return `
import { adapter, enhanceGlobals } from 'next/dist/esm/server/web/adapter'
enhanceGlobals()
var mod = require(${stringifiedPagePath})
var handler = mod.middleware || mod.default;
if (typeof handler !== 'function') {
throw new Error('The Middleware "pages${page}" must export a \`middleware\` or a \`default\` function');
}
export default function (opts) {
return adapter({
...opts,
page: ${JSON.stringify(page)},
handler,
})
}
`;
}
function encodeMatchers(matchers) {
return Buffer.from(JSON.stringify(matchers)).toString("base64");
}
function decodeMatchers(encodedMatchers) {
return JSON.parse(Buffer.from(encodedMatchers, "base64").toString());
}
//# sourceMappingURL=next-middleware-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-middleware-loader.ts"],"names":["middlewareLoader","encodeMatchers","decodeMatchers","absolutePagePath","page","rootDir","matchers","encodedMatchers","getOptions","undefined","stringifiedPagePath","stringifyRequest","buildInfo","getModuleBuildInfo","_module","nextEdgeMiddleware","replace","RegExp","MIDDLEWARE_LOCATION_REGEXP","JSON","stringify","Buffer","from","toString","parse"],"mappings":"AAAA;;;;kBAwBwBA,gBAAgB;QAVxBC,cAAc,GAAdA,cAAc;QAIdC,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OAAOY,IAAI,CAACK,KAAK,CACfH,MAAM,CAACC,IAAI,CAACf,eAAe,EAAE,QAAQ,CAAC,CAACgB,QAAQ,EAAE,CAClD,CAAuB;CACzB"}

View File

@@ -0,0 +1,3 @@
/// <reference types="node" />
export default function MiddlewareWasmLoader(this: any, source: Buffer): string;
export declare const raw = true;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = MiddlewareWasmLoader;
exports.raw = void 0;
var _getModuleBuildInfo = require("./get-module-build-info");
var _crypto = _interopRequireDefault(require("crypto"));
function MiddlewareWasmLoader(source) {
const name = `wasm_${sha1(source)}`;
const filePath = `edge-chunks/${name}.wasm`;
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextWasmMiddlewareBinding = {
filePath: `server/${filePath}`,
name
};
this.emitFile(`/${filePath}`, source, null);
return `module.exports = ${name};`;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function sha1(source) {
return _crypto.default.createHash("sha1").update(source).digest("hex");
}
const raw = true;
exports.raw = raw;
//# sourceMappingURL=next-middleware-wasm-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-middleware-wasm-loader.ts"],"names":["MiddlewareWasmLoader","source","name","sha1","filePath","buildInfo","getModuleBuildInfo","_module","nextWasmMiddlewareBinding","emitFile","crypto","createHash","update","digest","raw"],"mappings":"AAAA;;;;kBAOwBA,oBAAoB;;AAPT,IAAA,mBAAyB,WAAzB,yBAAyB,CAAA;AACzC,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAMZ,SAASA,oBAAoB,CAAYC,MAAc,EAAE;IACtE,MAAMC,IAAI,GAAG,CAAC,KAAK,EAAEC,IAAI,CAACF,MAAM,CAAC,CAAC,CAAC;IACnC,MAAMG,QAAQ,GAAG,CAAC,YAAY,EAAEF,IAAI,CAAC,KAAK,CAAC;IAC3C,MAAMG,SAAS,GAAGC,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClDF,SAAS,CAACG,yBAAyB,GAAG;QAAEJ,QAAQ,EAAE,CAAC,OAAO,EAAEA,QAAQ,CAAC,CAAC;QAAEF,IAAI;KAAE;IAC9E,IAAI,CAACO,QAAQ,CAAC,CAAC,CAAC,EAAEL,QAAQ,CAAC,CAAC,EAAEH,MAAM,EAAE,IAAI,CAAC;IAC3C,OAAO,CAAC,iBAAiB,EAAEC,IAAI,CAAC,CAAC,CAAC,CAAA;CACnC;;;;;;AAXD,SAASC,IAAI,CAACF,MAAuB,EAAE;IACrC,OAAOS,OAAM,QAAA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACX,MAAM,CAAC,CAACY,MAAM,CAAC,KAAK,CAAC,CAAA;CAC9D;AAWM,MAAMC,GAAG,GAAG,IAAI;QAAVA,GAAG,GAAHA,GAAG"}

View File

@@ -0,0 +1,4 @@
import { IncomingMessage, ServerResponse } from 'http';
import { ServerlessHandlerCtx } from './utils';
import { NodeNextResponse, NodeNextRequest } from '../../../../server/base-http/node';
export declare function getApiHandler(ctx: ServerlessHandlerCtx): (rawReq: NodeNextRequest | IncomingMessage, rawRes: NodeNextResponse | ServerResponse) => Promise<void>;

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getApiHandler = getApiHandler;
var _url = require("url");
var _http = require("http");
var _node = require("../../../../server/api-utils/node");
var _utils = require("./utils");
var _utils1 = require("../../../../shared/lib/utils");
var _node1 = require("../../../../server/base-http/node");
function getApiHandler(ctx) {
const { pageModule , encodedPreviewProps , pageIsDynamic } = ctx;
const { handleRewrites , handleBasePath , dynamicRouteMatcher , normalizeDynamicRouteParams , } = (0, _utils).getUtils(ctx);
return async (rawReq, rawRes)=>{
const req = rawReq instanceof _http.IncomingMessage ? new _node1.NodeNextRequest(rawReq) : rawReq;
const res = rawRes instanceof _http.ServerResponse ? new _node1.NodeNextResponse(rawRes) : rawRes;
try {
// We need to trust the dynamic route params from the proxy
// to ensure we are using the correct values
const trustQuery = req.headers[_utils.vercelHeader];
const parsedUrl = (0, _url).parse(req.url, true);
handleRewrites(req, parsedUrl);
if (parsedUrl.query.nextInternalLocale) {
delete parsedUrl.query.nextInternalLocale;
}
handleBasePath(req, parsedUrl);
let params = {};
if (pageIsDynamic) {
const result = normalizeDynamicRouteParams(trustQuery ? parsedUrl.query : dynamicRouteMatcher(parsedUrl.pathname));
params = result.params;
}
await (0, _node).apiResolver(req.originalRequest, res.originalResponse, Object.assign({}, parsedUrl.query, params), await pageModule, encodedPreviewProps, true);
} catch (err) {
console.error(err);
if (err instanceof _utils1.DecodeError) {
res.statusCode = 400;
res.body("Bad Request").send();
} else {
// Throw the error to crash the serverless function
throw err;
}
}
};
}
//# sourceMappingURL=api-handler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-serverless-loader/api-handler.ts"],"names":["getApiHandler","ctx","pageModule","encodedPreviewProps","pageIsDynamic","handleRewrites","handleBasePath","dynamicRouteMatcher","normalizeDynamicRouteParams","getUtils","rawReq","rawRes","req","IncomingMessage","NodeNextRequest","res","ServerResponse","NodeNextResponse","trustQuery","headers","vercelHeader","parsedUrl","parseUrl","url","query","nextInternalLocale","params","result","pathname","apiResolver","originalRequest","originalResponse","Object","assign","err","console","error","DecodeError","statusCode","body","send"],"mappings":"AAAA;;;;QAUgBA,aAAa,GAAbA,aAAa;AAVK,IAAA,IAAK,WAAL,KAAK,CAAA;AACS,IAAA,KAAM,WAAN,MAAM,CAAA;AAC1B,IAAA,KAAmC,WAAnC,mCAAmC,CAAA;AACF,IAAA,MAAS,WAAT,SAAS,CAAA;AAC1C,IAAA,OAA8B,WAA9B,8BAA8B,CAAA;AAInD,IAAA,MAAmC,WAAnC,mCAAmC,CAAA;AAEnC,SAASA,aAAa,CAACC,GAAyB,EAAE;IACvD,MAAM,EAAE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,CAACkB,eAAe,EACnBf,GAAG,CAACgB,gBAAgB,EACpBC,MAAM,CAACC,MAAM,CAAC,EAAE,EAAEZ,SAAS,CAACG,KAAK,EAAEE,MAAM,CAAC,EAC1C,MAAMxB,UAAU,EAChBC,mBAAmB,EACnB,IAAI,CACL;SACF,CAAC,OAAO+B,GAAG,EAAE;YACZC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;YAElB,IAAIA,GAAG,YAAYG,OAAW,YAAA,EAAE;gBAC9BtB,GAAG,CAACuB,UAAU,GAAG,GAAG;gBACpBvB,GAAG,CAACwB,IAAI,CAAC,aAAa,CAAC,CAACC,IAAI,EAAE;aAC/B,MAAM;gBACL,mDAAmD;gBACnD,MAAMN,GAAG,CAAA;aACV;SACF;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,22 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
export declare type ServerlessLoaderQuery = {
page: string;
distDir: string;
absolutePagePath: string;
absoluteAppPath: string;
absoluteDocumentPath: string;
absoluteErrorPath: string;
absolute404Path: string;
buildId: string;
assetPrefix: string;
generateEtags: string;
poweredByHeader: string;
canonicalBase: string;
basePath: string;
runtimeConfig: string;
previewProps: string;
loadedEnvFiles: string;
i18n: string;
};
declare const nextServerlessLoader: webpack.LoaderDefinitionFunction;
export default nextServerlessLoader;

View File

@@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _devalue = _interopRequireDefault(require("next/dist/compiled/devalue"));
var _path = require("path");
var _querystring = require("querystring");
var _isApiRoute = require("../../../../lib/is-api-route");
var _utils = require("../../../../shared/lib/router/utils");
var _escapeRegexp = require("../../../../shared/lib/escape-regexp");
var _constants = require("../../../../shared/lib/constants");
var _stringifyRequest = require("../../stringify-request");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const nextServerlessLoader = function() {
const { distDir , absolutePagePath , page , buildId , canonicalBase , assetPrefix , absoluteAppPath , absoluteDocumentPath , absoluteErrorPath , absolute404Path , generateEtags , poweredByHeader , basePath , runtimeConfig , previewProps , loadedEnvFiles , i18n , } = typeof this.query === "string" ? (0, _querystring).parse(this.query.slice(1)) : this.query;
const buildManifest = (0, _path).join(distDir, _constants.BUILD_MANIFEST).replace(/\\/g, "/");
const reactLoadableManifest = (0, _path).join(distDir, _constants.REACT_LOADABLE_MANIFEST).replace(/\\/g, "/");
const routesManifest = (0, _path).join(distDir, _constants.ROUTES_MANIFEST).replace(/\\/g, "/");
const escapedBuildId = (0, _escapeRegexp).escapeStringRegexp(buildId);
const pageIsDynamicRoute = (0, _utils).isDynamicRoute(page);
const encodedPreviewProps = (0, _devalue).default(JSON.parse(previewProps));
const envLoading = `
const { processEnv } = require('@next/env')
processEnv(${Buffer.from(loadedEnvFiles, "base64").toString()})
`;
const runtimeConfigImports = runtimeConfig ? `
const { setConfig } = require('next/config')
` : "";
const runtimeConfigSetter = runtimeConfig ? `
const runtimeConfig = ${runtimeConfig}
setConfig(runtimeConfig)
` : "const runtimeConfig = {}";
if ((0, _isApiRoute).isAPIRoute(page)) {
return `
${envLoading}
${runtimeConfigImports}
${/*
this needs to be called first so its available for any other imports
*/ runtimeConfigSetter}
import 'next/dist/server/node-polyfill-fetch'
import routesManifest from '${routesManifest}'
import { getApiHandler } from 'next/dist/build/webpack/loaders/next-serverless-loader/api-handler'
const rewrites = Array.isArray(routesManifest.rewrites)
? {
afterFiles: routesManifest.rewrites
}
: routesManifest.rewrites
const apiHandler = getApiHandler({
pageModule: require(${(0, _stringifyRequest).stringifyRequest(this, absolutePagePath)}),
rewrites: rewrites,
i18n: ${i18n || "undefined"},
page: "${page}",
basePath: "${basePath}",
pageIsDynamic: ${pageIsDynamicRoute},
encodedPreviewProps: ${encodedPreviewProps}
})
export default apiHandler
`;
} else {
return `
import 'next/dist/server/node-polyfill-fetch'
import routesManifest from '${routesManifest}'
import buildManifest from '${buildManifest}'
import reactLoadableManifest from '${reactLoadableManifest}'
${envLoading}
${runtimeConfigImports}
${// this needs to be called first so its available for any other imports
runtimeConfigSetter}
import { getPageHandler } from 'next/dist/build/webpack/loaders/next-serverless-loader/page-handler'
const documentModule = require(${(0, _stringifyRequest).stringifyRequest(this, absoluteDocumentPath)})
const appMod = require(${(0, _stringifyRequest).stringifyRequest(this, absoluteAppPath)})
let App = appMod.default || appMod.then && appMod.then(mod => mod.default);
const compMod = require(${(0, _stringifyRequest).stringifyRequest(this, absolutePagePath)})
const Component = compMod.default || compMod.then && compMod.then(mod => mod.default)
export default Component
export const getStaticProps = compMod['getStaticProp' + 's'] || compMod.then && compMod.then(mod => mod['getStaticProp' + 's'])
export const getStaticPaths = compMod['getStaticPath' + 's'] || compMod.then && compMod.then(mod => mod['getStaticPath' + 's'])
export const getServerSideProps = compMod['getServerSideProp' + 's'] || compMod.then && compMod.then(mod => mod['getServerSideProp' + 's'])
// kept for detecting legacy exports
export const unstable_getStaticParams = compMod['unstable_getStaticParam' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getStaticParam' + 's'])
export const unstable_getStaticProps = compMod['unstable_getStaticProp' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getStaticProp' + 's'])
export const unstable_getStaticPaths = compMod['unstable_getStaticPath' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getStaticPath' + 's'])
export const unstable_getServerProps = compMod['unstable_getServerProp' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getServerProp' + 's'])
export let config = compMod['confi' + 'g'] || (compMod.then && compMod.then(mod => mod['confi' + 'g'])) || {}
export const _app = App
const rewrites = Array.isArray(routesManifest.rewrites)
? {
afterFiles: routesManifest.rewrites
}
: routesManifest.rewrites
const { renderReqToHTML, render } = getPageHandler({
pageModule: compMod,
pageComponent: Component,
pageConfig: config,
appModule: App,
documentModule: documentModule,
errorModule: require(${(0, _stringifyRequest).stringifyRequest(this, absoluteErrorPath)}),
notFoundModule: ${absolute404Path ? `require(${(0, _stringifyRequest).stringifyRequest(this, absolute404Path)})` : undefined},
pageGetStaticProps: getStaticProps,
pageGetStaticPaths: getStaticPaths,
pageGetServerSideProps: getServerSideProps,
assetPrefix: "${assetPrefix}",
canonicalBase: "${canonicalBase}",
generateEtags: ${generateEtags || "false"},
poweredByHeader: ${poweredByHeader || "false"},
runtimeConfig,
buildManifest,
reactLoadableManifest,
rewrites: rewrites,
i18n: ${i18n || "undefined"},
page: "${page}",
buildId: "${buildId}",
escapedBuildId: "${escapedBuildId}",
basePath: "${basePath}",
pageIsDynamic: ${pageIsDynamicRoute},
encodedPreviewProps: ${encodedPreviewProps}
})
export { renderReqToHTML, render }
`;
}
};
var _default = nextServerlessLoader;
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-serverless-loader/index.ts"],"names":["nextServerlessLoader","distDir","absolutePagePath","page","buildId","canonicalBase","assetPrefix","absoluteAppPath","absoluteDocumentPath","absoluteErrorPath","absolute404Path","generateEtags","poweredByHeader","basePath","runtimeConfig","previewProps","loadedEnvFiles","i18n","query","parse","slice","buildManifest","join","BUILD_MANIFEST","replace","reactLoadableManifest","REACT_LOADABLE_MANIFEST","routesManifest","ROUTES_MANIFEST","escapedBuildId","escapeStringRegexp","pageIsDynamicRoute","isDynamicRoute","encodedPreviewProps","devalue","JSON","envLoading","Buffer","from","toString","runtimeConfigImports","runtimeConfigSetter","isAPIRoute","stringifyRequest","undefined"],"mappings":"AAAA;;;;;AAAoB,IAAA,QAA4B,kCAA5B,4BAA4B,EAAA;AAC3B,IAAA,KAAM,WAAN,MAAM,CAAA;AACL,IAAA,YAAa,WAAb,aAAa,CAAA;AAER,IAAA,WAA8B,WAA9B,8BAA8B,CAAA;AAC1B,IAAA,MAAqC,WAArC,qCAAqC,CAAA;AACjC,IAAA,aAAsC,WAAtC,sCAAsC,CAAA;AAMlE,IAAA,UAAkC,WAAlC,kCAAkC,CAAA;AACR,IAAA,iBAAyB,WAAzB,yBAAyB,CAAA;;;;;;AAsB1D,MA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EpC,eAAe,CAAC,CAAC;;;8BAGzC,EAAEoC,CAAAA,GAAAA,iBAAgB,AAAwB,CAAA,iBAAxB,CAAC,IAAI,EAAEzC,gBAAgB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA6B5C,EAAEyC,CAAAA,GAAAA,iBAAgB,AAAyB,CAAA,iBAAzB,CAAC,IAAI,EAAElC,iBAAiB,CAAC,CAAC;wBACjD,EACdC,eAAe,GACX,CAAC,QAAQ,EAAEiC,CAAAA,GAAAA,iBAAgB,AAAuB,CAAA,iBAAvB,CAAC,IAAI,EAAEjC,eAAe,CAAC,CAAC,CAAC,CAAC,GACrDkC,SAAS,CACd;;;;;sBAKa,EAAEtC,WAAW,CAAC;wBACZ,EAAED,aAAa,CAAC;uBACjB,EAAEM,aAAa,IAAI,OAAO,CAAC;yBACzB,EAAEC,eAAe,IAAI,OAAO,CAAC;;;;;;;cAOxC,EAAEK,IAAI,IAAI,WAAW,CAAC;eACrB,EAAEd,IAAI,CAAC;kBACJ,EAAEC,OAAO,CAAC;yBACH,EAAEyB,cAAc,CAAC;mBACvB,EAAEhB,QAAQ,CAAC;uBACP,EAAEkB,kBAAkB,CAAC;6BACf,EAAEE,mBAAmB,CAAC;;;IAG/C,CAAC,CAAA;KACF;CACF;eAEcjC,oBAAoB"}

View File

@@ -0,0 +1,10 @@
import { IncomingMessage, ServerResponse } from 'http';
import { ServerlessHandlerCtx } from './utils';
import RenderResult from '../../../../server/render-result';
export declare function getPageHandler(ctx: ServerlessHandlerCtx): {
renderReqToHTML: (req: IncomingMessage, res: ServerResponse, renderMode?: 'export' | 'passthrough' | true, _renderOpts?: any, _params?: any) => Promise<string | {
html: RenderResult | null;
renderOpts: any;
} | null>;
render: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
};

View File

@@ -0,0 +1,337 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPageHandler = getPageHandler;
var _url = require("url");
var _utils = require("../../../../shared/lib/utils");
var _sendPayload = require("../../../../server/send-payload");
var _utils1 = require("./utils");
var _render = require("../../../../server/render");
var _node = require("../../../../server/api-utils/node");
var _denormalizePagePath = require("../../../../shared/lib/page-path/denormalize-page-path");
var _apiUtils = require("../../../../server/api-utils");
var _redirectStatus = require("../../../../lib/redirect-status");
var _getRouteFromAssetPath = _interopRequireDefault(require("../../../../shared/lib/router/utils/get-route-from-asset-path"));
var _constants = require("../../../../shared/lib/constants");
var _renderResult = _interopRequireDefault(require("../../../../server/render-result"));
var _isError = _interopRequireDefault(require("../../../../lib/is-error"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getPageHandler(ctx) {
const { page , pageComponent , pageConfig , pageGetStaticProps , pageGetStaticPaths , pageGetServerSideProps , appModule , documentModule , errorModule , notFoundModule , encodedPreviewProps , pageIsDynamic , generateEtags , poweredByHeader , runtimeConfig , buildManifest , reactLoadableManifest , i18n , buildId , basePath , assetPrefix , canonicalBase , escapedBuildId , } = ctx;
const { handleLocale , handleRewrites , handleBasePath , defaultRouteRegex , dynamicRouteMatcher , interpolateDynamicPath , getParamsFromRouteMatches , normalizeDynamicRouteParams , normalizeVercelUrl , } = (0, _utils1).getUtils(ctx);
async function renderReqToHTML(req, res, renderMode, _renderOpts, _params) {
let Component;
let App;
let config;
let Document;
let Error;
let notFoundMod;
let getStaticProps;
let getStaticPaths;
let getServerSideProps;
[getStaticProps, getServerSideProps, getStaticPaths, Component, App, config, { default: Document }, { default: Error }, notFoundMod, ] = await Promise.all([
pageGetStaticProps,
pageGetServerSideProps,
pageGetStaticPaths,
pageComponent,
appModule,
pageConfig,
documentModule,
errorModule,
notFoundModule,
]);
const fromExport = renderMode === "export" || renderMode === true;
const nextStartMode = renderMode === "passthrough";
let hasValidParams = true;
(0, _apiUtils).setLazyProp({
req: req
}, "cookies", (0, _apiUtils).getCookieParser(req.headers));
const options = {
App,
Document,
ComponentMod: {
default: Component
},
buildManifest,
getStaticProps,
getServerSideProps,
getStaticPaths,
reactLoadableManifest,
canonicalBase,
buildId,
assetPrefix,
runtimeConfig: (runtimeConfig || {}).publicRuntimeConfig || {},
previewProps: encodedPreviewProps,
env: process.env,
basePath,
supportsDynamicHTML: false,
..._renderOpts
};
let _nextData = false;
let defaultLocale = i18n == null ? void 0 : i18n.defaultLocale;
let detectedLocale = i18n == null ? void 0 : i18n.defaultLocale;
let parsedUrl;
try {
var ref;
// We need to trust the dynamic route params from the proxy
// to ensure we are using the correct values
const trustQuery = !getStaticProps && req.headers[_utils1.vercelHeader];
parsedUrl = (0, _url).parse(req.url, true);
let routeNoAssetPath = parsedUrl.pathname;
if (basePath) {
routeNoAssetPath = routeNoAssetPath.replace(new RegExp(`^${basePath}`), "") || "/";
}
const origQuery = Object.assign({}, parsedUrl.query);
handleRewrites(req, parsedUrl);
handleBasePath(req, parsedUrl);
// remove ?amp=1 from request URL if rendering for export
if (fromExport && parsedUrl.query.amp) {
const queryNoAmp = Object.assign({}, origQuery);
delete queryNoAmp.amp;
req.url = (0, _url).format({
...parsedUrl,
search: undefined,
query: queryNoAmp
});
}
if (parsedUrl.pathname.match(/_next\/data/)) {
_nextData = page !== "/_error";
parsedUrl.pathname = (0, _getRouteFromAssetPath).default(parsedUrl.pathname.replace(new RegExp(`/_next/data/${escapedBuildId}/`), "/"), ".json");
routeNoAssetPath = parsedUrl.pathname;
}
const localeResult = handleLocale(req, res, parsedUrl, routeNoAssetPath, fromExport || nextStartMode);
defaultLocale = (localeResult == null ? void 0 : localeResult.defaultLocale) || defaultLocale;
detectedLocale = (localeResult == null ? void 0 : localeResult.detectedLocale) || detectedLocale;
routeNoAssetPath = (localeResult == null ? void 0 : localeResult.routeNoAssetPath) || routeNoAssetPath;
if (parsedUrl.query.nextInternalLocale) {
detectedLocale = parsedUrl.query.nextInternalLocale;
delete parsedUrl.query.nextInternalLocale;
}
const renderOpts = Object.assign({
Component,
pageConfig: config,
nextExport: fromExport,
isDataReq: _nextData,
locales: i18n == null ? void 0 : i18n.locales,
locale: detectedLocale,
defaultLocale,
domainLocales: i18n == null ? void 0 : i18n.domains,
optimizeCss: process.env.__NEXT_OPTIMIZE_CSS,
nextScriptWorkers: process.env.__NEXT_SCRIPT_WORKERS,
crossOrigin: process.env.__NEXT_CROSS_ORIGIN
}, options);
if (page === "/_error" && !res.statusCode) {
res.statusCode = 404;
}
let params = {};
if (!fromExport && pageIsDynamic) {
const result = normalizeDynamicRouteParams(trustQuery ? parsedUrl.query : dynamicRouteMatcher(parsedUrl.pathname));
hasValidParams = result.hasValidParams;
params = result.params;
}
let nowParams = null;
if (pageIsDynamic && !hasValidParams && ((ref = req.headers) == null ? void 0 : ref["x-now-route-matches"])) {
nowParams = getParamsFromRouteMatches(req, renderOpts, detectedLocale);
}
// make sure to set renderOpts to the correct params e.g. _params
// if provided from worker or params if we're parsing them here
renderOpts.params = _params || params;
normalizeVercelUrl(req, !!trustQuery);
// normalize request URL/asPath for fallback/revalidate pages since the
// proxy sets the request URL to the output's path for fallback pages
if (pageIsDynamic && nowParams && defaultRouteRegex) {
const _parsedUrl = (0, _url).parse(req.url);
_parsedUrl.pathname = interpolateDynamicPath(_parsedUrl.pathname, nowParams);
parsedUrl.pathname = _parsedUrl.pathname;
req.url = (0, _url).format(_parsedUrl);
}
// make sure to normalize asPath for revalidate and _next/data requests
// since the asPath should match what is shown on the client
if (!fromExport && (getStaticProps || getServerSideProps)) {
// don't include dynamic route params in query while normalizing
// asPath
if (pageIsDynamic && defaultRouteRegex) {
delete parsedUrl.search;
for (const param of Object.keys(defaultRouteRegex.groups)){
delete origQuery[param];
}
}
parsedUrl.pathname = (0, _denormalizePagePath).denormalizePagePath(parsedUrl.pathname);
renderOpts.resolvedUrl = (0, _url).format({
...parsedUrl,
query: origQuery
});
// For getServerSideProps we need to ensure we use the original URL
// and not the resolved URL to prevent a hydration mismatch on asPath
renderOpts.resolvedAsPath = getServerSideProps ? (0, _url).format({
...parsedUrl,
pathname: routeNoAssetPath,
query: origQuery
}) : renderOpts.resolvedUrl;
}
const isFallback = parsedUrl.query.__nextFallback;
const previewData = (0, _node).tryGetPreviewData(req, res, options.previewProps);
const isPreviewMode = previewData !== false;
if (process.env.__NEXT_OPTIMIZE_FONTS) {
renderOpts.optimizeFonts = process.env.__NEXT_OPTIMIZE_FONTS;
/**
* __webpack_require__.__NEXT_FONT_MANIFEST__ is added by
* font-stylesheet-gathering-plugin
*/ // @ts-ignore
renderOpts.fontManifest = __webpack_require__.__NEXT_FONT_MANIFEST__;
}
let result = await (0, _render).renderToHTML(req, res, page, Object.assign({}, getStaticProps ? {
...parsedUrl.query.amp ? {
amp: "1"
} : {}
} : parsedUrl.query, nowParams ? nowParams : params, _params, isFallback ? {
__nextFallback: "true"
} : {}), renderOpts);
if (!renderMode) {
if (_nextData || getStaticProps || getServerSideProps) {
if (renderOpts.isNotFound) {
res.statusCode = 404;
if (_nextData) {
res.end('{"notFound":true}');
return null;
}
const NotFoundComponent = notFoundMod ? notFoundMod.default : Error;
const errPathname = notFoundMod ? "/404" : "/_error";
const result2 = await (0, _render).renderToHTML(req, res, errPathname, parsedUrl.query, Object.assign({}, options, {
getStaticProps: notFoundMod ? notFoundMod.getStaticProps : undefined,
getStaticPaths: undefined,
getServerSideProps: undefined,
Component: NotFoundComponent,
err: undefined,
locale: detectedLocale,
locales: i18n == null ? void 0 : i18n.locales,
defaultLocale: i18n == null ? void 0 : i18n.defaultLocale
}));
(0, _sendPayload).sendRenderResult({
req,
res,
result: result2 ?? _renderResult.default.empty,
type: "html",
generateEtags,
poweredByHeader,
options: {
private: isPreviewMode || page === "/404",
stateful: !!getServerSideProps,
revalidate: renderOpts.revalidate
}
});
return null;
} else if (renderOpts.isRedirect && !_nextData) {
const redirect = {
destination: renderOpts.pageData.pageProps.__N_REDIRECT,
statusCode: renderOpts.pageData.pageProps.__N_REDIRECT_STATUS,
basePath: renderOpts.pageData.pageProps.__N_REDIRECT_BASE_PATH
};
const statusCode = (0, _redirectStatus).getRedirectStatus(redirect);
if (basePath && redirect.basePath !== false && redirect.destination.startsWith("/")) {
redirect.destination = `${basePath}${redirect.destination}`;
}
if (statusCode === _constants.PERMANENT_REDIRECT_STATUS) {
res.setHeader("Refresh", `0;url=${redirect.destination}`);
}
res.statusCode = statusCode;
res.setHeader("Location", redirect.destination);
res.end(redirect.destination);
return null;
} else {
(0, _sendPayload).sendRenderResult({
req,
res,
result: _nextData ? _renderResult.default.fromStatic(JSON.stringify(renderOpts.pageData)) : result ?? _renderResult.default.empty,
type: _nextData ? "json" : "html",
generateEtags,
poweredByHeader,
options: {
private: isPreviewMode || renderOpts.is404Page,
stateful: !!getServerSideProps,
revalidate: renderOpts.revalidate
}
});
return null;
}
}
} else if (isPreviewMode) {
res.setHeader("Cache-Control", "private, no-cache, no-store, max-age=0, must-revalidate");
}
if (renderMode) return {
html: result,
renderOpts
};
return result ? result.toUnchunkedString() : null;
} catch (err) {
if (!parsedUrl) {
parsedUrl = (0, _url).parse(req.url, true);
}
if ((0, _isError).default(err) && err.code === "ENOENT") {
res.statusCode = 404;
} else if (err instanceof _utils.DecodeError) {
res.statusCode = 400;
} else {
console.error("Unhandled error during request:", err);
// Backwards compat (call getInitialProps in custom error):
try {
await (0, _render).renderToHTML(req, res, "/_error", parsedUrl.query, Object.assign({}, options, {
getStaticProps: undefined,
getStaticPaths: undefined,
getServerSideProps: undefined,
Component: Error,
err: err,
// Short-circuit rendering:
isDataReq: true
}));
} catch (underErrorErr) {
console.error("Failed call /_error subroutine, continuing to crash function:", underErrorErr);
}
// Throw the error to crash the serverless function
if ((0, _utils).isResSent(res)) {
console.error("!!! WARNING !!!");
console.error("Your function crashed, but closed the response before allowing the function to exit.\\n" + "This may cause unexpected behavior for the next request.");
console.error("!!! WARNING !!!");
}
throw err;
}
const result2 = await (0, _render).renderToHTML(req, res, "/_error", parsedUrl.query, Object.assign({}, options, {
getStaticProps: undefined,
getStaticPaths: undefined,
getServerSideProps: undefined,
Component: Error,
err: res.statusCode === 404 ? undefined : err
}));
return result2 ? result2.toUnchunkedString() : null;
}
}
return {
renderReqToHTML,
render: async function render(req, res) {
try {
const html = await renderReqToHTML(req, res);
if (html) {
(0, _sendPayload).sendRenderResult({
req,
res,
result: _renderResult.default.fromStatic(html),
type: "html",
generateEtags,
poweredByHeader
});
}
} catch (err) {
console.error(err);
// Throw the error to crash the serverless function
throw err;
}
}
};
}
//# sourceMappingURL=page-handler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,83 @@
/// <reference types="node" />
/// <reference types="node" />
import type { IncomingMessage, ServerResponse } from 'http';
import type { Rewrite } from '../../../../lib/load-custom-routes';
import type { BuildManifest } from '../../../../server/get-page-files';
import type { RouteMatch } from '../../../../shared/lib/router/utils/route-matcher';
import type { NextConfig } from '../../../../server/config';
import type { GetServerSideProps, GetStaticPaths, GetStaticProps } from '../../../../types';
import type { BaseNextRequest } from '../../../../server/base-http';
import type { __ApiPreviewProps } from '../../../../server/api-utils';
import { UrlWithParsedQuery } from 'url';
import { ParsedUrlQuery } from 'querystring';
import { getNamedRouteRegex } from '../../../../shared/lib/router/utils/route-regex';
export declare const vercelHeader = "x-vercel-id";
export declare type ServerlessHandlerCtx = {
page: string;
pageModule: any;
pageComponent?: any;
pageConfig?: any;
pageGetStaticProps?: GetStaticProps;
pageGetStaticPaths?: GetStaticPaths;
pageGetServerSideProps?: GetServerSideProps;
appModule?: any;
errorModule?: any;
documentModule?: any;
notFoundModule?: any;
runtimeConfig: any;
buildManifest?: BuildManifest;
reactLoadableManifest?: any;
basePath: string;
rewrites: {
fallback?: Rewrite[];
afterFiles?: Rewrite[];
beforeFiles?: Rewrite[];
};
pageIsDynamic: boolean;
generateEtags: boolean;
distDir: string;
buildId: string;
escapedBuildId: string;
assetPrefix: string;
poweredByHeader: boolean;
canonicalBase: string;
encodedPreviewProps: __ApiPreviewProps;
i18n?: NextConfig['i18n'];
};
export declare function normalizeVercelUrl(req: BaseNextRequest | IncomingMessage, trustQuery: boolean, paramKeys?: string[], pageIsDynamic?: boolean, defaultRouteRegex?: ReturnType<typeof getNamedRouteRegex> | undefined): void;
export declare function interpolateDynamicPath(pathname: string, params: ParsedUrlQuery, defaultRouteRegex?: ReturnType<typeof getNamedRouteRegex> | undefined): string;
export declare function getUtils({ page, i18n, basePath, rewrites, pageIsDynamic, trailingSlash, }: {
page: ServerlessHandlerCtx['page'];
i18n?: ServerlessHandlerCtx['i18n'];
basePath: ServerlessHandlerCtx['basePath'];
rewrites: ServerlessHandlerCtx['rewrites'];
pageIsDynamic: ServerlessHandlerCtx['pageIsDynamic'];
trailingSlash?: boolean;
}): {
handleLocale: (req: IncomingMessage, res: ServerResponse, parsedUrl: UrlWithParsedQuery, routeNoAssetPath: string, shouldNotRedirect: boolean) => {
defaultLocale: string;
detectedLocale: string;
routeNoAssetPath: string;
} | undefined;
handleRewrites: (req: BaseNextRequest | IncomingMessage, parsedUrl: UrlWithParsedQuery) => {};
handleBasePath: (req: BaseNextRequest | IncomingMessage, parsedUrl: UrlWithParsedQuery) => void;
defaultRouteRegex: {
namedRegex: string;
routeKeys: {
[named: string]: string;
};
groups: {
[groupName: string]: import("../../../../shared/lib/router/utils/route-regex").Group;
};
re: RegExp;
} | undefined;
dynamicRouteMatcher: RouteMatch | undefined;
defaultRouteMatches: ParsedUrlQuery | undefined;
getParamsFromRouteMatches: (req: BaseNextRequest | IncomingMessage, renderOpts?: any, detectedLocale?: string) => ParsedUrlQuery;
normalizeDynamicRouteParams: (params: ParsedUrlQuery, ignoreOptional?: boolean) => {
params: ParsedUrlQuery;
hasValidParams: boolean;
};
normalizeVercelUrl: (req: BaseNextRequest | IncomingMessage, trustQuery: boolean, paramKeys?: string[]) => void;
interpolateDynamicPath: (pathname: string, params: Record<string, undefined | string | string[]>) => string;
};

View File

@@ -0,0 +1,375 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.normalizeVercelUrl = normalizeVercelUrl;
exports.interpolateDynamicPath = interpolateDynamicPath;
exports.getUtils = getUtils;
exports.vercelHeader = void 0;
var _url = require("url");
var _querystring = require("querystring");
var _normalizeLocalePath = require("../../../../shared/lib/i18n/normalize-locale-path");
var _pathMatch = require("../../../../shared/lib/router/utils/path-match");
var _routeRegex = require("../../../../shared/lib/router/utils/route-regex");
var _routeMatcher = require("../../../../shared/lib/router/utils/route-matcher");
var _prepareDestination = require("../../../../shared/lib/router/utils/prepare-destination");
var _acceptHeader = require("../../../../server/accept-header");
var _detectLocaleCookie = require("../../../../shared/lib/i18n/detect-locale-cookie");
var _detectDomainLocale = require("../../../../shared/lib/i18n/detect-domain-locale");
var _denormalizePagePath = require("../../../../shared/lib/page-path/denormalize-page-path");
var _cookie = _interopRequireDefault(require("next/dist/compiled/cookie"));
var _constants = require("../../../../shared/lib/constants");
var _requestMeta = require("../../../../server/request-meta");
var _removeTrailingSlash = require("../../../../shared/lib/router/utils/remove-trailing-slash");
var _appPaths = require("../../../../shared/lib/router/utils/app-paths");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const vercelHeader = "x-vercel-id";
exports.vercelHeader = vercelHeader;
function normalizeVercelUrl(req, trustQuery, paramKeys, pageIsDynamic, defaultRouteRegex) {
// make sure to normalize req.url on Vercel to strip dynamic params
// from the query which are added during routing
if (pageIsDynamic && trustQuery && defaultRouteRegex) {
const _parsedUrl = (0, _url).parse(req.url, true);
delete _parsedUrl.search;
for (const param of paramKeys || Object.keys(defaultRouteRegex.groups)){
delete _parsedUrl.query[param];
}
req.url = (0, _url).format(_parsedUrl);
}
}
function interpolateDynamicPath(pathname, params, defaultRouteRegex) {
if (!defaultRouteRegex) return pathname;
for (const param of Object.keys(defaultRouteRegex.groups)){
const { optional , repeat } = defaultRouteRegex.groups[param];
let builtParam = `[${repeat ? "..." : ""}${param}]`;
if (optional) {
builtParam = `[${builtParam}]`;
}
const paramIdx = pathname.indexOf(builtParam);
if (paramIdx > -1) {
let paramValue;
const value = params[param];
if (Array.isArray(value)) {
paramValue = value.map((v)=>v && encodeURIComponent(v)).join("/");
} else if (value) {
paramValue = encodeURIComponent(value);
} else {
paramValue = "";
}
pathname = pathname.slice(0, paramIdx) + paramValue + pathname.slice(paramIdx + builtParam.length);
}
}
return pathname;
}
function getUtils({ page , i18n , basePath , rewrites , pageIsDynamic , trailingSlash }) {
let defaultRouteRegex;
let dynamicRouteMatcher;
let defaultRouteMatches;
if (pageIsDynamic) {
defaultRouteRegex = (0, _routeRegex).getNamedRouteRegex(page);
dynamicRouteMatcher = (0, _routeMatcher).getRouteMatcher(defaultRouteRegex);
defaultRouteMatches = dynamicRouteMatcher(page);
}
function handleRewrites(req, parsedUrl) {
const rewriteParams = {};
let fsPathname = parsedUrl.pathname;
const matchesPage = ()=>{
const fsPathnameNoSlash = (0, _removeTrailingSlash).removeTrailingSlash(fsPathname || "");
return fsPathnameNoSlash === (0, _removeTrailingSlash).removeTrailingSlash(page) || (dynamicRouteMatcher == null ? void 0 : dynamicRouteMatcher(fsPathnameNoSlash));
};
const checkRewrite = (rewrite)=>{
const matcher = (0, _pathMatch).getPathMatch(rewrite.source + (trailingSlash ? "(/)?" : ""), {
removeUnnamedParams: true,
strict: true
});
let params = matcher(parsedUrl.pathname);
if ((rewrite.has || rewrite.missing) && params) {
const hasParams = (0, _prepareDestination).matchHas(req, parsedUrl.query, rewrite.has, rewrite.missing);
if (hasParams) {
Object.assign(params, hasParams);
} else {
params = false;
}
}
if (params) {
const { parsedDestination , destQuery } = (0, _prepareDestination).prepareDestination({
appendParamsToQuery: true,
destination: rewrite.destination,
params: params,
query: parsedUrl.query
});
// if the rewrite destination is external break rewrite chain
if (parsedDestination.protocol) {
return true;
}
Object.assign(rewriteParams, destQuery, params);
Object.assign(parsedUrl.query, parsedDestination.query);
delete parsedDestination.query;
Object.assign(parsedUrl, parsedDestination);
fsPathname = parsedUrl.pathname;
if (basePath) {
fsPathname = fsPathname.replace(new RegExp(`^${basePath}`), "") || "/";
}
if (i18n) {
const destLocalePathResult = (0, _normalizeLocalePath).normalizeLocalePath(fsPathname, i18n.locales);
fsPathname = destLocalePathResult.pathname;
parsedUrl.query.nextInternalLocale = destLocalePathResult.detectedLocale || params.nextInternalLocale;
}
if (fsPathname === page) {
return true;
}
if (pageIsDynamic && dynamicRouteMatcher) {
const dynamicParams = dynamicRouteMatcher(fsPathname);
if (dynamicParams) {
parsedUrl.query = {
...parsedUrl.query,
...dynamicParams
};
return true;
}
}
}
return false;
};
for (const rewrite1 of rewrites.beforeFiles || []){
checkRewrite(rewrite1);
}
if (fsPathname !== page) {
let finished = false;
for (const rewrite of rewrites.afterFiles || []){
finished = checkRewrite(rewrite);
if (finished) break;
}
if (!finished && !matchesPage()) {
for (const rewrite of rewrites.fallback || []){
finished = checkRewrite(rewrite);
if (finished) break;
}
}
}
return rewriteParams;
}
function handleBasePath(req, parsedUrl) {
// always strip the basePath if configured since it is required
req.url = req.url.replace(new RegExp(`^${basePath}`), "") || "/";
parsedUrl.pathname = parsedUrl.pathname.replace(new RegExp(`^${basePath}`), "") || "/";
}
function getParamsFromRouteMatches(req, renderOpts, detectedLocale) {
return (0, _routeMatcher).getRouteMatcher(function() {
const { groups , routeKeys } = defaultRouteRegex;
return {
re: {
// Simulate a RegExp match from the \`req.url\` input
exec: (str)=>{
const obj = (0, _querystring).parse(str);
const matchesHasLocale = i18n && detectedLocale && obj["1"] === detectedLocale;
// favor named matches if available
const routeKeyNames = Object.keys(routeKeys || {});
const filterLocaleItem = (val)=>{
if (i18n) {
// locale items can be included in route-matches
// for fallback SSG pages so ensure they are
// filtered
const isCatchAll = Array.isArray(val);
const _val = isCatchAll ? val[0] : val;
if (typeof _val === "string" && i18n.locales.some((item)=>{
if (item.toLowerCase() === _val.toLowerCase()) {
detectedLocale = item;
renderOpts.locale = detectedLocale;
return true;
}
return false;
})) {
// remove the locale item from the match
if (isCatchAll) {
val.splice(0, 1);
}
// the value is only a locale item and
// shouldn't be added
return isCatchAll ? val.length === 0 : true;
}
}
return false;
};
if (routeKeyNames.every((name)=>obj[name])) {
return routeKeyNames.reduce((prev, keyName)=>{
const paramName = routeKeys == null ? void 0 : routeKeys[keyName];
if (paramName && !filterLocaleItem(obj[keyName])) {
prev[groups[paramName].pos] = obj[keyName];
}
return prev;
}, {});
}
return Object.keys(obj).reduce((prev, key)=>{
if (!filterLocaleItem(obj[key])) {
let normalizedKey = key;
if (matchesHasLocale) {
normalizedKey = parseInt(key, 10) - 1 + "";
}
return Object.assign(prev, {
[normalizedKey]: obj[key]
});
}
return prev;
}, {});
}
},
groups
};
}())(req.headers["x-now-route-matches"]);
}
function normalizeDynamicRouteParams(params, ignoreOptional) {
let hasValidParams = true;
if (!defaultRouteRegex) return {
params,
hasValidParams: false
};
params = Object.keys(defaultRouteRegex.groups).reduce((prev, key)=>{
let value = params[key];
if (typeof value === "string") {
value = (0, _appPaths).normalizeRscPath(value, true);
}
if (Array.isArray(value)) {
value = value.map((val)=>{
if (typeof val === "string") {
val = (0, _appPaths).normalizeRscPath(val, true);
}
return val;
});
}
// if the value matches the default value we can't rely
// on the parsed params, this is used to signal if we need
// to parse x-now-route-matches or not
const defaultValue = defaultRouteMatches[key];
const isOptional = defaultRouteRegex.groups[key].optional;
const isDefaultValue = Array.isArray(defaultValue) ? defaultValue.some((defaultVal)=>{
return Array.isArray(value) ? value.some((val)=>val.includes(defaultVal)) : value == null ? void 0 : value.includes(defaultVal);
}) : value == null ? void 0 : value.includes(defaultValue);
if (isDefaultValue || typeof value === "undefined" && !(isOptional && ignoreOptional)) {
hasValidParams = false;
}
// non-provided optional values should be undefined so normalize
// them to undefined
if (isOptional && (!value || Array.isArray(value) && value.length === 1 && // fallback optional catch-all SSG pages have
// [[...paramName]] for the root path on Vercel
(value[0] === "index" || value[0] === `[[...${key}]]`))) {
value = undefined;
delete params[key];
}
// query values from the proxy aren't already split into arrays
// so make sure to normalize catch-all values
if (value && typeof value === "string" && defaultRouteRegex.groups[key].repeat) {
value = value.split("/");
}
if (value) {
prev[key] = value;
}
return prev;
}, {});
return {
params,
hasValidParams
};
}
function handleLocale(req, res, parsedUrl, routeNoAssetPath, shouldNotRedirect) {
if (!i18n) return;
const pathname = parsedUrl.pathname || "/";
let defaultLocale = i18n.defaultLocale;
let detectedLocale = (0, _detectLocaleCookie).detectLocaleCookie(req, i18n.locales);
let acceptPreferredLocale;
try {
acceptPreferredLocale = i18n.localeDetection !== false ? (0, _acceptHeader).acceptLanguage(req.headers["accept-language"], i18n.locales) : detectedLocale;
} catch (_) {
acceptPreferredLocale = detectedLocale;
}
const { host } = req.headers || {};
// remove port from host and remove port if present
const hostname = host && host.split(":")[0].toLowerCase();
const detectedDomain = (0, _detectDomainLocale).detectDomainLocale(i18n.domains, hostname);
if (detectedDomain) {
defaultLocale = detectedDomain.defaultLocale;
detectedLocale = defaultLocale;
(0, _requestMeta).addRequestMeta(req, "__nextIsLocaleDomain", true);
}
// if not domain specific locale use accept-language preferred
detectedLocale = detectedLocale || acceptPreferredLocale;
let localeDomainRedirect;
const localePathResult = (0, _normalizeLocalePath).normalizeLocalePath(pathname, i18n.locales);
routeNoAssetPath = (0, _normalizeLocalePath).normalizeLocalePath(routeNoAssetPath, i18n.locales).pathname;
if (localePathResult.detectedLocale) {
detectedLocale = localePathResult.detectedLocale;
req.url = (0, _url).format({
...parsedUrl,
pathname: localePathResult.pathname
});
(0, _requestMeta).addRequestMeta(req, "__nextStrippedLocale", true);
parsedUrl.pathname = localePathResult.pathname;
}
// If a detected locale is a domain specific locale and we aren't already
// on that domain and path prefix redirect to it to prevent duplicate
// content from multiple domains
if (detectedDomain) {
const localeToCheck = localePathResult.detectedLocale ? detectedLocale : acceptPreferredLocale;
const matchedDomain = (0, _detectDomainLocale).detectDomainLocale(i18n.domains, undefined, localeToCheck);
if (matchedDomain && matchedDomain.domain !== detectedDomain.domain) {
localeDomainRedirect = `http${matchedDomain.http ? "" : "s"}://${matchedDomain.domain}/${localeToCheck === matchedDomain.defaultLocale ? "" : localeToCheck}`;
}
}
const denormalizedPagePath = (0, _denormalizePagePath).denormalizePagePath(pathname);
const detectedDefaultLocale = !detectedLocale || detectedLocale.toLowerCase() === defaultLocale.toLowerCase();
const shouldStripDefaultLocale = false;
// detectedDefaultLocale &&
// denormalizedPagePath.toLowerCase() === \`/\${i18n.defaultLocale.toLowerCase()}\`
const shouldAddLocalePrefix = !detectedDefaultLocale && denormalizedPagePath === "/";
detectedLocale = detectedLocale || i18n.defaultLocale;
if (!shouldNotRedirect && !req.headers[vercelHeader] && i18n.localeDetection !== false && (localeDomainRedirect || shouldAddLocalePrefix || shouldStripDefaultLocale)) {
// set the NEXT_LOCALE cookie when a user visits the default locale
// with the locale prefix so that they aren't redirected back to
// their accept-language preferred locale
if (shouldStripDefaultLocale && acceptPreferredLocale !== defaultLocale) {
const previous = res.getHeader("set-cookie");
res.setHeader("set-cookie", [
...typeof previous === "string" ? [
previous
] : Array.isArray(previous) ? previous : [],
_cookie.default.serialize("NEXT_LOCALE", defaultLocale, {
httpOnly: true,
path: "/"
}),
]);
}
res.setHeader("Location", (0, _url).format({
// make sure to include any query values when redirecting
...parsedUrl,
pathname: localeDomainRedirect ? localeDomainRedirect : shouldStripDefaultLocale ? basePath || "/" : `${basePath}/${detectedLocale}`
}));
res.statusCode = _constants.TEMPORARY_REDIRECT_STATUS;
res.end();
return;
}
detectedLocale = localePathResult.detectedLocale || detectedDomain && detectedDomain.defaultLocale || defaultLocale;
return {
defaultLocale,
detectedLocale,
routeNoAssetPath
};
}
return {
handleLocale,
handleRewrites,
handleBasePath,
defaultRouteRegex,
dynamicRouteMatcher,
defaultRouteMatches,
getParamsFromRouteMatches,
normalizeDynamicRouteParams,
normalizeVercelUrl: (req, trustQuery, paramKeys)=>normalizeVercelUrl(req, trustQuery, paramKeys, pageIsDynamic, defaultRouteRegex),
interpolateDynamicPath: (pathname, params)=>interpolateDynamicPath(pathname, params, defaultRouteRegex)
};
}
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,214 @@
"use strict";
var _path = _interopRequireDefault(require("path"));
var _isEqualLocals = _interopRequireDefault(require("./runtime/isEqualLocals"));
var _stringifyRequest = require("../../stringify-request");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const loaderApi = ()=>{};
loaderApi.pitch = function loader(request) {
const loaderSpan = this.currentTraceSpan.traceChild("next-style-loader");
return loaderSpan.traceFn(()=>{
const options = this.getOptions();
const insert = typeof options.insert === "undefined" ? '"head"' : typeof options.insert === "string" ? JSON.stringify(options.insert) : options.insert.toString();
const injectType = options.injectType || "styleTag";
const esModule = typeof options.esModule !== "undefined" ? options.esModule : false;
delete options.esModule;
switch(injectType){
case "linkTag":
{
const hmrCode = this.hot ? `
if (module.hot) {
module.hot.accept(
${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)},
function() {
${esModule ? "update(content);" : `content = require(${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;
update(content);`}
}
);
module.hot.dispose(function() {
update();
});
}` : "";
return `${esModule ? `import api from ${(0, _stringifyRequest).stringifyRequest(this, `!${_path.default.join(__dirname, "runtime/injectStylesIntoLinkTag.js")}`)};
import content from ${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)};` : `var api = require(${(0, _stringifyRequest).stringifyRequest(this, `!${_path.default.join(__dirname, "runtime/injectStylesIntoLinkTag.js")}`)});
var content = require(${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;`}
var options = ${JSON.stringify(options)};
options.insert = ${insert};
var update = api(content, options);
${hmrCode}
${esModule ? "export default {}" : ""}`;
}
case "lazyStyleTag":
case "lazySingletonStyleTag":
{
const isSingleton = injectType === "lazySingletonStyleTag";
const hmrCode = this.hot ? `
if (module.hot) {
if (!content.locals || module.hot.invalidate) {
var isEqualLocals = ${_isEqualLocals.default.toString()};
var oldLocals = content.locals;
module.hot.accept(
${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)},
function () {
${esModule ? `if (!isEqualLocals(oldLocals, content.locals)) {
module.hot.invalidate();
return;
}
oldLocals = content.locals;
if (update && refs > 0) {
update(content);
}` : `content = require(${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;
if (!isEqualLocals(oldLocals, content.locals)) {
module.hot.invalidate();
return;
}
oldLocals = content.locals;
if (update && refs > 0) {
update(content);
}`}
}
)
}
module.hot.dispose(function() {
if (update) {
update();
}
});
}` : "";
return `${esModule ? `import api from ${(0, _stringifyRequest).stringifyRequest(this, `!${_path.default.join(__dirname, "runtime/injectStylesIntoStyleTag.js")}`)};
import content from ${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)};` : `var api = require(${(0, _stringifyRequest).stringifyRequest(this, `!${_path.default.join(__dirname, "runtime/injectStylesIntoStyleTag.js")}`)});
var content = require(${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;
if (typeof content === 'string') {
content = [[module.id, content, '']];
}`}
var refs = 0;
var update;
var options = ${JSON.stringify(options)};
options.insert = ${insert};
options.singleton = ${isSingleton};
var exported = {};
exported.locals = content.locals || {};
exported.use = function() {
if (!(refs++)) {
update = api(content, options);
}
return exported;
};
exported.unuse = function() {
if (refs > 0 && !--refs) {
update();
update = null;
}
};
${hmrCode}
${esModule ? "export default" : "module.exports ="} exported;`;
}
case "styleTag":
case "singletonStyleTag":
default:
{
const isSingleton = injectType === "singletonStyleTag";
const hmrCode = this.hot ? `
if (module.hot) {
if (!content.locals || module.hot.invalidate) {
var isEqualLocals = ${_isEqualLocals.default.toString()};
var oldLocals = content.locals;
module.hot.accept(
${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)},
function () {
${esModule ? `if (!isEqualLocals(oldLocals, content.locals)) {
module.hot.invalidate();
return;
}
oldLocals = content.locals;
update(content);` : `content = require(${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;
if (typeof content === 'string') {
content = [[module.id, content, '']];
}
if (!isEqualLocals(oldLocals, content.locals)) {
module.hot.invalidate();
return;
}
oldLocals = content.locals;
update(content);`}
}
)
}
module.hot.dispose(function() {
update();
});
}` : "";
return `${esModule ? `import api from ${(0, _stringifyRequest).stringifyRequest(this, `!${_path.default.join(__dirname, "runtime/injectStylesIntoStyleTag.js")}`)};
import content from ${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)};` : `var api = require(${(0, _stringifyRequest).stringifyRequest(this, `!${_path.default.join(__dirname, "runtime/injectStylesIntoStyleTag.js")}`)});
var content = require(${(0, _stringifyRequest).stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;
if (typeof content === 'string') {
content = [[module.id, content, '']];
}`}
var options = ${JSON.stringify(options)};
options.insert = ${insert};
options.singleton = ${isSingleton};
var update = api(content, options);
${hmrCode}
${esModule ? "export default" : "module.exports ="} content.locals || {};`;
}
}
});
};
module.exports = loaderApi;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-style-loader/index.js"],"names":["loaderApi","pitch","loader","request","loaderSpan","currentTraceSpan","traceChild","traceFn","options","getOptions","insert","JSON","stringify","toString","injectType","esModule","hmrCode","hot","stringifyRequest","path","join","__dirname","isSingleton","isEqualLocals","module","exports"],"mappings":"AAAA;AAAiB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACG,IAAA,cAAyB,kCAAzB,yBAAyB,EAAA;AAClB,IAAA,iBAAyB,WAAzB,yBAAyB,CAAA;;;;;;AAE1D,MAAMA,SAAS,GAAG,IAAM,EAAE;AAE1BA,SAAS,CAACC,KAAK,GAAG,SAASC,MAAM,CAACC,OAAO,EAAE;IACzC,MAAMC,UAAU,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CAAC,mBAAmB,CAAC;IAExE,OAAOF,UAAU,CAACG,OAAO,CAAC,IAAM;QAC9B,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,EAAE;QAEjC,MAAMC,MAAM,GACV,OAAOF,OAAO,CAACE,MAAM,KAAK,WAAW,GAC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gB,AAAsB,CAAA,iBAAtB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAEf,OAAO,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;8BAgB5C,CAAC,CACtB;;;;;;;;CAQR,CAAC,GACU,EAAE;oBAEN,OAAO,CAAC,EACNY,QAAQ,GACJ,CAAC,gBAAgB,EAAEG,CAAAA,GAAAA,iBAAgB,AAMlC,CAAA,iBANkC,CACjC,IAAI,EACJ,CAAC,CAAC,EAAEC,KAAI,QAAA,CAACC,IAAI,CACXC,SAAS,EACT,qCAAqC,CACtC,CAAC,CAAC,CACJ,CAAC;gCACgB,EAAEH,CAAAA,GAAAA,iBAAgB,AAAsB,CAAA,iBAAtB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAEf,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC7D,CAAC,kBAAkB,EAAEe,CAAAA,GAAAA,iBAAgB,AAMpC,CAAA,iBANoC,CACnC,IAAI,EACJ,CAAC,CAAC,EAAEC,KAAI,QAAA,CAACC,IAAI,CACXC,SAAS,EACT,qCAAqC,CACtC,CAAC,CAAC,CACJ,CAAC;kCACkB,EAAEH,CAAAA,GAAAA,iBAAgB,AAAsB,CAAA,iBAAtB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAEf,OAAO,CAAC,CAAC,CAAC,CAAC;;;;;;aAM9D,CAAC,CACL;;cAEK,EAAEQ,IAAI,CAACC,SAAS,CAACJ,OAAO,CAAC,CAAC;;iBAEvB,EAAEE,MAAM,CAAC;oBACN,EAAEY,WAAW,CAAC;;;;AAIlC,EAAEN,OAAO,CAAC;;AAEV,EAAED,QAAQ,GAAG,gBAAgB,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAA;iBACnE;SACF;KACF,CAAC,CAAA;CACH;AAEDS,MAAM,CAACC,OAAO,GAAGzB,SAAS"}

View File

@@ -0,0 +1,57 @@
"use strict";
const getTarget = function getTarget() {
const memo = {};
return function memorize(target) {
if (typeof memo[target] === "undefined") {
let styleTarget = document.querySelector(target);
// Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
};
}();
module.exports = (url, options)=>{
options = options || {};
options.attributes = typeof options.attributes === "object" ? options.attributes : {};
if (typeof options.attributes.nonce === "undefined") {
const nonce = // eslint-disable-next-line no-undef
typeof __webpack_nonce__ !== "undefined" ? __webpack_nonce__ : null;
if (nonce) {
options.attributes.nonce = nonce;
}
}
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = url;
Object.keys(options.attributes).forEach((key)=>{
link.setAttribute(key, options.attributes[key]);
});
if (typeof options.insert === "function") {
options.insert(link);
} else {
const target = getTarget(options.insert || "head");
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(link);
}
return (newUrl)=>{
if (typeof newUrl === "string") {
link.href = newUrl;
} else {
link.parentNode.removeChild(link);
}
};
};
//# sourceMappingURL=injectStylesIntoLinkTag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/next-style-loader/runtime/injectStylesIntoLinkTag.js"],"names":["getTarget","memo","memorize","target","styleTarget","document","querySelector","window","HTMLIFrameElement","contentDocument","head","e","module","exports","url","options","attributes","nonce","__webpack_nonce__","link","createElement","rel","href","Object","keys","forEach","key","setAttribute","insert","Error","appendChild","newUrl","parentNode","removeChild"],"mappings":"AAAA;AAAA,MAAMA,SAAS,GAAG,AAAC,SAASA,SAAS,GAAG;IACtC,MAAMC,IAAI,GAAG,EAAE;IAEf,OAAO,SAASC,QAAQ,CAACC,MAAM,EAAE;QAC/B,IAAI,OAAOF,IAAI,CAACE,MAAM,CAAC,KAAK,WAAW,EAAE;YACvC,IAAIC,WAAW,GAAGC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OAAOX,OAAO,CAACa,MAAM,KAAK,UAAU,EAAE;QACxCb,OAAO,CAACa,MAAM,CAACT,IAAI,CAAC;KACrB,MAAM;QACL,MAAMhB,MAAM,GAAGH,SAAS,CAACe,OAAO,CAACa,MAAM,IAAI,MAAM,CAAC;QAElD,IAAI,CAACzB,MAAM,EAAE;YACX,MAAM,IAAI0B,KAAK,CACb,yGAAyG,CAC1G,CAAA;SACF;QAED1B,MAAM,CAAC2B,WAAW,CAACX,IAAI,CAAC;KACzB;IAED,OAAO,CAACY,MAAM,GAAK;QACjB,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;YAC9BZ,IAAI,CAACG,IAAI,GAAGS,MAAM;SACnB,MAAM;YACLZ,IAAI,CAACa,UAAU,CAACC,WAAW,CAACd,IAAI,CAAC;SAClC;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,217 @@
"use strict";
const isOldIE = function isOldIE() {
let memo;
return function memorize() {
if (typeof memo === "undefined") {
// Test for IE <= 9 as proposed by Browserhacks
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
// Tests for existence of standard globals is to allow style-loader
// to operate correctly into non-standard environments
// @see https://github.com/webpack-contrib/style-loader/issues/177
memo = Boolean(window && document && document.all && !window.atob);
}
return memo;
};
}();
const getTarget = function getTarget() {
const memo = {};
return function memorize(target) {
if (typeof memo[target] === "undefined") {
let styleTarget = document.querySelector(target);
// Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
};
}();
const stylesInDom = [];
function getIndexByIdentifier(identifier) {
let result = -1;
for(let i = 0; i < stylesInDom.length; i++){
if (stylesInDom[i].identifier === identifier) {
result = i;
break;
}
}
return result;
}
function modulesToDom(list, options) {
const idCountMap = {};
const identifiers = [];
for(let i = 0; i < list.length; i++){
const item = list[i];
const id = options.base ? item[0] + options.base : item[0];
const count = idCountMap[id] || 0;
const identifier = id + " " + count.toString();
idCountMap[id] = count + 1;
const index = getIndexByIdentifier(identifier);
const obj = {
css: item[1],
media: item[2],
sourceMap: item[3]
};
if (index !== -1) {
stylesInDom[index].references++;
stylesInDom[index].updater(obj);
} else {
stylesInDom.push({
identifier: identifier,
updater: addStyle(obj, options),
references: 1
});
}
identifiers.push(identifier);
}
return identifiers;
}
function insertStyleElement(options) {
const style = document.createElement("style");
const attributes = options.attributes || {};
if (typeof attributes.nonce === "undefined") {
const nonce = // eslint-disable-next-line no-undef
typeof __webpack_nonce__ !== "undefined" ? __webpack_nonce__ : null;
if (nonce) {
attributes.nonce = nonce;
}
}
Object.keys(attributes).forEach(function(key) {
style.setAttribute(key, attributes[key]);
});
if (typeof options.insert === "function") {
options.insert(style);
} else {
const target = getTarget(options.insert || "head");
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(style);
}
return style;
}
function removeStyleElement(style) {
// istanbul ignore if
if (style.parentNode === null) {
return false;
}
style.parentNode.removeChild(style);
}
/* istanbul ignore next */ const replaceText = function replaceText() {
const textStore = [];
return function replace(index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join("\n");
};
}();
function applyToSingletonTag(style, index, remove, obj) {
const css = remove ? "" : obj.media ? "@media " + obj.media + " {" + obj.css + "}" : obj.css;
// For old IE
/* istanbul ignore if */ if (style.styleSheet) {
style.styleSheet.cssText = replaceText(index, css);
} else {
const cssNode = document.createTextNode(css);
const childNodes = style.childNodes;
if (childNodes[index]) {
style.removeChild(childNodes[index]);
}
if (childNodes.length) {
style.insertBefore(cssNode, childNodes[index]);
} else {
style.appendChild(cssNode);
}
}
}
function applyToTag(style, options, obj) {
let css = obj.css;
const media = obj.media;
const sourceMap = obj.sourceMap;
if (media) {
style.setAttribute("media", media);
} else {
style.removeAttribute("media");
}
if (sourceMap && typeof btoa !== "undefined") {
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
// For old IE
/* istanbul ignore if */ if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
while(style.firstChild){
style.removeChild(style.firstChild);
}
style.appendChild(document.createTextNode(css));
}
}
let singleton = null;
let singletonCounter = 0;
function addStyle(obj, options) {
let style;
let update;
let remove;
if (options.singleton) {
const styleIndex = singletonCounter++;
style = singleton || (singleton = insertStyleElement(options));
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
} else {
style = insertStyleElement(options);
update = applyToTag.bind(null, style, options);
remove = function() {
removeStyleElement(style);
};
}
update(obj);
return function updateStyle(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
return;
}
update(obj = newObj);
} else {
remove();
}
};
}
module.exports = function(list, options) {
options = options || {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (!options.singleton && typeof options.singleton !== "boolean") {
options.singleton = isOldIE();
}
list = list || [];
let lastIdentifiers = modulesToDom(list, options);
return function update(newList) {
newList = newList || [];
if (Object.prototype.toString.call(newList) !== "[object Array]") {
return;
}
for(let i = 0; i < lastIdentifiers.length; i++){
const identifier = lastIdentifiers[i];
const index = getIndexByIdentifier(identifier);
stylesInDom[index].references--;
}
const newLastIdentifiers = modulesToDom(newList, options);
for(let i1 = 0; i1 < lastIdentifiers.length; i1++){
const identifier = lastIdentifiers[i1];
const index = getIndexByIdentifier(identifier);
if (stylesInDom[index].references === 0) {
stylesInDom[index].updater();
stylesInDom.splice(index, 1);
}
}
lastIdentifiers = newLastIdentifiers;
};
};
//# sourceMappingURL=injectStylesIntoStyleTag.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,27 @@
"use strict";
function isEqualLocals(a, b, isNamedExport) {
if (!a && b || a && !b) {
return false;
}
let p;
for(p in a){
if (isNamedExport && p === "default") {
continue;
}
if (a[p] !== b[p]) {
return false;
}
}
for(p in b){
if (isNamedExport && p === "default") {
continue;
}
if (!a[p]) {
return false;
}
}
return true;
}
module.exports = isEqualLocals;
//# sourceMappingURL=isEqualLocals.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/next-style-loader/runtime/isEqualLocals.js"],"names":["isEqualLocals","a","b","isNamedExport","p","module","exports"],"mappings":"AAAA;AAAA,SAASA,aAAa,CAACC,CAAC,EAAEC,CAAC,EAAEC,aAAa,EAAE;IAC1C,IAAI,AAAC,CAACF,CAAC,IAAIC,CAAC,IAAMD,CAAC,IAAI,CAACC,CAAC,AAAC,EAAE;QAC1B,OAAO,KAAK,CAAA;KACb;IAED,IAAIE,CAAC;IAEL,IAAKA,CAAC,IAAIH,CAAC,CAAE;QACX,IAAIE,aAAa,IAAIC,CAAC,KAAK,SAAS,EAAE;YAEpC,SAAQ;SACT;QAED,IAAIH,CAAC,CAACG,CAAC,CAAC,KAAKF,CAAC,CAACE,CAAC,CAAC,EAAE;YACjB,OAAO,KAAK,CAAA;SACb;KACF;IAED,IAAKA,CAAC,IAAIF,CAAC,CAAE;QACX,IAAIC,aAAa,IAAIC,CAAC,KAAK,SAAS,EAAE;YAEpC,SAAQ;SACT;QAED,IAAI,CAACH,CAAC,CAACG,CAAC,CAAC,EAAE;YACT,OAAO,KAAK,CAAA;SACb;KACF;IAED,OAAO,IAAI,CAAA;CACZ;AAEDC,MAAM,CAACC,OAAO,GAAGN,aAAa"}

View File

@@ -0,0 +1,132 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = swcLoader;
exports.pitch = pitch;
exports.raw = void 0;
var _swc = require("../../swc");
var _options = require("../../swc/options");
var _path = _interopRequireWildcard(require("path"));
function swcLoader(inputSource, inputSourceMap) {
const loaderSpan = this.currentTraceSpan.traceChild("next-swc-loader");
const callback = this.async();
loaderSpan.traceAsyncFn(()=>loaderTransform.call(this, loaderSpan, inputSource, inputSourceMap)).then(([transformedSource, outputSourceMap])=>{
callback(null, transformedSource, outputSourceMap || inputSourceMap);
}, (err)=>{
callback(err);
});
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
async function loaderTransform(parentTrace, source, inputSourceMap) {
// Make the loader async
const filename = this.resourcePath;
let loaderOptions = this.getOptions() || {};
const { isServer , isServerLayer , rootDir , pagesDir , hasReactRefresh , nextConfig , jsConfig , supportedBrowsers , swcCacheDir , hasServerComponents , } = loaderOptions;
const isPageFile = filename.startsWith(pagesDir);
const relativeFilePathFromRoot = _path.default.relative(rootDir, filename);
const swcOptions = (0, _options).getLoaderSWCOptions({
pagesDir,
filename,
isServer,
isServerLayer,
isPageFile,
development: this.mode === "development",
hasReactRefresh,
nextConfig,
jsConfig,
supportedBrowsers,
swcCacheDir,
relativeFilePathFromRoot,
hasServerComponents
});
const programmaticOptions = {
...swcOptions,
filename,
inputSourceMap: inputSourceMap ? JSON.stringify(inputSourceMap) : undefined,
// Set the default sourcemap behavior based on Webpack's mapping flag,
sourceMaps: this.sourceMap,
inlineSourcesContent: this.sourceMap,
// Ensure that Webpack will get a full absolute path in the sourcemap
// so that it can properly map the module back to its internal cached
// modules.
sourceFileName: filename
};
if (!programmaticOptions.inputSourceMap) {
delete programmaticOptions.inputSourceMap;
}
// auto detect development mode
if (this.mode && programmaticOptions.jsc && programmaticOptions.jsc.transform && programmaticOptions.jsc.transform.react && !Object.prototype.hasOwnProperty.call(programmaticOptions.jsc.transform.react, "development")) {
programmaticOptions.jsc.transform.react.development = this.mode === "development";
}
const swcSpan = parentTrace.traceChild("next-swc-transform");
return swcSpan.traceAsyncFn(()=>(0, _swc).transform(source, programmaticOptions).then((output)=>{
if (output.eliminatedPackages && this.eliminatedPackages) {
for (const pkg of JSON.parse(output.eliminatedPackages)){
this.eliminatedPackages.add(pkg);
}
}
return [
output.code,
output.map ? JSON.parse(output.map) : undefined
];
}));
}
const EXCLUDED_PATHS = /[\\/](cache[\\/][^\\/]+\.zip[\\/]node_modules|__virtual__)[\\/]/g;
function pitch() {
const callback = this.async();
(async ()=>{
let loaderOptions = this.getOptions() || {};
if (// TODO: investigate swc file reading in PnP mode?
!process.versions.pnp && loaderOptions.fileReading && !EXCLUDED_PATHS.test(this.resourcePath) && this.loaders.length - 1 === this.loaderIndex && (0, _path).isAbsolute(this.resourcePath) && !await (0, _swc).isWasm()) {
const loaderSpan = this.currentTraceSpan.traceChild("next-swc-loader");
this.addDependency(this.resourcePath);
return loaderSpan.traceAsyncFn(()=>loaderTransform.call(this, loaderSpan));
}
})().then((r)=>{
if (r) return callback(null, ...r);
callback();
}, callback);
}
const raw = true;
exports.raw = raw;
//# sourceMappingURL=next-swc-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-swc-loader.js"],"names":["swcLoader","pitch","inputSource","inputSourceMap","loaderSpan","currentTraceSpan","traceChild","callback","async","traceAsyncFn","loaderTransform","call","then","transformedSource","outputSourceMap","err","parentTrace","source","filename","resourcePath","loaderOptions","getOptions","isServer","isServerLayer","rootDir","pagesDir","hasReactRefresh","nextConfig","jsConfig","supportedBrowsers","swcCacheDir","hasServerComponents","isPageFile","startsWith","relativeFilePathFromRoot","path","relative","swcOptions","getLoaderSWCOptions","development","mode","programmaticOptions","JSON","stringify","undefined","sourceMaps","sourceMap","inlineSourcesContent","sourceFileName","jsc","transform","react","Object","prototype","hasOwnProperty","swcSpan","output","eliminatedPackages","pkg","parse","add","code","map","EXCLUDED_PATHS","process","versions","pnp","fileReading","test","loaders","length","loaderIndex","isAbsolute","isWasm","addDependency","r","raw"],"mappings":"AA4BA;;;;kBAoHwBA,SAAS;QAzBjBC,KAAK,GAALA,KAAK;;AA3Fa,IAAA,IAAW,WAAX,WAAW,CAAA;AACT,IAAA,QAAmB,WAAnB,mBAAmB,CAAA;AACtB,IAAA,KAAM,mCAAN,MAAM,EAAA;AAkHxB,SAASD,SAAS,CAACE,WAAW,EAAEC,cAAc,EAAE;IAC7D,MAAMC,UAAU,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CAAC,iBAAiB,CAAC;IACtE,MAAMC,QAAQ,GAAG,IAAI,CAACC,KAAK,EAAE;IAC7BJ,UAAU,CACPK,YAAY,CAAC,IACZC,eAAe,CAACC,IAAI,CAAC,IAAI,EAAEP,UAAU,EAAEF,WAAW,EAAEC,cAAc,CAAC,CACpE,CACAS,IAAI,CACH,CAAC,CAACC,iBAAiB,EAAEC,eAAe,CAAC,GAAK;QACxCP,QAAQ,CAAC,IAAI,EAAEM,iBAAiB,EAAEC,eAAe,IAAIX,cAAc,CAAC;KACrE,EACD,CAACY,GAAG,GAAK;QACPR,QAAQ,CAACQ,GAAG,CAAC;KACd,CACF;CACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA/HD,eAAeL,eAAe,CAACM,WAAW,EAAEC,MAAM,EAAEd,cAAc,EAAE;IAClE,wBAAwB;IACxB,MAAMe,QAAQ,GAAG,IAAI,CAACC,YAAY;IAElC,IAAIC,aAAa,GAAG,IAAI,CAACC,UAAU,EAAE,IAAI,EAAE;IAE3C,MAAM,EACJC,Q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AI,CAACkD,OAAO,CAACC,MAAM,GAAG,CAAC,KAAK,IAAI,CAACC,WAAW,IAC5CC,CAAAA,GAAAA,KAAU,AAAmB,CAAA,WAAnB,CAAC,IAAI,CAACrD,YAAY,CAAC,IAC7B,CAAE,MAAMsD,CAAAA,GAAAA,IAAM,AAAE,CAAA,OAAF,EAAE,AAAC,EACjB;YACA,MAAMrE,UAAU,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CAAC,iBAAiB,CAAC;YACtE,IAAI,CAACoE,aAAa,CAAC,IAAI,CAACvD,YAAY,CAAC;YACrC,OAAOf,UAAU,CAACK,YAAY,CAAC,IAC7BC,eAAe,CAACC,IAAI,CAAC,IAAI,EAAEP,UAAU,CAAC,CACvC,CAAA;SACF;KACF,CAAC,EAAE,CAACQ,IAAI,CAAC,CAAC+D,CAAC,GAAK;QACf,IAAIA,CAAC,EAAE,OAAOpE,QAAQ,CAAC,IAAI,KAAKoE,CAAC,CAAC,CAAA;QAClCpE,QAAQ,EAAE;KACX,EAAEA,QAAQ,CAAC;CACb;AAoBM,MAAMqE,GAAG,GAAG,IAAI;QAAVA,GAAG,GAAHA,GAAG"}

View File

@@ -0,0 +1,3 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
declare const NoopLoader: webpack.LoaderDefinitionFunction;
export default NoopLoader;

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const NoopLoader = (source)=>source;
var _default = NoopLoader;
exports.default = _default;
//# sourceMappingURL=noop-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/noop-loader.ts"],"names":["NoopLoader","source"],"mappings":"AAAA;;;;;AAEA,MAAMA,UAAU,GAAqC,CAACC,MAAM,GAAKA,MAAM;eACxDD,UAAU"}

View File

@@ -0,0 +1,32 @@
"use strict";
/**
* **PostCSS Syntax Error**
*
* Loader wrapper for postcss syntax errors
*
* @class SyntaxError
* @extends Error
*
* @param {Object} err CssSyntaxError
*/ class SyntaxError extends Error {
constructor(error){
super(error);
const { line , column , reason , plugin , file } = error;
this.name = "SyntaxError";
this.message = `${this.name}\n\n`;
if (typeof line !== "undefined") {
this.message += `(${line}:${column}) `;
}
this.message += plugin ? `${plugin}: ` : "";
this.message += file ? `${file} ` : "<css input> ";
this.message += `${reason}`;
const code = error.showSourceCode();
if (code) {
this.message += `\n\n${code}\n`;
}
this.stack = false;
}
}
module.exports = SyntaxError;
//# sourceMappingURL=Error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/postcss-loader/src/Error.js"],"names":["SyntaxError","Error","constructor","error","line","column","reason","plugin","file","name","message","code","showSourceCode","stack","module","exports"],"mappings":"AAUA;AAVA;;;;;;;;;GASG,CACH,MAAMA,WAAW,SAASC,KAAK;IAC7BC,YAAYC,KAAK,CAAE;QACjB,KAAK,CAACA,KAAK,CAAC;QAEZ,MAAM,EAAEC,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAEC,IAAI,CAAA,EAAE,GAAGL,KAAK;QAEpD,IAAI,CAACM,IAAI,GAAG,aAAa;QAEzB,IAAI,CAACC,OAAO,GAAG,CAAC,EAAE,IAAI,CAACD,IAAI,CAAC,IAAI,CAAC;QAEjC,IAAI,OAAOL,IAAI,KAAK,WAAW,EAAE;YAC/B,IAAI,CAACM,OAAO,IAAI,CAAC,CAAC,EAAEN,IAAI,CAAC,CAAC,EAAEC,MAAM,CAAC,EAAE,CAAC;SACvC;QAED,IAAI,CAACK,OAAO,IAAIH,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE;QAC3C,IAAI,CAACG,OAAO,IAAIF,IAAI,GAAG,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,GAAG,cAAc;QAClD,IAAI,CAACE,OAAO,IAAI,CAAC,EAAEJ,MAAM,CAAC,CAAC;QAE3B,MAAMK,IAAI,GAAGR,KAAK,CAACS,cAAc,EAAE;QAEnC,IAAID,IAAI,EAAE;YACR,IAAI,CAACD,OAAO,IAAI,CAAC,IAAI,EAAEC,IAAI,CAAC,EAAE,CAAC;SAChC;QAED,IAAI,CAACE,KAAK,GAAG,KAAK;KACnB;CACF;AAEDC,MAAM,CAACC,OAAO,GAAGf,WAAW"}

View File

@@ -0,0 +1,27 @@
"use strict";
/**
* **PostCSS Plugin Warning**
*
* Loader wrapper for postcss plugin warnings (`root.messages`)
*
* @class Warning
* @extends Error
*
* @param {Object} warning PostCSS Warning
*/ class Warning extends Error {
constructor(warning){
super(warning);
const { text , line , column , plugin } = warning;
this.name = "Warning";
this.message = `${this.name}\n\n`;
if (typeof line !== "undefined") {
this.message += `(${line}:${column}) `;
}
this.message += plugin ? `${plugin}: ` : "";
this.message += `${text}`;
this.stack = false;
}
}
module.exports = Warning;
//# sourceMappingURL=Warning.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/postcss-loader/src/Warning.js"],"names":["Warning","Error","constructor","warning","text","line","column","plugin","name","message","stack","module","exports"],"mappings":"AAUA;AAVA;;;;;;;;;GASG,CACH,MAAMA,OAAO,SAASC,KAAK;IACzBC,YAAYC,OAAO,CAAE;QACnB,KAAK,CAACA,OAAO,CAAC;QAEd,MAAM,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGJ,OAAO;QAE9C,IAAI,CAACK,IAAI,GAAG,SAAS;QAErB,IAAI,CAACC,OAAO,GAAG,CAAC,EAAE,IAAI,CAACD,IAAI,CAAC,IAAI,CAAC;QAEjC,IAAI,OAAOH,IAAI,KAAK,WAAW,EAAE;YAC/B,IAAI,CAACI,OAAO,IAAI,CAAC,CAAC,EAAEJ,IAAI,CAAC,CAAC,EAAEC,MAAM,CAAC,EAAE,CAAC;SACvC;QAED,IAAI,CAACG,OAAO,IAAIF,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE;QAC3C,IAAI,CAACE,OAAO,IAAI,CAAC,EAAEL,IAAI,CAAC,CAAC;QAEzB,IAAI,CAACM,KAAK,GAAG,KAAK;KACnB;CACF;AAEDC,MAAM,CAACC,OAAO,GAAGZ,OAAO"}

Some files were not shown because too many files have changed in this diff Show More