create project
This commit is contained in:
30
kitabcitab/node_modules/next/dist/server/web/sandbox/context.d.ts
generated
vendored
Normal file
30
kitabcitab/node_modules/next/dist/server/web/sandbox/context.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference types="node" />
|
||||
import { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
|
||||
import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
|
||||
/**
|
||||
* For a given path a context, this function checks if there is any module
|
||||
* context that contains the path with an older content and, if that's the
|
||||
* case, removes the context from the cache.
|
||||
*/
|
||||
export declare function clearModuleContext(path: string, content: Buffer | string): void;
|
||||
interface ModuleContextOptions {
|
||||
moduleName: string;
|
||||
onWarning: (warn: Error) => void;
|
||||
useCache: boolean;
|
||||
env: string[];
|
||||
distDir: string;
|
||||
edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm'>;
|
||||
}
|
||||
/**
|
||||
* For a given module name this function will get a cached module
|
||||
* context or create it. It will return the module context along
|
||||
* with a function that allows to run some code from a given
|
||||
* filepath within the context.
|
||||
*/
|
||||
export declare function getModuleContext(options: ModuleContextOptions): Promise<{
|
||||
evaluateInContext: (filepath: string) => void;
|
||||
runtime: EdgeRuntime;
|
||||
paths: Map<string, string>;
|
||||
warnedEvals: Set<string>;
|
||||
}>;
|
||||
export {};
|
||||
276
kitabcitab/node_modules/next/dist/server/web/sandbox/context.js
generated
vendored
Normal file
276
kitabcitab/node_modules/next/dist/server/web/sandbox/context.js
generated
vendored
Normal file
@@ -0,0 +1,276 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.clearModuleContext = clearModuleContext;
|
||||
exports.getModuleContext = getModuleContext;
|
||||
var _asyncHooks = require("async_hooks");
|
||||
var _middleware = require("next/dist/compiled/@next/react-dev-overlay/dist/middleware");
|
||||
var _constants = require("../../../shared/lib/constants");
|
||||
var _edgeRuntime = require("next/dist/compiled/edge-runtime");
|
||||
var _fs = require("fs");
|
||||
var _utils = require("../utils");
|
||||
var _pick = require("../../../lib/pick");
|
||||
var _fetchInlineAssets = require("./fetch-inline-assets");
|
||||
const WEBPACK_HASH_REGEX = /__webpack_require__\.h = function\(\) \{ return "[0-9a-f]+"; \}/g;
|
||||
/**
|
||||
* A Map of cached module contexts indexed by the module name. It allows
|
||||
* to have a different cache scoped per module name or depending on the
|
||||
* provided module key on creation.
|
||||
*/ const moduleContexts = new Map();
|
||||
function clearModuleContext(path, content) {
|
||||
for (const [key, cache] of moduleContexts){
|
||||
var ref;
|
||||
const prev = (ref = cache == null ? void 0 : cache.paths.get(path)) == null ? void 0 : ref.replace(WEBPACK_HASH_REGEX, "");
|
||||
if (typeof prev !== "undefined" && prev !== content.toString().replace(WEBPACK_HASH_REGEX, "")) {
|
||||
moduleContexts.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function loadWasm(wasm) {
|
||||
const modules = {};
|
||||
await Promise.all(wasm.map(async (binding)=>{
|
||||
const module = await WebAssembly.compile(await _fs.promises.readFile(binding.filePath));
|
||||
modules[binding.name] = module;
|
||||
}));
|
||||
return modules;
|
||||
}
|
||||
function buildEnvironmentVariablesFrom(keys) {
|
||||
const pairs = keys.map((key)=>[
|
||||
key,
|
||||
process.env[key]
|
||||
]);
|
||||
const env = Object.fromEntries(pairs);
|
||||
env.NEXT_RUNTIME = "edge";
|
||||
return env;
|
||||
}
|
||||
function throwUnsupportedAPIError(name) {
|
||||
const error = new Error(`A Node.js API is used (${name}) which is not supported in the Edge Runtime.
|
||||
Learn more: https://nextjs.org/docs/api-reference/edge-runtime`);
|
||||
(0, _middleware).decorateServerError(error, _constants.COMPILER_NAMES.edgeServer);
|
||||
throw error;
|
||||
}
|
||||
function createProcessPolyfill(options) {
|
||||
const env = buildEnvironmentVariablesFrom(options.env);
|
||||
const processPolyfill = {
|
||||
env
|
||||
};
|
||||
const overridenValue = {};
|
||||
for (const key of Object.keys(process)){
|
||||
if (key === "env") continue;
|
||||
Object.defineProperty(processPolyfill, key, {
|
||||
get () {
|
||||
if (overridenValue[key]) {
|
||||
return overridenValue[key];
|
||||
}
|
||||
if (typeof process[key] === "function") {
|
||||
return ()=>throwUnsupportedAPIError(`process.${key}`);
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
set (value) {
|
||||
overridenValue[key] = value;
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
return processPolyfill;
|
||||
}
|
||||
function addStub(context, name) {
|
||||
Object.defineProperty(context, name, {
|
||||
get () {
|
||||
return function() {
|
||||
throwUnsupportedAPIError(name);
|
||||
};
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
function getDecorateUnhandledError(runtime) {
|
||||
const EdgeRuntimeError = runtime.evaluate(`Error`);
|
||||
return (error)=>{
|
||||
if (error instanceof EdgeRuntimeError) {
|
||||
(0, _middleware).decorateServerError(error, _constants.COMPILER_NAMES.edgeServer);
|
||||
}
|
||||
};
|
||||
}
|
||||
function getDecorateUnhandledRejection(runtime) {
|
||||
const EdgeRuntimeError = runtime.evaluate(`Error`);
|
||||
return (rejected)=>{
|
||||
if (rejected.reason instanceof EdgeRuntimeError) {
|
||||
(0, _middleware).decorateServerError(rejected.reason, _constants.COMPILER_NAMES.edgeServer);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Create a module cache specific for the provided parameters. It includes
|
||||
* a runtime context, require cache and paths cache.
|
||||
*/ async function createModuleContext(options) {
|
||||
const warnedEvals = new Set();
|
||||
const warnedWasmCodegens = new Set();
|
||||
const wasm = await loadWasm(options.edgeFunctionEntry.wasm ?? []);
|
||||
const runtime = new _edgeRuntime.EdgeRuntime({
|
||||
codeGeneration: process.env.NODE_ENV !== "production" ? {
|
||||
strings: true,
|
||||
wasm: true
|
||||
} : undefined,
|
||||
extend: (context)=>{
|
||||
context.process = createProcessPolyfill(options);
|
||||
context.__next_eval__ = function __next_eval__(fn) {
|
||||
const key = fn.toString();
|
||||
if (!warnedEvals.has(key)) {
|
||||
const warning = (0, _middleware).getServerError(new Error(`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime
|
||||
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
|
||||
warning.name = "DynamicCodeEvaluationWarning";
|
||||
Error.captureStackTrace(warning, __next_eval__);
|
||||
warnedEvals.add(key);
|
||||
options.onWarning(warning);
|
||||
}
|
||||
return fn();
|
||||
};
|
||||
context.__next_webassembly_compile__ = function __next_webassembly_compile__(fn) {
|
||||
const key = fn.toString();
|
||||
if (!warnedWasmCodegens.has(key)) {
|
||||
const warning = (0, _middleware).getServerError(new Error(`Dynamic WASM code generation (e. g. 'WebAssembly.compile') not allowed in Edge Runtime.
|
||||
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
|
||||
warning.name = "DynamicWasmCodeGenerationWarning";
|
||||
Error.captureStackTrace(warning, __next_webassembly_compile__);
|
||||
warnedWasmCodegens.add(key);
|
||||
options.onWarning(warning);
|
||||
}
|
||||
return fn();
|
||||
};
|
||||
context.__next_webassembly_instantiate__ = async function __next_webassembly_instantiate__(fn) {
|
||||
const result = await fn();
|
||||
// If a buffer is given, WebAssembly.instantiate returns an object
|
||||
// containing both a module and an instance while it returns only an
|
||||
// instance if a WASM module is given. Utilize the fact to determine
|
||||
// if the WASM code generation happens.
|
||||
//
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate#primary_overload_%E2%80%94_taking_wasm_binary_code
|
||||
const instantiatedFromBuffer = result.hasOwnProperty("module");
|
||||
const key = fn.toString();
|
||||
if (instantiatedFromBuffer && !warnedWasmCodegens.has(key)) {
|
||||
const warning = (0, _middleware).getServerError(new Error(`Dynamic WASM code generation ('WebAssembly.instantiate' with a buffer parameter) not allowed in Edge Runtime.
|
||||
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
|
||||
warning.name = "DynamicWasmCodeGenerationWarning";
|
||||
Error.captureStackTrace(warning, __next_webassembly_instantiate__);
|
||||
warnedWasmCodegens.add(key);
|
||||
options.onWarning(warning);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
const __fetch = context.fetch;
|
||||
context.fetch = async (input, init = {})=>{
|
||||
var ref;
|
||||
const assetResponse = await (0, _fetchInlineAssets).fetchInlineAsset({
|
||||
input,
|
||||
assets: options.edgeFunctionEntry.assets,
|
||||
distDir: options.distDir,
|
||||
context
|
||||
});
|
||||
if (assetResponse) {
|
||||
return assetResponse;
|
||||
}
|
||||
init.headers = new Headers(init.headers ?? {});
|
||||
const prevs = ((ref = init.headers.get(`x-middleware-subrequest`)) == null ? void 0 : ref.split(":")) || [];
|
||||
const value = prevs.concat(options.moduleName).join(":");
|
||||
init.headers.set("x-middleware-subrequest", value);
|
||||
if (!init.headers.has("user-agent")) {
|
||||
init.headers.set(`user-agent`, `Next.js Middleware`);
|
||||
}
|
||||
if (typeof input === "object" && "url" in input) {
|
||||
return __fetch(input.url, {
|
||||
...(0, _pick).pick(input, [
|
||||
"method",
|
||||
"body",
|
||||
"cache",
|
||||
"credentials",
|
||||
"integrity",
|
||||
"keepalive",
|
||||
"mode",
|
||||
"redirect",
|
||||
"referrer",
|
||||
"referrerPolicy",
|
||||
"signal",
|
||||
]),
|
||||
...init,
|
||||
headers: {
|
||||
...Object.fromEntries(input.headers),
|
||||
...Object.fromEntries(init.headers)
|
||||
}
|
||||
});
|
||||
}
|
||||
return __fetch(String(input), init);
|
||||
};
|
||||
const __Request = context.Request;
|
||||
context.Request = class extends __Request {
|
||||
constructor(input, init){
|
||||
const url = typeof input !== "string" && "url" in input ? input.url : String(input);
|
||||
(0, _utils).validateURL(url);
|
||||
super(url, init);
|
||||
this.next = init == null ? void 0 : init.next;
|
||||
}
|
||||
};
|
||||
const __redirect = context.Response.redirect.bind(context.Response);
|
||||
context.Response.redirect = (...args)=>{
|
||||
(0, _utils).validateURL(args[0]);
|
||||
return __redirect(...args);
|
||||
};
|
||||
for (const name of _constants.EDGE_UNSUPPORTED_NODE_APIS){
|
||||
addStub(context, name);
|
||||
}
|
||||
Object.assign(context, wasm);
|
||||
context.AsyncLocalStorage = _asyncHooks.AsyncLocalStorage;
|
||||
return context;
|
||||
}
|
||||
});
|
||||
const decorateUnhandledError = getDecorateUnhandledError(runtime);
|
||||
runtime.context.addEventListener("error", decorateUnhandledError);
|
||||
const decorateUnhandledRejection = getDecorateUnhandledRejection(runtime);
|
||||
runtime.context.addEventListener("unhandledrejection", decorateUnhandledRejection);
|
||||
return {
|
||||
runtime,
|
||||
paths: new Map(),
|
||||
warnedEvals: new Set()
|
||||
};
|
||||
}
|
||||
const pendingModuleCaches = new Map();
|
||||
function getModuleContextShared(options) {
|
||||
let deferredModuleContext = pendingModuleCaches.get(options.moduleName);
|
||||
if (!deferredModuleContext) {
|
||||
deferredModuleContext = createModuleContext(options);
|
||||
pendingModuleCaches.set(options.moduleName, deferredModuleContext);
|
||||
}
|
||||
return deferredModuleContext;
|
||||
}
|
||||
async function getModuleContext(options) {
|
||||
let moduleContext;
|
||||
if (options.useCache) {
|
||||
moduleContext = moduleContexts.get(options.moduleName) || await getModuleContextShared(options);
|
||||
}
|
||||
if (!moduleContext) {
|
||||
moduleContext = await createModuleContext(options);
|
||||
moduleContexts.set(options.moduleName, moduleContext);
|
||||
}
|
||||
const evaluateInContext = (filepath)=>{
|
||||
if (!moduleContext.paths.has(filepath)) {
|
||||
const content = (0, _fs).readFileSync(filepath, "utf-8");
|
||||
try {
|
||||
moduleContext == null ? void 0 : moduleContext.runtime.evaluate(content);
|
||||
moduleContext.paths.set(filepath, content);
|
||||
} catch (error) {
|
||||
if (options.useCache) {
|
||||
moduleContext == null ? void 0 : moduleContext.paths.delete(options.moduleName);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
...moduleContext,
|
||||
evaluateInContext
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=context.js.map
|
||||
1
kitabcitab/node_modules/next/dist/server/web/sandbox/context.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/server/web/sandbox/context.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
kitabcitab/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.d.ts
generated
vendored
Normal file
15
kitabcitab/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
|
||||
/**
|
||||
* Short-circuits the `fetch` function
|
||||
* to return a stream for a given asset, if a user used `new URL("file", import.meta.url)`.
|
||||
* This allows to embed assets in Edge Runtime.
|
||||
*/
|
||||
export declare function fetchInlineAsset(options: {
|
||||
input: RequestInfo | URL;
|
||||
distDir: string;
|
||||
assets: EdgeFunctionDefinition['assets'];
|
||||
context: {
|
||||
Response: typeof Response;
|
||||
ReadableStream: typeof ReadableStream;
|
||||
};
|
||||
}): Promise<Response | undefined>;
|
||||
28
kitabcitab/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.js
generated
vendored
Normal file
28
kitabcitab/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.fetchInlineAsset = fetchInlineAsset;
|
||||
var _fs = require("fs");
|
||||
var _bodyStreams = require("../../body-streams");
|
||||
var _path = require("path");
|
||||
async function fetchInlineAsset(options) {
|
||||
var ref;
|
||||
const inputString = String(options.input);
|
||||
if (!inputString.startsWith("blob:")) {
|
||||
return;
|
||||
}
|
||||
const hash = inputString.replace("blob:", "");
|
||||
const asset = (ref = options.assets) == null ? void 0 : ref.find((x)=>x.name === hash);
|
||||
if (!asset) {
|
||||
return;
|
||||
}
|
||||
const filePath = (0, _path).resolve(options.distDir, asset.filePath);
|
||||
const fileIsReadable = await _fs.promises.access(filePath).then(()=>true, ()=>false);
|
||||
if (fileIsReadable) {
|
||||
const readStream = (0, _fs).createReadStream(filePath);
|
||||
return new options.context.Response((0, _bodyStreams).requestToBodyStream(options.context, Uint8Array, readStream));
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=fetch-inline-assets.js.map
|
||||
1
kitabcitab/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../server/web/sandbox/fetch-inline-assets.ts"],"names":["fetchInlineAsset","options","inputString","String","input","startsWith","hash","replace","asset","assets","find","x","name","filePath","resolve","distDir","fileIsReadable","fs","access","then","readStream","createReadStream","context","Response","requestToBodyStream","Uint8Array"],"mappings":"AAAA;;;;QAUsBA,gBAAgB,GAAhBA,gBAAgB;AATW,IAAA,GAAI,WAAJ,IAAI,CAAA;AACjB,IAAA,YAAoB,WAApB,oBAAoB,CAAA;AAChC,IAAA,KAAM,WAAN,MAAM,CAAA;AAOvB,eAAeA,gBAAgB,CAACC,OAKtC,EAAiC;QAOlBA,GAAc;IAN5B,MAAMC,WAAW,GAAGC,MAAM,CAACF,OAAO,CAACG,KAAK,CAAC;IACzC,IAAI,CAACF,WAAW,CAACG,UAAU,CAAC,OAAO,CAAC,EAAE;QACpC,OAAM;KACP;IAED,MAAMC,IAAI,GAAGJ,WAAW,CAACK,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;IAC7C,MAAMC,KAAK,GAAGP,CAAAA,GAAc,GAAdA,OAAO,CAACQ,MAAM,SAAM,GAApBR,KAAAA,CAAoB,GAApBA,GAAc,CAAES,IAAI,CAAC,CAACC,CAAC,GAAKA,CAAC,CAACC,IAAI,KAAKN,IAAI,CAAC;IAC1D,IAAI,CAACE,KAAK,EAAE;QACV,OAAM;KACP;IAED,MAAMK,QAAQ,GAAGC,CAAAA,GAAAA,KAAO,AAAiC,CAAA,QAAjC,CAACb,OAAO,CAACc,OAAO,EAAEP,KAAK,CAACK,QAAQ,CAAC;IACzD,MAAMG,cAAc,GAAG,MAAMC,GAAE,SAAA,CAACC,MAAM,CAACL,QAAQ,CAAC,CAACM,IAAI,CACnD,IAAM,IAAI,EACV,IAAM,KAAK,CACZ;IAED,IAAIH,cAAc,EAAE;QAClB,MAAMI,UAAU,GAAGC,CAAAA,GAAAA,GAAgB,AAAU,CAAA,iBAAV,CAACR,QAAQ,CAAC;QAC7C,OAAO,IAAIZ,OAAO,CAACqB,OAAO,CAACC,QAAQ,CACjCC,CAAAA,GAAAA,YAAmB,AAAyC,CAAA,oBAAzC,CAACvB,OAAO,CAACqB,OAAO,EAAEG,UAAU,EAAEL,UAAU,CAAC,CAC7D,CAAA;KACF;CACF"}
|
||||
2
kitabcitab/node_modules/next/dist/server/web/sandbox/index.d.ts
generated
vendored
Normal file
2
kitabcitab/node_modules/next/dist/server/web/sandbox/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './sandbox';
|
||||
export { clearModuleContext } from './context';
|
||||
67
kitabcitab/node_modules/next/dist/server/web/sandbox/index.js
generated
vendored
Normal file
67
kitabcitab/node_modules/next/dist/server/web/sandbox/index.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
clearModuleContext: true
|
||||
};
|
||||
Object.defineProperty(exports, "clearModuleContext", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _context.clearModuleContext;
|
||||
}
|
||||
});
|
||||
var _sandbox = _interopRequireWildcard(require("./sandbox"));
|
||||
Object.keys(_sandbox).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _sandbox[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _sandbox[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _context = require("./context");
|
||||
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;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
kitabcitab/node_modules/next/dist/server/web/sandbox/index.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/server/web/sandbox/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../server/web/sandbox/index.ts"],"names":["clearModuleContext"],"mappings":"AAAA;;;;;;;+BACSA,oBAAkB;;;wBAAlBA,kBAAkB;;;+CADb,WAAW;AAAzB,YAAA,QAAyB;;;2CAAzB,QAAyB;;;;mBAAzB,QAAyB;;;EAAA;uBACU,WAAW"}
|
||||
25
kitabcitab/node_modules/next/dist/server/web/sandbox/sandbox.d.ts
generated
vendored
Normal file
25
kitabcitab/node_modules/next/dist/server/web/sandbox/sandbox.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { NodejsRequestData, FetchEventResult } from '../types';
|
||||
import { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
|
||||
import type { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
|
||||
export declare const ErrorSource: unique symbol;
|
||||
declare type RunnerFn = (params: {
|
||||
name: string;
|
||||
env: string[];
|
||||
onWarning?: (warn: Error) => void;
|
||||
paths: string[];
|
||||
request: NodejsRequestData;
|
||||
useCache: boolean;
|
||||
edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'wasm' | 'assets'>;
|
||||
distDir: string;
|
||||
}) => Promise<FetchEventResult>;
|
||||
export declare const getRuntimeContext: (params: {
|
||||
name: string;
|
||||
onWarning?: any;
|
||||
useCache: boolean;
|
||||
env: string[];
|
||||
edgeFunctionEntry: any;
|
||||
distDir: string;
|
||||
paths: string[];
|
||||
}) => Promise<EdgeRuntime<any>>;
|
||||
export declare const run: RunnerFn;
|
||||
export {};
|
||||
90
kitabcitab/node_modules/next/dist/server/web/sandbox/sandbox.js
generated
vendored
Normal file
90
kitabcitab/node_modules/next/dist/server/web/sandbox/sandbox.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.run = exports.getRuntimeContext = exports.ErrorSource = void 0;
|
||||
var _middleware = require("next/dist/compiled/@next/react-dev-overlay/dist/middleware");
|
||||
var _context = require("./context");
|
||||
var _bodyStreams = require("../../body-streams");
|
||||
const ErrorSource = Symbol("SandboxError");
|
||||
exports.ErrorSource = ErrorSource;
|
||||
const FORBIDDEN_HEADERS = [
|
||||
"content-length",
|
||||
"content-encoding",
|
||||
"transfer-encoding",
|
||||
];
|
||||
/**
|
||||
* Decorates the runner function making sure all errors it can produce are
|
||||
* tagged with `edge-server` so they can properly be rendered in dev.
|
||||
*/ function withTaggedErrors(fn) {
|
||||
return (params)=>{
|
||||
return fn(params).then((result)=>{
|
||||
var ref;
|
||||
return {
|
||||
...result,
|
||||
waitUntil: result == null ? void 0 : (ref = result.waitUntil) == null ? void 0 : ref.catch((error)=>{
|
||||
// TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.
|
||||
throw (0, _middleware).getServerError(error, "edge-server");
|
||||
})
|
||||
};
|
||||
}).catch((error)=>{
|
||||
// TODO: used COMPILER_NAMES.edgeServer instead
|
||||
throw (0, _middleware).getServerError(error, "edge-server");
|
||||
});
|
||||
};
|
||||
}
|
||||
const getRuntimeContext = async (params)=>{
|
||||
const { runtime , evaluateInContext } = await (0, _context).getModuleContext({
|
||||
moduleName: params.name,
|
||||
onWarning: params.onWarning ?? (()=>{}),
|
||||
useCache: params.useCache !== false,
|
||||
env: params.env,
|
||||
edgeFunctionEntry: params.edgeFunctionEntry,
|
||||
distDir: params.distDir
|
||||
});
|
||||
for (const paramPath of params.paths){
|
||||
evaluateInContext(paramPath);
|
||||
}
|
||||
return runtime;
|
||||
};
|
||||
exports.getRuntimeContext = getRuntimeContext;
|
||||
const run = withTaggedErrors(async (params)=>{
|
||||
var ref;
|
||||
const runtime = await getRuntimeContext(params);
|
||||
const subreq = params.request.headers[`x-middleware-subrequest`];
|
||||
const subrequests = typeof subreq === "string" ? subreq.split(":") : [];
|
||||
if (subrequests.includes(params.name)) {
|
||||
return {
|
||||
waitUntil: Promise.resolve(),
|
||||
response: new runtime.context.Response(null, {
|
||||
headers: {
|
||||
"x-middleware-next": "1"
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
const edgeFunction = runtime.context._ENTRIES[`middleware_${params.name}`].default;
|
||||
const cloned = ![
|
||||
"HEAD",
|
||||
"GET"
|
||||
].includes(params.request.method) ? (ref = params.request.body) == null ? void 0 : ref.cloneBodyStream() : undefined;
|
||||
const KUint8Array = runtime.evaluate("Uint8Array");
|
||||
try {
|
||||
const result = await edgeFunction({
|
||||
request: {
|
||||
...params.request,
|
||||
body: cloned && (0, _bodyStreams).requestToBodyStream(runtime.context, KUint8Array, cloned)
|
||||
}
|
||||
});
|
||||
for (const headerName of FORBIDDEN_HEADERS){
|
||||
result.response.headers.delete(headerName);
|
||||
}
|
||||
return result;
|
||||
} finally{
|
||||
var ref1;
|
||||
await ((ref1 = params.request.body) == null ? void 0 : ref1.finalize());
|
||||
}
|
||||
});
|
||||
exports.run = run;
|
||||
|
||||
//# sourceMappingURL=sandbox.js.map
|
||||
1
kitabcitab/node_modules/next/dist/server/web/sandbox/sandbox.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/server/web/sandbox/sandbox.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../server/web/sandbox/sandbox.ts"],"names":["ErrorSource","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","params","then","result","waitUntil","catch","error","getServerError","getRuntimeContext","runtime","evaluateInContext","getModuleContext","moduleName","name","onWarning","useCache","env","edgeFunctionEntry","distDir","paramPath","paths","run","subreq","request","headers","subrequests","split","includes","Promise","resolve","response","context","Response","edgeFunction","_ENTRIES","default","cloned","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","requestToBodyStream","headerName","delete","finalize"],"mappings":"AAAA;;;;;AAC+B,IAAA,WAA4D,WAA5D,4DAA4D,CAAA;AAC1D,IAAA,QAAW,WAAX,WAAW,CAAA;AAER,IAAA,YAAoB,WAApB,oBAAoB,CAAA;AAGjD,MAAMA,WAAW,GAAGC,MAAM,CAAC,cAAc,CAAC;QAApCD,WAAW,GAAXA,WAAW;AAExB,MAAME,iBAAiB,GAAG;IACxB,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;CACpB;AA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