create project

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

2
kitabcitab/node_modules/next/dist/lib/chalk.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
declare let chalk: typeof import('next/dist/compiled/chalk');
export default chalk;

15
kitabcitab/node_modules/next/dist/lib/chalk.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
let chalk;
if (process.env.NEXT_RUNTIME === "edge") {
chalk = require("./web/chalk").default;
} else {
chalk = require("next/dist/compiled/chalk");
}
var _default = chalk;
exports.default = _default;
//# sourceMappingURL=chalk.js.map

1
kitabcitab/node_modules/next/dist/lib/chalk.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/chalk.ts"],"names":["chalk","process","env","NEXT_RUNTIME","require","default"],"mappings":"AAAA;;;;;AAAA,IAAIA,KAAK,AAA2C;AAEpD,IAAIC,OAAO,CAACC,GAAG,CAACC,YAAY,KAAK,MAAM,EAAE;IACvCH,KAAK,GAAGI,OAAO,CAAC,aAAa,CAAC,CAACC,OAAO;CACvC,MAAM;IACLL,KAAK,GAAGI,OAAO,CAAC,0BAA0B,CAAC;CAC5C;eAEcJ,KAAK"}

View File

@@ -0,0 +1,7 @@
declare type CoalescedInvoke<T> = {
isOrigin: boolean;
value: T;
};
export declare type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
export declare function withCoalescedInvoke<F extends (...args: any) => any>(func: F): (key: string, args: Parameters<F>) => Promise<CoalescedInvoke<UnwrapPromise<ReturnType<F>>>>;
export {};

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withCoalescedInvoke = withCoalescedInvoke;
const globalInvokeCache = new Map();
function withCoalescedInvoke(func) {
return async function(key, args) {
const entry = globalInvokeCache.get(key);
if (entry) {
return entry.then((res)=>({
isOrigin: false,
value: res.value
}));
}
async function __wrapper() {
return await func.apply(undefined, args);
}
const future = __wrapper().then((res)=>{
globalInvokeCache.delete(key);
return {
isOrigin: true,
value: res
};
}).catch((err)=>{
globalInvokeCache.delete(key);
return Promise.reject(err);
});
globalInvokeCache.set(key, future);
return future;
};
}
//# sourceMappingURL=coalesced-function.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/coalesced-function.ts"],"names":["withCoalescedInvoke","globalInvokeCache","Map","func","key","args","entry","get","then","res","isOrigin","value","__wrapper","apply","undefined","future","delete","catch","err","Promise","reject","set"],"mappings":"AAAA;;;;QASgBA,mBAAmB,GAAnBA,mBAAmB;AAFnC,MAAMC,iBAAiB,GAAG,IAAIC,GAAG,EAA6C;AAEvE,SAASF,mBAAmB,CACjCG,IAAO,EAImD;IAC1D,OAAO,eAAgBC,GAAW,EAAEC,IAAmB,EAAE;QACvD,MAAMC,KAAK,GAAGL,iBAAiB,CAACM,GAAG,CAACH,GAAG,CAAC;QACxC,IAAIE,KAAK,EAAE;YACT,OAAOA,KAAK,CAACE,IAAI,CAAC,CAACC,GAAG,GAAK,CAAC;oBAC1BC,QAAQ,EAAE,KAAK;oBACfC,KAAK,EAAEF,GAAG,CAACE,KAAK;iBACjB,CAAC,CAAC,CAAA;SACJ;QAED,eAAeC,SAAS,GAAG;YACzB,OAAO,MAAMT,IAAI,CAACU,KAAK,CAACC,SAAS,EAAET,IAAI,CAAC,CAAA;SACzC;QAED,MAAMU,MAAM,GAAGH,SAAS,EAAE,CACvBJ,IAAI,CAAC,CAACC,GAAG,GAAK;YACbR,iBAAiB,CAACe,MAAM,CAACZ,GAAG,CAAC;YAC7B,OAAO;gBAAEM,QAAQ,EAAE,IAAI;gBAAEC,KAAK,EAAEF,GAAG;aAAkC,CAAA;SACtE,CAAC,CACDQ,KAAK,CAAC,CAACC,GAAG,GAAK;YACdjB,iBAAiB,CAACe,MAAM,CAACZ,GAAG,CAAC;YAC7B,OAAOe,OAAO,CAACC,MAAM,CAACF,GAAG,CAAC,CAAA;SAC3B,CAAC;QACJjB,iBAAiB,CAACoB,GAAG,CAACjB,GAAG,EAAEW,MAAM,CAAC;QAClC,OAAOA,MAAM,CAAA;KACd,CAAA;CACF"}

4
kitabcitab/node_modules/next/dist/lib/commands.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export declare type cliCommand = (argv?: string[]) => void;
export declare const commands: {
[command: string]: () => Promise<cliCommand>;
};

17
kitabcitab/node_modules/next/dist/lib/commands.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.commands = void 0;
const commands = {
build: ()=>Promise.resolve(require("../cli/next-build").nextBuild),
start: ()=>Promise.resolve(require("../cli/next-start").nextStart),
export: ()=>Promise.resolve(require("../cli/next-export").nextExport),
dev: ()=>Promise.resolve(require("../cli/next-dev").nextDev),
lint: ()=>Promise.resolve(require("../cli/next-lint").nextLint),
telemetry: ()=>Promise.resolve(require("../cli/next-telemetry").nextTelemetry),
info: ()=>Promise.resolve(require("../cli/next-info").nextInfo)
};
exports.commands = commands;
//# sourceMappingURL=commands.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/commands.ts"],"names":["commands","build","Promise","resolve","require","nextBuild","start","nextStart","export","nextExport","dev","nextDev","lint","nextLint","telemetry","nextTelemetry","info","nextInfo"],"mappings":"AAAA;;;;;AAEO,MAAMA,QAAQ,GAAqD;IACxEC,KAAK,EAAE,IAAMC,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,mBAAmB,CAAC,CAACC,SAAS,CAAC;IACpEC,KAAK,EAAE,IAAMJ,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,mBAAmB,CAAC,CAACG,SAAS,CAAC;IACpEC,MAAM,EAAE,IAAMN,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,oBAAoB,CAAC,CAACK,UAAU,CAAC;IACvEC,GAAG,EAAE,IAAMR,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,iBAAiB,CAAC,CAACO,OAAO,CAAC;IAC9DC,IAAI,EAAE,IAAMV,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,kBAAkB,CAAC,CAACS,QAAQ,CAAC;IACjEC,SAAS,EAAE,IACTZ,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,uBAAuB,CAAC,CAACW,aAAa,CAAC;IACjEC,IAAI,EAAE,IAAMd,OAAO,CAACC,OAAO,CAACC,OAAO,CAAC,kBAAkB,CAAC,CAACa,QAAQ,CAAC;CAClE;QATYjB,QAAQ,GAARA,QAAQ"}

View File

@@ -0,0 +1,2 @@
export declare class CompileError extends Error {
}

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
class CompileError extends Error {
}
exports.CompileError = CompileError;
//# sourceMappingURL=compile-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/compile-error.ts"],"names":["CompileError","Error"],"mappings":"AAAA;;;;AAAO,MAAMA,YAAY,SAASC,KAAK;CAAG;QAA7BD,YAAY,GAAZA,YAAY"}

48
kitabcitab/node_modules/next/dist/lib/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import type { ServerRuntime } from '../types';
export declare const MIDDLEWARE_FILENAME = "middleware";
export declare const MIDDLEWARE_LOCATION_REGEXP: string;
export declare const PAGES_DIR_ALIAS = "private-next-pages";
export declare const DOT_NEXT_ALIAS = "private-dot-next";
export declare const ROOT_DIR_ALIAS = "private-next-root-dir";
export declare const APP_DIR_ALIAS = "private-next-app-dir";
export declare const RSC_MOD_REF_PROXY_ALIAS = "private-next-rsc-mod-ref-proxy";
export declare const PUBLIC_DIR_MIDDLEWARE_CONFLICT = "You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict";
export declare const SSG_GET_INITIAL_PROPS_CONFLICT = "You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps";
export declare const SERVER_PROPS_GET_INIT_PROPS_CONFLICT = "You can not use getInitialProps with getServerSideProps. Please remove getInitialProps.";
export declare const SERVER_PROPS_SSG_CONFLICT = "You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps";
export declare const STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR = "can not have getInitialProps/getServerSideProps, https://nextjs.org/docs/messages/404-get-initial-props";
export declare const SERVER_PROPS_EXPORT_ERROR = "pages with `getServerSideProps` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export";
export declare const GSP_NO_RETURNED_VALUE = "Your `getStaticProps` function did not return an object. Did you forget to add a `return`?";
export declare const GSSP_NO_RETURNED_VALUE = "Your `getServerSideProps` function did not return an object. Did you forget to add a `return`?";
export declare const UNSTABLE_REVALIDATE_RENAME_ERROR: string;
export declare const GSSP_COMPONENT_MEMBER_ERROR = "can not be attached to a page's component and must be exported from the page. See more info here: https://nextjs.org/docs/messages/gssp-component-member";
export declare const NON_STANDARD_NODE_ENV = "You are using a non-standard \"NODE_ENV\" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env";
export declare const SSG_FALLBACK_EXPORT_ERROR = "Pages with `fallback` enabled in `getStaticPaths` can not be exported. See more info here: https://nextjs.org/docs/messages/ssg-fallback-true-export";
export declare const ESLINT_DEFAULT_DIRS: string[];
export declare const ESLINT_PROMPT_VALUES: ({
title: string;
recommended: boolean;
config: {
extends: string;
};
} | {
title: string;
config: {
extends: string;
};
recommended?: undefined;
} | {
title: string;
config: null;
recommended?: undefined;
})[];
export declare const SERVER_RUNTIME: Record<string, ServerRuntime>;
export declare const WEBPACK_LAYERS: {
shared: string;
server: string;
client: string;
api: string;
middleware: string;
edgeAsset: string;
appClient: string;
};

88
kitabcitab/node_modules/next/dist/lib/constants.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WEBPACK_LAYERS = exports.SERVER_RUNTIME = exports.ESLINT_PROMPT_VALUES = exports.ESLINT_DEFAULT_DIRS = exports.SSG_FALLBACK_EXPORT_ERROR = exports.NON_STANDARD_NODE_ENV = exports.GSSP_COMPONENT_MEMBER_ERROR = exports.UNSTABLE_REVALIDATE_RENAME_ERROR = exports.GSSP_NO_RETURNED_VALUE = exports.GSP_NO_RETURNED_VALUE = exports.SERVER_PROPS_EXPORT_ERROR = exports.STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR = exports.SERVER_PROPS_SSG_CONFLICT = exports.SERVER_PROPS_GET_INIT_PROPS_CONFLICT = exports.SSG_GET_INITIAL_PROPS_CONFLICT = exports.PUBLIC_DIR_MIDDLEWARE_CONFLICT = exports.RSC_MOD_REF_PROXY_ALIAS = exports.APP_DIR_ALIAS = exports.ROOT_DIR_ALIAS = exports.DOT_NEXT_ALIAS = exports.PAGES_DIR_ALIAS = exports.MIDDLEWARE_LOCATION_REGEXP = exports.MIDDLEWARE_FILENAME = void 0;
const MIDDLEWARE_FILENAME = "middleware";
exports.MIDDLEWARE_FILENAME = MIDDLEWARE_FILENAME;
const MIDDLEWARE_LOCATION_REGEXP = `(?:src/)?${MIDDLEWARE_FILENAME}`;
exports.MIDDLEWARE_LOCATION_REGEXP = MIDDLEWARE_LOCATION_REGEXP;
const PAGES_DIR_ALIAS = "private-next-pages";
exports.PAGES_DIR_ALIAS = PAGES_DIR_ALIAS;
const DOT_NEXT_ALIAS = "private-dot-next";
exports.DOT_NEXT_ALIAS = DOT_NEXT_ALIAS;
const ROOT_DIR_ALIAS = "private-next-root-dir";
exports.ROOT_DIR_ALIAS = ROOT_DIR_ALIAS;
const APP_DIR_ALIAS = "private-next-app-dir";
exports.APP_DIR_ALIAS = APP_DIR_ALIAS;
const RSC_MOD_REF_PROXY_ALIAS = "private-next-rsc-mod-ref-proxy";
exports.RSC_MOD_REF_PROXY_ALIAS = RSC_MOD_REF_PROXY_ALIAS;
const PUBLIC_DIR_MIDDLEWARE_CONFLICT = `You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict`;
exports.PUBLIC_DIR_MIDDLEWARE_CONFLICT = PUBLIC_DIR_MIDDLEWARE_CONFLICT;
const SSG_GET_INITIAL_PROPS_CONFLICT = `You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps`;
exports.SSG_GET_INITIAL_PROPS_CONFLICT = SSG_GET_INITIAL_PROPS_CONFLICT;
const SERVER_PROPS_GET_INIT_PROPS_CONFLICT = `You can not use getInitialProps with getServerSideProps. Please remove getInitialProps.`;
exports.SERVER_PROPS_GET_INIT_PROPS_CONFLICT = SERVER_PROPS_GET_INIT_PROPS_CONFLICT;
const SERVER_PROPS_SSG_CONFLICT = `You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`;
exports.SERVER_PROPS_SSG_CONFLICT = SERVER_PROPS_SSG_CONFLICT;
const STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR = `can not have getInitialProps/getServerSideProps, https://nextjs.org/docs/messages/404-get-initial-props`;
exports.STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR = STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR;
const SERVER_PROPS_EXPORT_ERROR = `pages with \`getServerSideProps\` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export`;
exports.SERVER_PROPS_EXPORT_ERROR = SERVER_PROPS_EXPORT_ERROR;
const GSP_NO_RETURNED_VALUE = "Your `getStaticProps` function did not return an object. Did you forget to add a `return`?";
exports.GSP_NO_RETURNED_VALUE = GSP_NO_RETURNED_VALUE;
const GSSP_NO_RETURNED_VALUE = "Your `getServerSideProps` function did not return an object. Did you forget to add a `return`?";
exports.GSSP_NO_RETURNED_VALUE = GSSP_NO_RETURNED_VALUE;
const UNSTABLE_REVALIDATE_RENAME_ERROR = "The `unstable_revalidate` property is available for general use.\n" + "Please use `revalidate` instead.";
exports.UNSTABLE_REVALIDATE_RENAME_ERROR = UNSTABLE_REVALIDATE_RENAME_ERROR;
const GSSP_COMPONENT_MEMBER_ERROR = `can not be attached to a page's component and must be exported from the page. See more info here: https://nextjs.org/docs/messages/gssp-component-member`;
exports.GSSP_COMPONENT_MEMBER_ERROR = GSSP_COMPONENT_MEMBER_ERROR;
const NON_STANDARD_NODE_ENV = `You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env`;
exports.NON_STANDARD_NODE_ENV = NON_STANDARD_NODE_ENV;
const SSG_FALLBACK_EXPORT_ERROR = `Pages with \`fallback\` enabled in \`getStaticPaths\` can not be exported. See more info here: https://nextjs.org/docs/messages/ssg-fallback-true-export`;
exports.SSG_FALLBACK_EXPORT_ERROR = SSG_FALLBACK_EXPORT_ERROR;
const ESLINT_DEFAULT_DIRS = [
"pages",
"components",
"lib",
"src"
];
exports.ESLINT_DEFAULT_DIRS = ESLINT_DEFAULT_DIRS;
const ESLINT_PROMPT_VALUES = [
{
title: "Strict",
recommended: true,
config: {
extends: "next/core-web-vitals"
}
},
{
title: "Base",
config: {
extends: "next"
}
},
{
title: "Cancel",
config: null
},
];
exports.ESLINT_PROMPT_VALUES = ESLINT_PROMPT_VALUES;
const SERVER_RUNTIME = {
edge: "edge",
experimentalEdge: "experimental-edge",
nodejs: "nodejs"
};
exports.SERVER_RUNTIME = SERVER_RUNTIME;
const WEBPACK_LAYERS = {
shared: "sc_shared",
server: "sc_server",
client: "sc_client",
api: "api",
middleware: "middleware",
edgeAsset: "edge-asset",
appClient: "app-client"
};
exports.WEBPACK_LAYERS = WEBPACK_LAYERS;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/constants.ts"],"names":["MIDDLEWARE_FILENAME","MIDDLEWARE_LOCATION_REGEXP","PAGES_DIR_ALIAS","DOT_NEXT_ALIAS","ROOT_DIR_ALIAS","APP_DIR_ALIAS","RSC_MOD_REF_PROXY_ALIAS","PUBLIC_DIR_MIDDLEWARE_CONFLICT","SSG_GET_INITIAL_PROPS_CONFLICT","SERVER_PROPS_GET_INIT_PROPS_CONFLICT","SERVER_PROPS_SSG_CONFLICT","STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR","SERVER_PROPS_EXPORT_ERROR","GSP_NO_RETURNED_VALUE","GSSP_NO_RETURNED_VALUE","UNSTABLE_REVALIDATE_RENAME_ERROR","GSSP_COMPONENT_MEMBER_ERROR","NON_STANDARD_NODE_ENV","SSG_FALLBACK_EXPORT_ERROR","ESLINT_DEFAULT_DIRS","ESLINT_PROMPT_VALUES","title","recommended","config","extends","SERVER_RUNTIME","edge","experimentalEdge","nodejs","WEBPACK_LAYERS","shared","server","client","api","middleware","edgeAsset","appClient"],"mappings":"AAAA;;;;;AAGO,MAAMA,mBAAmB,GAAG,YAAY;QAAlCA,mBAAmB,GAAnBA,mBAAmB;AACzB,MAAMC,0BAA0B,GAAG,CAAC,SAAS,EAAED,mBAAmB,CAAC,CAAC;QAA9DC,0BAA0B,GAA1BA,0BAA0B;AAIhC,MAAMC,eAAe,GAAG,oBAAoB;QAAtCA,eAAe,GAAfA,eAAe;AACrB,MAAMC,cAAc,GAAG,kBAAkB;QAAnCA,cAAc,GAAdA,cAAc;AACpB,MAAMC,cAAc,GAAG,uBAAuB;QAAxCA,cAAc,GAAdA,cAAc;AACpB,MAAMC,aAAa,GAAG,sBAAsB;QAAtCA,aAAa,GAAbA,aAAa;AACnB,MAAMC,uBAAuB,GAAG,gCAAgC;QAA1DA,uBAAuB,GAAvBA,uBAAuB;AAE7B,MAAMC,8BAA8B,GAAG,CAAC,6KAA6K,CAAC;QAAhNA,8BAA8B,GAA9BA,8BAA8B;AAEpC,MAAMC,8BAA8B,GAAG,CAAC,mGAAmG,CAAC;QAAtIA,8BAA8B,GAA9BA,8BAA8B;AAEpC,MAAMC,oCAAoC,GAAG,CAAC,uFAAuF,CAAC;QAAhIA,oCAAoC,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,gBAAgB,EAAE,mBAAmB;IACrCC,MAAM,EAAE,QAAQ;CACjB;QAJYH,cAAc,GAAdA,cAAc;AAMpB,MAAMI,cAAc,GAAG;IAC5BC,MAAM,EAAE,WAAW;IACnBC,MAAM,EAAE,WAAW;IACnBC,MAAM,EAAE,WAAW;IACnBC,GAAG,EAAE,KAAK;IACVC,UAAU,EAAE,YAAY;IACxBC,SAAS,EAAE,YAAY;IACvBC,SAAS,EAAE,YAAY;CACxB;QARYP,cAAc,GAAdA,cAAc"}

