Text Generation
Transformers
Safetensors
GGUF
English
code
code-generation
multimodal
llama
conversational
Instructions to use mrsandip/Alfa-Code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrsandip/Alfa-Code with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mrsandip/Alfa-Code")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mrsandip/Alfa-Code", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mrsandip/Alfa-Code with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf mrsandip/Alfa-Code:Q4_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf mrsandip/Alfa-Code:Q4_0
Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- LM Studio
- Jan
- vLLM
How to use mrsandip/Alfa-Code with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mrsandip/Alfa-Code" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- SGLang
How to use mrsandip/Alfa-Code with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use mrsandip/Alfa-Code with Ollama:
ollama run hf.co/mrsandip/Alfa-Code:Q4_0
- Unsloth Desktop
- Docker Model Runner
How to use mrsandip/Alfa-Code with Docker Model Runner:
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Lemonade
How to use mrsandip/Alfa-Code with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mrsandip/Alfa-Code:Q4_0
Run and chat with the model
lemonade run user.Alfa-Code-Q4_0
List all available models
lemonade list
- Atomic Chat
Update (part 24)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- e-commerce/node_modules/next/dist/server/lib/server-ipc/utils.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/source-maps.d.ts +52 -0
- e-commerce/node_modules/next/dist/server/lib/source-maps.js +241 -0
- e-commerce/node_modules/next/dist/server/lib/source-maps.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/start-server.d.ts +34 -0
- e-commerce/node_modules/next/dist/server/lib/start-server.js +550 -0
- e-commerce/node_modules/next/dist/server/lib/start-server.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/streaming-metadata.d.ts +1 -0
- e-commerce/node_modules/next/dist/server/lib/streaming-metadata.js +27 -0
- e-commerce/node_modules/next/dist/server/lib/streaming-metadata.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/to-route.d.ts +24 -0
- e-commerce/node_modules/next/dist/server/lib/to-route.js +37 -0
- e-commerce/node_modules/next/dist/server/lib/to-route.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/constants.d.ts +120 -0
- e-commerce/node_modules/next/dist/server/lib/trace/constants.js +248 -0
- e-commerce/node_modules/next/dist/server/lib/trace/constants.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/local-span-recorder.d.ts +39 -0
- e-commerce/node_modules/next/dist/server/lib/trace/local-span-recorder.js +385 -0
- e-commerce/node_modules/next/dist/server/lib/trace/local-span-recorder.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/request-insights-identity.d.ts +9 -0
- e-commerce/node_modules/next/dist/server/lib/trace/request-insights-identity.js +37 -0
- e-commerce/node_modules/next/dist/server/lib/trace/request-insights-identity.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/request-insights.d.ts +17 -0
- e-commerce/node_modules/next/dist/server/lib/trace/request-insights.js +308 -0
- e-commerce/node_modules/next/dist/server/lib/trace/request-insights.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/span-store.d.ts +41 -0
- e-commerce/node_modules/next/dist/server/lib/trace/span-store.js +69 -0
- e-commerce/node_modules/next/dist/server/lib/trace/span-store.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/tracer.d.ts +126 -0
- e-commerce/node_modules/next/dist/server/lib/trace/tracer.js +392 -0
- e-commerce/node_modules/next/dist/server/lib/trace/tracer.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/trace/utils.d.ts +6 -0
- e-commerce/node_modules/next/dist/server/lib/trace/utils.js +16 -0
- e-commerce/node_modules/next/dist/server/lib/trace/utils.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/types.d.ts +4 -0
- e-commerce/node_modules/next/dist/server/lib/types.js +6 -0
- e-commerce/node_modules/next/dist/server/lib/types.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/utils.d.ts +84 -0
- e-commerce/node_modules/next/dist/server/lib/utils.js +343 -0
- e-commerce/node_modules/next/dist/server/lib/utils.js.map +1 -0
- e-commerce/node_modules/next/dist/server/lib/worker-utils.d.ts +1 -0
- e-commerce/node_modules/next/dist/server/lib/worker-utils.js +32 -0
- e-commerce/node_modules/next/dist/server/lib/worker-utils.js.map +1 -0
- e-commerce/node_modules/next/dist/server/load-components.d.ts +85 -0
- e-commerce/node_modules/next/dist/server/load-components.js +190 -0
- e-commerce/node_modules/next/dist/server/load-components.js.map +1 -0
- e-commerce/node_modules/next/dist/server/load-default-error-components.d.ts +12 -0
- e-commerce/node_modules/next/dist/server/load-default-error-components.js +41 -0
- e-commerce/node_modules/next/dist/server/load-default-error-components.js.map +1 -0
- e-commerce/node_modules/next/dist/server/load-manifest.external.d.ts +46 -0
e-commerce/node_modules/next/dist/server/lib/server-ipc/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/server-ipc/utils.ts"],"sourcesContent":["export const ipcForbiddenHeaders = [\n 'accept-encoding',\n 'keepalive',\n 'keep-alive',\n 'content-encoding',\n 'transfer-encoding',\n // https://github.com/nodejs/undici/issues/1470\n 'connection',\n // marked as unsupported by undici: https://github.com/nodejs/undici/blob/c83b084879fa0bb8e0469d31ec61428ac68160d5/lib/core/request.js#L354\n 'expect',\n]\n\nexport const actionsForbiddenHeaders = [\n ...ipcForbiddenHeaders,\n 'content-length',\n 'set-cookie',\n]\n\nexport const filterReqHeaders = (\n headers: Record<string, undefined | string | number | string[]>,\n forbiddenHeaders: string[]\n) => {\n // Some browsers are not matching spec and sending Content-Length: 0. This causes issues in undici\n // https://github.com/nodejs/undici/issues/2046\n if (headers['content-length'] && headers['content-length'] === '0') {\n delete headers['content-length']\n }\n\n for (const [key, value] of Object.entries(headers)) {\n if (\n forbiddenHeaders.includes(key) ||\n !(Array.isArray(value) || typeof value === 'string')\n ) {\n delete headers[key]\n }\n }\n return headers as Record<string, undefined | string | string[]>\n}\n\n// These are headers that are only used internally and should\n// not be honored from the external request\nconst INTERNAL_HEADERS = [\n 'x-middleware-rewrite',\n 'x-middleware-redirect',\n 'x-middleware-set-cookie',\n 'x-middleware-skip',\n 'x-middleware-override-headers',\n 'x-middleware-next',\n 'x-now-route-matches',\n 'x-matched-path',\n 'x-nextjs-data',\n 'x-next-resume-state-length',\n 'next-resume',\n]\n\nexport const filterInternalHeaders = (\n headers: Record<string, undefined | string | string[]>\n) => {\n for (const header in headers) {\n if (INTERNAL_HEADERS.includes(header)) {\n delete headers[header]\n }\n }\n}\n"],"names":["actionsForbiddenHeaders","filterInternalHeaders","filterReqHeaders","ipcForbiddenHeaders","headers","forbiddenHeaders","key","value","Object","entries","includes","Array","isArray","INTERNAL_HEADERS","header"],"mappings":";;;;;;;;;;;;;;;;;IAYaA,uBAAuB;eAAvBA;;IA2CAC,qBAAqB;eAArBA;;IArCAC,gBAAgB;eAAhBA;;IAlBAC,mBAAmB;eAAnBA;;;AAAN,MAAMA,sBAAsB;IACjC;IACA;IACA;IACA;IACA;IACA,+CAA+C;IAC/C;IACA,2IAA2I;IAC3I;CACD;AAEM,MAAMH,0BAA0B;OAClCG;IACH;IACA;CACD;AAEM,MAAMD,mBAAmB,CAC9BE,SACAC;IAEA,kGAAkG;IAClG,+CAA+C;IAC/C,IAAID,OAAO,CAAC,iBAAiB,IAAIA,OAAO,CAAC,iBAAiB,KAAK,KAAK;QAClE,OAAOA,OAAO,CAAC,iBAAiB;IAClC;IAEA,KAAK,MAAM,CAACE,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,SAAU;QAClD,IACEC,iBAAiBK,QAAQ,CAACJ,QAC1B,CAAEK,CAAAA,MAAMC,OAAO,CAACL,UAAU,OAAOA,UAAU,QAAO,GAClD;YACA,OAAOH,OAAO,CAACE,IAAI;QACrB;IACF;IACA,OAAOF;AACT;AAEA,6DAA6D;AAC7D,2CAA2C;AAC3C,MAAMS,mBAAmB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAEM,MAAMZ,wBAAwB,CACnCG;IAEA,IAAK,MAAMU,UAAUV,QAAS;QAC5B,IAAIS,iBAAiBH,QAAQ,CAACI,SAAS;YACrC,OAAOV,OAAO,CAACU,OAAO;QACxB;IACF;AACF","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/source-maps.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* https://tc39.es/source-map/#index-map
|
| 3 |
+
*/
|
| 4 |
+
interface IndexSourceMapSection {
|
| 5 |
+
offset: {
|
| 6 |
+
line: number;
|
| 7 |
+
column: number;
|
| 8 |
+
};
|
| 9 |
+
map: BasicSourceMapPayload;
|
| 10 |
+
}
|
| 11 |
+
/** https://tc39.es/ecma426/#sec-index-source-map */
|
| 12 |
+
interface IndexSourceMap {
|
| 13 |
+
version: number;
|
| 14 |
+
file: string;
|
| 15 |
+
sections: IndexSourceMapSection[];
|
| 16 |
+
}
|
| 17 |
+
/** https://tc39.es/ecma426/#sec-source-map-format */
|
| 18 |
+
export interface BasicSourceMapPayload {
|
| 19 |
+
version: number;
|
| 20 |
+
/** WARNING: `file` is optional. */
|
| 21 |
+
file: string;
|
| 22 |
+
sourceRoot?: string;
|
| 23 |
+
/** WARNING: `sources[number]` can be `null`. */
|
| 24 |
+
sources: Array<string>;
|
| 25 |
+
names: Array<string>;
|
| 26 |
+
mappings: string;
|
| 27 |
+
ignoreList?: number[];
|
| 28 |
+
}
|
| 29 |
+
export type ModernSourceMapPayload = BasicSourceMapPayload | IndexSourceMap;
|
| 30 |
+
/**
|
| 31 |
+
* Like `module.findSourceMap`, but returns the source map's payload without
|
| 32 |
+
* cloning it on every call. Callers must not mutate the returned payload.
|
| 33 |
+
* Throws like `module.findSourceMap` does on invalid source maps.
|
| 34 |
+
*/
|
| 35 |
+
export declare function findSourceMapPayload(sourceURL: string): ModernSourceMapPayload | undefined;
|
| 36 |
+
export declare function sourceMapIgnoreListsEverything(sourceMap: BasicSourceMapPayload): boolean;
|
| 37 |
+
/**
|
| 38 |
+
* Finds the sourcemap payload applicable to a given frame.
|
| 39 |
+
* Equal to the input unless an Index Source Map is used.
|
| 40 |
+
* @param line0 - The line number of the frame, 0-based.
|
| 41 |
+
* @param column0 - The column number of the frame, 0-based.
|
| 42 |
+
*/
|
| 43 |
+
export declare function findApplicableSourceMapPayload(line0: number, column0: number, payload: ModernSourceMapPayload): BasicSourceMapPayload | undefined;
|
| 44 |
+
export declare function filterStackFrameDEV(sourceURL: string, functionName: string, line1: number, column1: number): boolean;
|
| 45 |
+
type FindSourceMapURL = (scriptNameOrSourceURL: string) => string | null;
|
| 46 |
+
export declare function setBundlerFindSourceMapURLImplementation(findSourceMapURLImplementation: FindSourceMapURL): void;
|
| 47 |
+
export declare function findSourceMapURLDEV(scriptNameOrSourceURL: string): string | null;
|
| 48 |
+
export declare function devirtualizeReactServerURL(sourceURL: string): string;
|
| 49 |
+
export declare function ignoreListAnonymousStackFramesIfSandwiched<Frame>(frames: Frame[], isAnonymousFrame: (frame: Frame) => boolean, isIgnoredFrame: (frame: Frame) => boolean, getMethodName: (frame: Frame) => string,
|
| 50 |
+
/** only passes frames for which `isAnonymousFrame` and their method is a native JS method or `isIgnoredFrame` return true */
|
| 51 |
+
ignoreFrame: (frame: Frame) => void): void;
|
| 52 |
+
export {};
|
e-commerce/node_modules/next/dist/server/lib/source-maps.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
0 && (module.exports = {
|
| 6 |
+
devirtualizeReactServerURL: null,
|
| 7 |
+
filterStackFrameDEV: null,
|
| 8 |
+
findApplicableSourceMapPayload: null,
|
| 9 |
+
findSourceMapPayload: null,
|
| 10 |
+
findSourceMapURLDEV: null,
|
| 11 |
+
ignoreListAnonymousStackFramesIfSandwiched: null,
|
| 12 |
+
setBundlerFindSourceMapURLImplementation: null,
|
| 13 |
+
sourceMapIgnoreListsEverything: null
|
| 14 |
+
});
|
| 15 |
+
function _export(target, all) {
|
| 16 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 17 |
+
enumerable: true,
|
| 18 |
+
get: all[name]
|
| 19 |
+
});
|
| 20 |
+
}
|
| 21 |
+
_export(exports, {
|
| 22 |
+
devirtualizeReactServerURL: function() {
|
| 23 |
+
return devirtualizeReactServerURL;
|
| 24 |
+
},
|
| 25 |
+
filterStackFrameDEV: function() {
|
| 26 |
+
return filterStackFrameDEV;
|
| 27 |
+
},
|
| 28 |
+
findApplicableSourceMapPayload: function() {
|
| 29 |
+
return findApplicableSourceMapPayload;
|
| 30 |
+
},
|
| 31 |
+
findSourceMapPayload: function() {
|
| 32 |
+
return findSourceMapPayload;
|
| 33 |
+
},
|
| 34 |
+
findSourceMapURLDEV: function() {
|
| 35 |
+
return findSourceMapURLDEV;
|
| 36 |
+
},
|
| 37 |
+
ignoreListAnonymousStackFramesIfSandwiched: function() {
|
| 38 |
+
return ignoreListAnonymousStackFramesIfSandwiched;
|
| 39 |
+
},
|
| 40 |
+
setBundlerFindSourceMapURLImplementation: function() {
|
| 41 |
+
return setBundlerFindSourceMapURLImplementation;
|
| 42 |
+
},
|
| 43 |
+
sourceMapIgnoreListsEverything: function() {
|
| 44 |
+
return sourceMapIgnoreListsEverything;
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
const _lrucache = require("./lru-cache");
|
| 48 |
+
function noSourceMap() {
|
| 49 |
+
return undefined;
|
| 50 |
+
}
|
| 51 |
+
// Edge runtime does not implement `module`
|
| 52 |
+
const findSourceMap = process.env.NEXT_RUNTIME === 'edge' ? noSourceMap : require('module').findSourceMap;
|
| 53 |
+
// `SourceMap#payload` deep-clones the payload on every access — expensive
|
| 54 |
+
// for large chunk maps — so the clone is shared per `SourceMap` instance,
|
| 55 |
+
// which Node.js memoizes per script.
|
| 56 |
+
const sourceMapPayloads = new WeakMap();
|
| 57 |
+
function findSourceMapPayload(sourceURL) {
|
| 58 |
+
const sourceMap = findSourceMap(sourceURL);
|
| 59 |
+
if (sourceMap === undefined) {
|
| 60 |
+
return undefined;
|
| 61 |
+
}
|
| 62 |
+
let payload = sourceMapPayloads.get(sourceMap);
|
| 63 |
+
if (payload === undefined) {
|
| 64 |
+
payload = sourceMap.payload;
|
| 65 |
+
sourceMapPayloads.set(sourceMap, payload);
|
| 66 |
+
}
|
| 67 |
+
return payload;
|
| 68 |
+
}
|
| 69 |
+
function sourceMapIgnoreListsEverything(sourceMap) {
|
| 70 |
+
return sourceMap.ignoreList !== undefined && sourceMap.sources.length === sourceMap.ignoreList.length;
|
| 71 |
+
}
|
| 72 |
+
function findApplicableSourceMapPayload(line0, column0, payload) {
|
| 73 |
+
if ('sections' in payload) {
|
| 74 |
+
if (payload.sections.length === 0) {
|
| 75 |
+
return undefined;
|
| 76 |
+
}
|
| 77 |
+
// Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
|
| 78 |
+
// Therefore the last section that has an offset less than or equal to the frame is the applicable one.
|
| 79 |
+
const sections = payload.sections;
|
| 80 |
+
let left = 0;
|
| 81 |
+
let right = sections.length - 1;
|
| 82 |
+
let result = null;
|
| 83 |
+
while(left <= right){
|
| 84 |
+
// fast Math.floor
|
| 85 |
+
const middle = ~~((left + right) / 2);
|
| 86 |
+
const section = sections[middle];
|
| 87 |
+
const offset = section.offset;
|
| 88 |
+
if (offset.line < line0 || offset.line === line0 && offset.column <= column0) {
|
| 89 |
+
result = section;
|
| 90 |
+
left = middle + 1;
|
| 91 |
+
} else {
|
| 92 |
+
right = middle - 1;
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
return result === null ? undefined : result.map;
|
| 96 |
+
} else {
|
| 97 |
+
return payload;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
const didWarnAboutInvalidSourceMapDEV = new Set();
|
| 101 |
+
function filterStackFrameDEV(sourceURL, functionName, line1, column1) {
|
| 102 |
+
if (sourceURL === '') {
|
| 103 |
+
// The default implementation filters out <anonymous> stack frames
|
| 104 |
+
// but we want to retain them because current Server Components and
|
| 105 |
+
// built-in Components in parent stacks don't have source location.
|
| 106 |
+
// Filter out frames that show up in Promises to get good names in React's
|
| 107 |
+
// Server Request track until we come up with a better heuristic.
|
| 108 |
+
return functionName !== 'new Promise';
|
| 109 |
+
}
|
| 110 |
+
if (sourceURL.startsWith('node:') || sourceURL.includes('node_modules')) {
|
| 111 |
+
return false;
|
| 112 |
+
}
|
| 113 |
+
try {
|
| 114 |
+
// Node.js loads source maps eagerly so this call is cheap.
|
| 115 |
+
// TODO: ESM sourcemaps are O(1) but CommonJS sourcemaps are O(Number of CJS modules).
|
| 116 |
+
// Make sure this doesn't adversely affect performance when CJS is used by Next.js.
|
| 117 |
+
const payload = findSourceMapPayload(sourceURL);
|
| 118 |
+
if (payload === undefined) {
|
| 119 |
+
// No source map associated.
|
| 120 |
+
return true;
|
| 121 |
+
}
|
| 122 |
+
const sourceMapPayload = findApplicableSourceMapPayload(line1 - 1, column1 - 1, payload);
|
| 123 |
+
if (sourceMapPayload === undefined) {
|
| 124 |
+
// No source map section applicable to the frame.
|
| 125 |
+
return true;
|
| 126 |
+
}
|
| 127 |
+
return !sourceMapIgnoreListsEverything(sourceMapPayload);
|
| 128 |
+
} catch (cause) {
|
| 129 |
+
if (process.env.NODE_ENV !== 'production') {
|
| 130 |
+
// TODO: Share cache with patch-error-inspect
|
| 131 |
+
if (!didWarnAboutInvalidSourceMapDEV.has(sourceURL)) {
|
| 132 |
+
didWarnAboutInvalidSourceMapDEV.add(sourceURL);
|
| 133 |
+
// We should not log an actual error instance here because that will re-enter
|
| 134 |
+
// this codepath during error inspection and could lead to infinite recursion.
|
| 135 |
+
console.error(`${sourceURL}: Invalid source map. Only conformant source maps can be used to filter stack frames. Cause: ${cause}`);
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
return true;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
// Find the URL of a source map using the bundler's API.
|
| 142 |
+
// Shared via `globalThis` because this module is compiled both into the server
|
| 143 |
+
// runtime bundles (which call `findSourceMapURLDEV`) and into `next/dist/server`
|
| 144 |
+
// (where the dev server registers the implementation), and each copy has its own
|
| 145 |
+
// module state.
|
| 146 |
+
const bundlerFindSourceMapURLSymbol = Symbol.for('next.server.bundlerFindSourceMapURL');
|
| 147 |
+
function setBundlerFindSourceMapURLImplementation(findSourceMapURLImplementation) {
|
| 148 |
+
;
|
| 149 |
+
globalThis[bundlerFindSourceMapURLSymbol] = findSourceMapURLImplementation;
|
| 150 |
+
}
|
| 151 |
+
function bundlerFindSourceMapURL(scriptNameOrSourceURL) {
|
| 152 |
+
const implementation = globalThis[bundlerFindSourceMapURLSymbol];
|
| 153 |
+
return implementation === undefined ? null : implementation(scriptNameOrSourceURL);
|
| 154 |
+
}
|
| 155 |
+
const invalidSourceMap = Symbol('invalid-source-map');
|
| 156 |
+
const sourceMapURLs = new _lrucache.LRUCache(512 * 1024 * 1024, (url, sourceURL)=>sourceURL.length + (url === invalidSourceMap ? 8 * 1024 : url.length));
|
| 157 |
+
function findSourceMapURLDEV(scriptNameOrSourceURL) {
|
| 158 |
+
try {
|
| 159 |
+
const bundlerSourceMapURL = bundlerFindSourceMapURL(scriptNameOrSourceURL);
|
| 160 |
+
if (bundlerSourceMapURL !== null) {
|
| 161 |
+
return bundlerSourceMapURL;
|
| 162 |
+
}
|
| 163 |
+
} catch (cause) {
|
| 164 |
+
console.error(`${scriptNameOrSourceURL}: Failed to find the source map URL. Cause: ${cause}`);
|
| 165 |
+
}
|
| 166 |
+
// No bundler implementation (e.g. Webpack): inline the source map Node.js
|
| 167 |
+
// knows as a `data:` URL.
|
| 168 |
+
let sourceMapURL = sourceMapURLs.get(scriptNameOrSourceURL);
|
| 169 |
+
if (sourceMapURL === undefined) {
|
| 170 |
+
let sourceMapPayload;
|
| 171 |
+
try {
|
| 172 |
+
sourceMapPayload = findSourceMapPayload(scriptNameOrSourceURL);
|
| 173 |
+
} catch (cause) {
|
| 174 |
+
console.error(`${scriptNameOrSourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`);
|
| 175 |
+
}
|
| 176 |
+
if (sourceMapPayload === undefined) {
|
| 177 |
+
sourceMapURL = invalidSourceMap;
|
| 178 |
+
} else {
|
| 179 |
+
// TODO: Might be more efficient to extract the relevant section from Index Maps.
|
| 180 |
+
// Unclear if that search is worth the smaller payload we have to stringify.
|
| 181 |
+
const sourceMapJSON = JSON.stringify(sourceMapPayload);
|
| 182 |
+
const sourceMapURLData = Buffer.from(sourceMapJSON, 'utf8').toString('base64');
|
| 183 |
+
sourceMapURL = `data:application/json;base64,${sourceMapURLData}`;
|
| 184 |
+
}
|
| 185 |
+
sourceMapURLs.set(scriptNameOrSourceURL, sourceMapURL);
|
| 186 |
+
}
|
| 187 |
+
return sourceMapURL === invalidSourceMap ? null : sourceMapURL;
|
| 188 |
+
}
|
| 189 |
+
function devirtualizeReactServerURL(sourceURL) {
|
| 190 |
+
if (sourceURL.startsWith('about://React/')) {
|
| 191 |
+
// about://React/Server/file://<filename>?42 => file://<filename>
|
| 192 |
+
const envIdx = sourceURL.indexOf('/', 'about://React/'.length);
|
| 193 |
+
const suffixIdx = sourceURL.lastIndexOf('?');
|
| 194 |
+
if (envIdx > -1 && suffixIdx > -1) {
|
| 195 |
+
return decodeURI(sourceURL.slice(envIdx + 1, suffixIdx));
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
return sourceURL;
|
| 199 |
+
}
|
| 200 |
+
function isAnonymousFrameLikelyJSNative(methodName) {
|
| 201 |
+
// Anonymous frames can also be produced in React parent stacks either from
|
| 202 |
+
// host components or Server Components. We don't want to ignore those.
|
| 203 |
+
// This could hide user-space methods that are named like native JS methods but
|
| 204 |
+
// should you really do that?
|
| 205 |
+
return(// e.g. JSON.parse
|
| 206 |
+
methodName.startsWith('JSON.') || // E.g. Promise.withResolves
|
| 207 |
+
methodName.startsWith('Function.') || // various JS built-ins
|
| 208 |
+
methodName.startsWith('Promise.') || methodName.startsWith('Array.') || methodName.startsWith('Set.') || methodName.startsWith('Map.'));
|
| 209 |
+
}
|
| 210 |
+
function ignoreListAnonymousStackFramesIfSandwiched(frames, isAnonymousFrame, isIgnoredFrame, getMethodName, /** only passes frames for which `isAnonymousFrame` and their method is a native JS method or `isIgnoredFrame` return true */ ignoreFrame) {
|
| 211 |
+
for(let i = 1; i < frames.length; i++){
|
| 212 |
+
const currentFrame = frames[i];
|
| 213 |
+
if (!(isAnonymousFrame(currentFrame) && isAnonymousFrameLikelyJSNative(getMethodName(currentFrame)))) {
|
| 214 |
+
continue;
|
| 215 |
+
}
|
| 216 |
+
const previousFrameIsIgnored = isIgnoredFrame(frames[i - 1]);
|
| 217 |
+
if (previousFrameIsIgnored && i < frames.length - 1) {
|
| 218 |
+
let ignoreSandwich = false;
|
| 219 |
+
let j = i + 1;
|
| 220 |
+
for(j; j < frames.length; j++){
|
| 221 |
+
const nextFrame = frames[j];
|
| 222 |
+
const nextFrameIsAnonymous = isAnonymousFrame(nextFrame) && isAnonymousFrameLikelyJSNative(getMethodName(nextFrame));
|
| 223 |
+
if (nextFrameIsAnonymous) {
|
| 224 |
+
continue;
|
| 225 |
+
}
|
| 226 |
+
const nextFrameIsIgnored = isIgnoredFrame(nextFrame);
|
| 227 |
+
if (nextFrameIsIgnored) {
|
| 228 |
+
ignoreSandwich = true;
|
| 229 |
+
break;
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
if (ignoreSandwich) {
|
| 233 |
+
for(i; i < j; i++){
|
| 234 |
+
ignoreFrame(frames[i]);
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
//# sourceMappingURL=source-maps.js.map
|
e-commerce/node_modules/next/dist/server/lib/source-maps.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/server/lib/source-maps.ts"],"sourcesContent":["import type { SourceMap } from 'module'\nimport { LRUCache } from './lru-cache'\n\nfunction noSourceMap(): SourceMap | undefined {\n return undefined\n}\n\n// Edge runtime does not implement `module`\nconst findSourceMap =\n process.env.NEXT_RUNTIME === 'edge'\n ? noSourceMap\n : (require('module') as typeof import('module')).findSourceMap\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: BasicSourceMapPayload\n}\n\n// TODO(veil): Upstream types\n/** https://tc39.es/ecma426/#sec-index-source-map */\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\n/** https://tc39.es/ecma426/#sec-source-map-format */\nexport interface BasicSourceMapPayload {\n version: number\n // TODO: Move to https://github.com/jridgewell/sourcemaps which is actively maintained\n /** WARNING: `file` is optional. */\n file: string\n sourceRoot?: string\n // TODO: Move to https://github.com/jridgewell/sourcemaps which is actively maintained\n /** WARNING: `sources[number]` can be `null`. */\n sources: Array<string>\n names: Array<string>\n mappings: string\n ignoreList?: number[]\n}\n\nexport type ModernSourceMapPayload = BasicSourceMapPayload | IndexSourceMap\n\n// `SourceMap#payload` deep-clones the payload on every access — expensive\n// for large chunk maps — so the clone is shared per `SourceMap` instance,\n// which Node.js memoizes per script.\nconst sourceMapPayloads = new WeakMap<SourceMap, ModernSourceMapPayload>()\n\n/**\n * Like `module.findSourceMap`, but returns the source map's payload without\n * cloning it on every call. Callers must not mutate the returned payload.\n * Throws like `module.findSourceMap` does on invalid source maps.\n */\nexport function findSourceMapPayload(\n sourceURL: string\n): ModernSourceMapPayload | undefined {\n const sourceMap = findSourceMap(sourceURL)\n if (sourceMap === undefined) {\n return undefined\n }\n let payload = sourceMapPayloads.get(sourceMap)\n if (payload === undefined) {\n payload = sourceMap.payload as ModernSourceMapPayload\n sourceMapPayloads.set(sourceMap, payload)\n }\n return payload\n}\n\nexport function sourceMapIgnoreListsEverything(\n sourceMap: BasicSourceMapPayload\n): boolean {\n return (\n sourceMap.ignoreList !== undefined &&\n sourceMap.sources.length === sourceMap.ignoreList.length\n )\n}\n\n/**\n * Finds the sourcemap payload applicable to a given frame.\n * Equal to the input unless an Index Source Map is used.\n * @param line0 - The line number of the frame, 0-based.\n * @param column0 - The column number of the frame, 0-based.\n */\nexport function findApplicableSourceMapPayload(\n line0: number,\n column0: number,\n payload: ModernSourceMapPayload\n): BasicSourceMapPayload | undefined {\n if ('sections' in payload) {\n if (payload.sections.length === 0) {\n return undefined\n }\n\n // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object\n // Therefore the last section that has an offset less than or equal to the frame is the applicable one.\n const sections = payload.sections\n let left = 0\n let right = sections.length - 1\n let result: IndexSourceMapSection | null = null\n\n while (left <= right) {\n // fast Math.floor\n const middle = ~~((left + right) / 2)\n const section = sections[middle]\n const offset = section.offset\n\n if (\n offset.line < line0 ||\n (offset.line === line0 && offset.column <= column0)\n ) {\n result = section\n left = middle + 1\n } else {\n right = middle - 1\n }\n }\n\n return result === null ? undefined : result.map\n } else {\n return payload\n }\n}\n\nconst didWarnAboutInvalidSourceMapDEV = new Set<string>()\n\nexport function filterStackFrameDEV(\n sourceURL: string,\n functionName: string,\n line1: number,\n column1: number\n): boolean {\n if (sourceURL === '') {\n // The default implementation filters out <anonymous> stack frames\n // but we want to retain them because current Server Components and\n // built-in Components in parent stacks don't have source location.\n // Filter out frames that show up in Promises to get good names in React's\n // Server Request track until we come up with a better heuristic.\n return functionName !== 'new Promise'\n }\n if (sourceURL.startsWith('node:') || sourceURL.includes('node_modules')) {\n return false\n }\n try {\n // Node.js loads source maps eagerly so this call is cheap.\n // TODO: ESM sourcemaps are O(1) but CommonJS sourcemaps are O(Number of CJS modules).\n // Make sure this doesn't adversely affect performance when CJS is used by Next.js.\n const payload = findSourceMapPayload(sourceURL)\n if (payload === undefined) {\n // No source map associated.\n return true\n }\n const sourceMapPayload = findApplicableSourceMapPayload(\n line1 - 1,\n column1 - 1,\n payload\n )\n if (sourceMapPayload === undefined) {\n // No source map section applicable to the frame.\n return true\n }\n return !sourceMapIgnoreListsEverything(sourceMapPayload)\n } catch (cause) {\n if (process.env.NODE_ENV !== 'production') {\n // TODO: Share cache with patch-error-inspect\n if (!didWarnAboutInvalidSourceMapDEV.has(sourceURL)) {\n didWarnAboutInvalidSourceMapDEV.add(sourceURL)\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to filter stack frames. Cause: ${cause}`\n )\n }\n }\n\n return true\n }\n}\n\n// `scriptNameOrSourceURL` is what React forwards from the stack frame: the\n// script's `getScriptNameOrSourceURL()`, which for the server chunks we can\n// map is an absolute filesystem path, not a URL. The returned value is the\n// source map's URL (`file:` or `data:`).\ntype FindSourceMapURL = (scriptNameOrSourceURL: string) => string | null\n// Find the URL of a source map using the bundler's API.\n// Shared via `globalThis` because this module is compiled both into the server\n// runtime bundles (which call `findSourceMapURLDEV`) and into `next/dist/server`\n// (where the dev server registers the implementation), and each copy has its own\n// module state.\nconst bundlerFindSourceMapURLSymbol = Symbol.for(\n 'next.server.bundlerFindSourceMapURL'\n)\n\nexport function setBundlerFindSourceMapURLImplementation(\n findSourceMapURLImplementation: FindSourceMapURL\n): void {\n ;(globalThis as any)[bundlerFindSourceMapURLSymbol] =\n findSourceMapURLImplementation\n}\n\nfunction bundlerFindSourceMapURL(scriptNameOrSourceURL: string): string | null {\n const implementation: FindSourceMapURL | undefined = (globalThis as any)[\n bundlerFindSourceMapURLSymbol\n ]\n return implementation === undefined\n ? null\n : implementation(scriptNameOrSourceURL)\n}\n\nconst invalidSourceMap = Symbol('invalid-source-map')\nconst sourceMapURLs = new LRUCache<string | typeof invalidSourceMap>(\n 512 * 1024 * 1024,\n (url, sourceURL) =>\n sourceURL.length +\n (url === invalidSourceMap\n ? // Guestimate a small source map so invalid entries don't fill the cache.\n 8 * 1024\n : // these URLs contain only ASCII characters so .length is equal to Buffer.byteLength\n url.length)\n)\nexport function findSourceMapURLDEV(\n scriptNameOrSourceURL: string\n): string | null {\n try {\n const bundlerSourceMapURL = bundlerFindSourceMapURL(scriptNameOrSourceURL)\n if (bundlerSourceMapURL !== null) {\n return bundlerSourceMapURL\n }\n } catch (cause) {\n console.error(\n `${scriptNameOrSourceURL}: Failed to find the source map URL. Cause: ${cause}`\n )\n }\n\n // No bundler implementation (e.g. Webpack): inline the source map Node.js\n // knows as a `data:` URL.\n let sourceMapURL = sourceMapURLs.get(scriptNameOrSourceURL)\n if (sourceMapURL === undefined) {\n let sourceMapPayload: ModernSourceMapPayload | undefined\n try {\n sourceMapPayload = findSourceMapPayload(scriptNameOrSourceURL)\n } catch (cause) {\n console.error(\n `${scriptNameOrSourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n }\n\n if (sourceMapPayload === undefined) {\n sourceMapURL = invalidSourceMap\n } else {\n // TODO: Might be more efficient to extract the relevant section from Index Maps.\n // Unclear if that search is worth the smaller payload we have to stringify.\n const sourceMapJSON = JSON.stringify(sourceMapPayload)\n const sourceMapURLData = Buffer.from(sourceMapJSON, 'utf8').toString(\n 'base64'\n )\n sourceMapURL = `data:application/json;base64,${sourceMapURLData}`\n }\n\n sourceMapURLs.set(scriptNameOrSourceURL, sourceMapURL)\n }\n\n return sourceMapURL === invalidSourceMap ? null : sourceMapURL\n}\n\nexport function devirtualizeReactServerURL(sourceURL: string): string {\n if (sourceURL.startsWith('about://React/')) {\n // about://React/Server/file://<filename>?42 => file://<filename>\n const envIdx = sourceURL.indexOf('/', 'about://React/'.length)\n const suffixIdx = sourceURL.lastIndexOf('?')\n if (envIdx > -1 && suffixIdx > -1) {\n return decodeURI(sourceURL.slice(envIdx + 1, suffixIdx))\n }\n }\n return sourceURL\n}\n\nfunction isAnonymousFrameLikelyJSNative(methodName: string): boolean {\n // Anonymous frames can also be produced in React parent stacks either from\n // host components or Server Components. We don't want to ignore those.\n // This could hide user-space methods that are named like native JS methods but\n // should you really do that?\n return (\n // e.g. JSON.parse\n methodName.startsWith('JSON.') ||\n // E.g. Promise.withResolves\n methodName.startsWith('Function.') ||\n // various JS built-ins\n methodName.startsWith('Promise.') ||\n methodName.startsWith('Array.') ||\n methodName.startsWith('Set.') ||\n methodName.startsWith('Map.')\n )\n}\n\nexport function ignoreListAnonymousStackFramesIfSandwiched<Frame>(\n frames: Frame[],\n isAnonymousFrame: (frame: Frame) => boolean,\n isIgnoredFrame: (frame: Frame) => boolean,\n getMethodName: (frame: Frame) => string,\n /** only passes frames for which `isAnonymousFrame` and their method is a native JS method or `isIgnoredFrame` return true */\n ignoreFrame: (frame: Frame) => void\n): void {\n for (let i = 1; i < frames.length; i++) {\n const currentFrame = frames[i]\n if (\n !(\n isAnonymousFrame(currentFrame) &&\n isAnonymousFrameLikelyJSNative(getMethodName(currentFrame))\n )\n ) {\n continue\n }\n\n const previousFrameIsIgnored = isIgnoredFrame(frames[i - 1])\n if (previousFrameIsIgnored && i < frames.length - 1) {\n let ignoreSandwich = false\n let j = i + 1\n for (j; j < frames.length; j++) {\n const nextFrame = frames[j]\n const nextFrameIsAnonymous =\n isAnonymousFrame(nextFrame) &&\n isAnonymousFrameLikelyJSNative(getMethodName(nextFrame))\n if (nextFrameIsAnonymous) {\n continue\n }\n\n const nextFrameIsIgnored = isIgnoredFrame(nextFrame)\n if (nextFrameIsIgnored) {\n ignoreSandwich = true\n break\n }\n }\n\n if (ignoreSandwich) {\n for (i; i < j; i++) {\n ignoreFrame(frames[i])\n }\n }\n }\n }\n}\n"],"names":["devirtualizeReactServerURL","filterStackFrameDEV","findApplicableSourceMapPayload","findSourceMapPayload","findSourceMapURLDEV","ignoreListAnonymousStackFramesIfSandwiched","setBundlerFindSourceMapURLImplementation","sourceMapIgnoreListsEverything","noSourceMap","undefined","findSourceMap","process","env","NEXT_RUNTIME","require","sourceMapPayloads","WeakMap","sourceURL","sourceMap","payload","get","set","ignoreList","sources","length","line0","column0","sections","left","right","result","middle","section","offset","line","column","map","didWarnAboutInvalidSourceMapDEV","Set","functionName","line1","column1","startsWith","includes","sourceMapPayload","cause","NODE_ENV","has","add","console","error","bundlerFindSourceMapURLSymbol","Symbol","for","findSourceMapURLImplementation","globalThis","bundlerFindSourceMapURL","scriptNameOrSourceURL","implementation","invalidSourceMap","sourceMapURLs","LRUCache","url","bundlerSourceMapURL","sourceMapURL","sourceMapJSON","JSON","stringify","sourceMapURLData","Buffer","from","toString","envIdx","indexOf","suffixIdx","lastIndexOf","decodeURI","slice","isAnonymousFrameLikelyJSNative","methodName","frames","isAnonymousFrame","isIgnoredFrame","getMethodName","ignoreFrame","i","currentFrame","previousFrameIsIgnored","ignoreSandwich","j","nextFrame","nextFrameIsAnonymous","nextFrameIsIgnored"],"mappings":";;;;;;;;;;;;;;;;;;;;;IA8QgBA,0BAA0B;eAA1BA;;IA3IAC,mBAAmB;eAAnBA;;IA1CAC,8BAA8B;eAA9BA;;IA9BAC,oBAAoB;eAApBA;;IAsKAC,mBAAmB;eAAnBA;;IA2EAC,0CAA0C;eAA1CA;;IAtGAC,wCAAwC;eAAxCA;;IA5HAC,8BAA8B;eAA9BA;;;0BAzES;AAEzB,SAASC;IACP,OAAOC;AACT;AAEA,2CAA2C;AAC3C,MAAMC,gBACJC,QAAQC,GAAG,CAACC,YAAY,KAAK,SACzBL,cACA,AAACM,QAAQ,UAAsCJ,aAAa;AAsClE,0EAA0E;AAC1E,0EAA0E;AAC1E,qCAAqC;AACrC,MAAMK,oBAAoB,IAAIC;AAOvB,SAASb,qBACdc,SAAiB;IAEjB,MAAMC,YAAYR,cAAcO;IAChC,IAAIC,cAAcT,WAAW;QAC3B,OAAOA;IACT;IACA,IAAIU,UAAUJ,kBAAkBK,GAAG,CAACF;IACpC,IAAIC,YAAYV,WAAW;QACzBU,UAAUD,UAAUC,OAAO;QAC3BJ,kBAAkBM,GAAG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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import './cpu-profile';
|
| 2 |
+
import '../next';
|
| 3 |
+
import '../require-hook';
|
| 4 |
+
import type { SelfSignedCertificate } from '../../lib/mkcert';
|
| 5 |
+
import { initialize } from './router-server';
|
| 6 |
+
export interface StartServerOptions {
|
| 7 |
+
dir: string;
|
| 8 |
+
port: number;
|
| 9 |
+
isDev: boolean;
|
| 10 |
+
hostname?: string;
|
| 11 |
+
allowRetry?: boolean;
|
| 12 |
+
customServer?: boolean;
|
| 13 |
+
minimalMode?: boolean;
|
| 14 |
+
keepAliveTimeout?: number;
|
| 15 |
+
selfSignedCertificate?: SelfSignedCertificate;
|
| 16 |
+
serverFastRefresh?: boolean;
|
| 17 |
+
}
|
| 18 |
+
export declare function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server, hostname, minimalMode, keepAliveTimeout, experimentalHttpsServer, serverFastRefresh, quiet, }: {
|
| 19 |
+
dir: string;
|
| 20 |
+
port: number;
|
| 21 |
+
isDev: boolean;
|
| 22 |
+
onDevServerCleanup: ((listener: () => Promise<void>) => void) | undefined;
|
| 23 |
+
server?: import('http').Server;
|
| 24 |
+
hostname?: string;
|
| 25 |
+
minimalMode?: boolean;
|
| 26 |
+
keepAliveTimeout?: number;
|
| 27 |
+
experimentalHttpsServer?: boolean;
|
| 28 |
+
serverFastRefresh?: boolean;
|
| 29 |
+
quiet?: boolean;
|
| 30 |
+
}): ReturnType<typeof initialize>;
|
| 31 |
+
export type StartServerResult = {
|
| 32 |
+
distDir: string;
|
| 33 |
+
};
|
| 34 |
+
export declare function startServer(serverOptions: StartServerOptions): Promise<StartServerResult>;
|
e-commerce/node_modules/next/dist/server/lib/start-server.js
ADDED
|
@@ -0,0 +1,550 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Start CPU profile if it wasn't already started.
|
| 2 |
+
"use strict";
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
0 && (module.exports = {
|
| 7 |
+
getRequestHandlers: null,
|
| 8 |
+
startServer: null
|
| 9 |
+
});
|
| 10 |
+
function _export(target, all) {
|
| 11 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 12 |
+
enumerable: true,
|
| 13 |
+
get: all[name]
|
| 14 |
+
});
|
| 15 |
+
}
|
| 16 |
+
_export(exports, {
|
| 17 |
+
getRequestHandlers: function() {
|
| 18 |
+
return getRequestHandlers;
|
| 19 |
+
},
|
| 20 |
+
startServer: function() {
|
| 21 |
+
return startServer;
|
| 22 |
+
}
|
| 23 |
+
});
|
| 24 |
+
require("./cpu-profile");
|
| 25 |
+
const _getnetworkhost = require("../../lib/get-network-host");
|
| 26 |
+
require("../next");
|
| 27 |
+
require("../require-hook");
|
| 28 |
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
| 29 |
+
const _v8 = /*#__PURE__*/ _interop_require_default(require("v8"));
|
| 30 |
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
| 31 |
+
const _http = /*#__PURE__*/ _interop_require_default(require("http"));
|
| 32 |
+
const _https = /*#__PURE__*/ _interop_require_default(require("https"));
|
| 33 |
+
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
| 34 |
+
const _child_process = require("child_process");
|
| 35 |
+
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../build/output/log"));
|
| 36 |
+
const _debug = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/debug"));
|
| 37 |
+
const _utils = require("./utils");
|
| 38 |
+
const _formathostname = require("./format-hostname");
|
| 39 |
+
const _routerserver = require("./router-server");
|
| 40 |
+
const _constants = require("../../shared/lib/constants");
|
| 41 |
+
const _appinfolog = require("./app-info-log");
|
| 42 |
+
const _turbopackwarning = require("../../lib/turbopack-warning");
|
| 43 |
+
const _trace = require("../../trace");
|
| 44 |
+
const _isipv6 = require("./is-ipv6");
|
| 45 |
+
const _asynccallbackset = require("./async-callback-set");
|
| 46 |
+
const _durationtostring = require("../../build/duration-to-string");
|
| 47 |
+
const _ciinfo = require("../ci-info");
|
| 48 |
+
function _interop_require_default(obj) {
|
| 49 |
+
return obj && obj.__esModule ? obj : {
|
| 50 |
+
default: obj
|
| 51 |
+
};
|
| 52 |
+
}
|
| 53 |
+
function _getRequireWildcardCache(nodeInterop) {
|
| 54 |
+
if (typeof WeakMap !== "function") return null;
|
| 55 |
+
var cacheBabelInterop = new WeakMap();
|
| 56 |
+
var cacheNodeInterop = new WeakMap();
|
| 57 |
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
| 58 |
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
| 59 |
+
})(nodeInterop);
|
| 60 |
+
}
|
| 61 |
+
function _interop_require_wildcard(obj, nodeInterop) {
|
| 62 |
+
if (!nodeInterop && obj && obj.__esModule) {
|
| 63 |
+
return obj;
|
| 64 |
+
}
|
| 65 |
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
| 66 |
+
return {
|
| 67 |
+
default: obj
|
| 68 |
+
};
|
| 69 |
+
}
|
| 70 |
+
var cache = _getRequireWildcardCache(nodeInterop);
|
| 71 |
+
if (cache && cache.has(obj)) {
|
| 72 |
+
return cache.get(obj);
|
| 73 |
+
}
|
| 74 |
+
var newObj = {
|
| 75 |
+
__proto__: null
|
| 76 |
+
};
|
| 77 |
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
| 78 |
+
for(var key in obj){
|
| 79 |
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
| 80 |
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
| 81 |
+
if (desc && (desc.get || desc.set)) {
|
| 82 |
+
Object.defineProperty(newObj, key, desc);
|
| 83 |
+
} else {
|
| 84 |
+
newObj[key] = obj[key];
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
newObj.default = obj;
|
| 89 |
+
if (cache) {
|
| 90 |
+
cache.set(obj, newObj);
|
| 91 |
+
}
|
| 92 |
+
return newObj;
|
| 93 |
+
}
|
| 94 |
+
const debug = (0, _debug.default)('next:start-server');
|
| 95 |
+
let startServerSpan;
|
| 96 |
+
/**
|
| 97 |
+
* Get the process ID (PID) of the process using the specified port
|
| 98 |
+
*/ async function getProcessIdUsingPort(port) {
|
| 99 |
+
const timeoutMs = 250;
|
| 100 |
+
const processLookupController = new AbortController();
|
| 101 |
+
const pidPromise = new Promise((resolve)=>{
|
| 102 |
+
const handleError = (error)=>{
|
| 103 |
+
debug('Failed to get process ID for port', port, error);
|
| 104 |
+
resolve(null);
|
| 105 |
+
};
|
| 106 |
+
try {
|
| 107 |
+
// Use lsof on Unix-like systems (macOS, Linux)
|
| 108 |
+
if (process.platform !== 'win32') {
|
| 109 |
+
(0, _child_process.exec)(`lsof -ti:${port} -sTCP:LISTEN`, {
|
| 110 |
+
signal: processLookupController.signal
|
| 111 |
+
}, (error, stdout)=>{
|
| 112 |
+
if (error) {
|
| 113 |
+
handleError(error);
|
| 114 |
+
return;
|
| 115 |
+
}
|
| 116 |
+
// `-sTCP` will ensure there's only one port, clean up output
|
| 117 |
+
const pid = stdout.trim();
|
| 118 |
+
resolve(pid || null);
|
| 119 |
+
});
|
| 120 |
+
} else {
|
| 121 |
+
// Use netstat on Windows
|
| 122 |
+
(0, _child_process.exec)(`netstat -ano | findstr /C:":${port} " | findstr LISTENING`, {
|
| 123 |
+
signal: processLookupController.signal
|
| 124 |
+
}, (error, stdout)=>{
|
| 125 |
+
if (error) {
|
| 126 |
+
handleError(error);
|
| 127 |
+
return;
|
| 128 |
+
}
|
| 129 |
+
// Clean up output and extract PID
|
| 130 |
+
const cleanOutput = stdout.replace(/\s+/g, ' ').trim();
|
| 131 |
+
if (cleanOutput) {
|
| 132 |
+
const lines = cleanOutput.split('\n');
|
| 133 |
+
const firstLine = lines[0].trim();
|
| 134 |
+
if (firstLine) {
|
| 135 |
+
const parts = firstLine.split(' ');
|
| 136 |
+
const pid = parts[parts.length - 1];
|
| 137 |
+
resolve(pid || null);
|
| 138 |
+
} else {
|
| 139 |
+
resolve(null);
|
| 140 |
+
}
|
| 141 |
+
} else {
|
| 142 |
+
resolve(null);
|
| 143 |
+
}
|
| 144 |
+
});
|
| 145 |
+
}
|
| 146 |
+
} catch (cause) {
|
| 147 |
+
handleError(new Error('Unexpected error during process lookup', {
|
| 148 |
+
cause
|
| 149 |
+
}));
|
| 150 |
+
}
|
| 151 |
+
});
|
| 152 |
+
const timeoutId = setTimeout(()=>{
|
| 153 |
+
processLookupController.abort(`PID detection timed out after ${timeoutMs}ms for port ${port}.`);
|
| 154 |
+
}, timeoutMs);
|
| 155 |
+
pidPromise.finally(()=>clearTimeout(timeoutId));
|
| 156 |
+
return pidPromise;
|
| 157 |
+
}
|
| 158 |
+
async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server, hostname, minimalMode, keepAliveTimeout, experimentalHttpsServer, serverFastRefresh, quiet }) {
|
| 159 |
+
return (0, _routerserver.initialize)({
|
| 160 |
+
dir,
|
| 161 |
+
port,
|
| 162 |
+
hostname,
|
| 163 |
+
onDevServerCleanup,
|
| 164 |
+
dev: isDev,
|
| 165 |
+
minimalMode,
|
| 166 |
+
server,
|
| 167 |
+
keepAliveTimeout,
|
| 168 |
+
experimentalHttpsServer,
|
| 169 |
+
serverFastRefresh,
|
| 170 |
+
startServerSpan,
|
| 171 |
+
quiet
|
| 172 |
+
});
|
| 173 |
+
}
|
| 174 |
+
async function startServer(serverOptions) {
|
| 175 |
+
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate, serverFastRefresh } = serverOptions;
|
| 176 |
+
let { port } = serverOptions;
|
| 177 |
+
process.title = `next-server (v${"16.4.0"})`;
|
| 178 |
+
let handlersReady = ()=>{};
|
| 179 |
+
let handlersError = ()=>{};
|
| 180 |
+
let handlersPromise = new Promise((resolve, reject)=>{
|
| 181 |
+
handlersReady = resolve;
|
| 182 |
+
handlersError = reject;
|
| 183 |
+
});
|
| 184 |
+
let requestHandler = async (req, res)=>{
|
| 185 |
+
if (handlersPromise) {
|
| 186 |
+
await handlersPromise;
|
| 187 |
+
return requestHandler(req, res);
|
| 188 |
+
}
|
| 189 |
+
throw new Error('Invariant request handler was not setup');
|
| 190 |
+
};
|
| 191 |
+
let upgradeHandler = async (req, socket, head)=>{
|
| 192 |
+
if (handlersPromise) {
|
| 193 |
+
await handlersPromise;
|
| 194 |
+
return upgradeHandler(req, socket, head);
|
| 195 |
+
}
|
| 196 |
+
throw new Error('Invariant upgrade handler was not setup');
|
| 197 |
+
};
|
| 198 |
+
let nextServer;
|
| 199 |
+
let devMemoryThresholdRestart = true;
|
| 200 |
+
// setup server listener as fast as possible
|
| 201 |
+
if (selfSignedCertificate && !isDev) {
|
| 202 |
+
throw new Error('Using a self signed certificate is only supported with `next dev`.');
|
| 203 |
+
}
|
| 204 |
+
async function requestListener(req, res) {
|
| 205 |
+
try {
|
| 206 |
+
if (handlersPromise) {
|
| 207 |
+
await handlersPromise;
|
| 208 |
+
handlersPromise = undefined;
|
| 209 |
+
}
|
| 210 |
+
await requestHandler(req, res);
|
| 211 |
+
} catch (err) {
|
| 212 |
+
res.statusCode = 500;
|
| 213 |
+
res.end('Internal Server Error');
|
| 214 |
+
_log.error(`Failed to handle request for ${req.url}`);
|
| 215 |
+
console.error(err);
|
| 216 |
+
} finally{
|
| 217 |
+
const memoryRestartStats = (0, _utils.getMemoryRestartStats)(isDev, devMemoryThresholdRestart, _v8.default.getHeapStatistics);
|
| 218 |
+
if (memoryRestartStats) {
|
| 219 |
+
_log.warn(`Server is approaching the used memory threshold, restarting...`);
|
| 220 |
+
(0, _trace.trace)('server-restart-close-to-memory-threshold', undefined, {
|
| 221 |
+
'memory.heapSizeLimit': String(memoryRestartStats.heap_size_limit),
|
| 222 |
+
'memory.heapUsed': String(memoryRestartStats.used_heap_size)
|
| 223 |
+
}).stop();
|
| 224 |
+
(0, _trace.flushAllTraces)();
|
| 225 |
+
process.exit(_utils.RESTART_EXIT_CODE);
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
const server = selfSignedCertificate ? _https.default.createServer({
|
| 230 |
+
key: _fs.default.readFileSync(selfSignedCertificate.key),
|
| 231 |
+
cert: _fs.default.readFileSync(selfSignedCertificate.cert)
|
| 232 |
+
}, requestListener) : _http.default.createServer(requestListener);
|
| 233 |
+
if (keepAliveTimeout) {
|
| 234 |
+
server.keepAliveTimeout = keepAliveTimeout;
|
| 235 |
+
}
|
| 236 |
+
server.on('upgrade', async (req, socket, head)=>{
|
| 237 |
+
try {
|
| 238 |
+
await upgradeHandler(req, socket, head);
|
| 239 |
+
} catch (err) {
|
| 240 |
+
socket.destroy();
|
| 241 |
+
_log.error(`Failed to handle request for ${req.url}`);
|
| 242 |
+
console.error(err);
|
| 243 |
+
}
|
| 244 |
+
});
|
| 245 |
+
let portRetryCount = 0;
|
| 246 |
+
const originalPort = port;
|
| 247 |
+
server.on('error', (err)=>{
|
| 248 |
+
if (allowRetry && port && isDev && err.code === 'EADDRINUSE' && portRetryCount < 10) {
|
| 249 |
+
port += 1;
|
| 250 |
+
portRetryCount += 1;
|
| 251 |
+
server.listen(port, hostname);
|
| 252 |
+
} else {
|
| 253 |
+
_log.error(`Failed to start server`);
|
| 254 |
+
console.error(err);
|
| 255 |
+
process.exit(1);
|
| 256 |
+
}
|
| 257 |
+
});
|
| 258 |
+
let cleanupListeners = isDev ? new _asynccallbackset.AsyncCallbackSet() : undefined;
|
| 259 |
+
const distDir = await new Promise((resolve)=>{
|
| 260 |
+
server.on('listening', async ()=>{
|
| 261 |
+
const addr = server.address();
|
| 262 |
+
const actualHostname = (0, _formathostname.formatHostname)(typeof addr === 'object' ? (addr == null ? void 0 : addr.address) || hostname || 'localhost' : addr);
|
| 263 |
+
const formattedHostname = !hostname || actualHostname === '0.0.0.0' ? 'localhost' : actualHostname === '[::]' ? '[::1]' : (0, _formathostname.formatHostname)(hostname);
|
| 264 |
+
port = typeof addr === 'object' ? (addr == null ? void 0 : addr.port) || port : port;
|
| 265 |
+
if (portRetryCount) {
|
| 266 |
+
const pid = await getProcessIdUsingPort(originalPort);
|
| 267 |
+
if (pid) {
|
| 268 |
+
_log.warn(`Port ${originalPort} is in use by process ${pid}, using available port ${port} instead.`);
|
| 269 |
+
} else {
|
| 270 |
+
_log.warn(`Port ${originalPort} is in use by an unknown process, using available port ${port} instead.`);
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
const networkHostname = hostname ?? (0, _getnetworkhost.getNetworkHost)((0, _isipv6.isIPv6)(actualHostname) ? 'IPv6' : 'IPv4');
|
| 274 |
+
const protocol = selfSignedCertificate ? 'https' : 'http';
|
| 275 |
+
const networkUrl = networkHostname ? `${protocol}://${(0, _formathostname.formatHostname)(networkHostname)}:${port}` : null;
|
| 276 |
+
const appUrl = `${protocol}://${formattedHostname}:${port}`;
|
| 277 |
+
// Store the selected port to:
|
| 278 |
+
// - expose it to render workers
|
| 279 |
+
// - re-use it for automatic dev server restarts with a randomly selected port
|
| 280 |
+
process.env.PORT = port + '';
|
| 281 |
+
process.env.__NEXT_PRIVATE_ORIGIN = appUrl;
|
| 282 |
+
// Set experimental HTTPS flag for metadata resolution
|
| 283 |
+
if (selfSignedCertificate) {
|
| 284 |
+
process.env.__NEXT_EXPERIMENTAL_HTTPS = '1';
|
| 285 |
+
}
|
| 286 |
+
// Get env info first (fast, doesn't require config)
|
| 287 |
+
const envInfo = isDev ? (0, _appinfolog.getEnvInfo)(dir) : undefined;
|
| 288 |
+
// Log basic startup info immediately (before loading config)
|
| 289 |
+
(0, _appinfolog.logStartInfo)({
|
| 290 |
+
networkUrl,
|
| 291 |
+
appUrl,
|
| 292 |
+
envInfo,
|
| 293 |
+
logBundler: isDev
|
| 294 |
+
});
|
| 295 |
+
// Calculate and log "Ready in X" before loading config
|
| 296 |
+
// so it reflects actual framework startup time.
|
| 297 |
+
// NEXT_PRIVATE_START_TIME is set by bin/next.ts or cli/next-start.ts.
|
| 298 |
+
const startTime = parseInt(process.env.NEXT_PRIVATE_START_TIME || '0', 10);
|
| 299 |
+
const endTime = Date.now();
|
| 300 |
+
const startServerProcessDurationMs = startTime ? endTime - startTime : 0;
|
| 301 |
+
const formattedStartDuration = (0, _durationtostring.durationToString)(startServerProcessDurationMs / 1000);
|
| 302 |
+
_log.event(`Ready in ${formattedStartDuration}`);
|
| 303 |
+
try {
|
| 304 |
+
let cleanupStarted = false;
|
| 305 |
+
let closeUpgraded = null;
|
| 306 |
+
const cleanup = (signal)=>{
|
| 307 |
+
if (cleanupStarted) {
|
| 308 |
+
// We can get duplicate signals, e.g. when `ctrl+c` is used in an
|
| 309 |
+
// interactive shell (i.e. bash, zsh), the shell will recursively
|
| 310 |
+
// send SIGINT to children. The parent `next-dev` process will also
|
| 311 |
+
// send us SIGINT.
|
| 312 |
+
return;
|
| 313 |
+
}
|
| 314 |
+
cleanupStarted = true;
|
| 315 |
+
(async ()=>{
|
| 316 |
+
debug('start-server process cleanup');
|
| 317 |
+
// first, stop accepting new connections and finish pending requests,
|
| 318 |
+
// because they might affect `nextServer.close()` (e.g. by scheduling an `after`)
|
| 319 |
+
await new Promise((res)=>{
|
| 320 |
+
server.close((err)=>{
|
| 321 |
+
if (err) console.error(err);
|
| 322 |
+
res();
|
| 323 |
+
});
|
| 324 |
+
if (isDev) {
|
| 325 |
+
server.closeAllConnections();
|
| 326 |
+
closeUpgraded == null ? void 0 : closeUpgraded();
|
| 327 |
+
}
|
| 328 |
+
});
|
| 329 |
+
// now that no new requests can come in, clean up the rest
|
| 330 |
+
await Promise.all([
|
| 331 |
+
nextServer == null ? void 0 : nextServer.close().catch(console.error),
|
| 332 |
+
cleanupListeners == null ? void 0 : cleanupListeners.runAll().catch(console.error)
|
| 333 |
+
]);
|
| 334 |
+
// Flush any remaining traces to the trace file on shutdown
|
| 335 |
+
(0, _trace.flushAllTraces)();
|
| 336 |
+
// Flush telemetry if this is a dev server
|
| 337 |
+
if (isDev) {
|
| 338 |
+
try {
|
| 339 |
+
const { traceGlobals } = require('../../trace/shared');
|
| 340 |
+
const telemetry = traceGlobals.get('telemetry');
|
| 341 |
+
if (telemetry) {
|
| 342 |
+
// Use flushDetached to avoid blocking process exit
|
| 343 |
+
// Each process writes to a unique file (_events_${pid}.json)
|
| 344 |
+
// to avoid race conditions with the parent process
|
| 345 |
+
telemetry.flushDetached({
|
| 346 |
+
mode: 'dev',
|
| 347 |
+
dir,
|
| 348 |
+
distDir: null,
|
| 349 |
+
events: null
|
| 350 |
+
});
|
| 351 |
+
}
|
| 352 |
+
} catch (_) {
|
| 353 |
+
// Ignore telemetry errors during cleanup
|
| 354 |
+
}
|
| 355 |
+
}
|
| 356 |
+
debug('start-server process cleanup finished');
|
| 357 |
+
// Exit with signal-based exit code (128 + signal number) so that
|
| 358 |
+
// Node.js treats this as a signal termination, not a normal exit.
|
| 359 |
+
// This avoids waiting for the debugger to disconnect.
|
| 360 |
+
switch(signal){
|
| 361 |
+
case 'SIGINT':
|
| 362 |
+
process.exit(130);
|
| 363 |
+
break;
|
| 364 |
+
case 'SIGTERM':
|
| 365 |
+
process.exit(143);
|
| 366 |
+
break;
|
| 367 |
+
default:
|
| 368 |
+
// Make sure all handled signals have explicit exit codes.
|
| 369 |
+
// This is just a fallback to guard against unsound types.
|
| 370 |
+
signal;
|
| 371 |
+
process.exit(128);
|
| 372 |
+
}
|
| 373 |
+
})();
|
| 374 |
+
};
|
| 375 |
+
// Make sure commands gracefully respect termination signals (e.g. from Docker)
|
| 376 |
+
// Allow the graceful termination to be manually configurable
|
| 377 |
+
if (!process.env.NEXT_MANUAL_SIG_HANDLE) {
|
| 378 |
+
process.on('SIGINT', cleanup);
|
| 379 |
+
process.on('SIGTERM', cleanup);
|
| 380 |
+
}
|
| 381 |
+
// Now load config via getRequestHandlers (single loadConfig call)
|
| 382 |
+
const initResult = await getRequestHandlers({
|
| 383 |
+
dir,
|
| 384 |
+
port,
|
| 385 |
+
isDev,
|
| 386 |
+
onDevServerCleanup: cleanupListeners ? cleanupListeners.add.bind(cleanupListeners) : undefined,
|
| 387 |
+
server,
|
| 388 |
+
hostname,
|
| 389 |
+
minimalMode,
|
| 390 |
+
keepAliveTimeout,
|
| 391 |
+
experimentalHttpsServer: !!selfSignedCertificate,
|
| 392 |
+
serverFastRefresh
|
| 393 |
+
});
|
| 394 |
+
devMemoryThresholdRestart = initResult.devMemoryThresholdRestart;
|
| 395 |
+
requestHandler = initResult.requestHandler;
|
| 396 |
+
upgradeHandler = initResult.upgradeHandler;
|
| 397 |
+
nextServer = initResult.server;
|
| 398 |
+
closeUpgraded = initResult.closeUpgraded;
|
| 399 |
+
// Log experimental features after config is loaded
|
| 400 |
+
if (isDev) {
|
| 401 |
+
(0, _appinfolog.logExperimentalInfo)({
|
| 402 |
+
experimentalFeatures: initResult.experimentalFeatures,
|
| 403 |
+
cacheComponents: initResult.cacheComponents,
|
| 404 |
+
partialPrefetching: initResult.partialPrefetching
|
| 405 |
+
});
|
| 406 |
+
logAgentFileSync(await (0, _appinfolog.syncAgentRulesForDev)(dir, initResult.agentRules !== false), (files)=>`Generated ${files} for AI agents. Set \`agentRules: false\` in next.config to disable.`, (files)=>`Removed agent rules from ${files} because \`agentRules\` is disabled.`);
|
| 407 |
+
if (!_ciinfo.isCI) {
|
| 408 |
+
const { traceGlobals } = require('../../trace/shared');
|
| 409 |
+
const telemetry = traceGlobals.get('telemetry');
|
| 410 |
+
const agentFeedbackConfigured = initResult.agentFeedback === true;
|
| 411 |
+
const telemetryEnabled = (telemetry == null ? void 0 : telemetry.isEnabled) === true;
|
| 412 |
+
logAgentFileSync(await (0, _appinfolog.syncAgentFeedbackForDev)(dir, agentFeedbackConfigured && telemetryEnabled), (files)=>`Generated agent feedback instructions in ${files}. Set \`experimental.agentFeedback: false\` in next.config to disable.`, (files)=>agentFeedbackConfigured ? `Removed agent feedback instructions from ${files} because Next.js Telemetry is disabled.` : `Removed agent feedback instructions from ${files} because \`experimental.agentFeedback\` is disabled.`);
|
| 413 |
+
}
|
| 414 |
+
}
|
| 415 |
+
handlersReady();
|
| 416 |
+
if (process.env.TURBOPACK && isDev) {
|
| 417 |
+
await (0, _turbopackwarning.validateTurboNextConfig)({
|
| 418 |
+
dir: serverOptions.dir,
|
| 419 |
+
configPhase: _constants.PHASE_DEVELOPMENT_SERVER
|
| 420 |
+
});
|
| 421 |
+
}
|
| 422 |
+
resolve(initResult.distDir);
|
| 423 |
+
} catch (err) {
|
| 424 |
+
// fatal error if we can't setup
|
| 425 |
+
handlersError();
|
| 426 |
+
console.error(err);
|
| 427 |
+
process.exit(1);
|
| 428 |
+
}
|
| 429 |
+
});
|
| 430 |
+
server.listen(port, hostname);
|
| 431 |
+
});
|
| 432 |
+
// Watch config files for changes and distDir ancestors for deletion.
|
| 433 |
+
if (isDev) {
|
| 434 |
+
// Note: dir is absolute and normalized (`..` segments removed), `absDistDir`
|
| 435 |
+
// is also normalized because `path.join()` performs normalization. `distDir`
|
| 436 |
+
// does not have to be inside of `dir`!
|
| 437 |
+
const absDistDir = _path.default.join(dir, distDir);
|
| 438 |
+
// always watch dir and absDistDir
|
| 439 |
+
const dirWatchPaths = [
|
| 440 |
+
dir,
|
| 441 |
+
absDistDir
|
| 442 |
+
];
|
| 443 |
+
// also watch ancestors of absDistDir that are inside of dir.
|
| 444 |
+
let prevAncestor = absDistDir;
|
| 445 |
+
while(true){
|
| 446 |
+
const nextAncestor = _path.default.dirname(prevAncestor);
|
| 447 |
+
// note: `dirname('/') === '/'` if we happen to reach the FS root
|
| 448 |
+
if (!nextAncestor.startsWith(dir + _path.default.sep) || nextAncestor === prevAncestor) {
|
| 449 |
+
break;
|
| 450 |
+
}
|
| 451 |
+
dirWatchPaths.push(nextAncestor);
|
| 452 |
+
prevAncestor = nextAncestor;
|
| 453 |
+
}
|
| 454 |
+
const configFiles = _constants.CONFIG_FILES.map((file)=>_path.default.join(dir, file));
|
| 455 |
+
const Watchpack = require('next/dist/compiled/watchpack');
|
| 456 |
+
const wp = new Watchpack();
|
| 457 |
+
wp.watch({
|
| 458 |
+
files: configFiles,
|
| 459 |
+
missing: dirWatchPaths
|
| 460 |
+
});
|
| 461 |
+
wp.on('change', async (filename)=>{
|
| 462 |
+
if (!configFiles.includes(filename)) {
|
| 463 |
+
return;
|
| 464 |
+
}
|
| 465 |
+
_log.warn(`Found a change in ${_path.default.basename(filename)}. Restarting the server to apply the changes...`);
|
| 466 |
+
process.exit(_utils.RESTART_EXIT_CODE);
|
| 467 |
+
});
|
| 468 |
+
wp.on('remove', (removedPath)=>{
|
| 469 |
+
if (dirWatchPaths.includes(removedPath)) {
|
| 470 |
+
_log.error(`The directory at "${removedPath}" was deleted.\n\n` + 'Deleting this directory removes caches and will cause slower ' + 'performance.\n\n' + 'Deleting this directory while Next.js is running can lead to ' + 'undefined behavior. Restarting the server to recover...');
|
| 471 |
+
process.exit(_utils.RESTART_EXIT_CODE);
|
| 472 |
+
}
|
| 473 |
+
});
|
| 474 |
+
}
|
| 475 |
+
return {
|
| 476 |
+
distDir
|
| 477 |
+
};
|
| 478 |
+
}
|
| 479 |
+
if (process.env.NEXT_PRIVATE_WORKER && process.send) {
|
| 480 |
+
// Output is piped to the CLI to hold it while the upgrade menu is open.
|
| 481 |
+
if (process.env.NEXT_PRIVATE_PROMPT_OUTPUT === '1') {
|
| 482 |
+
(0, _utils.blockOnOutputWrites)();
|
| 483 |
+
}
|
| 484 |
+
process.addListener('message', async (msg)=>{
|
| 485 |
+
if (msg && typeof msg === 'object' && msg.nextWorkerOptions && process.send) {
|
| 486 |
+
let enabledFeaturesFromParent = {};
|
| 487 |
+
if (process.env.NEXT_PRIVATE_ENABLED_FEATURES) {
|
| 488 |
+
const parsed = JSON.parse(process.env.NEXT_PRIVATE_ENABLED_FEATURES);
|
| 489 |
+
enabledFeaturesFromParent = Object.fromEntries(Object.entries(parsed).map(([key, value])=>[
|
| 490 |
+
`feature.${key}`,
|
| 491 |
+
value
|
| 492 |
+
]));
|
| 493 |
+
}
|
| 494 |
+
let rageRestartAttrsFromParent = {};
|
| 495 |
+
if (process.env.NEXT_PRIVATE_DEV_SPAN_ATTRS) {
|
| 496 |
+
rageRestartAttrsFromParent = JSON.parse(process.env.NEXT_PRIVATE_DEV_SPAN_ATTRS);
|
| 497 |
+
}
|
| 498 |
+
startServerSpan = (0, _trace.trace)('start-dev-server', undefined, {
|
| 499 |
+
cpus: String(_os.default.cpus().length),
|
| 500 |
+
platform: _os.default.platform(),
|
| 501 |
+
'memory.freeMem': String(_os.default.freemem()),
|
| 502 |
+
'memory.totalMem': String(_os.default.totalmem()),
|
| 503 |
+
'memory.heapSizeLimit': String(_v8.default.getHeapStatistics().heap_size_limit),
|
| 504 |
+
...enabledFeaturesFromParent,
|
| 505 |
+
...rageRestartAttrsFromParent
|
| 506 |
+
});
|
| 507 |
+
(0, _trace.initializeTraceState)({
|
| 508 |
+
...(0, _trace.exportTraceState)(),
|
| 509 |
+
defaultParentSpanId: startServerSpan.getId()
|
| 510 |
+
});
|
| 511 |
+
const result = await startServerSpan.traceAsyncFn(()=>startServer(msg.nextWorkerOptions));
|
| 512 |
+
const memoryUsage = process.memoryUsage();
|
| 513 |
+
startServerSpan.setAttribute('memory.rss', String(memoryUsage.rss));
|
| 514 |
+
startServerSpan.setAttribute('memory.heapTotal', String(memoryUsage.heapTotal));
|
| 515 |
+
startServerSpan.setAttribute('memory.heapUsed', String(memoryUsage.heapUsed));
|
| 516 |
+
process.send({
|
| 517 |
+
nextServerReady: true,
|
| 518 |
+
port: process.env.PORT,
|
| 519 |
+
distDir: result.distDir
|
| 520 |
+
});
|
| 521 |
+
}
|
| 522 |
+
});
|
| 523 |
+
process.send({
|
| 524 |
+
nextWorkerReady: true
|
| 525 |
+
});
|
| 526 |
+
}
|
| 527 |
+
/**
|
| 528 |
+
* Report which agent files a managed-block sync touched. Silent when the sync
|
| 529 |
+
* was a no-op so every `next dev` start doesn't mention the files.
|
| 530 |
+
*/ function logAgentFileSync(result, generatedMessage, removedMessage) {
|
| 531 |
+
if (!result) return;
|
| 532 |
+
const generated = [];
|
| 533 |
+
const removed = [];
|
| 534 |
+
for (const [file, action] of [
|
| 535 |
+
[
|
| 536 |
+
'AGENTS.md',
|
| 537 |
+
result.agentsMd
|
| 538 |
+
]
|
| 539 |
+
]){
|
| 540 |
+
if (action === 'created' || action === 'updated') {
|
| 541 |
+
generated.push(file);
|
| 542 |
+
} else if (action === 'removed') {
|
| 543 |
+
removed.push(file);
|
| 544 |
+
}
|
| 545 |
+
}
|
| 546 |
+
if (generated.length > 0) _log.event(generatedMessage(generated.join(' and ')));
|
| 547 |
+
if (removed.length > 0) _log.event(removedMessage(removed.join(' and ')));
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
//# sourceMappingURL=start-server.js.map
|
e-commerce/node_modules/next/dist/server/lib/start-server.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/server/lib/start-server.ts"],"sourcesContent":["// Start CPU profile if it wasn't already started.\nimport './cpu-profile'\nimport { getNetworkHost } from '../../lib/get-network-host'\n\nimport '../next'\nimport '../require-hook'\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type { SelfSignedCertificate } from '../../lib/mkcert'\nimport type { WorkerRequestHandler, WorkerUpgradeHandler } from './types'\n\nimport fs from 'fs'\nimport v8 from 'v8'\nimport path from 'path'\nimport http from 'http'\nimport https from 'https'\nimport os from 'os'\nimport { exec } from 'child_process'\nimport * as Log from '../../build/output/log'\nimport setupDebug from 'next/dist/compiled/debug'\nimport {\n blockOnOutputWrites,\n getMemoryRestartStats,\n RESTART_EXIT_CODE,\n} from './utils'\nimport { formatHostname } from './format-hostname'\nimport { initialize } from './router-server'\nimport {\n CONFIG_FILES,\n PHASE_DEVELOPMENT_SERVER,\n} from '../../shared/lib/constants'\nimport {\n getEnvInfo,\n logExperimentalInfo,\n logStartInfo,\n syncAgentFeedbackForDev,\n syncAgentRulesForDev,\n} from './app-info-log'\nimport type { AgentFilesResult } from './generate-agent-files'\nimport { validateTurboNextConfig } from '../../lib/turbopack-warning'\nimport {\n type Span,\n trace,\n flushAllTraces,\n exportTraceState,\n initializeTraceState,\n} from '../../trace'\nimport { isIPv6 } from './is-ipv6'\nimport { AsyncCallbackSet } from './async-callback-set'\nimport type { NextServer } from '../next'\nimport { durationToString } from '../../build/duration-to-string'\nimport { isCI } from '../ci-info'\n\nconst debug = setupDebug('next:start-server')\nlet startServerSpan: Span | undefined\n\n/**\n * Get the process ID (PID) of the process using the specified port\n */\nasync function getProcessIdUsingPort(port: number): Promise<string | null> {\n const timeoutMs = 250\n const processLookupController = new AbortController()\n\n const pidPromise = new Promise<string | null>((resolve) => {\n const handleError = (error: Error) => {\n debug('Failed to get process ID for port', port, error)\n resolve(null)\n }\n\n try {\n // Use lsof on Unix-like systems (macOS, Linux)\n if (process.platform !== 'win32') {\n exec(\n `lsof -ti:${port} -sTCP:LISTEN`,\n { signal: processLookupController.signal },\n (error, stdout) => {\n if (error) {\n handleError(error)\n return\n }\n // `-sTCP` will ensure there's only one port, clean up output\n const pid = stdout.trim()\n resolve(pid || null)\n }\n )\n } else {\n // Use netstat on Windows\n exec(\n `netstat -ano | findstr /C:\":${port} \" | findstr LISTENING`,\n { signal: processLookupController.signal },\n (error, stdout) => {\n if (error) {\n handleError(error)\n return\n }\n // Clean up output and extract PID\n const cleanOutput = stdout.replace(/\\s+/g, ' ').trim()\n if (cleanOutput) {\n const lines = cleanOutput.split('\\n')\n const firstLine = lines[0].trim()\n if (firstLine) {\n const parts = firstLine.split(' ')\n const pid = parts[parts.length - 1]\n resolve(pid || null)\n } else {\n resolve(null)\n }\n } else {\n resolve(null)\n }\n }\n )\n }\n } catch (cause) {\n handleError(\n new Error('Unexpected error during process lookup', { cause })\n )\n }\n })\n\n const timeoutId = setTimeout(() => {\n processLookupController.abort(\n `PID detection timed out after ${timeoutMs}ms for port ${port}.`\n )\n }, timeoutMs)\n\n pidPromise.finally(() => clearTimeout(timeoutId))\n\n return pidPromise\n}\n\nexport interface StartServerOptions {\n dir: string\n port: number\n isDev: boolean\n hostname?: string\n allowRetry?: boolean\n customServer?: boolean\n minimalMode?: boolean\n keepAliveTimeout?: number\n // this is dev-server only\n selfSignedCertificate?: SelfSignedCertificate\n serverFastRefresh?: boolean\n}\n\nexport async function getRequestHandlers({\n dir,\n port,\n isDev,\n onDevServerCleanup,\n server,\n hostname,\n minimalMode,\n keepAliveTimeout,\n experimentalHttpsServer,\n serverFastRefresh,\n quiet,\n}: {\n dir: string\n port: number\n isDev: boolean\n onDevServerCleanup: ((listener: () => Promise<void>) => void) | undefined\n server?: import('http').Server\n hostname?: string\n minimalMode?: boolean\n keepAliveTimeout?: number\n experimentalHttpsServer?: boolean\n serverFastRefresh?: boolean\n quiet?: boolean\n}): ReturnType<typeof initialize> {\n return initialize({\n dir,\n port,\n hostname,\n onDevServerCleanup,\n dev: isDev,\n minimalMode,\n server,\n keepAliveTimeout,\n experimentalHttpsServer,\n serverFastRefresh,\n startServerSpan,\n quiet,\n })\n}\n\nexport type StartServerResult = {\n distDir: string\n}\n\nexport async function startServer(\n serverOptions: StartServerOptions\n): Promise<StartServerResult> {\n const {\n dir,\n isDev,\n hostname,\n minimalMode,\n allowRetry,\n keepAliveTimeout,\n selfSignedCertificate,\n serverFastRefresh,\n } = serverOptions\n let { port } = serverOptions\n\n process.title = `next-server (v${process.env.__NEXT_VERSION})`\n let handlersReady = () => {}\n let handlersError = () => {}\n\n let handlersPromise: Promise<void> | undefined = new Promise<void>(\n (resolve, reject) => {\n handlersReady = resolve\n handlersError = reject\n }\n )\n let requestHandler: WorkerRequestHandler = async (\n req: IncomingMessage,\n res: ServerResponse\n ): Promise<void> => {\n if (handlersPromise) {\n await handlersPromise\n return requestHandler(req, res)\n }\n throw new Error('Invariant request handler was not setup')\n }\n let upgradeHandler: WorkerUpgradeHandler = async (\n req,\n socket,\n head\n ): Promise<void> => {\n if (handlersPromise) {\n await handlersPromise\n return upgradeHandler(req, socket, head)\n }\n throw new Error('Invariant upgrade handler was not setup')\n }\n\n let nextServer: NextServer | undefined\n let devMemoryThresholdRestart = true\n\n // setup server listener as fast as possible\n if (selfSignedCertificate && !isDev) {\n throw new Error(\n 'Using a self signed certificate is only supported with `next dev`.'\n )\n }\n\n async function requestListener(req: IncomingMessage, res: ServerResponse) {\n try {\n if (handlersPromise) {\n await handlersPromise\n handlersPromise = undefined\n }\n await requestHandler(req, res)\n } catch (err) {\n res.statusCode = 500\n res.end('Internal Server Error')\n Log.error(`Failed to handle request for ${req.url}`)\n console.error(err)\n } finally {\n const memoryRestartStats = getMemoryRestartStats(\n isDev,\n devMemoryThresholdRestart,\n v8.getHeapStatistics\n )\n if (memoryRestartStats) {\n Log.warn(\n `Server is approaching the used memory threshold, restarting...`\n )\n trace('server-restart-close-to-memory-threshold', undefined, {\n 'memory.heapSizeLimit': String(memoryRestartStats.heap_size_limit),\n 'memory.heapUsed': String(memoryRestartStats.used_heap_size),\n }).stop()\n flushAllTraces()\n process.exit(RESTART_EXIT_CODE)\n }\n }\n }\n\n const server = selfSignedCertificate\n ? https.createServer(\n {\n key: fs.readFileSync(selfSignedCertificate.key),\n cert: fs.readFileSync(selfSignedCertificate.cert),\n },\n requestListener\n )\n : http.createServer(requestListener)\n\n if (keepAliveTimeout) {\n server.keepAliveTimeout = keepAliveTimeout\n }\n server.on('upgrade', async (req, socket, head) => {\n try {\n await upgradeHandler(req, socket, head)\n } catch (err) {\n socket.destroy()\n Log.error(`Failed to handle request for ${req.url}`)\n console.error(err)\n }\n })\n\n let portRetryCount = 0\n const originalPort = port\n\n server.on('error', (err: NodeJS.ErrnoException) => {\n if (\n allowRetry &&\n port &&\n isDev &&\n err.code === 'EADDRINUSE' &&\n portRetryCount < 10\n ) {\n port += 1\n portRetryCount += 1\n server.listen(port, hostname)\n } else {\n Log.error(`Failed to start server`)\n console.error(err)\n process.exit(1)\n }\n })\n\n let cleanupListeners = isDev ? new AsyncCallbackSet() : undefined\n\n const distDir = await new Promise<string>((resolve) => {\n server.on('listening', async () => {\n const addr = server.address()\n const actualHostname = formatHostname(\n typeof addr === 'object'\n ? addr?.address || hostname || 'localhost'\n : addr\n )\n const formattedHostname =\n !hostname || actualHostname === '0.0.0.0'\n ? 'localhost'\n : actualHostname === '[::]'\n ? '[::1]'\n : formatHostname(hostname)\n\n port = typeof addr === 'object' ? addr?.port || port : port\n\n if (portRetryCount) {\n const pid = await getProcessIdUsingPort(originalPort)\n if (pid) {\n Log.warn(\n `Port ${originalPort} is in use by process ${pid}, using available port ${port} instead.`\n )\n } else {\n Log.warn(\n `Port ${originalPort} is in use by an unknown process, using available port ${port} instead.`\n )\n }\n }\n\n const networkHostname =\n hostname ?? getNetworkHost(isIPv6(actualHostname) ? 'IPv6' : 'IPv4')\n\n const protocol = selfSignedCertificate ? 'https' : 'http'\n\n const networkUrl = networkHostname\n ? `${protocol}://${formatHostname(networkHostname)}:${port}`\n : null\n\n const appUrl = `${protocol}://${formattedHostname}:${port}`\n\n // Store the selected port to:\n // - expose it to render workers\n // - re-use it for automatic dev server restarts with a randomly selected port\n process.env.PORT = port + ''\n\n process.env.__NEXT_PRIVATE_ORIGIN = appUrl\n\n // Set experimental HTTPS flag for metadata resolution\n if (selfSignedCertificate) {\n process.env.__NEXT_EXPERIMENTAL_HTTPS = '1'\n }\n\n // Get env info first (fast, doesn't require config)\n const envInfo = isDev ? getEnvInfo(dir) : undefined\n\n // Log basic startup info immediately (before loading config)\n logStartInfo({\n networkUrl,\n appUrl,\n envInfo,\n logBundler: isDev,\n })\n\n // Calculate and log \"Ready in X\" before loading config\n // so it reflects actual framework startup time.\n // NEXT_PRIVATE_START_TIME is set by bin/next.ts or cli/next-start.ts.\n const startTime = parseInt(process.env.NEXT_PRIVATE_START_TIME || '0', 10)\n const endTime = Date.now()\n const startServerProcessDurationMs = startTime ? endTime - startTime : 0\n\n const formattedStartDuration = durationToString(\n startServerProcessDurationMs / 1000\n )\n\n Log.event(`Ready in ${formattedStartDuration}`)\n\n try {\n let cleanupStarted = false\n let closeUpgraded: (() => void) | null = null\n const cleanup = (signal: 'SIGINT' | 'SIGTERM') => {\n if (cleanupStarted) {\n // We can get duplicate signals, e.g. when `ctrl+c` is used in an\n // interactive shell (i.e. bash, zsh), the shell will recursively\n // send SIGINT to children. The parent `next-dev` process will also\n // send us SIGINT.\n return\n }\n cleanupStarted = true\n ;(async () => {\n debug('start-server process cleanup')\n\n // first, stop accepting new connections and finish pending requests,\n // because they might affect `nextServer.close()` (e.g. by scheduling an `after`)\n await new Promise<void>((res) => {\n server.close((err) => {\n if (err) console.error(err)\n res()\n })\n if (isDev) {\n server.closeAllConnections()\n closeUpgraded?.()\n }\n })\n\n // now that no new requests can come in, clean up the rest\n await Promise.all([\n nextServer?.close().catch(console.error),\n cleanupListeners?.runAll().catch(console.error),\n ])\n\n // Flush any remaining traces to the trace file on shutdown\n flushAllTraces()\n\n // Flush telemetry if this is a dev server\n if (isDev) {\n try {\n const { traceGlobals } =\n require('../../trace/shared') as typeof import('../../trace/shared')\n const telemetry = traceGlobals.get('telemetry') as\n | InstanceType<\n typeof import('../../telemetry/storage').Telemetry\n >\n | undefined\n if (telemetry) {\n // Use flushDetached to avoid blocking process exit\n // Each process writes to a unique file (_events_${pid}.json)\n // to avoid race conditions with the parent process\n telemetry.flushDetached({\n mode: 'dev',\n dir,\n distDir: null,\n events: null,\n })\n }\n } catch (_) {\n // Ignore telemetry errors during cleanup\n }\n }\n\n debug('start-server process cleanup finished')\n\n // Exit with signal-based exit code (128 + signal number) so that\n // Node.js treats this as a signal termination, not a normal exit.\n // This avoids waiting for the debugger to disconnect.\n switch (signal) {\n case 'SIGINT':\n process.exit(130)\n break\n case 'SIGTERM':\n process.exit(143)\n break\n default:\n // Make sure all handled signals have explicit exit codes.\n // This is just a fallback to guard against unsound types.\n signal satisfies never\n process.exit(128)\n }\n })()\n }\n\n // Make sure commands gracefully respect termination signals (e.g. from Docker)\n // Allow the graceful termination to be manually configurable\n if (!process.env.NEXT_MANUAL_SIG_HANDLE) {\n process.on('SIGINT', cleanup)\n process.on('SIGTERM', cleanup)\n }\n\n // Now load config via getRequestHandlers (single loadConfig call)\n const initResult = await getRequestHandlers({\n dir,\n port,\n isDev,\n onDevServerCleanup: cleanupListeners\n ? cleanupListeners.add.bind(cleanupListeners)\n : undefined,\n server,\n hostname,\n minimalMode,\n keepAliveTimeout,\n experimentalHttpsServer: !!selfSignedCertificate,\n serverFastRefresh,\n })\n devMemoryThresholdRestart = initResult.devMemoryThresholdRestart\n requestHandler = initResult.requestHandler\n upgradeHandler = initResult.upgradeHandler\n nextServer = initResult.server\n closeUpgraded = initResult.closeUpgraded\n\n // Log experimental features after config is loaded\n if (isDev) {\n logExperimentalInfo({\n experimentalFeatures: initResult.experimentalFeatures,\n cacheComponents: initResult.cacheComponents,\n partialPrefetching: initResult.partialPrefetching,\n })\n\n logAgentFileSync(\n await syncAgentRulesForDev(dir, initResult.agentRules !== false),\n (files) =>\n `Generated ${files} for AI agents. Set \\`agentRules: false\\` in next.config to disable.`,\n (files) =>\n `Removed agent rules from ${files} because \\`agentRules\\` is disabled.`\n )\n\n if (!isCI) {\n const { traceGlobals } =\n require('../../trace/shared') as typeof import('../../trace/shared')\n const telemetry = traceGlobals.get('telemetry') as\n | InstanceType<typeof import('../../telemetry/storage').Telemetry>\n | undefined\n const agentFeedbackConfigured = initResult.agentFeedback === true\n const telemetryEnabled = telemetry?.isEnabled === true\n\n logAgentFileSync(\n await syncAgentFeedbackForDev(\n dir,\n agentFeedbackConfigured && telemetryEnabled\n ),\n (files) =>\n `Generated agent feedback instructions in ${files}. Set \\`experimental.agentFeedback: false\\` in next.config to disable.`,\n (files) =>\n agentFeedbackConfigured\n ? `Removed agent feedback instructions from ${files} because Next.js Telemetry is disabled.`\n : `Removed agent feedback instructions from ${files} because \\`experimental.agentFeedback\\` is disabled.`\n )\n }\n }\n\n handlersReady()\n\n if (process.env.TURBOPACK && isDev) {\n await validateTurboNextConfig({\n dir: serverOptions.dir,\n configPhase: PHASE_DEVELOPMENT_SERVER,\n })\n }\n\n resolve(initResult.distDir)\n } catch (err) {\n // fatal error if we can't setup\n handlersError()\n console.error(err)\n process.exit(1)\n }\n })\n server.listen(port, hostname)\n })\n\n // Watch config files for changes and distDir ancestors for deletion.\n if (isDev) {\n // Note: dir is absolute and normalized (`..` segments removed), `absDistDir`\n // is also normalized because `path.join()` performs normalization. `distDir`\n // does not have to be inside of `dir`!\n const absDistDir = path.join(dir, distDir)\n // always watch dir and absDistDir\n const dirWatchPaths: string[] = [dir, absDistDir]\n // also watch ancestors of absDistDir that are inside of dir.\n let prevAncestor = absDistDir\n while (true) {\n const nextAncestor = path.dirname(prevAncestor)\n // note: `dirname('/') === '/'` if we happen to reach the FS root\n if (\n !nextAncestor.startsWith(dir + path.sep) ||\n nextAncestor === prevAncestor\n ) {\n break\n }\n dirWatchPaths.push(nextAncestor)\n prevAncestor = nextAncestor\n }\n\n const configFiles = CONFIG_FILES.map((file) => path.join(dir, file))\n const Watchpack =\n require('next/dist/compiled/watchpack') as typeof import('next/dist/compiled/watchpack').default\n const wp = new Watchpack()\n wp.watch({\n files: configFiles,\n missing: dirWatchPaths,\n })\n wp.on('change', async (filename) => {\n if (!configFiles.includes(filename)) {\n return\n }\n Log.warn(\n `Found a change in ${path.basename(\n filename\n )}. Restarting the server to apply the changes...`\n )\n process.exit(RESTART_EXIT_CODE)\n })\n wp.on('remove', (removedPath: string) => {\n if (dirWatchPaths.includes(removedPath)) {\n Log.error(\n `The directory at \"${removedPath}\" was deleted.\\n\\n` +\n 'Deleting this directory removes caches and will cause slower ' +\n 'performance.\\n\\n' +\n 'Deleting this directory while Next.js is running can lead to ' +\n 'undefined behavior. Restarting the server to recover...'\n )\n process.exit(RESTART_EXIT_CODE)\n }\n })\n }\n\n return { distDir }\n}\n\nif (process.env.NEXT_PRIVATE_WORKER && process.send) {\n // Output is piped to the CLI to hold it while the upgrade menu is open.\n if (process.env.NEXT_PRIVATE_PROMPT_OUTPUT === '1') {\n blockOnOutputWrites()\n }\n process.addListener('message', async (msg: any) => {\n if (\n msg &&\n typeof msg === 'object' &&\n msg.nextWorkerOptions &&\n process.send\n ) {\n let enabledFeaturesFromParent = {}\n if (process.env.NEXT_PRIVATE_ENABLED_FEATURES) {\n const parsed = JSON.parse(process.env.NEXT_PRIVATE_ENABLED_FEATURES)\n enabledFeaturesFromParent = Object.fromEntries(\n Object.entries(parsed).map(([key, value]) => [\n `feature.${key}`,\n value,\n ])\n )\n }\n\n let rageRestartAttrsFromParent = {}\n if (process.env.NEXT_PRIVATE_DEV_SPAN_ATTRS) {\n rageRestartAttrsFromParent = JSON.parse(\n process.env.NEXT_PRIVATE_DEV_SPAN_ATTRS\n )\n }\n\n startServerSpan = trace('start-dev-server', undefined, {\n cpus: String(os.cpus().length),\n platform: os.platform(),\n 'memory.freeMem': String(os.freemem()),\n 'memory.totalMem': String(os.totalmem()),\n 'memory.heapSizeLimit': String(v8.getHeapStatistics().heap_size_limit),\n ...enabledFeaturesFromParent,\n ...rageRestartAttrsFromParent,\n })\n\n initializeTraceState({\n ...exportTraceState(),\n defaultParentSpanId: startServerSpan.getId(),\n })\n\n const result = await startServerSpan.traceAsyncFn(() =>\n startServer(msg.nextWorkerOptions)\n )\n const memoryUsage = process.memoryUsage()\n startServerSpan.setAttribute('memory.rss', String(memoryUsage.rss))\n startServerSpan.setAttribute(\n 'memory.heapTotal',\n String(memoryUsage.heapTotal)\n )\n startServerSpan.setAttribute(\n 'memory.heapUsed',\n String(memoryUsage.heapUsed)\n )\n process.send({\n nextServerReady: true,\n port: process.env.PORT,\n distDir: result.distDir,\n })\n }\n })\n process.send({ nextWorkerReady: true })\n}\n\n/**\n * Report which agent files a managed-block sync touched. Silent when the sync\n * was a no-op so every `next dev` start doesn't mention the files.\n */\nfunction logAgentFileSync(\n result: AgentFilesResult | null,\n generatedMessage: (files: string) => string,\n removedMessage: (files: string) => string\n): void {\n if (!result) return\n\n const generated: string[] = []\n const removed: string[] = []\n for (const [file, action] of [['AGENTS.md', result.agentsMd]] as const) {\n if (action === 'created' || action === 'updated') {\n generated.push(file)\n } else if (action === 'removed') {\n removed.push(file)\n }\n }\n if (generated.length > 0) Log.event(generatedMessage(generated.join(' and ')))\n if (removed.length > 0) Log.event(removedMessage(removed.join(' and ')))\n}\n"],"names":["getRequestHandlers","startServer","debug","setupDebug","startServerSpan","getProcessIdUsingPort","port","timeoutMs","processLookupController","AbortController","pidPromise","Promise","resolve","handleError","error","process","platform","exec","signal","stdout","pid","trim","cleanOutput","replace","lines","split","firstLine","parts","length","cause","Error","timeoutId","setTimeout","abort","finally","clearTimeout","dir","isDev","onDevServerCleanup","server","hostname","minimalMode","keepAliveTimeout","experimentalHttpsServer","serverFastRefresh","quiet","initialize","dev","serverOptions","allowRetry","selfSignedCertificate","title","env","__NEXT_VERSION","handlersReady","handlersError","handlersPromise","reject","requestHandler","req","res","upgradeHandler","socket","head","nextServer","devMemoryThresholdRestart","requestListener","undefined","err","statusCode","end","Log","url","console","memoryRestartStats","getMemoryRestartStats","v8","getHeapStatistics","warn","trace","String","heap_size_limit","used_heap_size","stop","flushAllTraces","exit","RESTART_EXIT_CODE","https","createServer","key","fs","readFileSync","cert","http","on","destroy","portRetryCount","originalPort","code","listen","cleanupListeners","AsyncCallbackSet","distDir","addr","address","actualHostname","formatHostname","formattedHostname","networkHostname","getNetworkHost","isIPv6","protocol","networkUrl","appUrl","PORT","__NEXT_PRIVATE_ORIGIN","__NEXT_EXPERIMENTAL_HTTPS","envInfo","getEnvInfo","logStartInfo","logBundler","startTime","parseInt","NEXT_PRIVATE_START_TIME","endTime","Date","now","startServerProcessDurationMs","formattedStartDuration","durationToString","event","cleanupStarted","closeUpgraded","cleanup","close","closeAllConnections","all","catch","runAll","traceGlobals","require","telemetry","get","flushDetached","mode","events","_","NEXT_MANUAL_SIG_HANDLE","initResult","add","bind","logExperimentalInfo","experimentalFeatures","cacheComponents","partialPrefetching","logAgentFileSync","syncAgentRulesForDev","agentRules","files","isCI","agentFeedbackConfigured","agentFeedback","telemetryEnabled","isEnabled","syncAgentFeedbackForDev","TURBOPACK","validateTurboNextConfig","configPhase","PHASE_DEVELOPMENT_SERVER","absDistDir","path","join","dirWatchPaths","prevAncestor","nextAncestor","dirname","startsWith","sep","push","configFiles","CONFIG_FILES","map","file","Watchpack","wp","watch","missing","filename","includes","basename","removedPath","NEXT_PRIVATE_WORKER","send","NEXT_PRIVATE_PROMPT_OUTPUT","blockOnOutputWrites","addListener","msg","nextWorkerOptions","enabledFeaturesFromParent","NEXT_PRIVATE_ENABLED_FEATURES","parsed","JSON","parse","Object","fromEntries","entries","value","rageRestartAttrsFromParent","NEXT_PRIVATE_DEV_SPAN_ATTRS","cpus","os","freemem","totalmem","initializeTraceState","exportTraceState","defaultParentSpanId","getId","result","traceAsyncFn","memoryUsage","setAttribute","rss","heapTotal","heapUsed","nextServerReady","nextWorkerReady","generatedMessage","removedMessage","generated","removed","action","agentsMd"],"mappings":"AAAA,kDAAkD;;;;;;;;;;;;;;;;IAiJ5BA,kBAAkB;eAAlBA;;IA6CAC,WAAW;eAAXA;;;QA7Lf;gCACwB;QAExB;QACA;2DAMQ;2DACA;6DACE;6DACA;8DACC;2DACH;+BACM;6DACA;8DACE;uBAKhB;gCACwB;8BACJ;2BAIpB;4BAOA;kCAEiC;uBAOjC;wBACgB;kCACU;kCAEA;wBACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErB,MAAM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AAOc,QAAQ;SAAC;KAAC,CAAW;QACtE,IAAID,WAAW,aAAaA,WAAW,WAAW;YAChDF,UAAUlD,IAAI,CAACI;QACjB,OAAO,IAAIgD,WAAW,WAAW;YAC/BD,QAAQnD,IAAI,CAACI;QACf;IACF;IACA,IAAI8C,UAAUxM,MAAM,GAAG,GAAG2C,KAAI2D,KAAK,CAACgG,iBAAiBE,UAAUzD,IAAI,CAAC;IACpE,IAAI0D,QAAQzM,MAAM,GAAG,GAAG2C,KAAI2D,KAAK,CAACiG,eAAeE,QAAQ1D,IAAI,CAAC;AAChE","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/streaming-metadata.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export declare function shouldServeStreamingMetadata(userAgent: string, htmlLimitedBots: string | undefined): boolean;
|
e-commerce/node_modules/next/dist/server/lib/streaming-metadata.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
Object.defineProperty(exports, "shouldServeStreamingMetadata", {
|
| 6 |
+
enumerable: true,
|
| 7 |
+
get: function() {
|
| 8 |
+
return shouldServeStreamingMetadata;
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
const _isbot = require("../../shared/lib/router/utils/is-bot");
|
| 12 |
+
let cachedPattern;
|
| 13 |
+
let cachedRegex;
|
| 14 |
+
function shouldServeStreamingMetadata(userAgent, htmlLimitedBots) {
|
| 15 |
+
const pattern = htmlLimitedBots || _isbot.HTML_LIMITED_BOT_UA_RE_STRING;
|
| 16 |
+
if (cachedPattern !== pattern) {
|
| 17 |
+
cachedPattern = pattern;
|
| 18 |
+
cachedRegex = new RegExp(pattern, 'i');
|
| 19 |
+
}
|
| 20 |
+
// Only block metadata for HTML-limited bots
|
| 21 |
+
if (userAgent && cachedRegex.test(userAgent)) {
|
| 22 |
+
return false;
|
| 23 |
+
}
|
| 24 |
+
return true;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
//# sourceMappingURL=streaming-metadata.js.map
|
e-commerce/node_modules/next/dist/server/lib/streaming-metadata.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/server/lib/streaming-metadata.ts"],"sourcesContent":["import { HTML_LIMITED_BOT_UA_RE_STRING } from '../../shared/lib/router/utils/is-bot'\n\nlet cachedPattern: string | undefined\nlet cachedRegex: RegExp | undefined\n\nexport function shouldServeStreamingMetadata(\n userAgent: string,\n htmlLimitedBots: string | undefined\n): boolean {\n const pattern = htmlLimitedBots || HTML_LIMITED_BOT_UA_RE_STRING\n if (cachedPattern !== pattern) {\n cachedPattern = pattern\n cachedRegex = new RegExp(pattern, 'i')\n }\n // Only block metadata for HTML-limited bots\n if (userAgent && cachedRegex!.test(userAgent)) {\n return false\n }\n return true\n}\n"],"names":["shouldServeStreamingMetadata","cachedPattern","cachedRegex","userAgent","htmlLimitedBots","pattern","HTML_LIMITED_BOT_UA_RE_STRING","RegExp","test"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBAL8B;AAE9C,IAAIC;AACJ,IAAIC;AAEG,SAASF,6BACdG,SAAiB,EACjBC,eAAmC;IAEnC,MAAMC,UAAUD,mBAAmBE,oCAA6B;IAChE,IAAIL,kBAAkBI,SAAS;QAC7BJ,gBAAgBI;QAChBH,cAAc,IAAIK,OAAOF,SAAS;IACpC;IACA,4CAA4C;IAC5C,IAAIF,aAAaD,YAAaM,IAAI,CAACL,YAAY;QAC7C,OAAO;IACT;IACA,OAAO;AACT","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/to-route.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* This transforms a URL pathname into a route. It removes any trailing slashes
|
| 3 |
+
* and the `/index` suffix.
|
| 4 |
+
*
|
| 5 |
+
* @param pathname - The URL path that needs to be optimized.
|
| 6 |
+
* @returns - The route
|
| 7 |
+
*
|
| 8 |
+
* @example
|
| 9 |
+
* // returns '/example'
|
| 10 |
+
* toRoute('/example/index/');
|
| 11 |
+
*
|
| 12 |
+
* @example
|
| 13 |
+
* // returns '/example'
|
| 14 |
+
* toRoute('/example/');
|
| 15 |
+
*
|
| 16 |
+
* @example
|
| 17 |
+
* // returns '/'
|
| 18 |
+
* toRoute('/index/');
|
| 19 |
+
*
|
| 20 |
+
* @example
|
| 21 |
+
* // returns '/'
|
| 22 |
+
* toRoute('/');
|
| 23 |
+
*/
|
| 24 |
+
export declare function toRoute(pathname: string): string;
|
e-commerce/node_modules/next/dist/server/lib/to-route.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* This transforms a URL pathname into a route. It removes any trailing slashes
|
| 3 |
+
* and the `/index` suffix.
|
| 4 |
+
*
|
| 5 |
+
* @param pathname - The URL path that needs to be optimized.
|
| 6 |
+
* @returns - The route
|
| 7 |
+
*
|
| 8 |
+
* @example
|
| 9 |
+
* // returns '/example'
|
| 10 |
+
* toRoute('/example/index/');
|
| 11 |
+
*
|
| 12 |
+
* @example
|
| 13 |
+
* // returns '/example'
|
| 14 |
+
* toRoute('/example/');
|
| 15 |
+
*
|
| 16 |
+
* @example
|
| 17 |
+
* // returns '/'
|
| 18 |
+
* toRoute('/index/');
|
| 19 |
+
*
|
| 20 |
+
* @example
|
| 21 |
+
* // returns '/'
|
| 22 |
+
* toRoute('/');
|
| 23 |
+
*/ "use strict";
|
| 24 |
+
Object.defineProperty(exports, "__esModule", {
|
| 25 |
+
value: true
|
| 26 |
+
});
|
| 27 |
+
Object.defineProperty(exports, "toRoute", {
|
| 28 |
+
enumerable: true,
|
| 29 |
+
get: function() {
|
| 30 |
+
return toRoute;
|
| 31 |
+
}
|
| 32 |
+
});
|
| 33 |
+
function toRoute(pathname) {
|
| 34 |
+
return pathname.replace(/(?:\/index)?\/?$/, '') || '/';
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
//# sourceMappingURL=to-route.js.map
|
e-commerce/node_modules/next/dist/server/lib/to-route.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/server/lib/to-route.ts"],"sourcesContent":["/**\n * This transforms a URL pathname into a route. It removes any trailing slashes\n * and the `/index` suffix.\n *\n * @param pathname - The URL path that needs to be optimized.\n * @returns - The route\n *\n * @example\n * // returns '/example'\n * toRoute('/example/index/');\n *\n * @example\n * // returns '/example'\n * toRoute('/example/');\n *\n * @example\n * // returns '/'\n * toRoute('/index/');\n *\n * @example\n * // returns '/'\n * toRoute('/');\n */\nexport function toRoute(pathname: string): string {\n return pathname.replace(/(?:\\/index)?\\/?$/, '') || '/'\n}\n"],"names":["toRoute","pathname","replace"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;CAsBC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,QAAQC,QAAgB;IACtC,OAAOA,SAASC,OAAO,CAAC,oBAAoB,OAAO;AACrD","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/constants.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Contains predefined constants for the trace span name in next/server.
|
| 3 |
+
*
|
| 4 |
+
* Currently, next/server/tracer is internal implementation only for tracking
|
| 5 |
+
* next.js's implementation only with known span names defined here.
|
| 6 |
+
**/
|
| 7 |
+
declare enum BaseServerSpan {
|
| 8 |
+
handleRequest = "BaseServer.handleRequest",
|
| 9 |
+
run = "BaseServer.run",
|
| 10 |
+
pipe = "BaseServer.pipe",
|
| 11 |
+
getStaticHTML = "BaseServer.getStaticHTML",
|
| 12 |
+
render = "BaseServer.render",
|
| 13 |
+
renderToResponseWithComponents = "BaseServer.renderToResponseWithComponents",
|
| 14 |
+
renderToResponse = "BaseServer.renderToResponse",
|
| 15 |
+
renderToHTML = "BaseServer.renderToHTML",
|
| 16 |
+
renderError = "BaseServer.renderError",
|
| 17 |
+
renderErrorToResponse = "BaseServer.renderErrorToResponse",
|
| 18 |
+
renderErrorToHTML = "BaseServer.renderErrorToHTML",
|
| 19 |
+
render404 = "BaseServer.render404"
|
| 20 |
+
}
|
| 21 |
+
declare enum LoadComponentsSpan {
|
| 22 |
+
loadDefaultErrorComponents = "LoadComponents.loadDefaultErrorComponents",
|
| 23 |
+
loadComponents = "LoadComponents.loadComponents",
|
| 24 |
+
loadRouteModule = "LoadComponents.loadRouteModule"
|
| 25 |
+
}
|
| 26 |
+
declare enum InstrumentationSpan {
|
| 27 |
+
loadModule = "Instrumentation.loadModule",
|
| 28 |
+
register = "Instrumentation.register"
|
| 29 |
+
}
|
| 30 |
+
declare enum NextServerSpan {
|
| 31 |
+
getRequestHandler = "NextServer.getRequestHandler",
|
| 32 |
+
getRequestHandlerWithMetadata = "NextServer.getRequestHandlerWithMetadata",
|
| 33 |
+
getServer = "NextServer.getServer",
|
| 34 |
+
getServerRequestHandler = "NextServer.getServerRequestHandler",
|
| 35 |
+
createServer = "createServer.createServer"
|
| 36 |
+
}
|
| 37 |
+
declare enum NextNodeServerSpan {
|
| 38 |
+
compression = "NextNodeServer.compression",
|
| 39 |
+
getBuildId = "NextNodeServer.getBuildId",
|
| 40 |
+
createComponentTree = "NextNodeServer.createComponentTree",
|
| 41 |
+
clientComponentLoading = "NextNodeServer.clientComponentLoading",
|
| 42 |
+
getLayoutOrPageModule = "NextNodeServer.getLayoutOrPageModule",
|
| 43 |
+
generateStaticRoutes = "NextNodeServer.generateStaticRoutes",
|
| 44 |
+
generateFsStaticRoutes = "NextNodeServer.generateFsStaticRoutes",
|
| 45 |
+
generatePublicRoutes = "NextNodeServer.generatePublicRoutes",
|
| 46 |
+
generateImageRoutes = "NextNodeServer.generateImageRoutes.route",
|
| 47 |
+
sendRenderResult = "NextNodeServer.sendRenderResult",
|
| 48 |
+
proxyRequest = "NextNodeServer.proxyRequest",
|
| 49 |
+
runApi = "NextNodeServer.runApi",
|
| 50 |
+
render = "NextNodeServer.render",
|
| 51 |
+
renderHTML = "NextNodeServer.renderHTML",
|
| 52 |
+
imageOptimizer = "NextNodeServer.imageOptimizer",
|
| 53 |
+
getPagePath = "NextNodeServer.getPagePath",
|
| 54 |
+
getRoutesManifest = "NextNodeServer.getRoutesManifest",
|
| 55 |
+
findPageComponents = "NextNodeServer.findPageComponents",
|
| 56 |
+
getFontManifest = "NextNodeServer.getFontManifest",
|
| 57 |
+
getServerComponentManifest = "NextNodeServer.getServerComponentManifest",
|
| 58 |
+
getRequestHandler = "NextNodeServer.getRequestHandler",
|
| 59 |
+
renderToHTML = "NextNodeServer.renderToHTML",
|
| 60 |
+
renderError = "NextNodeServer.renderError",
|
| 61 |
+
renderErrorToHTML = "NextNodeServer.renderErrorToHTML",
|
| 62 |
+
render404 = "NextNodeServer.render404",
|
| 63 |
+
startResponse = "NextNodeServer.startResponse",
|
| 64 |
+
route = "route",
|
| 65 |
+
onProxyReq = "onProxyReq",
|
| 66 |
+
apiResolver = "apiResolver",
|
| 67 |
+
internalFetch = "internalFetch"
|
| 68 |
+
}
|
| 69 |
+
declare enum StartServerSpan {
|
| 70 |
+
startServer = "startServer.startServer"
|
| 71 |
+
}
|
| 72 |
+
declare enum RenderSpan {
|
| 73 |
+
getServerSideProps = "Render.getServerSideProps",
|
| 74 |
+
getStaticProps = "Render.getStaticProps",
|
| 75 |
+
renderToString = "Render.renderToString",
|
| 76 |
+
renderDocument = "Render.renderDocument",
|
| 77 |
+
createBodyResult = "Render.createBodyResult"
|
| 78 |
+
}
|
| 79 |
+
declare enum AppRenderSpan {
|
| 80 |
+
renderToString = "AppRender.renderToString",
|
| 81 |
+
renderToReadableStream = "AppRender.renderToReadableStream",
|
| 82 |
+
getBodyResult = "AppRender.getBodyResult",
|
| 83 |
+
fetch = "AppRender.fetch",
|
| 84 |
+
waitShellReady = "AppRender.waitShellReady",
|
| 85 |
+
renderToNodeFizzStream = "AppRender.renderToNodeFizzStream",
|
| 86 |
+
instantInsights = "AppRender.instantInsights",
|
| 87 |
+
instantInsightsPrepareValidation = "AppRender.instantInsights.prepareValidation",
|
| 88 |
+
instantInsightsRunValidation = "AppRender.instantInsights.runValidation"
|
| 89 |
+
}
|
| 90 |
+
declare enum DevBundlerServiceSpan {
|
| 91 |
+
ensurePage = "DevBundlerService.ensurePage"
|
| 92 |
+
}
|
| 93 |
+
declare enum RouterSpan {
|
| 94 |
+
executeRoute = "Router.executeRoute"
|
| 95 |
+
}
|
| 96 |
+
declare enum NodeSpan {
|
| 97 |
+
runHandler = "Node.runHandler"
|
| 98 |
+
}
|
| 99 |
+
declare enum AppRouteRouteHandlersSpan {
|
| 100 |
+
runHandler = "AppRouteRouteHandlers.runHandler"
|
| 101 |
+
}
|
| 102 |
+
declare enum AppRouteRouteModuleSpan {
|
| 103 |
+
loadUserland = "AppRouteRouteModule.loadUserland"
|
| 104 |
+
}
|
| 105 |
+
declare enum RouteModuleSpan {
|
| 106 |
+
prepare = "RouteModule.prepare",
|
| 107 |
+
loadManifests = "RouteModule.loadManifests"
|
| 108 |
+
}
|
| 109 |
+
declare enum ResolveMetadataSpan {
|
| 110 |
+
generateMetadata = "ResolveMetadata.generateMetadata",
|
| 111 |
+
generateViewport = "ResolveMetadata.generateViewport"
|
| 112 |
+
}
|
| 113 |
+
declare enum MiddlewareSpan {
|
| 114 |
+
execute = "Middleware.execute"
|
| 115 |
+
}
|
| 116 |
+
type SpanTypes = `${BaseServerSpan}` | `${LoadComponentsSpan}` | `${InstrumentationSpan}` | `${NextServerSpan}` | `${StartServerSpan}` | `${NextNodeServerSpan}` | `${RenderSpan}` | `${RouterSpan}` | `${AppRenderSpan}` | `${DevBundlerServiceSpan}` | `${NodeSpan}` | `${AppRouteRouteHandlersSpan}` | `${AppRouteRouteModuleSpan}` | `${RouteModuleSpan}` | `${ResolveMetadataSpan}` | `${MiddlewareSpan}`;
|
| 117 |
+
export declare const NextVanillaSpanAllowlist: Set<BaseServerSpan | LoadComponentsSpan | InstrumentationSpan | NextNodeServerSpan | RenderSpan | AppRenderSpan | NodeSpan | AppRouteRouteHandlersSpan | AppRouteRouteModuleSpan | RouteModuleSpan | ResolveMetadataSpan | MiddlewareSpan>;
|
| 118 |
+
export declare const LogSpanAllowList: Set<NextNodeServerSpan>;
|
| 119 |
+
export { BaseServerSpan, LoadComponentsSpan, InstrumentationSpan, NextServerSpan, NextNodeServerSpan, StartServerSpan, RenderSpan, RouterSpan, AppRenderSpan, DevBundlerServiceSpan, NodeSpan, AppRouteRouteHandlersSpan, AppRouteRouteModuleSpan, RouteModuleSpan, ResolveMetadataSpan, MiddlewareSpan, };
|
| 120 |
+
export type { SpanTypes };
|
e-commerce/node_modules/next/dist/server/lib/trace/constants.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Contains predefined constants for the trace span name in next/server.
|
| 3 |
+
*
|
| 4 |
+
* Currently, next/server/tracer is internal implementation only for tracking
|
| 5 |
+
* next.js's implementation only with known span names defined here.
|
| 6 |
+
**/ // eslint typescript has a bug with TS enums
|
| 7 |
+
"use strict";
|
| 8 |
+
Object.defineProperty(exports, "__esModule", {
|
| 9 |
+
value: true
|
| 10 |
+
});
|
| 11 |
+
0 && (module.exports = {
|
| 12 |
+
AppRenderSpan: null,
|
| 13 |
+
AppRouteRouteHandlersSpan: null,
|
| 14 |
+
AppRouteRouteModuleSpan: null,
|
| 15 |
+
BaseServerSpan: null,
|
| 16 |
+
DevBundlerServiceSpan: null,
|
| 17 |
+
InstrumentationSpan: null,
|
| 18 |
+
LoadComponentsSpan: null,
|
| 19 |
+
LogSpanAllowList: null,
|
| 20 |
+
MiddlewareSpan: null,
|
| 21 |
+
NextNodeServerSpan: null,
|
| 22 |
+
NextServerSpan: null,
|
| 23 |
+
NextVanillaSpanAllowlist: null,
|
| 24 |
+
NodeSpan: null,
|
| 25 |
+
RenderSpan: null,
|
| 26 |
+
ResolveMetadataSpan: null,
|
| 27 |
+
RouteModuleSpan: null,
|
| 28 |
+
RouterSpan: null,
|
| 29 |
+
StartServerSpan: null
|
| 30 |
+
});
|
| 31 |
+
function _export(target, all) {
|
| 32 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 33 |
+
enumerable: true,
|
| 34 |
+
get: all[name]
|
| 35 |
+
});
|
| 36 |
+
}
|
| 37 |
+
_export(exports, {
|
| 38 |
+
AppRenderSpan: function() {
|
| 39 |
+
return AppRenderSpan;
|
| 40 |
+
},
|
| 41 |
+
AppRouteRouteHandlersSpan: function() {
|
| 42 |
+
return AppRouteRouteHandlersSpan;
|
| 43 |
+
},
|
| 44 |
+
AppRouteRouteModuleSpan: function() {
|
| 45 |
+
return AppRouteRouteModuleSpan;
|
| 46 |
+
},
|
| 47 |
+
BaseServerSpan: function() {
|
| 48 |
+
return BaseServerSpan;
|
| 49 |
+
},
|
| 50 |
+
DevBundlerServiceSpan: function() {
|
| 51 |
+
return DevBundlerServiceSpan;
|
| 52 |
+
},
|
| 53 |
+
InstrumentationSpan: function() {
|
| 54 |
+
return InstrumentationSpan;
|
| 55 |
+
},
|
| 56 |
+
LoadComponentsSpan: function() {
|
| 57 |
+
return LoadComponentsSpan;
|
| 58 |
+
},
|
| 59 |
+
LogSpanAllowList: function() {
|
| 60 |
+
return LogSpanAllowList;
|
| 61 |
+
},
|
| 62 |
+
MiddlewareSpan: function() {
|
| 63 |
+
return MiddlewareSpan;
|
| 64 |
+
},
|
| 65 |
+
NextNodeServerSpan: function() {
|
| 66 |
+
return NextNodeServerSpan;
|
| 67 |
+
},
|
| 68 |
+
NextServerSpan: function() {
|
| 69 |
+
return NextServerSpan;
|
| 70 |
+
},
|
| 71 |
+
NextVanillaSpanAllowlist: function() {
|
| 72 |
+
return NextVanillaSpanAllowlist;
|
| 73 |
+
},
|
| 74 |
+
NodeSpan: function() {
|
| 75 |
+
return NodeSpan;
|
| 76 |
+
},
|
| 77 |
+
RenderSpan: function() {
|
| 78 |
+
return RenderSpan;
|
| 79 |
+
},
|
| 80 |
+
ResolveMetadataSpan: function() {
|
| 81 |
+
return ResolveMetadataSpan;
|
| 82 |
+
},
|
| 83 |
+
RouteModuleSpan: function() {
|
| 84 |
+
return RouteModuleSpan;
|
| 85 |
+
},
|
| 86 |
+
RouterSpan: function() {
|
| 87 |
+
return RouterSpan;
|
| 88 |
+
},
|
| 89 |
+
StartServerSpan: function() {
|
| 90 |
+
return StartServerSpan;
|
| 91 |
+
}
|
| 92 |
+
});
|
| 93 |
+
var BaseServerSpan = /*#__PURE__*/ function(BaseServerSpan) {
|
| 94 |
+
BaseServerSpan["handleRequest"] = "BaseServer.handleRequest";
|
| 95 |
+
BaseServerSpan["run"] = "BaseServer.run";
|
| 96 |
+
BaseServerSpan["pipe"] = "BaseServer.pipe";
|
| 97 |
+
BaseServerSpan["getStaticHTML"] = "BaseServer.getStaticHTML";
|
| 98 |
+
BaseServerSpan["render"] = "BaseServer.render";
|
| 99 |
+
BaseServerSpan["renderToResponseWithComponents"] = "BaseServer.renderToResponseWithComponents";
|
| 100 |
+
BaseServerSpan["renderToResponse"] = "BaseServer.renderToResponse";
|
| 101 |
+
BaseServerSpan["renderToHTML"] = "BaseServer.renderToHTML";
|
| 102 |
+
BaseServerSpan["renderError"] = "BaseServer.renderError";
|
| 103 |
+
BaseServerSpan["renderErrorToResponse"] = "BaseServer.renderErrorToResponse";
|
| 104 |
+
BaseServerSpan["renderErrorToHTML"] = "BaseServer.renderErrorToHTML";
|
| 105 |
+
BaseServerSpan["render404"] = "BaseServer.render404";
|
| 106 |
+
return BaseServerSpan;
|
| 107 |
+
}(BaseServerSpan || {});
|
| 108 |
+
var LoadComponentsSpan = /*#__PURE__*/ function(LoadComponentsSpan) {
|
| 109 |
+
LoadComponentsSpan["loadDefaultErrorComponents"] = "LoadComponents.loadDefaultErrorComponents";
|
| 110 |
+
LoadComponentsSpan["loadComponents"] = "LoadComponents.loadComponents";
|
| 111 |
+
LoadComponentsSpan["loadRouteModule"] = "LoadComponents.loadRouteModule";
|
| 112 |
+
return LoadComponentsSpan;
|
| 113 |
+
}(LoadComponentsSpan || {});
|
| 114 |
+
var InstrumentationSpan = /*#__PURE__*/ function(InstrumentationSpan) {
|
| 115 |
+
InstrumentationSpan["loadModule"] = "Instrumentation.loadModule";
|
| 116 |
+
InstrumentationSpan["register"] = "Instrumentation.register";
|
| 117 |
+
return InstrumentationSpan;
|
| 118 |
+
}(InstrumentationSpan || {});
|
| 119 |
+
var NextServerSpan = /*#__PURE__*/ function(NextServerSpan) {
|
| 120 |
+
NextServerSpan["getRequestHandler"] = "NextServer.getRequestHandler";
|
| 121 |
+
NextServerSpan["getRequestHandlerWithMetadata"] = "NextServer.getRequestHandlerWithMetadata";
|
| 122 |
+
NextServerSpan["getServer"] = "NextServer.getServer";
|
| 123 |
+
NextServerSpan["getServerRequestHandler"] = "NextServer.getServerRequestHandler";
|
| 124 |
+
NextServerSpan["createServer"] = "createServer.createServer";
|
| 125 |
+
return NextServerSpan;
|
| 126 |
+
}(NextServerSpan || {});
|
| 127 |
+
var NextNodeServerSpan = /*#__PURE__*/ function(NextNodeServerSpan) {
|
| 128 |
+
NextNodeServerSpan["compression"] = "NextNodeServer.compression";
|
| 129 |
+
NextNodeServerSpan["getBuildId"] = "NextNodeServer.getBuildId";
|
| 130 |
+
NextNodeServerSpan["createComponentTree"] = "NextNodeServer.createComponentTree";
|
| 131 |
+
NextNodeServerSpan["clientComponentLoading"] = "NextNodeServer.clientComponentLoading";
|
| 132 |
+
NextNodeServerSpan["getLayoutOrPageModule"] = "NextNodeServer.getLayoutOrPageModule";
|
| 133 |
+
NextNodeServerSpan["generateStaticRoutes"] = "NextNodeServer.generateStaticRoutes";
|
| 134 |
+
NextNodeServerSpan["generateFsStaticRoutes"] = "NextNodeServer.generateFsStaticRoutes";
|
| 135 |
+
NextNodeServerSpan["generatePublicRoutes"] = "NextNodeServer.generatePublicRoutes";
|
| 136 |
+
NextNodeServerSpan["generateImageRoutes"] = "NextNodeServer.generateImageRoutes.route";
|
| 137 |
+
NextNodeServerSpan["sendRenderResult"] = "NextNodeServer.sendRenderResult";
|
| 138 |
+
NextNodeServerSpan["proxyRequest"] = "NextNodeServer.proxyRequest";
|
| 139 |
+
NextNodeServerSpan["runApi"] = "NextNodeServer.runApi";
|
| 140 |
+
NextNodeServerSpan["render"] = "NextNodeServer.render";
|
| 141 |
+
NextNodeServerSpan["renderHTML"] = "NextNodeServer.renderHTML";
|
| 142 |
+
NextNodeServerSpan["imageOptimizer"] = "NextNodeServer.imageOptimizer";
|
| 143 |
+
NextNodeServerSpan["getPagePath"] = "NextNodeServer.getPagePath";
|
| 144 |
+
NextNodeServerSpan["getRoutesManifest"] = "NextNodeServer.getRoutesManifest";
|
| 145 |
+
NextNodeServerSpan["findPageComponents"] = "NextNodeServer.findPageComponents";
|
| 146 |
+
NextNodeServerSpan["getFontManifest"] = "NextNodeServer.getFontManifest";
|
| 147 |
+
NextNodeServerSpan["getServerComponentManifest"] = "NextNodeServer.getServerComponentManifest";
|
| 148 |
+
NextNodeServerSpan["getRequestHandler"] = "NextNodeServer.getRequestHandler";
|
| 149 |
+
NextNodeServerSpan["renderToHTML"] = "NextNodeServer.renderToHTML";
|
| 150 |
+
NextNodeServerSpan["renderError"] = "NextNodeServer.renderError";
|
| 151 |
+
NextNodeServerSpan["renderErrorToHTML"] = "NextNodeServer.renderErrorToHTML";
|
| 152 |
+
NextNodeServerSpan["render404"] = "NextNodeServer.render404";
|
| 153 |
+
NextNodeServerSpan["startResponse"] = "NextNodeServer.startResponse";
|
| 154 |
+
// nested inner span, does not require parent scope name
|
| 155 |
+
NextNodeServerSpan["route"] = "route";
|
| 156 |
+
NextNodeServerSpan["onProxyReq"] = "onProxyReq";
|
| 157 |
+
NextNodeServerSpan["apiResolver"] = "apiResolver";
|
| 158 |
+
NextNodeServerSpan["internalFetch"] = "internalFetch";
|
| 159 |
+
return NextNodeServerSpan;
|
| 160 |
+
}(NextNodeServerSpan || {});
|
| 161 |
+
var StartServerSpan = /*#__PURE__*/ function(StartServerSpan) {
|
| 162 |
+
StartServerSpan["startServer"] = "startServer.startServer";
|
| 163 |
+
return StartServerSpan;
|
| 164 |
+
}(StartServerSpan || {});
|
| 165 |
+
var RenderSpan = /*#__PURE__*/ function(RenderSpan) {
|
| 166 |
+
RenderSpan["getServerSideProps"] = "Render.getServerSideProps";
|
| 167 |
+
RenderSpan["getStaticProps"] = "Render.getStaticProps";
|
| 168 |
+
RenderSpan["renderToString"] = "Render.renderToString";
|
| 169 |
+
RenderSpan["renderDocument"] = "Render.renderDocument";
|
| 170 |
+
RenderSpan["createBodyResult"] = "Render.createBodyResult";
|
| 171 |
+
return RenderSpan;
|
| 172 |
+
}(RenderSpan || {});
|
| 173 |
+
var AppRenderSpan = /*#__PURE__*/ function(AppRenderSpan) {
|
| 174 |
+
AppRenderSpan["renderToString"] = "AppRender.renderToString";
|
| 175 |
+
AppRenderSpan["renderToReadableStream"] = "AppRender.renderToReadableStream";
|
| 176 |
+
AppRenderSpan["getBodyResult"] = "AppRender.getBodyResult";
|
| 177 |
+
AppRenderSpan["fetch"] = "AppRender.fetch";
|
| 178 |
+
AppRenderSpan["waitShellReady"] = "AppRender.waitShellReady";
|
| 179 |
+
AppRenderSpan["renderToNodeFizzStream"] = "AppRender.renderToNodeFizzStream";
|
| 180 |
+
AppRenderSpan["instantInsights"] = "AppRender.instantInsights";
|
| 181 |
+
AppRenderSpan["instantInsightsPrepareValidation"] = "AppRender.instantInsights.prepareValidation";
|
| 182 |
+
AppRenderSpan["instantInsightsRunValidation"] = "AppRender.instantInsights.runValidation";
|
| 183 |
+
return AppRenderSpan;
|
| 184 |
+
}(AppRenderSpan || {});
|
| 185 |
+
var DevBundlerServiceSpan = /*#__PURE__*/ function(DevBundlerServiceSpan) {
|
| 186 |
+
DevBundlerServiceSpan["ensurePage"] = "DevBundlerService.ensurePage";
|
| 187 |
+
return DevBundlerServiceSpan;
|
| 188 |
+
}(DevBundlerServiceSpan || {});
|
| 189 |
+
var RouterSpan = /*#__PURE__*/ function(RouterSpan) {
|
| 190 |
+
RouterSpan["executeRoute"] = "Router.executeRoute";
|
| 191 |
+
return RouterSpan;
|
| 192 |
+
}(RouterSpan || {});
|
| 193 |
+
var NodeSpan = /*#__PURE__*/ function(NodeSpan) {
|
| 194 |
+
NodeSpan["runHandler"] = "Node.runHandler";
|
| 195 |
+
return NodeSpan;
|
| 196 |
+
}(NodeSpan || {});
|
| 197 |
+
var AppRouteRouteHandlersSpan = /*#__PURE__*/ function(AppRouteRouteHandlersSpan) {
|
| 198 |
+
AppRouteRouteHandlersSpan["runHandler"] = "AppRouteRouteHandlers.runHandler";
|
| 199 |
+
return AppRouteRouteHandlersSpan;
|
| 200 |
+
}(AppRouteRouteHandlersSpan || {});
|
| 201 |
+
var AppRouteRouteModuleSpan = /*#__PURE__*/ function(AppRouteRouteModuleSpan) {
|
| 202 |
+
AppRouteRouteModuleSpan["loadUserland"] = "AppRouteRouteModule.loadUserland";
|
| 203 |
+
return AppRouteRouteModuleSpan;
|
| 204 |
+
}(AppRouteRouteModuleSpan || {});
|
| 205 |
+
var RouteModuleSpan = /*#__PURE__*/ function(RouteModuleSpan) {
|
| 206 |
+
RouteModuleSpan["prepare"] = "RouteModule.prepare";
|
| 207 |
+
RouteModuleSpan["loadManifests"] = "RouteModule.loadManifests";
|
| 208 |
+
return RouteModuleSpan;
|
| 209 |
+
}(RouteModuleSpan || {});
|
| 210 |
+
var ResolveMetadataSpan = /*#__PURE__*/ function(ResolveMetadataSpan) {
|
| 211 |
+
ResolveMetadataSpan["generateMetadata"] = "ResolveMetadata.generateMetadata";
|
| 212 |
+
ResolveMetadataSpan["generateViewport"] = "ResolveMetadata.generateViewport";
|
| 213 |
+
return ResolveMetadataSpan;
|
| 214 |
+
}(ResolveMetadataSpan || {});
|
| 215 |
+
var MiddlewareSpan = /*#__PURE__*/ function(MiddlewareSpan) {
|
| 216 |
+
MiddlewareSpan["execute"] = "Middleware.execute";
|
| 217 |
+
return MiddlewareSpan;
|
| 218 |
+
}(MiddlewareSpan || {});
|
| 219 |
+
const NextVanillaSpanAllowlist = new Set([
|
| 220 |
+
"Middleware.execute",
|
| 221 |
+
"BaseServer.handleRequest",
|
| 222 |
+
"Render.getServerSideProps",
|
| 223 |
+
"Render.getStaticProps",
|
| 224 |
+
"AppRender.fetch",
|
| 225 |
+
"AppRender.getBodyResult",
|
| 226 |
+
"LoadComponents.loadRouteModule",
|
| 227 |
+
"Render.renderDocument",
|
| 228 |
+
"Node.runHandler",
|
| 229 |
+
"AppRouteRouteHandlers.runHandler",
|
| 230 |
+
"AppRouteRouteModule.loadUserland",
|
| 231 |
+
"RouteModule.prepare",
|
| 232 |
+
"Instrumentation.loadModule",
|
| 233 |
+
"Instrumentation.register",
|
| 234 |
+
"ResolveMetadata.generateMetadata",
|
| 235 |
+
"ResolveMetadata.generateViewport",
|
| 236 |
+
"NextNodeServer.createComponentTree",
|
| 237 |
+
"NextNodeServer.findPageComponents",
|
| 238 |
+
"NextNodeServer.getLayoutOrPageModule",
|
| 239 |
+
"NextNodeServer.startResponse",
|
| 240 |
+
"NextNodeServer.clientComponentLoading"
|
| 241 |
+
]);
|
| 242 |
+
const LogSpanAllowList = new Set([
|
| 243 |
+
"NextNodeServer.findPageComponents",
|
| 244 |
+
"NextNodeServer.createComponentTree",
|
| 245 |
+
"NextNodeServer.clientComponentLoading"
|
| 246 |
+
]);
|
| 247 |
+
|
| 248 |
+
//# sourceMappingURL=constants.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/constants.ts"],"sourcesContent":["/**\n * Contains predefined constants for the trace span name in next/server.\n *\n * Currently, next/server/tracer is internal implementation only for tracking\n * next.js's implementation only with known span names defined here.\n **/\n\n// eslint typescript has a bug with TS enums\n\nenum BaseServerSpan {\n handleRequest = 'BaseServer.handleRequest',\n run = 'BaseServer.run',\n pipe = 'BaseServer.pipe',\n getStaticHTML = 'BaseServer.getStaticHTML',\n render = 'BaseServer.render',\n renderToResponseWithComponents = 'BaseServer.renderToResponseWithComponents',\n renderToResponse = 'BaseServer.renderToResponse',\n renderToHTML = 'BaseServer.renderToHTML',\n renderError = 'BaseServer.renderError',\n renderErrorToResponse = 'BaseServer.renderErrorToResponse',\n renderErrorToHTML = 'BaseServer.renderErrorToHTML',\n render404 = 'BaseServer.render404',\n}\n\nenum LoadComponentsSpan {\n loadDefaultErrorComponents = 'LoadComponents.loadDefaultErrorComponents',\n loadComponents = 'LoadComponents.loadComponents',\n loadRouteModule = 'LoadComponents.loadRouteModule',\n}\n\nenum InstrumentationSpan {\n loadModule = 'Instrumentation.loadModule',\n register = 'Instrumentation.register',\n}\n\nenum NextServerSpan {\n getRequestHandler = 'NextServer.getRequestHandler',\n getRequestHandlerWithMetadata = 'NextServer.getRequestHandlerWithMetadata',\n getServer = 'NextServer.getServer',\n getServerRequestHandler = 'NextServer.getServerRequestHandler',\n createServer = 'createServer.createServer',\n}\n\nenum NextNodeServerSpan {\n compression = 'NextNodeServer.compression',\n getBuildId = 'NextNodeServer.getBuildId',\n createComponentTree = 'NextNodeServer.createComponentTree',\n clientComponentLoading = 'NextNodeServer.clientComponentLoading',\n getLayoutOrPageModule = 'NextNodeServer.getLayoutOrPageModule',\n generateStaticRoutes = 'NextNodeServer.generateStaticRoutes',\n generateFsStaticRoutes = 'NextNodeServer.generateFsStaticRoutes',\n generatePublicRoutes = 'NextNodeServer.generatePublicRoutes',\n generateImageRoutes = 'NextNodeServer.generateImageRoutes.route',\n sendRenderResult = 'NextNodeServer.sendRenderResult',\n proxyRequest = 'NextNodeServer.proxyRequest',\n runApi = 'NextNodeServer.runApi',\n render = 'NextNodeServer.render',\n renderHTML = 'NextNodeServer.renderHTML',\n imageOptimizer = 'NextNodeServer.imageOptimizer',\n getPagePath = 'NextNodeServer.getPagePath',\n getRoutesManifest = 'NextNodeServer.getRoutesManifest',\n findPageComponents = 'NextNodeServer.findPageComponents',\n getFontManifest = 'NextNodeServer.getFontManifest',\n getServerComponentManifest = 'NextNodeServer.getServerComponentManifest',\n getRequestHandler = 'NextNodeServer.getRequestHandler',\n renderToHTML = 'NextNodeServer.renderToHTML',\n renderError = 'NextNodeServer.renderError',\n renderErrorToHTML = 'NextNodeServer.renderErrorToHTML',\n render404 = 'NextNodeServer.render404',\n startResponse = 'NextNodeServer.startResponse',\n\n // nested inner span, does not require parent scope name\n route = 'route',\n onProxyReq = 'onProxyReq',\n apiResolver = 'apiResolver',\n internalFetch = 'internalFetch',\n}\n\nenum StartServerSpan {\n startServer = 'startServer.startServer',\n}\n\nenum RenderSpan {\n getServerSideProps = 'Render.getServerSideProps',\n getStaticProps = 'Render.getStaticProps',\n renderToString = 'Render.renderToString',\n renderDocument = 'Render.renderDocument',\n createBodyResult = 'Render.createBodyResult',\n}\n\nenum AppRenderSpan {\n renderToString = 'AppRender.renderToString',\n renderToReadableStream = 'AppRender.renderToReadableStream',\n getBodyResult = 'AppRender.getBodyResult',\n fetch = 'AppRender.fetch',\n waitShellReady = 'AppRender.waitShellReady',\n renderToNodeFizzStream = 'AppRender.renderToNodeFizzStream',\n instantInsights = 'AppRender.instantInsights',\n instantInsightsPrepareValidation = 'AppRender.instantInsights.prepareValidation',\n instantInsightsRunValidation = 'AppRender.instantInsights.runValidation',\n}\n\nenum DevBundlerServiceSpan {\n ensurePage = 'DevBundlerService.ensurePage',\n}\n\nenum RouterSpan {\n executeRoute = 'Router.executeRoute',\n}\n\nenum NodeSpan {\n runHandler = 'Node.runHandler',\n}\n\nenum AppRouteRouteHandlersSpan {\n runHandler = 'AppRouteRouteHandlers.runHandler',\n}\n\nenum AppRouteRouteModuleSpan {\n loadUserland = 'AppRouteRouteModule.loadUserland',\n}\n\nenum RouteModuleSpan {\n prepare = 'RouteModule.prepare',\n loadManifests = 'RouteModule.loadManifests',\n}\nenum ResolveMetadataSpan {\n generateMetadata = 'ResolveMetadata.generateMetadata',\n generateViewport = 'ResolveMetadata.generateViewport',\n}\n\nenum MiddlewareSpan {\n execute = 'Middleware.execute',\n}\n\ntype SpanTypes =\n | `${BaseServerSpan}`\n | `${LoadComponentsSpan}`\n | `${InstrumentationSpan}`\n | `${NextServerSpan}`\n | `${StartServerSpan}`\n | `${NextNodeServerSpan}`\n | `${RenderSpan}`\n | `${RouterSpan}`\n | `${AppRenderSpan}`\n | `${DevBundlerServiceSpan}`\n | `${NodeSpan}`\n | `${AppRouteRouteHandlersSpan}`\n | `${AppRouteRouteModuleSpan}`\n | `${RouteModuleSpan}`\n | `${ResolveMetadataSpan}`\n | `${MiddlewareSpan}`\n\n// This list is used to filter out spans that are not relevant to the user\nexport const NextVanillaSpanAllowlist = new Set([\n MiddlewareSpan.execute,\n BaseServerSpan.handleRequest,\n RenderSpan.getServerSideProps,\n RenderSpan.getStaticProps,\n AppRenderSpan.fetch,\n AppRenderSpan.getBodyResult,\n LoadComponentsSpan.loadRouteModule,\n RenderSpan.renderDocument,\n NodeSpan.runHandler,\n AppRouteRouteHandlersSpan.runHandler,\n AppRouteRouteModuleSpan.loadUserland,\n RouteModuleSpan.prepare,\n InstrumentationSpan.loadModule,\n InstrumentationSpan.register,\n ResolveMetadataSpan.generateMetadata,\n ResolveMetadataSpan.generateViewport,\n NextNodeServerSpan.createComponentTree,\n NextNodeServerSpan.findPageComponents,\n NextNodeServerSpan.getLayoutOrPageModule,\n NextNodeServerSpan.startResponse,\n NextNodeServerSpan.clientComponentLoading,\n])\n\n// These Spans are allowed to be always logged\n// when the otel log prefix env is set\nexport const LogSpanAllowList = new Set([\n NextNodeServerSpan.findPageComponents,\n NextNodeServerSpan.createComponentTree,\n NextNodeServerSpan.clientComponentLoading,\n])\n\nexport {\n BaseServerSpan,\n LoadComponentsSpan,\n InstrumentationSpan,\n NextServerSpan,\n NextNodeServerSpan,\n StartServerSpan,\n RenderSpan,\n RouterSpan,\n AppRenderSpan,\n DevBundlerServiceSpan,\n NodeSpan,\n AppRouteRouteHandlersSpan,\n AppRouteRouteModuleSpan,\n RouteModuleSpan,\n ResolveMetadataSpan,\n MiddlewareSpan,\n}\n\nexport type { SpanTypes }\n"],"names":["AppRenderSpan","AppRouteRouteHandlersSpan","AppRouteRouteModuleSpan","BaseServerSpan","DevBundlerServiceSpan","InstrumentationSpan","LoadComponentsSpan","LogSpanAllowList","MiddlewareSpan","NextNodeServerSpan","NextServerSpan","NextVanillaSpanAllowlist","NodeSpan","RenderSpan","ResolveMetadataSpan","RouteModuleSpan","RouterSpan","StartServerSpan","Set"],"mappings":"AAAA;;;;;EAKE,GAEF,4CAA4C;;;;;;;;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AAA;AAuBE,MAAMG,2BAA2B,IAAIO,IAAI;;;;;;;;;;;;;;;;;;;;;;CAsB/C;AAIM,MAAMX,mBAAmB,IAAIW,IAAI;;;;CAIvC","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/local-span-recorder.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { AttributeValue, Span, SpanOptions } from 'next/dist/compiled/@opentelemetry/api';
|
| 2 |
+
import { isLocalSpanRecordingEnabled, isRequestInsightsEnabled } from './span-store';
|
| 3 |
+
export { isLocalSpanRecordingEnabled } from './span-store';
|
| 4 |
+
type LocalSpanAttributes = Partial<Record<string, AttributeValue | undefined>>;
|
| 5 |
+
type LocalSpanOptions = {
|
| 6 |
+
name: string;
|
| 7 |
+
attributes?: LocalSpanAttributes;
|
| 8 |
+
links?: SpanOptions['links'];
|
| 9 |
+
startTime?: SpanOptions['startTime'];
|
| 10 |
+
traceId?: string;
|
| 11 |
+
spanId?: string;
|
| 12 |
+
parentSpanId?: string;
|
| 13 |
+
delegateSpan?: Span;
|
| 14 |
+
isolateOpenTelemetry?: boolean;
|
| 15 |
+
};
|
| 16 |
+
type TraceLocalSpanOptions = Omit<LocalSpanOptions, 'traceId' | 'spanId' | 'parentSpanId' | 'delegateSpan' | 'isolateOpenTelemetry'> & {
|
| 17 |
+
parentSpan?: Span | null;
|
| 18 |
+
};
|
| 19 |
+
export declare function createLocalSpan({ name, attributes, links, startTime, traceId, spanId, parentSpanId, delegateSpan, isolateOpenTelemetry, }: LocalSpanOptions): Span;
|
| 20 |
+
export declare function getActiveLocalSpan(): Span | undefined;
|
| 21 |
+
export declare function isLocalRecordingSpan(span: Span): boolean;
|
| 22 |
+
export declare function isOpenTelemetryIsolatedSpan(span: Span): boolean;
|
| 23 |
+
export declare function withLocalSpan<T>(span: Span, fn: () => T): T;
|
| 24 |
+
/**
|
| 25 |
+
* Records an async operation without replacing or exporting through the active
|
| 26 |
+
* OpenTelemetry context. Nested Next.js spans remain in the local trace.
|
| 27 |
+
*/
|
| 28 |
+
export declare function traceLocalSpan<T>({ parentSpan, ...options }: TraceLocalSpanOptions, fn: () => Promise<T>): Promise<T>;
|
| 29 |
+
export type LocalSpanRecorder = {
|
| 30 |
+
createLocalSpan: typeof createLocalSpan;
|
| 31 |
+
getActiveLocalSpan: typeof getActiveLocalSpan;
|
| 32 |
+
isLocalRecordingSpan: typeof isLocalRecordingSpan;
|
| 33 |
+
isOpenTelemetryIsolatedSpan: typeof isOpenTelemetryIsolatedSpan;
|
| 34 |
+
isLocalSpanRecordingEnabled: typeof isLocalSpanRecordingEnabled;
|
| 35 |
+
isRequestInsightsEnabled: typeof isRequestInsightsEnabled;
|
| 36 |
+
traceLocalSpan: typeof traceLocalSpan;
|
| 37 |
+
withLocalSpan: typeof withLocalSpan;
|
| 38 |
+
};
|
| 39 |
+
export declare function registerLocalSpanRecorder(): void;
|
e-commerce/node_modules/next/dist/server/lib/trace/local-span-recorder.js
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
0 && (module.exports = {
|
| 6 |
+
createLocalSpan: null,
|
| 7 |
+
getActiveLocalSpan: null,
|
| 8 |
+
isLocalRecordingSpan: null,
|
| 9 |
+
isLocalSpanRecordingEnabled: null,
|
| 10 |
+
isOpenTelemetryIsolatedSpan: null,
|
| 11 |
+
registerLocalSpanRecorder: null,
|
| 12 |
+
traceLocalSpan: null,
|
| 13 |
+
withLocalSpan: null
|
| 14 |
+
});
|
| 15 |
+
function _export(target, all) {
|
| 16 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 17 |
+
enumerable: true,
|
| 18 |
+
get: all[name]
|
| 19 |
+
});
|
| 20 |
+
}
|
| 21 |
+
_export(exports, {
|
| 22 |
+
createLocalSpan: function() {
|
| 23 |
+
return createLocalSpan;
|
| 24 |
+
},
|
| 25 |
+
getActiveLocalSpan: function() {
|
| 26 |
+
return getActiveLocalSpan;
|
| 27 |
+
},
|
| 28 |
+
isLocalRecordingSpan: function() {
|
| 29 |
+
return isLocalRecordingSpan;
|
| 30 |
+
},
|
| 31 |
+
isLocalSpanRecordingEnabled: function() {
|
| 32 |
+
return _spanstore.isLocalSpanRecordingEnabled;
|
| 33 |
+
},
|
| 34 |
+
isOpenTelemetryIsolatedSpan: function() {
|
| 35 |
+
return isOpenTelemetryIsolatedSpan;
|
| 36 |
+
},
|
| 37 |
+
registerLocalSpanRecorder: function() {
|
| 38 |
+
return registerLocalSpanRecorder;
|
| 39 |
+
},
|
| 40 |
+
traceLocalSpan: function() {
|
| 41 |
+
return traceLocalSpan;
|
| 42 |
+
},
|
| 43 |
+
withLocalSpan: function() {
|
| 44 |
+
return withLocalSpan;
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
const _api = require("next/dist/compiled/@opentelemetry/api");
|
| 48 |
+
const _spanstore = require("./span-store");
|
| 49 |
+
const TRACE_ID_HEX_LENGTH = 32;
|
| 50 |
+
const SPAN_ID_HEX_LENGTH = 16;
|
| 51 |
+
let lastLocalTraceId = 0;
|
| 52 |
+
let lastLocalSpanId = 0;
|
| 53 |
+
let localSpanAsyncStorage;
|
| 54 |
+
const getLocalTraceId = ()=>(++lastLocalTraceId).toString(16).padStart(TRACE_ID_HEX_LENGTH, '0');
|
| 55 |
+
const getLocalSpanId = ()=>(++lastLocalSpanId).toString(16).padStart(SPAN_ID_HEX_LENGTH, '0');
|
| 56 |
+
function createLocalSpan({ name, attributes, links, startTime, traceId, spanId, parentSpanId, delegateSpan, isolateOpenTelemetry }) {
|
| 57 |
+
return new LocalRecordingSpan({
|
| 58 |
+
name,
|
| 59 |
+
attributes,
|
| 60 |
+
links,
|
| 61 |
+
startTime,
|
| 62 |
+
delegateSpan,
|
| 63 |
+
traceId: traceId ?? getLocalTraceId(),
|
| 64 |
+
spanId: spanId ?? getLocalSpanId(),
|
| 65 |
+
parentSpanId,
|
| 66 |
+
requestIdentity: getCurrentRequestIdentity(),
|
| 67 |
+
isolateOpenTelemetry: isolateOpenTelemetry ?? false
|
| 68 |
+
});
|
| 69 |
+
}
|
| 70 |
+
function getActiveLocalSpan() {
|
| 71 |
+
return localSpanAsyncStorage == null ? void 0 : localSpanAsyncStorage.getStore();
|
| 72 |
+
}
|
| 73 |
+
function isLocalRecordingSpan(span) {
|
| 74 |
+
return span instanceof LocalRecordingSpan;
|
| 75 |
+
}
|
| 76 |
+
function isOpenTelemetryIsolatedSpan(span) {
|
| 77 |
+
return span instanceof LocalRecordingSpan && span.isOpenTelemetryIsolated();
|
| 78 |
+
}
|
| 79 |
+
function withLocalSpan(span, fn) {
|
| 80 |
+
return getLocalSpanAsyncStorage().run(span, fn);
|
| 81 |
+
}
|
| 82 |
+
async function traceLocalSpan({ parentSpan, ...options }, fn) {
|
| 83 |
+
const resolvedParentSpan = parentSpan === undefined ? getActiveLocalSpan() : parentSpan;
|
| 84 |
+
const parentSpanContext = resolvedParentSpan == null ? void 0 : resolvedParentSpan.spanContext();
|
| 85 |
+
const span = createLocalSpan({
|
| 86 |
+
...options,
|
| 87 |
+
traceId: parentSpanContext == null ? void 0 : parentSpanContext.traceId,
|
| 88 |
+
parentSpanId: parentSpanContext == null ? void 0 : parentSpanContext.spanId,
|
| 89 |
+
isolateOpenTelemetry: true
|
| 90 |
+
});
|
| 91 |
+
return withLocalSpan(span, async ()=>{
|
| 92 |
+
try {
|
| 93 |
+
return await fn();
|
| 94 |
+
} catch (err) {
|
| 95 |
+
span.recordException(err);
|
| 96 |
+
span.setStatus({
|
| 97 |
+
code: _api.SpanStatusCode.ERROR
|
| 98 |
+
});
|
| 99 |
+
throw err;
|
| 100 |
+
} finally{
|
| 101 |
+
span.end();
|
| 102 |
+
}
|
| 103 |
+
});
|
| 104 |
+
}
|
| 105 |
+
function registerLocalSpanRecorder() {
|
| 106 |
+
const key = Symbol.for('@next/local-span-recorder');
|
| 107 |
+
globalThis[key] = {
|
| 108 |
+
createLocalSpan,
|
| 109 |
+
getActiveLocalSpan,
|
| 110 |
+
isLocalRecordingSpan,
|
| 111 |
+
isOpenTelemetryIsolatedSpan,
|
| 112 |
+
isLocalSpanRecordingEnabled: _spanstore.isLocalSpanRecordingEnabled,
|
| 113 |
+
isRequestInsightsEnabled: _spanstore.isRequestInsightsEnabled,
|
| 114 |
+
traceLocalSpan,
|
| 115 |
+
withLocalSpan
|
| 116 |
+
};
|
| 117 |
+
}
|
| 118 |
+
function getLocalSpanAsyncStorage() {
|
| 119 |
+
if (!localSpanAsyncStorage) {
|
| 120 |
+
const { createAsyncLocalStorage } = require('../../app-render/async-local-storage');
|
| 121 |
+
localSpanAsyncStorage = createAsyncLocalStorage();
|
| 122 |
+
}
|
| 123 |
+
return localSpanAsyncStorage;
|
| 124 |
+
}
|
| 125 |
+
class LocalRecordingSpan {
|
| 126 |
+
constructor({ name, attributes, links, startTime, delegateSpan, traceId, spanId, parentSpanId, requestIdentity, isolateOpenTelemetry }){
|
| 127 |
+
this.name = name;
|
| 128 |
+
this.attributes = cleanSpanStoreAttributes(attributes);
|
| 129 |
+
this.events = [];
|
| 130 |
+
this.delegateSpan = delegateSpan;
|
| 131 |
+
this.openTelemetryIsolated = isolateOpenTelemetry;
|
| 132 |
+
this.spanContextValue = (delegateSpan == null ? void 0 : delegateSpan.spanContext()) ?? {
|
| 133 |
+
traceId,
|
| 134 |
+
spanId,
|
| 135 |
+
traceFlags: 0
|
| 136 |
+
};
|
| 137 |
+
this.links = getSpanStoreLinks(links);
|
| 138 |
+
this.parentSpanId = parentSpanId;
|
| 139 |
+
this.requestIdentity = requestIdentity;
|
| 140 |
+
this.startTime = getTimestamp(startTime);
|
| 141 |
+
this.statusCode = undefined;
|
| 142 |
+
this.statusMessage = undefined;
|
| 143 |
+
this.exception = undefined;
|
| 144 |
+
this.ended = false;
|
| 145 |
+
}
|
| 146 |
+
spanContext() {
|
| 147 |
+
return this.spanContextValue;
|
| 148 |
+
}
|
| 149 |
+
isOpenTelemetryIsolated() {
|
| 150 |
+
return this.openTelemetryIsolated;
|
| 151 |
+
}
|
| 152 |
+
setAttribute(key, value) {
|
| 153 |
+
var _this_delegateSpan;
|
| 154 |
+
if (this.ended) {
|
| 155 |
+
return this;
|
| 156 |
+
}
|
| 157 |
+
this.attributes[key] = value;
|
| 158 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.setAttribute(key, value);
|
| 159 |
+
return this;
|
| 160 |
+
}
|
| 161 |
+
setAttributes(attributes) {
|
| 162 |
+
var _this_delegateSpan;
|
| 163 |
+
if (this.ended) {
|
| 164 |
+
return this;
|
| 165 |
+
}
|
| 166 |
+
// OpenTelemetry attributes may be undefined. Ignore them instead of
|
| 167 |
+
// overwriting an existing value as Object.assign would.
|
| 168 |
+
for (const key of Object.keys(attributes)){
|
| 169 |
+
const value = attributes[key];
|
| 170 |
+
if (value !== undefined) {
|
| 171 |
+
this.attributes[key] = value;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.setAttributes(attributes);
|
| 175 |
+
return this;
|
| 176 |
+
}
|
| 177 |
+
addEvent(name, attributesOrStartTime, startTime) {
|
| 178 |
+
var _this_delegateSpan;
|
| 179 |
+
if (this.ended) {
|
| 180 |
+
return this;
|
| 181 |
+
}
|
| 182 |
+
const eventTime = startTime === undefined && isTimestampInput(attributesOrStartTime) ? attributesOrStartTime : startTime;
|
| 183 |
+
this.events.push({
|
| 184 |
+
name,
|
| 185 |
+
timestamp: getTimestamp(eventTime),
|
| 186 |
+
attributes: isSpanStoreAttributes(attributesOrStartTime) ? cleanSpanStoreAttributes(attributesOrStartTime) : undefined
|
| 187 |
+
});
|
| 188 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.addEvent(name, attributesOrStartTime, startTime);
|
| 189 |
+
return this;
|
| 190 |
+
}
|
| 191 |
+
setStatus(status) {
|
| 192 |
+
var _this_delegateSpan;
|
| 193 |
+
if (this.ended) {
|
| 194 |
+
return this;
|
| 195 |
+
}
|
| 196 |
+
this.statusCode = status.code;
|
| 197 |
+
this.statusMessage = status.message;
|
| 198 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.setStatus(status);
|
| 199 |
+
return this;
|
| 200 |
+
}
|
| 201 |
+
updateName(name) {
|
| 202 |
+
var _this_delegateSpan;
|
| 203 |
+
if (this.ended) {
|
| 204 |
+
return this;
|
| 205 |
+
}
|
| 206 |
+
this.name = name;
|
| 207 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.updateName(name);
|
| 208 |
+
return this;
|
| 209 |
+
}
|
| 210 |
+
end(endTime) {
|
| 211 |
+
if (this.ended) {
|
| 212 |
+
return;
|
| 213 |
+
}
|
| 214 |
+
this.ended = true;
|
| 215 |
+
try {
|
| 216 |
+
var _this_delegateSpan;
|
| 217 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.end(endTime);
|
| 218 |
+
} finally{
|
| 219 |
+
try {
|
| 220 |
+
this.record(endTime);
|
| 221 |
+
} finally{
|
| 222 |
+
this.releaseReferences();
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
isRecording() {
|
| 227 |
+
return !this.ended;
|
| 228 |
+
}
|
| 229 |
+
recordException(exception, time) {
|
| 230 |
+
var _this_delegateSpan;
|
| 231 |
+
if (this.ended) {
|
| 232 |
+
return;
|
| 233 |
+
}
|
| 234 |
+
this.exception = getSpanStoreException(exception);
|
| 235 |
+
this.events.push({
|
| 236 |
+
name: 'exception',
|
| 237 |
+
timestamp: getTimestamp(time),
|
| 238 |
+
attributes: getSpanStoreExceptionAttributes(this.exception)
|
| 239 |
+
});
|
| 240 |
+
(_this_delegateSpan = this.delegateSpan) == null ? void 0 : _this_delegateSpan.recordException(exception, time);
|
| 241 |
+
}
|
| 242 |
+
record(endTime) {
|
| 243 |
+
const recordAttributes = Object.keys(this.attributes).length > 0 ? this.attributes : undefined;
|
| 244 |
+
(0, _spanstore.recordSpan)({
|
| 245 |
+
name: this.name,
|
| 246 |
+
startTime: this.startTime,
|
| 247 |
+
durationMs: Math.max(0, getTimestamp(endTime) - this.startTime),
|
| 248 |
+
status: this.statusCode === _api.SpanStatusCode.ERROR ? 'error' : 'ok',
|
| 249 |
+
traceId: this.spanContextValue.traceId,
|
| 250 |
+
spanId: this.spanContextValue.spanId,
|
| 251 |
+
parentSpanId: this.parentSpanId,
|
| 252 |
+
requestId: this.requestIdentity.requestId,
|
| 253 |
+
requestInsightKind: this.requestIdentity.requestInsightKind,
|
| 254 |
+
htmlRequestId: this.requestIdentity.htmlRequestId,
|
| 255 |
+
route: getStringAttribute(recordAttributes, 'next.route') ?? getStringAttribute(recordAttributes, 'http.route') ?? this.requestIdentity.route,
|
| 256 |
+
url: getStringAttribute(recordAttributes, 'http.url') ?? this.requestIdentity.url,
|
| 257 |
+
attributes: recordAttributes,
|
| 258 |
+
links: this.links,
|
| 259 |
+
events: this.events.length > 0 ? this.events : undefined,
|
| 260 |
+
error: this.getRecordError()
|
| 261 |
+
});
|
| 262 |
+
}
|
| 263 |
+
releaseReferences() {
|
| 264 |
+
// AsyncLocalStorage can keep an ended span reachable when work spawned
|
| 265 |
+
// inside the span outlives it. Keep only the immutable span context and
|
| 266 |
+
// primitive timing/identity fields needed by the Span API after end.
|
| 267 |
+
this.name = '';
|
| 268 |
+
this.attributes = {};
|
| 269 |
+
this.events = [];
|
| 270 |
+
this.delegateSpan = undefined;
|
| 271 |
+
this.links = undefined;
|
| 272 |
+
this.requestIdentity = {};
|
| 273 |
+
this.statusMessage = undefined;
|
| 274 |
+
this.exception = undefined;
|
| 275 |
+
}
|
| 276 |
+
getRecordError() {
|
| 277 |
+
if (this.exception) {
|
| 278 |
+
return this.exception;
|
| 279 |
+
}
|
| 280 |
+
if (this.statusCode === _api.SpanStatusCode.ERROR && this.statusMessage) {
|
| 281 |
+
return {
|
| 282 |
+
message: this.statusMessage
|
| 283 |
+
};
|
| 284 |
+
}
|
| 285 |
+
return undefined;
|
| 286 |
+
}
|
| 287 |
+
}
|
| 288 |
+
function getSpanStoreLinks(links) {
|
| 289 |
+
const spanStoreLinks = links == null ? void 0 : links.map((link)=>({
|
| 290 |
+
traceId: link.context.traceId,
|
| 291 |
+
spanId: link.context.spanId,
|
| 292 |
+
attributes: cleanSpanStoreAttributes(link.attributes)
|
| 293 |
+
}));
|
| 294 |
+
return (spanStoreLinks == null ? void 0 : spanStoreLinks.length) ? spanStoreLinks : undefined;
|
| 295 |
+
}
|
| 296 |
+
function cleanSpanStoreAttributes(attributes) {
|
| 297 |
+
const cleanedAttributes = {};
|
| 298 |
+
if (attributes) {
|
| 299 |
+
for (const key of Object.keys(attributes)){
|
| 300 |
+
const value = attributes[key];
|
| 301 |
+
if (value !== undefined) {
|
| 302 |
+
cleanedAttributes[key] = value;
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
return cleanedAttributes;
|
| 307 |
+
}
|
| 308 |
+
function getTimestamp(time) {
|
| 309 |
+
if (time instanceof Date) {
|
| 310 |
+
return time.getTime();
|
| 311 |
+
}
|
| 312 |
+
if (Array.isArray(time)) {
|
| 313 |
+
return time[0] * 1000 + time[1] / 1000000;
|
| 314 |
+
}
|
| 315 |
+
if (typeof time === 'number') {
|
| 316 |
+
return time < performance.timeOrigin / 2 ? performance.timeOrigin + time : time;
|
| 317 |
+
}
|
| 318 |
+
return performance.timeOrigin + performance.now();
|
| 319 |
+
}
|
| 320 |
+
function getStringAttribute(attributes, key) {
|
| 321 |
+
const value = attributes == null ? void 0 : attributes[key];
|
| 322 |
+
return typeof value === 'string' ? value : undefined;
|
| 323 |
+
}
|
| 324 |
+
function isSpanStoreAttributes(value) {
|
| 325 |
+
return typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
| 326 |
+
}
|
| 327 |
+
function isTimestampInput(value) {
|
| 328 |
+
return typeof value === 'number' || Array.isArray(value) || value instanceof Date;
|
| 329 |
+
}
|
| 330 |
+
function getSpanStoreException(exception) {
|
| 331 |
+
if (exception instanceof Error) {
|
| 332 |
+
return {
|
| 333 |
+
type: exception.name,
|
| 334 |
+
message: exception.message
|
| 335 |
+
};
|
| 336 |
+
}
|
| 337 |
+
if (typeof exception === 'string') {
|
| 338 |
+
return {
|
| 339 |
+
message: exception
|
| 340 |
+
};
|
| 341 |
+
}
|
| 342 |
+
if (exception && typeof exception === 'object') {
|
| 343 |
+
var _exception_constructor;
|
| 344 |
+
return {
|
| 345 |
+
type: (_exception_constructor = exception.constructor) == null ? void 0 : _exception_constructor.name,
|
| 346 |
+
message: 'message' in exception ? String(exception.message) : undefined
|
| 347 |
+
};
|
| 348 |
+
}
|
| 349 |
+
return undefined;
|
| 350 |
+
}
|
| 351 |
+
function getSpanStoreExceptionAttributes(exception) {
|
| 352 |
+
if (!exception) {
|
| 353 |
+
return undefined;
|
| 354 |
+
}
|
| 355 |
+
const attributes = {};
|
| 356 |
+
if (exception.type !== undefined) {
|
| 357 |
+
attributes['exception.type'] = exception.type;
|
| 358 |
+
}
|
| 359 |
+
if (exception.message !== undefined) {
|
| 360 |
+
attributes['exception.message'] = exception.message;
|
| 361 |
+
}
|
| 362 |
+
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
| 363 |
+
}
|
| 364 |
+
function getCurrentRequestIdentity() {
|
| 365 |
+
try {
|
| 366 |
+
const { getRequestInsightsIdentity } = require('./request-insights-identity');
|
| 367 |
+
const { workAsyncStorage } = require('../../app-render/work-async-storage.external');
|
| 368 |
+
const { workUnitAsyncStorage } = require('../../app-render/work-unit-async-storage.external');
|
| 369 |
+
const workStore = workAsyncStorage.getStore();
|
| 370 |
+
const workUnitStore = workUnitAsyncStorage.getStore();
|
| 371 |
+
const requestInsightsIdentity = getRequestInsightsIdentity();
|
| 372 |
+
const url = workUnitStore && 'url' in workUnitStore ? workUnitStore.url : undefined;
|
| 373 |
+
return {
|
| 374 |
+
requestId: (requestInsightsIdentity == null ? void 0 : requestInsightsIdentity.requestId) ?? (workStore == null ? void 0 : workStore.requestId),
|
| 375 |
+
requestInsightKind: requestInsightsIdentity == null ? void 0 : requestInsightsIdentity.kind,
|
| 376 |
+
htmlRequestId: (requestInsightsIdentity == null ? void 0 : requestInsightsIdentity.htmlRequestId) ?? (workStore == null ? void 0 : workStore.htmlRequestId),
|
| 377 |
+
route: workStore == null ? void 0 : workStore.route,
|
| 378 |
+
url: url ? `${url.pathname}${url.search}` : requestInsightsIdentity == null ? void 0 : requestInsightsIdentity.url
|
| 379 |
+
};
|
| 380 |
+
} catch {
|
| 381 |
+
return {};
|
| 382 |
+
}
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
//# sourceMappingURL=local-span-recorder.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/local-span-recorder.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/local-span-recorder.ts"],"sourcesContent":["import type {\n AttributeValue,\n Span,\n SpanOptions,\n} from 'next/dist/compiled/@opentelemetry/api'\nimport type { AsyncLocalStorage } from 'async_hooks'\nimport { SpanStatusCode } from 'next/dist/compiled/@opentelemetry/api'\nimport {\n isLocalSpanRecordingEnabled,\n isRequestInsightsEnabled,\n recordSpan,\n type SpanStoreAttributes,\n type SpanStoreEvent,\n type SpanStoreLink,\n} from './span-store'\nimport type { RequestInsightKind } from '../../../next-devtools/shared/request-insights'\n\nexport { isLocalSpanRecordingEnabled } from './span-store'\n\nconst TRACE_ID_HEX_LENGTH = 32\nconst SPAN_ID_HEX_LENGTH = 16\n\ntype LocalSpanAttributes = Partial<Record<string, AttributeValue | undefined>>\n\ntype LocalSpanOptions = {\n name: string\n attributes?: LocalSpanAttributes\n links?: SpanOptions['links']\n startTime?: SpanOptions['startTime']\n traceId?: string\n spanId?: string\n parentSpanId?: string\n delegateSpan?: Span\n isolateOpenTelemetry?: boolean\n}\n\ntype TraceLocalSpanOptions = Omit<\n LocalSpanOptions,\n | 'traceId'\n | 'spanId'\n | 'parentSpanId'\n | 'delegateSpan'\n | 'isolateOpenTelemetry'\n> & {\n parentSpan?: Span | null\n}\n\nlet lastLocalTraceId = 0\nlet lastLocalSpanId = 0\nlet localSpanAsyncStorage: AsyncLocalStorage<Span> | undefined\n\nconst getLocalTraceId = () =>\n (++lastLocalTraceId).toString(16).padStart(TRACE_ID_HEX_LENGTH, '0')\n\nconst getLocalSpanId = () =>\n (++lastLocalSpanId).toString(16).padStart(SPAN_ID_HEX_LENGTH, '0')\n\nexport function createLocalSpan({\n name,\n attributes,\n links,\n startTime,\n traceId,\n spanId,\n parentSpanId,\n delegateSpan,\n isolateOpenTelemetry,\n}: LocalSpanOptions): Span {\n return new LocalRecordingSpan({\n name,\n attributes,\n links,\n startTime,\n delegateSpan,\n traceId: traceId ?? getLocalTraceId(),\n spanId: spanId ?? getLocalSpanId(),\n parentSpanId,\n requestIdentity: getCurrentRequestIdentity(),\n isolateOpenTelemetry: isolateOpenTelemetry ?? false,\n })\n}\n\nexport function getActiveLocalSpan(): Span | undefined {\n return localSpanAsyncStorage?.getStore()\n}\n\nexport function isLocalRecordingSpan(span: Span): boolean {\n return span instanceof LocalRecordingSpan\n}\n\nexport function isOpenTelemetryIsolatedSpan(span: Span): boolean {\n return span instanceof LocalRecordingSpan && span.isOpenTelemetryIsolated()\n}\n\nexport function withLocalSpan<T>(span: Span, fn: () => T): T {\n return getLocalSpanAsyncStorage().run(span, fn)\n}\n\n/**\n * Records an async operation without replacing or exporting through the active\n * OpenTelemetry context. Nested Next.js spans remain in the local trace.\n */\nexport async function traceLocalSpan<T>(\n { parentSpan, ...options }: TraceLocalSpanOptions,\n fn: () => Promise<T>\n): Promise<T> {\n const resolvedParentSpan =\n parentSpan === undefined ? getActiveLocalSpan() : parentSpan\n const parentSpanContext = resolvedParentSpan?.spanContext()\n const span = createLocalSpan({\n ...options,\n traceId: parentSpanContext?.traceId,\n parentSpanId: parentSpanContext?.spanId,\n isolateOpenTelemetry: true,\n })\n\n return withLocalSpan(span, async () => {\n try {\n return await fn()\n } catch (err) {\n span.recordException(err as Error)\n span.setStatus({ code: SpanStatusCode.ERROR })\n throw err\n } finally {\n span.end()\n }\n })\n}\n\nexport type LocalSpanRecorder = {\n createLocalSpan: typeof createLocalSpan\n getActiveLocalSpan: typeof getActiveLocalSpan\n isLocalRecordingSpan: typeof isLocalRecordingSpan\n isOpenTelemetryIsolatedSpan: typeof isOpenTelemetryIsolatedSpan\n isLocalSpanRecordingEnabled: typeof isLocalSpanRecordingEnabled\n isRequestInsightsEnabled: typeof isRequestInsightsEnabled\n traceLocalSpan: typeof traceLocalSpan\n withLocalSpan: typeof withLocalSpan\n}\n\nexport function registerLocalSpanRecorder(): void {\n const key = Symbol.for('@next/local-span-recorder')\n ;(\n globalThis as typeof globalThis & {\n [key]?: LocalSpanRecorder\n }\n )[key] = {\n createLocalSpan,\n getActiveLocalSpan,\n isLocalRecordingSpan,\n isOpenTelemetryIsolatedSpan,\n isLocalSpanRecordingEnabled,\n isRequestInsightsEnabled,\n traceLocalSpan,\n withLocalSpan,\n }\n}\n\nfunction getLocalSpanAsyncStorage(): AsyncLocalStorage<Span> {\n if (!localSpanAsyncStorage) {\n const { createAsyncLocalStorage } =\n require('../../app-render/async-local-storage') as typeof import('../../app-render/async-local-storage')\n localSpanAsyncStorage = createAsyncLocalStorage()\n }\n\n return localSpanAsyncStorage\n}\n\ntype RequestIdentity = {\n requestId?: string\n requestInsightKind?: RequestInsightKind\n htmlRequestId?: string\n route?: string\n url?: string\n}\n\nclass LocalRecordingSpan implements Span {\n public name: string\n\n private attributes: SpanStoreAttributes\n private events: SpanStoreEvent[]\n private readonly spanContextValue: ReturnType<Span['spanContext']>\n private readonly openTelemetryIsolated: boolean\n private delegateSpan?: Span\n private links?: SpanStoreLink[]\n private readonly parentSpanId?: string\n private requestIdentity: RequestIdentity\n private readonly startTime: number\n private statusCode: number | undefined\n private statusMessage: string | undefined\n private exception:\n | {\n type?: string\n message?: string\n }\n | undefined\n private ended: boolean\n\n constructor({\n name,\n attributes,\n links,\n startTime,\n delegateSpan,\n traceId,\n spanId,\n parentSpanId,\n requestIdentity,\n isolateOpenTelemetry,\n }: {\n name: string\n attributes?: LocalSpanAttributes\n links?: SpanOptions['links']\n startTime?: SpanOptions['startTime']\n delegateSpan?: Span\n traceId: string\n spanId: string\n parentSpanId?: string\n requestIdentity: RequestIdentity\n isolateOpenTelemetry: boolean\n }) {\n this.name = name\n this.attributes = cleanSpanStoreAttributes(attributes)\n this.events = []\n this.delegateSpan = delegateSpan\n this.openTelemetryIsolated = isolateOpenTelemetry\n this.spanContextValue = delegateSpan?.spanContext() ?? {\n traceId,\n spanId,\n traceFlags: 0,\n }\n this.links = getSpanStoreLinks(links)\n this.parentSpanId = parentSpanId\n this.requestIdentity = requestIdentity\n this.startTime = getTimestamp(startTime)\n this.statusCode = undefined\n this.statusMessage = undefined\n this.exception = undefined\n this.ended = false\n }\n\n spanContext(): ReturnType<Span['spanContext']> {\n return this.spanContextValue\n }\n\n isOpenTelemetryIsolated(): boolean {\n return this.openTelemetryIsolated\n }\n\n setAttribute(key: string, value: AttributeValue): this {\n if (this.ended) {\n return this\n }\n\n this.attributes[key] = value\n this.delegateSpan?.setAttribute(key, value)\n return this\n }\n\n setAttributes(attributes: Parameters<Span['setAttributes']>[0]): this {\n if (this.ended) {\n return this\n }\n\n // OpenTelemetry attributes may be undefined. Ignore them instead of\n // overwriting an existing value as Object.assign would.\n for (const key of Object.keys(attributes)) {\n const value = attributes[key]\n if (value !== undefined) {\n this.attributes[key] = value\n }\n }\n this.delegateSpan?.setAttributes(attributes)\n return this\n }\n\n addEvent(\n name: string,\n attributesOrStartTime?: Parameters<Span['addEvent']>[1],\n startTime?: Parameters<Span['addEvent']>[2]\n ): this {\n if (this.ended) {\n return this\n }\n\n const eventTime =\n startTime === undefined && isTimestampInput(attributesOrStartTime)\n ? attributesOrStartTime\n : startTime\n this.events.push({\n name,\n timestamp: getTimestamp(eventTime),\n attributes: isSpanStoreAttributes(attributesOrStartTime)\n ? cleanSpanStoreAttributes(attributesOrStartTime)\n : undefined,\n })\n this.delegateSpan?.addEvent(name, attributesOrStartTime, startTime)\n return this\n }\n\n setStatus(status: Parameters<Span['setStatus']>[0]): this {\n if (this.ended) {\n return this\n }\n\n this.statusCode = status.code\n this.statusMessage = status.message\n this.delegateSpan?.setStatus(status)\n return this\n }\n\n updateName(name: string): this {\n if (this.ended) {\n return this\n }\n\n this.name = name\n this.delegateSpan?.updateName(name)\n return this\n }\n\n end(endTime?: Parameters<Span['end']>[0]): void {\n if (this.ended) {\n return\n }\n\n this.ended = true\n try {\n this.delegateSpan?.end(endTime)\n } finally {\n try {\n this.record(endTime)\n } finally {\n this.releaseReferences()\n }\n }\n }\n\n isRecording(): boolean {\n return !this.ended\n }\n\n recordException(\n exception: Parameters<Span['recordException']>[0],\n time?: Parameters<Span['recordException']>[1]\n ): void {\n if (this.ended) {\n return\n }\n\n this.exception = getSpanStoreException(exception)\n this.events.push({\n name: 'exception',\n timestamp: getTimestamp(time),\n attributes: getSpanStoreExceptionAttributes(this.exception),\n })\n this.delegateSpan?.recordException(exception, time)\n }\n\n private record(endTime: Parameters<Span['end']>[0]): void {\n const recordAttributes =\n Object.keys(this.attributes).length > 0 ? this.attributes : undefined\n\n recordSpan({\n name: this.name,\n startTime: this.startTime,\n durationMs: Math.max(0, getTimestamp(endTime) - this.startTime),\n status: this.statusCode === SpanStatusCode.ERROR ? 'error' : 'ok',\n traceId: this.spanContextValue.traceId,\n spanId: this.spanContextValue.spanId,\n parentSpanId: this.parentSpanId,\n requestId: this.requestIdentity.requestId,\n requestInsightKind: this.requestIdentity.requestInsightKind,\n htmlRequestId: this.requestIdentity.htmlRequestId,\n route:\n getStringAttribute(recordAttributes, 'next.route') ??\n getStringAttribute(recordAttributes, 'http.route') ??\n this.requestIdentity.route,\n url:\n getStringAttribute(recordAttributes, 'http.url') ??\n this.requestIdentity.url,\n attributes: recordAttributes,\n links: this.links,\n events: this.events.length > 0 ? this.events : undefined,\n error: this.getRecordError(),\n })\n }\n\n private releaseReferences(): void {\n // AsyncLocalStorage can keep an ended span reachable when work spawned\n // inside the span outlives it. Keep only the immutable span context and\n // primitive timing/identity fields needed by the Span API after end.\n this.name = ''\n this.attributes = {}\n this.events = []\n this.delegateSpan = undefined\n this.links = undefined\n this.requestIdentity = {}\n this.statusMessage = undefined\n this.exception = undefined\n }\n\n private getRecordError():\n | {\n type?: string\n message?: string\n }\n | undefined {\n if (this.exception) {\n return this.exception\n }\n\n if (this.statusCode === SpanStatusCode.ERROR && this.statusMessage) {\n return {\n message: this.statusMessage,\n }\n }\n\n return undefined\n }\n}\n\nfunction getSpanStoreLinks(\n links: SpanOptions['links'] | undefined\n): SpanStoreLink[] | undefined {\n const spanStoreLinks = links?.map((link) => ({\n traceId: link.context.traceId,\n spanId: link.context.spanId,\n attributes: cleanSpanStoreAttributes(link.attributes),\n }))\n\n return spanStoreLinks?.length ? spanStoreLinks : undefined\n}\n\nfunction cleanSpanStoreAttributes(\n attributes:\n | Record<string, AttributeValue | undefined>\n | SpanStoreAttributes\n | undefined\n): SpanStoreAttributes {\n const cleanedAttributes: SpanStoreAttributes = {}\n if (attributes) {\n for (const key of Object.keys(attributes)) {\n const value = attributes[key]\n if (value !== undefined) {\n cleanedAttributes[key] = value\n }\n }\n }\n return cleanedAttributes\n}\n\nfunction getTimestamp(time?: SpanOptions['startTime']): number {\n if (time instanceof Date) {\n return time.getTime()\n }\n\n if (Array.isArray(time)) {\n return time[0] * 1000 + time[1] / 1_000_000\n }\n\n if (typeof time === 'number') {\n return time < performance.timeOrigin / 2\n ? performance.timeOrigin + time\n : time\n }\n\n return performance.timeOrigin + performance.now()\n}\n\nfunction getStringAttribute(\n attributes: SpanStoreAttributes | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key]\n return typeof value === 'string' ? value : undefined\n}\n\nfunction isSpanStoreAttributes(\n value: Parameters<Span['addEvent']>[1]\n): value is SpanStoreAttributes {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !(value instanceof Date)\n )\n}\n\nfunction isTimestampInput(\n value: Parameters<Span['addEvent']>[1]\n): value is SpanOptions['startTime'] {\n return (\n typeof value === 'number' || Array.isArray(value) || value instanceof Date\n )\n}\n\nfunction getSpanStoreException(\n exception: Parameters<Span['recordException']>[0]\n):\n | {\n type?: string\n message?: string\n }\n | undefined {\n if (exception instanceof Error) {\n return {\n type: exception.name,\n message: exception.message,\n }\n }\n\n if (typeof exception === 'string') {\n return {\n message: exception,\n }\n }\n\n if (exception && typeof exception === 'object') {\n return {\n type: exception.constructor?.name,\n message: 'message' in exception ? String(exception.message) : undefined,\n }\n }\n\n return undefined\n}\n\nfunction getSpanStoreExceptionAttributes(\n exception:\n | {\n type?: string\n message?: string\n }\n | undefined\n): SpanStoreAttributes | undefined {\n if (!exception) {\n return undefined\n }\n\n const attributes: SpanStoreAttributes = {}\n if (exception.type !== undefined) {\n attributes['exception.type'] = exception.type\n }\n if (exception.message !== undefined) {\n attributes['exception.message'] = exception.message\n }\n return Object.keys(attributes).length > 0 ? attributes : undefined\n}\n\nfunction getCurrentRequestIdentity(): RequestIdentity {\n try {\n const { getRequestInsightsIdentity } =\n require('./request-insights-identity') as typeof import('./request-insights-identity')\n const { workAsyncStorage } =\n require('../../app-render/work-async-storage.external') as typeof import('../../app-render/work-async-storage.external')\n const { workUnitAsyncStorage } =\n require('../../app-render/work-unit-async-storage.external') as typeof import('../../app-render/work-unit-async-storage.external')\n const workStore = workAsyncStorage.getStore()\n const workUnitStore = workUnitAsyncStorage.getStore()\n const requestInsightsIdentity = getRequestInsightsIdentity()\n const url =\n workUnitStore && 'url' in workUnitStore ? workUnitStore.url : undefined\n\n return {\n requestId: requestInsightsIdentity?.requestId ?? workStore?.requestId,\n requestInsightKind: requestInsightsIdentity?.kind,\n htmlRequestId:\n requestInsightsIdentity?.htmlRequestId ?? workStore?.htmlRequestId,\n route: workStore?.route,\n url: url ? `${url.pathname}${url.search}` : requestInsightsIdentity?.url,\n }\n } catch {\n return {}\n }\n}\n"],"names":["createLocalSpan","getActiveLocalSpan","isLocalRecordingSpan","isLocalSpanRecordingEnabled","isOpenTelemetryIsolatedSpan","registerLocalSpanRecorder","traceLocalSpan","withLocalSpan","TRACE_ID_HEX_LENGTH","SPAN_ID_HEX_LENGTH","lastLocalTraceId","lastLocalSpanId","localSpanAsyncStorage","getLocalTraceId","toString","padStart","getLocalSpanId","name","attributes","links","startTime","traceId","spanId","parentSpanId","delegateSpan","isolateOpenTelemetry","LocalRecordingSpan","requestIdentity","getCurrentRequestIdentity","getStore","span","isOpenTelemetryIsolated","fn","getLocalSpanAsyncStorage","run","parentSpan","options","resolvedParentSpan","undefined","parentSpanContext","spanContext","err","recordException","setStatus","code","SpanStatusCode","ERROR","end","key","Symbol","for","globalThis","isRequestInsightsEnabled","createAsyncLocalStorage","require","constructor","cleanSpanStoreAttributes","events","openTelemetryIsolated","spanContextValue","traceFlags","getSpanStoreLinks","getTimestamp","statusCode","statusMessage","exception","ended","setAttribute","value","setAttributes","Object","keys","addEvent","attributesOrStartTime","eventTime","isTimestampInput","push","timestamp","isSpanStoreAttributes","status","message","updateName","endTime","record","releaseReferences","isRecording","time","getSpanStoreException","getSpanStoreExceptionAttributes","recordAttributes","length","recordSpan","durationMs","Math","max","requestId","requestInsightKind","htmlRequestId","route","getStringAttribute","url","error","getRecordError","spanStoreLinks","map","link","context","cleanedAttributes","Date","getTime","Array","isArray","performance","timeOrigin","now","Error","type","String","getRequestInsightsIdentity","workAsyncStorage","workUnitAsyncStorage","workStore","workUnitStore","requestInsightsIdentity","kind","pathname","search"],"mappings":";;;;;;;;;;;;;;;;;;;;;IAyDgBA,eAAe;eAAfA;;IAyBAC,kBAAkB;eAAlBA;;IAIAC,oBAAoB;eAApBA;;IArEPC,2BAA2B;eAA3BA,sCAA2B;;IAyEpBC,2BAA2B;eAA3BA;;IAkDAC,yBAAyB;eAAzBA;;IAtCMC,cAAc;eAAdA;;IARNC,aAAa;eAAbA;;;qBAxFe;2BAQxB;AAKP,MAAMC,sBAAsB;AAC5B,MAAMC,qBAAqB;AA2B3B,IAAIC,mBAAmB;AACvB,IAAIC,kBAAkB;AACtB,IAAIC;AAEJ,MAAMC,kBAAkB,IACtB,AAAC,CAAA,EAAEH,gBAAe,EAAGI,QAAQ,CAAC,IAAIC,QAAQ,CAACP,qBAAqB;AAElE,MAAMQ,iBAAiB,IACrB,AAAC,CAAA,EAAEL,eAAc,EAAGG,QAAQ,CAAC,IAAIC,QAAQ,CAACN,oBAAoB;AAEzD,SAAST,gBAAgB,EAC9BiB,IAAI,EACJC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,YAAY,EACZC,YAAY,EACZC,oBAAoB,EACH;IACjB,OAAO,IAAIC,mBAAmB;QAC5BT;QACAC;QACAC;QACAC;Q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AAAA,UAAW1B,SAAS;YACrEC,kBAAkB,EAAE2B,2CAAAA,wBAAyBC,IAAI;YACjD3B,eACE0B,CAAAA,2CAAAA,wBAAyB1B,aAAa,MAAIwB,6BAAAA,UAAWxB,aAAa;YACpEC,KAAK,EAAEuB,6BAAAA,UAAWvB,KAAK;YACvBE,KAAKA,MAAM,GAAGA,IAAIyB,QAAQ,GAAGzB,IAAI0B,MAAM,EAAE,GAAGH,2CAAAA,wBAAyBvB,GAAG;QAC1E;IACF,EAAE,OAAM;QACN,OAAO,CAAC;IACV;AACF","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/request-insights-identity.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { RequestInsightKind } from '../../../next-devtools/shared/request-insights';
|
| 2 |
+
export type RequestInsightsIdentity = {
|
| 3 |
+
requestId: string;
|
| 4 |
+
kind?: RequestInsightKind;
|
| 5 |
+
htmlRequestId: string;
|
| 6 |
+
url: string | undefined;
|
| 7 |
+
};
|
| 8 |
+
export declare function runWithRequestInsightsIdentity<T>(identity: RequestInsightsIdentity, fn: () => T): T;
|
| 9 |
+
export declare function getRequestInsightsIdentity(): RequestInsightsIdentity | undefined;
|
e-commerce/node_modules/next/dist/server/lib/trace/request-insights-identity.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
0 && (module.exports = {
|
| 6 |
+
getRequestInsightsIdentity: null,
|
| 7 |
+
runWithRequestInsightsIdentity: null
|
| 8 |
+
});
|
| 9 |
+
function _export(target, all) {
|
| 10 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 11 |
+
enumerable: true,
|
| 12 |
+
get: all[name]
|
| 13 |
+
});
|
| 14 |
+
}
|
| 15 |
+
_export(exports, {
|
| 16 |
+
getRequestInsightsIdentity: function() {
|
| 17 |
+
return getRequestInsightsIdentity;
|
| 18 |
+
},
|
| 19 |
+
runWithRequestInsightsIdentity: function() {
|
| 20 |
+
return runWithRequestInsightsIdentity;
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
const _asynclocalstorage = require("../../app-render/async-local-storage");
|
| 24 |
+
// This storage covers the part of BaseServer request handling that runs before
|
| 25 |
+
// App Render creates workAsyncStorage. Once available, workStore remains the
|
| 26 |
+
// primary identity source for locally recorded spans.
|
| 27 |
+
function getRequestInsightsIdentityStorage() {
|
| 28 |
+
return (0, _asynclocalstorage.getOrCreateGlobalAsyncLocalStorage)('request-insights-identity-storage');
|
| 29 |
+
}
|
| 30 |
+
function runWithRequestInsightsIdentity(identity, fn) {
|
| 31 |
+
return getRequestInsightsIdentityStorage().run(identity, fn);
|
| 32 |
+
}
|
| 33 |
+
function getRequestInsightsIdentity() {
|
| 34 |
+
return getRequestInsightsIdentityStorage().getStore();
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
//# sourceMappingURL=request-insights-identity.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/request-insights-identity.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/request-insights-identity.ts"],"sourcesContent":["import type { AsyncLocalStorage } from 'async_hooks'\nimport type { RequestInsightKind } from '../../../next-devtools/shared/request-insights'\nimport { getOrCreateGlobalAsyncLocalStorage } from '../../app-render/async-local-storage'\n\nexport type RequestInsightsIdentity = {\n requestId: string\n kind?: RequestInsightKind\n htmlRequestId: string\n url: string | undefined\n}\n\n// This storage covers the part of BaseServer request handling that runs before\n// App Render creates workAsyncStorage. Once available, workStore remains the\n// primary identity source for locally recorded spans.\nfunction getRequestInsightsIdentityStorage(): AsyncLocalStorage<RequestInsightsIdentity> {\n return getOrCreateGlobalAsyncLocalStorage('request-insights-identity-storage')\n}\n\nexport function runWithRequestInsightsIdentity<T>(\n identity: RequestInsightsIdentity,\n fn: () => T\n): T {\n return getRequestInsightsIdentityStorage().run(identity, fn)\n}\n\nexport function getRequestInsightsIdentity():\n | RequestInsightsIdentity\n | undefined {\n return getRequestInsightsIdentityStorage().getStore()\n}\n"],"names":["getRequestInsightsIdentity","runWithRequestInsightsIdentity","getRequestInsightsIdentityStorage","getOrCreateGlobalAsyncLocalStorage","identity","fn","run","getStore"],"mappings":";;;;;;;;;;;;;;;IAyBgBA,0BAA0B;eAA1BA;;IAPAC,8BAA8B;eAA9BA;;;mCAhBmC;AASnD,+EAA+E;AAC/E,6EAA6E;AAC7E,sDAAsD;AACtD,SAASC;IACP,OAAOC,IAAAA,qDAAkC,EAAC;AAC5C;AAEO,SAASF,+BACdG,QAAiC,EACjCC,EAAW;IAEX,OAAOH,oCAAoCI,GAAG,CAACF,UAAUC;AAC3D;AAEO,SAASL;IAGd,OAAOE,oCAAoCK,QAAQ;AACrD","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/request-insights.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { RequestInsight, RequestInsightFetch, RequestInsightsSnapshot } from '../../../next-devtools/shared/request-insights';
|
| 2 |
+
import type { RequestInsightKind } from '../../../shared/lib/request-insights';
|
| 3 |
+
import type { SpanStoreRecord } from './span-store';
|
| 4 |
+
export { isRequestInsightsEnabled } from './span-store';
|
| 5 |
+
type RequestInsightsListener = (insight: RequestInsight) => void;
|
| 6 |
+
type RequestInsightIdentity = {
|
| 7 |
+
requestId?: string;
|
| 8 |
+
kind?: RequestInsightKind;
|
| 9 |
+
htmlRequestId?: string;
|
| 10 |
+
route?: string;
|
| 11 |
+
url?: string;
|
| 12 |
+
};
|
| 13 |
+
export declare function recordRequestInsightSpan(span: SpanStoreRecord): void;
|
| 14 |
+
export declare function recordRequestInsightFetch(identity: RequestInsightIdentity, fetch: RequestInsightFetch): void;
|
| 15 |
+
export declare function getRequestInsightsSnapshot(): RequestInsightsSnapshot;
|
| 16 |
+
export declare function subscribeRequestInsights(listener: RequestInsightsListener): () => void;
|
| 17 |
+
export declare function clearRequestInsightsForTest(): void;
|
e-commerce/node_modules/next/dist/server/lib/trace/request-insights.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
0 && (module.exports = {
|
| 6 |
+
clearRequestInsightsForTest: null,
|
| 7 |
+
getRequestInsightsSnapshot: null,
|
| 8 |
+
isRequestInsightsEnabled: null,
|
| 9 |
+
recordRequestInsightFetch: null,
|
| 10 |
+
recordRequestInsightSpan: null,
|
| 11 |
+
subscribeRequestInsights: null
|
| 12 |
+
});
|
| 13 |
+
function _export(target, all) {
|
| 14 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 15 |
+
enumerable: true,
|
| 16 |
+
get: all[name]
|
| 17 |
+
});
|
| 18 |
+
}
|
| 19 |
+
_export(exports, {
|
| 20 |
+
clearRequestInsightsForTest: function() {
|
| 21 |
+
return clearRequestInsightsForTest;
|
| 22 |
+
},
|
| 23 |
+
getRequestInsightsSnapshot: function() {
|
| 24 |
+
return getRequestInsightsSnapshot;
|
| 25 |
+
},
|
| 26 |
+
isRequestInsightsEnabled: function() {
|
| 27 |
+
return _spanstore.isRequestInsightsEnabled;
|
| 28 |
+
},
|
| 29 |
+
recordRequestInsightFetch: function() {
|
| 30 |
+
return recordRequestInsightFetch;
|
| 31 |
+
},
|
| 32 |
+
recordRequestInsightSpan: function() {
|
| 33 |
+
return recordRequestInsightSpan;
|
| 34 |
+
},
|
| 35 |
+
subscribeRequestInsights: function() {
|
| 36 |
+
return subscribeRequestInsights;
|
| 37 |
+
}
|
| 38 |
+
});
|
| 39 |
+
const _requestinsights = require("../../../shared/lib/request-insights");
|
| 40 |
+
const _spanstore = require("./span-store");
|
| 41 |
+
const MAX_REQUEST_INSIGHTS = 100;
|
| 42 |
+
const REQUEST_INSIGHTS_STORE_KEY = Symbol.for('@next/request-insights-store');
|
| 43 |
+
const CLIENT_COMPONENT_LOADING_SPAN_TYPE = 'NextNodeServer.clientComponentLoading';
|
| 44 |
+
const REDACTED_VALUE = 'redacted';
|
| 45 |
+
const SAFE_SPAN_ATTRIBUTE_KEYS = new Set([
|
| 46 |
+
'http.method',
|
| 47 |
+
'http.route',
|
| 48 |
+
'http.status_code',
|
| 49 |
+
'http.url',
|
| 50 |
+
'net.peer.name',
|
| 51 |
+
'net.peer.port',
|
| 52 |
+
'next.fetch.cache_reason',
|
| 53 |
+
'next.fetch.cache_status',
|
| 54 |
+
'next.fetch.idx',
|
| 55 |
+
'next.route',
|
| 56 |
+
'next.rsc',
|
| 57 |
+
'next.segment',
|
| 58 |
+
'next.span_category',
|
| 59 |
+
'next.span_name',
|
| 60 |
+
'next.span_type'
|
| 61 |
+
]);
|
| 62 |
+
const SENSITIVE_PARAM_NAME_RE = /(?:^|[_-])(?:access[_-]?token|api[_-]?key|auth|authorization|code|cookie|credential|id[_-]?token|jwt|key|password|secret|session|signature|sig|token)(?:$|[_-])/i;
|
| 63 |
+
class InMemoryRequestInsightsStore {
|
| 64 |
+
recordSpan(span) {
|
| 65 |
+
var _span_attributes;
|
| 66 |
+
if (!span.requestId) {
|
| 67 |
+
return;
|
| 68 |
+
}
|
| 69 |
+
const insight = this.getOrCreateRequest({
|
| 70 |
+
requestId: span.requestId,
|
| 71 |
+
kind: span.requestInsightKind,
|
| 72 |
+
htmlRequestId: span.htmlRequestId,
|
| 73 |
+
route: span.route,
|
| 74 |
+
url: span.url
|
| 75 |
+
}, span.startTime ?? span.timestamp);
|
| 76 |
+
const spanStartTime = span.startTime ?? span.timestamp;
|
| 77 |
+
insight.htmlRequestId = span.htmlRequestId ?? insight.htmlRequestId;
|
| 78 |
+
insight.route = insight.route ?? span.route;
|
| 79 |
+
insight.url = insight.url ?? sanitizeUrl(span.url);
|
| 80 |
+
this.updateTiming(insight, spanStartTime, span.durationMs, ((_span_attributes = span.attributes) == null ? void 0 : _span_attributes['next.span_type']) === 'BaseServer.handleRequest');
|
| 81 |
+
insight.status = insight.status === 'error' || span.status === 'error' ? 'error' : span.status === 'ok' ? 'ok' : insight.status;
|
| 82 |
+
insight.spans.push({
|
| 83 |
+
name: span.name,
|
| 84 |
+
startTime: spanStartTime,
|
| 85 |
+
durationMs: span.durationMs,
|
| 86 |
+
status: span.status,
|
| 87 |
+
traceId: span.traceId,
|
| 88 |
+
spanId: span.spanId,
|
| 89 |
+
parentSpanId: span.parentSpanId,
|
| 90 |
+
attributes: sanitizeSpanAttributes(span.attributes),
|
| 91 |
+
links: sanitizeSpanLinks(span.links),
|
| 92 |
+
events: sanitizeSpanEvents(span.events),
|
| 93 |
+
error: span.error
|
| 94 |
+
});
|
| 95 |
+
const fetch = getFetchInsight(span);
|
| 96 |
+
if (fetch) {
|
| 97 |
+
this.recordFetchForInsight(insight, fetch);
|
| 98 |
+
}
|
| 99 |
+
this.notify(insight);
|
| 100 |
+
}
|
| 101 |
+
recordFetch(identity, fetch) {
|
| 102 |
+
if (!identity.requestId) {
|
| 103 |
+
return;
|
| 104 |
+
}
|
| 105 |
+
const fetchStartTime = fetch.startTime ?? getCurrentTimestamp();
|
| 106 |
+
const insight = this.getOrCreateRequest(identity, fetchStartTime);
|
| 107 |
+
this.updateTiming(insight, fetchStartTime, fetch.durationMs, false);
|
| 108 |
+
this.recordFetchForInsight(insight, sanitizeFetchInsight(fetch));
|
| 109 |
+
this.notify(insight);
|
| 110 |
+
}
|
| 111 |
+
getSnapshot() {
|
| 112 |
+
return {
|
| 113 |
+
requests: this.requestOrder.map((insightKey)=>this.requests.get(insightKey)).filter((request)=>request !== undefined)
|
| 114 |
+
};
|
| 115 |
+
}
|
| 116 |
+
subscribe(listener) {
|
| 117 |
+
this.listeners.add(listener);
|
| 118 |
+
return ()=>{
|
| 119 |
+
this.listeners.delete(listener);
|
| 120 |
+
};
|
| 121 |
+
}
|
| 122 |
+
clear() {
|
| 123 |
+
this.requests.clear();
|
| 124 |
+
this.requestTimings.clear();
|
| 125 |
+
this.requestOrder.length = 0;
|
| 126 |
+
}
|
| 127 |
+
updateTiming(insight, startTime, durationMs, isRequestSpan) {
|
| 128 |
+
const insightKey = (0, _requestinsights.getRequestInsightKey)(insight);
|
| 129 |
+
if (isRequestSpan && durationMs !== undefined) {
|
| 130 |
+
const requestTiming = {
|
| 131 |
+
startTime,
|
| 132 |
+
durationMs
|
| 133 |
+
};
|
| 134 |
+
this.requestTimings.set(insightKey, requestTiming);
|
| 135 |
+
insight.startTime = requestTiming.startTime;
|
| 136 |
+
insight.durationMs = requestTiming.durationMs;
|
| 137 |
+
return;
|
| 138 |
+
}
|
| 139 |
+
const requestTiming = this.requestTimings.get(insightKey);
|
| 140 |
+
if (requestTiming) {
|
| 141 |
+
insight.startTime = requestTiming.startTime;
|
| 142 |
+
insight.durationMs = requestTiming.durationMs;
|
| 143 |
+
return;
|
| 144 |
+
}
|
| 145 |
+
const endTime = startTime + (durationMs ?? 0);
|
| 146 |
+
const requestEndTime = insight.startTime + (insight.durationMs ?? 0);
|
| 147 |
+
insight.startTime = Math.min(insight.startTime, startTime);
|
| 148 |
+
insight.durationMs = Math.max(requestEndTime, endTime) - insight.startTime;
|
| 149 |
+
}
|
| 150 |
+
notify(insight) {
|
| 151 |
+
for (const listener of this.listeners){
|
| 152 |
+
listener(insight);
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
getOrCreateRequest(identity, startTime) {
|
| 156 |
+
const requestId = identity.requestId;
|
| 157 |
+
const insightKey = (0, _requestinsights.getRequestInsightKey)({
|
| 158 |
+
requestId,
|
| 159 |
+
kind: identity.kind
|
| 160 |
+
});
|
| 161 |
+
let insight = this.requests.get(insightKey);
|
| 162 |
+
if (!insight) {
|
| 163 |
+
insight = {
|
| 164 |
+
requestId,
|
| 165 |
+
kind: (0, _requestinsights.getRequestInsightKind)(identity),
|
| 166 |
+
htmlRequestId: identity.htmlRequestId ?? requestId,
|
| 167 |
+
route: identity.route,
|
| 168 |
+
url: sanitizeUrl(identity.url),
|
| 169 |
+
startTime,
|
| 170 |
+
status: 'pending',
|
| 171 |
+
spans: [],
|
| 172 |
+
fetches: []
|
| 173 |
+
};
|
| 174 |
+
this.requests.set(insightKey, insight);
|
| 175 |
+
this.requestOrder.push(insightKey);
|
| 176 |
+
this.trim();
|
| 177 |
+
}
|
| 178 |
+
insight.htmlRequestId = identity.htmlRequestId ?? insight.htmlRequestId;
|
| 179 |
+
insight.route = insight.route ?? identity.route;
|
| 180 |
+
insight.url = insight.url ?? sanitizeUrl(identity.url);
|
| 181 |
+
insight.startTime = Math.min(insight.startTime, startTime);
|
| 182 |
+
return insight;
|
| 183 |
+
}
|
| 184 |
+
recordFetchForInsight(insight, fetch) {
|
| 185 |
+
if (insight.fetches.some((existingFetch)=>existingFetch.url === fetch.url && (existingFetch.index !== undefined && fetch.index !== undefined ? existingFetch.index === fetch.index : existingFetch.startTime === fetch.startTime))) {
|
| 186 |
+
return;
|
| 187 |
+
}
|
| 188 |
+
insight.fetches.push(sanitizeFetchInsight(fetch));
|
| 189 |
+
}
|
| 190 |
+
trim() {
|
| 191 |
+
while(this.requestOrder.length > MAX_REQUEST_INSIGHTS){
|
| 192 |
+
const insightKey = this.requestOrder.shift();
|
| 193 |
+
if (insightKey) {
|
| 194 |
+
this.requests.delete(insightKey);
|
| 195 |
+
this.requestTimings.delete(insightKey);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
constructor(){
|
| 200 |
+
this.requests = new Map();
|
| 201 |
+
this.requestTimings = new Map();
|
| 202 |
+
this.requestOrder = [];
|
| 203 |
+
this.listeners = new Set();
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
function recordRequestInsightSpan(span) {
|
| 207 |
+
var _span_attributes;
|
| 208 |
+
if (((_span_attributes = span.attributes) == null ? void 0 : _span_attributes['next.span_type']) === CLIENT_COMPONENT_LOADING_SPAN_TYPE) {
|
| 209 |
+
return;
|
| 210 |
+
}
|
| 211 |
+
getRequestInsightsStore().recordSpan(span);
|
| 212 |
+
}
|
| 213 |
+
function recordRequestInsightFetch(identity, fetch) {
|
| 214 |
+
getRequestInsightsStore().recordFetch(identity, fetch);
|
| 215 |
+
}
|
| 216 |
+
function getRequestInsightsSnapshot() {
|
| 217 |
+
return getRequestInsightsStore().getSnapshot();
|
| 218 |
+
}
|
| 219 |
+
function subscribeRequestInsights(listener) {
|
| 220 |
+
return getRequestInsightsStore().subscribe(listener);
|
| 221 |
+
}
|
| 222 |
+
function clearRequestInsightsForTest() {
|
| 223 |
+
getRequestInsightsStore().clear();
|
| 224 |
+
}
|
| 225 |
+
function getRequestInsightsStore() {
|
| 226 |
+
const globalStore = globalThis;
|
| 227 |
+
return globalStore[REQUEST_INSIGHTS_STORE_KEY] ??= new InMemoryRequestInsightsStore();
|
| 228 |
+
}
|
| 229 |
+
function getFetchInsight(span) {
|
| 230 |
+
const attributes = span.attributes;
|
| 231 |
+
if (!attributes || attributes['next.span_type'] !== 'AppRender.fetch') {
|
| 232 |
+
return null;
|
| 233 |
+
}
|
| 234 |
+
return {
|
| 235 |
+
url: sanitizeUrl(getStringAttribute(attributes['http.url']) ?? span.url),
|
| 236 |
+
method: getStringAttribute(attributes['http.method']),
|
| 237 |
+
statusCode: getNumberAttribute(attributes['http.status_code']),
|
| 238 |
+
startTime: span.startTime ?? span.timestamp,
|
| 239 |
+
durationMs: span.durationMs,
|
| 240 |
+
cacheStatus: getStringAttribute(attributes['next.fetch.cache_status']),
|
| 241 |
+
cacheReason: getStringAttribute(attributes['next.fetch.cache_reason']),
|
| 242 |
+
index: getNumberAttribute(attributes['next.fetch.idx'])
|
| 243 |
+
};
|
| 244 |
+
}
|
| 245 |
+
function sanitizeFetchInsight(fetch) {
|
| 246 |
+
return {
|
| 247 |
+
...fetch,
|
| 248 |
+
url: sanitizeUrl(fetch.url)
|
| 249 |
+
};
|
| 250 |
+
}
|
| 251 |
+
function getCurrentTimestamp() {
|
| 252 |
+
return performance.timeOrigin + performance.now();
|
| 253 |
+
}
|
| 254 |
+
function sanitizeSpanAttributes(attributes) {
|
| 255 |
+
if (!attributes) {
|
| 256 |
+
return undefined;
|
| 257 |
+
}
|
| 258 |
+
const sanitized = {};
|
| 259 |
+
for (const [key, value] of Object.entries(attributes)){
|
| 260 |
+
if (!SAFE_SPAN_ATTRIBUTE_KEYS.has(key)) {
|
| 261 |
+
continue;
|
| 262 |
+
}
|
| 263 |
+
sanitized[key] = key === 'http.url' ? sanitizeUrlAttribute(value) : value;
|
| 264 |
+
}
|
| 265 |
+
return Object.keys(sanitized).length > 0 ? sanitized : undefined;
|
| 266 |
+
}
|
| 267 |
+
function sanitizeSpanEvents(events) {
|
| 268 |
+
return events == null ? void 0 : events.map((event)=>({
|
| 269 |
+
...event,
|
| 270 |
+
attributes: sanitizeSpanAttributes(event.attributes)
|
| 271 |
+
}));
|
| 272 |
+
}
|
| 273 |
+
function sanitizeSpanLinks(links) {
|
| 274 |
+
return links == null ? void 0 : links.map((link)=>({
|
| 275 |
+
...link,
|
| 276 |
+
attributes: sanitizeSpanAttributes(link.attributes)
|
| 277 |
+
}));
|
| 278 |
+
}
|
| 279 |
+
function sanitizeUrlAttribute(value) {
|
| 280 |
+
return typeof value === 'string' ? sanitizeUrl(value) ?? '' : value;
|
| 281 |
+
}
|
| 282 |
+
function sanitizeUrl(value) {
|
| 283 |
+
if (!value) {
|
| 284 |
+
return value;
|
| 285 |
+
}
|
| 286 |
+
const isRelativeUrl = value.startsWith('/');
|
| 287 |
+
try {
|
| 288 |
+
const url = isRelativeUrl ? new URL(value, 'http://n') : new URL(value);
|
| 289 |
+
url.username = '';
|
| 290 |
+
url.password = '';
|
| 291 |
+
for (const name of Array.from(url.searchParams.keys())){
|
| 292 |
+
if (SENSITIVE_PARAM_NAME_RE.test(name)) {
|
| 293 |
+
url.searchParams.set(name, REDACTED_VALUE);
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
return isRelativeUrl ? `${url.pathname}${url.search}${url.hash}` : url.href;
|
| 297 |
+
} catch {
|
| 298 |
+
return value;
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
function getStringAttribute(value) {
|
| 302 |
+
return typeof value === 'string' ? value : undefined;
|
| 303 |
+
}
|
| 304 |
+
function getNumberAttribute(value) {
|
| 305 |
+
return typeof value === 'number' ? value : undefined;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
//# sourceMappingURL=request-insights.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/request-insights.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/request-insights.ts"],"sourcesContent":["import type { AttributeValue } from 'next/dist/compiled/@opentelemetry/api'\nimport type {\n RequestInsight,\n RequestInsightFetch,\n RequestInsightsSnapshot,\n} from '../../../next-devtools/shared/request-insights'\nimport type { RequestInsightKind } from '../../../shared/lib/request-insights'\nimport {\n getRequestInsightKey,\n getRequestInsightKind,\n} from '../../../shared/lib/request-insights'\nimport type { SpanStoreRecord } from './span-store'\nexport { isRequestInsightsEnabled } from './span-store'\n\nconst MAX_REQUEST_INSIGHTS = 100\nconst REQUEST_INSIGHTS_STORE_KEY = Symbol.for('@next/request-insights-store')\nconst CLIENT_COMPONENT_LOADING_SPAN_TYPE =\n 'NextNodeServer.clientComponentLoading'\n\ntype RequestInsightsListener = (insight: RequestInsight) => void\ntype RequestInsightIdentity = {\n requestId?: string\n kind?: RequestInsightKind\n htmlRequestId?: string\n route?: string\n url?: string\n}\n\nconst REDACTED_VALUE = 'redacted'\nconst SAFE_SPAN_ATTRIBUTE_KEYS = new Set([\n 'http.method',\n 'http.route',\n 'http.status_code',\n 'http.url',\n 'net.peer.name',\n 'net.peer.port',\n 'next.fetch.cache_reason',\n 'next.fetch.cache_status',\n 'next.fetch.idx',\n 'next.route',\n 'next.rsc',\n 'next.segment',\n 'next.span_category',\n 'next.span_name',\n 'next.span_type',\n])\nconst SENSITIVE_PARAM_NAME_RE =\n /(?:^|[_-])(?:access[_-]?token|api[_-]?key|auth|authorization|code|cookie|credential|id[_-]?token|jwt|key|password|secret|session|signature|sig|token)(?:$|[_-])/i\n\nclass InMemoryRequestInsightsStore {\n private readonly requests = new Map<string, RequestInsight>()\n private readonly requestTimings = new Map<\n string,\n { startTime: number; durationMs: number }\n >()\n private readonly requestOrder: string[] = []\n private readonly listeners = new Set<RequestInsightsListener>()\n\n recordSpan(span: SpanStoreRecord): void {\n if (!span.requestId) {\n return\n }\n\n const insight = this.getOrCreateRequest(\n {\n requestId: span.requestId,\n kind: span.requestInsightKind,\n htmlRequestId: span.htmlRequestId,\n route: span.route,\n url: span.url,\n },\n span.startTime ?? span.timestamp\n )\n\n const spanStartTime = span.startTime ?? span.timestamp\n insight.htmlRequestId = span.htmlRequestId ?? insight.htmlRequestId\n insight.route = insight.route ?? span.route\n insight.url = insight.url ?? sanitizeUrl(span.url)\n this.updateTiming(\n insight,\n spanStartTime,\n span.durationMs,\n span.attributes?.['next.span_type'] === 'BaseServer.handleRequest'\n )\n insight.status =\n insight.status === 'error' || span.status === 'error'\n ? 'error'\n : span.status === 'ok'\n ? 'ok'\n : insight.status\n\n insight.spans.push({\n name: span.name,\n startTime: spanStartTime,\n durationMs: span.durationMs,\n status: span.status,\n traceId: span.traceId,\n spanId: span.spanId,\n parentSpanId: span.parentSpanId,\n attributes: sanitizeSpanAttributes(span.attributes),\n links: sanitizeSpanLinks(span.links),\n events: sanitizeSpanEvents(span.events),\n error: span.error,\n })\n\n const fetch = getFetchInsight(span)\n if (fetch) {\n this.recordFetchForInsight(insight, fetch)\n }\n\n this.notify(insight)\n }\n\n recordFetch(identity: RequestInsightIdentity, fetch: RequestInsightFetch) {\n if (!identity.requestId) {\n return\n }\n\n const fetchStartTime = fetch.startTime ?? getCurrentTimestamp()\n const insight = this.getOrCreateRequest(identity, fetchStartTime)\n this.updateTiming(insight, fetchStartTime, fetch.durationMs, false)\n this.recordFetchForInsight(insight, sanitizeFetchInsight(fetch))\n this.notify(insight)\n }\n\n getSnapshot(): RequestInsightsSnapshot {\n return {\n requests: this.requestOrder\n .map((insightKey) => this.requests.get(insightKey))\n .filter((request): request is RequestInsight => request !== undefined),\n }\n }\n\n subscribe(listener: RequestInsightsListener): () => void {\n this.listeners.add(listener)\n return () => {\n this.listeners.delete(listener)\n }\n }\n\n clear(): void {\n this.requests.clear()\n this.requestTimings.clear()\n this.requestOrder.length = 0\n }\n\n private updateTiming(\n insight: RequestInsight,\n startTime: number,\n durationMs: number | undefined,\n isRequestSpan: boolean\n ): void {\n const insightKey = getRequestInsightKey(insight)\n if (isRequestSpan && durationMs !== undefined) {\n const requestTiming = { startTime, durationMs }\n this.requestTimings.set(insightKey, requestTiming)\n insight.startTime = requestTiming.startTime\n insight.durationMs = requestTiming.durationMs\n return\n }\n\n const requestTiming = this.requestTimings.get(insightKey)\n if (requestTiming) {\n insight.startTime = requestTiming.startTime\n insight.durationMs = requestTiming.durationMs\n return\n }\n\n const endTime = startTime + (durationMs ?? 0)\n const requestEndTime = insight.startTime + (insight.durationMs ?? 0)\n insight.startTime = Math.min(insight.startTime, startTime)\n insight.durationMs = Math.max(requestEndTime, endTime) - insight.startTime\n }\n\n private notify(insight: RequestInsight): void {\n for (const listener of this.listeners) {\n listener(insight)\n }\n }\n\n private getOrCreateRequest(\n identity: RequestInsightIdentity,\n startTime: number\n ): RequestInsight {\n const requestId = identity.requestId!\n const insightKey = getRequestInsightKey({\n requestId,\n kind: identity.kind,\n })\n let insight = this.requests.get(insightKey)\n\n if (!insight) {\n insight = {\n requestId,\n kind: getRequestInsightKind(identity),\n htmlRequestId: identity.htmlRequestId ?? requestId,\n route: identity.route,\n url: sanitizeUrl(identity.url),\n startTime,\n status: 'pending',\n spans: [],\n fetches: [],\n }\n this.requests.set(insightKey, insight)\n this.requestOrder.push(insightKey)\n this.trim()\n }\n\n insight.htmlRequestId = identity.htmlRequestId ?? insight.htmlRequestId\n insight.route = insight.route ?? identity.route\n insight.url = insight.url ?? sanitizeUrl(identity.url)\n insight.startTime = Math.min(insight.startTime, startTime)\n\n return insight\n }\n\n private recordFetchForInsight(\n insight: RequestInsight,\n fetch: RequestInsightFetch\n ): void {\n if (\n insight.fetches.some(\n (existingFetch) =>\n existingFetch.url === fetch.url &&\n (existingFetch.index !== undefined && fetch.index !== undefined\n ? existingFetch.index === fetch.index\n : existingFetch.startTime === fetch.startTime)\n )\n ) {\n return\n }\n\n insight.fetches.push(sanitizeFetchInsight(fetch))\n }\n\n private trim(): void {\n while (this.requestOrder.length > MAX_REQUEST_INSIGHTS) {\n const insightKey = this.requestOrder.shift()\n if (insightKey) {\n this.requests.delete(insightKey)\n this.requestTimings.delete(insightKey)\n }\n }\n }\n}\n\nexport function recordRequestInsightSpan(span: SpanStoreRecord): void {\n if (\n span.attributes?.['next.span_type'] === CLIENT_COMPONENT_LOADING_SPAN_TYPE\n ) {\n return\n }\n\n getRequestInsightsStore().recordSpan(span)\n}\n\nexport function recordRequestInsightFetch(\n identity: RequestInsightIdentity,\n fetch: RequestInsightFetch\n): void {\n getRequestInsightsStore().recordFetch(identity, fetch)\n}\n\nexport function getRequestInsightsSnapshot(): RequestInsightsSnapshot {\n return getRequestInsightsStore().getSnapshot()\n}\n\nexport function subscribeRequestInsights(\n listener: RequestInsightsListener\n): () => void {\n return getRequestInsightsStore().subscribe(listener)\n}\n\nexport function clearRequestInsightsForTest(): void {\n getRequestInsightsStore().clear()\n}\n\nfunction getRequestInsightsStore(): InMemoryRequestInsightsStore {\n const globalStore = globalThis as typeof globalThis & {\n [REQUEST_INSIGHTS_STORE_KEY]?: InMemoryRequestInsightsStore\n }\n\n return (globalStore[REQUEST_INSIGHTS_STORE_KEY] ??=\n new InMemoryRequestInsightsStore())\n}\n\nfunction getFetchInsight(span: SpanStoreRecord): RequestInsightFetch | null {\n const attributes = span.attributes\n\n if (!attributes || attributes['next.span_type'] !== 'AppRender.fetch') {\n return null\n }\n\n return {\n url: sanitizeUrl(getStringAttribute(attributes['http.url']) ?? span.url),\n method: getStringAttribute(attributes['http.method']),\n statusCode: getNumberAttribute(attributes['http.status_code']),\n startTime: span.startTime ?? span.timestamp,\n durationMs: span.durationMs,\n cacheStatus: getStringAttribute(attributes['next.fetch.cache_status']),\n cacheReason: getStringAttribute(attributes['next.fetch.cache_reason']),\n index: getNumberAttribute(attributes['next.fetch.idx']),\n }\n}\n\nfunction sanitizeFetchInsight(fetch: RequestInsightFetch): RequestInsightFetch {\n return {\n ...fetch,\n url: sanitizeUrl(fetch.url),\n }\n}\n\nfunction getCurrentTimestamp(): number {\n return performance.timeOrigin + performance.now()\n}\n\nfunction sanitizeSpanAttributes(\n attributes: SpanStoreRecord['attributes']\n): SpanStoreRecord['attributes'] {\n if (!attributes) {\n return undefined\n }\n\n const sanitized: NonNullable<SpanStoreRecord['attributes']> = {}\n for (const [key, value] of Object.entries(attributes)) {\n if (!SAFE_SPAN_ATTRIBUTE_KEYS.has(key)) {\n continue\n }\n\n sanitized[key] = key === 'http.url' ? sanitizeUrlAttribute(value) : value\n }\n\n return Object.keys(sanitized).length > 0 ? sanitized : undefined\n}\n\nfunction sanitizeSpanEvents(\n events: SpanStoreRecord['events']\n): SpanStoreRecord['events'] {\n return events?.map((event) => ({\n ...event,\n attributes: sanitizeSpanAttributes(event.attributes),\n }))\n}\n\nfunction sanitizeSpanLinks(\n links: SpanStoreRecord['links']\n): SpanStoreRecord['links'] {\n return links?.map((link) => ({\n ...link,\n attributes: sanitizeSpanAttributes(link.attributes),\n }))\n}\n\nfunction sanitizeUrlAttribute(value: AttributeValue): AttributeValue {\n return typeof value === 'string' ? (sanitizeUrl(value) ?? '') : value\n}\n\nfunction sanitizeUrl(value: string | undefined): string | undefined {\n if (!value) {\n return value\n }\n\n const isRelativeUrl = value.startsWith('/')\n\n try {\n const url = isRelativeUrl ? new URL(value, 'http://n') : new URL(value)\n\n url.username = ''\n url.password = ''\n\n for (const name of Array.from(url.searchParams.keys())) {\n if (SENSITIVE_PARAM_NAME_RE.test(name)) {\n url.searchParams.set(name, REDACTED_VALUE)\n }\n }\n\n return isRelativeUrl ? `${url.pathname}${url.search}${url.hash}` : url.href\n } catch {\n return value\n }\n}\n\nfunction getStringAttribute(value: AttributeValue | undefined) {\n return typeof value === 'string' ? value : undefined\n}\n\nfunction getNumberAttribute(value: AttributeValue | undefined) {\n return typeof value === 'number' ? value : undefined\n}\n"],"names":["clearRequestInsightsForTest","getRequestInsightsSnapshot","isRequestInsightsEnabled","recordRequestInsightFetch","recordRequestInsightSpan","subscribeRequestInsights","MAX_REQUEST_INSIGHTS","REQUEST_INSIGHTS_STORE_KEY","Symbol","for","CLIENT_COMPONENT_LOADING_SPAN_TYPE","REDACTED_VALUE","SAFE_SPAN_ATTRIBUTE_KEYS","Set","SENSITIVE_PARAM_NAME_RE","InMemoryRequestInsightsStore","recordSpan","span","requestId","insight","getOrCreateRequest","kind","requestInsightKind","htmlRequestId","route","url","startTime","timestamp","spanStartTime","sanitizeUrl","updateTiming","durationMs","attributes","status","spans","push","name","traceId","spanId","parentSpanId","sanitizeSpanAttributes","links","sanitizeSpanLinks","events","sanitizeSpanEvents","error","fetch","getFetchInsight","recordFetchForInsight","notify","recordFetch","identity","fetchStartTime","getCurrentTimestamp","sanitizeFetchInsight","getSnapshot","requests","requestOrder","map","insightKey","get","filter","request","undefined","subscribe","listener","listeners","add","delete","clear","requestTimings","length","isRequestSpan","getRequestInsightKey","requestTiming","set","endTime","requestEndTime","Math","min","max","getRequestInsightKind","fetches","trim","some","existingFetch","index","shift","Map","getRequestInsightsStore","globalStore","globalThis","getStringAttribute","method","statusCode","getNumberAttribute","cacheStatus","cacheReason","performance","timeOrigin","now","sanitized","key","value","Object","entries","has","sanitizeUrlAttribute","keys","event","link","isRelativeUrl","startsWith","URL","username","password","Array","from","searchParams","test","pathname","search","hash","href"],"mappings":";;;;;;;;;;;;;;;;;;;IAiRgBA,2BAA2B;eAA3BA;;IAVAC,0BAA0B;eAA1BA;;IA3PPC,wBAAwB;eAAxBA,mCAAwB;;IAoPjBC,yBAAyB;eAAzBA;;IAVAC,wBAAwB;eAAxBA;;IAqBAC,wBAAwB;eAAxBA;;;iCAjQT;2BAEkC;AAEzC,MAAMC,uBAAuB;AAC7B,MAAMC,6BAA6BC,OAAOC,GAAG,CAAC;AAC9C,MAAMC,qCACJ;AAWF,MAAMC,iBAAiB;AACvB,MAAMC,2BAA2B,IAAIC,IAAI;IACvC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AACD,MAAMC,0BACJ;AAEF,MAAMC;IASJC,WAAWC,IAAqB,EAAQ;YAwBpCA;QAvBF,IAAI,CAACA,KAAKC,SAAS,EAAE;YACnB;QACF;QAEA,MAAMC,UAAU,IAAI,CAACC,kBAAkB,CACrC;YACEF,WAAWD,KAAKC,SAAS;YACzBG,MAAMJ,KAAKK,kBAAkB;YAC7BC,eAAeN,KAAKM,aAAa;YACjCC,OAAOP,KAAKO,KAAK;YACjBC,KAAKR,KAAKQ,GAAG;QACf,GACAR,KAAKS,SAAS,IAAIT,KAAKU,SAAS;QAGlC,MAAMC,gBAAgBX,KAAKS,SAAS,IAAIT,KAAKU,SAAS;QACtDR,QAAQI,aAAa,GAAGN,KAAKM,aAAa,IAAIJ,QAAQI,aAAa;QACnEJ,QAAQK,KAAK,GAAGL,QAAQK,KAAK,IAAIP,KAAKO,KAAK;QAC3CL,QAAQM,GAAG,GAAGN,QAAQM,GAAG,IAAII,YAAYZ,KAAKQ,GAAG;QACjD,IAAI,CAACK,YAAY,CACfX,SACAS,eACAX,KAAKc,UAAU,EACfd,EAAAA,mBAA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Y0E,KAAyB;IAC5C,IAAI,CAACA,OAAO;QACV,OAAOA;IACT;IAEA,MAAMQ,gBAAgBR,MAAMS,UAAU,CAAC;IAEvC,IAAI;QACF,MAAMvF,MAAMsF,gBAAgB,IAAIE,IAAIV,OAAO,cAAc,IAAIU,IAAIV;QAEjE9E,IAAIyF,QAAQ,GAAG;QACfzF,IAAI0F,QAAQ,GAAG;QAEf,KAAK,MAAM/E,QAAQgF,MAAMC,IAAI,CAAC5F,IAAI6F,YAAY,CAACV,IAAI,IAAK;YACtD,IAAI9F,wBAAwByG,IAAI,CAACnF,OAAO;gBACtCX,IAAI6F,YAAY,CAAC3C,GAAG,CAACvC,MAAMzB;YAC7B;QACF;QAEA,OAAOoG,gBAAgB,GAAGtF,IAAI+F,QAAQ,GAAG/F,IAAIgG,MAAM,GAAGhG,IAAIiG,IAAI,EAAE,GAAGjG,IAAIkG,IAAI;IAC7E,EAAE,OAAM;QACN,OAAOpB;IACT;AACF;AAEA,SAASX,mBAAmBW,KAAiC;IAC3D,OAAO,OAAOA,UAAU,WAAWA,QAAQxC;AAC7C;AAEA,SAASgC,mBAAmBQ,KAAiC;IAC3D,OAAO,OAAOA,UAAU,WAAWA,QAAQxC;AAC7C","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/span-store.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { AttributeValue } from 'next/dist/compiled/@opentelemetry/api';
|
| 2 |
+
import type { RequestInsightKind } from '../../../next-devtools/shared/request-insights';
|
| 3 |
+
export type SpanStoreAttributes = Record<string, AttributeValue>;
|
| 4 |
+
export type SpanStoreLink = {
|
| 5 |
+
traceId: string;
|
| 6 |
+
spanId: string;
|
| 7 |
+
attributes?: SpanStoreAttributes;
|
| 8 |
+
};
|
| 9 |
+
export type SpanStoreEvent = {
|
| 10 |
+
name: string;
|
| 11 |
+
timestamp: number;
|
| 12 |
+
attributes?: SpanStoreAttributes;
|
| 13 |
+
};
|
| 14 |
+
export type SpanStoreRecord = {
|
| 15 |
+
name: string;
|
| 16 |
+
timestamp: number;
|
| 17 |
+
startTime?: number;
|
| 18 |
+
durationMs?: number;
|
| 19 |
+
status?: 'ok' | 'error';
|
| 20 |
+
traceId?: string;
|
| 21 |
+
spanId?: string;
|
| 22 |
+
parentSpanId?: string;
|
| 23 |
+
requestId?: string;
|
| 24 |
+
requestInsightKind?: RequestInsightKind;
|
| 25 |
+
htmlRequestId?: string;
|
| 26 |
+
route?: string;
|
| 27 |
+
url?: string;
|
| 28 |
+
attributes?: SpanStoreAttributes;
|
| 29 |
+
links?: SpanStoreLink[];
|
| 30 |
+
events?: SpanStoreEvent[];
|
| 31 |
+
error?: {
|
| 32 |
+
type?: string;
|
| 33 |
+
message?: string;
|
| 34 |
+
};
|
| 35 |
+
};
|
| 36 |
+
type SpanRecorderForTest = (span: SpanStoreRecord) => void;
|
| 37 |
+
export declare function recordSpan(record: Omit<SpanStoreRecord, 'timestamp'>): void;
|
| 38 |
+
export declare function setSpanRecorderForTest(recorder: SpanRecorderForTest | undefined): void;
|
| 39 |
+
export declare function isLocalSpanRecordingEnabled(): boolean;
|
| 40 |
+
export declare function isRequestInsightsEnabled(): boolean;
|
| 41 |
+
export {};
|
e-commerce/node_modules/next/dist/server/lib/trace/span-store.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
0 && (module.exports = {
|
| 6 |
+
isLocalSpanRecordingEnabled: null,
|
| 7 |
+
isRequestInsightsEnabled: null,
|
| 8 |
+
recordSpan: null,
|
| 9 |
+
setSpanRecorderForTest: null
|
| 10 |
+
});
|
| 11 |
+
function _export(target, all) {
|
| 12 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 13 |
+
enumerable: true,
|
| 14 |
+
get: all[name]
|
| 15 |
+
});
|
| 16 |
+
}
|
| 17 |
+
_export(exports, {
|
| 18 |
+
isLocalSpanRecordingEnabled: function() {
|
| 19 |
+
return isLocalSpanRecordingEnabled;
|
| 20 |
+
},
|
| 21 |
+
isRequestInsightsEnabled: function() {
|
| 22 |
+
return isRequestInsightsEnabled;
|
| 23 |
+
},
|
| 24 |
+
recordSpan: function() {
|
| 25 |
+
return recordSpan;
|
| 26 |
+
},
|
| 27 |
+
setSpanRecorderForTest: function() {
|
| 28 |
+
return setSpanRecorderForTest;
|
| 29 |
+
}
|
| 30 |
+
});
|
| 31 |
+
let spanRecorderForTest;
|
| 32 |
+
function recordSpan(record) {
|
| 33 |
+
if (!isLocalSpanRecordingEnabled()) {
|
| 34 |
+
return;
|
| 35 |
+
}
|
| 36 |
+
const spanRecord = {
|
| 37 |
+
timestamp: getCurrentTimestamp(),
|
| 38 |
+
...record
|
| 39 |
+
};
|
| 40 |
+
spanRecorderForTest == null ? void 0 : spanRecorderForTest(spanRecord);
|
| 41 |
+
if (isRequestInsightsEnabled() && spanRecord.requestId) {
|
| 42 |
+
const { recordRequestInsightSpan } = require('./request-insights');
|
| 43 |
+
recordRequestInsightSpan(spanRecord);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
function setSpanRecorderForTest(recorder) {
|
| 47 |
+
spanRecorderForTest = recorder;
|
| 48 |
+
}
|
| 49 |
+
function isLocalSpanRecordingEnabled() {
|
| 50 |
+
if (!process.env.__NEXT_DEV_SERVER) {
|
| 51 |
+
return false;
|
| 52 |
+
}
|
| 53 |
+
return spanRecorderForTest !== undefined || isRequestInsightsEnabled();
|
| 54 |
+
}
|
| 55 |
+
function isRequestInsightsEnabled() {
|
| 56 |
+
if (!process.env.__NEXT_DEV_SERVER) {
|
| 57 |
+
return false;
|
| 58 |
+
}
|
| 59 |
+
const value = process.env.__NEXT_REQUEST_INSIGHTS;
|
| 60 |
+
return isEnabledEnvValue(value);
|
| 61 |
+
}
|
| 62 |
+
function isEnabledEnvValue(value) {
|
| 63 |
+
return value === '1' || value === 'true' || value === true;
|
| 64 |
+
}
|
| 65 |
+
function getCurrentTimestamp() {
|
| 66 |
+
return performance.timeOrigin + performance.now();
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
//# sourceMappingURL=span-store.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/span-store.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/span-store.ts"],"sourcesContent":["import type { AttributeValue } from 'next/dist/compiled/@opentelemetry/api'\nimport type { RequestInsightKind } from '../../../next-devtools/shared/request-insights'\n\nexport type SpanStoreAttributes = Record<string, AttributeValue>\n\nexport type SpanStoreLink = {\n traceId: string\n spanId: string\n attributes?: SpanStoreAttributes\n}\n\nexport type SpanStoreEvent = {\n name: string\n timestamp: number\n attributes?: SpanStoreAttributes\n}\n\nexport type SpanStoreRecord = {\n name: string\n timestamp: number\n startTime?: number\n durationMs?: number\n status?: 'ok' | 'error'\n traceId?: string\n spanId?: string\n parentSpanId?: string\n requestId?: string\n requestInsightKind?: RequestInsightKind\n htmlRequestId?: string\n route?: string\n url?: string\n attributes?: SpanStoreAttributes\n links?: SpanStoreLink[]\n events?: SpanStoreEvent[]\n error?: {\n type?: string\n message?: string\n }\n}\n\ntype SpanRecorderForTest = (span: SpanStoreRecord) => void\n\nlet spanRecorderForTest: SpanRecorderForTest | undefined\n\nexport function recordSpan(record: Omit<SpanStoreRecord, 'timestamp'>): void {\n if (!isLocalSpanRecordingEnabled()) {\n return\n }\n\n const spanRecord: SpanStoreRecord = {\n timestamp: getCurrentTimestamp(),\n ...record,\n }\n\n spanRecorderForTest?.(spanRecord)\n\n if (isRequestInsightsEnabled() && spanRecord.requestId) {\n const { recordRequestInsightSpan } =\n require('./request-insights') as typeof import('./request-insights')\n recordRequestInsightSpan(spanRecord)\n }\n}\n\nexport function setSpanRecorderForTest(\n recorder: SpanRecorderForTest | undefined\n): void {\n spanRecorderForTest = recorder\n}\n\nexport function isLocalSpanRecordingEnabled(): boolean {\n if (!process.env.__NEXT_DEV_SERVER) {\n return false\n }\n\n return spanRecorderForTest !== undefined || isRequestInsightsEnabled()\n}\n\nexport function isRequestInsightsEnabled(): boolean {\n if (!process.env.__NEXT_DEV_SERVER) {\n return false\n }\n\n const value = process.env.__NEXT_REQUEST_INSIGHTS\n return isEnabledEnvValue(value)\n}\n\nfunction isEnabledEnvValue(value: string | undefined): boolean {\n return value === '1' || value === 'true' || (value as unknown) === true\n}\n\nfunction getCurrentTimestamp(): number {\n return performance.timeOrigin + performance.now()\n}\n"],"names":["isLocalSpanRecordingEnabled","isRequestInsightsEnabled","recordSpan","setSpanRecorderForTest","spanRecorderForTest","record","spanRecord","timestamp","getCurrentTimestamp","requestId","recordRequestInsightSpan","require","recorder","process","env","__NEXT_DEV_SERVER","undefined","value","__NEXT_REQUEST_INSIGHTS","isEnabledEnvValue","performance","timeOrigin","now"],"mappings":";;;;;;;;;;;;;;;;;IAqEgBA,2BAA2B;eAA3BA;;IAQAC,wBAAwB;eAAxBA;;IAjCAC,UAAU;eAAVA;;IAmBAC,sBAAsB;eAAtBA;;;AArBhB,IAAIC;AAEG,SAASF,WAAWG,MAA0C;IACnE,IAAI,CAACL,+BAA+B;QAClC;IACF;IAEA,MAAMM,aAA8B;QAClCC,WAAWC;QACX,GAAGH,MAAM;IACX;IAEAD,uCAAAA,oBAAsBE;IAEtB,IAAIL,8BAA8BK,WAAWG,SAAS,EAAE;QACtD,MAAM,EAAEC,wBAAwB,EAAE,GAChCC,QAAQ;QACVD,yBAAyBJ;IAC3B;AACF;AAEO,SAASH,uBACdS,QAAyC;IAEzCR,sBAAsBQ;AACxB;AAEO,SAASZ;IACd,IAAI,CAACa,QAAQC,GAAG,CAACC,iBAAiB,EAAE;QAClC,OAAO;IACT;IAEA,OAAOX,wBAAwBY,aAAaf;AAC9C;AAEO,SAASA;IACd,IAAI,CAACY,QAAQC,GAAG,CAACC,iBAAiB,EAAE;QAClC,OAAO;IACT;IAEA,MAAME,QAAQJ,QAAQC,GAAG,CAACI,uBAAuB;IACjD,OAAOC,kBAAkBF;AAC3B;AAEA,SAASE,kBAAkBF,KAAyB;IAClD,OAAOA,UAAU,OAAOA,UAAU,UAAU,AAACA,UAAsB;AACrE;AAEA,SAAST;IACP,OAAOY,YAAYC,UAAU,GAAGD,YAAYE,GAAG;AACjD","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/tracer.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { FetchEventResult } from '../../web/types';
|
| 2 |
+
import type { SpanTypes } from './constants';
|
| 3 |
+
import type { ContextAPI, Span, SpanOptions, AttributeValue, TextMapGetter } from 'next/dist/compiled/@opentelemetry/api';
|
| 4 |
+
declare const SpanStatusCode: typeof import("next/dist/compiled/@opentelemetry/api").SpanStatusCode, SpanKind: typeof import("next/dist/compiled/@opentelemetry/api").SpanKind;
|
| 5 |
+
export declare class BubbledError extends Error {
|
| 6 |
+
readonly bubble?: boolean | undefined;
|
| 7 |
+
readonly result?: FetchEventResult | undefined;
|
| 8 |
+
constructor(bubble?: boolean | undefined, result?: FetchEventResult | undefined);
|
| 9 |
+
}
|
| 10 |
+
export declare function isBubbledError(error: unknown): error is BubbledError;
|
| 11 |
+
type TracerSpanOptions = Omit<SpanOptions, 'attributes'> & {
|
| 12 |
+
endTime?: Parameters<Span['end']>[0];
|
| 13 |
+
parentSpan?: Span;
|
| 14 |
+
spanName?: string;
|
| 15 |
+
attributes?: Partial<Record<AttributeNames, AttributeValue | undefined>>;
|
| 16 |
+
hideSpan?: boolean;
|
| 17 |
+
};
|
| 18 |
+
interface NextTracer {
|
| 19 |
+
getContext(): ContextAPI;
|
| 20 |
+
/**
|
| 21 |
+
* Instruments a function by automatically creating a span activated on its
|
| 22 |
+
* scope.
|
| 23 |
+
*
|
| 24 |
+
* The span will automatically be finished when one of these conditions is
|
| 25 |
+
* met:
|
| 26 |
+
*
|
| 27 |
+
* * The function returns a promise, in which case the span will finish when
|
| 28 |
+
* the promise is resolved or rejected.
|
| 29 |
+
* * The function takes a callback as its second parameter, in which case the
|
| 30 |
+
* span will finish when that callback is called.
|
| 31 |
+
* * The function doesn't accept a callback and doesn't return a promise, in
|
| 32 |
+
* which case the span will finish at the end of the function execution.
|
| 33 |
+
*
|
| 34 |
+
*/
|
| 35 |
+
trace<T>(type: SpanTypes, fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>): Promise<T>;
|
| 36 |
+
trace<T>(type: SpanTypes, fn: (span?: Span, done?: (error?: Error) => any) => T): T;
|
| 37 |
+
trace<T>(type: SpanTypes, options: TracerSpanOptions, fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>): Promise<T>;
|
| 38 |
+
trace<T>(type: SpanTypes, options: TracerSpanOptions, fn: (span?: Span, done?: (error?: Error) => any) => T): T;
|
| 39 |
+
/**
|
| 40 |
+
* Wrap a function to automatically create a span activated on its
|
| 41 |
+
* scope when it's called.
|
| 42 |
+
*
|
| 43 |
+
* The span will automatically be finished when one of these conditions is
|
| 44 |
+
* met:
|
| 45 |
+
*
|
| 46 |
+
* * The function returns a promise, in which case the span will finish when
|
| 47 |
+
* the promise is resolved or rejected.
|
| 48 |
+
* * The function takes a callback as its last parameter, in which case the
|
| 49 |
+
* span will finish when that callback is called.
|
| 50 |
+
* * The function doesn't accept a callback and doesn't return a promise, in
|
| 51 |
+
* which case the span will finish at the end of the function execution.
|
| 52 |
+
*/
|
| 53 |
+
wrap<T = (...args: Array<any>) => any>(type: SpanTypes, fn: T): T;
|
| 54 |
+
wrap<T = (...args: Array<any>) => any>(type: SpanTypes, options: TracerSpanOptions, fn: T): T;
|
| 55 |
+
wrap<T = (...args: Array<any>) => any>(type: SpanTypes, options: (...args: any[]) => TracerSpanOptions, fn: T): T;
|
| 56 |
+
/**
|
| 57 |
+
* Starts and returns a new Span representing a logical unit of work.
|
| 58 |
+
*
|
| 59 |
+
* This method do NOT modify the current Context by default. In result, any inner span will not
|
| 60 |
+
* automatically set its parent context to the span created by this method unless manually activate
|
| 61 |
+
* context via `tracer.getContext().with`. `trace`, or `wrap` is generally recommended as it gracefully
|
| 62 |
+
* handles context activation. (ref: https://github.com/open-telemetry/opentelemetry-js/issues/1923)
|
| 63 |
+
*/
|
| 64 |
+
startSpan(type: SpanTypes): Span;
|
| 65 |
+
startSpan(type: SpanTypes, options: TracerSpanOptions): Span;
|
| 66 |
+
/**
|
| 67 |
+
* Returns currently activated span if current context is in the scope of the span.
|
| 68 |
+
* Returns undefined otherwise.
|
| 69 |
+
*/
|
| 70 |
+
getActiveScopeSpan(): Span | undefined;
|
| 71 |
+
/**
|
| 72 |
+
* Returns trace propagation data for the currently active context. The format is equal to data provided
|
| 73 |
+
* through the OpenTelemetry propagator API.
|
| 74 |
+
*/
|
| 75 |
+
getTracePropagationData(): ClientTraceDataEntry[];
|
| 76 |
+
/**
|
| 77 |
+
* Executes a function with the given span set as the active span in the context.
|
| 78 |
+
* This allows child spans created within the function to automatically parent to this span.
|
| 79 |
+
*/
|
| 80 |
+
withSpan<T>(span: Span, fn: () => T): T;
|
| 81 |
+
}
|
| 82 |
+
type NextAttributeNames = 'next.route' | 'next.page' | 'next.rsc' | 'next.segment' | 'next.span_category' | 'next.span_name' | 'next.span_type' | 'next.clientComponentLoadCount';
|
| 83 |
+
type OTELAttributeNames = `http.${string}` | `net.${string}`;
|
| 84 |
+
type AttributeNames = NextAttributeNames | OTELAttributeNames;
|
| 85 |
+
export interface ClientTraceDataEntry {
|
| 86 |
+
key: string;
|
| 87 |
+
value: string;
|
| 88 |
+
}
|
| 89 |
+
declare class NextTracerImpl implements NextTracer {
|
| 90 |
+
/**
|
| 91 |
+
* Returns an instance to the trace with configured name.
|
| 92 |
+
* Since wrap / trace can be defined in any place prior to actual trace subscriber initialization,
|
| 93 |
+
* This should be lazily evaluated.
|
| 94 |
+
*/
|
| 95 |
+
private getTracerInstance;
|
| 96 |
+
private isOpenTelemetryEnabled;
|
| 97 |
+
getContext(): ContextAPI;
|
| 98 |
+
getTracePropagationData(): ClientTraceDataEntry[];
|
| 99 |
+
getActiveScopeSpan(): Span | undefined;
|
| 100 |
+
/**
|
| 101 |
+
* Run `fn` with the active span cleared, so spans created inside become new
|
| 102 |
+
* roots (or parent to incoming propagated context). Used for in-process
|
| 103 |
+
* Node.js middleware so its span is a sibling of the request span, matching
|
| 104 |
+
* edge middleware which runs in a detached sandbox.
|
| 105 |
+
*/
|
| 106 |
+
runWithDetachedContext<T>(fn: () => T): T;
|
| 107 |
+
withPropagatedContext<T, C>(carrier: C, fn: () => T, getter?: TextMapGetter<C>, force?: boolean): T;
|
| 108 |
+
trace<T>(type: SpanTypes, fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>): Promise<T>;
|
| 109 |
+
trace<T>(type: SpanTypes, fn: (span?: Span, done?: (error?: Error) => any) => T): T;
|
| 110 |
+
trace<T>(type: SpanTypes, options: TracerSpanOptions, fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>): Promise<T>;
|
| 111 |
+
trace<T>(type: SpanTypes, options: TracerSpanOptions, fn: (span?: Span, done?: (error?: Error) => any) => T): T;
|
| 112 |
+
private runWithActiveSpan;
|
| 113 |
+
private createLocalRecordingSpan;
|
| 114 |
+
wrap<T = (...args: Array<any>) => any>(type: SpanTypes, fn: T): T;
|
| 115 |
+
wrap<T = (...args: Array<any>) => any>(type: SpanTypes, options: TracerSpanOptions, fn: T): T;
|
| 116 |
+
wrap<T = (...args: Array<any>) => any>(type: SpanTypes, options: (...args: any[]) => TracerSpanOptions, fn: T): T;
|
| 117 |
+
startSpan(type: SpanTypes): Span;
|
| 118 |
+
startSpan(type: SpanTypes, options: TracerSpanOptions): Span;
|
| 119 |
+
private getSpanContext;
|
| 120 |
+
getRootSpanAttributes(): Map<AttributeNames, AttributeValue | undefined> | undefined;
|
| 121 |
+
setRootSpanAttribute(key: AttributeNames, value: AttributeValue): void;
|
| 122 |
+
withSpan<T>(span: Span, fn: () => T): T;
|
| 123 |
+
}
|
| 124 |
+
declare const getTracer: () => NextTracerImpl;
|
| 125 |
+
export { getTracer, SpanStatusCode, SpanKind };
|
| 126 |
+
export type { NextTracer, Span, SpanOptions, ContextAPI, TracerSpanOptions };
|
e-commerce/node_modules/next/dist/server/lib/trace/tracer.js
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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er: null,
|
| 10 |
+
isBubbledError: null
|
| 11 |
+
});
|
| 12 |
+
function _export(target, all) {
|
| 13 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 14 |
+
enumerable: true,
|
| 15 |
+
get: all[name]
|
| 16 |
+
});
|
| 17 |
+
}
|
| 18 |
+
_export(exports, {
|
| 19 |
+
BubbledError: function() {
|
| 20 |
+
return BubbledError;
|
| 21 |
+
},
|
| 22 |
+
SpanKind: function() {
|
| 23 |
+
return SpanKind;
|
| 24 |
+
},
|
| 25 |
+
SpanStatusCode: function() {
|
| 26 |
+
return SpanStatusCode;
|
| 27 |
+
},
|
| 28 |
+
getTracer: function() {
|
| 29 |
+
return getTracer;
|
| 30 |
+
},
|
| 31 |
+
isBubbledError: function() {
|
| 32 |
+
return isBubbledError;
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
const _constants = require("./constants");
|
| 36 |
+
const _isthenable = require("../../../shared/lib/is-thenable");
|
| 37 |
+
const NEXT_OTEL_PERFORMANCE_PREFIX = process.env.NEXT_OTEL_PERFORMANCE_PREFIX;
|
| 38 |
+
const LOCAL_SPAN_RECORDER_KEY = Symbol.for('@next/local-span-recorder');
|
| 39 |
+
let api;
|
| 40 |
+
function getLocalSpanRecorder() {
|
| 41 |
+
if (process.env.__NEXT_DEV_SERVER) {
|
| 42 |
+
return globalThis[LOCAL_SPAN_RECORDER_KEY];
|
| 43 |
+
} else {
|
| 44 |
+
return undefined;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
// we want to allow users to use their own version of @opentelemetry/api if they
|
| 48 |
+
// want to, so we try to require it first, and if it fails we fall back to the
|
| 49 |
+
// version that is bundled with Next.js
|
| 50 |
+
// this is because @opentelemetry/api has to be synced with the version of
|
| 51 |
+
// @opentelemetry/tracing that is used, and we don't want to force users to use
|
| 52 |
+
// the version that is bundled with Next.js.
|
| 53 |
+
// the API is ~stable, so this should be fine
|
| 54 |
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
| 55 |
+
api = require('@opentelemetry/api');
|
| 56 |
+
} else {
|
| 57 |
+
try {
|
| 58 |
+
api = require('@opentelemetry/api');
|
| 59 |
+
} catch (err) {
|
| 60 |
+
api = require('next/dist/compiled/@opentelemetry/api');
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
const { context, propagation, trace, SpanStatusCode, SpanKind, ROOT_CONTEXT } = api;
|
| 64 |
+
class BubbledError extends Error {
|
| 65 |
+
constructor(bubble, result){
|
| 66 |
+
super(), this.bubble = bubble, this.result = result;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
function isBubbledError(error) {
|
| 70 |
+
if (typeof error !== 'object' || error === null) return false;
|
| 71 |
+
return error instanceof BubbledError;
|
| 72 |
+
}
|
| 73 |
+
const closeSpanWithError = (span, error, endTime)=>{
|
| 74 |
+
if (isBubbledError(error) && error.bubble) {
|
| 75 |
+
span.setAttribute('next.bubble', true);
|
| 76 |
+
} else {
|
| 77 |
+
if (error) {
|
| 78 |
+
span.recordException(error);
|
| 79 |
+
span.setAttribute('error.type', error.name);
|
| 80 |
+
}
|
| 81 |
+
span.setStatus({
|
| 82 |
+
code: SpanStatusCode.ERROR,
|
| 83 |
+
message: error == null ? void 0 : error.message
|
| 84 |
+
});
|
| 85 |
+
}
|
| 86 |
+
span.end(endTime);
|
| 87 |
+
};
|
| 88 |
+
/** we use this map to propagate attributes from nested spans to the top span */ const rootSpanAttributesStore = new Map();
|
| 89 |
+
const rootSpanIdKey = api.createContextKey('next.rootSpanId');
|
| 90 |
+
let lastSpanId = 0;
|
| 91 |
+
const getSpanId = ()=>lastSpanId++;
|
| 92 |
+
const clientTraceDataSetter = {
|
| 93 |
+
set (carrier, key, value) {
|
| 94 |
+
carrier.push({
|
| 95 |
+
key,
|
| 96 |
+
value
|
| 97 |
+
});
|
| 98 |
+
}
|
| 99 |
+
};
|
| 100 |
+
class NextTracerImpl {
|
| 101 |
+
/**
|
| 102 |
+
* Returns an instance to the trace with configured name.
|
| 103 |
+
* Since wrap / trace can be defined in any place prior to actual trace subscriber initialization,
|
| 104 |
+
* This should be lazily evaluated.
|
| 105 |
+
*/ getTracerInstance() {
|
| 106 |
+
return trace.getTracer('next.js', "16.4.0");
|
| 107 |
+
}
|
| 108 |
+
isOpenTelemetryEnabled() {
|
| 109 |
+
var _tracerProvider_getDelegate_constructor, _tracerProvider_getDelegate;
|
| 110 |
+
const activeSpan = trace.getSpan(context.active());
|
| 111 |
+
if (activeSpan == null ? void 0 : activeSpan.isRecording()) {
|
| 112 |
+
return true;
|
| 113 |
+
}
|
| 114 |
+
const tracerProvider = trace.getTracerProvider();
|
| 115 |
+
if (!('getDelegate' in tracerProvider)) {
|
| 116 |
+
return true;
|
| 117 |
+
}
|
| 118 |
+
return (tracerProvider.getDelegate == null ? void 0 : (_tracerProvider_getDelegate = tracerProvider.getDelegate.call(tracerProvider)) == null ? void 0 : (_tracerProvider_getDelegate_constructor = _tracerProvider_getDelegate.constructor) == null ? void 0 : _tracerProvider_getDelegate_constructor.name) !== 'NoopTracerProvider';
|
| 119 |
+
}
|
| 120 |
+
getContext() {
|
| 121 |
+
return context;
|
| 122 |
+
}
|
| 123 |
+
getTracePropagationData() {
|
| 124 |
+
const activeContext = context.active();
|
| 125 |
+
const entries = [];
|
| 126 |
+
propagation.inject(activeContext, entries, clientTraceDataSetter);
|
| 127 |
+
return entries;
|
| 128 |
+
}
|
| 129 |
+
getActiveScopeSpan() {
|
| 130 |
+
const localSpanRecorder = getLocalSpanRecorder();
|
| 131 |
+
const activeLocalSpan = localSpanRecorder == null ? void 0 : localSpanRecorder.getActiveLocalSpan();
|
| 132 |
+
if (activeLocalSpan && (localSpanRecorder == null ? void 0 : localSpanRecorder.isOpenTelemetryIsolatedSpan(activeLocalSpan))) {
|
| 133 |
+
return activeLocalSpan;
|
| 134 |
+
}
|
| 135 |
+
const activeSpan = trace.getSpan(context.active());
|
| 136 |
+
if (activeSpan || !process.env.__NEXT_DEV_SERVER) {
|
| 137 |
+
return activeSpan;
|
| 138 |
+
}
|
| 139 |
+
return activeLocalSpan;
|
| 140 |
+
}
|
| 141 |
+
/**
|
| 142 |
+
* Run `fn` with the active span cleared, so spans created inside become new
|
| 143 |
+
* roots (or parent to incoming propagated context). Used for in-process
|
| 144 |
+
* Node.js middleware so its span is a sibling of the request span, matching
|
| 145 |
+
* edge middleware which runs in a detached sandbox.
|
| 146 |
+
*/ runWithDetachedContext(fn) {
|
| 147 |
+
if (!NEXT_OTEL_PERFORMANCE_PREFIX && !this.isOpenTelemetryEnabled()) {
|
| 148 |
+
return fn();
|
| 149 |
+
}
|
| 150 |
+
return context.with(ROOT_CONTEXT, fn);
|
| 151 |
+
}
|
| 152 |
+
withPropagatedContext(carrier, fn, getter, force = false) {
|
| 153 |
+
const activeContext = context.active();
|
| 154 |
+
if (!NEXT_OTEL_PERFORMANCE_PREFIX && !this.isOpenTelemetryEnabled() && !trace.getSpanContext(activeContext)) {
|
| 155 |
+
return fn();
|
| 156 |
+
}
|
| 157 |
+
if (force) {
|
| 158 |
+
const remoteContext = propagation.extract(ROOT_CONTEXT, carrier, getter);
|
| 159 |
+
if (trace.getSpanContext(remoteContext)) {
|
| 160 |
+
return context.with(remoteContext, fn);
|
| 161 |
+
}
|
| 162 |
+
// Preserve the current active span while still merging any extracted
|
| 163 |
+
// baggage/context values from the carrier.
|
| 164 |
+
const mergedContext = propagation.extract(activeContext, carrier, getter);
|
| 165 |
+
return context.with(mergedContext, fn);
|
| 166 |
+
}
|
| 167 |
+
if (trace.getSpanContext(activeContext)) {
|
| 168 |
+
// Active span is already set, too late to propagate.
|
| 169 |
+
return fn();
|
| 170 |
+
}
|
| 171 |
+
const remoteContext = propagation.extract(activeContext, carrier, getter);
|
| 172 |
+
return context.with(remoteContext, fn);
|
| 173 |
+
}
|
| 174 |
+
trace(...args) {
|
| 175 |
+
const [type, fnOrOptions, fnOrEmpty] = args;
|
| 176 |
+
const tracingEnabled = Boolean(NEXT_OTEL_PERFORMANCE_PREFIX) || this.isOpenTelemetryEnabled();
|
| 177 |
+
const localSpanRecorder = getLocalSpanRecorder();
|
| 178 |
+
const localSpanRecordingEnabled = (localSpanRecorder == null ? void 0 : localSpanRecorder.isLocalSpanRecordingEnabled()) ?? false;
|
| 179 |
+
if (!tracingEnabled && !localSpanRecordingEnabled) {
|
| 180 |
+
return typeof fnOrOptions === 'function' ? fnOrOptions() : fnOrEmpty();
|
| 181 |
+
}
|
| 182 |
+
// coerce options form overload
|
| 183 |
+
const { fn, options } = typeof fnOrOptions === 'function' ? {
|
| 184 |
+
fn: fnOrOptions,
|
| 185 |
+
options: {}
|
| 186 |
+
} : {
|
| 187 |
+
fn: fnOrEmpty,
|
| 188 |
+
options: {
|
| 189 |
+
...fnOrOptions
|
| 190 |
+
}
|
| 191 |
+
};
|
| 192 |
+
const spanName = options.spanName ?? type;
|
| 193 |
+
const parentSpan = options.parentSpan ?? this.getActiveScopeSpan();
|
| 194 |
+
const isolatedParentSpan = parentSpan && (localSpanRecorder == null ? void 0 : localSpanRecorder.isOpenTelemetryIsolatedSpan(parentSpan)) ? parentSpan : undefined;
|
| 195 |
+
const shouldDelegateSpan = !isolatedParentSpan && (_constants.NextVanillaSpanAllowlist.has(type) || process.env.NEXT_OTEL_VERBOSE === '1');
|
| 196 |
+
const shouldTraceSpan = shouldDelegateSpan || ((localSpanRecorder == null ? void 0 : localSpanRecorder.isRequestInsightsEnabled()) ?? false);
|
| 197 |
+
if (!shouldTraceSpan || options.hideSpan) {
|
| 198 |
+
return fn();
|
| 199 |
+
}
|
| 200 |
+
// Trying to get active scoped span to assign parent. If option specifies parent span manually, will try to use it.
|
| 201 |
+
let spanContext = isolatedParentSpan ? context.active() : this.getSpanContext(parentSpan);
|
| 202 |
+
if (!spanContext) {
|
| 203 |
+
spanContext = (context == null ? void 0 : context.active()) ?? ROOT_CONTEXT;
|
| 204 |
+
}
|
| 205 |
+
// Check if there's already a root span in the store for this trace
|
| 206 |
+
// We are intentionally not checking whether there is an active context
|
| 207 |
+
// from outside of nextjs to ensure that we can provide the same level
|
| 208 |
+
// of telemetry when using a custom server
|
| 209 |
+
const existingRootSpanId = spanContext.getValue(rootSpanIdKey);
|
| 210 |
+
const isRootSpan = typeof existingRootSpanId !== 'number' || !rootSpanAttributesStore.has(existingRootSpanId);
|
| 211 |
+
const spanId = getSpanId();
|
| 212 |
+
options.attributes = {
|
| 213 |
+
'next.span_category': 'nextjs',
|
| 214 |
+
'next.span_name': spanName,
|
| 215 |
+
'next.span_type': type,
|
| 216 |
+
...options.attributes
|
| 217 |
+
};
|
| 218 |
+
return context.with(spanContext.setValue(rootSpanIdKey, spanId), ()=>this.runWithActiveSpan(spanName, options, spanContext, tracingEnabled && shouldDelegateSpan, localSpanRecordingEnabled, isolatedParentSpan, (span)=>{
|
| 219 |
+
let startTime;
|
| 220 |
+
if (NEXT_OTEL_PERFORMANCE_PREFIX && type && _constants.LogSpanAllowList.has(type)) {
|
| 221 |
+
startTime = 'performance' in globalThis && 'measure' in performance ? globalThis.performance.now() : undefined;
|
| 222 |
+
}
|
| 223 |
+
let cleanedUp = false;
|
| 224 |
+
const onCleanup = ()=>{
|
| 225 |
+
if (cleanedUp) return;
|
| 226 |
+
cleanedUp = true;
|
| 227 |
+
rootSpanAttributesStore.delete(spanId);
|
| 228 |
+
if (startTime) {
|
| 229 |
+
performance.measure(`${NEXT_OTEL_PERFORMANCE_PREFIX}:next-${(type.split('.').pop() || '').replace(/[A-Z]/g, (match)=>'-' + match.toLowerCase())}`, {
|
| 230 |
+
start: startTime,
|
| 231 |
+
end: performance.now()
|
| 232 |
+
});
|
| 233 |
+
}
|
| 234 |
+
};
|
| 235 |
+
if (isRootSpan) {
|
| 236 |
+
rootSpanAttributesStore.set(spanId, new Map(Object.entries(options.attributes ?? {})));
|
| 237 |
+
}
|
| 238 |
+
if (fn.length > 1) {
|
| 239 |
+
try {
|
| 240 |
+
return fn(span, (err)=>{
|
| 241 |
+
if (err) {
|
| 242 |
+
closeSpanWithError(span, err, options.endTime);
|
| 243 |
+
} else {
|
| 244 |
+
span.end(options.endTime);
|
| 245 |
+
}
|
| 246 |
+
});
|
| 247 |
+
} catch (err) {
|
| 248 |
+
closeSpanWithError(span, err, options.endTime);
|
| 249 |
+
throw err;
|
| 250 |
+
} finally{
|
| 251 |
+
onCleanup();
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
try {
|
| 255 |
+
const result = fn(span);
|
| 256 |
+
if ((0, _isthenable.isThenable)(result)) {
|
| 257 |
+
// If there's error make sure it throws
|
| 258 |
+
return result.then((res)=>{
|
| 259 |
+
span.end(options.endTime);
|
| 260 |
+
// Need to pass down the promise result,
|
| 261 |
+
// it could be react stream response with error { error, stream }
|
| 262 |
+
return res;
|
| 263 |
+
}).catch((err)=>{
|
| 264 |
+
closeSpanWithError(span, err, options.endTime);
|
| 265 |
+
throw err;
|
| 266 |
+
}).finally(onCleanup);
|
| 267 |
+
} else {
|
| 268 |
+
span.end(options.endTime);
|
| 269 |
+
onCleanup();
|
| 270 |
+
}
|
| 271 |
+
return result;
|
| 272 |
+
} catch (err) {
|
| 273 |
+
closeSpanWithError(span, err, options.endTime);
|
| 274 |
+
onCleanup();
|
| 275 |
+
throw err;
|
| 276 |
+
}
|
| 277 |
+
}));
|
| 278 |
+
}
|
| 279 |
+
runWithActiveSpan(spanName, options, parentContext, tracingEnabled, localSpanRecordingEnabled, isolatedParentSpan, fn) {
|
| 280 |
+
if (tracingEnabled) {
|
| 281 |
+
return this.getTracerInstance().startActiveSpan(spanName, options, (span)=>fn(localSpanRecordingEnabled ? this.createLocalRecordingSpan(spanName, options, parentContext, span, isolatedParentSpan) : span));
|
| 282 |
+
}
|
| 283 |
+
const span = this.createLocalRecordingSpan(spanName, options, parentContext, undefined, isolatedParentSpan);
|
| 284 |
+
const localSpanRecorder = getLocalSpanRecorder();
|
| 285 |
+
return localSpanRecorder.withLocalSpan(span, ()=>localSpanRecorder.isOpenTelemetryIsolatedSpan(span) ? fn(span) : context.with(trace.setSpan(context.active(), span), fn, undefined, span));
|
| 286 |
+
}
|
| 287 |
+
createLocalRecordingSpan(name, options, parentContext, delegateSpan, isolatedParentSpan) {
|
| 288 |
+
const parentSpanContext = (isolatedParentSpan == null ? void 0 : isolatedParentSpan.spanContext()) ?? trace.getSpanContext(parentContext);
|
| 289 |
+
const delegateSpanContext = delegateSpan == null ? void 0 : delegateSpan.spanContext();
|
| 290 |
+
return getLocalSpanRecorder().createLocalSpan({
|
| 291 |
+
name,
|
| 292 |
+
attributes: options.attributes,
|
| 293 |
+
links: options.links,
|
| 294 |
+
startTime: options.startTime,
|
| 295 |
+
delegateSpan,
|
| 296 |
+
traceId: (delegateSpanContext == null ? void 0 : delegateSpanContext.traceId) ?? (parentSpanContext == null ? void 0 : parentSpanContext.traceId),
|
| 297 |
+
spanId: delegateSpanContext == null ? void 0 : delegateSpanContext.spanId,
|
| 298 |
+
parentSpanId: parentSpanContext == null ? void 0 : parentSpanContext.spanId,
|
| 299 |
+
isolateOpenTelemetry: isolatedParentSpan !== undefined
|
| 300 |
+
});
|
| 301 |
+
}
|
| 302 |
+
wrap(...args) {
|
| 303 |
+
const tracer = this;
|
| 304 |
+
const [name, options, fn] = args.length === 3 ? args : [
|
| 305 |
+
args[0],
|
| 306 |
+
{},
|
| 307 |
+
args[1]
|
| 308 |
+
];
|
| 309 |
+
if (!_constants.NextVanillaSpanAllowlist.has(name) && process.env.NEXT_OTEL_VERBOSE !== '1' && !process.env.__NEXT_DEV_SERVER) {
|
| 310 |
+
return fn;
|
| 311 |
+
}
|
| 312 |
+
return function() {
|
| 313 |
+
let optionsObj = options;
|
| 314 |
+
if (typeof optionsObj === 'function' && typeof fn === 'function') {
|
| 315 |
+
optionsObj = optionsObj.apply(this, arguments);
|
| 316 |
+
}
|
| 317 |
+
const lastArgId = arguments.length - 1;
|
| 318 |
+
const cb = arguments[lastArgId];
|
| 319 |
+
if (typeof cb === 'function') {
|
| 320 |
+
const scopeBoundCb = tracer.getContext().bind(context.active(), cb);
|
| 321 |
+
return tracer.trace(name, optionsObj, (_span, done)=>{
|
| 322 |
+
arguments[lastArgId] = function(err) {
|
| 323 |
+
done == null ? void 0 : done(err);
|
| 324 |
+
return scopeBoundCb.apply(this, arguments);
|
| 325 |
+
};
|
| 326 |
+
return fn.apply(this, arguments);
|
| 327 |
+
});
|
| 328 |
+
} else {
|
| 329 |
+
return tracer.trace(name, optionsObj, ()=>fn.apply(this, arguments));
|
| 330 |
+
}
|
| 331 |
+
};
|
| 332 |
+
}
|
| 333 |
+
startSpan(...args) {
|
| 334 |
+
const [type, passedOptions] = args;
|
| 335 |
+
const options = passedOptions ? {
|
| 336 |
+
...passedOptions,
|
| 337 |
+
attributes: {
|
| 338 |
+
'next.span_category': 'nextjs',
|
| 339 |
+
...passedOptions.attributes
|
| 340 |
+
}
|
| 341 |
+
} : {
|
| 342 |
+
attributes: {
|
| 343 |
+
'next.span_category': 'nextjs'
|
| 344 |
+
}
|
| 345 |
+
};
|
| 346 |
+
const localSpanRecorder = getLocalSpanRecorder();
|
| 347 |
+
const parentSpan = options.parentSpan ?? this.getActiveScopeSpan();
|
| 348 |
+
const isolatedParentSpan = parentSpan && (localSpanRecorder == null ? void 0 : localSpanRecorder.isOpenTelemetryIsolatedSpan(parentSpan)) ? parentSpan : undefined;
|
| 349 |
+
const parentContext = (isolatedParentSpan ? undefined : this.getSpanContext(parentSpan)) ?? context.active();
|
| 350 |
+
const localSpanRecordingEnabled = (localSpanRecorder == null ? void 0 : localSpanRecorder.isLocalSpanRecordingEnabled()) ?? false;
|
| 351 |
+
if (!localSpanRecordingEnabled) {
|
| 352 |
+
return this.getTracerInstance().startSpan(type, options, parentContext);
|
| 353 |
+
}
|
| 354 |
+
const delegateSpan = !isolatedParentSpan && this.isOpenTelemetryEnabled() ? this.getTracerInstance().startSpan(type, options, parentContext) : undefined;
|
| 355 |
+
return this.createLocalRecordingSpan(type, options, parentContext, delegateSpan, isolatedParentSpan);
|
| 356 |
+
}
|
| 357 |
+
getSpanContext(parentSpan) {
|
| 358 |
+
const spanContext = parentSpan ? trace.setSpan(context.active(), parentSpan) : undefined;
|
| 359 |
+
return spanContext;
|
| 360 |
+
}
|
| 361 |
+
getRootSpanAttributes() {
|
| 362 |
+
const spanId = context.active().getValue(rootSpanIdKey);
|
| 363 |
+
return rootSpanAttributesStore.get(spanId);
|
| 364 |
+
}
|
| 365 |
+
setRootSpanAttribute(key, value) {
|
| 366 |
+
const spanId = context.active().getValue(rootSpanIdKey);
|
| 367 |
+
const attributes = rootSpanAttributesStore.get(spanId);
|
| 368 |
+
if (attributes && !attributes.has(key)) {
|
| 369 |
+
attributes.set(key, value);
|
| 370 |
+
}
|
| 371 |
+
if (process.env.__NEXT_DEV_SERVER) {
|
| 372 |
+
var _getLocalSpanRecorder;
|
| 373 |
+
const localSpan = (_getLocalSpanRecorder = getLocalSpanRecorder()) == null ? void 0 : _getLocalSpanRecorder.getActiveLocalSpan();
|
| 374 |
+
if (localSpan) {
|
| 375 |
+
localSpan.setAttribute(key, value);
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
withSpan(span, fn) {
|
| 380 |
+
const recorder = getLocalSpanRecorder();
|
| 381 |
+
if (recorder == null ? void 0 : recorder.isLocalRecordingSpan(span)) {
|
| 382 |
+
return recorder.withLocalSpan(span, ()=>recorder.isOpenTelemetryIsolatedSpan(span) ? fn() : context.with(trace.setSpan(context.active(), span), fn));
|
| 383 |
+
}
|
| 384 |
+
return context.with(trace.setSpan(context.active(), span), fn);
|
| 385 |
+
}
|
| 386 |
+
}
|
| 387 |
+
const getTracer = (()=>{
|
| 388 |
+
const tracer = new NextTracerImpl();
|
| 389 |
+
return ()=>tracer;
|
| 390 |
+
})();
|
| 391 |
+
|
| 392 |
+
//# sourceMappingURL=tracer.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/tracer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/tracer.ts"],"sourcesContent":["import type { FetchEventResult } from '../../web/types'\nimport type { TextMapSetter } from '@opentelemetry/api'\nimport type { SpanTypes } from './constants'\nimport type { LocalSpanRecorder } from './local-span-recorder'\nimport { LogSpanAllowList, NextVanillaSpanAllowlist } from './constants'\n\nimport type {\n Context,\n ContextAPI,\n Span,\n SpanOptions,\n Tracer,\n AttributeValue,\n TextMapGetter,\n} from 'next/dist/compiled/@opentelemetry/api'\nimport { isThenable } from '../../../shared/lib/is-thenable'\n\nconst NEXT_OTEL_PERFORMANCE_PREFIX = process.env.NEXT_OTEL_PERFORMANCE_PREFIX\nconst LOCAL_SPAN_RECORDER_KEY = Symbol.for('@next/local-span-recorder')\n\ntype GlobalWithLocalSpanRecorder = typeof globalThis & {\n [LOCAL_SPAN_RECORDER_KEY]?: LocalSpanRecorder\n}\n\nlet api: typeof import('next/dist/compiled/@opentelemetry/api')\n\nfunction getLocalSpanRecorder() {\n if (process.env.__NEXT_DEV_SERVER) {\n return (globalThis as GlobalWithLocalSpanRecorder)[LOCAL_SPAN_RECORDER_KEY]\n } else {\n return undefined\n }\n}\n\n// we want to allow users to use their own version of @opentelemetry/api if they\n// want to, so we try to require it first, and if it fails we fall back to the\n// version that is bundled with Next.js\n// this is because @opentelemetry/api has to be synced with the version of\n// @opentelemetry/tracing that is used, and we don't want to force users to use\n// the version that is bundled with Next.js.\n// the API is ~stable, so this should be fine\nif (process.env.NEXT_RUNTIME === 'edge') {\n api = require('@opentelemetry/api') as typeof import('@opentelemetry/api')\n} else {\n try {\n api = require('@opentelemetry/api') as typeof import('@opentelemetry/api')\n } catch (err) {\n api =\n require('next/dist/compiled/@opentelemetry/api') as typeof import('next/dist/compiled/@opentelemetry/api')\n }\n}\n\nconst { context, propagation, trace, SpanStatusCode, SpanKind, ROOT_CONTEXT } =\n api\n\nexport class BubbledError extends Error {\n constructor(\n public readonly bubble?: boolean,\n public readonly result?: FetchEventResult\n ) {\n super()\n }\n}\n\nexport function isBubbledError(error: unknown): error is BubbledError {\n if (typeof error !== 'object' || error === null) return false\n return error instanceof BubbledError\n}\n\nconst closeSpanWithError = (\n span: Span,\n error?: Error,\n endTime?: Parameters<Span['end']>[0]\n) => {\n if (isBubbledError(error) && error.bubble) {\n span.setAttribute('next.bubble', true)\n } else {\n if (error) {\n span.recordException(error)\n span.setAttribute('error.type', error.name)\n }\n span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message })\n }\n span.end(endTime)\n}\n\ntype TracerSpanOptions = Omit<SpanOptions, 'attributes'> & {\n endTime?: Parameters<Span['end']>[0]\n parentSpan?: Span\n spanName?: string\n attributes?: Partial<Record<AttributeNames, AttributeValue | undefined>>\n hideSpan?: boolean\n}\n\ninterface NextTracer {\n getContext(): ContextAPI\n\n /**\n * Instruments a function by automatically creating a span activated on its\n * scope.\n *\n * The span will automatically be finished when one of these conditions is\n * met:\n *\n * * The function returns a promise, in which case the span will finish when\n * the promise is resolved or rejected.\n * * The function takes a callback as its second parameter, in which case the\n * span will finish when that callback is called.\n * * The function doesn't accept a callback and doesn't return a promise, in\n * which case the span will finish at the end of the function execution.\n *\n */\n trace<T>(\n type: SpanTypes,\n fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>\n ): Promise<T>\n trace<T>(\n type: SpanTypes,\n fn: (span?: Span, done?: (error?: Error) => any) => T\n ): T\n trace<T>(\n type: SpanTypes,\n options: TracerSpanOptions,\n fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>\n ): Promise<T>\n trace<T>(\n type: SpanTypes,\n options: TracerSpanOptions,\n fn: (span?: Span, done?: (error?: Error) => any) => T\n ): T\n\n /**\n * Wrap a function to automatically create a span activated on its\n * scope when it's called.\n *\n * The span will automatically be finished when one of these conditions is\n * met:\n *\n * * The function returns a promise, in which case the span will finish when\n * the promise is resolved or rejected.\n * * The function takes a callback as its last parameter, in which case the\n * span will finish when that callback is called.\n * * The function doesn't accept a callback and doesn't return a promise, in\n * which case the span will finish at the end of the function execution.\n */\n wrap<T = (...args: Array<any>) => any>(type: SpanTypes, fn: T): T\n wrap<T = (...args: Array<any>) => any>(\n type: SpanTypes,\n options: TracerSpanOptions,\n fn: T\n ): T\n wrap<T = (...args: Array<any>) => any>(\n type: SpanTypes,\n options: (...args: any[]) => TracerSpanOptions,\n fn: T\n ): T\n\n /**\n * Starts and returns a new Span representing a logical unit of work.\n *\n * This method do NOT modify the current Context by default. In result, any inner span will not\n * automatically set its parent context to the span created by this method unless manually activate\n * context via `tracer.getContext().with`. `trace`, or `wrap` is generally recommended as it gracefully\n * handles context activation. (ref: https://github.com/open-telemetry/opentelemetry-js/issues/1923)\n */\n startSpan(type: SpanTypes): Span\n startSpan(type: SpanTypes, options: TracerSpanOptions): Span\n\n /**\n * Returns currently activated span if current context is in the scope of the span.\n * Returns undefined otherwise.\n */\n getActiveScopeSpan(): Span | undefined\n\n /**\n * Returns trace propagation data for the currently active context. The format is equal to data provided\n * through the OpenTelemetry propagator API.\n */\n getTracePropagationData(): ClientTraceDataEntry[]\n\n /**\n * Executes a function with the given span set as the active span in the context.\n * This allows child spans created within the function to automatically parent to this span.\n */\n withSpan<T>(span: Span, fn: () => T): T\n}\n\ntype NextAttributeNames =\n | 'next.route'\n | 'next.page'\n | 'next.rsc'\n | 'next.segment'\n | 'next.span_category'\n | 'next.span_name'\n | 'next.span_type'\n | 'next.clientComponentLoadCount'\ntype OTELAttributeNames = `http.${string}` | `net.${string}`\ntype AttributeNames = NextAttributeNames | OTELAttributeNames\n\n/** we use this map to propagate attributes from nested spans to the top span */\nconst rootSpanAttributesStore = new Map<\n number,\n Map<AttributeNames, AttributeValue | undefined>\n>()\nconst rootSpanIdKey = api.createContextKey('next.rootSpanId')\nlet lastSpanId = 0\nconst getSpanId = () => lastSpanId++\n\nexport interface ClientTraceDataEntry {\n key: string\n value: string\n}\n\nconst clientTraceDataSetter: TextMapSetter<ClientTraceDataEntry[]> = {\n set(carrier, key, value) {\n carrier.push({\n key,\n value,\n })\n },\n}\n\nclass NextTracerImpl implements NextTracer {\n /**\n * Returns an instance to the trace with configured name.\n * Since wrap / trace can be defined in any place prior to actual trace subscriber initialization,\n * This should be lazily evaluated.\n */\n private getTracerInstance(): Tracer {\n return trace.getTracer('next.js', process.env.__NEXT_VERSION)\n }\n\n private isOpenTelemetryEnabled(): boolean {\n const activeSpan = trace.getSpan(context.active())\n if (activeSpan?.isRecording()) {\n return true\n }\n\n const tracerProvider = trace.getTracerProvider() as {\n getDelegate?: () => { constructor?: { name?: string } } | undefined\n }\n\n if (!('getDelegate' in tracerProvider)) {\n return true\n }\n\n return (\n tracerProvider.getDelegate?.()?.constructor?.name !== 'NoopTracerProvider'\n )\n }\n\n public getContext(): ContextAPI {\n return context\n }\n\n public getTracePropagationData(): ClientTraceDataEntry[] {\n const activeContext = context.active()\n const entries: ClientTraceDataEntry[] = []\n propagation.inject(activeContext, entries, clientTraceDataSetter)\n return entries\n }\n\n public getActiveScopeSpan(): Span | undefined {\n const localSpanRecorder = getLocalSpanRecorder()\n const activeLocalSpan = localSpanRecorder?.getActiveLocalSpan()\n if (\n activeLocalSpan &&\n localSpanRecorder?.isOpenTelemetryIsolatedSpan(activeLocalSpan)\n ) {\n return activeLocalSpan\n }\n\n const activeSpan = trace.getSpan(context.active())\n if (activeSpan || !process.env.__NEXT_DEV_SERVER) {\n return activeSpan\n }\n return activeLocalSpan\n }\n\n /**\n * Run `fn` with the active span cleared, so spans created inside become new\n * roots (or parent to incoming propagated context). Used for in-process\n * Node.js middleware so its span is a sibling of the request span, matching\n * edge middleware which runs in a detached sandbox.\n */\n public runWithDetachedContext<T>(fn: () => T): T {\n if (!NEXT_OTEL_PERFORMANCE_PREFIX && !this.isOpenTelemetryEnabled()) {\n return fn()\n }\n return context.with(ROOT_CONTEXT, fn)\n }\n\n public withPropagatedContext<T, C>(\n carrier: C,\n fn: () => T,\n getter?: TextMapGetter<C>,\n force = false\n ): T {\n const activeContext = context.active()\n\n if (\n !NEXT_OTEL_PERFORMANCE_PREFIX &&\n !this.isOpenTelemetryEnabled() &&\n !trace.getSpanContext(activeContext)\n ) {\n return fn()\n }\n\n if (force) {\n const remoteContext = propagation.extract(ROOT_CONTEXT, carrier, getter)\n\n if (trace.getSpanContext(remoteContext)) {\n return context.with(remoteContext, fn)\n }\n\n // Preserve the current active span while still merging any extracted\n // baggage/context values from the carrier.\n const mergedContext = propagation.extract(activeContext, carrier, getter)\n return context.with(mergedContext, fn)\n }\n\n if (trace.getSpanContext(activeContext)) {\n // Active span is already set, too late to propagate.\n return fn()\n }\n\n const remoteContext = propagation.extract(activeContext, carrier, getter)\n return context.with(remoteContext, fn)\n }\n\n // Trace, wrap implementation is inspired by datadog trace implementation\n // (https://datadoghq.dev/dd-trace-js/interfaces/tracer.html#trace).\n public trace<T>(\n type: SpanTypes,\n fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>\n ): Promise<T>\n public trace<T>(\n type: SpanTypes,\n fn: (span?: Span, done?: (error?: Error) => any) => T\n ): T\n public trace<T>(\n type: SpanTypes,\n options: TracerSpanOptions,\n fn: (span?: Span, done?: (error?: Error) => any) => Promise<T>\n ): Promise<T>\n public trace<T>(\n type: SpanTypes,\n options: TracerSpanOptions,\n fn: (span?: Span, done?: (error?: Error) => any) => T\n ): T\n public trace<T>(...args: Array<any>) {\n const [type, fnOrOptions, fnOrEmpty] = args\n const tracingEnabled =\n Boolean(NEXT_OTEL_PERFORMANCE_PREFIX) || this.isOpenTelemetryEnabled()\n const localSpanRecorder = getLocalSpanRecorder()\n const localSpanRecordingEnabled =\n localSpanRecorder?.isLocalSpanRecordingEnabled() ?? false\n\n if (!tracingEnabled && !localSpanRecordingEnabled) {\n return typeof fnOrOptions === 'function' ? fnOrOptions() : fnOrEmpty()\n }\n\n // coerce options form overload\n const {\n fn,\n options,\n }: {\n fn: (span?: Span, done?: (error?: Error) => any) => T | Promise<T>\n options: TracerSpanOptions\n } =\n typeof fnOrOptions === 'function'\n ? {\n fn: fnOrOptions,\n options: {},\n }\n : {\n fn: fnOrEmpty,\n options: { ...fnOrOptions },\n }\n\n const spanName = options.spanName ?? type\n\n const parentSpan = options.parentSpan ?? this.getActiveScopeSpan()\n const isolatedParentSpan =\n parentSpan && localSpanRecorder?.isOpenTelemetryIsolatedSpan(parentSpan)\n ? parentSpan\n : undefined\n const shouldDelegateSpan =\n !isolatedParentSpan &&\n (NextVanillaSpanAllowlist.has(type) ||\n process.env.NEXT_OTEL_VERBOSE === '1')\n const shouldTraceSpan =\n shouldDelegateSpan ||\n (localSpanRecorder?.isRequestInsightsEnabled() ?? false)\n\n if (!shouldTraceSpan || options.hideSpan) {\n return fn()\n }\n\n // Trying to get active scoped span to assign parent. If option specifies parent span manually, will try to use it.\n let spanContext = isolatedParentSpan\n ? context.active()\n : this.getSpanContext(parentSpan)\n\n if (!spanContext) {\n spanContext = context?.active() ?? ROOT_CONTEXT\n }\n // Check if there's already a root span in the store for this trace\n // We are intentionally not checking whether there is an active context\n // from outside of nextjs to ensure that we can provide the same level\n // of telemetry when using a custom server\n const existingRootSpanId = spanContext.getValue(rootSpanIdKey)\n const isRootSpan =\n typeof existingRootSpanId !== 'number' ||\n !rootSpanAttributesStore.has(existingRootSpanId)\n\n const spanId = getSpanId()\n\n options.attributes = {\n 'next.span_category': 'nextjs',\n 'next.span_name': spanName,\n 'next.span_type': type,\n ...options.attributes,\n }\n\n return context.with(spanContext.setValue(rootSpanIdKey, spanId), () =>\n this.runWithActiveSpan(\n spanName,\n options,\n spanContext,\n tracingEnabled && shouldDelegateSpan,\n localSpanRecordingEnabled,\n isolatedParentSpan,\n (span: Span) => {\n let startTime: number | undefined\n if (\n NEXT_OTEL_PERFORMANCE_PREFIX &&\n type &&\n LogSpanAllowList.has(type)\n ) {\n startTime =\n 'performance' in globalThis && 'measure' in performance\n ? globalThis.performance.now()\n : undefined\n }\n\n let cleanedUp = false\n const onCleanup = () => {\n if (cleanedUp) return\n cleanedUp = true\n rootSpanAttributesStore.delete(spanId)\n if (startTime) {\n performance.measure(\n `${NEXT_OTEL_PERFORMANCE_PREFIX}:next-${(\n type.split('.').pop() || ''\n ).replace(\n /[A-Z]/g,\n (match: string) => '-' + match.toLowerCase()\n )}`,\n {\n start: startTime,\n end: performance.now(),\n }\n )\n }\n }\n\n if (isRootSpan) {\n rootSpanAttributesStore.set(\n spanId,\n new Map(\n Object.entries(options.attributes ?? {}) as [\n AttributeNames,\n AttributeValue | undefined,\n ][]\n )\n )\n }\n if (fn.length > 1) {\n try {\n return fn(span, (err) => {\n if (err) {\n closeSpanWithError(span, err, options.endTime)\n } else {\n span.end(options.endTime)\n }\n })\n } catch (err: any) {\n closeSpanWithError(span, err, options.endTime)\n throw err\n } finally {\n onCleanup()\n }\n }\n\n try {\n const result = fn(span)\n if (isThenable(result)) {\n // If there's error make sure it throws\n return result\n .then((res) => {\n span.end(options.endTime)\n // Need to pass down the promise result,\n // it could be react stream response with error { error, stream }\n return res\n })\n .catch((err) => {\n closeSpanWithError(span, err, options.endTime)\n throw err\n })\n .finally(onCleanup)\n } else {\n span.end(options.endTime)\n onCleanup()\n }\n\n return result\n } catch (err: any) {\n closeSpanWithError(span, err, options.endTime)\n onCleanup()\n throw err\n }\n }\n )\n )\n }\n\n private runWithActiveSpan<T>(\n spanName: string,\n options: TracerSpanOptions,\n parentContext: Context,\n tracingEnabled: boolean,\n localSpanRecordingEnabled: boolean,\n isolatedParentSpan: Span | undefined,\n fn: (span: Span) => T\n ): T {\n if (tracingEnabled) {\n return this.getTracerInstance().startActiveSpan(\n spanName,\n options,\n (span: Span) =>\n fn(\n localSpanRecordingEnabled\n ? this.createLocalRecordingSpan(\n spanName,\n options,\n parentContext,\n span,\n isolatedParentSpan\n )\n : span\n )\n )\n }\n\n const span = this.createLocalRecordingSpan(\n spanName,\n options,\n parentContext,\n undefined,\n isolatedParentSpan\n )\n const localSpanRecorder = getLocalSpanRecorder()!\n return localSpanRecorder.withLocalSpan(span, () =>\n localSpanRecorder.isOpenTelemetryIsolatedSpan(span)\n ? fn(span)\n : context.with(\n trace.setSpan(context.active(), span),\n fn,\n undefined,\n span\n )\n )\n }\n\n private createLocalRecordingSpan(\n name: string,\n options: TracerSpanOptions,\n parentContext: Context,\n delegateSpan?: Span,\n isolatedParentSpan?: Span\n ): Span {\n const parentSpanContext =\n isolatedParentSpan?.spanContext() ?? trace.getSpanContext(parentContext)\n const delegateSpanContext = delegateSpan?.spanContext()\n\n return getLocalSpanRecorder()!.createLocalSpan({\n name,\n attributes: options.attributes,\n links: options.links,\n startTime: options.startTime,\n delegateSpan,\n traceId: delegateSpanContext?.traceId ?? parentSpanContext?.traceId,\n spanId: delegateSpanContext?.spanId,\n parentSpanId: parentSpanContext?.spanId,\n isolateOpenTelemetry: isolatedParentSpan !== undefined,\n })\n }\n\n public wrap<T = (...args: Array<any>) => any>(type: SpanTypes, fn: T): T\n public wrap<T = (...args: Array<any>) => any>(\n type: SpanTypes,\n options: TracerSpanOptions,\n fn: T\n ): T\n public wrap<T = (...args: Array<any>) => any>(\n type: SpanTypes,\n options: (...args: any[]) => TracerSpanOptions,\n fn: T\n ): T\n public wrap(...args: Array<any>) {\n const tracer = this\n const [name, options, fn] =\n args.length === 3 ? args : [args[0], {}, args[1]]\n\n if (\n !NextVanillaSpanAllowlist.has(name) &&\n process.env.NEXT_OTEL_VERBOSE !== '1' &&\n !process.env.__NEXT_DEV_SERVER\n ) {\n return fn\n }\n\n return function (this: any) {\n let optionsObj = options\n if (typeof optionsObj === 'function' && typeof fn === 'function') {\n optionsObj = optionsObj.apply(this, arguments)\n }\n\n const lastArgId = arguments.length - 1\n const cb = arguments[lastArgId]\n\n if (typeof cb === 'function') {\n const scopeBoundCb = tracer.getContext().bind(context.active(), cb)\n return tracer.trace(name, optionsObj, (_span, done) => {\n arguments[lastArgId] = function (err: any) {\n done?.(err)\n return scopeBoundCb.apply(this, arguments)\n }\n\n return fn.apply(this, arguments)\n })\n } else {\n return tracer.trace(name, optionsObj, () => fn.apply(this, arguments))\n }\n }\n }\n\n public startSpan(type: SpanTypes): Span\n public startSpan(type: SpanTypes, options: TracerSpanOptions): Span\n public startSpan(...args: Array<any>): Span {\n const [type, passedOptions]: [string, TracerSpanOptions | undefined] =\n args as any\n const options: TracerSpanOptions = passedOptions\n ? {\n ...passedOptions,\n attributes: {\n 'next.span_category': 'nextjs',\n ...passedOptions.attributes,\n },\n }\n : { attributes: { 'next.span_category': 'nextjs' } }\n\n const localSpanRecorder = getLocalSpanRecorder()\n const parentSpan = options.parentSpan ?? this.getActiveScopeSpan()\n const isolatedParentSpan =\n parentSpan && localSpanRecorder?.isOpenTelemetryIsolatedSpan(parentSpan)\n ? parentSpan\n : undefined\n const parentContext =\n (isolatedParentSpan ? undefined : this.getSpanContext(parentSpan)) ??\n context.active()\n const localSpanRecordingEnabled =\n localSpanRecorder?.isLocalSpanRecordingEnabled() ?? false\n\n if (!localSpanRecordingEnabled) {\n return this.getTracerInstance().startSpan(type, options, parentContext)\n }\n\n const delegateSpan =\n !isolatedParentSpan && this.isOpenTelemetryEnabled()\n ? this.getTracerInstance().startSpan(type, options, parentContext)\n : undefined\n\n return this.createLocalRecordingSpan(\n type,\n options,\n parentContext,\n delegateSpan,\n isolatedParentSpan\n )\n }\n\n private getSpanContext(parentSpan?: Span) {\n const spanContext = parentSpan\n ? trace.setSpan(context.active(), parentSpan)\n : undefined\n\n return spanContext\n }\n\n public getRootSpanAttributes() {\n const spanId = context.active().getValue(rootSpanIdKey) as number\n return rootSpanAttributesStore.get(spanId)\n }\n\n public setRootSpanAttribute(key: AttributeNames, value: AttributeValue) {\n const spanId = context.active().getValue(rootSpanIdKey) as number\n const attributes = rootSpanAttributesStore.get(spanId)\n if (attributes && !attributes.has(key)) {\n attributes.set(key, value)\n }\n\n if (process.env.__NEXT_DEV_SERVER) {\n const localSpan = getLocalSpanRecorder()?.getActiveLocalSpan()\n if (localSpan) {\n localSpan.setAttribute(key, value)\n }\n }\n }\n\n public withSpan<T>(span: Span, fn: () => T): T {\n const recorder = getLocalSpanRecorder()\n if (recorder?.isLocalRecordingSpan(span)) {\n return recorder.withLocalSpan(span, () =>\n recorder.isOpenTelemetryIsolatedSpan(span)\n ? fn()\n : context.with(trace.setSpan(context.active(), span), fn)\n )\n }\n return context.with(trace.setSpan(context.active(), span), fn)\n }\n}\n\nconst getTracer = (() => {\n const tracer = new NextTracerImpl()\n\n return () => tracer\n})()\n\nexport { getTracer, SpanStatusCode, SpanKind }\nexport type { NextTracer, Span, SpanOptions, ContextAPI, TracerSpanOptions }\n"],"names":["BubbledError","SpanKind","SpanStatusCode","getTracer","isBubbledError","NEXT_OTEL_PERFORMANCE_PREFIX","process","env","LOCAL_SPAN_RECORDER_KEY","Symbol","for","api","getLocalSpanRecorder","__NEXT_DEV_SERVER","globalThis","undefined","NEXT_RUNTIME","require","err","context","propagation","trace","ROOT_CONTEXT","Error","constructor","bubble","result","error","closeSpanWithError","span","endTime","setAttribute","recordException","name","setStatus","code","ERROR","message","end","rootSpanAttributesStore","Map","rootSpanIdKey","createContextKey","lastSpanId","getSpanId","clientTraceDataSetter","set","carrier","key","value","push","NextTracerImpl","getTracerInstance","__NEXT_VERSION","isOpenTelemetryEnabled","tracerProvider","activeSpan","getSpan","active","isRecording","getTracerProvider","getDelegate","getContext","getTracePropagationData","activeContext","entries","inject","getActiveScopeSpan","localSpanRecorder","activeLocalSpan","getActiveLocalSpan","isOpenTelemetryIsolatedSpan","runWithDetachedContext","fn","with","withPropagatedContext","getter","force","getSpanContext","remoteContext","extract","mergedContext","args","type","fnOrOptions","fnOrEmpty","tracingEnabled","Boolean","localSpanRecordingEnabled","isLocalSpanRecordingEnabled","options","spanName","parentSpan","isolatedParentSpan","shouldDelegateSpan","NextVanillaSpanAllowlist","has","NEXT_OTEL_VERBOSE","shouldTraceSpan","isRequestInsightsEnabled","hideSpan","spanContext","existingRootSpanId","getValue","isRootSpan","spanId","attributes","setValue","runWithActiveSpan","startTime","LogSpanAllowList","performance","now","cleanedUp","onCleanup","delete","measure","split","pop","replace","match","toLowerCase","start","Object","length","isThenable","then","res","catch","finally","parentContext","startActiveSpan","createLocalRecordingSpan","withLocalSpan","setSpan","delegateSpan","parentSpanContext","delegateSpanContext","createLocalSpan","links","traceId","parentSpanId","isolateOpenTelemetry","wrap","tracer","optionsObj","apply","arguments","lastArgId","cb","scopeBoundCb","bind","_span","done","startSpan","passedOptions","getRootSpanAttributes","get","setRootSpanAttribute","localSpan","withSpan","recorder","isLocalRecordingSpan"],"mappings":";;;;;;;;;;;;;;;;;;IAuDaA,YAAY;eAAZA;;IA6qBuBC,QAAQ;eAARA;;IAAhBC,cAAc;eAAdA;;IAAXC,SAAS;eAATA;;IApqBOC,cAAc;eAAdA;;;2BA5D2C;4BAWhC;AAE3B,MAAMC,+BAA+BC,QAAQC,GAAG,CAACF,4BAA4B;AAC7E,MAAMG,0BAA0BC,OAAOC,GAAG,CAAC;AAM3C,IAAIC;AAEJ,SAASC;IACP,IAAIN,QAAQC,GAAG,CAACM,iBAAiB,EAAE;QACjC,OAAO,AAACC,UAA0C,CAACN,wBAAwB;IAC7E,OAAO;QACL,OAAOO;IACT;AACF;AAEA,gFAAgF;AAChF,8EAA8E;AAC9E,uCAAuC;AACvC,0EAA0E;AAC1E,+EAA+E;AAC/E,4CAA4C;AAC5C,6CAA6C;AAC7C,IAAIT,QAAQC,GAAG,CAACS,YAAY,KAAK,QAAQ;IACvCL,MAAMM,QAAQ;AAChB,OAAO;IACL,IAAI;QACFN,MAAMM,QAAQ;IAChB,EAAE,OAAOC,KAAK;QACZP,MACEM,QAAQ;IACZ;AACF;AAEA,MAAM,EAAEE,OAAO,EAAEC,WAAW,EAAEC,KAAK,EAAEnB,cAAc,EAAED,QAAQ,EAAEqB,YAAY,EAAE,GAC3EX;AAEK,MAAMX,qBAAqBuB;IAChCC,YACE,AAAgBC,MAAgB,EAChC,AAAgBC,MAAyB,CACzC;QACA,KAAK,SAHWD,SAAAA,aACAC,SAAAA;IAGlB;AACF;AAEO,SAAStB,eAAeuB,KAAc;IAC3C,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OA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S1F,2BAA2B,CAAC1C,QACjC4C,OACAtD,QAAQuD,IAAI,CAACrD,MAAMiH,OAAO,CAACnH,QAAQuC,MAAM,IAAI7B,OAAO4C;QAE5D;QACA,OAAOtD,QAAQuD,IAAI,CAACrD,MAAMiH,OAAO,CAACnH,QAAQuC,MAAM,IAAI7B,OAAO4C;IAC7D;AACF;AAEA,MAAMtE,YAAY,AAAC,CAAA;IACjB,MAAM6I,SAAS,IAAI7F;IAEnB,OAAO,IAAM6F;AACf,CAAA","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/trace/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { ClientTraceDataEntry } from './tracer';
|
| 2 |
+
/**
|
| 3 |
+
* Takes OpenTelemetry client trace data and the `clientTraceMetadata` option configured in the Next.js config (currently
|
| 4 |
+
* experimental) and returns a filtered/allowed list of client trace data entries.
|
| 5 |
+
*/
|
| 6 |
+
export declare function getTracedMetadata(traceData: ClientTraceDataEntry[], clientTraceMetadata: string[] | undefined): ClientTraceDataEntry[] | undefined;
|
e-commerce/node_modules/next/dist/server/lib/trace/utils.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
Object.defineProperty(exports, "getTracedMetadata", {
|
| 6 |
+
enumerable: true,
|
| 7 |
+
get: function() {
|
| 8 |
+
return getTracedMetadata;
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
function getTracedMetadata(traceData, clientTraceMetadata) {
|
| 12 |
+
if (!clientTraceMetadata) return undefined;
|
| 13 |
+
return traceData.filter(({ key })=>clientTraceMetadata.includes(key));
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
//# sourceMappingURL=utils.js.map
|
e-commerce/node_modules/next/dist/server/lib/trace/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/server/lib/trace/utils.ts"],"sourcesContent":["import type { ClientTraceDataEntry } from './tracer'\n\n/**\n * Takes OpenTelemetry client trace data and the `clientTraceMetadata` option configured in the Next.js config (currently\n * experimental) and returns a filtered/allowed list of client trace data entries.\n */\nexport function getTracedMetadata(\n traceData: ClientTraceDataEntry[],\n clientTraceMetadata: string[] | undefined\n): ClientTraceDataEntry[] | undefined {\n if (!clientTraceMetadata) return undefined\n return traceData.filter(({ key }) => clientTraceMetadata.includes(key))\n}\n"],"names":["getTracedMetadata","traceData","clientTraceMetadata","undefined","filter","key","includes"],"mappings":";;;;+BAMgBA;;;eAAAA;;;AAAT,SAASA,kBACdC,SAAiC,EACjCC,mBAAyC;IAEzC,IAAI,CAACA,qBAAqB,OAAOC;IACjC,OAAOF,UAAUG,MAAM,CAAC,CAAC,EAAEC,GAAG,EAAE,GAAKH,oBAAoBI,QAAQ,CAACD;AACpE","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/types.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { IncomingMessage, ServerResponse } from 'http';
|
| 2 |
+
import type { Duplex } from 'stream';
|
| 3 |
+
export type WorkerRequestHandler = (req: IncomingMessage, res: ServerResponse) => Promise<any>;
|
| 4 |
+
export type WorkerUpgradeHandler = (req: IncomingMessage, socket: Duplex, head: Buffer) => any;
|
e-commerce/node_modules/next/dist/server/lib/types.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
|
| 6 |
+
//# sourceMappingURL=types.js.map
|
e-commerce/node_modules/next/dist/server/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":[],"names":[],"mappings":"","ignoreList":[]}
|
e-commerce/node_modules/next/dist/server/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare function printAndExit(message: string, code?: number): never;
|
| 2 |
+
export type NodeOptions = Record<string, string | string[] | boolean | undefined>;
|
| 3 |
+
/**
|
| 4 |
+
* Tokenizes the arguments string into an array of strings, supporting quoted
|
| 5 |
+
* values and escaped characters.
|
| 6 |
+
* Converted from: https://github.com/nodejs/node/blob/c29d53c5cfc63c5a876084e788d70c9e87bed880/src/node_options.cc#L1401
|
| 7 |
+
*
|
| 8 |
+
* @param input The arguments string to be tokenized.
|
| 9 |
+
* @returns An array of strings with the tokenized arguments.
|
| 10 |
+
*/
|
| 11 |
+
export declare const tokenizeArgs: (input: string) => string[];
|
| 12 |
+
/**
|
| 13 |
+
* Get the node options from the environment variable `NODE_OPTIONS` and returns
|
| 14 |
+
* them as an array of strings.
|
| 15 |
+
*
|
| 16 |
+
* @returns An array of strings with the node options.
|
| 17 |
+
*/
|
| 18 |
+
export declare const getNodeOptionsArgs: () => string[];
|
| 19 |
+
/**
|
| 20 |
+
* The debug address is in the form of `[host:]port`. The host is optional.
|
| 21 |
+
*/
|
| 22 |
+
export interface DebugAddress {
|
| 23 |
+
host: string | undefined;
|
| 24 |
+
port: number;
|
| 25 |
+
}
|
| 26 |
+
/**
|
| 27 |
+
* Formats the debug address into a string.
|
| 28 |
+
*/
|
| 29 |
+
export declare const formatDebugAddress: ({ host, port }: DebugAddress) => string;
|
| 30 |
+
/**
|
| 31 |
+
* Get's the debug address from the `NODE_OPTIONS` environment variable. If the
|
| 32 |
+
* address is not found, it returns the default host (`undefined`) and port
|
| 33 |
+
* (`9229`).
|
| 34 |
+
*
|
| 35 |
+
* @returns An object with the host and port of the debug address.
|
| 36 |
+
*/
|
| 37 |
+
export declare const getParsedDebugAddress: (address: string | string[] | boolean | undefined) => DebugAddress;
|
| 38 |
+
/**
|
| 39 |
+
* Stringify the arguments to be used in a command line. It will ignore any
|
| 40 |
+
* argument that has a value of `undefined`. Options that are not allowed in
|
| 41 |
+
* NODE_OPTIONS are returned separately as execArgv.
|
| 42 |
+
*
|
| 43 |
+
* @param args The arguments to be stringified.
|
| 44 |
+
* @returns An object with `nodeOptions` string and `execArgv` array.
|
| 45 |
+
*/
|
| 46 |
+
export declare function formatNodeOptions(args: NodeOptions): {
|
| 47 |
+
nodeOptions: string;
|
| 48 |
+
execArgv: string[];
|
| 49 |
+
};
|
| 50 |
+
export declare function getParsedNodeOptions(): NodeOptions;
|
| 51 |
+
/**
|
| 52 |
+
* Get the node options from the `NODE_OPTIONS` environment variable and parse
|
| 53 |
+
* them into an object without the inspect options.
|
| 54 |
+
*
|
| 55 |
+
* @returns An object with the parsed node options.
|
| 56 |
+
*/
|
| 57 |
+
export declare function getParsedNodeOptionsWithoutInspect(): NodeOptions;
|
| 58 |
+
/**
|
| 59 |
+
* Get the node options from the `NODE_OPTIONS` environment variable and format
|
| 60 |
+
* them into a string without the inspect options.
|
| 61 |
+
*
|
| 62 |
+
* @returns A string with the formatted node options.
|
| 63 |
+
*/
|
| 64 |
+
export declare function getFormattedNodeOptionsWithoutInspect(): string;
|
| 65 |
+
/**
|
| 66 |
+
* Check if the value is a valid positive integer and parse it. If it's not, it will throw an error.
|
| 67 |
+
*
|
| 68 |
+
* @param value The value to be parsed.
|
| 69 |
+
*/
|
| 70 |
+
export declare function parseValidPositiveInteger(value: string): number;
|
| 71 |
+
export declare const RESTART_EXIT_CODE = 77;
|
| 72 |
+
export type NodeInspectType = 'inspect' | 'inspect-brk' | undefined;
|
| 73 |
+
/**
|
| 74 |
+
* Get the debug type from the `NODE_OPTIONS` environment variable.
|
| 75 |
+
*/
|
| 76 |
+
export declare function getNodeDebugType(nodeOptions: NodeOptions): NodeInspectType;
|
| 77 |
+
/**
|
| 78 |
+
* Get the `max-old-space-size` value from the `NODE_OPTIONS` environment
|
| 79 |
+
* variable.
|
| 80 |
+
*
|
| 81 |
+
* @returns The value of the `max-old-space-size` option as a number.
|
| 82 |
+
*/
|
| 83 |
+
export declare function getMaxOldSpaceSize(): number | undefined;
|
| 84 |
+
export declare function blockOnOutputWrites(): void;
|
e-commerce/node_modules/next/dist/server/lib/utils.js
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
0 && (module.exports = {
|
| 6 |
+
RESTART_EXIT_CODE: null,
|
| 7 |
+
blockOnOutputWrites: null,
|
| 8 |
+
formatDebugAddress: null,
|
| 9 |
+
formatNodeOptions: null,
|
| 10 |
+
getFormattedNodeOptionsWithoutInspect: null,
|
| 11 |
+
getMaxOldSpaceSize: null,
|
| 12 |
+
getMemoryRestartStats: null,
|
| 13 |
+
getNodeDebugType: null,
|
| 14 |
+
getNodeOptionsArgs: null,
|
| 15 |
+
getParsedDebugAddress: null,
|
| 16 |
+
getParsedNodeOptions: null,
|
| 17 |
+
getParsedNodeOptionsWithoutInspect: null,
|
| 18 |
+
parseValidPositiveInteger: null,
|
| 19 |
+
printAndExit: null,
|
| 20 |
+
tokenizeArgs: null
|
| 21 |
+
});
|
| 22 |
+
function _export(target, all) {
|
| 23 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 24 |
+
enumerable: true,
|
| 25 |
+
get: all[name]
|
| 26 |
+
});
|
| 27 |
+
}
|
| 28 |
+
_export(exports, {
|
| 29 |
+
RESTART_EXIT_CODE: function() {
|
| 30 |
+
return RESTART_EXIT_CODE;
|
| 31 |
+
},
|
| 32 |
+
blockOnOutputWrites: function() {
|
| 33 |
+
return blockOnOutputWrites;
|
| 34 |
+
},
|
| 35 |
+
formatDebugAddress: function() {
|
| 36 |
+
return formatDebugAddress;
|
| 37 |
+
},
|
| 38 |
+
formatNodeOptions: function() {
|
| 39 |
+
return formatNodeOptions;
|
| 40 |
+
},
|
| 41 |
+
getFormattedNodeOptionsWithoutInspect: function() {
|
| 42 |
+
return getFormattedNodeOptionsWithoutInspect;
|
| 43 |
+
},
|
| 44 |
+
getMaxOldSpaceSize: function() {
|
| 45 |
+
return getMaxOldSpaceSize;
|
| 46 |
+
},
|
| 47 |
+
getMemoryRestartStats: function() {
|
| 48 |
+
return getMemoryRestartStats;
|
| 49 |
+
},
|
| 50 |
+
getNodeDebugType: function() {
|
| 51 |
+
return getNodeDebugType;
|
| 52 |
+
},
|
| 53 |
+
getNodeOptionsArgs: function() {
|
| 54 |
+
return getNodeOptionsArgs;
|
| 55 |
+
},
|
| 56 |
+
getParsedDebugAddress: function() {
|
| 57 |
+
return getParsedDebugAddress;
|
| 58 |
+
},
|
| 59 |
+
getParsedNodeOptions: function() {
|
| 60 |
+
return getParsedNodeOptions;
|
| 61 |
+
},
|
| 62 |
+
getParsedNodeOptionsWithoutInspect: function() {
|
| 63 |
+
return getParsedNodeOptionsWithoutInspect;
|
| 64 |
+
},
|
| 65 |
+
parseValidPositiveInteger: function() {
|
| 66 |
+
return parseValidPositiveInteger;
|
| 67 |
+
},
|
| 68 |
+
printAndExit: function() {
|
| 69 |
+
return printAndExit;
|
| 70 |
+
},
|
| 71 |
+
tokenizeArgs: function() {
|
| 72 |
+
return tokenizeArgs;
|
| 73 |
+
}
|
| 74 |
+
});
|
| 75 |
+
const _nodeutil = require("node:util");
|
| 76 |
+
const _commander = require("next/dist/compiled/commander");
|
| 77 |
+
function printAndExit(message, code = 1) {
|
| 78 |
+
if (code === 0) {
|
| 79 |
+
console.log(message);
|
| 80 |
+
} else {
|
| 81 |
+
console.error(message);
|
| 82 |
+
}
|
| 83 |
+
return process.exit(code);
|
| 84 |
+
}
|
| 85 |
+
/**
|
| 86 |
+
* Node.js CLI flags that can be repeated. Node runs every occurrence of these
|
| 87 |
+
* flags, so they need to be preserved individually rather than collapsed into
|
| 88 |
+
* a single value keyed by option name.
|
| 89 |
+
* https://nodejs.org/api/cli.html#--requiremodule
|
| 90 |
+
* https://nodejs.org/api/cli.html#--importmodule
|
| 91 |
+
*/ const REPEATABLE_OPTIONS = {
|
| 92 |
+
require: {
|
| 93 |
+
type: 'string',
|
| 94 |
+
multiple: true
|
| 95 |
+
},
|
| 96 |
+
import: {
|
| 97 |
+
type: 'string',
|
| 98 |
+
multiple: true
|
| 99 |
+
}
|
| 100 |
+
};
|
| 101 |
+
const parseNodeArgs = (args)=>{
|
| 102 |
+
const parsed = (0, _nodeutil.parseArgs)({
|
| 103 |
+
args,
|
| 104 |
+
strict: false,
|
| 105 |
+
tokens: true,
|
| 106 |
+
options: REPEATABLE_OPTIONS
|
| 107 |
+
});
|
| 108 |
+
const values = parsed.values;
|
| 109 |
+
const tokens = parsed.tokens;
|
| 110 |
+
// For the `NODE_OPTIONS`, we support arguments with values without the `=`
|
| 111 |
+
// sign. We need to parse them manually.
|
| 112 |
+
let orphan = null;
|
| 113 |
+
for(let i = 0; i < tokens.length; i++){
|
| 114 |
+
const token = tokens[i];
|
| 115 |
+
if (token.kind === 'option-terminator') {
|
| 116 |
+
break;
|
| 117 |
+
}
|
| 118 |
+
// When we encounter an option, if it's value is undefined, we should check
|
| 119 |
+
// to see if the following tokens are positional parameters. If they are,
|
| 120 |
+
// then the option is orphaned, and we can assign it.
|
| 121 |
+
if (token.kind === 'option') {
|
| 122 |
+
orphan = typeof token.value === 'undefined' ? token : null;
|
| 123 |
+
continue;
|
| 124 |
+
}
|
| 125 |
+
// If the token isn't a positional one, then we can't assign it to the found
|
| 126 |
+
// orphaned option.
|
| 127 |
+
if (token.kind !== 'positional') {
|
| 128 |
+
orphan = null;
|
| 129 |
+
continue;
|
| 130 |
+
}
|
| 131 |
+
// If we don't have an orphan, then we can skip this token.
|
| 132 |
+
if (!orphan) {
|
| 133 |
+
continue;
|
| 134 |
+
}
|
| 135 |
+
const name = orphan.name;
|
| 136 |
+
// If the option is repeatable, accumulate each occurrence instead of
|
| 137 |
+
// collapsing them into a single value.
|
| 138 |
+
if (name in REPEATABLE_OPTIONS) {
|
| 139 |
+
if (Array.isArray(values[name])) {
|
| 140 |
+
values[name].push(token.value);
|
| 141 |
+
} else if (typeof values[name] === 'string') {
|
| 142 |
+
values[name] = [
|
| 143 |
+
values[name],
|
| 144 |
+
token.value
|
| 145 |
+
];
|
| 146 |
+
} else {
|
| 147 |
+
values[name] = token.value;
|
| 148 |
+
}
|
| 149 |
+
continue;
|
| 150 |
+
}
|
| 151 |
+
// If the token is a positional one, and it has a value, so add it to the
|
| 152 |
+
// values object. If it already exists, append it with a space.
|
| 153 |
+
if (name in values && typeof values[name] === 'string') {
|
| 154 |
+
values[name] += ` ${token.value}`;
|
| 155 |
+
} else {
|
| 156 |
+
values[name] = token.value;
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
return values;
|
| 160 |
+
};
|
| 161 |
+
const tokenizeArgs = (input)=>{
|
| 162 |
+
let args = [];
|
| 163 |
+
let isInString = false;
|
| 164 |
+
let willStartNewArg = true;
|
| 165 |
+
for(let i = 0; i < input.length; i++){
|
| 166 |
+
let char = input[i];
|
| 167 |
+
// Skip any escaped characters in strings.
|
| 168 |
+
if (char === '\\' && isInString) {
|
| 169 |
+
// Ensure we don't have an escape character at the end.
|
| 170 |
+
if (input.length === i + 1) {
|
| 171 |
+
throw new Error('Invalid escape character at the end.');
|
| 172 |
+
}
|
| 173 |
+
// Skip the next character.
|
| 174 |
+
char = input[++i];
|
| 175 |
+
} else if (char === ' ' && !isInString) {
|
| 176 |
+
willStartNewArg = true;
|
| 177 |
+
continue;
|
| 178 |
+
} else if (char === '"') {
|
| 179 |
+
isInString = !isInString;
|
| 180 |
+
continue;
|
| 181 |
+
}
|
| 182 |
+
// If we're starting a new argument, we should add it to the array.
|
| 183 |
+
if (willStartNewArg) {
|
| 184 |
+
args.push(char);
|
| 185 |
+
willStartNewArg = false;
|
| 186 |
+
} else {
|
| 187 |
+
args[args.length - 1] += char;
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
if (isInString) {
|
| 191 |
+
throw new Error('Unterminated string');
|
| 192 |
+
}
|
| 193 |
+
return args;
|
| 194 |
+
};
|
| 195 |
+
const getNodeOptionsArgs = ()=>{
|
| 196 |
+
if (!process.env.NODE_OPTIONS) return [];
|
| 197 |
+
return tokenizeArgs(process.env.NODE_OPTIONS);
|
| 198 |
+
};
|
| 199 |
+
const formatDebugAddress = ({ host, port })=>{
|
| 200 |
+
if (host) return `${host}:${port}`;
|
| 201 |
+
return `${port}`;
|
| 202 |
+
};
|
| 203 |
+
const getParsedDebugAddress = (address)=>{
|
| 204 |
+
if (!address || typeof address !== 'string') {
|
| 205 |
+
return {
|
| 206 |
+
host: undefined,
|
| 207 |
+
port: 9229
|
| 208 |
+
};
|
| 209 |
+
}
|
| 210 |
+
// The address is in the form of `[host:]port`. Let's parse the address.
|
| 211 |
+
if (address.includes(':')) {
|
| 212 |
+
const [host, port] = address.split(':');
|
| 213 |
+
return {
|
| 214 |
+
host,
|
| 215 |
+
port: parseInt(port, 10)
|
| 216 |
+
};
|
| 217 |
+
}
|
| 218 |
+
return {
|
| 219 |
+
host: undefined,
|
| 220 |
+
port: parseInt(address, 10)
|
| 221 |
+
};
|
| 222 |
+
};
|
| 223 |
+
/**
|
| 224 |
+
* Node.js CLI flags that are not allowed in NODE_OPTIONS and must be
|
| 225 |
+
* passed as direct CLI arguments via execArgv.
|
| 226 |
+
* This set is the difference between all Node.js CLI flags and the ones **not**
|
| 227 |
+
* allowed in NODE_OPTIONS, as listed in the Node.js documentation:
|
| 228 |
+
* https://nodejs.org/api/cli.html#node_optionsoptions
|
| 229 |
+
*
|
| 230 |
+
* It is not exhaustive since not all options make sense for Next.js (e.g. --test)
|
| 231 |
+
*/ const EXEC_ARGV_ONLY_OPTIONS = new Set([
|
| 232 |
+
'experimental-network-inspection',
|
| 233 |
+
'experimental-storage-inspection',
|
| 234 |
+
'experimental-worker-inspection',
|
| 235 |
+
'experimental-inspector-network-resource'
|
| 236 |
+
]);
|
| 237 |
+
function formatArg(key, value) {
|
| 238 |
+
if (value === true) {
|
| 239 |
+
return `--${key}`;
|
| 240 |
+
}
|
| 241 |
+
if (Array.isArray(value)) {
|
| 242 |
+
const formatted = [];
|
| 243 |
+
for (const item of value){
|
| 244 |
+
const formattedItem = formatArg(key, item);
|
| 245 |
+
if (formattedItem !== null) {
|
| 246 |
+
formatted.push(formattedItem);
|
| 247 |
+
}
|
| 248 |
+
}
|
| 249 |
+
return formatted.length > 0 ? formatted.join(' ') : null;
|
| 250 |
+
}
|
| 251 |
+
if (value) {
|
| 252 |
+
return `--${key}=${// Values with spaces need to be quoted. We use JSON.stringify to
|
| 253 |
+
// also escape any nested quotes.
|
| 254 |
+
value.includes(' ') && !value.startsWith('"') ? JSON.stringify(value) : value}`;
|
| 255 |
+
}
|
| 256 |
+
return null;
|
| 257 |
+
}
|
| 258 |
+
function formatNodeOptions(args) {
|
| 259 |
+
const nodeOptionsParts = [];
|
| 260 |
+
const execArgv = [];
|
| 261 |
+
for (const [key, value] of Object.entries(args)){
|
| 262 |
+
const formatted = formatArg(key, value);
|
| 263 |
+
if (formatted === null) continue;
|
| 264 |
+
if (EXEC_ARGV_ONLY_OPTIONS.has(key)) {
|
| 265 |
+
execArgv.push(formatted);
|
| 266 |
+
} else {
|
| 267 |
+
nodeOptionsParts.push(formatted);
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
return {
|
| 271 |
+
nodeOptions: nodeOptionsParts.join(' '),
|
| 272 |
+
execArgv
|
| 273 |
+
};
|
| 274 |
+
}
|
| 275 |
+
function getParsedNodeOptions() {
|
| 276 |
+
const args = [
|
| 277 |
+
...process.execArgv,
|
| 278 |
+
...getNodeOptionsArgs()
|
| 279 |
+
];
|
| 280 |
+
if (args.length === 0) return {};
|
| 281 |
+
return parseNodeArgs(args);
|
| 282 |
+
}
|
| 283 |
+
function getParsedNodeOptionsWithoutInspect() {
|
| 284 |
+
const args = getNodeOptionsArgs();
|
| 285 |
+
if (args.length === 0) return {};
|
| 286 |
+
const parsed = parseNodeArgs(args);
|
| 287 |
+
// Remove inspect options.
|
| 288 |
+
delete parsed.inspect;
|
| 289 |
+
delete parsed['inspect-brk'];
|
| 290 |
+
delete parsed['inspect_brk'];
|
| 291 |
+
return parsed;
|
| 292 |
+
}
|
| 293 |
+
function getFormattedNodeOptionsWithoutInspect() {
|
| 294 |
+
const args = getParsedNodeOptionsWithoutInspect();
|
| 295 |
+
if (Object.keys(args).length === 0) return '';
|
| 296 |
+
return formatNodeOptions(args).nodeOptions;
|
| 297 |
+
}
|
| 298 |
+
function parseValidPositiveInteger(value) {
|
| 299 |
+
const parsedValue = parseInt(value, 10);
|
| 300 |
+
if (isNaN(parsedValue) || !isFinite(parsedValue) || parsedValue < 0) {
|
| 301 |
+
throw new _commander.InvalidArgumentError(`'${value}' is not a non-negative number.`);
|
| 302 |
+
}
|
| 303 |
+
return parsedValue;
|
| 304 |
+
}
|
| 305 |
+
const RESTART_EXIT_CODE = 77;
|
| 306 |
+
function getMemoryRestartStats(isDev, devMemoryThresholdRestart, getHeapStatistics) {
|
| 307 |
+
if (!isDev || !devMemoryThresholdRestart) {
|
| 308 |
+
return undefined;
|
| 309 |
+
}
|
| 310 |
+
const heapStatistics = getHeapStatistics();
|
| 311 |
+
if (heapStatistics.used_heap_size > 0.8 * heapStatistics.heap_size_limit) {
|
| 312 |
+
return heapStatistics;
|
| 313 |
+
}
|
| 314 |
+
return undefined;
|
| 315 |
+
}
|
| 316 |
+
function getNodeDebugType(nodeOptions) {
|
| 317 |
+
if (nodeOptions.inspect) {
|
| 318 |
+
return 'inspect';
|
| 319 |
+
}
|
| 320 |
+
if (nodeOptions['inspect-brk'] || nodeOptions['inspect_brk']) {
|
| 321 |
+
return 'inspect-brk';
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
function getMaxOldSpaceSize() {
|
| 325 |
+
const args = getNodeOptionsArgs();
|
| 326 |
+
if (args.length === 0) return;
|
| 327 |
+
const parsed = parseNodeArgs(args);
|
| 328 |
+
const size = parsed['max-old-space-size'] || parsed['max_old_space_size'];
|
| 329 |
+
if (!size || typeof size !== 'string') return;
|
| 330 |
+
return parseInt(size, 10);
|
| 331 |
+
}
|
| 332 |
+
function blockOnOutputWrites() {
|
| 333 |
+
for (const stream of [
|
| 334 |
+
process.stdout,
|
| 335 |
+
process.stderr
|
| 336 |
+
]){
|
| 337 |
+
var _stream__handle_setBlocking, _stream__handle;
|
| 338 |
+
;
|
| 339 |
+
(_stream__handle = stream._handle) == null ? void 0 : (_stream__handle_setBlocking = _stream__handle.setBlocking) == null ? void 0 : _stream__handle_setBlocking.call(_stream__handle, true);
|
| 340 |
+
}
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
//# sourceMappingURL=utils.js.map
|
e-commerce/node_modules/next/dist/server/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/server/lib/utils.ts"],"sourcesContent":["import { parseArgs } from 'node:util'\nimport { InvalidArgumentError } from 'next/dist/compiled/commander'\n\nexport function printAndExit(message: string, code = 1) {\n if (code === 0) {\n console.log(message)\n } else {\n console.error(message)\n }\n\n return process.exit(code)\n}\n\nexport type NodeOptions = Record<\n string,\n string | string[] | boolean | undefined\n>\n\n/**\n * Node.js CLI flags that can be repeated. Node runs every occurrence of these\n * flags, so they need to be preserved individually rather than collapsed into\n * a single value keyed by option name.\n * https://nodejs.org/api/cli.html#--requiremodule\n * https://nodejs.org/api/cli.html#--importmodule\n */\nconst REPEATABLE_OPTIONS: Record<string, { type: 'string'; multiple: true }> = {\n require: { type: 'string', multiple: true },\n import: { type: 'string', multiple: true },\n}\n\nconst parseNodeArgs = (args: string[]): NodeOptions => {\n const parsed = parseArgs({\n args,\n strict: false,\n tokens: true,\n options: REPEATABLE_OPTIONS,\n })\n const values: NodeOptions = parsed.values\n const tokens = parsed.tokens\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan = null\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i]\n\n if (token.kind === 'option-terminator') {\n break\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === 'option') {\n orphan = typeof token.value === 'undefined' ? token : null\n continue\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== 'positional') {\n orphan = null\n continue\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue\n }\n\n const name = orphan.name\n\n // If the option is repeatable, accumulate each occurrence instead of\n // collapsing them into a single value.\n if (name in REPEATABLE_OPTIONS) {\n if (Array.isArray(values[name])) {\n values[name].push(token.value)\n } else if (typeof values[name] === 'string') {\n values[name] = [values[name], token.value]\n } else {\n values[name] = token.value\n }\n continue\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (name in values && typeof values[name] === 'string') {\n values[name] += ` ${token.value}`\n } else {\n values[name] = token.value\n }\n }\n\n return values\n}\n\n/**\n * Tokenizes the arguments string into an array of strings, supporting quoted\n * values and escaped characters.\n * Converted from: https://github.com/nodejs/node/blob/c29d53c5cfc63c5a876084e788d70c9e87bed880/src/node_options.cc#L1401\n *\n * @param input The arguments string to be tokenized.\n * @returns An array of strings with the tokenized arguments.\n */\nexport const tokenizeArgs = (input: string): string[] => {\n let args: string[] = []\n let isInString = false\n let willStartNewArg = true\n\n for (let i = 0; i < input.length; i++) {\n let char = input[i]\n\n // Skip any escaped characters in strings.\n if (char === '\\\\' && isInString) {\n // Ensure we don't have an escape character at the end.\n if (input.length === i + 1) {\n throw new Error('Invalid escape character at the end.')\n }\n\n // Skip the next character.\n char = input[++i]\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === ' ' && !isInString) {\n willStartNewArg = true\n continue\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString\n continue\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char)\n willStartNewArg = false\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char\n }\n }\n\n if (isInString) {\n throw new Error('Unterminated string')\n }\n\n return args\n}\n\n/**\n * Get the node options from the environment variable `NODE_OPTIONS` and returns\n * them as an array of strings.\n *\n * @returns An array of strings with the node options.\n */\nexport const getNodeOptionsArgs = () => {\n if (!process.env.NODE_OPTIONS) return []\n\n return tokenizeArgs(process.env.NODE_OPTIONS)\n}\n\n/**\n * The debug address is in the form of `[host:]port`. The host is optional.\n */\nexport interface DebugAddress {\n host: string | undefined\n port: number\n}\n\n/**\n * Formats the debug address into a string.\n */\nexport const formatDebugAddress = ({ host, port }: DebugAddress): string => {\n if (host) return `${host}:${port}`\n return `${port}`\n}\n\n/**\n * Get's the debug address from the `NODE_OPTIONS` environment variable. If the\n * address is not found, it returns the default host (`undefined`) and port\n * (`9229`).\n *\n * @returns An object with the host and port of the debug address.\n */\nexport const getParsedDebugAddress = (\n address: string | string[] | boolean | undefined\n): DebugAddress => {\n if (!address || typeof address !== 'string') {\n return { host: undefined, port: 9229 }\n }\n\n // The address is in the form of `[host:]port`. Let's parse the address.\n if (address.includes(':')) {\n const [host, port] = address.split(':')\n return { host, port: parseInt(port, 10) }\n }\n\n return { host: undefined, port: parseInt(address, 10) }\n}\n\n/**\n * Node.js CLI flags that are not allowed in NODE_OPTIONS and must be\n * passed as direct CLI arguments via execArgv.\n * This set is the difference between all Node.js CLI flags and the ones **not**\n * allowed in NODE_OPTIONS, as listed in the Node.js documentation:\n * https://nodejs.org/api/cli.html#node_optionsoptions\n *\n * It is not exhaustive since not all options make sense for Next.js (e.g. --test)\n */\nconst EXEC_ARGV_ONLY_OPTIONS = new Set([\n 'experimental-network-inspection',\n 'experimental-storage-inspection',\n 'experimental-worker-inspection',\n 'experimental-inspector-network-resource',\n])\n\nfunction formatArg(\n key: string,\n value: string | string[] | boolean | undefined\n): string | null {\n if (value === true) {\n return `--${key}`\n }\n\n if (Array.isArray(value)) {\n const formatted: string[] = []\n for (const item of value) {\n const formattedItem = formatArg(key, item)\n if (formattedItem !== null) {\n formatted.push(formattedItem)\n }\n }\n return formatted.length > 0 ? formatted.join(' ') : null\n }\n\n if (value) {\n return `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(' ') && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`\n }\n\n return null\n}\n\n/**\n * Stringify the arguments to be used in a command line. It will ignore any\n * argument that has a value of `undefined`. Options that are not allowed in\n * NODE_OPTIONS are returned separately as execArgv.\n *\n * @param args The arguments to be stringified.\n * @returns An object with `nodeOptions` string and `execArgv` array.\n */\nexport function formatNodeOptions(args: NodeOptions): {\n nodeOptions: string\n execArgv: string[]\n} {\n const nodeOptionsParts: string[] = []\n const execArgv: string[] = []\n\n for (const [key, value] of Object.entries(args)) {\n const formatted = formatArg(key, value)\n if (formatted === null) continue\n\n if (EXEC_ARGV_ONLY_OPTIONS.has(key)) {\n execArgv.push(formatted)\n } else {\n nodeOptionsParts.push(formatted)\n }\n }\n\n return { nodeOptions: nodeOptionsParts.join(' '), execArgv }\n}\n\nexport function getParsedNodeOptions(): NodeOptions {\n const args = [...process.execArgv, ...getNodeOptionsArgs()]\n if (args.length === 0) return {}\n\n return parseNodeArgs(args)\n}\n\n/**\n * Get the node options from the `NODE_OPTIONS` environment variable and parse\n * them into an object without the inspect options.\n *\n * @returns An object with the parsed node options.\n */\nexport function getParsedNodeOptionsWithoutInspect() {\n const args = getNodeOptionsArgs()\n if (args.length === 0) return {}\n\n const parsed = parseNodeArgs(args)\n\n // Remove inspect options.\n delete parsed.inspect\n delete parsed['inspect-brk']\n delete parsed['inspect_brk']\n\n return parsed\n}\n\n/**\n * Get the node options from the `NODE_OPTIONS` environment variable and format\n * them into a string without the inspect options.\n *\n * @returns A string with the formatted node options.\n */\nexport function getFormattedNodeOptionsWithoutInspect() {\n const args = getParsedNodeOptionsWithoutInspect()\n if (Object.keys(args).length === 0) return ''\n\n return formatNodeOptions(args).nodeOptions\n}\n\n/**\n * Check if the value is a valid positive integer and parse it. If it's not, it will throw an error.\n *\n * @param value The value to be parsed.\n */\nexport function parseValidPositiveInteger(value: string): number {\n const parsedValue = parseInt(value, 10)\n\n if (isNaN(parsedValue) || !isFinite(parsedValue) || parsedValue < 0) {\n throw new InvalidArgumentError(`'${value}' is not a non-negative number.`)\n }\n return parsedValue\n}\n\nexport const RESTART_EXIT_CODE = 77\n\ntype HeapStatistics = {\n used_heap_size: number\n heap_size_limit: number\n}\n\n/**\n * @internal\n */\nexport function getMemoryRestartStats<T extends HeapStatistics>(\n isDev: boolean,\n devMemoryThresholdRestart: boolean,\n getHeapStatistics: () => T\n): T | undefined {\n if (!isDev || !devMemoryThresholdRestart) {\n return undefined\n }\n\n const heapStatistics = getHeapStatistics()\n if (heapStatistics.used_heap_size > 0.8 * heapStatistics.heap_size_limit) {\n return heapStatistics\n }\n\n return undefined\n}\n\nexport type NodeInspectType = 'inspect' | 'inspect-brk' | undefined\n\n/**\n * Get the debug type from the `NODE_OPTIONS` environment variable.\n */\nexport function getNodeDebugType(nodeOptions: NodeOptions): NodeInspectType {\n if (nodeOptions.inspect) {\n return 'inspect'\n }\n if (nodeOptions['inspect-brk'] || nodeOptions['inspect_brk']) {\n return 'inspect-brk'\n }\n}\n\n/**\n * Get the `max-old-space-size` value from the `NODE_OPTIONS` environment\n * variable.\n *\n * @returns The value of the `max-old-space-size` option as a number.\n */\nexport function getMaxOldSpaceSize() {\n const args = getNodeOptionsArgs()\n if (args.length === 0) return\n\n const parsed = parseNodeArgs(args)\n\n const size = parsed['max-old-space-size'] || parsed['max_old_space_size']\n if (!size || typeof size !== 'string') return\n\n return parseInt(size, 10)\n}\n\n// For a child whose output is piped to its parent. Without this,\n// process.exit() can drop the last lines written to the pipe. Node already\n// does this for terminals.\nexport function blockOnOutputWrites() {\n for (const stream of [process.stdout, process.stderr]) {\n ;(stream as any)._handle?.setBlocking?.(true)\n }\n}\n"],"names":["RESTART_EXIT_CODE","blockOnOutputWrites","formatDebugAddress","formatNodeOptions","getFormattedNodeOptionsWithoutInspect","getMaxOldSpaceSize","getMemoryRestartStats","getNodeDebugType","getNodeOptionsArgs","getParsedDebugAddress","getParsedNodeOptions","getParsedNodeOptionsWithoutInspect","parseValidPositiveInteger","printAndExit","tokenizeArgs","message","code","console","log","error","process","exit","REPEATABLE_OPTIONS","require","type","multiple","import","parseNodeArgs","args","parsed","parseArgs","strict","tokens","options","values","orphan","i","length","token","kind","value","name","Array","isArray","push","input","isInString","willStartNewArg","char","Error","env","NODE_OPTIONS","host","port","address","undefined","includes","split","parseInt","EXEC_ARGV_ONLY_OPTIONS","Set","formatArg","key","formatted","item","formattedItem","join","startsWith","JSON","stringify","nodeOptionsParts","execArgv","Object","entries","has","nodeOptions","inspect","keys","parsedValue","isNaN","isFinite","InvalidArgumentError","isDev","devMemoryThresholdRestart","getHeapStatistics","heapStatistics","used_heap_size","heap_size_limit","size","stream","stdout","stderr","_handle","setBlocking"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+UaA,iBAAiB;eAAjBA;;IA8DGC,mBAAmB;eAAnBA;;IA7NHC,kBAAkB;eAAlBA;;IAoFGC,iBAAiB;eAAjBA;;IAsDAC,qCAAqC;eAArCA;;IAoEAC,kBAAkB;eAAlBA;;IArCAC,qBAAqB;eAArBA;;IAsBAC,gBAAgB;eAAhBA;;IAhNHC,kBAAkB;eAAlBA;;IA6BAC,qBAAqB;eAArBA;;IA6FGC,oBAAoB;eAApBA;;IAaAC,kCAAkC;eAAlCA;;IAgCAC,yBAAyB;eAAzBA;;IAnUAC,YAAY;eAAZA;;IAsGHC,YAAY;eAAZA;;;0BAzGa;2BACW;AAE9B,SAASD,aAAaE,OAAe,EAAEC,OAAO,CAAC;IACpD,IAAIA,SAAS,GAAG;QACdC,QAAQC,GAAG,CAACH;IACd,OAAO;QACLE,QAAQE,KAAK,CAACJ;IAChB;IAEA,OAAOK,QAAQC,IAAI,CAACL;AACtB;AAOA;;;;;;CAMC,GACD,MAAMM,qBAAyE;IAC7EC,SAAS;QAAEC,MAAM;QAAUC,UAAU;IAAK;IAC1CC,QAAQ;QAAEF,MAAM;QAAUC,UAAU;IAAK;AAC3C;AAEA,MAAME,gBAAgB,CAACC;IACrB,MAAMC,SAASC,IAAAA,mBAAS,EAAC;QACvBF;QACAG,QAAQ;QACRC,QAAQ;QACRC,SAASX;IACX;IACA,MAAMY,SAAsBL,OAAOK,MAAM;IACzC,MAAMF,SAASH,OAAOG,MAAM;IAE5B,2EAA2E;IAC3E,wCAAwC;IACxC,IAAIG,SAAS;IACb,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,OAAOK,MAAM,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AqB,IAAIA,MAAM,CAAC,qBAAqB;IACzE,IAAI,CAAC2D,QAAQ,OAAOA,SAAS,UAAU;IAEvC,OAAO9B,SAAS8B,MAAM;AACxB;AAKO,SAASvF;IACd,KAAK,MAAMwF,UAAU;QAACrE,QAAQsE,MAAM;QAAEtE,QAAQuE,MAAM;KAAC,CAAE;YACpD,6BAAA;;SAAA,kBAAA,AAACF,OAAeG,OAAO,sBAAvB,8BAAA,gBAAyBC,WAAW,qBAApC,iCAAA,iBAAuC;IAC1C;AACF","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/lib/worker-utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export declare const getFreePort: () => Promise<number>;
|
e-commerce/node_modules/next/dist/server/lib/worker-utils.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
Object.defineProperty(exports, "getFreePort", {
|
| 6 |
+
enumerable: true,
|
| 7 |
+
get: function() {
|
| 8 |
+
return getFreePort;
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
const _http = /*#__PURE__*/ _interop_require_default(require("http"));
|
| 12 |
+
function _interop_require_default(obj) {
|
| 13 |
+
return obj && obj.__esModule ? obj : {
|
| 14 |
+
default: obj
|
| 15 |
+
};
|
| 16 |
+
}
|
| 17 |
+
const getFreePort = async ()=>{
|
| 18 |
+
return new Promise((resolve, reject)=>{
|
| 19 |
+
const server = _http.default.createServer(()=>{});
|
| 20 |
+
server.listen(0, ()=>{
|
| 21 |
+
const address = server.address();
|
| 22 |
+
server.close();
|
| 23 |
+
if (address && typeof address === 'object') {
|
| 24 |
+
resolve(address.port);
|
| 25 |
+
} else {
|
| 26 |
+
reject(new Error('invalid address from server: ' + (address == null ? void 0 : address.toString())));
|
| 27 |
+
}
|
| 28 |
+
});
|
| 29 |
+
});
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
//# sourceMappingURL=worker-utils.js.map
|
e-commerce/node_modules/next/dist/server/lib/worker-utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/server/lib/worker-utils.ts"],"sourcesContent":["import http from 'http'\n\nexport const getFreePort = async (): Promise<number> => {\n return new Promise((resolve, reject) => {\n const server = http.createServer(() => {})\n server.listen(0, () => {\n const address = server.address()\n server.close()\n\n if (address && typeof address === 'object') {\n resolve(address.port)\n } else {\n reject(new Error('invalid address from server: ' + address?.toString()))\n }\n })\n })\n}\n"],"names":["getFreePort","Promise","resolve","reject","server","http","createServer","listen","address","close","port","Error","toString"],"mappings":";;;;+BAEaA;;;eAAAA;;;6DAFI;;;;;;AAEV,MAAMA,cAAc;IACzB,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,MAAMC,SAASC,aAAI,CAACC,YAAY,CAAC,KAAO;QACxCF,OAAOG,MAAM,CAAC,GAAG;YACf,MAAMC,UAAUJ,OAAOI,OAAO;YAC9BJ,OAAOK,KAAK;YAEZ,IAAID,WAAW,OAAOA,YAAY,UAAU;gBAC1CN,QAAQM,QAAQE,IAAI;YACtB,OAAO;gBACLP,OAAO,IAAIQ,MAAM,mCAAkCH,2BAAAA,QAASI,QAAQ;YACtE;QACF;IACF;AACF","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/load-components.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
| 2 |
+
import type { AppType, DocumentType, NextComponentType } from '../shared/lib/utils';
|
| 3 |
+
import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin';
|
| 4 |
+
import type { PageConfig, GetStaticPaths, GetServerSideProps, GetStaticProps } from '../types';
|
| 5 |
+
import type { RouteModule } from './route-modules/route-module';
|
| 6 |
+
import type { BuildManifest } from './get-page-files';
|
| 7 |
+
import type { DeepReadonly } from '../shared/lib/deep-readonly';
|
| 8 |
+
export type ManifestItem = {
|
| 9 |
+
id: number | string;
|
| 10 |
+
files: string[];
|
| 11 |
+
};
|
| 12 |
+
export type ReactLoadableManifest = {
|
| 13 |
+
[moduleId: string]: ManifestItem;
|
| 14 |
+
};
|
| 15 |
+
/**
|
| 16 |
+
* This manifest prevents removing server rendered <link> tags after client
|
| 17 |
+
* navigation. This is only needed under `Pages dir && Production && Webpack`.
|
| 18 |
+
* @see https://github.com/vercel/next.js/pull/72959
|
| 19 |
+
*/
|
| 20 |
+
export type DynamicCssManifest = string[];
|
| 21 |
+
/**
|
| 22 |
+
* A manifest entry type for the react-loadable-manifest.json.
|
| 23 |
+
*
|
| 24 |
+
* The whole manifest.json is a type of `Record<pathname, LoadableManifest>`
|
| 25 |
+
* where pathname is a string-based key points to the path of the page contains
|
| 26 |
+
* each dynamic imports.
|
| 27 |
+
*/
|
| 28 |
+
export interface LoadableManifest {
|
| 29 |
+
[k: string]: {
|
| 30 |
+
id: string | number;
|
| 31 |
+
files: string[];
|
| 32 |
+
};
|
| 33 |
+
}
|
| 34 |
+
export type GenericComponentMod = {
|
| 35 |
+
handler(req: IncomingMessage, res: ServerResponse, ctx: {
|
| 36 |
+
waitUntil?: (prom: Promise<void>) => void;
|
| 37 |
+
}): Promise<void | null>;
|
| 38 |
+
};
|
| 39 |
+
export type LoadComponentsReturnType<NextModule extends GenericComponentMod = GenericComponentMod> = {
|
| 40 |
+
Component: NextComponentType;
|
| 41 |
+
pageConfig: PageConfig;
|
| 42 |
+
buildManifest: DeepReadonly<BuildManifest>;
|
| 43 |
+
subresourceIntegrityManifest?: DeepReadonly<Record<string, string>>;
|
| 44 |
+
reactLoadableManifest: DeepReadonly<ReactLoadableManifest>;
|
| 45 |
+
dynamicCssManifest?: DeepReadonly<DynamicCssManifest>;
|
| 46 |
+
Document: DocumentType;
|
| 47 |
+
App: AppType;
|
| 48 |
+
getStaticProps?: GetStaticProps;
|
| 49 |
+
getStaticPaths?: GetStaticPaths;
|
| 50 |
+
getServerSideProps?: GetServerSideProps;
|
| 51 |
+
ComponentMod: NextModule;
|
| 52 |
+
routeModule: RouteModule;
|
| 53 |
+
isAppPath?: boolean;
|
| 54 |
+
page: string;
|
| 55 |
+
multiZoneDraftMode?: boolean;
|
| 56 |
+
};
|
| 57 |
+
/**
|
| 58 |
+
* Load manifest file with retries, defaults to 3 attempts.
|
| 59 |
+
*/
|
| 60 |
+
export declare function loadManifestWithRetries<T extends object>(manifestPath: string, attempts?: number): Promise<DeepReadonly<T>>;
|
| 61 |
+
/**
|
| 62 |
+
* Load manifest file with retries, defaults to 3 attempts, or return undefined.
|
| 63 |
+
*/
|
| 64 |
+
export declare function tryLoadManifestWithRetries<T extends object>(manifestPath: string, attempts?: number): Promise<DeepReadonly<T> | undefined>;
|
| 65 |
+
/**
|
| 66 |
+
* Load manifest file with retries, defaults to 3 attempts.
|
| 67 |
+
*/
|
| 68 |
+
export declare function evalManifestWithRetries<T extends object>(manifestPath: string, attempts?: number): Promise<DeepReadonly<T>>;
|
| 69 |
+
/**
|
| 70 |
+
* Loads the client reference manifest that the bundler emitted for an app page,
|
| 71 |
+
* or returns undefined if there is none. Both the manifest file and the entry
|
| 72 |
+
* inside it are addressed by the page with `%5F` decoded back to `_`, so
|
| 73 |
+
* callers pass the page as-is and this resolves both.
|
| 74 |
+
*/
|
| 75 |
+
export declare function loadClientReferenceManifestForPage(distDir: string, page: string, attempts?: number): Promise<DeepReadonly<ClientReferenceManifest> | undefined>;
|
| 76 |
+
declare function loadComponentsImpl<N extends GenericComponentMod = GenericComponentMod>({ distDir, page, isAppPath, isDev, sriEnabled, needsManifestsForLegacyReasons, }: {
|
| 77 |
+
distDir: string;
|
| 78 |
+
page: string;
|
| 79 |
+
isAppPath: boolean;
|
| 80 |
+
isDev: boolean;
|
| 81 |
+
sriEnabled: boolean;
|
| 82 |
+
needsManifestsForLegacyReasons: boolean;
|
| 83 |
+
}): Promise<LoadComponentsReturnType<N>>;
|
| 84 |
+
export declare const loadComponents: typeof loadComponentsImpl;
|
| 85 |
+
export {};
|
e-commerce/node_modules/next/dist/server/load-components.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
| 6 |
+
evalManifestWithRetries: null,
|
| 7 |
+
loadClientReferenceManifestForPage: null,
|
| 8 |
+
loadComponents: null,
|
| 9 |
+
loadManifestWithRetries: null,
|
| 10 |
+
tryLoadManifestWithRetries: null
|
| 11 |
+
});
|
| 12 |
+
function _export(target, all) {
|
| 13 |
+
for(var name in all)Object.defineProperty(target, name, {
|
| 14 |
+
enumerable: true,
|
| 15 |
+
get: all[name]
|
| 16 |
+
});
|
| 17 |
+
}
|
| 18 |
+
_export(exports, {
|
| 19 |
+
evalManifestWithRetries: function() {
|
| 20 |
+
return evalManifestWithRetries;
|
| 21 |
+
},
|
| 22 |
+
loadClientReferenceManifestForPage: function() {
|
| 23 |
+
return loadClientReferenceManifestForPage;
|
| 24 |
+
},
|
| 25 |
+
loadComponents: function() {
|
| 26 |
+
return loadComponents;
|
| 27 |
+
},
|
| 28 |
+
loadManifestWithRetries: function() {
|
| 29 |
+
return loadManifestWithRetries;
|
| 30 |
+
},
|
| 31 |
+
tryLoadManifestWithRetries: function() {
|
| 32 |
+
return tryLoadManifestWithRetries;
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
const _constants = require("../shared/lib/constants");
|
| 36 |
+
const _path = require("path");
|
| 37 |
+
const _require = require("./require");
|
| 38 |
+
const _interopdefault = require("../lib/interop-default");
|
| 39 |
+
const _tracer = require("./lib/trace/tracer");
|
| 40 |
+
const _constants1 = require("./lib/trace/constants");
|
| 41 |
+
const _loadmanifestexternal = require("./load-manifest.external");
|
| 42 |
+
const _wait = require("../lib/wait");
|
| 43 |
+
const _manifestssingleton = require("./app-render/manifests-singleton");
|
| 44 |
+
const _normalizepagepath = require("../shared/lib/page-path/normalize-page-path");
|
| 45 |
+
const _ismetadataroute = require("../lib/metadata/is-metadata-route");
|
| 46 |
+
async function loadManifestWithRetries(manifestPath, attempts = 3) {
|
| 47 |
+
while(true){
|
| 48 |
+
try {
|
| 49 |
+
return (0, _loadmanifestexternal.loadManifest)(manifestPath);
|
| 50 |
+
} catch (err) {
|
| 51 |
+
attempts--;
|
| 52 |
+
if (attempts <= 0) throw err;
|
| 53 |
+
await (0, _wait.wait)(100);
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
async function tryLoadManifestWithRetries(manifestPath, attempts = 3) {
|
| 58 |
+
try {
|
| 59 |
+
return await loadManifestWithRetries(manifestPath, attempts);
|
| 60 |
+
} catch (err) {
|
| 61 |
+
return undefined;
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
async function evalManifestWithRetries(manifestPath, attempts = 3) {
|
| 65 |
+
while(true){
|
| 66 |
+
try {
|
| 67 |
+
return (0, _loadmanifestexternal.evalManifest)(manifestPath);
|
| 68 |
+
} catch (err) {
|
| 69 |
+
attempts--;
|
| 70 |
+
if (attempts <= 0) throw err;
|
| 71 |
+
await (0, _wait.wait)(100);
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
async function loadClientReferenceManifestForPage(distDir, page, attempts) {
|
| 76 |
+
const entryName = page.replace(/%5F/g, '_');
|
| 77 |
+
const manifestPath = (0, _path.join)(/* turbopackIgnore: true */ distDir, 'server', 'app', entryName + '_' + _constants.CLIENT_REFERENCE_MANIFEST + '.js');
|
| 78 |
+
try {
|
| 79 |
+
const context = await evalManifestWithRetries(manifestPath, attempts);
|
| 80 |
+
return context.__RSC_MANIFEST[entryName];
|
| 81 |
+
} catch (err) {
|
| 82 |
+
return undefined;
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
function loadRouteModule(page, distDir, isAppPath) {
|
| 86 |
+
return (0, _tracer.getTracer)().trace(_constants1.LoadComponentsSpan.loadRouteModule, {
|
| 87 |
+
spanName: 'load route module'
|
| 88 |
+
}, ()=>(0, _require.requirePage)(page, distDir, isAppPath));
|
| 89 |
+
}
|
| 90 |
+
async function loadComponentsImpl({ distDir, page, isAppPath, isDev, sriEnabled, // When route modules are used, which is the case for the server calls to loadComponents, it no longer needs manifest to be loaded here.
|
| 91 |
+
// Static generation still needs the manifests to be loaded here.
|
| 92 |
+
// In the future static generation will also use route modules, and we will remove this flag.
|
| 93 |
+
needsManifestsForLegacyReasons }) {
|
| 94 |
+
let DocumentMod = {};
|
| 95 |
+
let AppMod = {};
|
| 96 |
+
if (!isAppPath) {
|
| 97 |
+
;
|
| 98 |
+
[DocumentMod, AppMod] = await Promise.all([
|
| 99 |
+
(0, _require.requirePage)('/_document', distDir, false),
|
| 100 |
+
(0, _require.requirePage)('/_app', distDir, false)
|
| 101 |
+
]);
|
| 102 |
+
}
|
| 103 |
+
if (needsManifestsForLegacyReasons) {
|
| 104 |
+
// In dev mode we retry loading a manifest file to handle a race condition
|
| 105 |
+
// that can occur while app and pages are compiling at the same time, and the
|
| 106 |
+
// build-manifest is still being written to disk while an app path is
|
| 107 |
+
// attempting to load.
|
| 108 |
+
const manifestLoadAttempts = isDev ? 3 : 1;
|
| 109 |
+
let reactLoadableManifestPath;
|
| 110 |
+
if (!process.env.TURBOPACK) {
|
| 111 |
+
reactLoadableManifestPath = (0, _path.join)(/* turbopackIgnore: true */ distDir, _constants.REACT_LOADABLE_MANIFEST);
|
| 112 |
+
} else if (isAppPath) {
|
| 113 |
+
reactLoadableManifestPath = (0, _path.join)(/* turbopackIgnore: true */ distDir, 'server', 'app', page, _constants.REACT_LOADABLE_MANIFEST);
|
| 114 |
+
} else {
|
| 115 |
+
reactLoadableManifestPath = (0, _path.join)(/* turbopackIgnore: true */ distDir, 'server', 'pages', (0, _normalizepagepath.normalizePagePath)(page), _constants.REACT_LOADABLE_MANIFEST);
|
| 116 |
+
}
|
| 117 |
+
// Make sure to avoid loading the manifest for static metadata routes for better performance.
|
| 118 |
+
const hasClientManifest = !(0, _ismetadataroute.isStaticMetadataRoute)(page);
|
| 119 |
+
// Load the manifest files first
|
| 120 |
+
//
|
| 121 |
+
// Loading page-specific manifests shouldn't throw an error if the manifest couldn't be found, so
|
| 122 |
+
// that the `requirePage` call below will throw the correct error in that case
|
| 123 |
+
// (a `PageNotFoundError`).
|
| 124 |
+
const [buildManifest, reactLoadableManifest, dynamicCssManifest, clientReferenceManifest, serverActionsManifest, subresourceIntegrityManifest] = await Promise.all([
|
| 125 |
+
loadManifestWithRetries((0, _path.join)(/* turbopackIgnore: true */ distDir, _constants.BUILD_MANIFEST), manifestLoadAttempts),
|
| 126 |
+
tryLoadManifestWithRetries(reactLoadableManifestPath, manifestLoadAttempts),
|
| 127 |
+
// This manifest will only exist in Pages dir && Production && Webpack.
|
| 128 |
+
isAppPath || process.env.TURBOPACK ? undefined : loadManifestWithRetries((0, _path.join)(/* turbopackIgnore: true */ distDir, `${_constants.DYNAMIC_CSS_MANIFEST}.json`), manifestLoadAttempts).catch(()=>undefined),
|
| 129 |
+
isAppPath && hasClientManifest ? loadClientReferenceManifestForPage(distDir, page, manifestLoadAttempts) : undefined,
|
| 130 |
+
isAppPath ? loadManifestWithRetries((0, _path.join)(/* turbopackIgnore: true */ distDir, 'server', _constants.SERVER_REFERENCE_MANIFEST + '.json'), manifestLoadAttempts).catch(()=>null) : null,
|
| 131 |
+
sriEnabled ? loadManifestWithRetries((0, _path.join)(/* turbopackIgnore: true */ distDir, 'server', _constants.SUBRESOURCE_INTEGRITY_MANIFEST + '.json')).catch(()=>undefined) : undefined
|
| 132 |
+
]);
|
| 133 |
+
// Before requiring the actual page module, we have to set the reference
|
| 134 |
+
// manifests to our global store so Server Action's encryption util can access
|
| 135 |
+
// to them at the top level of the page module.
|
| 136 |
+
if (serverActionsManifest && clientReferenceManifest) {
|
| 137 |
+
(0, _manifestssingleton.setManifestsSingleton)({
|
| 138 |
+
page,
|
| 139 |
+
clientReferenceManifest,
|
| 140 |
+
serverActionsManifest
|
| 141 |
+
});
|
| 142 |
+
}
|
| 143 |
+
const ComponentMod = await loadRouteModule(page, distDir, isAppPath);
|
| 144 |
+
const Component = (0, _interopdefault.interopDefault)(ComponentMod);
|
| 145 |
+
const Document = (0, _interopdefault.interopDefault)(DocumentMod);
|
| 146 |
+
const App = (0, _interopdefault.interopDefault)(AppMod);
|
| 147 |
+
const { getServerSideProps, getStaticProps, getStaticPaths, routeModule } = ComponentMod;
|
| 148 |
+
return {
|
| 149 |
+
// @ts-expect-error this is indeed `{} || AppType` and not always `AppType`
|
| 150 |
+
App,
|
| 151 |
+
// @ts-expect-error this is indeed `{} || DocumentType` and not always `DocumentType`
|
| 152 |
+
Document,
|
| 153 |
+
Component,
|
| 154 |
+
buildManifest,
|
| 155 |
+
subresourceIntegrityManifest,
|
| 156 |
+
reactLoadableManifest: reactLoadableManifest || {},
|
| 157 |
+
dynamicCssManifest,
|
| 158 |
+
pageConfig: ComponentMod.config || {},
|
| 159 |
+
ComponentMod,
|
| 160 |
+
getServerSideProps,
|
| 161 |
+
getStaticProps,
|
| 162 |
+
getStaticPaths,
|
| 163 |
+
isAppPath,
|
| 164 |
+
page,
|
| 165 |
+
routeModule
|
| 166 |
+
};
|
| 167 |
+
} else {
|
| 168 |
+
const ComponentMod = await loadRouteModule(page, distDir, isAppPath);
|
| 169 |
+
const Component = (0, _interopdefault.interopDefault)(ComponentMod);
|
| 170 |
+
const Document = (0, _interopdefault.interopDefault)(DocumentMod);
|
| 171 |
+
const App = (0, _interopdefault.interopDefault)(AppMod);
|
| 172 |
+
const { getServerSideProps, getStaticProps, getStaticPaths, routeModule } = ComponentMod;
|
| 173 |
+
return {
|
| 174 |
+
App,
|
| 175 |
+
Document,
|
| 176 |
+
Component,
|
| 177 |
+
pageConfig: ComponentMod.config || {},
|
| 178 |
+
ComponentMod,
|
| 179 |
+
getServerSideProps,
|
| 180 |
+
getStaticProps,
|
| 181 |
+
getStaticPaths,
|
| 182 |
+
isAppPath,
|
| 183 |
+
page,
|
| 184 |
+
routeModule
|
| 185 |
+
}; // temporary `as any` to make TypeScript not fail so that the tests will run on the PR.
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
const loadComponents = (0, _tracer.getTracer)().wrap(_constants1.LoadComponentsSpan.loadComponents, loadComponentsImpl);
|
| 189 |
+
|
| 190 |
+
//# sourceMappingURL=load-components.js.map
|
e-commerce/node_modules/next/dist/server/load-components.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/server/load-components.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type {\n AppType,\n DocumentType,\n NextComponentType,\n} from '../shared/lib/utils'\nimport type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin'\nimport type {\n PageConfig,\n GetStaticPaths,\n GetServerSideProps,\n GetStaticProps,\n} from '../types'\nimport type { RouteModule } from './route-modules/route-module'\nimport type { BuildManifest } from './get-page-files'\nimport type { ActionManifest } from '../build/webpack/plugins/flight-client-entry-plugin'\n\nimport {\n BUILD_MANIFEST,\n REACT_LOADABLE_MANIFEST,\n CLIENT_REFERENCE_MANIFEST,\n SERVER_REFERENCE_MANIFEST,\n DYNAMIC_CSS_MANIFEST,\n SUBRESOURCE_INTEGRITY_MANIFEST,\n} from '../shared/lib/constants'\nimport { join } from 'path'\nimport { requirePage } from './require'\nimport { interopDefault } from '../lib/interop-default'\nimport { getTracer } from './lib/trace/tracer'\nimport { LoadComponentsSpan } from './lib/trace/constants'\nimport { evalManifest, loadManifest } from './load-manifest.external'\nimport { wait } from '../lib/wait'\nimport { setManifestsSingleton } from './app-render/manifests-singleton'\nimport type { DeepReadonly } from '../shared/lib/deep-readonly'\nimport { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'\nimport { isStaticMetadataRoute } from '../lib/metadata/is-metadata-route'\n\nexport type ManifestItem = {\n id: number | string\n files: string[]\n}\n\nexport type ReactLoadableManifest = { [moduleId: string]: ManifestItem }\n/**\n * This manifest prevents removing server rendered <link> tags after client\n * navigation. This is only needed under `Pages dir && Production && Webpack`.\n * @see https://github.com/vercel/next.js/pull/72959\n */\nexport type DynamicCssManifest = string[]\n\n/**\n * A manifest entry type for the react-loadable-manifest.json.\n *\n * The whole manifest.json is a type of `Record<pathname, LoadableManifest>`\n * where pathname is a string-based key points to the path of the page contains\n * each dynamic imports.\n */\nexport interface LoadableManifest {\n [k: string]: { id: string | number; files: string[] }\n}\n\nexport type GenericComponentMod = {\n handler(\n req: IncomingMessage,\n res: ServerResponse,\n ctx: {\n waitUntil?: (prom: Promise<void>) => void\n }\n ): Promise<void | null>\n}\n\nexport type LoadComponentsReturnType<\n NextModule extends GenericComponentMod = GenericComponentMod,\n> = {\n Component: NextComponentType\n pageConfig: PageConfig\n buildManifest: DeepReadonly<BuildManifest>\n subresourceIntegrityManifest?: DeepReadonly<Record<string, string>>\n reactLoadableManifest: DeepReadonly<ReactLoadableManifest>\n dynamicCssManifest?: DeepReadonly<DynamicCssManifest>\n Document: DocumentType\n App: AppType\n getStaticProps?: GetStaticProps\n getStaticPaths?: GetStaticPaths\n getServerSideProps?: GetServerSideProps\n ComponentMod: NextModule\n routeModule: RouteModule\n isAppPath?: boolean\n page: string\n multiZoneDraftMode?: boolean\n}\n\n/**\n * Load manifest file with retries, defaults to 3 attempts.\n */\nexport async function loadManifestWithRetries<T extends object>(\n manifestPath: string,\n attempts = 3\n) {\n while (true) {\n try {\n return loadManifest<T>(manifestPath)\n } catch (err) {\n attempts--\n if (attempts <= 0) throw err\n\n await wait(100)\n }\n }\n}\n\n/**\n * Load manifest file with retries, defaults to 3 attempts, or return undefined.\n */\nexport async function tryLoadManifestWithRetries<T extends object>(\n manifestPath: string,\n attempts = 3\n) {\n try {\n return await loadManifestWithRetries<T>(manifestPath, attempts)\n } catch (err) {\n return undefined\n }\n}\n\n/**\n * Load manifest file with retries, defaults to 3 attempts.\n */\nexport async function evalManifestWithRetries<T extends object>(\n manifestPath: string,\n attempts = 3\n) {\n while (true) {\n try {\n return evalManifest<T>(manifestPath)\n } catch (err) {\n attempts--\n if (attempts <= 0) throw err\n\n await wait(100)\n }\n }\n}\n\n/**\n * Loads the client reference manifest that the bundler emitted for an app page,\n * or returns undefined if there is none. Both the manifest file and the entry\n * inside it are addressed by the page with `%5F` decoded back to `_`, so\n * callers pass the page as-is and this resolves both.\n */\nexport async function loadClientReferenceManifestForPage(\n distDir: string,\n page: string,\n attempts?: number\n): Promise<DeepReadonly<ClientReferenceManifest> | undefined> {\n const entryName = page.replace(/%5F/g, '_')\n\n const manifestPath = join(\n /* turbopackIgnore: true */ distDir,\n 'server',\n 'app',\n entryName + '_' + CLIENT_REFERENCE_MANIFEST + '.js'\n )\n\n try {\n const context = await evalManifestWithRetries<{\n __RSC_MANIFEST: { [key: string]: ClientReferenceManifest }\n }>(manifestPath, attempts)\n return context.__RSC_MANIFEST[entryName]\n } catch (err) {\n return undefined\n }\n}\n\nfunction loadRouteModule(page: string, distDir: string, isAppPath: boolean) {\n return getTracer().trace(\n LoadComponentsSpan.loadRouteModule,\n { spanName: 'load route module' },\n () => requirePage(page, distDir, isAppPath)\n )\n}\n\nasync function loadComponentsImpl<\n N extends GenericComponentMod = GenericComponentMod,\n>({\n distDir,\n page,\n isAppPath,\n isDev,\n sriEnabled,\n // When route modules are used, which is the case for the server calls to loadComponents, it no longer needs manifest to be loaded here.\n // Static generation still needs the manifests to be loaded here.\n // In the future static generation will also use route modules, and we will remove this flag.\n needsManifestsForLegacyReasons,\n}: {\n distDir: string\n page: string\n isAppPath: boolean\n isDev: boolean\n sriEnabled: boolean\n needsManifestsForLegacyReasons: boolean\n}): Promise<LoadComponentsReturnType<N>> {\n let DocumentMod = {}\n let AppMod = {}\n if (!isAppPath) {\n ;[DocumentMod, AppMod] = await Promise.all([\n requirePage('/_document', distDir, false),\n requirePage('/_app', distDir, false),\n ])\n }\n\n if (needsManifestsForLegacyReasons) {\n // In dev mode we retry loading a manifest file to handle a race condition\n // that can occur while app and pages are compiling at the same time, and the\n // build-manifest is still being written to disk while an app path is\n // attempting to load.\n const manifestLoadAttempts = isDev ? 3 : 1\n\n let reactLoadableManifestPath: string\n if (!process.env.TURBOPACK) {\n reactLoadableManifestPath = join(\n /* turbopackIgnore: true */ distDir,\n REACT_LOADABLE_MANIFEST\n )\n } else if (isAppPath) {\n reactLoadableManifestPath = join(\n /* turbopackIgnore: true */ distDir,\n 'server',\n 'app',\n page,\n REACT_LOADABLE_MANIFEST\n )\n } else {\n reactLoadableManifestPath = join(\n /* turbopackIgnore: true */ distDir,\n 'server',\n 'pages',\n normalizePagePath(page),\n REACT_LOADABLE_MANIFEST\n )\n }\n\n // Make sure to avoid loading the manifest for static metadata routes for better performance.\n const hasClientManifest = !isStaticMetadataRoute(page)\n\n // Load the manifest files first\n //\n // Loading page-specific manifests shouldn't throw an error if the manifest couldn't be found, so\n // that the `requirePage` call below will throw the correct error in that case\n // (a `PageNotFoundError`).\n const [\n buildManifest,\n reactLoadableManifest,\n dynamicCssManifest,\n clientReferenceManifest,\n serverActionsManifest,\n subresourceIntegrityManifest,\n ] = await Promise.all([\n loadManifestWithRetries<BuildManifest>(\n join(/* turbopackIgnore: true */ distDir, BUILD_MANIFEST),\n manifestLoadAttempts\n ),\n tryLoadManifestWithRetries<ReactLoadableManifest>(\n reactLoadableManifestPath,\n manifestLoadAttempts\n ),\n // This manifest will only exist in Pages dir && Production && Webpack.\n isAppPath || process.env.TURBOPACK\n ? undefined\n : loadManifestWithRetries<DynamicCssManifest>(\n join(\n /* turbopackIgnore: true */ distDir,\n `${DYNAMIC_CSS_MANIFEST}.json`\n ),\n manifestLoadAttempts\n ).catch(() => undefined),\n isAppPath && hasClientManifest\n ? loadClientReferenceManifestForPage(\n distDir,\n page,\n manifestLoadAttempts\n )\n : undefined,\n isAppPath\n ? loadManifestWithRetries<ActionManifest>(\n join(\n /* turbopackIgnore: true */ distDir,\n 'server',\n SERVER_REFERENCE_MANIFEST + '.json'\n ),\n manifestLoadAttempts\n ).catch(() => null)\n : null,\n sriEnabled\n ? loadManifestWithRetries<DeepReadonly<Record<string, string>>>(\n join(\n /* turbopackIgnore: true */ distDir,\n 'server',\n SUBRESOURCE_INTEGRITY_MANIFEST + '.json'\n )\n ).catch(() => undefined)\n : undefined,\n ])\n\n // Before requiring the actual page module, we have to set the reference\n // manifests to our global store so Server Action's encryption util can access\n // to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page,\n clientReferenceManifest,\n serverActionsManifest,\n })\n }\n\n const ComponentMod = await loadRouteModule(page, distDir, isAppPath)\n\n const Component = interopDefault(ComponentMod)\n const Document = interopDefault(DocumentMod)\n const App = interopDefault(AppMod)\n\n const { getServerSideProps, getStaticProps, getStaticPaths, routeModule } =\n ComponentMod\n\n return {\n // @ts-expect-error this is indeed `{} || AppType` and not always `AppType`\n App,\n // @ts-expect-error this is indeed `{} || DocumentType` and not always `DocumentType`\n Document,\n Component,\n buildManifest,\n subresourceIntegrityManifest,\n reactLoadableManifest: reactLoadableManifest || {},\n dynamicCssManifest,\n pageConfig: ComponentMod.config || {},\n ComponentMod,\n getServerSideProps,\n getStaticProps,\n getStaticPaths,\n isAppPath,\n page,\n routeModule,\n }\n } else {\n const ComponentMod = await loadRouteModule(page, distDir, isAppPath)\n\n const Component = interopDefault(ComponentMod)\n const Document = interopDefault(DocumentMod)\n const App = interopDefault(AppMod)\n\n const { getServerSideProps, getStaticProps, getStaticPaths, routeModule } =\n ComponentMod\n\n return {\n App,\n Document,\n Component,\n pageConfig: ComponentMod.config || {},\n ComponentMod,\n getServerSideProps,\n getStaticProps,\n getStaticPaths,\n isAppPath,\n page,\n routeModule,\n } as any // temporary `as any` to make TypeScript not fail so that the tests will run on the PR.\n }\n}\n\nexport const loadComponents = getTracer().wrap(\n LoadComponentsSpan.loadComponents,\n loadComponentsImpl\n)\n"],"names":["evalManifestWithRetries","loadClientReferenceManifestForPage","loadComponents","loadManifestWithRetries","tryLoadManifestWithRetries","manifestPath","attempts","loadManifest","err","wait","undefined","evalManifest","distDir","page","entryName","replace","join","CLIENT_REFERENCE_MANIFEST","context","__RSC_MANIFEST","loadRouteModule","isAppPath","getTracer","trace","LoadComponentsSpan","spanName","requirePage","loadComponentsImpl","isDev","sriEnabled","needsManifestsForLegacyReasons","DocumentMod","AppMod","Promise","all","manifestLoadAttempts","reactLoadableManifestPath","process","env","TURBOPACK","REACT_LOADABLE_MANIFEST","normalizePagePath","hasClientManifest","isStaticMetadataRoute","buildManifest","reactLoadableManifest","dynamicCssManifest","clientReferenceManifest","serverActionsManifest","subresourceIntegrityManifest","BUILD_MANIFEST","DYNAMIC_CSS_MANIFEST","catch","SERVER_REFERENCE_MANIFEST","SUBRESOURCE_INTEGRITY_MANIFEST","setManifestsSingleton","ComponentMod","Component","interopDefault","Document","App","getServerSideProps","getStaticProps","getStaticPaths","routeModule","pageConfig","config","wrap"],"mappings":";;;;;;;;;;;;;;;;;;IAgIsBA,uBAAuB;eAAvBA;;IAsBAC,kCAAkC;eAAlCA;;IA2NTC,cAAc;eAAdA;;IAlRSC,uBAAuB;eAAvBA;;IAmBAC,0BAA0B;eAA1BA;;;2BA1Ff;sBACc;yBACO;gCACG;wBACL;4BACS;sCACQ;sBACtB;oCACiB;mCAEJ;iCACI;AA4D/B,eAAeD,wBACpBE,YAAoB,EACpBC,WAAW,CAAC;IAEZ,MAAO,KAAM;QACX,IAAI;YACF,OAAOC,IAAAA,kCAAY,EAAIF;QACzB,EAAE,OAAOG,KAAK;YACZF;YACA,IAAIA,YAAY,GAAG,MAAME;YAEzB,MAAMC,IAAAA,UAAI,EAAC;QACb;IACF;AACF;AAKO,eAAeL,2BACpBC,YAAoB,EACpBC,WAAW,CAAC;IAEZ,IAAI;QACF,OAAO,MAAMH,wBAA2BE,cAAcC;IACxD,EAAE,OAAOE,KAAK;QACZ,OAAOE;IACT;AACF;AAKO,eAAeV,wBACpBK,YAAoB,EACpBC,WAAW,CAAC;IAEZ,MAAO,KAAM;QACX,IAAI;YACF,OAAOK,IAAAA,kCAAY,EAAIN;QACzB,EAAE,OAAOG,KAAK;YACZF;YACA,IAAIA,YAAY,GAAG,MAAME;YAEzB,MAAMC,IAAAA,UAAI,EAAC;QACb;IACF;AACF;AAQO,eAAeR,mCACpBW,OAAe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EAACF;QACjC,MAAMG,WAAWD,IAAAA,8BAAc,EAAC3B;QAChC,MAAM6B,MAAMF,IAAAA,8BAAc,EAAC1B;QAE3B,MAAM,EAAE6B,kBAAkB,EAAEC,cAAc,EAAEC,cAAc,EAAEC,WAAW,EAAE,GACvER;QAEF,OAAO;YACL,2EAA2E;YAC3EI;YACA,qFAAqF;YACrFD;YACAF;YACAb;YACAK;YACAJ,uBAAuBA,yBAAyB,CAAC;YACjDC;YACAmB,YAAYT,aAAaU,MAAM,IAAI,CAAC;YACpCV;YACAK;YACAC;YACAC;YACA1C;YACAR;YACAmD;QACF;IACF,OAAO;QACL,MAAMR,eAAe,MAAMpC,gBAAgBP,MAAMD,SAASS;QAE1D,MAAMoC,YAAYC,IAAAA,8BAAc,EAACF;QACjC,MAAMG,WAAWD,IAAAA,8BAAc,EAAC3B;QAChC,MAAM6B,MAAMF,IAAAA,8BAAc,EAAC1B;QAE3B,MAAM,EAAE6B,kBAAkB,EAAEC,cAAc,EAAEC,cAAc,EAAEC,WAAW,EAAE,GACvER;QAEF,OAAO;YACLI;YACAD;YACAF;YACAQ,YAAYT,aAAaU,MAAM,IAAI,CAAC;YACpCV;YACAK;YACAC;YACAC;YACA1C;YACAR;YACAmD;QACF,GAAS,uFAAuF;IAClG;AACF;AAEO,MAAM9D,iBAAiBoB,IAAAA,iBAAS,IAAG6C,IAAI,CAC5C3C,8BAAkB,CAACtB,cAAc,EACjCyB","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/load-default-error-components.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { type LoadComponentsReturnType } from './load-components';
|
| 2 |
+
export type ManifestItem = {
|
| 3 |
+
id: number | string;
|
| 4 |
+
files: string[];
|
| 5 |
+
};
|
| 6 |
+
export type ReactLoadableManifest = {
|
| 7 |
+
[moduleId: string]: ManifestItem;
|
| 8 |
+
};
|
| 9 |
+
export type ErrorModule = typeof import('./route-modules/pages/builtin/_error');
|
| 10 |
+
declare function loadDefaultErrorComponentsImpl(distDir: string): Promise<LoadComponentsReturnType<ErrorModule>>;
|
| 11 |
+
export declare const loadDefaultErrorComponents: typeof loadDefaultErrorComponentsImpl;
|
| 12 |
+
export {};
|
e-commerce/node_modules/next/dist/server/load-default-error-components.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", {
|
| 3 |
+
value: true
|
| 4 |
+
});
|
| 5 |
+
Object.defineProperty(exports, "loadDefaultErrorComponents", {
|
| 6 |
+
enumerable: true,
|
| 7 |
+
get: function() {
|
| 8 |
+
return loadDefaultErrorComponents;
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
const _constants = require("../shared/lib/constants");
|
| 12 |
+
const _path = require("path");
|
| 13 |
+
const _interopdefault = require("../lib/interop-default");
|
| 14 |
+
const _tracer = require("./lib/trace/tracer");
|
| 15 |
+
const _constants1 = require("./lib/trace/constants");
|
| 16 |
+
const _loadcomponents = require("./load-components");
|
| 17 |
+
async function loadDefaultErrorComponentsImpl(distDir) {
|
| 18 |
+
// eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?
|
| 19 |
+
const Document = (0, _interopdefault.interopDefault)(require('next/dist/pages/_document'));
|
| 20 |
+
// eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?
|
| 21 |
+
const AppMod = require('next/dist/pages/_app');
|
| 22 |
+
const App = (0, _interopdefault.interopDefault)(AppMod);
|
| 23 |
+
// Load the compiled route module for this builtin error.
|
| 24 |
+
// TODO: (wyattjoh) replace this with just exporting the route module when the transition is complete
|
| 25 |
+
const ComponentMod = require('./route-modules/pages/builtin/_error');
|
| 26 |
+
const Component = ComponentMod.routeModule.userland.default;
|
| 27 |
+
return {
|
| 28 |
+
App,
|
| 29 |
+
Document,
|
| 30 |
+
Component,
|
| 31 |
+
pageConfig: {},
|
| 32 |
+
buildManifest: await (0, _loadcomponents.loadManifestWithRetries)((0, _path.join)(distDir, `fallback-${_constants.BUILD_MANIFEST}`)),
|
| 33 |
+
reactLoadableManifest: {},
|
| 34 |
+
ComponentMod,
|
| 35 |
+
page: '/_error',
|
| 36 |
+
routeModule: ComponentMod.routeModule
|
| 37 |
+
};
|
| 38 |
+
}
|
| 39 |
+
const loadDefaultErrorComponents = (0, _tracer.getTracer)().wrap(_constants1.LoadComponentsSpan.loadDefaultErrorComponents, loadDefaultErrorComponentsImpl);
|
| 40 |
+
|
| 41 |
+
//# sourceMappingURL=load-default-error-components.js.map
|
e-commerce/node_modules/next/dist/server/load-default-error-components.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/server/load-default-error-components.ts"],"sourcesContent":["import type { BuildManifest } from './get-page-files'\n\nimport { BUILD_MANIFEST } from '../shared/lib/constants'\nimport { join } from 'path'\nimport { interopDefault } from '../lib/interop-default'\nimport { getTracer } from './lib/trace/tracer'\nimport { LoadComponentsSpan } from './lib/trace/constants'\nimport {\n loadManifestWithRetries,\n type LoadComponentsReturnType,\n} from './load-components'\nexport type ManifestItem = {\n id: number | string\n files: string[]\n}\n\nexport type ReactLoadableManifest = { [moduleId: string]: ManifestItem }\n\nexport type ErrorModule = typeof import('./route-modules/pages/builtin/_error')\n\nasync function loadDefaultErrorComponentsImpl(\n distDir: string\n): Promise<LoadComponentsReturnType<ErrorModule>> {\n // eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?\n const Document = interopDefault(require('next/dist/pages/_document'))\n // eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?\n const AppMod = require('next/dist/pages/_app')\n const App = interopDefault(AppMod)\n\n // Load the compiled route module for this builtin error.\n // TODO: (wyattjoh) replace this with just exporting the route module when the transition is complete\n const ComponentMod =\n require('./route-modules/pages/builtin/_error') as typeof import('./route-modules/pages/builtin/_error')\n const Component = ComponentMod.routeModule.userland.default\n\n return {\n App,\n Document,\n Component,\n pageConfig: {},\n buildManifest: (await loadManifestWithRetries(\n join(distDir, `fallback-${BUILD_MANIFEST}`)\n )) as BuildManifest,\n reactLoadableManifest: {},\n ComponentMod,\n page: '/_error',\n routeModule: ComponentMod.routeModule,\n }\n}\nexport const loadDefaultErrorComponents = getTracer().wrap(\n LoadComponentsSpan.loadDefaultErrorComponents,\n loadDefaultErrorComponentsImpl\n)\n"],"names":["loadDefaultErrorComponents","loadDefaultErrorComponentsImpl","distDir","Document","interopDefault","require","AppMod","App","ComponentMod","Component","routeModule","userland","default","pageConfig","buildManifest","loadManifestWithRetries","join","BUILD_MANIFEST","reactLoadableManifest","page","getTracer","wrap","LoadComponentsSpan"],"mappings":";;;;+BAiDaA;;;eAAAA;;;2BA/CkB;sBACV;gCACU;wBACL;4BACS;gCAI5B;AAUP,eAAeC,+BACbC,OAAe;IAEf,2FAA2F;IAC3F,MAAMC,WAAWC,IAAAA,8BAAc,EAACC,QAAQ;IACxC,2FAA2F;IAC3F,MAAMC,SAASD,QAAQ;IACvB,MAAME,MAAMH,IAAAA,8BAAc,EAACE;IAE3B,yDAAyD;IACzD,qGAAqG;IACrG,MAAME,eACJH,QAAQ;IACV,MAAMI,YAAYD,aAAaE,WAAW,CAACC,QAAQ,CAACC,OAAO;IAE3D,OAAO;QACLL;QACAJ;QACAM;QACAI,YAAY,CAAC;QACbC,eAAgB,MAAMC,IAAAA,uCAAuB,EAC3CC,IAAAA,UAAI,EAACd,SAAS,CAAC,SAAS,EAAEe,yBAAc,EAAE;QAE5CC,uBAAuB,CAAC;QACxBV;QACAW,MAAM;QACNT,aAAaF,aAAaE,WAAW;IACvC;AACF;AACO,MAAMV,6BAA6BoB,IAAAA,iBAAS,IAAGC,IAAI,CACxDC,8BAAkB,CAACtB,0BAA0B,EAC7CC","ignoreList":[0]}
|
e-commerce/node_modules/next/dist/server/load-manifest.external.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { DeepReadonly } from '../shared/lib/deep-readonly';
|
| 2 |
+
/**
|
| 3 |
+
* Load a manifest file from the file system. Optionally cache the manifest in
|
| 4 |
+
* memory to avoid reading the file multiple times using the provided cache or
|
| 5 |
+
* defaulting to a shared module cache. The manifest is frozen to prevent
|
| 6 |
+
* modifications if it is cached.
|
| 7 |
+
*
|
| 8 |
+
* @param path the path to the manifest file
|
| 9 |
+
* @param shouldCache whether to cache the manifest in memory
|
| 10 |
+
* @param cache the cache to use for storing the manifest
|
| 11 |
+
* @returns the manifest object
|
| 12 |
+
*/
|
| 13 |
+
export declare function loadManifest<T extends object>(path: string, shouldCache: false): T;
|
| 14 |
+
export declare function loadManifest<T extends object>(path: string, shouldCache?: boolean, cache?: Map<string, unknown>, skipParse?: boolean): DeepReadonly<T>;
|
| 15 |
+
export declare function loadManifest<T extends object>(path: string, shouldCache?: boolean, cache?: Map<string, unknown>, skipParse?: boolean, handleMissing?: boolean): DeepReadonly<T | undefined>;
|
| 16 |
+
export declare function evalManifest<T extends object>(path: string, shouldCache: false): T;
|
| 17 |
+
export declare function evalManifest<T extends object>(path: string, shouldCache?: true, cache?: Map<string, unknown>): DeepReadonly<T>;
|
| 18 |
+
export declare function evalManifest<T extends object>(path: string, shouldCache?: boolean, cache?: Map<string, unknown>, handleMissing?: boolean): DeepReadonly<T | undefined>;
|
| 19 |
+
export declare function evalManifestFromRelativePath<T extends object>({ projectDir, distDir, manifest, shouldCache, cache, handleMissing, }: {
|
| 20 |
+
projectDir: string;
|
| 21 |
+
distDir: string;
|
| 22 |
+
manifest: string;
|
| 23 |
+
shouldCache: boolean;
|
| 24 |
+
cache?: Map<string, unknown>;
|
| 25 |
+
skipParse?: boolean;
|
| 26 |
+
handleMissing?: boolean;
|
| 27 |
+
}): DeepReadonly<T | undefined>;
|
| 28 |
+
export declare function loadManifestFromRelativePath<T extends object>({ projectDir, distDir, manifest, shouldCache, cache, skipParse, handleMissing, }: {
|
| 29 |
+
projectDir: string;
|
| 30 |
+
distDir: string;
|
| 31 |
+
manifest: string;
|
| 32 |
+
shouldCache: boolean;
|
| 33 |
+
cache?: Map<string, unknown>;
|
| 34 |
+
skipParse?: boolean;
|
| 35 |
+
handleMissing?: false | undefined;
|
| 36 |
+
}): DeepReadonly<T>;
|
| 37 |
+
export declare function loadManifestFromRelativePath<T extends object>({ projectDir, distDir, manifest, shouldCache, cache, skipParse, handleMissing, }: {
|
| 38 |
+
projectDir: string;
|
| 39 |
+
distDir: string;
|
| 40 |
+
manifest: string;
|
| 41 |
+
shouldCache: boolean;
|
| 42 |
+
cache?: Map<string, unknown>;
|
| 43 |
+
skipParse?: boolean;
|
| 44 |
+
handleMissing: true;
|
| 45 |
+
}): DeepReadonly<T | undefined>;
|
| 46 |
+
export declare function clearManifestCache(path: string, cache?: Map<string, unknown>): boolean;
|