next 15.2.0-canary.47 → 15.2.0-canary.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of next might be problematic. Click here for more details.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/app-dir/link.d.ts +108 -28
- package/dist/client/app-dir/link.js +6 -4
- package/dist/client/app-dir/link.js.map +1 -1
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +3 -2
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +8 -6
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
- package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +2 -3
- package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
- package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js +39 -13
- package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
- package/dist/client/components/react-dev-overlay/server/middleware-webpack.js +13 -3
- package/dist/client/components/react-dev-overlay/server/middleware-webpack.js.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/app-page.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +6 -6
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/app-dir/link.js +6 -4
- package/dist/esm/client/app-dir/link.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +3 -2
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +8 -6
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +2 -3
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js +39 -13
- package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/server/middleware-webpack.js +13 -3
- package/dist/esm/client/components/react-dev-overlay/server/middleware-webpack.js.map +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/metadata/types/metadata-interface.js +13 -1
- package/dist/esm/lib/metadata/types/metadata-interface.js.map +1 -1
- package/dist/esm/server/config.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/patch-error-inspect.js +42 -15
- package/dist/esm/server/patch-error-inspect.js.map +1 -1
- package/dist/lib/metadata/types/metadata-interface.d.ts +252 -179
- package/dist/lib/metadata/types/metadata-interface.js +13 -1
- package/dist/lib/metadata/types/metadata-interface.js.map +1 -1
- package/dist/server/config.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/patch-error-inspect.js +42 -15
- package/dist/server/patch-error-inspect.js.map +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n jsonString,\n noContent,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\n\nimport fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } from '../internal/helpers/launchEditor'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { SourceMapConsumer } from 'next/dist/compiled/source-map08'\nimport type { Project, TurbopackStackFrame } from '../../../../build/swc/types'\nimport { getSourceMapFromFile } from '../internal/helpers/get-source-map-from-file'\nimport { findSourceMap, type SourceMapPayload } from 'node:module'\nimport { pathToFileURL } from 'node:url'\nimport { inspect } from 'node:util'\n\nfunction shouldIgnorePath(modulePath: string): boolean {\n return (\n modulePath.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n modulePath.includes('next/dist') ||\n modulePath.startsWith('node:')\n )\n}\n\ntype IgnorableStackFrame = StackFrame & { ignored: boolean }\n\nconst currentSourcesByFile: Map<string, Promise<string | null>> = new Map()\nexport async function batchedTraceSource(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const file = frame.file\n ? // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n : undefined\n\n if (!file) return\n\n // For node internals they cannot traced the actual source code with project.traceSource,\n // we need an early return to indicate it's ignored to avoid the unknown scheme error from `project.traceSource`.\n if (file.startsWith('node:')) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: true,\n arguments: [],\n },\n source: null,\n }\n }\n\n const currentDirectoryFileUrl = pathToFileURL(process.cwd()).href\n\n const sourceFrame = await project.traceSource(frame, currentDirectoryFileUrl)\n if (!sourceFrame) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: shouldIgnorePath(file),\n arguments: [],\n },\n source: null,\n }\n }\n\n let source = null\n const originalFile = sourceFrame.originalFile\n\n // Don't look up source for node_modules or internals. These can often be large bundled files.\n const ignored =\n shouldIgnorePath(originalFile ?? sourceFrame.file) ||\n // isInternal means resource starts with turbopack://[turbopack]\n !!sourceFrame.isInternal\n if (originalFile && !ignored) {\n let sourcePromise = currentSourcesByFile.get(originalFile)\n if (!sourcePromise) {\n sourcePromise = project.getSourceForAsset(originalFile)\n currentSourcesByFile.set(originalFile, sourcePromise)\n setTimeout(() => {\n // Cache file reads for 100ms, as frames will often reference the same\n // files and can be large.\n currentSourcesByFile.delete(originalFile!)\n }, 100)\n }\n source = await sourcePromise\n }\n\n // TODO: get ignoredList from turbopack source map\n const ignorableFrame = {\n file: sourceFrame.file,\n lineNumber: sourceFrame.line ?? 0,\n column: sourceFrame.column ?? 0,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName ?? '<unknown>',\n ignored,\n arguments: [],\n }\n\n return {\n frame: ignorableFrame,\n source,\n }\n}\nfunction parseFile(fileParam: string | null): string | undefined {\n if (!fileParam) {\n return undefined\n }\n\n // rsc://React/Server/file://<filename>?42 => file://<filename>\n return fileParam.replace(/^rsc:\\/\\/React\\/[^/]+\\//, '').replace(/\\?\\d+$/, '')\n}\n\nfunction createStackFrames(\n body: OriginalStackFramesRequest\n): TurbopackStackFrame[] {\n const { frames, isServer } = body\n\n return frames\n .map((frame): TurbopackStackFrame | undefined => {\n const file = parseFile(frame.file)\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: frame.methodName ?? '<unknown>',\n line: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n isServer,\n } satisfies TurbopackStackFrame\n })\n .filter((f): f is TurbopackStackFrame => f !== undefined)\n}\n\nfunction createStackFrame(\n searchParams: URLSearchParams\n): TurbopackStackFrame | undefined {\n const file = parseFile(searchParams.get('file'))\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: searchParams.get('methodName') ?? '<unknown>',\n line: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n isServer: searchParams.get('isServer') === 'true',\n } satisfies TurbopackStackFrame\n}\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: ModernRawSourceMap\n}\n\n// TODO(veil): Upstream types\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\ninterface ModernRawSourceMap extends SourceMapPayload {\n ignoreList?: number[]\n}\n\ntype ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap\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 */\nfunction findApplicableSourceMapPayload(\n frame: TurbopackStackFrame,\n payload: ModernSourceMapPayload\n): ModernRawSourceMap | undefined {\n if ('sections' in payload) {\n const frameLine = frame.line ?? 0\n const frameColumn = frame.column ?? 0\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 // TODO(veil): Binary search\n let section: IndexSourceMapSection | undefined = payload.sections[0]\n for (\n let i = 0;\n i < payload.sections.length &&\n payload.sections[i].offset.line <= frameLine &&\n payload.sections[i].offset.column <= frameColumn;\n i++\n ) {\n section = payload.sections[i]\n }\n\n return section === undefined ? undefined : section.map\n } else {\n return payload\n }\n}\n\nasync function nativeTraceSource(\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const sourceMap = findSourceMap(\n // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n )\n if (sourceMap !== undefined) {\n const traced = await SourceMapConsumer.with(\n sourceMap.payload,\n null,\n async (consumer) => {\n const originalPosition = consumer.originalPositionFor({\n line: frame.line ?? 1,\n column: frame.column ?? 1,\n })\n\n if (originalPosition.source === null) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n originalPosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return { originalPosition, sourceContent }\n }\n )\n\n if (traced !== null) {\n const { originalPosition, sourceContent } = traced\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMap.payload\n )\n\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n let ignored = false\n if (applicableSourceMap === undefined) {\n console.error(\n 'No applicable source map found in sections for frame',\n frame\n )\n } else {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n originalPosition.source!\n )\n ignored =\n applicableSourceMap.ignoreList?.includes(sourceIndex) ??\n // When sourcemap is not available, fallback to checking `frame.file`.\n // e.g. In pages router, nextjs server code is not bundled into the page.\n shouldIgnorePath(frame.file)\n }\n\n const originalStackFrame: IgnorableStackFrame = {\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', '') || '<unknown>',\n column: (originalPosition.column ?? 0) + 1,\n file: originalPosition.source?.startsWith('file://')\n ? relativeToCwd(originalPosition.source)\n : originalPosition.source,\n lineNumber: originalPosition.line ?? 0,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n return {\n frame: originalStackFrame,\n source: sourceContent,\n }\n }\n }\n\n return undefined\n}\n\nfunction relativeToCwd(file: string): string {\n const relPath = path.relative(process.cwd(), url.fileURLToPath(file))\n // TODO(sokra) include a ./ here to make it a relative path\n return relPath\n}\n\nasync function createOriginalStackFrame(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<OriginalStackFrameResponse | null> {\n const traced =\n (await nativeTraceSource(frame)) ??\n // TODO(veil): When would the bundler know more than native?\n // If it's faster, try the bundler first and fall back to native later.\n (await batchedTraceSource(project, frame))\n if (!traced) {\n return null\n }\n\n return {\n originalStackFrame: traced.frame,\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware(project: Project) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n const request = JSON.parse(body) as OriginalStackFramesRequest\n const stackFrames = createStackFrames(request)\n const result: OriginalStackFramesResponse = await Promise.all(\n stackFrames.map(async (frame) => {\n try {\n const stackFrame = await createOriginalStackFrame(project, frame)\n if (stackFrame === null) {\n return {\n status: 'rejected',\n reason: 'Failed to create original stack frame',\n }\n }\n return { status: 'fulfilled', value: stackFrame }\n } catch (error) {\n return {\n status: 'rejected',\n reason: inspect(error, { colors: false }),\n }\n }\n })\n )\n\n return json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return noContent(res)\n\n try {\n launchEditor(frame.file, frame.line ?? 1, frame.column ?? 1)\n } catch (err) {\n console.log('Failed to launch editor:', err)\n return internalServerError(res)\n }\n\n noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(project: Project) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n let filename = searchParams.get('filename')\n\n if (!filename) {\n return badRequest(res)\n }\n\n // TODO(veil): Always try the native version first.\n // Externals could also be files that aren't bundled via Webpack.\n if (\n filename.startsWith('webpack://') ||\n filename.startsWith('webpack-internal:///')\n ) {\n const sourceMap = findSourceMap(filename)\n\n if (sourceMap) {\n return json(res, sourceMap.payload)\n }\n\n return noContent(res)\n }\n\n try {\n // Turbopack chunk filenames might be URL-encoded.\n filename = decodeURI(filename)\n\n if (path.isAbsolute(filename)) {\n filename = url.pathToFileURL(filename).href\n }\n\n const sourceMapString = await project.getSourceMap(filename)\n\n if (sourceMapString) {\n return jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n noContent(res)\n }\n}\n"],"names":["badRequest","getOriginalCodeFrame","internalServerError","json","jsonString","noContent","fs","constants","FS","path","url","launchEditor","SourceMapConsumer","getSourceMapFromFile","findSourceMap","pathToFileURL","inspect","shouldIgnorePath","modulePath","includes","startsWith","currentSourcesByFile","Map","batchedTraceSource","project","frame","file","decodeURIComponent","undefined","lineNumber","line","column","methodName","ignored","arguments","source","currentDirectoryFileUrl","process","cwd","href","sourceFrame","traceSource","originalFile","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","ignorableFrame","parseFile","fileParam","replace","createStackFrames","body","frames","isServer","map","filter","f","createStackFrame","searchParams","parseInt","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","i","length","offset","nativeTraceSource","sourceMap","traced","with","consumer","originalPosition","originalPositionFor","sourceContent","sourceContentFor","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","relativeToCwd","relPath","relative","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOverlayMiddleware","req","res","next","pathname","URL","method","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","colors","fileExists","access","F_OK","then","err","log","getSourceMapMiddleware","filename","decodeURI","isAbsolute","sourceMapString","getSourceMap"],"mappings":"AACA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,mBAAmB,EACnBC,IAAI,EACJC,UAAU,EACVC,SAAS,QAIJ,WAAU;AAEjB,OAAOC,MAAMC,aAAaC,EAAE,QAAQ,cAAa;AACjD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,YAAY,QAAQ,mCAAkC;AAE/D,SAASC,iBAAiB,QAAQ,kCAAiC;AAEnE,SAASC,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,aAAa,QAA+B,cAAa;AAClE,SAASC,aAAa,QAAQ,WAAU;AACxC,SAASC,OAAO,QAAQ,YAAW;AAEnC,SAASC,iBAAiBC,UAAkB;IAC1C,OACEA,WAAWC,QAAQ,CAAC,mBACpB,2EAA2E;IAC3ED,WAAWC,QAAQ,CAAC,gBACpBD,WAAWE,UAAU,CAAC;AAE1B;AAIA,MAAMC,uBAA4D,IAAIC;AACtE,OAAO,eAAeC,mBACpBC,OAAgB,EAChBC,KAA0B;IAE1B,MAAMC,OAAOD,MAAMC,IAAI,GAEnBC,mBAAmBF,MAAMC,IAAI,IAC7BE;IAEJ,IAAI,CAACF,MAAM;IAEX,yFAAyF;IACzF,iHAAiH;IACjH,IAAIA,KAAKN,UAAU,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tG,OAAgB;IACrD,OAAO,eACLyE,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEtC,YAAY,EAAE,GAAG,IAAIuC,IAAIJ,IAAIvF,GAAG,EAAG;QAErD,IAAI0F,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,IAAI4B,WAAWjE,aAAajB,GAAG,CAAC;QAEhC,IAAI,CAACkF,UAAU;YACb,OAAO/H,WAAWkG;QACpB;QAEA,mDAAmD;QACnD,iEAAiE;QACjE,IACE6B,SAAS3G,UAAU,CAAC,iBACpB2G,SAAS3G,UAAU,CAAC,yBACpB;YACA,MAAMsD,YAAY5D,cAAciH;YAEhC,IAAIrD,WAAW;gBACb,OAAOvE,KAAK+F,KAAKxB,UAAUT,OAAO;YACpC;YAEA,OAAO5D,UAAU6F;QACnB;QAEA,IAAI;YACF,kDAAkD;YAClD6B,WAAWC,UAAUD;YAErB,IAAItH,KAAKwH,UAAU,CAACF,WAAW;gBAC7BA,WAAWrH,IAAIK,aAAa,CAACgH,UAAUxF,IAAI;YAC7C;YAEA,MAAM2F,kBAAkB,MAAM1G,QAAQ2G,YAAY,CAACJ;YAEnD,IAAIG,iBAAiB;gBACnB,OAAO9H,WAAW8F,KAAKgC;YACzB;YAEA,IAAIH,SAAS3G,UAAU,CAAC,UAAU;gBAChC,MAAMsD,YAAY,MAAM7D,qBAAqBkH;gBAE7C,IAAIrD,WAAW;oBACb,OAAOvE,KAAK+F,KAAKxB;gBACnB;YACF;QACF,EAAE,OAAOU,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEA/E,UAAU6F;IACZ;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n jsonString,\n noContent,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\n\nimport fs, { constants as FS } from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport { launchEditor } from '../internal/helpers/launchEditor'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport {\n SourceMapConsumer,\n type BasicSourceMapConsumer,\n type NullableMappedPosition,\n} from 'next/dist/compiled/source-map08'\nimport type { Project, TurbopackStackFrame } from '../../../../build/swc/types'\nimport { getSourceMapFromFile } from '../internal/helpers/get-source-map-from-file'\nimport { findSourceMap, type SourceMapPayload } from 'node:module'\nimport { pathToFileURL } from 'node:url'\nimport { inspect } from 'node:util'\n\nfunction shouldIgnorePath(modulePath: string): boolean {\n return (\n modulePath.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n modulePath.includes('next/dist') ||\n modulePath.startsWith('node:')\n )\n}\n\ntype IgnorableStackFrame = StackFrame & { ignored: boolean }\n\nconst currentSourcesByFile: Map<string, Promise<string | null>> = new Map()\nexport async function batchedTraceSource(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const file = frame.file\n ? // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n : undefined\n\n if (!file) return\n\n // For node internals they cannot traced the actual source code with project.traceSource,\n // we need an early return to indicate it's ignored to avoid the unknown scheme error from `project.traceSource`.\n if (file.startsWith('node:')) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: true,\n arguments: [],\n },\n source: null,\n }\n }\n\n const currentDirectoryFileUrl = pathToFileURL(process.cwd()).href\n\n const sourceFrame = await project.traceSource(frame, currentDirectoryFileUrl)\n if (!sourceFrame) {\n return {\n frame: {\n file,\n lineNumber: frame.line ?? 0,\n column: frame.column ?? 0,\n methodName: frame.methodName ?? '<unknown>',\n ignored: shouldIgnorePath(file),\n arguments: [],\n },\n source: null,\n }\n }\n\n let source = null\n const originalFile = sourceFrame.originalFile\n\n // Don't look up source for node_modules or internals. These can often be large bundled files.\n const ignored =\n shouldIgnorePath(originalFile ?? sourceFrame.file) ||\n // isInternal means resource starts with turbopack://[turbopack]\n !!sourceFrame.isInternal\n if (originalFile && !ignored) {\n let sourcePromise = currentSourcesByFile.get(originalFile)\n if (!sourcePromise) {\n sourcePromise = project.getSourceForAsset(originalFile)\n currentSourcesByFile.set(originalFile, sourcePromise)\n setTimeout(() => {\n // Cache file reads for 100ms, as frames will often reference the same\n // files and can be large.\n currentSourcesByFile.delete(originalFile!)\n }, 100)\n }\n source = await sourcePromise\n }\n\n // TODO: get ignoredList from turbopack source map\n const ignorableFrame = {\n file: sourceFrame.file,\n lineNumber: sourceFrame.line ?? 0,\n column: sourceFrame.column ?? 0,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName ?? '<unknown>',\n ignored,\n arguments: [],\n }\n\n return {\n frame: ignorableFrame,\n source,\n }\n}\nfunction parseFile(fileParam: string | null): string | undefined {\n if (!fileParam) {\n return undefined\n }\n\n // rsc://React/Server/file://<filename>?42 => file://<filename>\n return fileParam.replace(/^rsc:\\/\\/React\\/[^/]+\\//, '').replace(/\\?\\d+$/, '')\n}\n\nfunction createStackFrames(\n body: OriginalStackFramesRequest\n): TurbopackStackFrame[] {\n const { frames, isServer } = body\n\n return frames\n .map((frame): TurbopackStackFrame | undefined => {\n const file = parseFile(frame.file)\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: frame.methodName ?? '<unknown>',\n line: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n isServer,\n } satisfies TurbopackStackFrame\n })\n .filter((f): f is TurbopackStackFrame => f !== undefined)\n}\n\nfunction createStackFrame(\n searchParams: URLSearchParams\n): TurbopackStackFrame | undefined {\n const file = parseFile(searchParams.get('file'))\n\n if (!file) {\n return undefined\n }\n\n return {\n file,\n methodName: searchParams.get('methodName') ?? '<unknown>',\n line: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n isServer: searchParams.get('isServer') === 'true',\n } satisfies TurbopackStackFrame\n}\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: ModernRawSourceMap\n}\n\n// TODO(veil): Upstream types\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\ninterface ModernRawSourceMap extends SourceMapPayload {\n ignoreList?: number[]\n}\n\ntype ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap\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 */\nfunction findApplicableSourceMapPayload(\n frame: TurbopackStackFrame,\n payload: ModernSourceMapPayload\n): ModernRawSourceMap | undefined {\n if ('sections' in payload) {\n const frameLine = frame.line ?? 0\n const frameColumn = frame.column ?? 0\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 // TODO(veil): Binary search\n let section: IndexSourceMapSection | undefined = payload.sections[0]\n for (\n let i = 0;\n i < payload.sections.length &&\n payload.sections[i].offset.line <= frameLine &&\n payload.sections[i].offset.column <= frameColumn;\n i++\n ) {\n section = payload.sections[i]\n }\n\n return section === undefined ? undefined : section.map\n } else {\n return payload\n }\n}\n\nasync function nativeTraceSource(\n frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n const sourceURL = // TODO(veil): Why are the frames sent encoded?\n decodeURIComponent(frame.file)\n let sourceMapPayload: ModernSourceMapPayload | undefined\n try {\n sourceMapPayload = findSourceMap(sourceURL)?.payload\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n if (sourceMapPayload !== undefined) {\n let consumer: BasicSourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMapPayload)\n } catch (cause) {\n throw new Error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n let traced: {\n originalPosition: NullableMappedPosition\n sourceContent: string | null\n } | null\n try {\n const originalPosition = consumer.originalPositionFor({\n line: frame.line ?? 1,\n column: frame.column ?? 1,\n })\n\n if (originalPosition.source === null) {\n traced = null\n } else {\n const sourceContent: string | null =\n consumer.sourceContentFor(\n originalPosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n traced = { originalPosition, sourceContent }\n }\n } finally {\n consumer.destroy()\n }\n\n if (traced !== null) {\n const { originalPosition, sourceContent } = traced\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMapPayload\n )\n\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n let ignored = false\n if (applicableSourceMap === undefined) {\n console.error(\n 'No applicable source map found in sections for frame',\n frame\n )\n } else {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n originalPosition.source!\n )\n ignored =\n applicableSourceMap.ignoreList?.includes(sourceIndex) ??\n // When sourcemap is not available, fallback to checking `frame.file`.\n // e.g. In pages router, nextjs server code is not bundled into the page.\n shouldIgnorePath(frame.file)\n }\n\n const originalStackFrame: IgnorableStackFrame = {\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', '') || '<unknown>',\n column: (originalPosition.column ?? 0) + 1,\n file: originalPosition.source?.startsWith('file://')\n ? relativeToCwd(originalPosition.source)\n : originalPosition.source,\n lineNumber: originalPosition.line ?? 0,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n return {\n frame: originalStackFrame,\n source: sourceContent,\n }\n }\n }\n\n return undefined\n}\n\nfunction relativeToCwd(file: string): string {\n const relPath = path.relative(process.cwd(), url.fileURLToPath(file))\n // TODO(sokra) include a ./ here to make it a relative path\n return relPath\n}\n\nasync function createOriginalStackFrame(\n project: Project,\n frame: TurbopackStackFrame\n): Promise<OriginalStackFrameResponse | null> {\n const traced =\n (await nativeTraceSource(frame)) ??\n // TODO(veil): When would the bundler know more than native?\n // If it's faster, try the bundler first and fall back to native later.\n (await batchedTraceSource(project, frame))\n if (!traced) {\n return null\n }\n\n return {\n originalStackFrame: traced.frame,\n originalCodeFrame: getOriginalCodeFrame(traced.frame, traced.source),\n }\n}\n\nexport function getOverlayMiddleware(project: Project) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n const request = JSON.parse(body) as OriginalStackFramesRequest\n const stackFrames = createStackFrames(request)\n const result: OriginalStackFramesResponse = await Promise.all(\n stackFrames.map(async (frame) => {\n try {\n const stackFrame = await createOriginalStackFrame(project, frame)\n if (stackFrame === null) {\n return {\n status: 'rejected',\n reason: 'Failed to create original stack frame',\n }\n }\n return { status: 'fulfilled', value: stackFrame }\n } catch (error) {\n return {\n status: 'rejected',\n reason: inspect(error, { colors: false }),\n }\n }\n })\n )\n\n return json(res, result)\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = createStackFrame(searchParams)\n\n if (!frame) return badRequest(res)\n\n const fileExists = await fs.access(frame.file, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return noContent(res)\n\n try {\n launchEditor(frame.file, frame.line ?? 1, frame.column ?? 1)\n } catch (err) {\n console.log('Failed to launch editor:', err)\n return internalServerError(res)\n }\n\n noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(project: Project) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(req.url!, 'http://n')\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n let filename = searchParams.get('filename')\n\n if (!filename) {\n return badRequest(res)\n }\n\n // TODO(veil): Always try the native version first.\n // Externals could also be files that aren't bundled via Webpack.\n if (\n filename.startsWith('webpack://') ||\n filename.startsWith('webpack-internal:///')\n ) {\n const sourceMap = findSourceMap(filename)\n\n if (sourceMap) {\n return json(res, sourceMap.payload)\n }\n\n return noContent(res)\n }\n\n try {\n // Turbopack chunk filenames might be URL-encoded.\n filename = decodeURI(filename)\n\n if (path.isAbsolute(filename)) {\n filename = url.pathToFileURL(filename).href\n }\n\n const sourceMapString = await project.getSourceMap(filename)\n\n if (sourceMapString) {\n return jsonString(res, sourceMapString)\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n\n if (sourceMap) {\n return json(res, sourceMap)\n }\n }\n } catch (error) {\n console.error('Failed to get source map:', error)\n }\n\n noContent(res)\n }\n}\n"],"names":["badRequest","getOriginalCodeFrame","internalServerError","json","jsonString","noContent","fs","constants","FS","path","url","launchEditor","SourceMapConsumer","getSourceMapFromFile","findSourceMap","pathToFileURL","inspect","shouldIgnorePath","modulePath","includes","startsWith","currentSourcesByFile","Map","batchedTraceSource","project","frame","file","decodeURIComponent","undefined","lineNumber","line","column","methodName","ignored","arguments","source","currentDirectoryFileUrl","process","cwd","href","sourceFrame","traceSource","originalFile","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","ignorableFrame","parseFile","fileParam","replace","createStackFrames","body","frames","isServer","map","filter","f","createStackFrame","searchParams","parseInt","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","i","length","offset","nativeTraceSource","sourceURL","sourceMapPayload","cause","Error","consumer","traced","originalPosition","originalPositionFor","sourceContent","sourceContentFor","destroy","applicableSourceMap","console","error","sourceIndex","sources","indexOf","ignoreList","originalStackFrame","relativeToCwd","relPath","relative","fileURLToPath","createOriginalStackFrame","originalCodeFrame","getOverlayMiddleware","req","res","next","pathname","URL","method","Promise","resolve","reject","data","on","chunk","request","JSON","parse","stackFrames","result","all","stackFrame","status","reason","value","colors","fileExists","access","F_OK","then","err","log","getSourceMapMiddleware","filename","sourceMap","decodeURI","isAbsolute","sourceMapString","getSourceMap"],"mappings":"AACA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,mBAAmB,EACnBC,IAAI,EACJC,UAAU,EACVC,SAAS,QAIJ,WAAU;AAEjB,OAAOC,MAAMC,aAAaC,EAAE,QAAQ,cAAa;AACjD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,YAAY,QAAQ,mCAAkC;AAE/D,SACEC,iBAAiB,QAGZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,aAAa,QAA+B,cAAa;AAClE,SAASC,aAAa,QAAQ,WAAU;AACxC,SAASC,OAAO,QAAQ,YAAW;AAEnC,SAASC,iBAAiBC,UAAkB;IAC1C,OACEA,WAAWC,QAAQ,CAAC,mBACpB,2EAA2E;IAC3ED,WAAWC,QAAQ,CAAC,gBACpBD,WAAWE,UAAU,CAAC;AAE1B;AAIA,MAAMC,uBAA4D,IAAIC;AACtE,OAAO,eAAeC,mBACpBC,OAAgB,EAChBC,KAA0B;IAE1B,MAAMC,OAAOD,MAAMC,IAAI,GAEnBC,mBAAmBF,MAAMC,IAAI,IAC7BE;IAEJ,IAAI,CAACF,MAAM;IAEX,yFAAyF;IACzF,iHAAiH;IACjH,IAAIA,KAAKN,UAAU,CAAC,UAAU;YAIZK,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tH,qBAAqBqH;gBAE7C,IAAIC,WAAW;oBACb,OAAOhI,KAAKkG,KAAK8B;gBACnB;YACF;QACF,EAAE,OAAO5C,OAAO;YACdD,QAAQC,KAAK,CAAC,6BAA6BA;QAC7C;QAEAlF,UAAUgG;IACZ;AACF"}
|
|
@@ -28,7 +28,17 @@ function getSourcePath(source) {
|
|
|
28
28
|
return source.replace(/^(webpack:\/\/\/|webpack:\/\/|webpack:\/\/_N_E\/)/, '');
|
|
29
29
|
}
|
|
30
30
|
async function findOriginalSourcePositionAndContent(sourceMap, position) {
|
|
31
|
-
|
|
31
|
+
let consumer;
|
|
32
|
+
try {
|
|
33
|
+
consumer = await new SourceMapConsumer(sourceMap);
|
|
34
|
+
} catch (cause) {
|
|
35
|
+
throw Object.defineProperty(new Error("" + sourceMap.file + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
|
|
36
|
+
cause
|
|
37
|
+
}), "__NEXT_ERROR_CODE", {
|
|
38
|
+
value: "E635",
|
|
39
|
+
enumerable: false
|
|
40
|
+
});
|
|
41
|
+
}
|
|
32
42
|
try {
|
|
33
43
|
var _position_column;
|
|
34
44
|
const sourcePosition = consumer.originalPositionFor({
|
|
@@ -340,8 +350,8 @@ export function getOverlayMiddleware(options) {
|
|
|
340
350
|
edgeServerStats,
|
|
341
351
|
rootDirectory
|
|
342
352
|
}));
|
|
343
|
-
} catch (
|
|
344
|
-
return
|
|
353
|
+
} catch (err) {
|
|
354
|
+
return badRequest(res);
|
|
345
355
|
}
|
|
346
356
|
} else if (pathname === '/__nextjs_launch-editor') {
|
|
347
357
|
var _searchParams_get, _searchParams_get1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-webpack.ts"],"sourcesContent":["import { constants as FS, promises as fs } from 'fs'\nimport path from 'path'\nimport url from 'url'\nimport { SourceMapConsumer } from 'next/dist/compiled/source-map08'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { getSourceMapFromFile } from '../internal/helpers/get-source-map-from-file'\nimport { launchEditor } from '../internal/helpers/launchEditor'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n noContent,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\nexport { getServerError } from '../internal/helpers/node-stack-frames'\nexport { parseStack } from '../internal/helpers/parse-stack'\nexport { getSourceMapFromFile }\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type webpack from 'webpack'\nimport type {\n NullableMappedPosition,\n RawSourceMap,\n} from 'next/dist/compiled/source-map08'\nimport { formatFrameSourceFile } from '../internal/helpers/webpack-module-path'\nimport type { MappedPosition } from 'source-map'\nimport { inspect } from 'util'\n\nfunction shouldIgnorePath(modulePath: string): boolean {\n return (\n modulePath.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n modulePath.includes('next/dist') ||\n modulePath.startsWith('node:')\n )\n}\n\ntype IgnoredSources = Array<{ url: string; ignored: boolean }>\n\nexport interface IgnorableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceAttributes = {\n sourcePosition: NullableMappedPosition\n sourceContent: string | null\n}\n\ntype Source =\n | {\n type: 'file'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n modulePath: string\n }\n | {\n type: 'bundle'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n compilation: webpack.Compilation\n moduleId: string\n modulePath: string\n }\n\nfunction getModuleById(\n id: string | undefined,\n compilation: webpack.Compilation\n) {\n const { chunkGraph, modules } = compilation\n\n return [...modules].find((module) => chunkGraph.getModuleId(module) === id)\n}\n\nfunction findModuleNotFoundFromError(errorMessage: string | undefined) {\n return errorMessage?.match(/'([^']+)' module/)?.[1]\n}\n\nfunction getSourcePath(source: string) {\n return source.replace(/^(webpack:\\/\\/\\/|webpack:\\/\\/|webpack:\\/\\/_N_E\\/)/, '')\n}\n\nasync function findOriginalSourcePositionAndContent(\n sourceMap: RawSourceMap,\n position: { line: number; column: number | null }\n): Promise<SourceAttributes | null> {\n const consumer = await new SourceMapConsumer(sourceMap)\n try {\n const sourcePosition = consumer.originalPositionFor({\n line: position.line,\n column: position.column ?? 0,\n })\n\n if (!sourcePosition.source) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return {\n sourcePosition,\n sourceContent,\n }\n } finally {\n consumer.destroy()\n }\n}\n\nexport function getIgnoredSources(sourceMap: RawSourceMap): IgnoredSources {\n const ignoreList = new Set<number>()\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const bundlerFilePath = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(bundlerFilePath)\n if (shouldIgnorePath(formattedFilePath)) {\n ignoreList.add(index)\n }\n }\n\n const ignoredSources = sourceMap.sources.map((source, index) => {\n return {\n url: source,\n ignored: ignoreList.has(sourceMap.sources.indexOf(source)),\n content: sourceMap.sourcesContent?.[index] ?? null,\n }\n })\n return ignoredSources\n}\n\nfunction isIgnoredSource(\n source: Source,\n sourcePosition: MappedPosition | NullableMappedPosition\n) {\n if (sourcePosition.source == null) {\n return true\n }\n for (const ignoredSource of source.ignoredSources) {\n if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {\n return true\n }\n }\n\n return false\n}\n\nfunction findOriginalSourcePositionAndContentFromCompilation(\n moduleId: string | undefined,\n importedModule: string,\n compilation: webpack.Compilation\n): SourceAttributes | null {\n const module = getModuleById(moduleId, compilation)\n return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null\n}\n\nexport async function createOriginalStackFrame({\n source,\n rootDirectory,\n frame,\n errorMessage,\n}: {\n source: Source\n rootDirectory: string\n frame: StackFrame\n errorMessage?: string\n}): Promise<OriginalStackFrameResponse | null> {\n const { lineNumber, column } = frame\n const moduleNotFound = findModuleNotFoundFromError(errorMessage)\n const result = await (async () => {\n if (moduleNotFound) {\n if (source.type === 'file') {\n return undefined\n }\n\n return findOriginalSourcePositionAndContentFromCompilation(\n source.moduleId,\n moduleNotFound,\n source.compilation\n )\n }\n // This returns 1-based lines and 0-based columns\n return await findOriginalSourcePositionAndContent(source.sourceMap, {\n line: lineNumber ?? 1,\n column,\n })\n })()\n\n if (!result) {\n return null\n }\n const { sourcePosition, sourceContent } = result\n\n if (!sourcePosition.source) {\n return null\n }\n\n const ignored =\n isIgnoredSource(source, sourcePosition) ||\n // If the source file is externals, should be excluded even it's not ignored source.\n // e.g. webpack://next/dist/.. needs to be ignored\n shouldIgnorePath(source.modulePath)\n\n const sourcePath = getSourcePath(\n // When sourcePosition.source is the loader path the modulePath is generally better.\n (sourcePosition.source!.includes('|')\n ? source.modulePath\n : sourcePosition.source) || source.modulePath\n )\n const filePath = path.resolve(rootDirectory, sourcePath)\n\n const resolvedFilePath = sourceContent\n ? path.relative(rootDirectory, filePath)\n : sourcePosition.source\n\n const traced: IgnorableStackFrame = {\n file: resolvedFilePath,\n lineNumber: sourcePosition.line,\n column: (sourcePosition.column ?? 0) + 1,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export\n // Resolve it back to `default` for the method name if the source position didn't have the method.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n arguments: [],\n ignored,\n }\n\n return {\n originalStackFrame: traced,\n originalCodeFrame: getOriginalCodeFrame(traced, sourceContent),\n }\n}\n\nasync function getSourceMapFromCompilation(\n id: string,\n compilation: webpack.Compilation\n): Promise<RawSourceMap | undefined> {\n try {\n const module = getModuleById(id, compilation)\n\n if (!module) {\n return undefined\n }\n\n // @ts-expect-error The types for `CodeGenerationResults.get` require a\n // runtime to be passed as second argument, but apparently it also works\n // without it.\n const codeGenerationResult = compilation.codeGenerationResults.get(module)\n const source = codeGenerationResult?.sources.get('javascript')\n\n return source?.map() ?? undefined\n } catch (err) {\n console.error(`Failed to lookup module by ID (\"${id}\"):`, err)\n return undefined\n }\n}\n\nasync function getSource(\n filename: string,\n options: {\n getCompilations: () => webpack.Compilation[]\n }\n): Promise<Source | undefined> {\n const { getCompilations } = options\n\n if (path.isAbsolute(filename)) {\n filename = url.pathToFileURL(filename).href\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n return sourceMap\n ? {\n type: 'file',\n sourceMap,\n ignoredSources: getIgnoredSources(sourceMap),\n modulePath: filename.replace(/^file:\\/\\//, ''),\n }\n : undefined\n }\n\n // webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n // rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx\n // webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n const moduleId = filename\n .replace(\n /^(rsc:\\/\\/React\\/[^/]+\\/)?(webpack-internal:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)/,\n ''\n )\n .replace(/\\?\\d+$/, '')\n\n // (rsc)/./src/hello.tsx => ./src/hello.tsx\n const modulePath = moduleId.replace(/^(\\(.*\\)\\/?)/, '')\n\n for (const compilation of getCompilations()) {\n const sourceMap = await getSourceMapFromCompilation(moduleId, compilation)\n const ignoreList = []\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const bundlerFilePath = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(bundlerFilePath)\n if (shouldIgnorePath(formattedFilePath)) {\n ignoreList.push(index)\n }\n }\n\n if (sourceMap) {\n const ignoredSources = getIgnoredSources(sourceMap)\n return {\n type: 'bundle',\n sourceMap,\n compilation,\n moduleId,\n modulePath,\n ignoredSources,\n }\n }\n }\n\n return undefined\n}\n\nfunction getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frames: StackFrame[]\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFramesResponse> {\n return Promise.all(\n frames.map(\n (frame): Promise<OriginalStackFramesResponse[number]> =>\n getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n }).then(\n (value) => {\n return {\n status: 'fulfilled',\n value,\n }\n },\n (reason) => {\n return {\n status: 'rejected',\n reason: inspect(reason, { colors: false }),\n }\n }\n )\n )\n )\n}\n\nasync function getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frame: StackFrame\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFrameResponse> {\n const filename = frame.file ?? ''\n const source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n // Try Client Compilation first. In `pages` we leverage\n // `isClientError` to check. In `app` it depends on if it's a server\n // / client component and when the code throws. E.g. during HTML\n // rendering it's the server/edge compilation.\n if ((!isEdgeServer && !isServer) || isAppDirectory) {\n const compilation = clientStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Server Compilation. In `pages` this could be something\n // imported in getServerSideProps/getStaticProps as the code for\n // those is tree-shaken. In `app` this finds server components and\n // code that was imported from a server component. It also covers\n // when client component code throws during HTML rendering.\n if (isServer || isAppDirectory) {\n const compilation = serverStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Edge Server Compilation. Both cases are the same as Server\n // Compilation, main difference is that it covers `runtime: 'edge'`\n // pages/app routes.\n if (isEdgeServer || isAppDirectory) {\n const compilation = edgeServerStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n return compilations\n },\n })\n\n // This stack frame is used for the one that couldn't locate the source or source mapped frame\n const defaultStackFrame: IgnorableStackFrame = {\n file: frame.file,\n lineNumber: frame.lineNumber,\n column: frame.column ?? 1,\n methodName: frame.methodName,\n ignored: shouldIgnorePath(filename),\n arguments: [],\n }\n if (!source) {\n // return original stack frame with no source map\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n const originalStackFrameResponse = await createOriginalStackFrame({\n frame,\n source,\n rootDirectory,\n })\n\n if (!originalStackFrameResponse) {\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n return originalStackFrameResponse\n}\n\nexport function getOverlayMiddleware(options: {\n rootDirectory: string\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { rootDirectory, clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n try {\n const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(\n body\n ) as OriginalStackFramesRequest\n\n return json(\n res,\n await getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames: frames.map((frame) => ({\n ...frame,\n lineNumber: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n })),\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n })\n )\n } catch (error) {\n return internalServerError(res, error)\n }\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = {\n file: searchParams.get('file') as string,\n methodName: searchParams.get('methodName') as string,\n lineNumber: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n arguments: searchParams.getAll('arguments').filter(Boolean),\n } satisfies StackFrame\n\n if (!frame.file) return badRequest(res)\n\n // frame files may start with their webpack layer, like (middleware)/middleware.js\n const filePath = path.resolve(\n rootDirectory,\n frame.file.replace(/^\\([^)]+\\)\\//, '')\n )\n const fileExists = await fs.access(filePath, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return noContent(res)\n\n try {\n await launchEditor(filePath, frame.lineNumber, frame.column ?? 1)\n } catch (err) {\n console.log('Failed to launch editor:', err)\n return internalServerError(res)\n }\n\n return noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(options: {\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n const filename = searchParams.get('filename')\n\n if (!filename) {\n return badRequest(res)\n }\n\n let source: Source | undefined\n\n try {\n source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n for (const stats of [\n clientStats(),\n serverStats(),\n edgeServerStats(),\n ]) {\n if (stats?.compilation) {\n compilations.push(stats.compilation)\n }\n }\n\n return compilations\n },\n })\n } catch (error) {\n return internalServerError(res, error)\n }\n\n if (!source) {\n return noContent(res)\n }\n\n return json(res, source.sourceMap)\n }\n}\n"],"names":["constants","FS","promises","fs","path","url","SourceMapConsumer","getSourceMapFromFile","launchEditor","badRequest","getOriginalCodeFrame","internalServerError","json","noContent","getServerError","parseStack","formatFrameSourceFile","inspect","shouldIgnorePath","modulePath","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","sourcePosition","originalPositionFor","line","column","sourceContent","sourceContentFor","destroy","getIgnoredSources","ignoreList","Set","moduleFilenames","sources","index","length","bundlerFilePath","formattedFilePath","add","ignoredSources","map","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","createOriginalStackFrame","rootDirectory","frame","lineNumber","moduleNotFound","result","type","undefined","sourcePath","filePath","resolve","resolvedFilePath","relative","traced","file","methodName","arguments","originalStackFrame","originalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","console","error","getSource","filename","options","getCompilations","isAbsolute","pathToFileURL","href","push","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","colors","compilations","defaultStackFrame","originalStackFrameResponse","getOverlayMiddleware","req","res","next","pathname","searchParams","URL","method","body","reject","data","on","chunk","JSON","parse","parseInt","getAll","filter","Boolean","fileExists","access","F_OK","log","getSourceMapMiddleware","stats"],"mappings":"AAAA,SAASA,aAAaC,EAAE,EAAEC,YAAYC,EAAE,QAAQ,KAAI;AACpD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SAASC,iBAAiB,QAAQ,kCAAiC;AAEnE,SAASC,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SACEC,UAAU,EACVC,oBAAoB,EACpBC,mBAAmB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WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGb;IAEtD,OAAO,eACL0B,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAG,IAAIC,IAAI,AAAC,aAAUL,IAAIxH,GAAG;QAE7D,IAAI2H,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,MAAM7B,WAAW+B,aAAa1D,GAAG,CAAC;QAElC,IAAI,CAAC2B,UAAU;YACb,OAAOzF,WAAWqH;QACpB;QAEA,IAAI5F;QAEJ,IAAI;YACFA,SAAS,MAAM+D,UAAUC,UAAU;gBACjCE,iBAAiB;oBACf,MAAMqB,eAAsC,EAAE;oBAE9C,KAAK,MAAM2B,SAAS;wBAClBtC;wBACAC;wBACAC;qBACD,CAAE;wBACD,IAAIoC,yBAAAA,MAAO5H,WAAW,EAAE;4BACtBiG,aAAajB,IAAI,CAAC4C,MAAM5H,WAAW;wBACrC;oBACF;oBAEA,OAAOiG;gBACT;YACF;QACF,EAAE,OAAOzB,OAAO;YACd,OAAOrF,oBAAoBmH,KAAK9B;QAClC;QAEA,IAAI,CAAC9D,QAAQ;YACX,OAAOrB,UAAUiH;QACnB;QAEA,OAAOlH,KAAKkH,KAAK5F,OAAOG,SAAS;IACnC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-webpack.ts"],"sourcesContent":["import { constants as FS, promises as fs } from 'fs'\nimport path from 'path'\nimport url from 'url'\nimport {\n SourceMapConsumer,\n type BasicSourceMapConsumer,\n} from 'next/dist/compiled/source-map08'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { getSourceMapFromFile } from '../internal/helpers/get-source-map-from-file'\nimport { launchEditor } from '../internal/helpers/launchEditor'\nimport {\n badRequest,\n getOriginalCodeFrame,\n internalServerError,\n json,\n noContent,\n type OriginalStackFrameResponse,\n type OriginalStackFramesRequest,\n type OriginalStackFramesResponse,\n} from './shared'\nexport { getServerError } from '../internal/helpers/node-stack-frames'\nexport { parseStack } from '../internal/helpers/parse-stack'\nexport { getSourceMapFromFile }\n\nimport type { IncomingMessage, ServerResponse } from 'http'\nimport type webpack from 'webpack'\nimport type {\n NullableMappedPosition,\n RawSourceMap,\n} from 'next/dist/compiled/source-map08'\nimport { formatFrameSourceFile } from '../internal/helpers/webpack-module-path'\nimport type { MappedPosition } from 'source-map'\nimport { inspect } from 'util'\n\nfunction shouldIgnorePath(modulePath: string): boolean {\n return (\n modulePath.includes('node_modules') ||\n // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo\n modulePath.includes('next/dist') ||\n modulePath.startsWith('node:')\n )\n}\n\ntype IgnoredSources = Array<{ url: string; ignored: boolean }>\n\nexport interface IgnorableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceAttributes = {\n sourcePosition: NullableMappedPosition\n sourceContent: string | null\n}\n\ntype Source =\n | {\n type: 'file'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n modulePath: string\n }\n | {\n type: 'bundle'\n sourceMap: RawSourceMap\n ignoredSources: IgnoredSources\n compilation: webpack.Compilation\n moduleId: string\n modulePath: string\n }\n\nfunction getModuleById(\n id: string | undefined,\n compilation: webpack.Compilation\n) {\n const { chunkGraph, modules } = compilation\n\n return [...modules].find((module) => chunkGraph.getModuleId(module) === id)\n}\n\nfunction findModuleNotFoundFromError(errorMessage: string | undefined) {\n return errorMessage?.match(/'([^']+)' module/)?.[1]\n}\n\nfunction getSourcePath(source: string) {\n return source.replace(/^(webpack:\\/\\/\\/|webpack:\\/\\/|webpack:\\/\\/_N_E\\/)/, '')\n}\n\nasync function findOriginalSourcePositionAndContent(\n sourceMap: RawSourceMap,\n position: { line: number; column: number | null }\n): Promise<SourceAttributes | null> {\n let consumer: BasicSourceMapConsumer\n try {\n consumer = await new SourceMapConsumer(sourceMap)\n } catch (cause) {\n throw new Error(\n `${sourceMap.file}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n { cause }\n )\n }\n\n try {\n const sourcePosition = consumer.originalPositionFor({\n line: position.line,\n column: position.column ?? 0,\n })\n\n if (!sourcePosition.source) {\n return null\n }\n\n const sourceContent: string | null =\n consumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n return {\n sourcePosition,\n sourceContent,\n }\n } finally {\n consumer.destroy()\n }\n}\n\nexport function getIgnoredSources(sourceMap: RawSourceMap): IgnoredSources {\n const ignoreList = new Set<number>()\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const bundlerFilePath = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(bundlerFilePath)\n if (shouldIgnorePath(formattedFilePath)) {\n ignoreList.add(index)\n }\n }\n\n const ignoredSources = sourceMap.sources.map((source, index) => {\n return {\n url: source,\n ignored: ignoreList.has(sourceMap.sources.indexOf(source)),\n content: sourceMap.sourcesContent?.[index] ?? null,\n }\n })\n return ignoredSources\n}\n\nfunction isIgnoredSource(\n source: Source,\n sourcePosition: MappedPosition | NullableMappedPosition\n) {\n if (sourcePosition.source == null) {\n return true\n }\n for (const ignoredSource of source.ignoredSources) {\n if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {\n return true\n }\n }\n\n return false\n}\n\nfunction findOriginalSourcePositionAndContentFromCompilation(\n moduleId: string | undefined,\n importedModule: string,\n compilation: webpack.Compilation\n): SourceAttributes | null {\n const module = getModuleById(moduleId, compilation)\n return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null\n}\n\nexport async function createOriginalStackFrame({\n source,\n rootDirectory,\n frame,\n errorMessage,\n}: {\n source: Source\n rootDirectory: string\n frame: StackFrame\n errorMessage?: string\n}): Promise<OriginalStackFrameResponse | null> {\n const { lineNumber, column } = frame\n const moduleNotFound = findModuleNotFoundFromError(errorMessage)\n const result = await (async () => {\n if (moduleNotFound) {\n if (source.type === 'file') {\n return undefined\n }\n\n return findOriginalSourcePositionAndContentFromCompilation(\n source.moduleId,\n moduleNotFound,\n source.compilation\n )\n }\n // This returns 1-based lines and 0-based columns\n return await findOriginalSourcePositionAndContent(source.sourceMap, {\n line: lineNumber ?? 1,\n column,\n })\n })()\n\n if (!result) {\n return null\n }\n const { sourcePosition, sourceContent } = result\n\n if (!sourcePosition.source) {\n return null\n }\n\n const ignored =\n isIgnoredSource(source, sourcePosition) ||\n // If the source file is externals, should be excluded even it's not ignored source.\n // e.g. webpack://next/dist/.. needs to be ignored\n shouldIgnorePath(source.modulePath)\n\n const sourcePath = getSourcePath(\n // When sourcePosition.source is the loader path the modulePath is generally better.\n (sourcePosition.source!.includes('|')\n ? source.modulePath\n : sourcePosition.source) || source.modulePath\n )\n const filePath = path.resolve(rootDirectory, sourcePath)\n\n const resolvedFilePath = sourceContent\n ? path.relative(rootDirectory, filePath)\n : sourcePosition.source\n\n const traced: IgnorableStackFrame = {\n file: resolvedFilePath,\n lineNumber: sourcePosition.line,\n column: (sourcePosition.column ?? 0) + 1,\n methodName:\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export\n // Resolve it back to `default` for the method name if the source position didn't have the method.\n frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n arguments: [],\n ignored,\n }\n\n return {\n originalStackFrame: traced,\n originalCodeFrame: getOriginalCodeFrame(traced, sourceContent),\n }\n}\n\nasync function getSourceMapFromCompilation(\n id: string,\n compilation: webpack.Compilation\n): Promise<RawSourceMap | undefined> {\n try {\n const module = getModuleById(id, compilation)\n\n if (!module) {\n return undefined\n }\n\n // @ts-expect-error The types for `CodeGenerationResults.get` require a\n // runtime to be passed as second argument, but apparently it also works\n // without it.\n const codeGenerationResult = compilation.codeGenerationResults.get(module)\n const source = codeGenerationResult?.sources.get('javascript')\n\n return source?.map() ?? undefined\n } catch (err) {\n console.error(`Failed to lookup module by ID (\"${id}\"):`, err)\n return undefined\n }\n}\n\nasync function getSource(\n filename: string,\n options: {\n getCompilations: () => webpack.Compilation[]\n }\n): Promise<Source | undefined> {\n const { getCompilations } = options\n\n if (path.isAbsolute(filename)) {\n filename = url.pathToFileURL(filename).href\n }\n\n if (filename.startsWith('file:')) {\n const sourceMap = await getSourceMapFromFile(filename)\n return sourceMap\n ? {\n type: 'file',\n sourceMap,\n ignoredSources: getIgnoredSources(sourceMap),\n modulePath: filename.replace(/^file:\\/\\//, ''),\n }\n : undefined\n }\n\n // webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n // rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx\n // webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n const moduleId = filename\n .replace(\n /^(rsc:\\/\\/React\\/[^/]+\\/)?(webpack-internal:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)/,\n ''\n )\n .replace(/\\?\\d+$/, '')\n\n // (rsc)/./src/hello.tsx => ./src/hello.tsx\n const modulePath = moduleId.replace(/^(\\(.*\\)\\/?)/, '')\n\n for (const compilation of getCompilations()) {\n const sourceMap = await getSourceMapFromCompilation(moduleId, compilation)\n const ignoreList = []\n const moduleFilenames = sourceMap?.sources ?? []\n\n for (let index = 0; index < moduleFilenames.length; index++) {\n // bundlerFilePath case: webpack://./app/page.tsx\n const bundlerFilePath = moduleFilenames[index]\n // Format the path to the normal file path\n const formattedFilePath = formatFrameSourceFile(bundlerFilePath)\n if (shouldIgnorePath(formattedFilePath)) {\n ignoreList.push(index)\n }\n }\n\n if (sourceMap) {\n const ignoredSources = getIgnoredSources(sourceMap)\n return {\n type: 'bundle',\n sourceMap,\n compilation,\n moduleId,\n modulePath,\n ignoredSources,\n }\n }\n }\n\n return undefined\n}\n\nfunction getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frames: StackFrame[]\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFramesResponse> {\n return Promise.all(\n frames.map(\n (frame): Promise<OriginalStackFramesResponse[number]> =>\n getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n }).then(\n (value) => {\n return {\n status: 'fulfilled',\n value,\n }\n },\n (reason) => {\n return {\n status: 'rejected',\n reason: inspect(reason, { colors: false }),\n }\n }\n )\n )\n )\n}\n\nasync function getOriginalStackFrame({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frame,\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n}: {\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n frame: StackFrame\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n rootDirectory: string\n}): Promise<OriginalStackFrameResponse> {\n const filename = frame.file ?? ''\n const source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n // Try Client Compilation first. In `pages` we leverage\n // `isClientError` to check. In `app` it depends on if it's a server\n // / client component and when the code throws. E.g. during HTML\n // rendering it's the server/edge compilation.\n if ((!isEdgeServer && !isServer) || isAppDirectory) {\n const compilation = clientStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Server Compilation. In `pages` this could be something\n // imported in getServerSideProps/getStaticProps as the code for\n // those is tree-shaken. In `app` this finds server components and\n // code that was imported from a server component. It also covers\n // when client component code throws during HTML rendering.\n if (isServer || isAppDirectory) {\n const compilation = serverStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n // Try Edge Server Compilation. Both cases are the same as Server\n // Compilation, main difference is that it covers `runtime: 'edge'`\n // pages/app routes.\n if (isEdgeServer || isAppDirectory) {\n const compilation = edgeServerStats()?.compilation\n\n if (compilation) {\n compilations.push(compilation)\n }\n }\n\n return compilations\n },\n })\n\n // This stack frame is used for the one that couldn't locate the source or source mapped frame\n const defaultStackFrame: IgnorableStackFrame = {\n file: frame.file,\n lineNumber: frame.lineNumber,\n column: frame.column ?? 1,\n methodName: frame.methodName,\n ignored: shouldIgnorePath(filename),\n arguments: [],\n }\n if (!source) {\n // return original stack frame with no source map\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n const originalStackFrameResponse = await createOriginalStackFrame({\n frame,\n source,\n rootDirectory,\n })\n\n if (!originalStackFrameResponse) {\n return {\n originalStackFrame: defaultStackFrame,\n originalCodeFrame: null,\n }\n }\n\n return originalStackFrameResponse\n}\n\nexport function getOverlayMiddleware(options: {\n rootDirectory: string\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { rootDirectory, clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname === '/__nextjs_original-stack-frames') {\n if (req.method !== 'POST') {\n return badRequest(res)\n }\n\n const body = await new Promise<string>((resolve, reject) => {\n let data = ''\n req.on('data', (chunk) => {\n data += chunk\n })\n req.on('end', () => resolve(data))\n req.on('error', reject)\n })\n\n try {\n const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(\n body\n ) as OriginalStackFramesRequest\n\n return json(\n res,\n await getOriginalStackFrames({\n isServer,\n isEdgeServer,\n isAppDirectory,\n frames: frames.map((frame) => ({\n ...frame,\n lineNumber: frame.lineNumber ?? 0,\n column: frame.column ?? 0,\n })),\n clientStats,\n serverStats,\n edgeServerStats,\n rootDirectory,\n })\n )\n } catch (err) {\n return badRequest(res)\n }\n } else if (pathname === '/__nextjs_launch-editor') {\n const frame = {\n file: searchParams.get('file') as string,\n methodName: searchParams.get('methodName') as string,\n lineNumber: parseInt(searchParams.get('lineNumber') ?? '0', 10) || 0,\n column: parseInt(searchParams.get('column') ?? '0', 10) || 0,\n arguments: searchParams.getAll('arguments').filter(Boolean),\n } satisfies StackFrame\n\n if (!frame.file) return badRequest(res)\n\n // frame files may start with their webpack layer, like (middleware)/middleware.js\n const filePath = path.resolve(\n rootDirectory,\n frame.file.replace(/^\\([^)]+\\)\\//, '')\n )\n const fileExists = await fs.access(filePath, FS.F_OK).then(\n () => true,\n () => false\n )\n if (!fileExists) return noContent(res)\n\n try {\n await launchEditor(filePath, frame.lineNumber, frame.column ?? 1)\n } catch (err) {\n console.log('Failed to launch editor:', err)\n return internalServerError(res)\n }\n\n return noContent(res)\n }\n\n return next()\n }\n}\n\nexport function getSourceMapMiddleware(options: {\n clientStats: () => webpack.Stats | null\n serverStats: () => webpack.Stats | null\n edgeServerStats: () => webpack.Stats | null\n}) {\n const { clientStats, serverStats, edgeServerStats } = options\n\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_source-map') {\n return next()\n }\n\n const filename = searchParams.get('filename')\n\n if (!filename) {\n return badRequest(res)\n }\n\n let source: Source | undefined\n\n try {\n source = await getSource(filename, {\n getCompilations: () => {\n const compilations: webpack.Compilation[] = []\n\n for (const stats of [\n clientStats(),\n serverStats(),\n edgeServerStats(),\n ]) {\n if (stats?.compilation) {\n compilations.push(stats.compilation)\n }\n }\n\n return compilations\n },\n })\n } catch (error) {\n return internalServerError(res, error)\n }\n\n if (!source) {\n return noContent(res)\n }\n\n return json(res, source.sourceMap)\n }\n}\n"],"names":["constants","FS","promises","fs","path","url","SourceMapConsumer","getSourceMapFromFile","launchEditor","badRequest","getOriginalCodeFrame","internalServerError","json","noContent","getServerError","parseStack","formatFrameSourceFile","inspect","shouldIgnorePath","modulePath","includes","startsWith","getModuleById","id","compilation","chunkGraph","modules","find","module","getModuleId","findModuleNotFoundFromError","errorMessage","match","getSourcePath","source","replace","findOriginalSourcePositionAndContent","sourceMap","position","consumer","cause","Error","file","sourcePosition","originalPositionFor","line","column","sourceContent","sourceContentFor","destroy","getIgnoredSources","ignoreList","Set","moduleFilenames","sources","index","length","bundlerFilePath","formattedFilePath","add","ignoredSources","map","ignored","has","indexOf","content","sourcesContent","isIgnoredSource","ignoredSource","findOriginalSourcePositionAndContentFromCompilation","moduleId","importedModule","buildInfo","importLocByPath","get","createOriginalStackFrame","rootDirectory","frame","lineNumber","moduleNotFound","result","type","undefined","sourcePath","filePath","resolve","resolvedFilePath","relative","traced","methodName","arguments","originalStackFrame","originalCodeFrame","getSourceMapFromCompilation","codeGenerationResult","codeGenerationResults","err","console","error","getSource","filename","options","getCompilations","isAbsolute","pathToFileURL","href","push","getOriginalStackFrames","isServer","isEdgeServer","isAppDirectory","frames","clientStats","serverStats","edgeServerStats","Promise","all","getOriginalStackFrame","then","value","status","reason","colors","compilations","defaultStackFrame","originalStackFrameResponse","getOverlayMiddleware","req","res","next","pathname","searchParams","URL","method","body","reject","data","on","chunk","JSON","parse","parseInt","getAll","filter","Boolean","fileExists","access","F_OK","log","getSourceMapMiddleware","stats"],"mappings":"AAAA,SAASA,aAAaC,EAAE,EAAEC,YAAYC,EAAE,QAAQ,KAAI;AACpD,OAAOC,UAAU,OAAM;AACvB,OAAOC,SAAS,MAAK;AACrB,SACEC,iBAAiB,QAEZ,kCAAiC;AAExC,SAASC,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,YAAY,QAAQ,mCAAkC;AAC/D,SACEC,UAAU,EACVC,oBAAoB,EACpBC,mBAAmB,EACnBC,IAAI,EACJC,SAAS,QAIJ,WAAU;AACjB,SAASC,cAAc,QAAQ,wC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BqH;YAC7B;YAEA,OAAOnH,UAAUmH;QACnB;QAEA,OAAOC;IACT;AACF;AAEA,OAAO,SAASoB,uBAAuBhD,OAItC;IACC,MAAM,EAAEW,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGb;IAEtD,OAAO,eACL0B,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAG,IAAIC,IAAI,AAAC,aAAUL,IAAI1H,GAAG;QAE7D,IAAI6H,aAAa,wBAAwB;YACvC,OAAOD;QACT;QAEA,MAAM7B,WAAW+B,aAAazD,GAAG,CAAC;QAElC,IAAI,CAAC0B,UAAU;YACb,OAAO3F,WAAWuH;QACpB;QAEA,IAAI9F;QAEJ,IAAI;YACFA,SAAS,MAAMiE,UAAUC,UAAU;gBACjCE,iBAAiB;oBACf,MAAMqB,eAAsC,EAAE;oBAE9C,KAAK,MAAM2B,SAAS;wBAClBtC;wBACAC;wBACAC;qBACD,CAAE;wBACD,IAAIoC,yBAAAA,MAAO9H,WAAW,EAAE;4BACtBmG,aAAajB,IAAI,CAAC4C,MAAM9H,WAAW;wBACrC;oBACF;oBAEA,OAAOmG;gBACT;YACF;QACF,EAAE,OAAOzB,OAAO;YACd,OAAOvF,oBAAoBqH,KAAK9B;QAClC;QAEA,IAAI,CAAChE,QAAQ;YACX,OAAOrB,UAAUmH;QACnB;QAEA,OAAOpH,KAAKoH,KAAK9F,OAAOG,SAAS;IACnC;AACF"}
|
package/dist/esm/client/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import { onRecoverableError } from './react-client-callbacks/on-recoverable-erro
|
|
|
27
27
|
import tracer from './tracing/tracer';
|
|
28
28
|
import reportToSocket from './tracing/report-to-socket';
|
|
29
29
|
import { isNextRouterError } from './components/is-next-router-error';
|
|
30
|
-
export const version = "15.2.0-canary.
|
|
30
|
+
export const version = "15.2.0-canary.48";
|
|
31
31
|
export let router;
|
|
32
32
|
export const emitter = mitt();
|
|
33
33
|
const looseToArray = (input)=>[].slice.call(input);
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Metadata API
|
|
3
|
+
*
|
|
4
|
+
* This file defines the types used by Next.js to configure metadata
|
|
5
|
+
* through static exports or dynamic `generateMetadata` functions in Server Components.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - The static `metadata` object and `generateMetadata` function are only supported in Server Components.
|
|
9
|
+
* - Do not export both a `metadata` object and a `generateMetadata` function from the same route segment.
|
|
10
|
+
* - You can still render metadata in client components directly as part of the component's JSX.
|
|
11
|
+
*
|
|
12
|
+
* @see https://nextjs.org/docs/app/api-reference/metadata
|
|
13
|
+
*/ export { };
|
|
2
14
|
|
|
3
15
|
//# sourceMappingURL=metadata-interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/metadata/types/metadata-interface.ts"],"sourcesContent":["import type {\n AlternateURLs,\n Languages,\n ResolvedAlternateURLs,\n} from './alternative-urls-types'\nimport type {\n AppleWebApp,\n AppLinks,\n Facebook,\n FormatDetection,\n ItunesApp,\n ResolvedAppleWebApp,\n ResolvedAppLinks,\n ResolvedFacebook,\n ViewportLayout,\n} from './extra-types'\nimport type {\n DeprecatedMetadataFields,\n AbsoluteTemplateString,\n Author,\n ColorSchemeEnum,\n Icon,\n Icons,\n IconURL,\n ReferrerEnum,\n ResolvedIcons,\n ResolvedVerification,\n Robots,\n ResolvedRobots,\n TemplateString,\n Verification,\n ThemeColorDescriptor,\n Videos,\n} from './metadata-types'\nimport type { Manifest as ManifestFile } from './manifest-types'\nimport type { OpenGraph, ResolvedOpenGraph } from './opengraph-types'\nimport type { ResolvedTwitterMetadata, Twitter } from './twitter-types'\n\n/**\n * Metadata interface to describe all the metadata fields that can be set in a document.\n * @interface\n */\ninterface Metadata extends DeprecatedMetadataFields {\n /**\n * The base path and origin for absolute urls for various metadata links such as OpenGraph images.\n */\n metadataBase?: null | URL | undefined\n\n /**\n * The document title.\n * @example\n * ```tsx\n * \"My Blog\"\n * <title>My Blog</title>\n *\n * { default: \"Dashboard\", template: \"%s | My Website\" }\n * <title>Dashboard | My Website</title>\n *\n * { absolute: \"My Blog\", template: \"%s | My Website\" }\n * <title>My Blog</title>\n * ```\n */\n title?: null | string | TemplateString | undefined\n\n /**\n * The document description, and optionally the OpenGraph and twitter descriptions.\n * @example\n * ```tsx\n * \"My Blog Description\"\n * <meta name=\"description\" content=\"My Blog Description\" />\n * ```\n */\n description?: null | string | undefined\n\n // Standard metadata names\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name\n\n /**\n * The application name.\n * @example\n * ```tsx\n * \"My Blog\"\n * <meta name=\"application-name\" content=\"My Blog\" />\n * ```\n */\n applicationName?: null | string | undefined\n\n /**\n * The authors of the document.\n * @example\n * ```tsx\n * [{ name: \"Next.js Team\", url: \"https://nextjs.org\" }]\n *\n * <meta name=\"author\" content=\"Next.js Team\" />\n * <link rel=\"author\" href=\"https://nextjs.org\" />\n * ```\n */\n authors?: null | Author | Array<Author> | undefined\n\n /**\n * The generator used for the document.\n * @example\n * ```tsx\n * \"Next.js\"\n *\n * <meta name=\"generator\" content=\"Next.js\" />\n * ```\n */\n generator?: null | string | undefined\n\n /**\n * The keywords for the document. If an array is provided, it will be flattened into a single tag with comma separation.\n * @example\n * ```tsx\n * \"nextjs, react, blog\"\n * <meta name=\"keywords\" content=\"nextjs, react, blog\" />\n *\n * [\"react\", \"server components\"]\n * <meta name=\"keywords\" content=\"react, server components\" />\n * ```\n */\n keywords?: null | string | Array<string> | undefined\n\n /**\n * The referrer setting for the document.\n * @example\n * ```tsx\n * \"origin\"\n * <meta name=\"referrer\" content=\"origin\" />\n * ```\n */\n referrer?: null | ReferrerEnum | undefined\n\n /**\n * The theme color for the document.\n * @deprecated Use `export const viewport: Viewport = { ... }` instead.\n * @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#the-viewport-object\n * @example\n * ```tsx\n * \"#000000\"\n * <meta name=\"theme-color\" content=\"#000000\" />\n *\n * { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" }\n * <meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"#000000\" />\n *\n * [\n * { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" },\n * { media: \"(prefers-color-scheme: light)\", color: \"#ffffff\" }\n * ]\n * <meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"#000000\" />\n * <meta name=\"theme-color\" media=\"(prefers-color-scheme: light)\" content=\"#ffffff\" />\n * ```\n */\n themeColor?:\n | null\n | string\n | ThemeColorDescriptor\n | ThemeColorDescriptor[]\n | undefined\n\n /**\n * The color scheme for the document.\n * @deprecated Use `export const viewport: Viewport = { ... }` instead.\n * @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#the-viewport-object\n * @example\n * ```tsx\n * \"dark\"\n * <meta name=\"color-scheme\" content=\"dark\" />\n * ```\n */\n colorScheme?: null | ColorSchemeEnum | undefined\n\n /**\n * The viewport setting for the document.\n * @deprecated Use `export const viewport: Viewport = { ... }` instead.\n * @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#the-viewport-object\n * @example\n * ```tsx\n * { width: \"device-width\", initialScale: 1 }\n * <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n * ```\n */\n viewport?: null | string | ViewportLayout | undefined\n\n /**\n * The creator of the document.\n * @example\n * ```tsx\n * \"Next.js Team\"\n * <meta name=\"creator\" content=\"Next.js Team\" />\n * ```\n */\n creator?: null | string | undefined\n\n /**\n * The publisher of the document.\n * @example\n *\n * ```tsx\n * \"Vercel\"\n * <meta name=\"publisher\" content=\"Vercel\" />\n * ```\n */\n publisher?: null | string | undefined\n\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name#other_metadata_names\n\n /**\n * The robots setting for the document.\n *\n * @see https://developer.mozilla.org/docs/Glossary/Robots.txt\n * @example\n * ```tsx\n * \"index, follow\"\n * <meta name=\"robots\" content=\"index, follow\" />\n *\n * { index: false, follow: false }\n * <meta name=\"robots\" content=\"noindex, nofollow\" />\n * ```\n */\n robots?: null | string | Robots | undefined\n\n /**\n * The canonical and alternate URLs for the document.\n * @example\n * ```tsx\n * { canonical: \"https://example.com\" }\n * <link rel=\"canonical\" href=\"https://example.com\" />\n *\n * { canonical: \"https://example.com\", hreflang: { \"en-US\": \"https://example.com/en-US\" } }\n * <link rel=\"canonical\" href=\"https://example.com\" />\n * <link rel=\"alternate\" href=\"https://example.com/en-US\" hreflang=\"en-US\" />\n * ```\n *\n * Multiple titles example for alternate URLs except `canonical`:\n * ```tsx\n * {\n * canonical: \"https://example.com\",\n * types: {\n * 'application/rss+xml': [\n * { url: 'blog.rss', title: 'rss' },\n * { url: 'blog/js.rss', title: 'js title' },\n * ],\n * },\n * }\n * <link rel=\"canonical\" href=\"https://example.com\" />\n * <link rel=\"alternate\" href=\"https://example.com/blog.rss\" type=\"application/rss+xml\" title=\"rss\" />\n * <link rel=\"alternate\" href=\"https://example.com/blog/js.rss\" type=\"application/rss+xml\" title=\"js title\" />\n * ```\n */\n alternates?: null | AlternateURLs | undefined\n\n /**\n * The icons for the document. Defaults to rel=\"icon\".\n *\n * @see https://developer.mozilla.org/docs/Web/HTML/Attributes/rel#attr-icon\n * @example\n * ```tsx\n * \"https://example.com/icon.png\"\n * <link rel=\"icon\" href=\"https://example.com/icon.png\" />\n *\n * { icon: \"https://example.com/icon.png\", apple: \"https://example.com/apple-icon.png\" }\n * <link rel=\"icon\" href=\"https://example.com/icon.png\" />\n * <link rel=\"apple-touch-icon\" href=\"https://example.com/apple-icon.png\" />\n *\n * [{ rel: \"icon\", url: \"https://example.com/icon.png\" }, { rel: \"apple-touch-icon\", url: \"https://example.com/apple-icon.png\" }]\n * <link rel=\"icon\" href=\"https://example.com/icon.png\" />\n * <link rel=\"apple-touch-icon\" href=\"https://example.com/apple-icon.png\" />\n * ```\n */\n icons?: null | IconURL | Array<Icon> | Icons | undefined\n\n /**\n * A web application manifest, as defined in the Web Application Manifest specification.\n *\n * @see https://developer.mozilla.org/docs/Web/Manifest\n * @example\n * ```tsx\n * \"https://example.com/manifest.json\"\n * <link rel=\"manifest\" href=\"https://example.com/manifest.json\" />\n * ```\n *\n */\n manifest?: null | string | URL | undefined\n\n /**\n * The Open Graph metadata for the document.\n *\n * @see https://ogp.me\n * @example\n * ```tsx\n * {\n * type: \"website\",\n * url: \"https://example.com\",\n * title: \"My Website\",\n * description: \"My Website Description\",\n * siteName: \"My Website\",\n * images: [{\n * url: \"https://example.com/og.png\",\n * }],\n * }\n *\n * <meta property=\"og:type\" content=\"website\" />\n * <meta property=\"og:url\" content=\"https://example.com\" />\n * <meta property=\"og:site_name\" content=\"My Website\" />\n * <meta property=\"og:title\" content=\"My Website\" />\n * <meta property=\"og:description\" content=\"My Website Description\" />\n * <meta property=\"og:image\" content=\"https://example.com/og.png\" />\n * ```\n */\n openGraph?: null | OpenGraph | undefined\n\n /**\n * The Twitter metadata for the document.\n * @example\n * ```tsx\n * { card: \"summary_large_image\", site: \"@site\", creator: \"@creator\", images: \"https://example.com/og.png\" }\n *\n * <meta name=\"twitter:card\" content=\"summary_large_image\" />\n * <meta name=\"twitter:site\" content=\"@site\" />\n * <meta name=\"twitter:creator\" content=\"@creator\" />\n * <meta name=\"twitter:title\" content=\"My Website\" />\n * <meta name=\"twitter:description\" content=\"My Website Description\" />\n * <meta name=\"twitter:image\" content=\"https://example.com/og.png\" />\n * ```\n *\n */\n twitter?: null | Twitter | undefined\n\n /**\n * The Facebook metadata for the document.\n * You can specify either appId or admins, but not both.\n * @example\n * ```tsx\n * { appId: \"12345678\" }\n *\n * <meta property=\"fb:app_id\" content=\"12345678\" />\n * ```\n *\n * @example\n * ```tsx\n * { admins: [\"12345678\"] }\n *\n * <meta property=\"fb:admins\" content=\"12345678\" />\n * ```\n */\n facebook?: null | Facebook | undefined\n\n /**\n * The common verification tokens for the document.\n * @example\n * ```tsx\n * { verification: { google: \"1234567890\", yandex: \"1234567890\", \"me\": \"1234567890\" } }\n * <meta name=\"google-site-verification\" content=\"1234567890\" />\n * <meta name=\"yandex-verification\" content=\"1234567890\" />\n * <meta name=\"me\" content=\"@me\" />\n * ```\n */\n verification?: Verification | undefined\n\n /**\n * The Apple web app metadata for the document.\n *\n * @see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html\n * @example\n * ```tsx\n * { capable: true, title: \"My Website\", statusBarStyle: \"black-translucent\" }\n * <meta name=\"mobile-web-app-capable\" content=\"yes\" />\n * <meta name=\"apple-mobile-web-app-title\" content=\"My Website\" />\n * <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\" />\n * ```\n *\n */\n appleWebApp?: null | boolean | AppleWebApp | undefined\n\n /**\n * Indicates if devices should try to interpret various formats and make actionable links out of them. For example it controles\n * if telephone numbers on mobile that can be clicked to dial or not.\n * @example\n * ```tsx\n * { telephone: false }\n * <meta name=\"format-detection\" content=\"telephone=no\" />\n * ```\n *\n */\n formatDetection?: null | FormatDetection | undefined\n\n /**\n * The metadata for the iTunes App.\n * It adds the `name=\"apple-itunes-app\"` meta tag.\n *\n * @example\n * ```tsx\n * { app: { id: \"123456789\", affiliateData: \"123456789\", appArguments: \"123456789\" } }\n * <meta name=\"apple-itunes-app\" content=\"app-id=123456789, affiliate-data=123456789, app-arguments=123456789\" />\n * ```\n */\n itunes?: null | ItunesApp | undefined\n\n /**\n * A brief description of what this web-page is about. Not recommended, superseded by description.\n * It adds the `name=\"abstract\"` meta tag.\n *\n * @see https://www.metatags.org/all-meta-tags-overview/meta-name-abstract/\n * @example\n * ```tsx\n * \"My Website Description\"\n * <meta name=\"abstract\" content=\"My Website Description\" />\n * ```\n */\n abstract?: null | string | undefined\n\n /**\n * The Facebook AppLinks metadata for the document.\n * @example\n * ```tsx\n * { ios: { appStoreId: \"123456789\", url: \"https://example.com\" }, android: { packageName: \"com.example\", url: \"https://example.com\" } }\n *\n * <meta property=\"al:ios:app_store_id\" content=\"123456789\" />\n * <meta property=\"al:ios:url\" content=\"https://example.com\" />\n * <meta property=\"al:android:package\" content=\"com.example\" />\n * <meta property=\"al:android:url\" content=\"https://example.com\" />\n * ```\n */\n appLinks?: null | AppLinks | undefined\n\n /**\n * The archives link rel property.\n * @example\n * ```tsx\n * { archives: \"https://example.com/archives\" }\n * <link rel=\"archives\" href=\"https://example.com/archives\" />\n * ```\n */\n archives?: null | string | Array<string> | undefined\n\n /**\n * The assets link rel property.\n * @example\n * ```tsx\n * \"https://example.com/assets\"\n * <link rel=\"assets\" href=\"https://example.com/assets\" />\n * ```\n */\n assets?: null | string | Array<string> | undefined\n\n /**\n * The bookmarks link rel property.\n * @example\n * ```tsx\n * \"https://example.com/bookmarks\"\n * <link rel=\"bookmarks\" href=\"https://example.com/bookmarks\" />\n * ```\n */\n bookmarks?: null | string | Array<string> | undefined // This is technically against HTML spec but is used in wild\n\n /**\n * The pagination link rel properties.\n *\n * @see https://developers.google.com/search/blog/2011/09/pagination-with-relnext-and-relprev\n * @example\n * ```tsx\n * \"https://example.com/items\"\n * <link rel=\"prev\" href=\"https://example.com/items?page=1\" />\n * <link rel=\"next\" href=\"https://example.com/items?page=3\" />\n * ```\n */\n pagination?: {\n previous?: null | string | URL | undefined\n next?: null | string | URL | undefined\n }\n\n // meta name properties\n\n /**\n * The category meta name property.\n * @example\n * ```tsx\n * \"My Category\"\n * <meta name=\"category\" content=\"My Category\" />\n * ```\n */\n category?: null | string | undefined\n\n /**\n * The classification meta name property.\n * @example\n * ```tsx\n * \"My Classification\"\n * <meta name=\"classification\" content=\"My Classification\" />\n * ```\n */\n classification?: null | string | undefined\n\n /**\n * Arbitrary name/value pairs for the document.\n */\n other?:\n | ({\n [name: string]: string | number | Array<string | number>\n } & DeprecatedMetadataFields)\n | undefined\n}\n\ninterface ResolvedMetadata extends DeprecatedMetadataFields {\n // origin and base path for absolute urls for various metadata links such as\n // opengraph-image\n metadataBase: null | URL\n\n // The Document title and template if defined\n title: null | AbsoluteTemplateString\n\n // The Document description, and optionally the opengraph and twitter descriptions\n description: null | string\n\n // Standard metadata names\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name\n applicationName: null | string\n authors: null | Array<Author>\n generator: null | string\n // if you provide an array it will be flattened into a single tag with comma separation\n keywords: null | Array<string>\n referrer: null | ReferrerEnum\n /**\n * @deprecated\n */\n themeColor: null | ThemeColorDescriptor[]\n /**\n * @deprecated\n */\n colorScheme: null | ColorSchemeEnum\n /**\n * @deprecated\n */\n viewport: null | string\n creator: null | string\n publisher: null | string\n\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name#other_metadata_names\n robots: null | ResolvedRobots\n\n // The canonical and alternate URLs for this location\n alternates: null | ResolvedAlternateURLs\n\n // Defaults to rel=\"icon\" but the Icons type can be used\n // to get more specific about rel types\n icons: null | ResolvedIcons\n\n openGraph: null | ResolvedOpenGraph\n\n manifest: null | string | URL\n\n twitter: null | ResolvedTwitterMetadata\n\n facebook: null | ResolvedFacebook\n\n // common verification tokens\n verification: null | ResolvedVerification\n\n // Apple web app metadata\n // https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html\n appleWebApp: null | ResolvedAppleWebApp\n\n // Should devices try to interpret various formats and make actionable links\n // out of them? The canonical example is telephone numbers on mobile that can\n // be clicked to dial\n formatDetection: null | FormatDetection\n\n // meta name=\"apple-itunes-app\"\n itunes: null | ItunesApp\n\n // meta name=\"abstract\"\n // A brief description of what this web-page is about.\n // Not recommended, superceded by description.\n // https://www.metatags.org/all-meta-tags-overview/meta-name-abstract/\n abstract: null | string\n\n // Facebook AppLinks\n appLinks: null | ResolvedAppLinks\n\n // link rel properties\n archives: null | Array<string>\n assets: null | Array<string>\n bookmarks: null | Array<string> // This is technically against HTML spec but is used in wild\n pagination: {\n previous: null | string\n next: null | string\n }\n\n // meta name properties\n category: null | string\n classification: null | string\n\n // Arbitrary name/value pairs\n other:\n | null\n | ({\n [name: string]: string | number | Array<string | number>\n } & DeprecatedMetadataFields)\n}\n\ntype RobotsFile = {\n // Apply rules for all\n rules:\n | {\n userAgent?: string | string[] | undefined\n allow?: string | string[] | undefined\n disallow?: string | string[] | undefined\n crawlDelay?: number | undefined\n }\n // Apply rules for specific user agents\n | Array<{\n userAgent: string | string[]\n allow?: string | string[] | undefined\n disallow?: string | string[] | undefined\n crawlDelay?: number | undefined\n }>\n sitemap?: string | string[] | undefined\n host?: string | undefined\n}\n\ntype SitemapFile = Array<{\n url: string\n lastModified?: string | Date | undefined\n changeFrequency?:\n | 'always'\n | 'hourly'\n | 'daily'\n | 'weekly'\n | 'monthly'\n | 'yearly'\n | 'never'\n | undefined\n priority?: number | undefined\n alternates?:\n | {\n languages?: Languages<string> | undefined\n }\n | undefined\n images?: string[] | undefined\n videos?: Videos[] | undefined\n}>\n\ntype ResolvingMetadata = Promise<ResolvedMetadata>\ndeclare namespace MetadataRoute {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n export type Robots = RobotsFile\n export type Sitemap = SitemapFile\n export type Manifest = ManifestFile\n}\n\ninterface Viewport extends ViewportLayout {\n /**\n * The theme color for the document.\n * @example\n *\n * ```tsx\n * \"#000000\"\n * <meta name=\"theme-color\" content=\"#000000\" />\n *\n * { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" }\n * <meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"#000000\" />\n *\n * [\n * { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" },\n * { media: \"(prefers-color-scheme: light)\", color: \"#ffffff\" }\n * ]\n * <meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"#000000\" />\n * <meta name=\"theme-color\" media=\"(prefers-color-scheme: light)\" content=\"#ffffff\" />\n * ```\n */\n themeColor?:\n | null\n | string\n | ThemeColorDescriptor\n | ThemeColorDescriptor[]\n | undefined\n\n /**\n * The color scheme for the document.\n * @example\n *\n * ```tsx\n * \"dark\"\n * <meta name=\"color-scheme\" content=\"dark\" />\n * ```\n */\n colorScheme?: null | ColorSchemeEnum | undefined\n}\n\ntype ResolvingViewport = Promise<Viewport>\n\ninterface ResolvedViewport extends ViewportLayout {\n themeColor: null | ThemeColorDescriptor[]\n colorScheme: null | ColorSchemeEnum\n}\n\nexport type {\n Metadata,\n ResolvedMetadata,\n ResolvingMetadata,\n MetadataRoute,\n Viewport,\n ResolvingViewport,\n ResolvedViewport,\n}\n"],"names":[],"mappings":"AAyrBA,WAQC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/metadata/types/metadata-interface.ts"],"sourcesContent":["/**\n * Next.js Metadata API\n *\n * This file defines the types used by Next.js to configure metadata\n * through static exports or dynamic `generateMetadata` functions in Server Components.\n *\n * @remarks\n * - The static `metadata` object and `generateMetadata` function are only supported in Server Components.\n * - Do not export both a `metadata` object and a `generateMetadata` function from the same route segment.\n * - You can still render metadata in client components directly as part of the component's JSX.\n *\n * @see https://nextjs.org/docs/app/api-reference/metadata\n */\n\nimport type {\n AlternateURLs,\n Languages,\n ResolvedAlternateURLs,\n} from './alternative-urls-types'\nimport type {\n AppleWebApp,\n AppLinks,\n Facebook,\n FormatDetection,\n ItunesApp,\n ResolvedAppleWebApp,\n ResolvedAppLinks,\n ResolvedFacebook,\n ViewportLayout,\n} from './extra-types'\nimport type {\n DeprecatedMetadataFields,\n AbsoluteTemplateString,\n Author,\n ColorSchemeEnum,\n Icon,\n Icons,\n IconURL,\n ReferrerEnum,\n ResolvedIcons,\n ResolvedVerification,\n Robots,\n ResolvedRobots,\n TemplateString,\n Verification,\n ThemeColorDescriptor,\n Videos,\n} from './metadata-types'\nimport type { Manifest as ManifestFile } from './manifest-types'\nimport type { OpenGraph, ResolvedOpenGraph } from './opengraph-types'\nimport type { ResolvedTwitterMetadata, Twitter } from './twitter-types'\n\n/**\n * Metadata interface to describe all the metadata fields that can be set in a document.\n *\n * @remarks\n * This interface covers all the metadata fields available in Next.js including title, description,\n * icons, openGraph, twitter, and more. Fields such as `metadataBase` help in composing absolute URLs\n * from relative ones. The `title` field supports both simple strings and a template object with `default`,\n * `template`, and `absolute` properties.\n *\n * @example\n * ```tsx\n * // Static metadata export in a layout or page:\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * metadataBase: new URL('https://example.com'),\n * title: { default: 'My Site', template: '%s | My Site' },\n * description: 'Welcome to My Site',\n * alternates: {\n * canonical: 'https://example.com',\n * languages: {\n * 'en-US': 'https://example.com/en-US',\n * 'de-DE': 'https://example.com/de-DE'\n * }\n * },\n * openGraph: {\n * title: 'My Site',\n * description: 'Welcome to My Site',\n * url: 'https://example.com',\n * siteName: 'My Site',\n * images: [{ url: 'https://example.com/og.png' }]\n * },\n * }\n * ```\n */\ninterface Metadata extends DeprecatedMetadataFields {\n /**\n * The base path and origin for absolute URLs in various metadata fields.\n *\n * @remarks\n * When relative URLs (for Open Graph images, alternates, etc.) are used, they are composed with this base.\n * If not provided, Next.js will populate a default value based on environment variables.\n */\n metadataBase?: null | URL | undefined\n\n /**\n * The document title.\n *\n * @remarks\n * The title can be a simple string (e.g., `\"My Blog\"`) or an object with:\n * - `default`: A fallback title for child segments.\n * - `template`: A title template (e.g., `\"%s | My Website\"`) applied to child titles.\n * - `absolute`: A title that overrides parent templates.\n *\n * @example\n * ```tsx\n * // As a simple string:\n * title: \"My Blog\"\n *\n * // As a template object:\n * title: { default: \"Dashboard\", template: \"%s | My Website\" }\n *\n * // Using absolute value (ignores parent template):\n * title: { absolute: \"My Blog\", template: \"%s | My Website\" }\n * ```\n */\n title?: null | string | TemplateString | undefined\n\n /**\n * The document description, and optionally the Open Graph and Twitter descriptions.\n *\n * @example\n * ```tsx\n * description: \"My Blog Description\"\n * // Renders: <meta name=\"description\" content=\"My Blog Description\" />\n * ```\n */\n description?: null | string | undefined\n\n // Standard metadata names\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name\n\n /**\n * The application name.\n *\n * @example\n * ```tsx\n * applicationName: \"My Blog\"\n * // Renders: <meta name=\"application-name\" content=\"My Blog\" />\n * ```\n */\n applicationName?: null | string | undefined\n\n /**\n * The authors of the document.\n *\n * @example\n * ```tsx\n * authors: [{ name: \"Next.js Team\", url: \"https://nextjs.org\" }]\n * // Renders:\n * // <meta name=\"author\" content=\"Next.js Team\" />\n * // <link rel=\"author\" href=\"https://nextjs.org\" />\n * ```\n */\n authors?: null | Author | Array<Author> | undefined\n\n /**\n * The generator used for the document.\n *\n * @example\n * ```tsx\n * generator: \"Next.js\"\n * // Renders: <meta name=\"generator\" content=\"Next.js\" />\n * ```\n */\n generator?: null | string | undefined\n\n /**\n * The keywords for the document.\n *\n * @remarks\n * When an array is provided, keywords are flattened into a comma-separated string.\n *\n * @example\n * ```tsx\n * keywords: \"nextjs, react, blog\"\n * // or\n * keywords: [\"react\", \"server components\"]\n * ```\n */\n keywords?: null | string | Array<string> | undefined\n\n /**\n * The referrer setting for the document.\n *\n * @example\n * ```tsx\n * referrer: \"origin\"\n * // Renders: <meta name=\"referrer\" content=\"origin\" />\n * ```\n */\n referrer?: null | ReferrerEnum | undefined\n\n /**\n * The theme color for the document.\n *\n * @deprecated Use the new viewport configuration (`export const viewport: Viewport = { ... }`) instead.\n */\n themeColor?:\n | null\n | string\n | ThemeColorDescriptor\n | ThemeColorDescriptor[]\n | undefined\n\n /**\n * The color scheme for the document.\n *\n * @deprecated Use the new viewport configuration (`export const viewport: Viewport = { ... }`) instead.\n */\n colorScheme?: null | ColorSchemeEnum | undefined\n\n /**\n * The viewport setting for the document.\n *\n * @deprecated Use the new viewport configuration (`export const viewport: Viewport = { ... }`) instead.\n */\n viewport?: null | string | ViewportLayout | undefined\n\n /**\n * The creator of the document.\n *\n * @example\n * ```tsx\n * creator: \"Next.js Team\"\n * // Renders: <meta name=\"creator\" content=\"Next.js Team\" />\n * ```\n */\n creator?: null | string | undefined\n\n /**\n * The publisher of the document.\n *\n * @example\n * ```tsx\n * publisher: \"Vercel\"\n * // Renders: <meta name=\"publisher\" content=\"Vercel\" />\n * ```\n */\n publisher?: null | string | undefined\n\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name#other_metadata_names\n\n /**\n * The robots setting for the document.\n *\n * @remarks\n * Can be a string (e.g., \"index, follow\") or an object with more granular rules.\n *\n * @example\n * ```tsx\n * robots: \"index, follow\"\n * // or\n * robots: { index: true, follow: true }\n * ```\n *\n * @see https://developer.mozilla.org/docs/Glossary/Robots.txt\n */\n robots?: null | string | Robots | undefined\n\n /**\n * The canonical and alternate URLs for the document.\n *\n * @remarks\n * This field allows defining a canonical URL as well as alternate URLs (such as for multiple languages).\n *\n * @example\n * ```tsx\n * alternates: {\n * canonical: \"https://example.com\",\n * languages: {\n * \"en-US\": \"https://example.com/en-US\"\n * }\n * }\n * ```\n */\n alternates?: null | AlternateURLs | undefined\n\n /**\n * The icons for the document. Defaults to rel=\"icon\".\n *\n * @remarks\n * You can specify a simple URL or an object to differentiate between icon types (e.g., apple-touch-icon).\n *\n * @example\n * ```tsx\n * icons: \"https://example.com/icon.png\"\n * // or\n * icons: {\n * icon: \"https://example.com/icon.png\",\n * apple: \"https://example.com/apple-icon.png\"\n * }\n * ```\n *\n * @see https://developer.mozilla.org/docs/Web/HTML/Attributes/rel#attr-icon\n */\n icons?: null | IconURL | Array<Icon> | Icons | undefined\n\n /**\n * A web application manifest, as defined in the Web Application Manifest specification.\n *\n * @example\n * ```tsx\n * manifest: \"https://example.com/manifest.json\"\n * // Renders: <link rel=\"manifest\" href=\"https://example.com/manifest.json\" />\n * ```\n *\n * @see https://developer.mozilla.org/docs/Web/Manifest\n */\n manifest?: null | string | URL | undefined\n\n /**\n * The Open Graph metadata for the document.\n *\n * @remarks\n * Follows the Open Graph protocol to enrich link previews.\n *\n * @example\n * ```tsx\n * openGraph: {\n * type: \"website\",\n * url: \"https://example.com\",\n * title: \"My Website\",\n * description: \"My Website Description\",\n * siteName: \"My Website\",\n * images: [{ url: \"https://example.com/og.png\" }]\n * }\n * ```\n *\n * @see https://ogp.me/\n */\n openGraph?: null | OpenGraph | undefined\n\n /**\n * The Twitter metadata for the document.\n *\n * @remarks\n * - Used for configuring Twitter Cards and can include details such as `card`, `site`, and `creator`.\n * - Notably, more sites than just Twitter (now X) use this format.\n *\n * @example\n * ```tsx\n * twitter: {\n * card: \"summary_large_image\",\n * site: \"@site\",\n * creator: \"@creator\",\n * images: \"https://example.com/og.png\"\n * }\n * ```\n */\n twitter?: null | Twitter | undefined\n\n /**\n * The Facebook metadata for the document.\n *\n * @remarks\n * Specify either `appId` or `admins` (but not both) to configure Facebook integration.\n *\n * @example\n * ```tsx\n * facebook: { appId: \"12345678\" }\n * // Renders <meta property=\"fb:app_id\" content=\"12345678\" />\n * // or\n * facebook: { admins: [\"12345678\"] }\n * // Renders <meta property=\"fb:admins\" content=\"12345678\" />\n * ```\n */\n facebook?: null | Facebook | undefined\n\n /**\n * The common verification tokens for the document.\n *\n * @example\n * ```tsx\n * verification: { google: \"1234567890\", yandex: \"1234567890\", \"me\": \"1234567890\" }\n * // Renders <meta name=\"google-site-verification\" content=\"1234567890\" />\n * // <meta name=\"yandex-verification\" content=\"1234567890\" />\n * // <meta name=\"me\" content=\"@me\" />\n * ```\n */\n verification?: Verification | undefined\n\n /**\n * The Apple web app metadata for the document.\n *\n * @example\n * ```tsx\n * appleWebApp: { capable: true, title: \"My Website\", statusBarStyle: \"black-translucent\" }\n * ```\n *\n * @see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html\n */\n appleWebApp?: null | boolean | AppleWebApp | undefined\n\n /**\n * Indicates whether devices should interpret certain formats (such as telephone numbers) as actionable links.\n *\n * @example\n * ```tsx\n * formatDetection: { telephone: false }\n * // Renders: <meta name=\"format-detection\" content=\"telephone=no\" />\n * ```\n */\n formatDetection?: null | FormatDetection | undefined\n\n /**\n * The metadata for the iTunes App.\n *\n * @remarks\n * Adds the `name=\"apple-itunes-app\"` meta tag.\n *\n * @example\n * ```tsx\n * itunes: { app: { id: \"123456789\", affiliateData: \"123456789\", appArguments: \"123456789\" } }\n * // Renders <meta name=\"apple-itunes-app\" content=\"app-id=123456789, affiliate-data=123456789, app-arguments=123456789\" />\n * ```\n */\n itunes?: null | ItunesApp | undefined\n\n /**\n * A brief description of the web page.\n *\n * @remarks\n * Rendered as the `abstract` meta tag. This is *not recommended* as it is superseded by `description`.\n *\n * @example\n * ```tsx\n * abstract: \"My Website Description\"\n * // Renders <meta name=\"abstract\" content=\"My Website Description\" />\n * ```\n */\n abstract?: null | string | undefined\n\n /**\n * The Facebook AppLinks metadata for the document.\n *\n * @example\n * ```tsx\n * appLinks: {\n * ios: { appStoreId: \"123456789\", url: \"https://example.com\" },\n * android: { packageName: \"com.example\", url: \"https://example.com\" }\n * }\n *\n * // Renders\n * <meta property=\"al:ios:app_store_id\" content=\"123456789\" />\n * <meta property=\"al:ios:url\" content=\"https://example.com\" />\n * <meta property=\"al:android:package\" content=\"com.example\" />\n * <meta property=\"al:android:url\" content=\"https://example.com\" />\n * ```\n */\n appLinks?: null | AppLinks | undefined\n\n /**\n * The archives link rel property.\n *\n * @example\n * ```tsx\n * archives: \"https://example.com/archives\"\n * // Renders <link rel=\"archives\" href=\"https://example.com/archives\" />\n * ```\n */\n archives?: null | string | Array<string> | undefined\n\n /**\n * The assets link rel property.\n *\n * @example\n * ```tsx\n * assets: \"https://example.com/assets\"\n * // Renders <link rel=\"assets\" href=\"https://example.com/assets\" />\n * ```\n */\n assets?: null | string | Array<string> | undefined\n\n /**\n * The bookmarks link rel property.\n *\n * @remarks\n * Although technically against the HTML spec, this is used in practice.\n *\n * @example\n * ```tsx\n * bookmarks: \"https://example.com/bookmarks\"\n * // Renders <link rel=\"bookmarks\" href=\"https://example.com/bookmarks\" />\n * ```\n */\n bookmarks?: null | string | Array<string> | undefined\n\n /**\n * The pagination link rel properties.\n *\n * @example\n * ```tsx\n * pagination: {\n * previous: \"https://example.com/items?page=1\",\n * next: \"https://example.com/items?page=3\"\n * }\n *\n * // Renders\n * <link rel=\"prev\" href=\"https://example.com/items?page=1\" />\n * <link rel=\"next\" href=\"https://example.com/items?page=3\" />\n * ```\n *\n * @see https://developers.google.com/search/blog/2011/09/pagination-with-relnext-and-relprev\n */\n pagination?: {\n previous?: null | string | URL | undefined\n next?: null | string | URL | undefined\n }\n\n /**\n * The category meta name property.\n *\n * @example\n * ```tsx\n * category: \"My Category\"\n * // Renders <meta name=\"category\" content=\"My Category\" />\n * ```\n */\n category?: null | string | undefined\n\n /**\n * The classification meta name property.\n *\n * @example\n * ```tsx\n * classification: \"My Classification\"\n * // Renders <meta name=\"classification\" content=\"My Classification\" />\n * ```\n */\n classification?: null | string | undefined\n\n /**\n * Arbitrary name/value pairs for additional metadata.\n *\n * @remarks\n * Use this field to define custom meta tags that are not directly supported.\n *\n * @example\n * ```tsx\n * other: { custom: [\"meta1\", \"meta2\"] }\n * ```\n */\n other?:\n | ({\n [name: string]: string | number | Array<string | number>\n } & DeprecatedMetadataFields)\n | undefined\n}\n\n/**\n * ResolvedMetadata represents the fully processed metadata after defaults are applied\n * and relative URLs are composed with `metadataBase`.\n */\ninterface ResolvedMetadata extends DeprecatedMetadataFields {\n // origin and base path for absolute urls for various metadata links such as\n // opengraph-image\n metadataBase: null | URL\n\n // The Document title and template if defined\n title: null | AbsoluteTemplateString\n\n // The Document description, and optionally the opengraph and twitter descriptions\n description: null | string\n\n // Standard metadata names\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name\n applicationName: null | string\n authors: null | Array<Author>\n generator: null | string\n // if you provide an array it will be flattened into a single tag with comma separation\n keywords: null | Array<string>\n referrer: null | ReferrerEnum\n /**\n * @deprecated\n */\n themeColor: null | ThemeColorDescriptor[]\n /**\n * @deprecated\n */\n colorScheme: null | ColorSchemeEnum\n /**\n * @deprecated\n */\n viewport: null | string\n creator: null | string\n publisher: null | string\n\n // https://developer.mozilla.org/docs/Web/HTML/Element/meta/name#other_metadata_names\n robots: null | ResolvedRobots\n\n // The canonical and alternate URLs for this location\n alternates: null | ResolvedAlternateURLs\n\n // Defaults to rel=\"icon\" but the Icons type can be used\n // to get more specific about rel types\n icons: null | ResolvedIcons\n\n openGraph: null | ResolvedOpenGraph\n\n manifest: null | string | URL\n\n twitter: null | ResolvedTwitterMetadata\n\n facebook: null | ResolvedFacebook\n\n // common verification tokens\n verification: null | ResolvedVerification\n\n // Apple web app metadata\n // https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html\n appleWebApp: null | ResolvedAppleWebApp\n\n // Should devices try to interpret various formats and make actionable links\n // out of them? The canonical example is telephone numbers on mobile that can\n // be clicked to dial\n formatDetection: null | FormatDetection\n\n // meta name=\"apple-itunes-app\"\n itunes: null | ItunesApp\n\n // meta name=\"abstract\"\n // A brief description of what this web-page is about.\n // Not recommended, superceded by description.\n // https://www.metatags.org/all-meta-tags-overview/meta-name-abstract/\n abstract: null | string\n\n // Facebook AppLinks\n appLinks: null | ResolvedAppLinks\n\n // link rel properties\n archives: null | Array<string>\n assets: null | Array<string>\n bookmarks: null | Array<string> // This is technically against HTML spec but is used in wild\n pagination: {\n previous: null | string\n next: null | string\n }\n\n // meta name properties\n category: null | string\n classification: null | string\n other:\n | null\n | ({\n [name: string]: string | number | Array<string | number>\n } & DeprecatedMetadataFields)\n}\n\ntype RobotsFile = {\n // Apply rules for all\n rules:\n | {\n userAgent?: string | string[] | undefined\n allow?: string | string[] | undefined\n disallow?: string | string[] | undefined\n crawlDelay?: number | undefined\n }\n // Apply rules for specific user agents\n | Array<{\n userAgent: string | string[]\n allow?: string | string[] | undefined\n disallow?: string | string[] | undefined\n crawlDelay?: number | undefined\n }>\n sitemap?: string | string[] | undefined\n host?: string | undefined\n}\n\ntype SitemapFile = Array<{\n url: string\n lastModified?: string | Date | undefined\n changeFrequency?:\n | 'always'\n | 'hourly'\n | 'daily'\n | 'weekly'\n | 'monthly'\n | 'yearly'\n | 'never'\n | undefined\n priority?: number | undefined\n alternates?:\n | {\n languages?: Languages<string> | undefined\n }\n | undefined\n images?: string[] | undefined\n videos?: Videos[] | undefined\n}>\n\ntype ResolvingMetadata = Promise<ResolvedMetadata>\ndeclare namespace MetadataRoute {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n export type Robots = RobotsFile\n export type Sitemap = SitemapFile\n export type Manifest = ManifestFile\n}\n\n/**\n * Interface for the viewport configuration.\n *\n * @remarks\n * This configuration allows defining properties such as width, initial scale, theme colors,\n * and color scheme.\n *\n * @example\n * ```tsx\n * export const viewport: Viewport = {\n * width: \"device-width\",\n * initialScale: 1,\n * themeColor: [\n * { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" },\n * { media: \"(prefers-color-scheme: light)\", color: \"#ffffff\" }\n * ],\n * colorScheme: \"dark\"\n * }\n * ```\n */\ninterface Viewport extends ViewportLayout {\n /**\n * The theme color for the document.\n *\n * @example\n * ```tsx\n * themeColor: \"#000000\"\n * // Renders <meta name=\"theme-color\" content=\"#000000\" />\n *\n * themeColor: { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" }\n * // Renders <meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"#000000\" />\n *\n * themeColor: [\n * { media: \"(prefers-color-scheme: dark)\", color: \"#000000\" },\n * { media: \"(prefers-color-scheme: light)\", color: \"#ffffff\" }\n * ]\n * // Renders <meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"#000000\" />\n * // Renders <meta name=\"theme-color\" media=\"(prefers-color-scheme: light)\" content=\"#ffffff\" />\n * ```\n */\n themeColor?:\n | null\n | string\n | ThemeColorDescriptor\n | ThemeColorDescriptor[]\n | undefined\n\n /**\n * The color scheme for the document.\n *\n * @example\n * ```tsx\n * colorScheme: \"dark\"\n * // Renders <meta name=\"color-scheme\" content=\"dark\" />\n * ```\n */\n colorScheme?: null | ColorSchemeEnum | undefined\n}\n\ntype ResolvingViewport = Promise<Viewport>\n\ninterface ResolvedViewport extends ViewportLayout {\n themeColor: null | ThemeColorDescriptor[]\n colorScheme: null | ColorSchemeEnum\n}\n\nexport type {\n Metadata,\n ResolvedMetadata,\n ResolvingMetadata,\n MetadataRoute,\n Viewport,\n ResolvingViewport,\n ResolvedViewport,\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAmvBD,WAQC"}
|
|
@@ -177,7 +177,7 @@ function assignDefaults(dir, userConfig, silent) {
|
|
|
177
177
|
enumerable: false
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
-
if (!((_process_env___NEXT_VERSION = "15.2.0-canary.
|
|
180
|
+
if (!((_process_env___NEXT_VERSION = "15.2.0-canary.48") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV) {
|
|
181
181
|
var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9;
|
|
182
182
|
// Prevents usage of certain experimental features outside of canary
|
|
183
183
|
if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
|
|
@@ -80,7 +80,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
|
|
|
80
80
|
}
|
|
81
81
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
|
82
82
|
const hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
83
|
-
version: "15.2.0-canary.
|
|
83
|
+
version: "15.2.0-canary.48"
|
|
84
84
|
});
|
|
85
85
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
86
86
|
// of the current `next dev` invocation.
|
|
@@ -178,7 +178,7 @@ export default class HotReloaderWebpack {
|
|
|
178
178
|
this.previewProps = previewProps;
|
|
179
179
|
this.rewrites = rewrites;
|
|
180
180
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
181
|
-
version: "15.2.0-canary.
|
|
181
|
+
version: "15.2.0-canary.48"
|
|
182
182
|
});
|
|
183
183
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
184
184
|
// of the current `next dev` invocation.
|
|
@@ -4,7 +4,7 @@ import { bold, purple } from '../../lib/picocolors';
|
|
|
4
4
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from '../../shared/lib/constants';
|
|
5
5
|
import loadConfig, { getConfiguredExperimentalFeatures } from '../config';
|
|
6
6
|
export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, maxExperimentalFeatures = Infinity }) {
|
|
7
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.2.0-canary.
|
|
7
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.2.0-canary.48"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
|
|
8
8
|
if (appUrl) {
|
|
9
9
|
Log.bootstrap(`- Local: ${appUrl}`);
|
|
10
10
|
}
|
|
@@ -43,7 +43,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
|
43
43
|
export async function startServer(serverOptions) {
|
|
44
44
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
45
45
|
let { port } = serverOptions;
|
|
46
|
-
process.title = `next-server (v${"15.2.0-canary.
|
|
46
|
+
process.title = `next-server (v${"15.2.0-canary.48"})`;
|
|
47
47
|
let handlersReady = ()=>{};
|
|
48
48
|
let handlersError = ()=>{};
|
|
49
49
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -73,6 +73,19 @@ function shouldIgnoreListOriginalFrame(file) {
|
|
|
73
73
|
return payload;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
function createUnsourcemappedFrame(frame) {
|
|
77
|
+
return {
|
|
78
|
+
stack: {
|
|
79
|
+
arguments: frame.arguments,
|
|
80
|
+
column: frame.column,
|
|
81
|
+
file: frame.file,
|
|
82
|
+
lineNumber: frame.lineNumber,
|
|
83
|
+
methodName: frame.methodName,
|
|
84
|
+
ignored: shouldIgnoreListGeneratedFrame(frame.file)
|
|
85
|
+
},
|
|
86
|
+
code: null
|
|
87
|
+
};
|
|
88
|
+
}
|
|
76
89
|
/**
|
|
77
90
|
* @param frame
|
|
78
91
|
* @param sourceMapCache
|
|
@@ -83,7 +96,6 @@ function shouldIgnoreListOriginalFrame(file) {
|
|
|
83
96
|
let sourceMapConsumer;
|
|
84
97
|
let sourceMapPayload;
|
|
85
98
|
if (sourceMapCacheEntry === undefined) {
|
|
86
|
-
var _nativeFindSourceMap;
|
|
87
99
|
let sourceURL = frame.file;
|
|
88
100
|
// e.g. "/APP/.next/server/chunks/ssr/[root of the server]__2934a0._.js"
|
|
89
101
|
// will be keyed by Node.js as "file:///APP/.next/server/chunks/ssr/[root%20of%20the%20server]__2934a0._.js".
|
|
@@ -91,23 +103,38 @@ function shouldIgnoreListOriginalFrame(file) {
|
|
|
91
103
|
if (sourceURL.startsWith('/')) {
|
|
92
104
|
sourceURL = url.pathToFileURL(frame.file).toString();
|
|
93
105
|
}
|
|
94
|
-
|
|
106
|
+
let maybeSourceMapPayload;
|
|
107
|
+
try {
|
|
108
|
+
const sourceMap = nativeFindSourceMap(sourceURL);
|
|
109
|
+
maybeSourceMapPayload = sourceMap == null ? void 0 : sourceMap.payload;
|
|
110
|
+
} catch (cause) {
|
|
111
|
+
// We should not log an actual error instance here because that will re-enter
|
|
112
|
+
// this codepath during error inspection and could lead to infinite recursion.
|
|
113
|
+
console.error(`${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`);
|
|
114
|
+
// Don't even fall back to the bundler because it might be not as strict
|
|
115
|
+
// with regards to parsing and then we fail later once we consume the
|
|
116
|
+
// source map payload.
|
|
117
|
+
// This essentially avoids a redundant error where we fail here and then
|
|
118
|
+
// later on consumption because the bundler just handed back an invalid
|
|
119
|
+
// source map.
|
|
120
|
+
return createUnsourcemappedFrame(frame);
|
|
121
|
+
}
|
|
95
122
|
if (maybeSourceMapPayload === undefined) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
file: frame.file,
|
|
101
|
-
lineNumber: frame.lineNumber,
|
|
102
|
-
methodName: frame.methodName,
|
|
103
|
-
ignored: shouldIgnoreListGeneratedFrame(frame.file)
|
|
104
|
-
},
|
|
105
|
-
code: null
|
|
106
|
-
};
|
|
123
|
+
maybeSourceMapPayload = bundlerFindSourceMapPayload(sourceURL);
|
|
124
|
+
}
|
|
125
|
+
if (maybeSourceMapPayload === undefined) {
|
|
126
|
+
return createUnsourcemappedFrame(frame);
|
|
107
127
|
}
|
|
108
128
|
sourceMapPayload = maybeSourceMapPayload;
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
try {
|
|
130
|
+
sourceMapConsumer = new SyncSourceMapConsumer(// @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string
|
|
131
|
+
sourceMapPayload);
|
|
132
|
+
} catch (cause) {
|
|
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 find the original code. Cause: ${cause}`);
|
|
136
|
+
return createUnsourcemappedFrame(frame);
|
|
137
|
+
}
|
|
111
138
|
sourceMapCache.set(frame.file, {
|
|
112
139
|
map: sourceMapConsumer,
|
|
113
140
|
payload: sourceMapPayload
|