View File

@@ -0,0 +1 @@
export declare function detectTypo(input: string, options: string[], threshold?: number): string | null;

46
kitabcitab/node_modules/next/dist/lib/detect-typo.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.detectTypo = detectTypo;
// the minimum number of operations required to convert string a to string b.
function minDistance(a, b, threshold) {
const m = a.length;
const n = b.length;
if (m < n) {
return minDistance(b, a, threshold);
}
if (n === 0) {
return m;
}
let previousRow = Array.from({
length: n + 1
}, (_, i)=>i);
for(let i1 = 0; i1 < m; i1++){
const s1 = a[i1];
let currentRow = [
i1 + 1
];
for(let j = 0; j < n; j++){
const s2 = b[j];
const insertions = previousRow[j + 1] + 1;
const deletions = currentRow[j] + 1;
const substitutions = previousRow[j] + Number(s1 !== s2);
currentRow.push(Math.min(insertions, deletions, substitutions));
}
previousRow = currentRow;
}
return previousRow[previousRow.length - 1];
}
function detectTypo(input, options, threshold = 2) {
const potentialTypos = options.map((o)=>({
option: o,
distance: minDistance(o, input, threshold)
})).filter(({ distance })=>distance <= threshold && distance > 0).sort((a, b)=>a.distance - b.distance);
if (potentialTypos.length) {
return potentialTypos[0].option;
}
return null;
}
//# sourceMappingURL=detect-typo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/detect-typo.ts"],"names":["detectTypo","minDistance","a","b","threshold","m","length","n","previousRow","Array","from","_","i","s1","currentRow","j","s2","insertions","deletions","substitutions","Number","push","Math","min","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CAAC;SAChE;QACDX,WAAW,GAAGM,UAAU;KACzB;IACD,OAAON,WAAW,CAACA,WAAW,CAACF,MAAM,GAAG,CAAC,CAAC,CAAA;CAC3C;AAEM,SAASN,UAAU,CAACwB,KAAa,EAAEC,OAAiB,EAAErB,SAAS,GAAG,CAAC,EAAE;IAC1E,MAAMsB,cAAc,GAAGD,OAAO,CAC3BE,GAAG,CAAC,CAACC,CAAC,GAAK,CAAC;YACXC,MAAM,EAAED,CAAC;YACTE,QAAQ,EAAE7B,WAAW,CAAC2B,CAAC,EAAEJ,KAAK,EAAEpB,SAAS,CAAC;SAC3C,CAAC,CAAC,CACF2B,MAAM,CAAC,CAAC,EAAED,QAAQ,CAAA,EAAE,GAAKA,QAAQ,IAAI1B,SAAS,IAAI0B,QAAQ,GAAG,CAAC,CAAC,CAC/DE,IAAI,CAAC,CAAC9B,CAAC,EAAEC,CAAC,GAAKD,CAAC,CAAC4B,QAAQ,GAAG3B,CAAC,CAAC2B,QAAQ,CAAC;IAE1C,IAAIJ,cAAc,CAACpB,MAAM,EAAE;QACzB,OAAOoB,cAAc,CAAC,CAAC,CAAC,CAACG,MAAM,CAAA;KAChC;IACD,OAAO,IAAI,CAAA;CACZ"}

View File

@@ -0,0 +1 @@
export declare function downloadWasmSwc(version: string, wasmDirectory: string, variant?: 'nodejs' | 'web'): Promise<void>;

View File

@@ -0,0 +1,161 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.downloadWasmSwc = downloadWasmSwc;
var _os = _interopRequireDefault(require("os"));
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var Log = _interopRequireWildcard(require("../build/output/log"));
var _childProcess = require("child_process");
var _tar = _interopRequireDefault(require("next/dist/compiled/tar"));
var _nodeFetch = _interopRequireDefault(require("next/dist/compiled/node-fetch"));
var _fileExists = require("./file-exists");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
const MAX_VERSIONS_TO_CACHE = 5;
async function downloadWasmSwc(version, wasmDirectory, variant = "nodejs") {
const pkgName = `@next/swc-wasm-${variant}`;
const tarFileName = `${pkgName.substring(6)}-${version}.tgz`;
const outputDirectory = _path.default.join(wasmDirectory, pkgName);
if (await (0, _fileExists).fileExists(outputDirectory)) {
// if the package is already downloaded a different
// failure occurred than not being present
return;
}
// get platform specific cache directory adapted from playwright's handling
// https://github.com/microsoft/playwright/blob/7d924470d397975a74a19184c136b3573a974e13/packages/playwright-core/src/utils/registry.ts#L141
const cacheDirectory = await (async ()=>{
let result;
const envDefined = process.env["NEXT_SWC_PATH"];
if (envDefined) {
result = envDefined;
} else {
let systemCacheDirectory;
if (process.platform === "linux") {
systemCacheDirectory = process.env.XDG_CACHE_HOME || _path.default.join(_os.default.homedir(), ".cache");
} else if (process.platform === "darwin") {
systemCacheDirectory = _path.default.join(_os.default.homedir(), "Library", "Caches");
} else if (process.platform === "win32") {
systemCacheDirectory = process.env.LOCALAPPDATA || _path.default.join(_os.default.homedir(), "AppData", "Local");
} else {
/// Attempt to use generic tmp location for these platforms
if (process.platform === "freebsd" || process.platform === "android") {
for (const dir of [
_path.default.join(_os.default.homedir(), ".cache"),
_path.default.join(_os.default.tmpdir()),
]){
if (await (0, _fileExists).fileExists(dir)) {
systemCacheDirectory = dir;
break;
}
}
}
if (!systemCacheDirectory) {
console.error(new Error("Unsupported platform: " + process.platform));
process.exit(0);
}
}
result = _path.default.join(systemCacheDirectory, "next-swc");
}
if (!_path.default.isAbsolute(result)) {
// It is important to resolve to the absolute path:
// - for unzipping to work correctly;
// - so that registry directory matches between installation and execution.
// INIT_CWD points to the root of `npm/yarn install` and is probably what
// the user meant when typing the relative path.
result = _path.default.resolve(process.env["INIT_CWD"] || process.cwd(), result);
}
return result;
})();
await _fs.default.promises.mkdir(outputDirectory, {
recursive: true
});
const extractFromTar = async ()=>{
await _tar.default.x({
file: _path.default.join(cacheDirectory, tarFileName),
cwd: outputDirectory,
strip: 1
});
};
if (!await (0, _fileExists).fileExists(_path.default.join(cacheDirectory, tarFileName))) {
Log.info("Downloading WASM swc package...");
await _fs.default.promises.mkdir(cacheDirectory, {
recursive: true
});
const tempFile = _path.default.join(cacheDirectory, `${tarFileName}.temp-${Date.now()}`);
let registry = `https://registry.npmjs.org/`;
try {
const output = (0, _childProcess).execSync("npm config get registry").toString().trim();
if (output.startsWith("http")) {
registry = output.endsWith("/") ? output : `${output}/`;
}
} catch (_) {}
await (0, _nodeFetch).default(`${registry}${pkgName}/-/${tarFileName}`).then((res)=>{
if (!res.ok) {
throw new Error(`request failed with status ${res.status}`);
}
const cacheWriteStream = _fs.default.createWriteStream(tempFile);
return new Promise((resolve, reject)=>{
res.body.pipe(cacheWriteStream).on("error", (err)=>reject(err)).on("finish", ()=>resolve());
}).finally(()=>cacheWriteStream.close());
});
await _fs.default.promises.rename(tempFile, _path.default.join(cacheDirectory, tarFileName));
}
await extractFromTar();
const cacheFiles = await _fs.default.promises.readdir(cacheDirectory);
if (cacheFiles.length > MAX_VERSIONS_TO_CACHE) {
cacheFiles.sort((a, b)=>{
if (a.length < b.length) return -1;
return a.localeCompare(b);
});
// prune oldest versions in cache
for(let i = 0; i++; i < cacheFiles.length - MAX_VERSIONS_TO_CACHE){
await _fs.default.promises.unlink(_path.default.join(cacheDirectory, cacheFiles[i])).catch(()=>{});
}
}
}
//# sourceMappingURL=download-wasm-swc.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
export declare enum MessageSeverity {
Warning = 1,
Error = 2
}
interface LintMessage {
ruleId: string | null;
severity: 1 | 2;
message: string;
line: number;
column: number;
}
export interface LintResult {
filePath: string;
messages: LintMessage[];
errorCount: number;
warningCount: number;
output?: string;
source?: string;
}
export declare function formatResults(baseDir: string, results: LintResult[], format: (r: LintResult[]) => string): {
output: string;
outputWithMessages: string;
totalNextPluginErrorCount: number;
totalNextPluginWarningCount: number;
};
export {};

View File

@@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatResults = formatResults;
exports.MessageSeverity = void 0;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var MessageSeverity;
exports.MessageSeverity = MessageSeverity;
(function(MessageSeverity) {
MessageSeverity[MessageSeverity["Warning"] = 1] = "Warning";
MessageSeverity[MessageSeverity["Error"] = 2] = "Error";
})(MessageSeverity || (exports.MessageSeverity = MessageSeverity = {}));
function pluginCount(messages) {
let nextPluginWarningCount = 0;
let nextPluginErrorCount = 0;
for(let i = 0; i < messages.length; i++){
const { severity , ruleId } = messages[i];
if (ruleId == null ? void 0 : ruleId.includes("@next/next")) {
if (severity === 1) {
nextPluginWarningCount += 1;
} else {
nextPluginErrorCount += 1;
}
}
}
return {
nextPluginErrorCount,
nextPluginWarningCount
};
}
function formatMessage(dir, messages, filePath) {
let fileName = _path.default.posix.normalize(_path.default.relative(dir, filePath).replace(/\\/g, "/"));
if (!fileName.startsWith(".")) {
fileName = "./" + fileName;
}
let output = "\n" + _chalk.default.cyan(fileName);
for(let i = 0; i < messages.length; i++){
const { message , severity , line , column , ruleId } = messages[i];
output = output + "\n";
if (line && column) {
output = output + _chalk.default.yellow(line.toString()) + ":" + _chalk.default.yellow(column.toString()) + " ";
}
if (severity === 1) {
output += _chalk.default.yellow.bold("Warning") + ": ";
} else {
output += _chalk.default.red.bold("Error") + ": ";
}
output += message;
if (ruleId) {
output += " " + _chalk.default.gray.bold(ruleId);
}
}
return output;
}
function formatResults(baseDir, results, format) {
let totalNextPluginErrorCount = 0;
let totalNextPluginWarningCount = 0;
let resultsWithMessages = results.filter(({ messages })=>{
return messages == null ? void 0 : messages.length;
});
// Track number of Next.js plugin errors and warnings
resultsWithMessages.forEach(({ messages })=>{
const res = pluginCount(messages);
totalNextPluginErrorCount += res.nextPluginErrorCount;
totalNextPluginWarningCount += res.nextPluginWarningCount;
});
// Use user defined formatter or Next.js's built-in custom formatter
const output = format ? format(resultsWithMessages) : resultsWithMessages.map(({ messages , filePath })=>formatMessage(baseDir, messages, filePath)).join("\n");
return {
output: output,
outputWithMessages: resultsWithMessages.length > 0 ? output + `\n\n${_chalk.default.cyan("info")} - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules` : "",
totalNextPluginErrorCount,
totalNextPluginWarningCount
};
}
//# sourceMappingURL=customFormatter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/eslint/customFormatter.ts"],"names":["formatResults","MessageSeverity","Warning","Error","pluginCount","messages","nextPluginWarningCount","nextPluginErrorCount","i","length","severity","ruleId","includes","formatMessage","dir","filePath","fileName","path","posix","normalize","relative","replace","startsWith","output","chalk","cyan","message","line","column","yellow","toString","bold","red","gray","baseDir","results","format","totalNextPluginErrorCount","totalNextPluginWarningCount","resultsWithMessages","filter","forEach","res","map","join","outputWithMessages"],"mappings":"AAAA;;;;QAgGgBA,aAAa,GAAbA,aAAa;;AAhGX,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC3B,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;IA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5E,qDAAqD;IACrD8B,mBAAmB,CAACE,OAAO,CAAC,CAAC,EAAEpC,QAAQ,CAAA,EAAE,GAAK;QAC5C,MAAMqC,GAAG,GAAGtC,WAAW,CAACC,QAAQ,CAAC;QACjCgC,yBAAyB,IAAIK,GAAG,CAACnC,oBAAoB;QACrD+B,2BAA2B,IAAII,GAAG,CAACpC,sBAAsB;KAC1D,CAAC;IAEF,oEAAoE;IACpE,MAAMiB,MAAM,GAAGa,MAAM,GACjBA,MAAM,CAACG,mBAAmB,CAAC,GAC3BA,mBAAmB,CAChBI,GAAG,CAAC,CAAC,EAAEtC,QAAQ,CAAA,EAAEU,QAAQ,CAAA,EAAE,GAC1BF,aAAa,CAACqB,OAAO,EAAE7B,QAAQ,EAAEU,QAAQ,CAAC,CAC3C,CACA6B,IAAI,CAAC,IAAI,CAAC;IAEjB,OAAO;QACLrB,MAAM,EAAEA,MAAM;QACdsB,kBAAkB,EAChBN,mBAAmB,CAAC9B,MAAM,GAAG,CAAC,GAC1Bc,MAAM,GACN,CAAC,IAAI,EAAEC,MAAK,QAAA,CAACC,IAAI,CACf,MAAM,CACP,CAAC,qHAAqH,CAAC,GACxH,EAAE;QACRY,yBAAyB;QACzBC,2BAA2B;KAC5B,CAAA;CACF"}

View File

@@ -0,0 +1,9 @@
export declare type ConfigAvailable = {
exists: boolean;
emptyEslintrc?: boolean;
emptyPkgJsonConfig?: boolean;
firstTimeSetup?: true;
};
export declare function hasEslintConfiguration(eslintrcFile: string | null, packageJsonConfig: {
eslintConfig: any;
} | null): Promise<ConfigAvailable>;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasEslintConfiguration = hasEslintConfiguration;
var _fs = require("fs");
async function hasEslintConfiguration(eslintrcFile, packageJsonConfig) {
const configObject = {
exists: false,
emptyEslintrc: false,
emptyPkgJsonConfig: false
};
if (eslintrcFile) {
const content = await _fs.promises.readFile(eslintrcFile, {
encoding: "utf8"
}).then((txt)=>txt.trim().replace(/\n/g, ""), ()=>null);
if (content === "" || content === "{}" || content === "---" || content === "module.exports = {}") {
return {
...configObject,
emptyEslintrc: true
};
}
return {
...configObject,
exists: true
};
} else if (packageJsonConfig == null ? void 0 : packageJsonConfig.eslintConfig) {
if (Object.keys(packageJsonConfig == null ? void 0 : packageJsonConfig.eslintConfig).length) {
return {
...configObject,
exists: true
};
}
return {
...configObject,
emptyPkgJsonConfig: true
};
}
return configObject;
}
//# sourceMappingURL=hasEslintConfiguration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/eslint/hasEslintConfiguration.ts"],"names":["hasEslintConfiguration","eslintrcFile","packageJsonConfig","configObject","exists","emptyEslintrc","emptyPkgJsonConfig","content","fs","readFile","encoding","then","txt","trim","replace","eslintConfig","Object","keys","length"],"mappings":"AAAA;;;;QASsBA,sBAAsB,GAAtBA,sBAAsB;AATb,IAAA,GAAI,WAAJ,IAAI,CAAA;AAS5B,eAAeA,sBAAsB,CAC1CC,YAA2B,EAC3BC,iBAA+C,EACrB;IAC1B,MAAMC,YAAY,GAAG;QACnBC,MAAM,EAAE,KAAK;QACbC,aAAa,EAAE,KAAK;QACpBC,kBAAkB,EAAE,KAAK;KAC1B;IAED,IAAIL,YAAY,EAAE;QAChB,MAAMM,OAAO,GAAG,MAAMC,GAAE,SAAA,CAACC,QAAQ,CAACR,YAAY,EAAE;YAAES,QAAQ,EAAE,MAAM;SAAE,CAAC,CAACC,IAAI,CACxE,CAACC,GAAG,GAAKA,GAAG,CAACC,IAAI,EAAE,CAACC,OAAO,QAAQ,EAAE,CAAC,EACtC,IAAM,IAAI,CACX;QAED,IACEP,OAAO,KAAK,EAAE,IACdA,OAAO,KAAK,IAAI,IAChBA,OAAO,KAAK,KAAK,IACjBA,OAAO,KAAK,qBAAqB,EACjC;YACA,OAAO;gBAAE,GAAGJ,YAAY;gBAAEE,aAAa,EAAE,IAAI;aAAE,CAAA;SAChD;QACD,OAAO;YAAE,GAAGF,YAAY;YAAEC,MAAM,EAAE,IAAI;SAAE,CAAA;KACzC,MAAM,IAAIF,iBAAiB,QAAc,GAA/BA,KAAAA,CAA+B,GAA/BA,iBAAiB,CAAEa,YAAY,EAAE;QAC1C,IAAIC,MAAM,CAACC,IAAI,CAACf,iBAAiB,QAAc,GAA/BA,KAAAA,CAA+B,GAA/BA,iBAAiB,CAAEa,YAAY,CAAC,CAACG,MAAM,EAAE;YACvD,OAAO;gBAAE,GAAGf,YAAY;gBAAEC,MAAM,EAAE,IAAI;aAAE,CAAA;SACzC;QACD,OAAO;YAAE,GAAGD,YAAY;YAAEG,kBAAkB,EAAE,IAAI;SAAE,CAAA;KACrD;IACD,OAAOH,YAAY,CAAA;CACpB"}

View File

@@ -0,0 +1,23 @@
import { EventLintCheckCompleted } from '../../telemetry/events/build';
declare function lint(baseDir: string, lintDirs: string[], eslintrcFile: string | null, pkgJsonPath: string | null, hasAppDir: boolean, { lintDuringBuild, eslintOptions, reportErrorsOnly, maxWarnings, formatter, outputFile, }: {
lintDuringBuild: boolean;
eslintOptions: any;
reportErrorsOnly: boolean;
maxWarnings: number;
formatter: string | null;
outputFile: string | null;
}): Promise<string | null | {
output: string | null;
isError: boolean;
eventInfo: EventLintCheckCompleted;
}>;
export declare function runLintCheck(baseDir: string, lintDirs: string[], hasAppDir: boolean, opts: {
lintDuringBuild?: boolean;
eslintOptions?: any;
reportErrorsOnly?: boolean;
maxWarnings?: number;
formatter?: string | null;
outputFile?: string | null;
strict?: boolean;
}): ReturnType<typeof lint>;
export {};

View File

@@ -0,0 +1,295 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.runLintCheck = runLintCheck;
var _fs = require("fs");
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _path = _interopRequireDefault(require("path"));
var _findUp = _interopRequireDefault(require("next/dist/compiled/find-up"));
var _semver = _interopRequireDefault(require("next/dist/compiled/semver"));
var CommentJson = _interopRequireWildcard(require("next/dist/compiled/comment-json"));
var _customFormatter = require("./customFormatter");
var _writeDefaultConfig = require("./writeDefaultConfig");
var _hasEslintConfiguration = require("./hasEslintConfiguration");
var _writeOutputFile = require("./writeOutputFile");
var _constants = require("../constants");
var _findPagesDir = require("../find-pages-dir");
var _installDependencies = require("../install-dependencies");
var _hasNecessaryDependencies = require("../has-necessary-dependencies");
var Log = _interopRequireWildcard(require("../../build/output/log"));
var _isError = _interopRequireWildcard(require("../is-error"));
var _getPkgManager = require("../helpers/get-pkg-manager");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules
const VALID_SEVERITY = [
"off",
"warn",
"error"
];
function isValidSeverity(severity) {
return VALID_SEVERITY.includes(severity);
}
const requiredPackages = [
{
file: "eslint",
pkg: "eslint",
exportsRestrict: false
},
{
file: "eslint-config-next",
pkg: "eslint-config-next",
exportsRestrict: false
},
];
async function cliPrompt() {
console.log(_chalk.default.bold(`${_chalk.default.cyan("?")} How would you like to configure ESLint? https://nextjs.org/docs/basic-features/eslint`));
try {
const cliSelect = (await Promise.resolve(require("next/dist/compiled/cli-select"))).default;
const { value } = await cliSelect({
values: _constants.ESLINT_PROMPT_VALUES,
valueRenderer: ({ title , recommended }, selected)=>{
const name = selected ? _chalk.default.bold.underline.cyan(title) : title;
return name + (recommended ? _chalk.default.bold.yellow(" (recommended)") : "");
},
selected: _chalk.default.cyan("\u276F "),
unselected: " "
});
return {
config: value == null ? void 0 : value.config
};
} catch {
return {
config: null
};
}
}
async function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, hasAppDir, { lintDuringBuild =false , eslintOptions =null , reportErrorsOnly =false , maxWarnings =-1 , formatter =null , outputFile =null }) {
try {
var ref, ref1;
// Load ESLint after we're sure it exists:
const deps = await (0, _hasNecessaryDependencies).hasNecessaryDependencies(baseDir, requiredPackages);
const packageManager = (0, _getPkgManager).getPkgManager(baseDir);
if (deps.missing.some((dep)=>dep.pkg === "eslint")) {
Log.error(`ESLint must be installed${lintDuringBuild ? " in order to run during builds:" : ":"} ${_chalk.default.bold.cyan((packageManager === "yarn" ? "yarn add --dev" : packageManager === "pnpm" ? "pnpm install --save-dev" : "npm install --save-dev") + " eslint")}`);
return null;
}
const mod = await Promise.resolve(require(deps.resolved.get("eslint")));
const { ESLint } = mod;
let eslintVersion = (ESLint == null ? void 0 : ESLint.version) ?? (mod == null ? void 0 : (ref = mod.CLIEngine) == null ? void 0 : ref.version);
if (!eslintVersion || _semver.default.lt(eslintVersion, "7.0.0")) {
return `${_chalk.default.red("error")} - Your project has an older version of ESLint installed${eslintVersion ? " (" + eslintVersion + ")" : ""}. Please upgrade to ESLint version 7 or above`;
}
let options = {
useEslintrc: true,
baseConfig: {},
errorOnUnmatchedPattern: false,
extensions: [
".js",
".jsx",
".ts",
".tsx"
],
cache: true,
...eslintOptions
};
let eslint = new ESLint(options);
let nextEslintPluginIsEnabled = false;
const nextRulesEnabled = new Map();
for (const configFile of [
eslintrcFile,
pkgJsonPath
]){
var ref2;
if (!configFile) continue;
const completeConfig = await eslint.calculateConfigForFile(configFile);
if ((ref2 = completeConfig.plugins) == null ? void 0 : ref2.includes("@next/next")) {
nextEslintPluginIsEnabled = true;
for (const [name, [severity]] of Object.entries(completeConfig.rules)){
if (!name.startsWith("@next/next/")) {
continue;
}
if (typeof severity === "number" && severity >= 0 && severity < VALID_SEVERITY.length) {
nextRulesEnabled.set(name, VALID_SEVERITY[severity]);
} else if (typeof severity === "string" && isValidSeverity(severity)) {
nextRulesEnabled.set(name, severity);
}
}
break;
}
}
const pagesDir = (0, _findPagesDir).findPagesDir(baseDir, hasAppDir).pagesDir;
const pagesDirRules = pagesDir ? [
"@next/next/no-html-link-for-pages"
] : [];
if (nextEslintPluginIsEnabled) {
let updatedPagesDir = false;
for (const rule of pagesDirRules){
var ref3, ref4;
if (!((ref3 = options.baseConfig.rules) == null ? void 0 : ref3[rule]) && !((ref4 = options.baseConfig.rules) == null ? void 0 : ref4[rule.replace("@next/next", "@next/babel-plugin-next")])) {
if (!options.baseConfig.rules) {
options.baseConfig.rules = {};
}
options.baseConfig.rules[rule] = [
1,
pagesDir
];
updatedPagesDir = true;
}
}
if (updatedPagesDir) {
eslint = new ESLint(options);
}
} else {
Log.warn("The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config");
}
const lintStart = process.hrtime();
let results = await eslint.lintFiles(lintDirs);
let selectedFormatter = null;
if (options.fix) await ESLint.outputFixes(results);
if (reportErrorsOnly) results = await ESLint.getErrorResults(results) // Only return errors if --quiet flag is used
;
if (formatter) selectedFormatter = await eslint.loadFormatter(formatter);
const formattedResult = (0, _customFormatter).formatResults(baseDir, results, selectedFormatter == null ? void 0 : selectedFormatter.format);
const lintEnd = process.hrtime(lintStart);
const totalWarnings = results.reduce((sum, file)=>sum + file.warningCount, 0);
if (outputFile) await (0, _writeOutputFile).writeOutputFile(outputFile, formattedResult.output);
return {
output: formattedResult.outputWithMessages,
isError: ((ref1 = ESLint.getErrorResults(results)) == null ? void 0 : ref1.length) > 0 || maxWarnings >= 0 && totalWarnings > maxWarnings,
eventInfo: {
durationInSeconds: lintEnd[0],
eslintVersion: eslintVersion,
lintedFilesCount: results.length,
lintFix: !!options.fix,
nextEslintPluginVersion: nextEslintPluginIsEnabled && deps.resolved.has("eslint-config-next") ? require(_path.default.join(_path.default.dirname(deps.resolved.get("eslint-config-next")), "package.json")).version : null,
nextEslintPluginErrorsCount: formattedResult.totalNextPluginErrorCount,
nextEslintPluginWarningsCount: formattedResult.totalNextPluginWarningCount,
nextRulesEnabled: Object.fromEntries(nextRulesEnabled)
}
};
} catch (err) {
if (lintDuringBuild) {
Log.error(`ESLint: ${(0, _isError).default(err) && err.message ? err.message.replace(/\n/g, " ") : err}`);
return null;
} else {
throw (0, _isError).getProperError(err);
}
}
}
async function runLintCheck(baseDir, lintDirs, hasAppDir, opts) {
const { lintDuringBuild =false , eslintOptions =null , reportErrorsOnly =false , maxWarnings =-1 , formatter =null , outputFile =null , strict =false , } = opts;
try {
// Find user's .eslintrc file
// See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
const eslintrcFile = await (0, _findUp).default([
".eslintrc.js",
".eslintrc.cjs",
".eslintrc.yaml",
".eslintrc.yml",
".eslintrc.json",
".eslintrc",
], {
cwd: baseDir
}) ?? null;
const pkgJsonPath = await (0, _findUp).default("package.json", {
cwd: baseDir
}) ?? null;
let packageJsonConfig = null;
if (pkgJsonPath) {
const pkgJsonContent = await _fs.promises.readFile(pkgJsonPath, {
encoding: "utf8"
});
packageJsonConfig = CommentJson.parse(pkgJsonContent);
}
const config = await (0, _hasEslintConfiguration).hasEslintConfiguration(eslintrcFile, packageJsonConfig);
let deps;
if (config.exists) {
// Run if ESLint config exists
return await lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, hasAppDir, {
lintDuringBuild,
eslintOptions,
reportErrorsOnly,
maxWarnings,
formatter,
outputFile
});
} else {
// Display warning if no ESLint configuration is present inside
// config file during "next build", no warning is shown when
// no eslintrc file is present
if (lintDuringBuild) {
if (config.emptyPkgJsonConfig || config.emptyEslintrc) {
Log.warn(`No ESLint configuration detected. Run ${_chalk.default.bold.cyan("next lint")} to begin setup`);
}
return null;
} else {
// Ask user what config they would like to start with for first time "next lint" setup
const { config: selectedConfig } = strict ? _constants.ESLINT_PROMPT_VALUES.find((opt)=>opt.title === "Strict") : await cliPrompt();
if (selectedConfig == null) {
// Show a warning if no option is selected in prompt
Log.warn("If you set up ESLint yourself, we recommend adding the Next.js ESLint plugin. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config");
return null;
} else {
// Check if necessary deps installed, and install any that are missing
deps = await (0, _hasNecessaryDependencies).hasNecessaryDependencies(baseDir, requiredPackages);
if (deps.missing.length > 0) await (0, _installDependencies).installDependencies(baseDir, deps.missing, true);
// Write default ESLint config.
// Check for /pages and src/pages is to make sure this happens in Next.js folder
if ((0, _findPagesDir).existsSync(_path.default.join(baseDir, "pages")) || (0, _findPagesDir).existsSync(_path.default.join(baseDir, "src/pages"))) {
await (0, _writeDefaultConfig).writeDefaultConfig(baseDir, config, selectedConfig, eslintrcFile, pkgJsonPath, packageJsonConfig);
}
}
Log.ready(`ESLint has successfully been configured. Run ${_chalk.default.bold.cyan("next lint")} again to view warnings and errors.`);
return null;
}
}
} catch (err) {
throw err;
}
}
//# sourceMappingURL=runLintCheck.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import { ConfigAvailable } from './hasEslintConfiguration';
export declare function writeDefaultConfig(baseDir: string, { exists, emptyEslintrc, emptyPkgJsonConfig }: ConfigAvailable, selectedConfig: any, eslintrcFile: string | null, pkgJsonPath: string | null, packageJsonConfig: {
eslintConfig: any;
} | null): Promise<void>;

View File

@@ -0,0 +1,80 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.writeDefaultConfig = writeDefaultConfig;
var _fs = require("fs");
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _os = _interopRequireDefault(require("os"));
var _path = _interopRequireDefault(require("path"));
var CommentJson = _interopRequireWildcard(require("next/dist/compiled/comment-json"));
var Log = _interopRequireWildcard(require("../../build/output/log"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
async function writeDefaultConfig(baseDir, { exists , emptyEslintrc , emptyPkgJsonConfig }, selectedConfig, eslintrcFile, pkgJsonPath, packageJsonConfig) {
if (!exists && emptyEslintrc && eslintrcFile) {
const ext = _path.default.extname(eslintrcFile);
let newFileContent;
if (ext === ".yaml" || ext === ".yml") {
newFileContent = "extends: 'next'";
} else {
newFileContent = CommentJson.stringify(selectedConfig, null, 2);
if (ext === ".js") {
newFileContent = "module.exports = " + newFileContent;
}
}
await _fs.promises.writeFile(eslintrcFile, newFileContent + _os.default.EOL);
Log.info(`We detected an empty ESLint configuration file (${_chalk.default.bold(_path.default.basename(eslintrcFile))}) and updated it for you!`);
} else if (!exists && emptyPkgJsonConfig && packageJsonConfig) {
packageJsonConfig.eslintConfig = selectedConfig;
if (pkgJsonPath) await _fs.promises.writeFile(pkgJsonPath, CommentJson.stringify(packageJsonConfig, null, 2) + _os.default.EOL);
Log.info(`We detected an empty ${_chalk.default.bold("eslintConfig")} field in package.json and updated it for you!`);
} else if (!exists) {
await _fs.promises.writeFile(_path.default.join(baseDir, ".eslintrc.json"), CommentJson.stringify(selectedConfig, null, 2) + _os.default.EOL);
console.log(_chalk.default.green(`We created the ${_chalk.default.bold(".eslintrc.json")} file for you and included your selected configuration.`));
}
}
//# sourceMappingURL=writeDefaultConfig.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/eslint/writeDefaultConfig.ts"],"names":["writeDefaultConfig","CommentJson","Log","baseDir","exists","emptyEslintrc","emptyPkgJsonConfig","selectedConfig","eslintrcFile","pkgJsonPath","packageJsonConfig","ext","path","extname","newFileContent","stringify","fs","writeFile","os","EOL","info","chalk","bold","basename","eslintConfig","join","console","log","green"],"mappings":"AAAA;;;;QASsBA,kBAAkB,GAAlBA,kBAAkB;AATT,IAAA,GAAI,WAAJ,IAAI,CAAA;AACjB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC7B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACXC,IAAAA,WAAW,mCAAM,iCAAiC,EAAvC;AAGXC,IAAAA,GAAG,mCAAM,wBAAwB,EAA9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAER,eAAeF,kBAAkB,CACtCG,OAAe,EACf,EAAEC,MAAM,CAAA,EAAEC,aAAa,CAAA,EAAEC,kBAAkB,CAAA,EAAmB,EAC9DC,cAAmB,EACnBC,YAA2B,EAC3BC,WAA0B,EAC1BC,iBAA+C,EAC/C;IACA,IAAI,CAACN,MAAM,IAAIC,aAAa,IAAIG,YAAY,EAAE;QAC5C,MAAMG,GAAG,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACL,YAAY,CAAC;QAEtC,IAAIM,cAAc;QAClB,IAAIH,GAAG,KAAK,OAAO,IAAIA,GAAG,KAAK,MAAM,EAAE;YACrCG,cAAc,GAAG,iBAAiB;SACnC,MAAM;YACLA,cAAc,GAAGb,WAAW,CAACc,SA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0 +1,8 @@
/**
* Create a file with eslint output data
*/
export declare function writeOutputFile(
/** The name file that needs to be created */
outputFile: string,
/** The data that needs to be inserted into the file */
outputData: string): Promise<void>;

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.writeOutputFile = writeOutputFile;
var _fs = require("fs");
var _path = _interopRequireDefault(require("path"));
var Log = _interopRequireWildcard(require("../../build/output/log"));
var _isError = _interopRequireDefault(require("../../lib/is-error"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
/**
* Check if a given file path is a directory or not.
* Returns `true` if the path is a directory.
*/ async function isDirectory(/** The path to a file to check. */ filePath) {
try {
return (await _fs.promises.stat(filePath)).isDirectory();
} catch (error) {
if ((0, _isError).default(error) && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
return false;
}
throw error;
}
}
async function writeOutputFile(/** The name file that needs to be created */ outputFile, /** The data that needs to be inserted into the file */ outputData) {
const filePath = _path.default.resolve(process.cwd(), outputFile);
if (await isDirectory(filePath)) {
Log.error(`Cannot write to output file path, it is a directory: ${filePath}`);
} else {
try {
await _fs.promises.mkdir(_path.default.dirname(filePath), {
recursive: true
});
await _fs.promises.writeFile(filePath, outputData);
Log.info(`The output file has been created: ${filePath}`);
} catch (err) {
Log.error(`There was a problem writing the output file: ${filePath}`);
console.error(err);
}
}
}
//# sourceMappingURL=writeOutputFile.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/eslint/writeOutputFile.ts"],"names":["writeOutputFile","Log","isDirectory","filePath","fs","stat","error","isError","code","outputFile","outputData","path","resolve","process","cwd","mkdir","dirname","recursive","writeFile","info","err","console"],"mappings":"AAAA;;;;QA4BsBA,eAAe,GAAfA,eAAe;AA5BN,IAAA,GAAI,WAAJ,IAAI,CAAA;AAClB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACXC,IAAAA,GAAG,mCAAM,wBAAwB,EAA9B;AACK,IAAA,QAAoB,kCAApB,oBAAoB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExC;;;GAGG,CACH,eAAeC,WAAW,CACxB,oCAAoC,CACpCC,QAAgB,EACE;IAClB,IAAI;QACF,OAAO,CAAC,MAAMC,GAAE,SAAA,CAACC,IAAI,CAACF,QAAQ,CAAC,CAAC,CAACD,WAAW,EAAE,CAAA;KAC/C,CAAC,OAAOI,KAAK,EAAE;QACd,IACEC,CAAAA,GAAAA,QAAO,AAAO,CAAA,QAAP,CAACD,KAAK,CAAC,IACd,CAACA,KAAK,CAACE,IAAI,KAAK,QAAQ,IAAIF,KAAK,CAACE,IAAI,KAAK,SAAS,CAAC,EACrD;YACA,OAAO,KAAK,CAAA;SACb;QACD,MAAMF,KAAK,CAAA;KACZ;CACF;AAIM,eAAeN,eAAe,CACnC,6CAA6C,CAC7CS,UAAkB,EAClB,uDAAuD,CACvDC,UAAkB,EACH;IACf,MAAMP,QAAQ,GAAGQ,KAAI,QAAA,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAEL,UAAU,CAAC;IAExD,IAAI,MAAMP,WAAW,CAACC,QAAQ,CAAC,EAAE;QAC/BF,GAAG,CAACK,KAAK,CACP,CAAC,qDAAqD,EAAEH,QAAQ,CAAC,CAAC,CACnE;KACF,MAAM;QACL,IAAI;YACF,MAAMC,GAAE,SAAA,CAACW,KAAK,CAACJ,KAAI,QAAA,CAACK,OAAO,CAACb,QAAQ,CAAC,EAAE;gBAAEc,SAAS,EAAE,IAAI;aAAE,CAAC;YAC3D,MAAMb,GAAE,SAAA,CAACc,SAAS,CAACf,QAAQ,EAAEO,UAAU,CAAC;YACxCT,GAAG,CAACkB,IAAI,CAAC,CAAC,kCAAkC,EAAEhB,QAAQ,CAAC,CAAC,CAAC;SAC1D,CAAC,OAAOiB,GAAG,EAAE;YACZnB,GAAG,CAACK,KAAK,CAAC,CAAC,6CAA6C,EAAEH,QAAQ,CAAC,CAAC,CAAC;YACrEkB,OAAO,CAACf,KAAK,CAACc,GAAG,CAAC;SACnB;KACF;CACF"}

View File

@@ -0,0 +1,2 @@
export declare class FatalError extends Error {
}

9
kitabcitab/node_modules/next/dist/lib/fatal-error.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
class FatalError extends Error {
}
exports.FatalError = FatalError;
//# sourceMappingURL=fatal-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/fatal-error.ts"],"names":["FatalError","Error"],"mappings":"AAAA;;;;AAAO,MAAMA,UAAU,SAASC,KAAK;CAAG;QAA3BD,UAAU,GAAVA,UAAU"}

View File

@@ -0,0 +1 @@
export declare function fileExists(fileName: string, type?: 'file' | 'directory'): Promise<boolean>;

33
kitabcitab/node_modules/next/dist/lib/file-exists.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fileExists = fileExists;
var _fs = require("fs");
var _isError = _interopRequireDefault(require("./is-error"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
async function fileExists(fileName, type) {
try {
if (type === "file") {
const stats = await _fs.promises.stat(fileName);
return stats.isFile();
} else if (type === "directory") {
const stats = await _fs.promises.stat(fileName);
return stats.isDirectory();
} else {
await _fs.promises.access(fileName, _fs.constants.F_OK);
}
return true;
} catch (err) {
if ((0, _isError).default(err) && (err.code === "ENOENT" || err.code === "ENAMETOOLONG")) {
return false;
}
throw err;
}
}
//# sourceMappingURL=file-exists.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/file-exists.ts"],"names":["fileExists","fileName","type","stats","promises","stat","isFile","isDirectory","access","constants","F_OK","err","isError","code"],"mappings":"AAAA;;;;QAGsBA,UAAU,GAAVA,UAAU;AAHI,IAAA,GAAI,WAAJ,IAAI,CAAA;AACpB,IAAA,QAAY,kCAAZ,YAAY,EAAA;;;;;;AAEzB,eAAeA,UAAU,CAC9BC,QAAgB,EAChBC,IAA2B,EACT;IAClB,IAAI;QACF,IAAIA,IAAI,KAAK,MAAM,EAAE;YACnB,MAAMC,KAAK,GAAG,MAAMC,GAAQ,SAAA,CAACC,IAAI,CAACJ,QAAQ,CAAC;YAC3C,OAAOE,KAAK,CAACG,MAAM,EAAE,CAAA;SACtB,MAAM,IAAIJ,IAAI,KAAK,WAAW,EAAE;YAC/B,MAAMC,KAAK,GAAG,MAAMC,GAAQ,SAAA,CAACC,IAAI,CAACJ,QAAQ,CAAC;YAC3C,OAAOE,KAAK,CAACI,WAAW,EAAE,CAAA;SAC3B,MAAM;YACL,MAAMH,GAAQ,SAAA,CAACI,MAAM,CAACP,QAAQ,EAAEQ,GAAS,UAAA,CAACC,IAAI,CAAC;SAChD;QACD,OAAO,IAAI,CAAA;KACZ,CAAC,OAAOC,GAAG,EAAE;QACZ,IACEC,CAAAA,GAAAA,QAAO,AAAK,CAAA,QAAL,CAACD,GAAG,CAAC,IACZ,CAACA,GAAG,CAACE,IAAI,KAAK,QAAQ,IAAIF,GAAG,CAACE,IAAI,KAAK,cAAc,CAAC,EACtD;YACA,OAAO,KAAK,CAAA;SACb;QACD,MAAMF,GAAG,CAAA;KACV;CACF"}

View File

@@ -0,0 +1,6 @@
declare type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export declare function findConfigPath(dir: string, key: string): Promise<string | undefined>;
export declare function findConfig<T>(directory: string, key: string, _returnFile?: boolean): Promise<RecursivePartial<T> | null>;
export {};

52
kitabcitab/node_modules/next/dist/lib/find-config.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findConfigPath = findConfigPath;
exports.findConfig = findConfig;
var _findUp = _interopRequireDefault(require("next/dist/compiled/find-up"));
var _fs = _interopRequireDefault(require("fs"));
var _json5 = _interopRequireDefault(require("next/dist/compiled/json5"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function findConfigPath(dir, key) {
// If we didn't find the configuration in `package.json`, we should look for
// known filenames.
return (0, _findUp).default([
`.${key}rc.json`,
`${key}.config.json`,
`.${key}rc.js`,
`${key}.config.js`,
`${key}.config.cjs`,
], {
cwd: dir
});
}
async function findConfig(directory, key, _returnFile) {
// `package.json` configuration always wins. Let's check that first.
const packageJsonPath = await (0, _findUp).default("package.json", {
cwd: directory
});
if (packageJsonPath) {
const packageJson = require(packageJsonPath);
if (packageJson[key] != null && typeof packageJson[key] === "object") {
return packageJson[key];
}
}
const filePath = await findConfigPath(directory, key);
if (filePath) {
if (filePath.endsWith(".js") || filePath.endsWith(".cjs")) {
return require(filePath);
}
// We load JSON contents with JSON5 to allow users to comment in their
// configuration file. This pattern was popularized by TypeScript.
const fileContents = _fs.default.readFileSync(filePath, "utf8");
return _json5.default.parse(fileContents);
}
return null;
}
//# sourceMappingURL=find-config.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/find-config.ts"],"names":["findConfigPath","findConfig","dir","key","findUp","cwd","directory","_returnFile","packageJsonPath","packageJson","require","filePath","endsWith","fileContents","fs","readFileSync","JSON5","par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,QAAQ,CAACC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACzD,OAAOF,OAAO,CAACC,QAAQ,CAAC,CAAA;SACzB;QAED,sEAAsE;QACtE,kEAAkE;QAClE,MAAME,YAAY,GAAGC,GAAE,QAAA,CAACC,YAAY,CAACJ,QAAQ,EAAE,MAAM,CAAC;QACtD,OAAOK,MAAK,QAAA,CAACC,KAAK,CAACJ,YAAY,CAAC,CAAA;KACjC;IAED,OAAO,IAAI,CAAA;CACZ"}

View File

@@ -0,0 +1,6 @@
export declare const existsSync: (f: string) => boolean;
export declare function findDir(dir: string, name: 'pages' | 'app'): string | null;
export declare function findPagesDir(dir: string, isAppDirEnabled: boolean): {
pagesDir: string | undefined;
appDir: string | undefined;
};

View File

@@ -0,0 +1,95 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findDir = findDir;
exports.findPagesDir = findPagesDir;
exports.existsSync = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var Log = _interopRequireWildcard(require("../build/output/log"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
const existsSync = (f)=>{
try {
_fs.default.accessSync(f, _fs.default.constants.F_OK);
return true;
} catch (_) {
return false;
}
};
exports.existsSync = existsSync;
function findDir(dir, name) {
// prioritize ./${name} over ./src/${name}
let curDir = _path.default.join(dir, name);
if (existsSync(curDir)) return curDir;
curDir = _path.default.join(dir, "src", name);
if (existsSync(curDir)) return curDir;
return null;
}
function findPagesDir(dir, isAppDirEnabled) {
const pagesDir = findDir(dir, "pages") || undefined;
const appDir = findDir(dir, "app") || undefined;
if (isAppDirEnabled && appDir == null && pagesDir == null) {
throw new Error("> Couldn't find any `pages` or `app` directory. Please create one under the project root");
}
if (!isAppDirEnabled) {
if (appDir != null && pagesDir == null) {
throw new Error("> The `app` directory is experimental. To enable, add `appDir: true` to your `next.config.js` configuration under `experimental`. See https://nextjs.org/docs/messages/experimental-app-dir-config");
}
if (appDir != null && pagesDir != null) {
Log.warn("The `app` directory is experimental. To enable, add `appDir: true` to your `next.config.js` configuration under `experimental`. See https://nextjs.org/docs/messages/experimental-app-dir-config");
}
if (pagesDir == null) {
throw new Error("> Couldn't find a `pages` directory. Please create one under the project root");
}
}
return {
pagesDir,
appDir: isAppDirEnabled ? appDir : undefined
};
}
//# sourceMappingURL=find-pages-dir.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/find-pages-dir.ts"],"names":["findDir","findPagesDir","Log","existsSync","f","fs","accessSync","constants","F_OK","_","dir","name","curDir","path","join","isAppDirEnabled","pagesDir","undefined","appDir","Error","warn"],"mappings":"AAAA;;;;QAagBA,OAAO,GAAPA,OAAO;QAWPC,YAAY,GAAZA,YAAY;;AAxBb,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACXC,IAAAA,GAAG,mCAAM,qBAAqB,EAA3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAER,MAAMC,UAAU,GAAG,CAACC,CAAS,GAAc;IAChD,IAAI;QACFC,GAAE,QAAA,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AM,IAAIG,KAAK,CACb,+EAA+E,CAChF,CAAA;SACF;KACF;IAED,OAAO;QACLH,QAAQ;QACRE,MAAM,EAAEH,eAAe,GAAGG,MAAM,GAAGD,SAAS;KAC7C,CAAA;CACF"}

View File

@@ -0,0 +1 @@
export declare function flatReaddir(dir: string, include: RegExp): Promise<string[]>;

29
kitabcitab/node_modules/next/dist/lib/flat-readdir.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.flatReaddir = flatReaddir;
var _path = require("path");
var _nonNullable = require("./non-nullable");
var _fs = require("fs");
async function flatReaddir(dir, include) {
const dirents = await _fs.promises.readdir(dir, {
withFileTypes: true
});
const result = await Promise.all(dirents.map(async (part)=>{
const absolutePath = (0, _path).join(dir, part.name);
if (part.isSymbolicLink()) {
const stats = await _fs.promises.stat(absolutePath);
if (stats.isDirectory()) {
return null;
}
}
if (part.isDirectory() || !include.test(part.name)) {
return null;
}
return absolutePath;
}));
return result.filter(_nonNullable.nonNullable);
}
//# sourceMappingURL=flat-readdir.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/flat-readdir.ts"],"names":["flatReaddir","dir","include","dirents","promises","readdir","withFileTypes","result","Promise","all","map","part","absolutePath","join","name","isSymbolicLink","stats","stat","isDirectory","test","filter","nonNullable"],"mappings":"AAAA;;;;QAIsBA,WAAW,GAAXA,WAAW;AAJZ,IAAA,KAAM,WAAN,MAAM,CAAA;AACC,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AACnB,IAAA,GAAI,WAAJ,IAAI,CAAA;AAEtB,eAAeA,WAAW,CAACC,GAAW,EAAEC,OAAe,EAAE;IAC9D,MAAMC,OAAO,GAAG,MAAMC,GAAQ,SAAA,CAACC,OAAO,CAACJ,GAAG,EAAE;QAAEK,aAAa,EAAE,IAAI;KAAE,CAAC;IACpE,MAAMC,MAAM,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC9BN,OAAO,CAACO,GAAG,CAAC,OAAOC,IAAI,GAAK;QAC1B,MAAMC,YAAY,GAAGC,CAAAA,GAAAA,KAAI,AAAgB,CAAA,KAAhB,CAACZ,GAAG,EAAEU,IAAI,CAACG,IAAI,CAAC;QACzC,IAAIH,IAAI,CAACI,cAAc,EAAE,EAAE;YACzB,MAAMC,KAAK,GAAG,MAAMZ,GAAQ,SAAA,CAACa,IAAI,CAACL,YAAY,CAAC;YAC/C,IAAII,KAAK,CAACE,WAAW,EAAE,EAAE;gBACvB,OAAO,IAAI,CAAA;aACZ;SACF;QAED,IAAIP,IAAI,CAACO,WAAW,EAAE,IAAI,CAAChB,OAAO,CAACiB,IAAI,CAACR,IAAI,CAACG,IAAI,CAAC,EAAE;YAClD,OAAO,IAAI,CAAA;SACZ;QAED,OAAOF,YAAY,CAAA;KACpB,CAAC,CACH;IAED,OAAOL,MAAM,CAACa,MAAM,CAACC,YAAW,YAAA,CAAC,CAAA;CAClC"}

View File

@@ -0,0 +1 @@
export declare function formatServerError(error: Error): void;

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatServerError = formatServerError;
function formatServerError(error) {
if (error.message.includes("createContext is not a function")) {
const message = 'createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component';
error.message = message;
if (error.stack) {
const lines = error.stack.split("\n");
lines[0] = message;
error.stack = lines.join("\n");
}
}
}
//# sourceMappingURL=format-server-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/format-server-error.ts"],"names":["formatServerError","error","message","includes","stack","lines","split","join"],"mappings":"AAAA;;;;QAAgBA,iBAAiB,GAAjBA,iBAAiB;AAA1B,SAASA,iBAAiB,CAACC,KAAY,EAAQ;IACpD,IAAIA,KAAK,CAACC,OAAO,CAACC,QAAQ,CAAC,iCAAiC,CAAC,EAAE;QAC7D,MAAMD,OAAO,GACX,yLAAyL;QAC3LD,KAAK,CAACC,OAAO,GAAGA,OAAO;QACvB,IAAID,KAAK,CAACG,KAAK,EAAE;YACf,MAAMC,KAAK,GAAGJ,KAAK,CAACG,KAAK,CAACE,KAAK,CAAC,IAAI,CAAC;YACrCD,KAAK,CAAC,CAAC,CAAC,GAAGH,OAAO;YAClBD,KAAK,CAACG,KAAK,GAAGC,KAAK,CAACE,IAAI,CAAC,IAAI,CAAC;SAC/B;KACF;CACF"}

View File

@@ -0,0 +1,12 @@
declare type PackageJsonDependencies = {
dependencies: Record<string, string>;
devDependencies: Record<string, string>;
};
export declare function getDependencies({ cwd, }: {
cwd: string;
}): Promise<PackageJsonDependencies>;
export declare function getPackageVersion({ cwd, name, }: {
cwd: string;
name: string;
}): Promise<string | null>;
export {};

View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getDependencies = getDependencies;
exports.getPackageVersion = getPackageVersion;
var _fs = require("fs");
var _findUp = _interopRequireDefault(require("next/dist/compiled/find-up"));
var _json5 = _interopRequireDefault(require("next/dist/compiled/json5"));
var path = _interopRequireWildcard(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
let cachedDeps;
function getDependencies({ cwd }) {
if (cachedDeps) {
return cachedDeps;
}
return cachedDeps = (async ()=>{
const configurationPath = await (0, _findUp).default("package.json", {
cwd
});
if (!configurationPath) {
return {
dependencies: {},
devDependencies: {}
};
}
const content = await _fs.promises.readFile(configurationPath, "utf-8");
const packageJson = _json5.default.parse(content);
const { dependencies ={} , devDependencies ={} } = packageJson || {};
return {
dependencies,
devDependencies
};
})();
}
async function getPackageVersion({ cwd , name }) {
const { dependencies , devDependencies } = await getDependencies({
cwd
});
if (!(dependencies[name] || devDependencies[name])) {
return null;
}
const cwd2 = cwd.endsWith(path.posix.sep) || cwd.endsWith(path.win32.sep) ? cwd : `${cwd}/`;
try {
const targetPath = require.resolve(`${name}/package.json`, {
paths: [
cwd2
]
});
const targetContent = await _fs.promises.readFile(targetPath, "utf-8");
return _json5.default.parse(targetContent).version ?? null;
} catch {
return null;
}
}
//# sourceMappingURL=get-package-version.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/get-package-version.ts"],"names":["getDependencies","getPackageVersion","path","cachedDeps","cwd","configurationPath","findUp","dependencies","devDependencies","content","fs","readFile","packageJson","JSON5","parse","name","cwd2","endsWith","posix","sep","win32","targetPath","require","resolve","paths","targetContent","version"],"mappings":"AAAA;;;;QAYgBA,eAAe,GAAfA,eAAe;QAyBTC,iBAAiB,GAAjBA,iBAAiB;AArCR,IAAA,GAAI,WAAJ,IAAI,CAAA;AAChB,IAAA,OAA4B,kCAA5B,4BAA4B,EAAA;AAC7B,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAChCC,IAAAA,IAAI,mCAAM,MAAM,EAAZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOhB,IAAIC,UAAU,AAAkC;AAEzC,SAASH,eAAe,CAAC,EAC9BI,GAAG,CAAA,EAGJ,EAAoC;IACnC,IAAID,UAAU,EAAE;QACd,OAAOA,UAAU,CAAA;KAClB;IAED,OAAQA,U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KAAK,EAAE;gBAACR,IAAI;aAAC;SACd,CAAC;QACF,MAAMS,aAAa,GAAG,MAAMf,GAAE,SAAA,CAACC,QAAQ,CAACU,UAAU,EAAE,OAAO,CAAC;QAC5D,OAAOR,MAAK,QAAA,CAACC,KAAK,CAACW,aAAa,CAAC,CAACC,OAAO,IAAI,IAAI,CAAA;KAClD,CAAC,OAAM;QACN,OAAO,IAAI,CAAA;KACZ;CACF"}

View File

@@ -0,0 +1 @@
export declare function getProjectDir(dir?: string): string;

View File

@@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getProjectDir = getProjectDir;
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _commands = require("./commands");
var Log = _interopRequireWildcard(require("../build/output/log"));
var _detectTypo = require("./detect-typo");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function getProjectDir(dir) {
try {
const resolvedDir = _path.default.resolve(dir || ".");
const realDir = _fs.default.realpathSync.native(resolvedDir);
if (resolvedDir !== realDir && resolvedDir.toLowerCase() === realDir.toLowerCase()) {
Log.warn(`Invalid casing detected for project dir, received ${resolvedDir} actual path ${realDir}, see more info here https://nextjs.org/docs/messages/invalid-project-dir-casing`);
}
return realDir;
} catch (err) {
if (err.code === "ENOENT") {
if (typeof dir === "string") {
const detectedTypo = (0, _detectTypo).detectTypo(dir, Object.keys(_commands.commands));
if (detectedTypo) {
Log.error(`"next ${dir}" does not exist. Did you mean "next ${detectedTypo}"?`);
process.exit(1);
}
}
Log.error(`Invalid project directory provided, no such directory: ${_path.default.resolve(dir || ".")}`);
process.exit(1);
}
throw err;
}
}
//# sourceMappingURL=get-project-dir.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/get-project-dir.ts"],"names":["getProjectDir","Log","dir","resolvedDir","path","resolve","realDir","fs","realpathSync","native","toLowerCase","warn","err","code","detectedTypo","detectTypo","Object","keys","commands","error","process","exit"],"mappings":"AAAA;;;;QAMgBA,aAAa,GAAbA,aAAa;AANd,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACE,IAAA,SAAY,WAAZ,YAAY,CAAA;AACzBC,IAAAA,GAAG,mCAAM,qBAAqB,EAA3B;AACY,IAAA,WAAe,WAAf,eAAe,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,SAASD,aAAa,CAACE,GAAY,EAAE;IAC1C,IAAI;QACF,MAAMC,WAAW,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACH,GAAG,IAAI,GAAG,CAAC;QAC5C,MAAMI,OAAO,GAAGC,GAAE,QAAA,CAACC,YAAY,CAACC,MAAM,CAACN,WAAW,CAAC;QAEnD,IACEA,WAAW,KAAKG,OAAO,IACvBH,WAAW,CAACO,WAAW,EAAE,KAAKJ,OAAO,CAACI,WAAW,EAAE,EACnD;YACAT,GAAG,CAACU,IAAI,CACN,CAAC,kDAAkD,EAAER,WAAW,CAAC,aAAa,EAAEG,OAAO,CAAC,gFAAgF,CAAC,CAC1K;SACF;QAED,OAAOA,OAAO,CAAA;KACf,CAAC,OAAOM,GAAG,EAAO;QACjB,IAAIA,GAAG,CAACC,IAAI,KAAK,QAAQ,EAAE;YACzB,IAAI,OAAOX,GAAG,KAAK,QAAQ,EAAE;gBAC3B,MAAMY,YAAY,GAAGC,CAAAA,GAAAA,WAAU,AAA4B,CAAA,WAA5B,CAACb,GAAG,EAAEc,MAAM,CAACC,IAAI,CAACC,SAAQ,SAAA,CAAC,CAAC;gBAE3D,IAAIJ,YAAY,EAAE;oBAChBb,GAAG,CAACkB,KAAK,CACP,CAAC,MAAM,EAAEjB,GAAG,CAAC,qCAAqC,EAAEY,YAAY,CAAC,EAAE,CAAC,CACrE;oBACDM,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;iBAChB;aACF;YAEDpB,GAAG,CAACkB,KAAK,CACP,CAAC,uDAAuD,EAAEf,KAAI,QAAA,CAACC,OAAO,CACpEH,GAAG,IAAI,GAAG,CACX,CAAC,CAAC,CACJ;YACDkB,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;SAChB;QACD,MAAMT,GAAG,CAAA;KACV;CACF"}

View File

@@ -0,0 +1,10 @@
export interface MissingDependency {
file: string;
pkg: string;
exportsRestrict: boolean;
}
export declare type NecessaryDependencies = {
resolved: Map<string, string>;
missing: MissingDependency[];
};
export declare function hasNecessaryDependencies(baseDir: string, requiredPackages: MissingDependency[]): Promise<NecessaryDependencies>;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasNecessaryDependencies = hasNecessaryDependencies;
var _fs = require("fs");
var _fileExists = require("./file-exists");
var _resolveFrom = require("./resolve-from");
var _path = require("path");
async function hasNecessaryDependencies(baseDir, requiredPackages) {
let resolutions = new Map();
const missingPackages = [];
await Promise.all(requiredPackages.map(async (p)=>{
try {
const pkgPath = await _fs.promises.realpath((0, _resolveFrom).resolveFrom(baseDir, `${p.pkg}/package.json`));
const pkgDir = (0, _path).dirname(pkgPath);
if (p.exportsRestrict) {
const fileNameToVerify = (0, _path).relative(p.pkg, p.file);
if (fileNameToVerify) {
const fileToVerify = (0, _path).join(pkgDir, fileNameToVerify);
if (await (0, _fileExists).fileExists(fileToVerify)) {
resolutions.set(p.pkg, fileToVerify);
} else {
return missingPackages.push(p);
}
} else {
resolutions.set(p.pkg, pkgPath);
}
} else {
resolutions.set(p.pkg, (0, _resolveFrom).resolveFrom(baseDir, p.file));
}
} catch (_) {
return missingPackages.push(p);
}
}));
return {
resolved: resolutions,
missing: missingPackages
};
}
//# sourceMappingURL=has-necessary-dependencies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/has-necessary-dependencies.ts"],"names":["hasNecessaryDependencies","baseDir","requiredPackages","resolutions","Map","missingPackages","Promise","all","map","p","pkgPath","fs","realpath","resolveFrom","pkg","pkgDir","dirname","exportsRestrict","fileNameToVerify","relative","file","fileToVerify","join","fileExists","set","push","_","resolved","missing"],"mappings":"AAAA;;;;QAgBsBA,wBAAwB,GAAxBA,wBAAwB;AAhBf,IAAA,GAAI,WAAJ,IAAI,CAAA;AACR,IAAA,WAAe,WAAf,eAAe,CAAA;AACd,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AACJ,IAAA,KAAM,WAAN,MAAM,CAAA;AAavC,eAAeA,wBAAwB,CAC5CC,OAAe,EACfC,gBAAqC,EACL;IAChC,IAAIC,WAAW,GAAG,IAAIC,GAAG,EAAkB;IAC3C,MAAMC,eAAe,GAAwB,EAAE;IAE/C,MAAMC,OAAO,CAACC,GAAG,CACfL,gBAAgB,CAACM,GAAG,CAAC,OAAOC,CAAC,GAAK;QAChC,IAAI;YACF,MAAMC,OAAO,GAAG,MAAMC,GAAE,SAAA,CAACC,QAAQ,CAC/BC,CAAAA,GAAAA,YAAW,AAAkC,CAAA,YAAlC,CAACZ,OAAO,EAAE,CAAC,EAAEQ,CAAC,CAACK,GAAG,CAAC,aAAa,CAAC,CAAC,CAC9C;YACD,MAAMC,MAAM,GAAGC,CAAAA,GAAAA,KAAO,AAAS,CAAA,QAAT,CAACN,OAAO,CAAC;YAE/B,IAAID,CAAC,CAACQ,eAAe,EAAE;gBACrB,MAAMC,gBAAgB,GAAGC,CAAAA,GAAAA,KAAQ,AAAe,CAAA,SAAf,CAACV,CAAC,CAACK,GAAG,EAAEL,CAAC,CAACW,IAAI,CAAC;gBAChD,IAAIF,gBAAgB,EAAE;oBACpB,MAAMG,YAAY,GAAGC,CAAAA,GAAAA,KAAI,AAA0B,CAAA,KAA1B,CAACP,MAAM,EAAEG,gBAAgB,CAAC;oBACnD,IAAI,MAAMK,CAAAA,GAAAA,WAAU,AAAc,CAAA,WAAd,CAACF,YAAY,CAAC,EAAE;wBAClClB,WAAW,CAACqB,GAAG,CAACf,CAAC,CAACK,GAAG,EAAEO,YAAY,CAAC;qBACrC,MAAM;wBACL,OAAOhB,eAAe,CAACoB,IAAI,CAAChB,CAAC,CAAC,CAAA;qBAC/B;iBACF,MAAM;oBACLN,WAAW,CAACqB,GAAG,CAACf,CAAC,CAACK,GAAG,EAAEJ,OAAO,CAAC;iBAChC;aACF,MAAM;gBACLP,WAAW,CAACqB,GAAG,CAACf,CAAC,CAACK,GAAG,EAAED,CAAAA,GAAAA,YAAW,AAAiB,CAAA,YAAjB,CAACZ,OAAO,EAAEQ,CAAC,CAACW,IAAI,CAAC,CAAC;aACrD;SACF,CAAC,OAAOM,CAAC,EAAE;YACV,OAAOrB,eAAe,CAACoB,IAAI,CAAChB,CAAC,CAAC,CAAA;SAC/B;KACF,CAAC,CACH;IAED,OAAO;QACLkB,QAAQ,EAAExB,WAAW;QACrByB,OAAO,EAAEvB,eAAe;KACzB,CAAA;CACF"}

View File

@@ -0,0 +1 @@
export declare function getOnline(): Promise<boolean>;

View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getOnline = getOnline;
var _childProcess = require("child_process");
var _dns = _interopRequireDefault(require("dns"));
var _url = _interopRequireDefault(require("url"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getProxy() {
if (process.env.https_proxy) {
return process.env.https_proxy;
}
try {
const httpsProxy = (0, _childProcess).execSync("npm config get https-proxy").toString().trim();
return httpsProxy !== "null" ? httpsProxy : undefined;
} catch (e) {
return;
}
}
function getOnline() {
return new Promise((resolve)=>{
_dns.default.lookup("registry.yarnpkg.com", (registryErr)=>{
if (!registryErr) {
return resolve(true);
}
const proxy = getProxy();
if (!proxy) {
return resolve(false);
}
const { hostname } = _url.default.parse(proxy);
if (!hostname) {
return resolve(false);
}
_dns.default.lookup(hostname, (proxyErr)=>{
resolve(proxyErr == null);
});
});
});
}
//# sourceMappingURL=get-online.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/helpers/get-online.ts"],"names":["getOnline","getProxy","process","env","https_proxy","httpsProxy","execSync","toString","trim","undefined","e","Promise","resolve","dns","lookup","registryErr","proxy","hostname","url","parse","proxyErr"],"mappings":"AAAA;;;;QAiBgBA,SAAS,GAATA,SAAS;AAjBA,IAAA,aAAe,WAAf,eAAe,CAAA;AACxB,IAAA,IAAK,kCAAL,KAAK,EAAA;AACL,IAAA,IAAK,kCAAL,KAAK,EAAA;;;;;;AAErB,SAASC,QAAQ,GAAuB;IACtC,IAAIC,OAAO,CAACC,GAAG,CAACC,WAAW,EAAE;QAC3B,OAAOF,OAAO,CAACC,GAAG,CAACC,WAAW,CAAA;KAC/B;IAED,IAAI;QACF,MAAMC,UAAU,GAAGC,CAAAA,GAAAA,aAAQ,AAA8B,CAAA,SAA9B,CAAC,4BAA4B,CAAC,CAACC,QAAQ,EAAE,CAACC,IAAI,EAAE;QAC3E,OAAOH,UAAU,KAAK,MAAM,GAAGA,UAAU,GAAGI,SAAS,CAAA;KACtD,CAAC,OAAOC,CAAC,EAAE;QACV,OAAM;KACP;CACF;AAEM,SAASV,SAAS,GAAqB;IAC5C,OAAO,IAAIW,OAAO,CAAC,CAACC,OAAO,GAAK;QAC9BC,IAAG,QAAA,CAACC,MAAM,CAAC,sBAAsB,EAAE,CAACC,WAAW,GAAK;YAClD,IAAI,CAACA,WAAW,EAAE;gBAChB,OAAOH,OAAO,CAAC,IAAI,CAAC,CAAA;aACrB;YAED,MAAMI,KAAK,GAAGf,QAAQ,EAAE;YACxB,IAAI,CAACe,KAAK,EAAE;gBACV,OAAOJ,OAAO,CAAC,KAAK,CAAC,CAAA;aACtB;YAED,MAAM,EAAEK,QAAQ,CAAA,EAAE,GAAGC,IAAG,QAAA,CAACC,KAAK,CAACH,KAAK,CAAC;YACrC,IAAI,CAACC,QAAQ,EAAE;gBACb,OAAOL,OAAO,CAAC,KAAK,CAAC,CAAA;aACtB;YAEDC,IAAG,QAAA,CAACC,MAAM,CAACG,QAAQ,EAAE,CAACG,QAAQ,GAAK;gBACjCR,OAAO,CAACQ,QAAQ,IAAI,IAAI,CAAC;aAC1B,CAAC;SACH,CAAC;KACH,CAAC,CAAA;CACH"}

View File

@@ -0,0 +1,2 @@
export declare type PackageManager = 'npm' | 'pnpm' | 'yarn';
export declare function getPkgManager(baseDir: string): PackageManager;

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPkgManager = getPkgManager;
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _childProcess = require("child_process");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getPkgManager(baseDir) {
try {
for (const { lockFile , packageManager } of [
{
lockFile: "yarn.lock",
packageManager: "yarn"
},
{
lockFile: "pnpm-lock.yaml",
packageManager: "pnpm"
},
{
lockFile: "package-lock.json",
packageManager: "npm"
},
]){
if (_fs.default.existsSync(_path.default.join(baseDir, lockFile))) {
return packageManager;
}
}
const userAgent = process.env.npm_config_user_agent;
if (userAgent) {
if (userAgent.startsWith("yarn")) {
return "yarn";
} else if (userAgent.startsWith("pnpm")) {
return "pnpm";
}
}
try {
(0, _childProcess).execSync("yarn --version", {
stdio: "ignore"
});
return "yarn";
} catch {
(0, _childProcess).execSync("pnpm --version", {
stdio: "ignore"
});
return "pnpm";
}
} catch {
return "npm";
}
}
//# sourceMappingURL=get-pkg-manager.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/helpers/get-pkg-manager.ts"],"names":["getPkgManager","baseDir","lockFile","packageManager","fs","existsSync","path","join","userAgent","process","env","npm_config_user_agent","startsWith","execSync","stdio"],"mappings":"AAAA;;;;QAMgBA,aAAa,GAAbA,aAAa;AANd,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACE,IAAA,aAAe,WAAf,eAAe,CAAA;;;;;;AAIjC,SAASA,aAAa,CAACC,OAAe,EAAkB;IAC7D,IAAI;QACF,KAAK,MAAM,EAAEC,QAAQ,CAAA,EAAEC,cAAc,CAAA,EAAE,IAAI;YACzC;gBAAED,QAAQ,EAAE,WAAW;gBAAEC,cAAc,EAAE,MAAM;aAAE;YACjD;gBAAED,QAAQ,EAAE,gBAAgB;gBAAEC,cAAc,EAAE,MAAM;aAAE;YACtD;gBAAED,QAAQ,EAAE,mBAAmB;gBAAEC,cAAc,EAAE,KAAK;aAAE;SACzD,CAAE;YACD,IAAIC,GAAE,QAAA,CAACC,UAAU,CAACC,KAAI,QAAA,CAACC,IAAI,CAACN,OAAO,EAAEC,QAAQ,CAAC,CAAC,EAAE;gBAC/C,OAAOC,cAAc,CAAkB;aACxC;SACF;QACD,MAAMK,SAAS,GAAGC,OAAO,CAACC,GAAG,CAACC,qBAAqB;QACnD,IAAIH,SAAS,EAAE;YACb,IAAIA,SAAS,CAACI,UAAU,CAAC,MAAM,CAAC,EAAE;gBAChC,OAAO,MAAM,CAAA;aACd,MAAM,IAAIJ,SAAS,CAACI,UAAU,CAAC,MAAM,CAAC,EAAE;gBACvC,OAAO,MAAM,CAAA;aACd;SACF;QACD,IAAI;YACFC,CAAAA,GAAAA,aAAQ,AAAuC,CAAA,SAAvC,CAAC,gBAAgB,EAAE;gBAAEC,KAAK,EAAE,QAAQ;aAAE,CAAC;YAC/C,OAAO,MAAM,CAAA;SACd,CAAC,OAAM;YACND,CAAAA,GAAAA,aAAQ,AAAuC,CAAA,SAAvC,CAAC,gBAAgB,EAAE;gBAAEC,KAAK,EAAE,QAAQ;aAAE,CAAC;YAC/C,OAAO,MAAM,CAAA;SACd;KACF,CAAC,OAAM;QACN,OAAO,KAAK,CAAA;KACb;CACF"}

View File

@@ -0,0 +1,22 @@
export declare type PackageManager = 'npm' | 'pnpm' | 'yarn';
interface InstallArgs {
/**
* Indicate whether to install packages using npm, pnpm or Yarn.
*/
packageManager: PackageManager;
/**
* Indicate whether there is an active Internet connection.
*/
isOnline: boolean;
/**
* Indicate whether the given dependencies are devDependencies.
*/
devDependencies?: boolean;
}
/**
* Spawn a package manager installation with either Yarn or NPM.
*
* @returns A Promise that resolves once the installation is finished.
*/
export declare function install(root: string, dependencies: string[] | null, { packageManager, isOnline, devDependencies }: InstallArgs): Promise<void>;
export {};

View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.install = install;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _crossSpawn = _interopRequireDefault(require("next/dist/compiled/cross-spawn"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function install(root, dependencies, { packageManager , isOnline , devDependencies }) {
/**
* (p)npm-specific command-line flags.
*/ const npmFlags = [];
/**
* Yarn-specific command-line flags.
*/ const yarnFlags = [];
/**
* Return a Promise that resolves once the installation is finished.
*/ return new Promise((resolve, reject)=>{
let args;
let command = packageManager;
const useYarn = packageManager === "yarn";
if (dependencies && dependencies.length) {
/**
* If there are dependencies, run a variation of `{packageManager} add`.
*/ if (useYarn) {
/**
* Call `yarn add --exact (--offline)? (-D)? ...`.
*/ args = [
"add",
"--exact"
];
if (!isOnline) args.push("--offline");
args.push("--cwd", root);
if (devDependencies) args.push("--dev");
args.push(...dependencies);
} else {
/**
* Call `(p)npm install [--save|--save-dev] ...`.
*/ args = [
"install",
"--save-exact"
];
args.push(devDependencies ? "--save-dev" : "--save");
args.push(...dependencies);
}
} else {
/**
* If there are no dependencies, run a variation of `{packageManager}
* install`.
*/ args = [
"install"
];
if (!isOnline) {
console.log(_chalk.default.yellow("You appear to be offline."));
if (useYarn) {
console.log(_chalk.default.yellow("Falling back to the local Yarn cache."));
console.log();
args.push("--offline");
} else {
console.log();
}
}
}
/**
* Add any package manager-specific flags.
*/ if (useYarn) {
args.push(...yarnFlags);
} else {
args.push(...npmFlags);
}
/**
* Spawn the installation process.
*/ const child = (0, _crossSpawn).default(command, args, {
stdio: "inherit",
env: {
...process.env,
ADBLOCK: "1",
// we set NODE_ENV to development as pnpm skips dev
// dependencies when production
NODE_ENV: "development",
DISABLE_OPENCOLLECTIVE: "1"
}
});
child.on("close", (code)=>{
if (code !== 0) {
reject({
command: `${command} ${args.join(" ")}`
});
return;
}
resolve();
});
});
}
//# sourceMappingURL=install.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../lib/helpers/install.ts"],"names":["install","root","dependencies","packageManager","isOnline","devDependencies","npmFlags","yarnFlags","Promise","resolve","reject","args","command","useYarn","length","push","console","log","chalk","yellow","child","spawn","stdio","env","process","ADBLOCK","NODE_ENV","DISABLE_OPENCOLLECTIVE","on","code","join"],"mappings":"AAAA;;;;QAyBgBA,OAAO,GAAPA,OAAO;AAzBL,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC1B,IAAA,WAAgC,kCAAhC,gCAAgC,EAAA;;;;;;AAwB3C,SAASA,OAAO,CACrBC,IAAY,EACZC,YAA6B,EAC7B,EAAEC,cAAc,CAAA,EAAEC,QAAQ,CAAA,EAAEC,eAAe,CAAA,EAAe,EAC3C;IACf;;KAEG,CACH,MAAMC,QAAQ,GAAa,EAAE;IAC7B;;KAEG,CACH,MAAMC,SAAS,GAAa,EAAE;IAC9B;;KAEG,CACH,OAAO,IAAI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,CAAC;SACxB,MAAM;YACLI,IAAI,CAACI,IAAI,IAAIT,QAAQ,CAAC;SACvB;QACD;;OAEG,CACH,MAAMc,KAAK,GAAGC,CAAAA,GAAAA,WAAK,AAUjB,CAAA,QAViB,CAACT,OAAO,EAAED,IAAI,EAAE;YACjCW,KAAK,EAAE,SAAS;YAChBC,GAAG,EAAE;gBACH,GAAGC,OAAO,CAACD,GAAG;gBACdE,OAAO,EAAE,GAAG;gBACZ,mDAAmD;gBACnD,+BAA+B;gBAC/BC,QAAQ,EAAE,aAAa;gBACvBC,sBAAsB,EAAE,GAAG;aAC5B;SACF,CAAC;QACFP,KAAK,CAACQ,EAAE,CAAC,OAAO,EAAE,CAACC,IAAI,GAAK;YAC1B,IAAIA,IAAI,KAAK,CAAC,EAAE;gBACdnB,MAAM,CAAC;oBAAEE,OAAO,EAAE,CAAC,EAAEA,OAAO,CAAC,CAAC,EAAED,IAAI,CAACmB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;iBAAE,CAAC;gBACnD,OAAM;aACP;YACDrB,OAAO,EAAE;SACV,CAAC;KACH,CAAC,CAAA;CACH"}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,45 @@
"use strict";
var Log = _interopRequireWildcard(require("../build/output/log"));
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
var ref;
Log.warn(`"next" should not be imported directly, imported in ${(ref = module.parent) == null ? void 0 : ref.filename}\nSee more info here: https://nextjs.org/docs/messages/import-next`);
//# sourceMappingURL=import-next-warning.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/import-next-warning.ts"],"names":["Log","module","warn","parent","filename"],"mappings":"AAAA;AAAYA,IAAAA,GAAG,mCAAM,qBAAqB,EAA3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAG0CC,GAAa;AADtED,GAAG,CAACE,IAAI,CACN,CAAC,oDAAoD,EAAED,CAAAA,GAAa,GAAbA,MAAM,CAACE,MAAM,SAAU,GAAvBF,KAAAA,CAAuB,GAAvBA,GAAa,CAAEG,QAAQ,CAAC,kEAAkE,CAAC,CACnJ"}

View File

@@ -0,0 +1,4 @@
export declare type Dependencies = {
resolved: Map<string, string>;
};
export declare function installDependencies(baseDir: string, deps: any, dev?: boolean): Promise<void>;

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.installDependencies = installDependencies;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _path = _interopRequireDefault(require("path"));
var _getPkgManager = require("./helpers/get-pkg-manager");
var _install = require("./helpers/install");
var _getOnline = require("./helpers/get-online");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
async function installDependencies(baseDir, deps, dev = false) {
const packageManager = (0, _getPkgManager).getPkgManager(baseDir);
const isOnline = await (0, _getOnline).getOnline();
if (deps.length) {
console.log();
console.log(`Installing ${dev ? "devDependencies" : "dependencies"} (${packageManager}):`);
for (const dep1 of deps){
console.log(`- ${_chalk.default.cyan(dep1.pkg)}`);
}
console.log();
await (0, _install).install(_path.default.resolve(baseDir), deps.map((dep)=>dep.pkg), {
devDependencies: dev,
isOnline,
packageManager
});
console.log();
}
}
//# sourceMappingURL=install-dependencies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/install-dependencies.ts"],"names":["installDependencies","baseDir","deps","dev","packageManager","getPkgManager","isOnline","getOnline","length","console","log","dep","chalk","cyan","pkg","install","path","resolve","map","devDependencies"],"mappings":"AAAA;;;;QAYsBA,mBAAmB,GAAnBA,mBAAmB;AAZvB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC3B,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGO,IAAA,cAA2B,WAA3B,2BAA2B,CAAA;AACjC,IAAA,QAAmB,WAAnB,mBAAmB,CAAA;AACjB,IAAA,UAAsB,WAAtB,sBAAsB,CAAA;;;;;;AAMzC,eAAeA,mBAAmB,CACvCC,OAAe,EACfC,IAAS,EACTC,GAAY,GAAG,KAAK,EACpB;IACA,MAAMC,cAAc,GAAGC,CAAAA,GAAAA,cAAa,AAAS,CAAA,cAAT,CAACJ,OAAO,CAAC;IAC7C,MAAMK,QAAQ,GAAG,MAAMC,CAAAA,GAAAA,UAAS,AAAE,CAAA,UAAF,EAAE;IAElC,IAAIL,IAAI,CAACM,MAAM,EAAE;QACfC,OAAO,CAACC,GAAG,EAAE;QACbD,OAAO,CAACC,GAAG,CACT,CAAC,WAAW,EACVP,GAAG,GAAG,iBAAiB,GAAG,cAAc,CACzC,EAAE,EAAEC,cAAc,CAAC,EAAE,CAAC,CACxB;QACD,KAAK,MAAMO,IAAG,IAAIT,IAAI,CAAE;YACtBO,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,EAAEE,MAAK,QAAA,CAACC,IAAI,CAACF,IAAG,CAACG,GAAG,CAAC,CAAC,CAAC,CAAC;SACxC;QACDL,OAAO,CAACC,GAAG,EAAE;QAEb,MAAMK,CAAAA,GAAAA,QAAO,AAIZ,CAAA,QAJY,CACXC,KAAI,QAAA,CAACC,OAAO,CAAChB,OAAO,CAAC,EACrBC,IAAI,CAACgB,GAAG,CAAC,CAACP,GAAsB,GAAKA,GAAG,CAACG,GAAG,CAAC,EAC7C;YAAEK,eAAe,EAAEhB,GAAG;YAAEG,QAAQ;YAAEF,cAAc;SAAE,CACnD;QACDK,OAAO,CAACC,GAAG,EAAE;KACd;CACF"}

View File

@@ -0,0 +1 @@
export declare function interopDefault(mod: any): any;

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.interopDefault = interopDefault;
function interopDefault(mod) {
return mod.default || mod;
}
//# sourceMappingURL=interop-default.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/interop-default.ts"],"names":["interopDefault","mod","default"],"mappings":"AAAA;;;;QAAgBA,cAAc,GAAdA,cAAc;AAAvB,SAASA,cAAc,CAACC,GAAQ,EAAE;IACvC,OAAOA,GAAG,CAACC,OAAO,IAAID,GAAG,CAAA;CAC1B"}

View File

@@ -0,0 +1 @@
export declare function isAPIRoute(value?: string): boolean;

10
kitabcitab/node_modules/next/dist/lib/is-api-route.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isAPIRoute = isAPIRoute;
function isAPIRoute(value) {
return value === "/api" || Boolean(value == null ? void 0 : value.startsWith("/api/"));
}
//# sourceMappingURL=is-api-route.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/is-api-route.ts"],"names":["isAPIRoute","value","Boolean","startsWith"],"mappings":"AAAA;;;;QAAgBA,UAAU,GAAVA,UAAU;AAAnB,SAASA,UAAU,CAACC,KAAc,EAAE;IACzC,OAAOA,KAAK,KAAK,MAAM,IAAIC,OAAO,CAACD,KAAK,QAAY,GAAjBA,KAAAA,CAAiB,GAAjBA,KAAK,CAAEE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;CAC/D"}

View File

@@ -0,0 +1,2 @@
import { ServerRuntime } from '../types';
export declare function isEdgeRuntime(value?: string): value is ServerRuntime;

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEdgeRuntime = isEdgeRuntime;
var _constants = require("./constants");
function isEdgeRuntime(value) {
return value === _constants.SERVER_RUNTIME.experimentalEdge || value === _constants.SERVER_RUNTIME.edge;
}
//# sourceMappingURL=is-edge-runtime.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/is-edge-runtime.ts"],"names":["isEdgeRuntime","value","SERVER_RUNTIME","experimentalEdge","edge"],"mappings":"AAAA;;;;QAGgBA,aAAa,GAAbA,aAAa;AAFE,IAAA,UAAa,WAAb,aAAa,CAAA;AAErC,SAASA,aAAa,CAACC,KAAc,EAA0B;IACpE,OACEA,KAAK,KAAKC,UAAc,eAAA,CAACC,gBAAgB,IAAIF,KAAK,KAAKC,UAAc,eAAA,CAACE,IAAI,CAC3E;CACF"}

8
kitabcitab/node_modules/next/dist/lib/is-error.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export interface NextError extends Error {
type?: string;
page?: string;
code?: string | number;
cancelled?: boolean;
}
export default function isError(err: unknown): err is NextError;
export declare function getProperError(err: unknown): Error;

28
kitabcitab/node_modules/next/dist/lib/is-error.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isError;
exports.getProperError = getProperError;
var _isPlainObject = require("../shared/lib/is-plain-object");
function isError(err) {
return typeof err === "object" && err !== null && "name" in err && "message" in err;
}
function getProperError(err) {
if (isError(err)) {
return err;
}
if (process.env.NODE_ENV === "development") {
// provide better error for case where `throw undefined`
// is called in development
if (typeof err === "undefined") {
return new Error("An undefined error was thrown, " + "see here for more info: https://nextjs.org/docs/messages/threw-undefined");
}
if (err === null) {
return new Error("A null error was thrown, " + "see here for more info: https://nextjs.org/docs/messages/threw-undefined");
}
}
return new Error((0, _isPlainObject).isPlainObject(err) ? JSON.stringify(err) : err + "");
}
//# sourceMappingURL=is-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/is-error.ts"],"names":["isError","getProperError","err","process","env","NODE_ENV","Error","isPlainObject","JSON","stringify"],"mappings":"AAAA;;;;kBAUwBA,OAAO;QAMfC,cAAc,GAAdA,cAAc;AAhBA,IAAA,cAA+B,WAA/B,+BAA+B,CAAA;AAU9C,SAASD,OAAO,CAACE,GAAY,EAAoB;IAC9D,OACE,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,KAAK,IAAI,IAAI,MAAM,IAAIA,GAAG,IAAI,SAAS,IAAIA,GAAG,CAC7E;CACF;AAEM,SAASD,cAAc,CAACC,GAAY,EAAS;IAClD,IAAIF,OAAO,CAACE,GAAG,CAAC,EAAE;QAChB,OAAOA,GAAG,CAAA;KACX;IAED,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;QAC1C,wDAAwD;QACxD,2BAA2B;QAC3B,IAAI,OAAOH,GAAG,KAAK,WAAW,EAAE;YAC9B,OAAO,IAAII,KAAK,CACd,iCAAiC,GAC/B,0EAA0E,CAC7E,CAAA;SACF;QAED,IAAIJ,GAAG,KAAK,IAAI,EAAE;YAChB,OAAO,IAAII,KAAK,CACd,2BAA2B,GACzB,0EAA0E,CAC7E,CAAA;SACF;KACF;IAED,OAAO,IAAIA,KAAK,CAACC,CAAAA,GAAAA,cAAa,AAAK,CAAA,cAAL,CAACL,GAAG,CAAC,GAAGM,IAAI,CAACC,SAAS,CAACP,GAAG,CAAC,GAAGA,GAAG,GAAG,EAAE,CAAC,CAAA;CACtE"}

View File

@@ -0,0 +1,4 @@
export declare class SerializableError extends Error {
constructor(page: string, method: string, path: string, message: string);
}
export declare function isSerializableProps(page: string, method: string, input: any): true;

View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isSerializableProps = isSerializableProps;
var _isPlainObject = require("../shared/lib/is-plain-object");
const regexpPlainIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
class SerializableError extends Error {
constructor(page, method, path, message){
super(path ? `Error serializing \`${path}\` returned from \`${method}\` in "${page}".\nReason: ${message}` : `Error serializing props returned from \`${method}\` in "${page}".\nReason: ${message}`);
}
}
exports.SerializableError = SerializableError;
function isSerializableProps(page, method, input) {
if (!(0, _isPlainObject).isPlainObject(input)) {
throw new SerializableError(page, method, "", `Props must be returned as a plain object from ${method}: \`{ props: { ... } }\` (received: \`${(0, _isPlainObject).getObjectClassLabel(input)}\`).`);
}
function visit(visited, value, path) {
if (visited.has(value)) {
throw new SerializableError(page, method, path, `Circular references cannot be expressed in JSON (references: \`${visited.get(value) || "(self)"}\`).`);
}
visited.set(value, path);
}
function isSerializable(refs, value, path) {
const type = typeof value;
if (// `null` can be serialized, but not `undefined`.
value === null || // n.b. `bigint`, `function`, `symbol`, and `undefined` cannot be
// serialized.
//
// `object` is special-cased below, as it may represent `null`, an Array,
// a plain object, a class, et al.
type === "boolean" || type === "number" || type === "string") {
return true;
}
if (type === "undefined") {
throw new SerializableError(page, method, path, "`undefined` cannot be serialized as JSON. Please use `null` or omit this value.");
}
if ((0, _isPlainObject).isPlainObject(value)) {
visit(refs, value, path);
if (Object.entries(value).every(([key, nestedValue])=>{
const nextPath = regexpPlainIdentifier.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
const newRefs = new Map(refs);
return isSerializable(newRefs, key, nextPath) && isSerializable(newRefs, nestedValue, nextPath);
})) {
return true;
}
throw new SerializableError(page, method, path, `invariant: Unknown error encountered in Object.`);
}
if (Array.isArray(value)) {
visit(refs, value, path);
if (value.every((nestedValue, index)=>{
const newRefs = new Map(refs);
return isSerializable(newRefs, nestedValue, `${path}[${index}]`);
})) {
return true;
}
throw new SerializableError(page, method, path, `invariant: Unknown error encountered in Array.`);
}
// None of these can be expressed as JSON:
// const type: "bigint" | "symbol" | "object" | "function"
throw new SerializableError(page, method, path, "`" + type + "`" + (type === "object" ? ` ("${Object.prototype.toString.call(value)}")` : "") + " cannot be serialized as JSON. Please only return JSON serializable data types.");
}
return isSerializable(new Map(), input, "");
}
//# sourceMappingURL=is-serializable-props.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/is-serializable-props.ts"],"names":["isSerializableProps","regexpPlainIdentifier","SerializableError","Error","constructor","page","method","path","message","input","isPlainObject","getObjectClassLabel","visit","visited","value","has","get","set","isSerializable","refs","type","Object","entries","every","key","nestedValue","nextPath","test","JSON","stringify","newRefs","Map","Array","isArray","index","prototype","toString","call"],"mappings":"AAAA;;;;QAiBgBA,mBAAmB,GAAnBA,mBAAmB;AAd5B,IAAA,cAA+B,WAA/B,+BAA+B,CAAA;AAEtC,MAAMC,qBAAqB,+BAA+B;AAEnD,MAAMC,iBAAiB,SAASC,KAAK;IAC1CC,YAAYC,IAAY,EAAEC,MAAc,EAAEC,IAAY,EAAEC,OAAe,CAAE;QACvE,KAAK,CACHD,IAAI,GACA,CAAC,oBAAoB,EAAEA,IAAI,CAAC,mBAAmB,EAAED,MAAM,CAAC,OAAO,EAAED,IAAI,CAAC,YAAY,EAAEG,OAAO,CAAC,CAAC,GAC7F,CAAC,wCAAwC,EAAEF,MAAM,CAAC,OAAO,EAAED,IAAI,CAAC,YAAY,EAAEG,OAAO,CAAC,CAAC,CAC5F;KACF;CACF;QARYN,iBAAiB,GAAjBA,iBAAiB;AAUvB,SAASF,mBAAmB,CACjCK,IAAY,EACZC,MAAc,EACdG,KAAU,EACJ;IACN,IAAI,CAACC,CAAAA,GAAAA,cAAa,AAAO,CAAA,cAAP,CAACD,KAAK,CAAC,EAAE;QACzB,MAAM,IAAIP,iBAAiB,CACzBG,IAAI,EACJC,MAAM,EACN,EAAE,EACF,CAAC,8CAA8C,EAAEA,MAAM,CAAC,sCAAsC,EAAEK,CAAAA,GAAAA,cAAmB,AAElH,CAAA,oBAFkH,CACjHF,KAAK,CACN,CAAC,IAAI,CAAC,CACR,CAAA;KACF;IAED,SAASG,KAAK,CAACC,OAAyB,EAAEC,KAAU,EAAEP,IAAY,EAAE;QAClE,IAAIM,OAAO,CAAC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C,CAAA;CAC5C"}

View File

@@ -0,0 +1,62 @@
import type { NextConfig } from '../server/config';
export declare type RouteHas = {
type: 'header' | 'query' | 'cookie';
key: string;
value?: string;
} | {
type: 'host';
key?: undefined;
value: string;
};
export declare type Rewrite = {
source: string;
destination: string;
basePath?: false;
locale?: false;
has?: RouteHas[];
missing?: RouteHas[];
};
export declare type Header = {
source: string;
basePath?: false;
locale?: false;
headers: Array<{
key: string;
value: string;
}>;
has?: RouteHas[];
missing?: RouteHas[];
};
export declare type Redirect = {
source: string;
destination: string;
basePath?: false;
locale?: false;
has?: RouteHas[];
missing?: RouteHas[];
} & ({
statusCode?: never;
permanent: boolean;
} | {
statusCode: number;
permanent?: never;
});
export declare type Middleware = {
source: string;
locale?: false;
has?: RouteHas[];
missing?: RouteHas[];
};
export declare function normalizeRouteRegex(regex: string): string;
export declare type RouteType = 'rewrite' | 'redirect' | 'header';
export declare function checkCustomRoutes(routes: Redirect[] | Header[] | Rewrite[] | Middleware[], type: RouteType | 'middleware'): void;
export interface CustomRoutes {
headers: Header[];
rewrites: {
fallback: Rewrite[];
afterFiles: Rewrite[];
beforeFiles: Rewrite[];
};
redirects: Redirect[];
}
export default function loadCustomRoutes(config: NextConfig): Promise<CustomRoutes>;

View File

@@ -0,0 +1,465 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loadCustomRoutes;
exports.normalizeRouteRegex = normalizeRouteRegex;
exports.checkCustomRoutes = checkCustomRoutes;
var _chalk = _interopRequireDefault(require("./chalk"));
var _escapeRegexp = require("../shared/lib/escape-regexp");
var _tryToParsePath = require("./try-to-parse-path");
var _redirectStatus = require("./redirect-status");
async function loadCustomRoutes(config) {
const [headers, rewrites, redirects] = await Promise.all([
loadHeaders(config),
loadRewrites(config),
loadRedirects(config),
]);
const totalRewrites = rewrites.beforeFiles.length + rewrites.afterFiles.length + rewrites.fallback.length;
const totalRoutes = headers.length + redirects.length + totalRewrites;
if (totalRoutes > 1000) {
console.warn(_chalk.default.bold.yellow(`Warning: `) + `total number of custom routes exceeds 1000, this can reduce performance. Route counts:\n` + `headers: ${headers.length}\n` + `rewrites: ${totalRewrites}\n` + `redirects: ${redirects.length}\n` + `See more info: https://nextjs.org/docs/messages/max-custom-routes-reached`);
}
if (!config.skipTrailingSlashRedirect) {
if (config.trailingSlash) {
redirects.unshift({
source: "/:file((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/]+\\.\\w+)/",
destination: "/:file",
permanent: true,
locale: config.i18n ? false : undefined,
internal: true
}, {
source: "/:notfile((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/\\.]+)",
destination: "/:notfile/",
permanent: true,
locale: config.i18n ? false : undefined,
internal: true
});
if (config.basePath) {
redirects.unshift({
source: config.basePath,
destination: config.basePath + "/",
permanent: true,
basePath: false,
locale: config.i18n ? false : undefined,
internal: true
});
}
} else {
redirects.unshift({
source: "/:path+/",
destination: "/:path+",
permanent: true,
locale: config.i18n ? false : undefined,
internal: true
});
if (config.basePath) {
redirects.unshift({
source: config.basePath + "/",
destination: config.basePath,
permanent: true,
basePath: false,
locale: config.i18n ? false : undefined,
internal: true
});
}
}
}
return {
headers,
rewrites,
redirects
};
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const allowedHasTypes = new Set([
"header",
"cookie",
"query",
"host"
]);
const namedGroupsRegex = /\(\?<([a-zA-Z][a-zA-Z0-9]*)>/g;
function normalizeRouteRegex(regex) {
// clean up un-necessary escaping from regex.source which turns / into \\/
return regex.replace(/\\\//g, "/");
}
function checkRedirect(route) {
const invalidParts = [];
let hadInvalidStatus = false;
if (route.statusCode && !_redirectStatus.allowedStatusCodes.has(route.statusCode)) {
hadInvalidStatus = true;
invalidParts.push(`\`statusCode\` is not undefined or valid statusCode`);
}
if (typeof route.permanent !== "boolean" && !route.statusCode) {
invalidParts.push(`\`permanent\` is not set to \`true\` or \`false\``);
}
return {
invalidParts,
hadInvalidStatus
};
}
function checkHeader(route) {
const invalidParts = [];
if (!Array.isArray(route.headers)) {
invalidParts.push("`headers` field must be an array");
} else if (route.headers.length === 0) {
invalidParts.push("`headers` field cannot be empty");
} else {
for (const header of route.headers){
if (!header || typeof header !== "object") {
invalidParts.push("`headers` items must be object with { key: '', value: '' }");
break;
}
if (typeof header.key !== "string") {
invalidParts.push("`key` in header item must be string");
break;
}
if (typeof header.value !== "string") {
invalidParts.push("`value` in header item must be string");
break;
}
}
}
return invalidParts;
}
function checkCustomRoutes(routes, type) {
if (!Array.isArray(routes)) {
console.error(`Error: ${type}s must return an array, received ${typeof routes}.\n` + `See here for more info: https://nextjs.org/docs/messages/routes-must-be-array`);
process.exit(1);
}
let numInvalidRoutes = 0;
let hadInvalidStatus = false;
let hadInvalidHas = false;
let hadInvalidMissing = false;
const allowedKeys = new Set([
"source",
"locale",
"has",
"missing"
]);
if (type === "rewrite") {
allowedKeys.add("basePath");
allowedKeys.add("destination");
}
if (type === "redirect") {
allowedKeys.add("basePath");
allowedKeys.add("statusCode");
allowedKeys.add("permanent");
allowedKeys.add("destination");
}
if (type === "header") {
allowedKeys.add("basePath");
allowedKeys.add("headers");
}
for (const route of routes){
if (!route || typeof route !== "object") {
console.error(`The route ${JSON.stringify(route)} is not a valid object with \`source\`${type !== "middleware" ? ` and \`${type === "header" ? "headers" : "destination"}\`` : ""}`);
numInvalidRoutes++;
continue;
}
if (type === "rewrite" && route.basePath === false && !(route.destination.startsWith("http://") || route.destination.startsWith("https://"))) {
console.error(`The route ${route.source} rewrites urls outside of the basePath. Please use a destination that starts with \`http://\` or \`https://\` https://nextjs.org/docs/messages/invalid-external-rewrite`);
numInvalidRoutes++;
continue;
}
const keys = Object.keys(route);
const invalidKeys = keys.filter((key)=>!allowedKeys.has(key));
const invalidParts = [];
if ("basePath" in route && typeof route.basePath !== "undefined" && route.basePath !== false) {
invalidParts.push("`basePath` must be undefined or false");
}
if (typeof route.locale !== "undefined" && route.locale !== false) {
invalidParts.push("`locale` must be undefined or false");
}
const checkInvalidHasMissing = (items, fieldName)=>{
let hadInvalidItem = false;
if (typeof items !== "undefined" && !Array.isArray(items)) {
invalidParts.push(`\`${fieldName}\` must be undefined or valid has object`);
hadInvalidItem = true;
} else if (items) {
const invalidHasItems = [];
for (const hasItem of items){
let invalidHasParts = [];
if (!allowedHasTypes.has(hasItem.type)) {
invalidHasParts.push(`invalid type "${hasItem.type}"`);
}
if (typeof hasItem.key !== "string" && hasItem.type !== "host") {
invalidHasParts.push(`invalid key "${hasItem.key}"`);
}
if (typeof hasItem.value !== "undefined" && typeof hasItem.value !== "string") {
invalidHasParts.push(`invalid value "${hasItem.value}"`);
}
if (typeof hasItem.value === "undefined" && hasItem.type === "host") {
invalidHasParts.push(`value is required for "host" type`);
}
if (invalidHasParts.length > 0) {
invalidHasItems.push(`${invalidHasParts.join(", ")} for ${JSON.stringify(hasItem)}`);
}
}
if (invalidHasItems.length > 0) {
hadInvalidItem = true;
const itemStr = `item${invalidHasItems.length === 1 ? "" : "s"}`;
console.error(`Invalid \`${fieldName}\` ${itemStr}:\n` + invalidHasItems.join("\n"));
console.error();
invalidParts.push(`invalid \`${fieldName}\` ${itemStr} found`);
}
}
return hadInvalidItem;
};
if (checkInvalidHasMissing(route.has, "has")) {
hadInvalidHas = true;
}
if (checkInvalidHasMissing(route.missing, "missing")) {
hadInvalidMissing = true;
}
if (!route.source) {
invalidParts.push("`source` is missing");
} else if (typeof route.source !== "string") {
invalidParts.push("`source` is not a string");
} else if (!route.source.startsWith("/")) {
invalidParts.push("`source` does not start with /");
}
if (type === "header") {
invalidParts.push(...checkHeader(route));
} else if (type !== "middleware") {
let _route = route;
if (!_route.destination) {
invalidParts.push("`destination` is missing");
} else if (typeof _route.destination !== "string") {
invalidParts.push("`destination` is not a string");
} else if (type === "rewrite" && !_route.destination.match(/^(\/|https:\/\/|http:\/\/)/)) {
invalidParts.push("`destination` does not start with `/`, `http://`, or `https://`");
}
}
if (type === "redirect") {
const result = checkRedirect(route);
hadInvalidStatus = hadInvalidStatus || result.hadInvalidStatus;
invalidParts.push(...result.invalidParts);
}
let sourceTokens;
if (typeof route.source === "string" && route.source.startsWith("/")) {
// only show parse error if we didn't already show error
// for not being a string
const { tokens , error , regexStr } = (0, _tryToParsePath).tryToParsePath(route.source);
if (error) {
invalidParts.push("`source` parse failed");
}
if (regexStr && regexStr.length > 4096) {
invalidParts.push("`source` exceeds max built length of 4096");
}
sourceTokens = tokens;
}
const hasSegments = new Set();
if (route.has) {
for (const hasItem of route.has){
if (!hasItem.value && hasItem.key) {
hasSegments.add(hasItem.key);
}
if (hasItem.value) {
for (const match of hasItem.value.matchAll(namedGroupsRegex)){
if (match[1]) {
hasSegments.add(match[1]);
}
}
if (hasItem.type === "host") {
hasSegments.add("host");
}
}
}
}
// make sure no unnamed patterns are attempted to be used in the
// destination as this can cause confusion and is not allowed
if (typeof route.destination === "string") {
if (route.destination.startsWith("/") && Array.isArray(sourceTokens)) {
const unnamedInDest = new Set();
for (const token of sourceTokens){
if (typeof token === "object" && typeof token.name === "number") {
const unnamedIndex = new RegExp(`:${token.name}(?!\\d)`);
if (route.destination.match(unnamedIndex)) {
unnamedInDest.add(`:${token.name}`);
}
}
}
if (unnamedInDest.size > 0) {
invalidParts.push(`\`destination\` has unnamed params ${[
...unnamedInDest
].join(", ")}`);
} else {
const { tokens: destTokens , regexStr: destRegexStr , error: destinationParseFailed , } = (0, _tryToParsePath).tryToParsePath(route.destination, {
handleUrl: true
});
if (destRegexStr && destRegexStr.length > 4096) {
invalidParts.push("`destination` exceeds max built length of 4096");
}
if (destinationParseFailed) {
invalidParts.push("`destination` parse failed");
} else {
const sourceSegments = new Set(sourceTokens.map((item)=>typeof item === "object" && item.name).filter(Boolean));
const invalidDestSegments = new Set();
for (const token of destTokens){
if (typeof token === "object" && !sourceSegments.has(token.name) && !hasSegments.has(token.name)) {
invalidDestSegments.add(token.name);
}
}
if (invalidDestSegments.size) {
invalidParts.push(`\`destination\` has segments not in \`source\` or \`has\` (${[
...invalidDestSegments,
].join(", ")})`);
}
}
}
}
}
const hasInvalidKeys = invalidKeys.length > 0;
const hasInvalidParts = invalidParts.length > 0;
if (hasInvalidKeys || hasInvalidParts) {
console.error(`${invalidParts.join(", ")}${invalidKeys.length ? (hasInvalidParts ? "," : "") + ` invalid field${invalidKeys.length === 1 ? "" : "s"}: ` + invalidKeys.join(",") : ""} for route ${JSON.stringify(route)}`);
console.error();
numInvalidRoutes++;
}
}
if (numInvalidRoutes > 0) {
if (hadInvalidStatus) {
console.error(`\nValid redirect statusCode values are ${[
..._redirectStatus.allowedStatusCodes
].join(", ")}`);
}
if (hadInvalidHas) {
console.error(`\nValid \`has\` object shape is ${JSON.stringify({
type: [
...allowedHasTypes
].join(", "),
key: "the key to check for",
value: "undefined or a value string to match against"
}, null, 2)}`);
}
if (hadInvalidMissing) {
console.error(`\nValid \`missing\` object shape is ${JSON.stringify({
type: [
...allowedHasTypes
].join(", "),
key: "the key to check for",
value: "undefined or a value string to match against"
}, null, 2)}`);
}
console.error();
console.error(`Error: Invalid ${type}${numInvalidRoutes === 1 ? "" : "s"} found`);
process.exit(1);
}
}
function processRoutes(routes, config, type) {
const _routes = routes;
const newRoutes = [];
const defaultLocales = [];
if (config.i18n && type === "redirect") {
var ref;
for (const item of ((ref = config.i18n) == null ? void 0 : ref.domains) || []){
defaultLocales.push({
locale: item.defaultLocale,
base: `http${item.http ? "" : "s"}://${item.domain}`
});
}
defaultLocales.push({
locale: config.i18n.defaultLocale,
base: ""
});
}
for (const r of _routes){
var ref1;
const srcBasePath = config.basePath && r.basePath !== false ? config.basePath : "";
const isExternal = !((ref1 = r.destination) == null ? void 0 : ref1.startsWith("/"));
const destBasePath = srcBasePath && !isExternal ? srcBasePath : "";
if (config.i18n && r.locale !== false) {
var ref2;
if (!isExternal) {
defaultLocales.forEach((item)=>{
let destination;
if (r.destination) {
destination = item.base ? `${item.base}${destBasePath}${r.destination}` : `${destBasePath}${r.destination}`;
}
newRoutes.push({
...r,
destination,
source: `${srcBasePath}/${item.locale}${r.source}`
});
});
}
r.source = `/:nextInternalLocale(${config.i18n.locales.map((locale)=>(0, _escapeRegexp).escapeStringRegexp(locale)).join("|")})${r.source === "/" && !config.trailingSlash ? "" : r.source}`;
if (r.destination && ((ref2 = r.destination) == null ? void 0 : ref2.startsWith("/"))) {
r.destination = `/:nextInternalLocale${r.destination === "/" && !config.trailingSlash ? "" : r.destination}`;
}
}
r.source = `${srcBasePath}${r.source === "/" && srcBasePath ? "" : r.source}`;
if (r.destination) {
r.destination = `${destBasePath}${r.destination === "/" && destBasePath ? "" : r.destination}`;
}
newRoutes.push(r);
}
return newRoutes;
}
async function loadRedirects(config) {
if (typeof config.redirects !== "function") {
return [];
}
let redirects = await config.redirects();
// check before we process the routes and after to ensure
// they are still valid
checkCustomRoutes(redirects, "redirect");
redirects = processRoutes(redirects, config, "redirect");
checkCustomRoutes(redirects, "redirect");
return redirects;
}
async function loadRewrites(config) {
if (typeof config.rewrites !== "function") {
return {
beforeFiles: [],
afterFiles: [],
fallback: []
};
}
const _rewrites = await config.rewrites();
let beforeFiles = [];
let afterFiles = [];
let fallback = [];
if (!Array.isArray(_rewrites) && typeof _rewrites === "object" && Object.keys(_rewrites).every((key)=>key === "beforeFiles" || key === "afterFiles" || key === "fallback")) {
beforeFiles = _rewrites.beforeFiles || [];
afterFiles = _rewrites.afterFiles || [];
fallback = _rewrites.fallback || [];
} else {
afterFiles = _rewrites;
}
// check before we process the routes and after to ensure
// they are still valid
checkCustomRoutes(beforeFiles, "rewrite");
checkCustomRoutes(afterFiles, "rewrite");
checkCustomRoutes(fallback, "rewrite");
beforeFiles = processRoutes(beforeFiles, config, "rewrite");
afterFiles = processRoutes(afterFiles, config, "rewrite");
fallback = processRoutes(fallback, config, "rewrite");
checkCustomRoutes(beforeFiles, "rewrite");
checkCustomRoutes(afterFiles, "rewrite");
checkCustomRoutes(fallback, "rewrite");
return {
beforeFiles,
afterFiles,
fallback
};
}
async function loadHeaders(config) {
if (typeof config.headers !== "function") {
return [];
}
let headers = await config.headers();
// check before we process the routes and after to ensure
// they are still valid
checkCustomRoutes(headers, "header");
headers = processRoutes(headers, config, "header");
checkCustomRoutes(headers, "header");
return headers;
}
//# sourceMappingURL=load-custom-routes.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export declare function nonNullable<T>(value: T): value is NonNullable<T>;

10
kitabcitab/node_modules/next/dist/lib/non-nullable.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.nonNullable = nonNullable;
function nonNullable(value) {
return value !== null && value !== undefined;
}
//# sourceMappingURL=non-nullable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../lib/non-nullable.ts"],"names":["nonNullable","value","undefined"],"mappings":"AAAA;;;;QAAgBA,WAAW,GAAXA,WAAW;AAApB,SAASA,WAAW,CAAIC,KAAQ,EAA2B;IAChE,OAAOA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,CAAA;CAC7C"}

View File

@@ -0,0 +1 @@
export declare function getOxfordCommaList(items: string[]): string;

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