feat: init
This commit is contained in:
8
node_modules/@vercel/nft/out/analyze.d.ts
generated
vendored
Normal file
8
node_modules/@vercel/nft/out/analyze.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Job } from './node-file-trace';
|
||||
export interface AnalyzeResult {
|
||||
assets: Set<string>;
|
||||
deps: Set<string>;
|
||||
imports: Set<string>;
|
||||
isESM: boolean;
|
||||
}
|
||||
export default function analyze(id: string, code: string, job: Job): Promise<AnalyzeResult>;
|
||||
1098
node_modules/@vercel/nft/out/analyze.js
generated
vendored
Normal file
1098
node_modules/@vercel/nft/out/analyze.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@vercel/nft/out/analyze.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/analyze.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@vercel/nft/out/cli.d.ts
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
94
node_modules/@vercel/nft/out/cli.js
generated
vendored
Executable file
94
node_modules/@vercel/nft/out/cli.js
generated
vendored
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = require("path");
|
||||
const graceful_fs_1 = require("graceful-fs");
|
||||
const { copyFile, mkdir, rm } = graceful_fs_1.promises;
|
||||
const node_file_trace_1 = require("./node-file-trace");
|
||||
function printStack(file, reasons, stdout, cwd) {
|
||||
stdout.push(file);
|
||||
const reason = reasons.get(file);
|
||||
if (!reason ||
|
||||
!reason.parents ||
|
||||
(reason.type.length === 1 &&
|
||||
reason.type.includes('initial') &&
|
||||
reason.parents.size === 0)) {
|
||||
return;
|
||||
}
|
||||
for (let parent of reason.parents) {
|
||||
printStack(parent, reasons, stdout, cwd);
|
||||
}
|
||||
}
|
||||
async function cli(action = process.argv[2], entrypoint = process.argv[3], exitpoint = process.argv[4], outputDir = 'dist', cwd = process.cwd()) {
|
||||
const opts = {
|
||||
ts: true,
|
||||
base: cwd,
|
||||
mixedModules: true,
|
||||
log: action == 'print' || action == 'build',
|
||||
};
|
||||
const { fileList, esmFileList, warnings, reasons } = await (0, node_file_trace_1.nodeFileTrace)([entrypoint], opts);
|
||||
const allFiles = [...fileList].concat([...esmFileList]).sort();
|
||||
const stdout = [];
|
||||
if (action === 'print') {
|
||||
stdout.push('FILELIST:');
|
||||
stdout.push(...allFiles);
|
||||
stdout.push('\n');
|
||||
if (warnings.size > 0) {
|
||||
stdout.push('WARNINGS:');
|
||||
for (var warning of warnings) {
|
||||
stdout.push(warning.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action === 'build') {
|
||||
await rm((0, path_1.join)(cwd, outputDir), { recursive: true, force: true });
|
||||
for (const f of allFiles) {
|
||||
const src = (0, path_1.join)(cwd, f);
|
||||
const dest = (0, path_1.join)(cwd, outputDir, f);
|
||||
const dir = (0, path_1.dirname)(dest);
|
||||
await mkdir(dir, { recursive: true });
|
||||
await copyFile(src, dest);
|
||||
}
|
||||
}
|
||||
else if (action === 'size') {
|
||||
const isSymbolicLink = (m) => (m & 61440) === 40960;
|
||||
let bytes = 0;
|
||||
for (const f of allFiles) {
|
||||
const lstat = (0, graceful_fs_1.lstatSync)(f);
|
||||
if (isSymbolicLink(lstat.mode)) {
|
||||
bytes += lstat.size;
|
||||
}
|
||||
else {
|
||||
const stat = (0, graceful_fs_1.statSync)(f);
|
||||
bytes += stat.size;
|
||||
}
|
||||
}
|
||||
stdout.push(`${bytes} bytes total`);
|
||||
}
|
||||
else if (action === 'why') {
|
||||
if (!exitpoint) {
|
||||
throw new Error('Expected additional argument for "why" action');
|
||||
}
|
||||
const normalizedExitPoint = ((0, path_1.isAbsolute)(exitpoint) ? (0, path_1.relative)(cwd, exitpoint) : exitpoint).replace(/[/\\]/g, path_1.sep);
|
||||
printStack(normalizedExitPoint, reasons, stdout, cwd);
|
||||
}
|
||||
else {
|
||||
stdout.push(`△ nft ${require('../package.json').version}`);
|
||||
stdout.push('');
|
||||
stdout.push('Usage:');
|
||||
stdout.push('');
|
||||
stdout.push(` $ nft [command] <file>`);
|
||||
stdout.push('');
|
||||
stdout.push('Commands:');
|
||||
stdout.push('');
|
||||
stdout.push(' build [entrypoint] trace and copy to the dist directory');
|
||||
stdout.push(' print [entrypoint] trace and print to stdout');
|
||||
stdout.push(' size [entrypoint] trace and print size in bytes');
|
||||
stdout.push(' why [entrypoint] [file] trace and print stack why file was included');
|
||||
}
|
||||
return stdout.join('\n');
|
||||
}
|
||||
if (require.main === module) {
|
||||
cli().then(console.log).catch(console.error);
|
||||
}
|
||||
module.exports = cli;
|
||||
1
node_modules/@vercel/nft/out/cli.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/cli.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"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"}
|
||||
22
node_modules/@vercel/nft/out/fs.d.ts
generated
vendored
Normal file
22
node_modules/@vercel/nft/out/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { Stats } from 'fs';
|
||||
export declare class CachedFileSystem {
|
||||
private fileCache;
|
||||
private statCache;
|
||||
private symlinkCache;
|
||||
private fileIOQueue;
|
||||
constructor({ cache, fileIOConcurrency, }: {
|
||||
cache?: {
|
||||
fileCache?: Map<string, Promise<string | null>>;
|
||||
statCache?: Map<string, Promise<Stats | null>>;
|
||||
symlinkCache?: Map<string, Promise<string | null>>;
|
||||
};
|
||||
fileIOConcurrency: number;
|
||||
});
|
||||
readlink(path: string): Promise<string | null>;
|
||||
readFile(path: string): Promise<string | null>;
|
||||
stat(path: string): Promise<Stats | null>;
|
||||
private _internalReadlink;
|
||||
private _internalReadFile;
|
||||
private _internalStat;
|
||||
private executeFileIO;
|
||||
}
|
||||
106
node_modules/@vercel/nft/out/fs.js
generated
vendored
Normal file
106
node_modules/@vercel/nft/out/fs.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CachedFileSystem = void 0;
|
||||
const path_1 = require("path");
|
||||
const graceful_fs_1 = __importDefault(require("graceful-fs"));
|
||||
const async_sema_1 = require("async-sema");
|
||||
const fsReadFile = graceful_fs_1.default.promises.readFile;
|
||||
const fsReadlink = graceful_fs_1.default.promises.readlink;
|
||||
const fsStat = graceful_fs_1.default.promises.stat;
|
||||
class CachedFileSystem {
|
||||
fileCache;
|
||||
statCache;
|
||||
symlinkCache;
|
||||
fileIOQueue;
|
||||
constructor({ cache, fileIOConcurrency, }) {
|
||||
this.fileIOQueue = new async_sema_1.Sema(fileIOConcurrency);
|
||||
this.fileCache = cache?.fileCache ?? new Map();
|
||||
this.statCache = cache?.statCache ?? new Map();
|
||||
this.symlinkCache = cache?.symlinkCache ?? new Map();
|
||||
if (cache) {
|
||||
cache.fileCache = this.fileCache;
|
||||
cache.statCache = this.statCache;
|
||||
cache.symlinkCache = this.symlinkCache;
|
||||
}
|
||||
}
|
||||
async readlink(path) {
|
||||
const cached = this.symlinkCache.get(path);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
// This is not awaiting the response, so that the cache is instantly populated and
|
||||
// future calls serve the Promise from the cache
|
||||
const readlinkPromise = this.executeFileIO(path, this._internalReadlink);
|
||||
this.symlinkCache.set(path, readlinkPromise);
|
||||
return readlinkPromise;
|
||||
}
|
||||
async readFile(path) {
|
||||
const cached = this.fileCache.get(path);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
// This is not awaiting the response, so that the cache is instantly populated and
|
||||
// future calls serve the Promise from the cache
|
||||
const readFilePromise = this.executeFileIO(path, this._internalReadFile);
|
||||
this.fileCache.set(path, readFilePromise);
|
||||
return readFilePromise;
|
||||
}
|
||||
async stat(path) {
|
||||
const cached = this.statCache.get(path);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
// This is not awaiting the response, so that the cache is instantly populated and
|
||||
// future calls serve the Promise from the cache
|
||||
const statPromise = this.executeFileIO(path, this._internalStat);
|
||||
this.statCache.set(path, statPromise);
|
||||
return statPromise;
|
||||
}
|
||||
async _internalReadlink(path) {
|
||||
try {
|
||||
const link = await fsReadlink(path);
|
||||
// also copy stat cache to symlink
|
||||
const stats = this.statCache.get(path);
|
||||
if (stats)
|
||||
this.statCache.set((0, path_1.resolve)(path, link), stats);
|
||||
return link;
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== 'EINVAL' && e.code !== 'ENOENT' && e.code !== 'UNKNOWN')
|
||||
throw e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async _internalReadFile(path) {
|
||||
try {
|
||||
return (await fsReadFile(path)).toString();
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === 'ENOENT' || e.code === 'EISDIR') {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async _internalStat(path) {
|
||||
try {
|
||||
return await fsStat(path);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async executeFileIO(path, fileIO) {
|
||||
await this.fileIOQueue.acquire();
|
||||
try {
|
||||
return fileIO.call(this, path);
|
||||
}
|
||||
finally {
|
||||
this.fileIOQueue.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CachedFileSystem = CachedFileSystem;
|
||||
1
node_modules/@vercel/nft/out/fs.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/fs.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"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"}
|
||||
4
node_modules/@vercel/nft/out/index.d.ts
generated
vendored
Normal file
4
node_modules/@vercel/nft/out/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './types';
|
||||
export { nodeFileTrace } from './node-file-trace';
|
||||
import resolveDependency from './resolve-dependency';
|
||||
export { resolveDependency as resolve };
|
||||
25
node_modules/@vercel/nft/out/index.js
generated
vendored
Normal file
25
node_modules/@vercel/nft/out/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolve = exports.nodeFileTrace = void 0;
|
||||
__exportStar(require("./types"), exports);
|
||||
var node_file_trace_1 = require("./node-file-trace");
|
||||
Object.defineProperty(exports, "nodeFileTrace", { enumerable: true, get: function () { return node_file_trace_1.nodeFileTrace; } });
|
||||
const resolve_dependency_1 = __importDefault(require("./resolve-dependency"));
|
||||
exports.resolve = resolve_dependency_1.default;
|
||||
1
node_modules/@vercel/nft/out/index.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,8EAAqD;AACvB,kBADvB,4BAAiB,CACa"}
|
||||
40
node_modules/@vercel/nft/out/node-file-trace.d.ts
generated
vendored
Normal file
40
node_modules/@vercel/nft/out/node-file-trace.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { NodeFileTraceOptions, NodeFileTraceResult, NodeFileTraceReasons, NodeFileTraceReasonType } from './types';
|
||||
export declare function nodeFileTrace(files: string[], opts?: NodeFileTraceOptions): Promise<NodeFileTraceResult>;
|
||||
export declare class Job {
|
||||
ts: boolean;
|
||||
base: string;
|
||||
cwd: string;
|
||||
conditions: string[];
|
||||
exportsOnly: boolean;
|
||||
paths: Record<string, string>;
|
||||
ignoreFn: (path: string, parent?: string) => boolean;
|
||||
log: boolean;
|
||||
depth: number;
|
||||
mixedModules: boolean;
|
||||
analysis: {
|
||||
emitGlobs?: boolean;
|
||||
computeFileReferences?: boolean;
|
||||
evaluatePureExpressions?: boolean;
|
||||
};
|
||||
private analysisCache;
|
||||
fileList: Set<string>;
|
||||
esmFileList: Set<string>;
|
||||
processed: Set<string>;
|
||||
warnings: Set<Error>;
|
||||
reasons: NodeFileTraceReasons;
|
||||
private cachedFileSystem;
|
||||
private remappings;
|
||||
constructor({ base, processCwd, exports, conditions, exportsOnly, paths, ignore, log, mixedModules, ts, analysis, cache, fileIOConcurrency, depth, }: NodeFileTraceOptions);
|
||||
addRemapping(path: string, dep: string): void;
|
||||
readlink(path: string): Promise<string | null>;
|
||||
isFile(path: string): Promise<boolean>;
|
||||
isDir(path: string): Promise<boolean>;
|
||||
stat(path: string): Promise<import("fs").Stats | null>;
|
||||
private maybeEmitDep;
|
||||
resolve(id: string, parent: string, job: Job, cjsResolve: boolean): Promise<string | string[]>;
|
||||
readFile(path: string): Promise<Buffer | string | null>;
|
||||
realpath(path: string, parent?: string, seen?: Set<unknown>): Promise<string>;
|
||||
emitFile(path: string, reasonType: NodeFileTraceReasonType, parent?: string, isRealpath?: boolean): Promise<boolean>;
|
||||
getPjsonBoundary(path: string): Promise<string | undefined>;
|
||||
emitDependency(path: string, parent?: string, depth?: number): Promise<void>;
|
||||
}
|
||||
378
node_modules/@vercel/nft/out/node-file-trace.js
generated
vendored
Normal file
378
node_modules/@vercel/nft/out/node-file-trace.js
generated
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Job = void 0;
|
||||
exports.nodeFileTrace = nodeFileTrace;
|
||||
const path_1 = require("path");
|
||||
const analyze_1 = __importDefault(require("./analyze"));
|
||||
const resolve_dependency_1 = __importStar(require("./resolve-dependency"));
|
||||
const picomatch_1 = require("picomatch");
|
||||
const sharedlib_emit_1 = require("./utils/sharedlib-emit");
|
||||
const fs_1 = require("./fs");
|
||||
function inPath(path, parent) {
|
||||
const pathWithSep = (0, path_1.join)(parent, path_1.sep);
|
||||
return path.startsWith(pathWithSep) && path !== pathWithSep;
|
||||
}
|
||||
async function nodeFileTrace(files, opts = {}) {
|
||||
const job = new Job(opts);
|
||||
if (opts.readFile)
|
||||
job.readFile = opts.readFile;
|
||||
if (opts.stat)
|
||||
job.stat = opts.stat;
|
||||
if (opts.readlink)
|
||||
job.readlink = opts.readlink;
|
||||
if (opts.resolve)
|
||||
job.resolve = opts.resolve;
|
||||
job.ts = true;
|
||||
await Promise.all(files.map(async (file) => {
|
||||
const path = (0, path_1.resolve)(file);
|
||||
await job.emitFile(path, 'initial');
|
||||
return job.emitDependency(path);
|
||||
}));
|
||||
const result = {
|
||||
fileList: job.fileList,
|
||||
esmFileList: job.esmFileList,
|
||||
reasons: job.reasons,
|
||||
warnings: job.warnings,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
class Job {
|
||||
ts;
|
||||
base;
|
||||
cwd;
|
||||
conditions;
|
||||
exportsOnly;
|
||||
paths;
|
||||
ignoreFn;
|
||||
log;
|
||||
depth;
|
||||
mixedModules;
|
||||
analysis;
|
||||
analysisCache;
|
||||
fileList;
|
||||
esmFileList;
|
||||
processed;
|
||||
warnings;
|
||||
reasons = new Map();
|
||||
cachedFileSystem;
|
||||
remappings = new Map();
|
||||
constructor({ base = process.cwd(), processCwd, exports, conditions = exports || ['node'], exportsOnly = false, paths = {}, ignore, log = false, mixedModules = false, ts = true, analysis = {}, cache,
|
||||
// we use a default of 1024 concurrency to balance
|
||||
// performance and memory usage for fs operations
|
||||
fileIOConcurrency = 1024, depth = Infinity, }) {
|
||||
this.ts = ts;
|
||||
base = (0, path_1.resolve)(base);
|
||||
this.ignoreFn = (path) => {
|
||||
if (path.startsWith('..' + path_1.sep))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
if (typeof ignore === 'string')
|
||||
ignore = [ignore];
|
||||
if (typeof ignore === 'function') {
|
||||
const ig = ignore;
|
||||
this.ignoreFn = (path) => {
|
||||
if (path.startsWith('..' + path_1.sep))
|
||||
return true;
|
||||
if (ig(path))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
else if (Array.isArray(ignore)) {
|
||||
const resolvedIgnores = ignore.map((ignore) => (0, path_1.relative)(base, (0, path_1.resolve)(base || process.cwd(), ignore)));
|
||||
this.ignoreFn = (path) => {
|
||||
if (path.startsWith('..' + path_1.sep))
|
||||
return true;
|
||||
if ((0, picomatch_1.isMatch)(path, resolvedIgnores))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
this.base = base;
|
||||
this.cwd = (0, path_1.resolve)(processCwd || base);
|
||||
this.conditions = conditions;
|
||||
this.exportsOnly = exportsOnly;
|
||||
const resolvedPaths = {};
|
||||
for (const path of Object.keys(paths)) {
|
||||
const trailer = paths[path].endsWith('/');
|
||||
const resolvedPath = (0, path_1.resolve)(base, paths[path]);
|
||||
resolvedPaths[path] = resolvedPath + (trailer ? '/' : '');
|
||||
}
|
||||
this.paths = resolvedPaths;
|
||||
this.log = log;
|
||||
this.depth = depth;
|
||||
this.mixedModules = mixedModules;
|
||||
this.cachedFileSystem = new fs_1.CachedFileSystem({ cache, fileIOConcurrency });
|
||||
this.analysis = {};
|
||||
if (analysis !== false) {
|
||||
Object.assign(this.analysis, {
|
||||
// whether to glob any analysis like __dirname + '/dir/' or require('x/' + y)
|
||||
// that might output any file in a directory
|
||||
emitGlobs: true,
|
||||
// whether __filename and __dirname style
|
||||
// expressions should be analyzed as file references
|
||||
computeFileReferences: true,
|
||||
// evaluate known bindings to assist with glob and file reference analysis
|
||||
evaluatePureExpressions: true,
|
||||
}, analysis === true ? {} : analysis);
|
||||
}
|
||||
this.analysisCache = (cache && cache.analysisCache) || new Map();
|
||||
if (cache) {
|
||||
cache.analysisCache = this.analysisCache;
|
||||
}
|
||||
this.fileList = new Set();
|
||||
this.esmFileList = new Set();
|
||||
this.processed = new Set();
|
||||
this.warnings = new Set();
|
||||
}
|
||||
addRemapping(path, dep) {
|
||||
if (path === dep)
|
||||
return;
|
||||
let deps = this.remappings.get(path);
|
||||
if (!deps) {
|
||||
deps = new Set();
|
||||
this.remappings.set(path, deps);
|
||||
}
|
||||
deps.add(dep);
|
||||
}
|
||||
async readlink(path) {
|
||||
return this.cachedFileSystem.readlink(path);
|
||||
}
|
||||
async isFile(path) {
|
||||
const stats = await this.stat(path);
|
||||
if (stats)
|
||||
return stats.isFile();
|
||||
return false;
|
||||
}
|
||||
async isDir(path) {
|
||||
const stats = await this.stat(path);
|
||||
if (stats)
|
||||
return stats.isDirectory();
|
||||
return false;
|
||||
}
|
||||
async stat(path) {
|
||||
return this.cachedFileSystem.stat(path);
|
||||
}
|
||||
maybeEmitDep = async (dep, path, cjsResolve, depth) => {
|
||||
let resolved = '';
|
||||
let error;
|
||||
try {
|
||||
resolved = await this.resolve(dep, path, this, cjsResolve);
|
||||
}
|
||||
catch (e1) {
|
||||
error = e1;
|
||||
try {
|
||||
if (this.ts && dep.endsWith('.js') && e1 instanceof resolve_dependency_1.NotFoundError) {
|
||||
// TS with ESM relative import paths need full extensions
|
||||
// (we have to write import "./foo.js" instead of import "./foo")
|
||||
// See https://www.typescriptlang.org/docs/handbook/esm-node.html
|
||||
const depTS = dep.slice(0, -3) + '.ts';
|
||||
resolved = await this.resolve(depTS, path, this, cjsResolve);
|
||||
error = undefined;
|
||||
}
|
||||
}
|
||||
catch (e2) {
|
||||
error = e2;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
this.warnings.add(new Error(`Failed to resolve dependency "${dep}":\n${error?.message}`));
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(resolved)) {
|
||||
for (const item of resolved) {
|
||||
// ignore builtins
|
||||
if (item.startsWith('node:'))
|
||||
return;
|
||||
await this.emitDependency(item, path, depth);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ignore builtins
|
||||
if (resolved.startsWith('node:'))
|
||||
return;
|
||||
await this.emitDependency(resolved, path, depth);
|
||||
}
|
||||
};
|
||||
async resolve(id, parent, job, cjsResolve) {
|
||||
return (0, resolve_dependency_1.default)(id, parent, job, cjsResolve);
|
||||
}
|
||||
async readFile(path) {
|
||||
return this.cachedFileSystem.readFile(path);
|
||||
}
|
||||
async realpath(path, parent, seen = new Set()) {
|
||||
if (seen.has(path))
|
||||
throw new Error('Recursive symlink detected resolving ' + path);
|
||||
seen.add(path);
|
||||
const symlink = await this.readlink(path);
|
||||
// emit direct symlink paths only
|
||||
if (symlink) {
|
||||
const parentPath = (0, path_1.dirname)(path);
|
||||
const resolved = (0, path_1.resolve)(parentPath, symlink);
|
||||
const realParent = await this.realpath(parentPath, parent);
|
||||
if (inPath(path, realParent))
|
||||
await this.emitFile(path, 'resolve', parent, true);
|
||||
return this.realpath(resolved, parent, seen);
|
||||
}
|
||||
// keep backtracking for realpath, emitting folder symlinks within base
|
||||
if (!inPath(path, this.base))
|
||||
return path;
|
||||
return (0, path_1.join)(await this.realpath((0, path_1.dirname)(path), parent, seen), (0, path_1.basename)(path));
|
||||
}
|
||||
async emitFile(path, reasonType, parent, isRealpath = false) {
|
||||
if (!isRealpath) {
|
||||
path = await this.realpath(path, parent);
|
||||
}
|
||||
path = (0, path_1.relative)(this.base, path);
|
||||
if (parent) {
|
||||
parent = (0, path_1.relative)(this.base, parent);
|
||||
}
|
||||
let reasonEntry = this.reasons.get(path);
|
||||
if (!reasonEntry) {
|
||||
reasonEntry = {
|
||||
type: [reasonType],
|
||||
ignored: false,
|
||||
parents: new Set(),
|
||||
};
|
||||
this.reasons.set(path, reasonEntry);
|
||||
}
|
||||
else if (!reasonEntry.type.includes(reasonType)) {
|
||||
reasonEntry.type.push(reasonType);
|
||||
}
|
||||
if (parent && this.ignoreFn(path, parent)) {
|
||||
if (!this.fileList.has(path) && reasonEntry) {
|
||||
reasonEntry.ignored = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (parent) {
|
||||
reasonEntry.parents.add(parent);
|
||||
}
|
||||
this.fileList.add(path);
|
||||
return true;
|
||||
}
|
||||
async getPjsonBoundary(path) {
|
||||
const rootSeparatorIndex = path.indexOf(path_1.sep);
|
||||
let separatorIndex;
|
||||
while ((separatorIndex = path.lastIndexOf(path_1.sep)) > rootSeparatorIndex) {
|
||||
path = path.slice(0, separatorIndex);
|
||||
if (await this.isFile(path + path_1.sep + 'package.json'))
|
||||
return path;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async emitDependency(path, parent, depth = this.depth) {
|
||||
if (depth < 0)
|
||||
throw new Error('invariant - depth option cannot be negative');
|
||||
// Resolve symlinks so that dependencies are resolved relative to the real
|
||||
// file location, not the symlink location
|
||||
const realPath = await this.realpath(path, parent);
|
||||
if (this.processed.has(realPath)) {
|
||||
if (parent) {
|
||||
await this.emitFile(path, 'dependency', parent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.processed.add(realPath);
|
||||
// Additional dependencies.
|
||||
const additionalDeps = this.remappings.get(realPath);
|
||||
if (additionalDeps) {
|
||||
await Promise.all([...additionalDeps].map(async (dep) => this.emitDependency(dep, realPath, depth)));
|
||||
}
|
||||
const emitted = await this.emitFile(path, 'dependency', parent);
|
||||
if (!emitted)
|
||||
return;
|
||||
if (realPath.endsWith('.json'))
|
||||
return;
|
||||
if (realPath.endsWith('.node'))
|
||||
return await (0, sharedlib_emit_1.sharedLibEmit)(realPath, this);
|
||||
// .js and .ts files can change behavior based on { "type": "module" }
|
||||
// in the nearest package.json so we must emit it too. We don't need to
|
||||
// emit for .cjs/.mjs/.cts/.mts files since their behavior does not
|
||||
// depend on package.json
|
||||
if (realPath.endsWith('.js') || realPath.endsWith('.ts')) {
|
||||
const pjsonBoundary = await this.getPjsonBoundary(realPath);
|
||||
if (pjsonBoundary)
|
||||
await this.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', realPath);
|
||||
}
|
||||
if (depth === 0)
|
||||
return;
|
||||
let analyzeResult;
|
||||
const cachedAnalysis = this.analysisCache.get(realPath);
|
||||
if (cachedAnalysis) {
|
||||
analyzeResult = cachedAnalysis;
|
||||
}
|
||||
else {
|
||||
const source = await this.readFile(realPath);
|
||||
if (source === null)
|
||||
throw new Error('File ' + realPath + ' does not exist.');
|
||||
// analyze should not have any side-effects e.g. calling `job.emitFile`
|
||||
// directly as this will not be included in the cachedAnalysis and won't
|
||||
// be emit for successive runs that leverage the cache
|
||||
analyzeResult = await (0, analyze_1.default)(realPath, source.toString(), this);
|
||||
this.analysisCache.set(realPath, analyzeResult);
|
||||
}
|
||||
const { deps, imports, assets, isESM } = analyzeResult;
|
||||
if (isESM) {
|
||||
this.esmFileList.add((0, path_1.relative)(this.base, realPath));
|
||||
}
|
||||
await Promise.all([
|
||||
...[...assets].map(async (asset) => {
|
||||
const ext = (0, path_1.extname)(asset);
|
||||
if (ext === '.js' ||
|
||||
ext === '.mjs' ||
|
||||
ext === '.node' ||
|
||||
ext === '' ||
|
||||
(this.ts &&
|
||||
(ext === '.ts' || ext === '.tsx') &&
|
||||
asset.startsWith(this.base) &&
|
||||
asset
|
||||
.slice(this.base.length)
|
||||
.indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1))
|
||||
await this.emitDependency(asset, realPath, depth - 1);
|
||||
else
|
||||
await this.emitFile(asset, 'asset', realPath);
|
||||
}),
|
||||
...[...deps].map(async (dep) => this.maybeEmitDep(dep, realPath, !isESM, depth - 1)),
|
||||
...[...imports].map(async (dep) => this.maybeEmitDep(dep, realPath, false, depth - 1)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
exports.Job = Job;
|
||||
1
node_modules/@vercel/nft/out/node-file-trace.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/node-file-trace.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/@vercel/nft/out/resolve-dependency.d.ts
generated
vendored
Normal file
6
node_modules/@vercel/nft/out/resolve-dependency.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Job } from './node-file-trace';
|
||||
export default function resolveDependency(specifier: string, parent: string, job: Job, cjsResolve?: boolean): Promise<string | string[]>;
|
||||
export declare class NotFoundError extends Error {
|
||||
code: string;
|
||||
constructor(specifier: string, parent: string);
|
||||
}
|
||||
359
node_modules/@vercel/nft/out/resolve-dependency.js
generated
vendored
Normal file
359
node_modules/@vercel/nft/out/resolve-dependency.js
generated
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NotFoundError = void 0;
|
||||
exports.default = resolveDependency;
|
||||
const path_1 = require("path");
|
||||
const module_1 = require("module");
|
||||
const node_version_1 = require("./utils/node-version");
|
||||
// node resolver
|
||||
// custom implementation to emit only needed package.json files for resolver
|
||||
// (package.json files are emitted as they are hit)
|
||||
async function resolveDependency(specifier, parent, job, cjsResolve = true) {
|
||||
let resolved;
|
||||
if ((0, path_1.isAbsolute)(specifier) ||
|
||||
specifier === '.' ||
|
||||
specifier === '..' ||
|
||||
specifier.startsWith('./') ||
|
||||
specifier.startsWith('../')) {
|
||||
const trailingSlash = specifier.endsWith('/');
|
||||
resolved = await resolvePath((0, path_1.resolve)(parent, '..', specifier) + (trailingSlash ? '/' : ''), parent, job);
|
||||
}
|
||||
else if (specifier[0] === '#') {
|
||||
resolved = await packageImportsResolve(specifier, parent, job, cjsResolve);
|
||||
}
|
||||
else {
|
||||
resolved = await resolvePackage(specifier, parent, job, cjsResolve);
|
||||
}
|
||||
if (Array.isArray(resolved)) {
|
||||
return Promise.all(resolved.map((resolved) => job.realpath(resolved, parent)));
|
||||
}
|
||||
else if (resolved.startsWith('node:')) {
|
||||
return resolved;
|
||||
}
|
||||
else {
|
||||
return job.realpath(resolved, parent);
|
||||
}
|
||||
}
|
||||
async function resolvePath(path, parent, job) {
|
||||
const result = (await resolveFile(path, parent, job)) ||
|
||||
(await resolveDir(path, parent, job));
|
||||
if (!result) {
|
||||
throw new NotFoundError(path, parent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async function resolveFile(path, parent, job) {
|
||||
if (path.endsWith('/'))
|
||||
return undefined;
|
||||
path = await job.realpath(path, parent);
|
||||
if (await job.isFile(path))
|
||||
return path;
|
||||
if (job.ts &&
|
||||
path.startsWith(job.base) &&
|
||||
path.slice(job.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1 &&
|
||||
(await job.isFile(path + '.ts')))
|
||||
return path + '.ts';
|
||||
if (job.ts &&
|
||||
path.startsWith(job.base) &&
|
||||
path.slice(job.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1 &&
|
||||
(await job.isFile(path + '.tsx')))
|
||||
return path + '.tsx';
|
||||
if (await job.isFile(path + '.js'))
|
||||
return path + '.js';
|
||||
if (await job.isFile(path + '.json'))
|
||||
return path + '.json';
|
||||
if (await job.isFile(path + '.node'))
|
||||
return path + '.node';
|
||||
return undefined;
|
||||
}
|
||||
async function resolveDir(path, parent, job) {
|
||||
if (path.endsWith('/'))
|
||||
path = path.slice(0, -1);
|
||||
if (!(await job.isDir(path)))
|
||||
return;
|
||||
const pkgCfg = await getPkgCfg(path, job);
|
||||
if (pkgCfg && typeof pkgCfg.main === 'string') {
|
||||
const resolved = (await resolveFile((0, path_1.resolve)(path, pkgCfg.main), parent, job)) ||
|
||||
(await resolveFile((0, path_1.resolve)(path, pkgCfg.main, 'index'), parent, job));
|
||||
if (resolved) {
|
||||
await job.emitFile(path + path_1.sep + 'package.json', 'resolve', parent);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
return resolveFile((0, path_1.resolve)(path, 'index'), parent, job);
|
||||
}
|
||||
class NotFoundError extends Error {
|
||||
code;
|
||||
constructor(specifier, parent) {
|
||||
super("Cannot find module '" + specifier + "' loaded from " + parent);
|
||||
this.code = 'MODULE_NOT_FOUND';
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
const nodeBuiltins = new Set(module_1.builtinModules);
|
||||
function getPkgName(name) {
|
||||
const segments = name.split('/');
|
||||
if (name[0] === '@' && segments.length > 1)
|
||||
return segments.length > 1 ? segments.slice(0, 2).join('/') : null;
|
||||
return segments.length ? segments[0] : null;
|
||||
}
|
||||
async function getPkgCfg(pkgPath, job) {
|
||||
const pjsonSource = await job.readFile(pkgPath + path_1.sep + 'package.json');
|
||||
if (pjsonSource) {
|
||||
try {
|
||||
return JSON.parse(pjsonSource.toString());
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getExportsTarget(exports, conditions, cjsResolve) {
|
||||
if (typeof exports === 'string') {
|
||||
return exports;
|
||||
}
|
||||
else if (exports === null) {
|
||||
return exports;
|
||||
}
|
||||
else if (Array.isArray(exports)) {
|
||||
for (const item of exports) {
|
||||
const target = getExportsTarget(item, conditions, cjsResolve);
|
||||
if (target === null ||
|
||||
(typeof target === 'string' && target.startsWith('./')))
|
||||
return target;
|
||||
}
|
||||
}
|
||||
else if (typeof exports === 'object') {
|
||||
for (const condition of Object.keys(exports)) {
|
||||
if (condition === 'default' ||
|
||||
(condition === 'require' && cjsResolve) ||
|
||||
(condition === 'import' && !cjsResolve) ||
|
||||
(condition === 'module-sync' && (0, node_version_1.getNodeMajorVersion)() >= 22) ||
|
||||
conditions.includes(condition)) {
|
||||
const target = getExportsTarget(exports[condition], conditions, cjsResolve);
|
||||
if (target !== undefined)
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async function validateAndResolvePaths(paths, parent, job, cjsResolve) {
|
||||
const validatedPaths = [];
|
||||
for (const path of paths) {
|
||||
if (cjsResolve) {
|
||||
const resolved = (await resolveFile(path, parent, job)) ||
|
||||
(await resolveDir(path, parent, job));
|
||||
if (!resolved)
|
||||
throw new NotFoundError(path, parent);
|
||||
validatedPaths.push(resolved);
|
||||
}
|
||||
else {
|
||||
if (!(await job.isFile(path)))
|
||||
throw new NotFoundError(path, parent);
|
||||
validatedPaths.push(path);
|
||||
}
|
||||
}
|
||||
return validatedPaths;
|
||||
}
|
||||
async function resolveExportsImports(pkgPath, obj, subpath, job, isImports, cjsResolve, parent) {
|
||||
let matchObj;
|
||||
if (isImports) {
|
||||
if (!(typeof obj === 'object' && !Array.isArray(obj) && obj !== null))
|
||||
return undefined;
|
||||
matchObj = obj;
|
||||
}
|
||||
else if (typeof obj === 'string' ||
|
||||
Array.isArray(obj) ||
|
||||
obj === null ||
|
||||
(typeof obj === 'object' &&
|
||||
Object.keys(obj).length &&
|
||||
Object.keys(obj)[0][0] !== '.')) {
|
||||
matchObj = { '.': obj };
|
||||
}
|
||||
else {
|
||||
matchObj = obj;
|
||||
}
|
||||
if (subpath in matchObj) {
|
||||
const target = getExportsTarget(matchObj[subpath], job.conditions, cjsResolve);
|
||||
if (typeof target === 'string' && target.startsWith('./')) {
|
||||
const resolvedPath = pkgPath + target.slice(1);
|
||||
const paths = [resolvedPath];
|
||||
const exportsForSubpath = matchObj[subpath];
|
||||
if (typeof exportsForSubpath === 'object' &&
|
||||
exportsForSubpath !== null &&
|
||||
!Array.isArray(exportsForSubpath) &&
|
||||
'module-sync' in exportsForSubpath &&
|
||||
(0, node_version_1.getNodeMajorVersion)() >= 22) {
|
||||
const fallbackCondition = 'require' in exportsForSubpath ? 'require' : 'default';
|
||||
const fallbackTarget = getExportsTarget(exportsForSubpath[fallbackCondition], job.conditions, cjsResolve);
|
||||
if (typeof fallbackTarget === 'string' &&
|
||||
fallbackTarget.startsWith('./')) {
|
||||
const fallbackPath = pkgPath + fallbackTarget.slice(1);
|
||||
if (fallbackPath !== resolvedPath) {
|
||||
paths.push(fallbackPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return await validateAndResolvePaths(paths, parent, job, cjsResolve);
|
||||
}
|
||||
}
|
||||
for (const match of Object.keys(matchObj).sort((a, b) => b.length - a.length)) {
|
||||
if (match.endsWith('*') && subpath.startsWith(match.slice(0, -1))) {
|
||||
const target = getExportsTarget(matchObj[match], job.conditions, cjsResolve);
|
||||
if (typeof target === 'string' && target.startsWith('./')) {
|
||||
const resolvedPath = pkgPath +
|
||||
target.slice(1).replace(/\*/g, subpath.slice(match.length - 1));
|
||||
return await validateAndResolvePaths([resolvedPath], parent, job, cjsResolve);
|
||||
}
|
||||
}
|
||||
if (!match.endsWith('/'))
|
||||
continue;
|
||||
if (subpath.startsWith(match)) {
|
||||
const target = getExportsTarget(matchObj[match], job.conditions, cjsResolve);
|
||||
if (typeof target === 'string' &&
|
||||
target.endsWith('/') &&
|
||||
target.startsWith('./')) {
|
||||
const resolvedPath = pkgPath + target.slice(1) + subpath.slice(match.length);
|
||||
return await validateAndResolvePaths([resolvedPath], parent, job, cjsResolve);
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async function resolveRemappings(pkgPath, pkgCfg, parent, job) {
|
||||
if (job.conditions?.includes('browser')) {
|
||||
const { browser: pkgBrowser } = pkgCfg;
|
||||
if (!pkgBrowser) {
|
||||
return;
|
||||
}
|
||||
if (typeof pkgBrowser === 'object') {
|
||||
for (const [key, value] of Object.entries(pkgBrowser)) {
|
||||
if (typeof value !== 'string') {
|
||||
/**
|
||||
* `false` can be used to specify that a file is not meant to be included.
|
||||
* Downstream processing is expected to handle this case, and it should remain in the mapping result
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
if (!key.startsWith('./') || !value.startsWith('./')) {
|
||||
continue;
|
||||
}
|
||||
const keyResolved = await resolveFile(pkgPath + path_1.sep + key, parent, job);
|
||||
const valueResolved = await resolveFile(pkgPath + path_1.sep + value, parent, job);
|
||||
if (keyResolved && valueResolved) {
|
||||
job.addRemapping(keyResolved, valueResolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async function packageImportsResolve(name, parent, job, cjsResolve) {
|
||||
if (name !== '#' && !name.startsWith('#/') && job.conditions) {
|
||||
const pjsonBoundary = await job.getPjsonBoundary(parent);
|
||||
if (pjsonBoundary) {
|
||||
const pkgCfg = await getPkgCfg(pjsonBoundary, job);
|
||||
const { imports: pkgImports } = pkgCfg || {};
|
||||
if (pkgCfg && pkgImports !== null && pkgImports !== undefined) {
|
||||
const importsResolved = await resolveExportsImports(pjsonBoundary, pkgImports, name, job, true, cjsResolve, parent);
|
||||
if (importsResolved) {
|
||||
await job.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', parent);
|
||||
return importsResolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new NotFoundError(name, parent);
|
||||
}
|
||||
async function resolvePackage(name, parent, job, cjsResolve) {
|
||||
let packageParent = parent;
|
||||
if (nodeBuiltins.has(name))
|
||||
return 'node:' + name;
|
||||
if (name.startsWith('node:'))
|
||||
return name;
|
||||
const pkgName = getPkgName(name) || '';
|
||||
// package own name resolution
|
||||
let selfResolved;
|
||||
if (job.conditions) {
|
||||
const pjsonBoundary = await job.getPjsonBoundary(parent);
|
||||
if (pjsonBoundary) {
|
||||
const pkgCfg = await getPkgCfg(pjsonBoundary, job);
|
||||
const { exports: pkgExports } = pkgCfg || {};
|
||||
if (pkgCfg &&
|
||||
pkgCfg.name &&
|
||||
pkgCfg.name === pkgName &&
|
||||
pkgExports !== null &&
|
||||
pkgExports !== undefined) {
|
||||
selfResolved = await resolveExportsImports(pjsonBoundary, pkgExports, '.' + name.slice(pkgName.length), job, false, cjsResolve, parent);
|
||||
if (selfResolved)
|
||||
await job.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
let separatorIndex;
|
||||
const rootSeparatorIndex = packageParent.indexOf(path_1.sep);
|
||||
while ((separatorIndex = packageParent.lastIndexOf(path_1.sep)) > rootSeparatorIndex) {
|
||||
packageParent = packageParent.slice(0, separatorIndex);
|
||||
const nodeModulesDir = packageParent + path_1.sep + 'node_modules';
|
||||
const stat = await job.stat(nodeModulesDir);
|
||||
if (!stat || !stat.isDirectory())
|
||||
continue;
|
||||
const pkgCfg = await getPkgCfg(nodeModulesDir + path_1.sep + pkgName, job);
|
||||
const { exports: pkgExports } = pkgCfg || {};
|
||||
if (pkgCfg) {
|
||||
await resolveRemappings(nodeModulesDir + path_1.sep + pkgName, pkgCfg, parent, job);
|
||||
}
|
||||
if (job.conditions &&
|
||||
pkgExports !== undefined &&
|
||||
pkgExports !== null &&
|
||||
!selfResolved) {
|
||||
let legacyResolved;
|
||||
if (!job.exportsOnly)
|
||||
legacyResolved =
|
||||
(await resolveFile(nodeModulesDir + path_1.sep + name, parent, job)) ||
|
||||
(await resolveDir(nodeModulesDir + path_1.sep + name, parent, job));
|
||||
const resolved = await resolveExportsImports(nodeModulesDir + path_1.sep + pkgName, pkgExports, '.' + name.slice(pkgName.length), job, false, cjsResolve, parent);
|
||||
if (resolved) {
|
||||
await job.emitFile(nodeModulesDir + path_1.sep + pkgName + path_1.sep + 'package.json', 'resolve', parent);
|
||||
if (legacyResolved && !resolved.includes(legacyResolved))
|
||||
return [...resolved, legacyResolved];
|
||||
return resolved;
|
||||
}
|
||||
if (legacyResolved)
|
||||
return legacyResolved;
|
||||
}
|
||||
else {
|
||||
const resolved = (await resolveFile(nodeModulesDir + path_1.sep + name, parent, job)) ||
|
||||
(await resolveDir(nodeModulesDir + path_1.sep + name, parent, job));
|
||||
if (resolved) {
|
||||
if (selfResolved) {
|
||||
if (Array.isArray(selfResolved)) {
|
||||
if (!selfResolved.includes(resolved))
|
||||
return [resolved, ...selfResolved];
|
||||
return selfResolved;
|
||||
}
|
||||
else if (selfResolved !== resolved) {
|
||||
return [resolved, selfResolved];
|
||||
}
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selfResolved)
|
||||
return selfResolved;
|
||||
if (Object.hasOwnProperty.call(job.paths, name)) {
|
||||
return job.paths[name];
|
||||
}
|
||||
for (const path of Object.keys(job.paths)) {
|
||||
if (path.endsWith('/') && name.startsWith(path)) {
|
||||
const pathTarget = job.paths[path] + name.slice(path.length);
|
||||
const resolved = (await resolveFile(pathTarget, parent, job)) ||
|
||||
(await resolveDir(pathTarget, parent, job));
|
||||
if (!resolved) {
|
||||
throw new NotFoundError(name, parent);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
throw new NotFoundError(name, parent);
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/resolve-dependency.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/resolve-dependency.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
65
node_modules/@vercel/nft/out/types.d.ts
generated
vendored
Normal file
65
node_modules/@vercel/nft/out/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Job } from './node-file-trace';
|
||||
export interface Stats {
|
||||
isFile(): boolean;
|
||||
isDirectory(): boolean;
|
||||
isBlockDevice(): boolean;
|
||||
isCharacterDevice(): boolean;
|
||||
isSymbolicLink(): boolean;
|
||||
isFIFO(): boolean;
|
||||
isSocket(): boolean;
|
||||
dev: number;
|
||||
ino: number;
|
||||
mode: number;
|
||||
nlink: number;
|
||||
uid: number;
|
||||
gid: number;
|
||||
rdev: number;
|
||||
size: number;
|
||||
blksize: number;
|
||||
blocks: number;
|
||||
atimeMs: number;
|
||||
mtimeMs: number;
|
||||
ctimeMs: number;
|
||||
birthtimeMs: number;
|
||||
atime: Date;
|
||||
mtime: Date;
|
||||
ctime: Date;
|
||||
birthtime: Date;
|
||||
}
|
||||
export interface NodeFileTraceOptions {
|
||||
base?: string;
|
||||
processCwd?: string;
|
||||
exports?: string[];
|
||||
conditions?: string[];
|
||||
exportsOnly?: boolean;
|
||||
ignore?: string | string[] | ((path: string) => boolean);
|
||||
analysis?: boolean | {
|
||||
emitGlobs?: boolean;
|
||||
computeFileReferences?: boolean;
|
||||
evaluatePureExpressions?: boolean;
|
||||
};
|
||||
cache?: any;
|
||||
paths?: Record<string, string>;
|
||||
ts?: boolean;
|
||||
log?: boolean;
|
||||
mixedModules?: boolean;
|
||||
readFile?: (path: string) => Promise<Buffer | string | null>;
|
||||
stat?: (path: string) => Promise<Stats | null>;
|
||||
readlink?: (path: string) => Promise<string | null>;
|
||||
resolve?: (id: string, parent: string, job: Job, cjsResolve: boolean) => Promise<string | string[]>;
|
||||
fileIOConcurrency?: number;
|
||||
depth?: number;
|
||||
}
|
||||
export type NodeFileTraceReasonType = 'initial' | 'resolve' | 'dependency' | 'asset' | 'sharedlib';
|
||||
export interface NodeFileTraceReasons extends Map<string, {
|
||||
type: NodeFileTraceReasonType[];
|
||||
ignored: boolean;
|
||||
parents: Set<string>;
|
||||
}> {
|
||||
}
|
||||
export interface NodeFileTraceResult {
|
||||
fileList: Set<string>;
|
||||
esmFileList: Set<string>;
|
||||
reasons: NodeFileTraceReasons;
|
||||
warnings: Set<Error>;
|
||||
}
|
||||
2
node_modules/@vercel/nft/out/types.js
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
node_modules/@vercel/nft/out/types.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
||||
49
node_modules/@vercel/nft/out/utils/ast-helpers.js
generated
vendored
Normal file
49
node_modules/@vercel/nft/out/utils/ast-helpers.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isIdentifierRead = isIdentifierRead;
|
||||
exports.isVarLoop = isVarLoop;
|
||||
exports.isLoop = isLoop;
|
||||
function isIdentifierRead(node, parent) {
|
||||
switch (parent.type) {
|
||||
case 'ObjectPattern':
|
||||
case 'ArrayPattern':
|
||||
// Note: default values not currently supported
|
||||
return false;
|
||||
// disregard `bar` in `bar = thing()`
|
||||
case 'AssignmentExpression':
|
||||
return parent.right === node;
|
||||
case 'MemberExpression':
|
||||
return parent.computed || node === parent.object;
|
||||
// disregard the `bar` in `{ bar: foo }`
|
||||
case 'Property':
|
||||
return node === parent.value;
|
||||
// disregard the `bar` in `class Foo { bar () {...} }`
|
||||
case 'MethodDefinition':
|
||||
return false;
|
||||
// disregard the `bar` in var bar = asdf
|
||||
case 'VariableDeclarator':
|
||||
return parent.id !== node;
|
||||
// disregard the `bar` in `export { foo as bar }`
|
||||
case 'ExportSpecifier':
|
||||
return false;
|
||||
// disregard the `bar` in `function (bar) {}`
|
||||
case 'FunctionExpression':
|
||||
case 'FunctionDeclaration':
|
||||
case 'ArrowFunctionExpression':
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function isVarLoop(node) {
|
||||
return (node.type === 'ForStatement' ||
|
||||
node.type === 'ForInStatement' ||
|
||||
node.type === 'ForOfStatement');
|
||||
}
|
||||
function isLoop(node) {
|
||||
return (node.type === 'ForStatement' ||
|
||||
node.type === 'ForInStatement' ||
|
||||
node.type === 'ForOfStatement' ||
|
||||
node.type === 'WhileStatement' ||
|
||||
node.type === 'DoWhileStatement');
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/ast-helpers.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/ast-helpers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ast-helpers.js","sourceRoot":"","sources":["../../src/utils/ast-helpers.ts"],"names":[],"mappings":";;AAEA,4CA+BC;AAED,8BAMC;AAED,wBAQC;AAjDD,SAAgB,gBAAgB,CAAC,IAAU,EAAE,MAAY;IACvD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe,CAAC;QACrB,KAAK,cAAc;YACjB,+CAA+C;YAC/C,OAAO,KAAK,CAAC;QACf,qCAAqC;QACrC,KAAK,sBAAsB;YACzB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;QAC/B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,QAAQ,IAAI,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC;QACnD,wCAAwC;QACxC,KAAK,UAAU;YACb,OAAO,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC;QAC/B,sDAAsD;QACtD,KAAK,kBAAkB;YACrB,OAAO,KAAK,CAAC;QACf,wCAAwC;QACxC,KAAK,oBAAoB;YACvB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;QAC5B,iDAAiD;QACjD,KAAK,iBAAiB;YACpB,OAAO,KAAK,CAAC;QACf,6CAA6C;QAC7C,KAAK,oBAAoB,CAAC;QAC1B,KAAK,qBAAqB,CAAC;QAC3B,KAAK,yBAAyB;YAC5B,OAAO,KAAK,CAAC;QACf;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,gBAAgB;QAC9B,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAC/B,CAAC;AACJ,CAAC;AAED,SAAgB,MAAM,CAAC,IAAU;IAC/B,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,gBAAgB;QAC9B,IAAI,CAAC,IAAI,KAAK,gBAAgB;QAC9B,IAAI,CAAC,IAAI,KAAK,gBAAgB;QAC9B,IAAI,CAAC,IAAI,KAAK,kBAAkB,CACjC,CAAC;AACJ,CAAC"}
|
||||
88
node_modules/@vercel/nft/out/utils/binary-locators.js
generated
vendored
Normal file
88
node_modules/@vercel/nft/out/utils/binary-locators.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pregyp = void 0;
|
||||
exports.nbind = nbind;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const graceful_fs_1 = __importDefault(require("graceful-fs"));
|
||||
// pregyp
|
||||
const versioning = require('@mapbox/node-pre-gyp/lib/util/versioning.js');
|
||||
const napi = require('@mapbox/node-pre-gyp/lib/util/napi.js');
|
||||
const pregypFind = (package_json_path, opts) => {
|
||||
const package_json = JSON.parse(graceful_fs_1.default.readFileSync(package_json_path).toString());
|
||||
versioning.validate_config(package_json, opts);
|
||||
var napi_build_version;
|
||||
if (napi.get_napi_build_versions(package_json, opts)) {
|
||||
napi_build_version = napi.get_best_napi_build_version(package_json, opts);
|
||||
}
|
||||
opts = opts || {};
|
||||
if (!opts.module_root)
|
||||
opts.module_root = path_1.default.dirname(package_json_path);
|
||||
var meta = versioning.evaluate(package_json, opts, napi_build_version);
|
||||
return meta.module;
|
||||
};
|
||||
exports.pregyp = { default: { find: pregypFind }, find: pregypFind };
|
||||
// nbind
|
||||
// Adapted from nbind.js
|
||||
function makeModulePathList(root, name) {
|
||||
return [
|
||||
[root, name],
|
||||
[root, 'build', name],
|
||||
[root, 'build', 'Debug', name],
|
||||
[root, 'build', 'Release', name],
|
||||
[root, 'out', 'Debug', name],
|
||||
[root, 'Debug', name],
|
||||
[root, 'out', 'Release', name],
|
||||
[root, 'Release', name],
|
||||
[root, 'build', 'default', name],
|
||||
[
|
||||
root,
|
||||
process.env['NODE_BINDINGS_COMPILED_DIR'] || 'compiled',
|
||||
process.versions.node,
|
||||
process.platform,
|
||||
process.arch,
|
||||
name,
|
||||
],
|
||||
];
|
||||
}
|
||||
function findCompiledModule(basePath, specList) {
|
||||
var resolvedList = [];
|
||||
var ext = path_1.default.extname(basePath);
|
||||
for (var _i = 0, specList_1 = specList; _i < specList_1.length; _i++) {
|
||||
var spec = specList_1[_i];
|
||||
if (ext == spec.ext) {
|
||||
try {
|
||||
spec.path = eval('require.resolve(basePath)');
|
||||
return spec;
|
||||
}
|
||||
catch (err) {
|
||||
resolvedList.push(basePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var _a = 0, specList_2 = specList; _a < specList_2.length; _a++) {
|
||||
var spec = specList_2[_a];
|
||||
for (var _b = 0, _c = makeModulePathList(basePath, spec.name); _b < _c.length; _b++) {
|
||||
var pathParts = _c[_b];
|
||||
var resolvedPath = path_1.default.resolve.apply(path_1.default, pathParts);
|
||||
try {
|
||||
spec.path = eval('require.resolve(resolvedPath)');
|
||||
}
|
||||
catch (err) {
|
||||
resolvedList.push(resolvedPath);
|
||||
continue;
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function nbind(basePath = process.cwd()) {
|
||||
const found = findCompiledModule(basePath, [
|
||||
{ ext: '.node', name: 'nbind.node', type: 'node' },
|
||||
{ ext: '.js', name: 'nbind.js', type: 'emcc' },
|
||||
]);
|
||||
return found;
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/binary-locators.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/binary-locators.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"binary-locators.js","sourceRoot":"","sources":["../../src/utils/binary-locators.ts"],"names":[],"mappings":"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"}
|
||||
30
node_modules/@vercel/nft/out/utils/get-package-base.js
generated
vendored
Normal file
30
node_modules/@vercel/nft/out/utils/get-package-base.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPackageBase = getPackageBase;
|
||||
exports.getPackageName = getPackageName;
|
||||
// returns the base-level package folder based on detecting "node_modules"
|
||||
// package name boundaries
|
||||
const pkgNameRegEx = /^(@[^\\\/]+[\\\/])?[^\\\/]+/;
|
||||
function getPackageBase(id) {
|
||||
const pkgIndex = id.lastIndexOf('node_modules');
|
||||
if (pkgIndex !== -1 &&
|
||||
(id[pkgIndex - 1] === '/' || id[pkgIndex - 1] === '\\') &&
|
||||
(id[pkgIndex + 12] === '/' || id[pkgIndex + 12] === '\\')) {
|
||||
const pkgNameMatch = id.slice(pkgIndex + 13).match(pkgNameRegEx);
|
||||
if (pkgNameMatch)
|
||||
return id.slice(0, pkgIndex + 13 + pkgNameMatch[0].length);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getPackageName(id) {
|
||||
const pkgIndex = id.lastIndexOf('node_modules');
|
||||
if (pkgIndex !== -1 &&
|
||||
(id[pkgIndex - 1] === '/' || id[pkgIndex - 1] === '\\') &&
|
||||
(id[pkgIndex + 12] === '/' || id[pkgIndex + 12] === '\\')) {
|
||||
const pkgNameMatch = id.slice(pkgIndex + 13).match(pkgNameRegEx);
|
||||
if (pkgNameMatch && pkgNameMatch.length > 0) {
|
||||
return pkgNameMatch[0].replace(/\\/g, '/');
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/get-package-base.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/get-package-base.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-package-base.js","sourceRoot":"","sources":["../../src/utils/get-package-base.ts"],"names":[],"mappings":";;AAIA,wCAYC;AAED,wCAaC;AA/BD,0EAA0E;AAC1E,0BAA0B;AAC1B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD,SAAgB,cAAc,CAAC,EAAU;IACvC,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAChD,IACE,QAAQ,KAAK,CAAC,CAAC;QACf,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;QACvD,CAAC,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,EACzD,CAAC;QACD,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjE,IAAI,YAAY;YACd,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,cAAc,CAAC,EAAU;IACvC,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAChD,IACE,QAAQ,KAAK,CAAC,CAAC;QACf,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;QACvD,CAAC,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,EACzD,CAAC;QACD,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjE,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
||||
24
node_modules/@vercel/nft/out/utils/interop-require.js
generated
vendored
Normal file
24
node_modules/@vercel/nft/out/utils/interop-require.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeDefaultRequire = normalizeDefaultRequire;
|
||||
exports.normalizeWildcardRequire = normalizeWildcardRequire;
|
||||
function normalizeDefaultRequire(obj) {
|
||||
if (obj && obj.__esModule)
|
||||
return obj;
|
||||
return { default: obj };
|
||||
}
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
function normalizeWildcardRequire(obj) {
|
||||
if (obj && obj.__esModule)
|
||||
return obj;
|
||||
// Note: This implements only value properties and doesn't preserve getters.
|
||||
// This follows the simpler helpers generated by TypeScript.
|
||||
const out = {};
|
||||
for (const key in obj) {
|
||||
if (!hasOwnProperty.call(obj, key))
|
||||
continue;
|
||||
out[key] = obj[key];
|
||||
}
|
||||
out['default'] = obj;
|
||||
return out;
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/interop-require.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/interop-require.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"interop-require.js","sourceRoot":"","sources":["../../src/utils/interop-require.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,0DAGC;AAGD,4DAWC;AAjBD,SAAgB,uBAAuB,CAAC,GAAQ;IAC9C,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACvD,SAAgB,wBAAwB,CAAC,GAAQ;IAC/C,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC;IACtC,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM,GAAG,GAA8B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;YAAE,SAAS;QAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC;IACrB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
||||
10
node_modules/@vercel/nft/out/utils/node-version.js
generated
vendored
Normal file
10
node_modules/@vercel/nft/out/utils/node-version.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getNodeMajorVersion = getNodeMajorVersion;
|
||||
/**
|
||||
* Gets the major version of the current Node.js runtime
|
||||
* @returns The major version number (e.g., 22 for Node.js v22.16.0)
|
||||
*/
|
||||
function getNodeMajorVersion() {
|
||||
return parseInt(process.versions.node.split('.')[0], 10);
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/node-version.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/node-version.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"node-version.js","sourceRoot":"","sources":["../../src/utils/node-version.ts"],"names":[],"mappings":";;AAIA,kDAEC;AAND;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
||||
33
node_modules/@vercel/nft/out/utils/sharedlib-emit.js
generated
vendored
Normal file
33
node_modules/@vercel/nft/out/utils/sharedlib-emit.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sharedLibEmit = sharedLibEmit;
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const glob_1 = require("glob");
|
||||
const get_package_base_1 = require("./get-package-base");
|
||||
let sharedlibGlob = '';
|
||||
switch (os_1.default.platform()) {
|
||||
case 'darwin':
|
||||
sharedlibGlob = '/**/*.@(dylib|so?(.*))';
|
||||
break;
|
||||
case 'win32':
|
||||
sharedlibGlob = '/**/*.dll';
|
||||
break;
|
||||
default:
|
||||
sharedlibGlob = '/**/*.so?(.*)';
|
||||
}
|
||||
// helper for emitting the associated shared libraries when a binary is emitted
|
||||
async function sharedLibEmit(p, job) {
|
||||
// console.log('Emitting shared libs for ' + path);
|
||||
const pkgPath = (0, get_package_base_1.getPackageBase)(p);
|
||||
if (!pkgPath)
|
||||
return;
|
||||
const files = await (0, glob_1.glob)(pkgPath.replaceAll(path_1.default.sep, path_1.default.posix.sep) + sharedlibGlob, {
|
||||
ignore: pkgPath.replaceAll(path_1.default.sep, path_1.default.posix.sep) + '/**/node_modules/**/*',
|
||||
dot: true,
|
||||
});
|
||||
await Promise.all(files.map((file) => job.emitFile(file, 'sharedlib', p)));
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/sharedlib-emit.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/sharedlib-emit.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sharedlib-emit.js","sourceRoot":"","sources":["../../src/utils/sharedlib-emit.ts"],"names":[],"mappings":";;;;;AAmBA,sCAcC;AAjCD,4CAAoB;AACpB,gDAAwB;AACxB,+BAA4B;AAC5B,yDAAoD;AAGpD,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,QAAQ,YAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;IACtB,KAAK,QAAQ;QACX,aAAa,GAAG,wBAAwB,CAAC;QACzC,MAAM;IACR,KAAK,OAAO;QACV,aAAa,GAAG,WAAW,CAAC;QAC5B,MAAM;IACR;QACE,aAAa,GAAG,eAAe,CAAC;AACpC,CAAC;AAED,+EAA+E;AACxE,KAAK,UAAU,aAAa,CAAC,CAAS,EAAE,GAAQ;IACrD,mDAAmD;IACnD,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,CAAC,CAAC,CAAC;IAClC,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,MAAM,KAAK,GAAG,MAAM,IAAA,WAAI,EACtB,OAAO,CAAC,UAAU,CAAC,cAAI,CAAC,GAAG,EAAE,cAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,aAAa,EAC5D;QACE,MAAM,EACJ,OAAO,CAAC,UAAU,CAAC,cAAI,CAAC,GAAG,EAAE,cAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,uBAAuB;QACxE,GAAG,EAAE,IAAI;KACV,CACF,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
||||
339
node_modules/@vercel/nft/out/utils/special-cases.js
generated
vendored
Normal file
339
node_modules/@vercel/nft/out/utils/special-cases.js
generated
vendored
Normal file
@@ -0,0 +1,339 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = handleSpecialCases;
|
||||
const path_1 = require("path");
|
||||
const resolve_dependency_1 = __importDefault(require("../resolve-dependency"));
|
||||
const get_package_base_1 = require("./get-package-base");
|
||||
const graceful_fs_1 = require("graceful-fs");
|
||||
const specialCases = {
|
||||
'@generated/photon'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('@generated/photon/index.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'runtime/'));
|
||||
}
|
||||
},
|
||||
'@serialport/bindings-cpp'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('@serialport/bindings-cpp/dist/index.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'build', 'Release'));
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'prebuilds'));
|
||||
}
|
||||
},
|
||||
argon2({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('argon2/argon2.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'build', 'Release'));
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'prebuilds'));
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'lib', 'binding'));
|
||||
}
|
||||
},
|
||||
bull({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('bull/lib/commands/index.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id)));
|
||||
}
|
||||
},
|
||||
camaro({ id, emitAsset }) {
|
||||
if (id.endsWith('camaro/dist/camaro.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), 'camaro.wasm'));
|
||||
}
|
||||
},
|
||||
esbuild({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('esbuild/lib/main.js')) {
|
||||
const file = (0, path_1.resolve)(id, '..', '..', 'package.json');
|
||||
const pkg = JSON.parse((0, graceful_fs_1.readFileSync)(file, 'utf8'));
|
||||
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
|
||||
const dir = (0, path_1.resolve)(id, '..', '..', '..', dep);
|
||||
emitAssetDirectory(dir);
|
||||
}
|
||||
}
|
||||
},
|
||||
'ffmpeg-static'({ id, emitAsset }) {
|
||||
if (id.endsWith('ffmpeg-static/index.js')) {
|
||||
const bin = require(id);
|
||||
emitAsset(bin);
|
||||
}
|
||||
},
|
||||
'google-gax'({ id, ast, emitAssetDirectory }) {
|
||||
if (id.endsWith('google-gax/build/src/grpc.js')) {
|
||||
// const googleProtoFilesDir = path.normalize(google_proto_files_1.getProtoPath('..'));
|
||||
// ->
|
||||
// const googleProtoFilesDir = resolve(__dirname, '../../../google-proto-files');
|
||||
for (const statement of ast.body) {
|
||||
if (statement.type === 'VariableDeclaration' &&
|
||||
statement.declarations[0].id.type === 'Identifier' &&
|
||||
statement.declarations[0].id.name === 'googleProtoFilesDir') {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '../../../google-proto-files'));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
oracledb({ id, ast, emitAsset }) {
|
||||
if (id.endsWith('oracledb/lib/oracledb.js')) {
|
||||
for (const statement of ast.body) {
|
||||
if (statement.type === 'ForStatement' &&
|
||||
'body' in statement.body &&
|
||||
statement.body.body &&
|
||||
Array.isArray(statement.body.body) &&
|
||||
statement.body.body[0] &&
|
||||
statement.body.body[0].type === 'TryStatement' &&
|
||||
statement.body.body[0].block.body[0] &&
|
||||
statement.body.body[0].block.body[0].type === 'ExpressionStatement' &&
|
||||
statement.body.body[0].block.body[0].expression.type ===
|
||||
'AssignmentExpression' &&
|
||||
statement.body.body[0].block.body[0].expression.operator === '=' &&
|
||||
statement.body.body[0].block.body[0].expression.left.type ===
|
||||
'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.left.name ===
|
||||
'oracledbCLib' &&
|
||||
statement.body.body[0].block.body[0].expression.right.type ===
|
||||
'CallExpression' &&
|
||||
statement.body.body[0].block.body[0].expression.right.callee.type ===
|
||||
'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.right.callee.name ===
|
||||
'require' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments
|
||||
.length === 1 &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0]
|
||||
.type === 'MemberExpression' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0]
|
||||
.computed === true &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0]
|
||||
.object.type === 'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0]
|
||||
.object.name === 'binaryLocations' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0]
|
||||
.property.type === 'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0]
|
||||
.property.name === 'i') {
|
||||
statement.body.body[0].block.body[0].expression.right.arguments = [
|
||||
{ type: 'Literal', value: '_' },
|
||||
];
|
||||
const version = global._unit
|
||||
? '3.0.0'
|
||||
: JSON.parse((0, graceful_fs_1.readFileSync)(id.slice(0, -15) + 'package.json', 'utf8')).version;
|
||||
const useVersion = Number(version.slice(0, version.indexOf('.'))) >= 4;
|
||||
const binaryName = 'oracledb-' +
|
||||
(useVersion ? version : 'abi' + process.versions.modules) +
|
||||
'-' +
|
||||
process.platform +
|
||||
'-' +
|
||||
process.arch +
|
||||
'.node';
|
||||
emitAsset((0, path_1.resolve)(id, '../../build/Release/' + binaryName));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'phantomjs-prebuilt'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('phantomjs-prebuilt/lib/phantomjs.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'bin'));
|
||||
}
|
||||
},
|
||||
'remark-prism'({ id, emitAssetDirectory }) {
|
||||
const file = 'remark-prism/src/highlight.js';
|
||||
if (id.endsWith(file)) {
|
||||
try {
|
||||
const node_modules = id.slice(0, -file.length);
|
||||
emitAssetDirectory((0, path_1.resolve)(node_modules, 'prismjs', 'components'));
|
||||
}
|
||||
catch (e) {
|
||||
// fail silently
|
||||
}
|
||||
}
|
||||
},
|
||||
semver({ id, emitAsset }) {
|
||||
if (id.endsWith('semver/index.js')) {
|
||||
// See https://github.com/npm/node-semver/blob/master/CHANGELOG.md#710
|
||||
emitAsset((0, path_1.resolve)(id.replace('index.js', 'preload.js')));
|
||||
}
|
||||
},
|
||||
sharp: async ({ id, emitAssetDirectory, job }) => {
|
||||
if (id.endsWith('sharp/lib/index.js')) {
|
||||
const file = (0, path_1.resolve)(id, '..', '..', 'package.json');
|
||||
const pkg = JSON.parse((0, graceful_fs_1.readFileSync)(file, 'utf8'));
|
||||
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
|
||||
const dir = (0, path_1.resolve)(id, '..', '..', '..', dep);
|
||||
emitAssetDirectory(dir);
|
||||
try {
|
||||
const file = (0, path_1.resolve)(dir, 'package.json');
|
||||
const pkg = JSON.parse((0, graceful_fs_1.readFileSync)(file, 'utf8'));
|
||||
for (const innerDep of Object.keys(pkg.optionalDependencies || {})) {
|
||||
const innerDir = (0, path_1.resolve)(await job.realpath(dir), '..', '..', innerDep);
|
||||
emitAssetDirectory(innerDir);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
console.error(`Error reading "sharp" dependencies from "${dir}/package.json"'`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
shiki({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('/dist/index.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'languages'));
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'themes'));
|
||||
}
|
||||
},
|
||||
'socket.io': async function ({ id, ast, job }) {
|
||||
if (id.endsWith('socket.io/lib/index.js')) {
|
||||
async function replaceResolvePathStatement(statement) {
|
||||
if (statement.type === 'ExpressionStatement' &&
|
||||
statement.expression.type === 'AssignmentExpression' &&
|
||||
statement.expression.operator === '=' &&
|
||||
statement.expression.right.type === 'CallExpression' &&
|
||||
statement.expression.right.callee.type === 'Identifier' &&
|
||||
statement.expression.right.callee.name === 'read' &&
|
||||
statement.expression.right.arguments.length >= 1 &&
|
||||
statement.expression.right.arguments[0].type === 'CallExpression' &&
|
||||
statement.expression.right.arguments[0].callee.type ===
|
||||
'Identifier' &&
|
||||
statement.expression.right.arguments[0].callee.name ===
|
||||
'resolvePath' &&
|
||||
statement.expression.right.arguments[0].arguments.length === 1 &&
|
||||
statement.expression.right.arguments[0].arguments[0].type ===
|
||||
'Literal') {
|
||||
const arg = statement.expression.right.arguments[0].arguments[0].value;
|
||||
let resolved;
|
||||
try {
|
||||
const dep = await (0, resolve_dependency_1.default)(String(arg), id, job);
|
||||
if (typeof dep === 'string') {
|
||||
resolved = dep;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
// The asset relocator will then pick up the AST rewriting from here
|
||||
const relResolved = '/' + (0, path_1.relative)((0, path_1.dirname)(id), resolved);
|
||||
statement.expression.right.arguments[0] = {
|
||||
type: 'BinaryExpression',
|
||||
// @ts-ignore Its okay if start is undefined
|
||||
start: statement.expression.right.arguments[0].start,
|
||||
// @ts-ignore Its okay if end is undefined
|
||||
end: statement.expression.right.arguments[0].end,
|
||||
operator: '+',
|
||||
left: {
|
||||
type: 'Identifier',
|
||||
name: '__dirname',
|
||||
},
|
||||
right: {
|
||||
type: 'Literal',
|
||||
value: relResolved,
|
||||
raw: JSON.stringify(relResolved),
|
||||
},
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
for (const statement of ast.body) {
|
||||
if (statement.type === 'ExpressionStatement' &&
|
||||
statement.expression.type === 'AssignmentExpression' &&
|
||||
statement.expression.operator === '=' &&
|
||||
statement.expression.left.type === 'MemberExpression' &&
|
||||
statement.expression.left.object.type === 'MemberExpression' &&
|
||||
statement.expression.left.object.object.type === 'Identifier' &&
|
||||
statement.expression.left.object.object.name === 'Server' &&
|
||||
statement.expression.left.object.property.type === 'Identifier' &&
|
||||
statement.expression.left.object.property.name === 'prototype' &&
|
||||
statement.expression.left.property.type === 'Identifier' &&
|
||||
statement.expression.left.property.name === 'serveClient' &&
|
||||
statement.expression.right.type === 'FunctionExpression') {
|
||||
for (const node of statement.expression.right.body.body) {
|
||||
if (node.type === 'IfStatement' &&
|
||||
node.consequent &&
|
||||
'body' in node.consequent &&
|
||||
node.consequent.body) {
|
||||
const ifBody = node.consequent.body;
|
||||
let replaced = false;
|
||||
if (Array.isArray(ifBody) &&
|
||||
ifBody[0] &&
|
||||
ifBody[0].type === 'ExpressionStatement') {
|
||||
replaced = await replaceResolvePathStatement(ifBody[0]);
|
||||
}
|
||||
if (Array.isArray(ifBody) &&
|
||||
ifBody[1] &&
|
||||
ifBody[1].type === 'TryStatement' &&
|
||||
ifBody[1].block.body &&
|
||||
ifBody[1].block.body[0]) {
|
||||
replaced =
|
||||
(await replaceResolvePathStatement(ifBody[1].block.body[0])) || replaced;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
typescript({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('typescript/lib/tsc.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)(id, '../'));
|
||||
}
|
||||
},
|
||||
'uglify-es'({ id, emitAsset }) {
|
||||
if (id.endsWith('uglify-es/tools/node.js')) {
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/utils.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/ast.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/parse.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/transform.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/scope.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/output.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/compress.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/sourcemap.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/mozilla-ast.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/propmangle.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/minify.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../exports.js'));
|
||||
}
|
||||
},
|
||||
'uglify-js'({ id, emitAsset, emitAssetDirectory }) {
|
||||
if (id.endsWith('uglify-js/tools/node.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)(id, '../../lib'));
|
||||
emitAsset((0, path_1.resolve)(id, '../exports.js'));
|
||||
}
|
||||
},
|
||||
'playwright-core'({ id, emitAsset }) {
|
||||
if (id.endsWith('playwright-core/index.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), 'browsers.json'));
|
||||
}
|
||||
},
|
||||
'geo-tz'({ id, emitAsset }) {
|
||||
if (id.endsWith('geo-tz/dist/geo-tz.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geo.dat'));
|
||||
}
|
||||
},
|
||||
pixelmatch({ id, emitDependency }) {
|
||||
if (id.endsWith('pixelmatch/index.js')) {
|
||||
emitDependency((0, path_1.resolve)((0, path_1.dirname)(id), 'bin/pixelmatch'));
|
||||
}
|
||||
},
|
||||
'geoip-lite'({ id, emitAsset }) {
|
||||
if (id.endsWith('geoip-lite/lib/geoip.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geoip-city.dat'));
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geoip-city6.dat'));
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geoip-city-names.dat'));
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geoip-country.dat'));
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geoip-country6.dat'));
|
||||
}
|
||||
},
|
||||
};
|
||||
async function handleSpecialCases({ id, ast, emitDependency, emitAsset, emitAssetDirectory, job, }) {
|
||||
const pkgName = (0, get_package_base_1.getPackageName)(id);
|
||||
const specialCase = specialCases[pkgName || ''];
|
||||
id = id.replace(/\\/g, '/');
|
||||
if (specialCase)
|
||||
await specialCase({
|
||||
id,
|
||||
ast,
|
||||
emitDependency,
|
||||
emitAsset,
|
||||
emitAssetDirectory,
|
||||
job,
|
||||
});
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/special-cases.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/special-cases.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
579
node_modules/@vercel/nft/out/utils/static-eval.js
generated
vendored
Normal file
579
node_modules/@vercel/nft/out/utils/static-eval.js
generated
vendored
Normal file
@@ -0,0 +1,579 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wildcardRegEx = exports.WILDCARD = exports.FUNCTION = exports.UNKNOWN = void 0;
|
||||
exports.evaluate = evaluate;
|
||||
async function evaluate(ast, vars = {}, computeBranches = true) {
|
||||
const state = {
|
||||
computeBranches,
|
||||
vars,
|
||||
};
|
||||
return walk(ast);
|
||||
// walk returns:
|
||||
// 1. Single known value: { value: value }
|
||||
// 2. Conditional value: { test, ifTrue, else }
|
||||
// 3. Unknown value: undefined
|
||||
function walk(node) {
|
||||
const visitor = visitors[node.type];
|
||||
if (visitor) {
|
||||
return visitor.call(state, node, walk);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.UNKNOWN = Symbol();
|
||||
exports.FUNCTION = Symbol();
|
||||
exports.WILDCARD = '\x1a';
|
||||
exports.wildcardRegEx = /\x1a/g;
|
||||
function countWildcards(str) {
|
||||
exports.wildcardRegEx.lastIndex = 0;
|
||||
let cnt = 0;
|
||||
while (exports.wildcardRegEx.exec(str))
|
||||
cnt++;
|
||||
return cnt;
|
||||
}
|
||||
const visitors = {
|
||||
ArrayExpression: async function ArrayExpression(node, walk) {
|
||||
const arr = [];
|
||||
for (let i = 0, l = node.elements.length; i < l; i++) {
|
||||
if (node.elements[i] === null) {
|
||||
arr.push(null);
|
||||
continue;
|
||||
}
|
||||
const x = await walk(node.elements[i]);
|
||||
if (!x)
|
||||
return;
|
||||
if ('value' in x === false)
|
||||
return;
|
||||
arr.push(x.value);
|
||||
}
|
||||
return { value: arr };
|
||||
},
|
||||
ArrowFunctionExpression: async function (node, walk) {
|
||||
// () => val support only
|
||||
if (node.params.length === 0 &&
|
||||
!node.generator &&
|
||||
!node.async &&
|
||||
node.expression) {
|
||||
const innerValue = await walk(node.body);
|
||||
if (!innerValue || !('value' in innerValue))
|
||||
return;
|
||||
return {
|
||||
value: {
|
||||
[exports.FUNCTION]: () => innerValue.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
BinaryExpression: async function BinaryExpression(node, walk) {
|
||||
const op = node.operator;
|
||||
let l = await walk(node.left);
|
||||
if (!l && op !== '+')
|
||||
return;
|
||||
let r = await walk(node.right);
|
||||
if (!l && !r)
|
||||
return;
|
||||
if (!l) {
|
||||
// UNKNOWN + 'str' -> wildcard string value
|
||||
if (this.computeBranches &&
|
||||
r &&
|
||||
'value' in r &&
|
||||
typeof r.value === 'string')
|
||||
return {
|
||||
value: exports.WILDCARD + r.value,
|
||||
wildcards: [node.left, ...(r.wildcards || [])],
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (!r) {
|
||||
// 'str' + UKNOWN -> wildcard string value
|
||||
if (this.computeBranches && op === '+') {
|
||||
if (l && 'value' in l && typeof l.value === 'string')
|
||||
return {
|
||||
value: l.value + exports.WILDCARD,
|
||||
wildcards: [...(l.wildcards || []), node.right],
|
||||
};
|
||||
}
|
||||
// A || UNKNOWN -> A if A is truthy
|
||||
if (!('test' in l) && op === '||' && l.value)
|
||||
return l;
|
||||
return;
|
||||
}
|
||||
if ('test' in l && 'value' in r) {
|
||||
const v = r.value;
|
||||
if (op === '==')
|
||||
return { test: l.test, ifTrue: l.ifTrue == v, else: l.else == v };
|
||||
if (op === '===')
|
||||
return { test: l.test, ifTrue: l.ifTrue === v, else: l.else === v };
|
||||
if (op === '!=')
|
||||
return { test: l.test, ifTrue: l.ifTrue != v, else: l.else != v };
|
||||
if (op === '!==')
|
||||
return { test: l.test, ifTrue: l.ifTrue !== v, else: l.else !== v };
|
||||
if (op === '+')
|
||||
return { test: l.test, ifTrue: l.ifTrue + v, else: l.else + v };
|
||||
if (op === '-')
|
||||
return { test: l.test, ifTrue: l.ifTrue - v, else: l.else - v };
|
||||
if (op === '*')
|
||||
return { test: l.test, ifTrue: l.ifTrue * v, else: l.else * v };
|
||||
if (op === '/')
|
||||
return { test: l.test, ifTrue: l.ifTrue / v, else: l.else / v };
|
||||
if (op === '%')
|
||||
return { test: l.test, ifTrue: l.ifTrue % v, else: l.else % v };
|
||||
if (op === '<')
|
||||
return { test: l.test, ifTrue: l.ifTrue < v, else: l.else < v };
|
||||
if (op === '<=')
|
||||
return { test: l.test, ifTrue: l.ifTrue <= v, else: l.else <= v };
|
||||
if (op === '>')
|
||||
return { test: l.test, ifTrue: l.ifTrue > v, else: l.else > v };
|
||||
if (op === '>=')
|
||||
return { test: l.test, ifTrue: l.ifTrue >= v, else: l.else >= v };
|
||||
if (op === '|')
|
||||
return { test: l.test, ifTrue: l.ifTrue | v, else: l.else | v };
|
||||
if (op === '&')
|
||||
return { test: l.test, ifTrue: l.ifTrue & v, else: l.else & v };
|
||||
if (op === '^')
|
||||
return { test: l.test, ifTrue: l.ifTrue ^ v, else: l.else ^ v };
|
||||
if (op === '&&')
|
||||
return { test: l.test, ifTrue: l.ifTrue && v, else: l.else && v };
|
||||
if (op === '||')
|
||||
return { test: l.test, ifTrue: l.ifTrue || v, else: l.else || v };
|
||||
}
|
||||
else if ('test' in r && 'value' in l) {
|
||||
const v = l.value;
|
||||
if (op === '==')
|
||||
return { test: r.test, ifTrue: v == r.ifTrue, else: v == r.else };
|
||||
if (op === '===')
|
||||
return { test: r.test, ifTrue: v === r.ifTrue, else: v === r.else };
|
||||
if (op === '!=')
|
||||
return { test: r.test, ifTrue: v != r.ifTrue, else: v != r.else };
|
||||
if (op === '!==')
|
||||
return { test: r.test, ifTrue: v !== r.ifTrue, else: v !== r.else };
|
||||
if (op === '+')
|
||||
return { test: r.test, ifTrue: v + r.ifTrue, else: v + r.else };
|
||||
if (op === '-')
|
||||
return { test: r.test, ifTrue: v - r.ifTrue, else: v - r.else };
|
||||
if (op === '*')
|
||||
return { test: r.test, ifTrue: v * r.ifTrue, else: v * r.else };
|
||||
if (op === '/')
|
||||
return { test: r.test, ifTrue: v / r.ifTrue, else: v / r.else };
|
||||
if (op === '%')
|
||||
return { test: r.test, ifTrue: v % r.ifTrue, else: v % r.else };
|
||||
if (op === '<')
|
||||
return { test: r.test, ifTrue: v < r.ifTrue, else: v < r.else };
|
||||
if (op === '<=')
|
||||
return { test: r.test, ifTrue: v <= r.ifTrue, else: v <= r.else };
|
||||
if (op === '>')
|
||||
return { test: r.test, ifTrue: v > r.ifTrue, else: v > r.else };
|
||||
if (op === '>=')
|
||||
return { test: r.test, ifTrue: v >= r.ifTrue, else: v >= r.else };
|
||||
if (op === '|')
|
||||
return { test: r.test, ifTrue: v | r.ifTrue, else: v | r.else };
|
||||
if (op === '&')
|
||||
return { test: r.test, ifTrue: v & r.ifTrue, else: v & r.else };
|
||||
if (op === '^')
|
||||
return { test: r.test, ifTrue: v ^ r.ifTrue, else: v ^ r.else };
|
||||
if (op === '&&')
|
||||
return { test: r.test, ifTrue: v && r.ifTrue, else: l && r.else };
|
||||
if (op === '||')
|
||||
return { test: r.test, ifTrue: v || r.ifTrue, else: l || r.else };
|
||||
}
|
||||
else if ('value' in l && 'value' in r) {
|
||||
if (op === '==')
|
||||
return { value: l.value == r.value };
|
||||
if (op === '===')
|
||||
return { value: l.value === r.value };
|
||||
if (op === '!=')
|
||||
return { value: l.value != r.value };
|
||||
if (op === '!==')
|
||||
return { value: l.value !== r.value };
|
||||
if (op === '+') {
|
||||
const val = { value: l.value + r.value };
|
||||
let wildcards = [];
|
||||
if ('wildcards' in l && l.wildcards) {
|
||||
wildcards = wildcards.concat(l.wildcards);
|
||||
}
|
||||
if ('wildcards' in r && r.wildcards) {
|
||||
wildcards = wildcards.concat(r.wildcards);
|
||||
}
|
||||
if (wildcards.length > 0) {
|
||||
val.wildcards = wildcards;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
if (op === '-')
|
||||
return { value: l.value - r.value };
|
||||
if (op === '*')
|
||||
return { value: l.value * r.value };
|
||||
if (op === '/')
|
||||
return { value: l.value / r.value };
|
||||
if (op === '%')
|
||||
return { value: l.value % r.value };
|
||||
if (op === '<')
|
||||
return { value: l.value < r.value };
|
||||
if (op === '<=')
|
||||
return { value: l.value <= r.value };
|
||||
if (op === '>')
|
||||
return { value: l.value > r.value };
|
||||
if (op === '>=')
|
||||
return { value: l.value >= r.value };
|
||||
if (op === '|')
|
||||
return { value: l.value | r.value };
|
||||
if (op === '&')
|
||||
return { value: l.value & r.value };
|
||||
if (op === '^')
|
||||
return { value: l.value ^ r.value };
|
||||
if (op === '&&')
|
||||
return { value: l.value && r.value };
|
||||
if (op === '||')
|
||||
return { value: l.value || r.value };
|
||||
}
|
||||
return;
|
||||
},
|
||||
CallExpression: async function CallExpression(node, walk) {
|
||||
const callee = await walk(node.callee);
|
||||
if (!callee || 'test' in callee)
|
||||
return;
|
||||
let fn = callee.value;
|
||||
if (typeof fn === 'object' && fn !== null)
|
||||
fn = fn[exports.FUNCTION];
|
||||
if (typeof fn !== 'function')
|
||||
return;
|
||||
let ctx = null;
|
||||
if (node.callee.object) {
|
||||
ctx = await walk(node.callee.object);
|
||||
ctx = ctx && 'value' in ctx && ctx.value ? ctx.value : null;
|
||||
}
|
||||
// we allow one conditional argument to create a conditional expression
|
||||
let predicate;
|
||||
let args = [];
|
||||
let argsElse;
|
||||
let allWildcards = node.arguments.length > 0 && node.callee.property?.name !== 'concat';
|
||||
const wildcards = [];
|
||||
for (let i = 0, l = node.arguments.length; i < l; i++) {
|
||||
let x = await walk(node.arguments[i]);
|
||||
if (x) {
|
||||
allWildcards = false;
|
||||
if ('value' in x && typeof x.value === 'string' && x.wildcards)
|
||||
x.wildcards.forEach((w) => wildcards.push(w));
|
||||
}
|
||||
else {
|
||||
if (!this.computeBranches)
|
||||
return;
|
||||
// this works because provided static functions
|
||||
// operate on known string inputs
|
||||
x = { value: exports.WILDCARD };
|
||||
wildcards.push(node.arguments[i]);
|
||||
}
|
||||
if ('test' in x) {
|
||||
if (wildcards.length)
|
||||
return;
|
||||
if (predicate)
|
||||
return;
|
||||
predicate = x.test;
|
||||
argsElse = args.concat([]);
|
||||
args.push(x.ifTrue);
|
||||
argsElse.push(x.else);
|
||||
}
|
||||
else {
|
||||
args.push(x.value);
|
||||
if (argsElse)
|
||||
argsElse.push(x.value);
|
||||
}
|
||||
}
|
||||
if (allWildcards)
|
||||
return;
|
||||
try {
|
||||
const result = await fn.apply(ctx, args);
|
||||
if (result === exports.UNKNOWN)
|
||||
return;
|
||||
if (!predicate) {
|
||||
if (wildcards.length) {
|
||||
if (typeof result !== 'string' ||
|
||||
countWildcards(result) !== wildcards.length)
|
||||
return;
|
||||
return { value: result, wildcards };
|
||||
}
|
||||
return { value: result };
|
||||
}
|
||||
const resultElse = await fn.apply(ctx, argsElse);
|
||||
if (result === exports.UNKNOWN)
|
||||
return;
|
||||
return { test: predicate, ifTrue: result, else: resultElse };
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
ConditionalExpression: async function ConditionalExpression(node, walk) {
|
||||
const val = await walk(node.test);
|
||||
if (val && 'value' in val)
|
||||
return val.value ? walk(node.consequent) : walk(node.alternate);
|
||||
if (!this.computeBranches)
|
||||
return;
|
||||
const thenValue = await walk(node.consequent);
|
||||
if (!thenValue || 'wildcards' in thenValue || 'test' in thenValue)
|
||||
return;
|
||||
const elseValue = await walk(node.alternate);
|
||||
if (!elseValue || 'wildcards' in elseValue || 'test' in elseValue)
|
||||
return;
|
||||
return {
|
||||
test: node.test,
|
||||
ifTrue: thenValue.value,
|
||||
else: elseValue.value,
|
||||
};
|
||||
},
|
||||
ExpressionStatement: async function ExpressionStatement(node, walk) {
|
||||
return walk(node.expression);
|
||||
},
|
||||
Identifier: async function Identifier(node, _walk) {
|
||||
if (Object.hasOwnProperty.call(this.vars, node.name))
|
||||
return this.vars[node.name];
|
||||
return undefined;
|
||||
},
|
||||
Literal: async function Literal(node, _walk) {
|
||||
return { value: node.value };
|
||||
},
|
||||
MemberExpression: async function MemberExpression(node, walk) {
|
||||
const obj = await walk(node.object);
|
||||
if (!obj || 'test' in obj || typeof obj.value === 'function') {
|
||||
return undefined;
|
||||
}
|
||||
if (node.property.type === 'Identifier') {
|
||||
if (typeof obj.value === 'string' && node.property.name === 'concat') {
|
||||
return {
|
||||
value: {
|
||||
[exports.FUNCTION]: (...args) => obj.value.concat(args),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (typeof obj.value === 'object' && obj.value !== null) {
|
||||
const objValue = obj.value;
|
||||
if (node.computed) {
|
||||
// See if we can compute the computed property
|
||||
const computedProp = await walk(node.property);
|
||||
if (computedProp && 'value' in computedProp && computedProp.value) {
|
||||
const val = objValue[computedProp.value];
|
||||
if (val === exports.UNKNOWN)
|
||||
return undefined;
|
||||
return { value: val };
|
||||
}
|
||||
// Special case for empty object
|
||||
if (!objValue[exports.UNKNOWN] && Object.keys(obj).length === 0) {
|
||||
return { value: undefined };
|
||||
}
|
||||
}
|
||||
else if (node.property.name in objValue) {
|
||||
const val = objValue[node.property.name];
|
||||
if (val === exports.UNKNOWN)
|
||||
return undefined;
|
||||
return { value: val };
|
||||
}
|
||||
else if (objValue[exports.UNKNOWN])
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
return { value: undefined };
|
||||
}
|
||||
}
|
||||
const prop = await walk(node.property);
|
||||
if (!prop || 'test' in prop)
|
||||
return undefined;
|
||||
if (typeof obj.value === 'object' && obj.value !== null) {
|
||||
//@ts-ignore
|
||||
if (prop.value in obj.value) {
|
||||
//@ts-ignore
|
||||
const val = obj.value[prop.value];
|
||||
if (val === exports.UNKNOWN)
|
||||
return undefined;
|
||||
return { value: val };
|
||||
}
|
||||
//@ts-ignore
|
||||
else if (obj.value[exports.UNKNOWN]) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return { value: undefined };
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
MetaProperty: async function MetaProperty(node) {
|
||||
if (node.meta.name === 'import' && node.property.name === 'meta')
|
||||
return { value: this.vars['import.meta'] };
|
||||
return undefined;
|
||||
},
|
||||
NewExpression: async function NewExpression(node, walk) {
|
||||
// new URL('./local', parent)
|
||||
const cls = await walk(node.callee);
|
||||
if (cls && 'value' in cls && cls.value === URL && node.arguments.length) {
|
||||
const arg = await walk(node.arguments[0]);
|
||||
if (!arg)
|
||||
return undefined;
|
||||
let parent = null;
|
||||
if (node.arguments[1]) {
|
||||
parent = await walk(node.arguments[1]);
|
||||
if (!parent || !('value' in parent))
|
||||
return undefined;
|
||||
}
|
||||
if ('value' in arg) {
|
||||
if (parent) {
|
||||
try {
|
||||
return { value: new URL(arg.value, parent.value) };
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return { value: new URL(arg.value) };
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const test = arg.test;
|
||||
if (parent) {
|
||||
try {
|
||||
return {
|
||||
test,
|
||||
ifTrue: new URL(arg.ifTrue, parent.value),
|
||||
else: new URL(arg.else, parent.value),
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return {
|
||||
test,
|
||||
ifTrue: new URL(arg.ifTrue),
|
||||
else: new URL(arg.else),
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
ObjectExpression: async function ObjectExpression(node, walk) {
|
||||
const obj = {};
|
||||
for (let i = 0; i < node.properties.length; i++) {
|
||||
const prop = node.properties[i];
|
||||
const keyValue = prop.computed
|
||||
? walk(prop.key)
|
||||
: prop.key && { value: prop.key.name || prop.key.value };
|
||||
if (!keyValue || 'test' in keyValue)
|
||||
return;
|
||||
const value = await walk(prop.value);
|
||||
if (!value || 'test' in value)
|
||||
return;
|
||||
//@ts-ignore
|
||||
if (value.value === exports.UNKNOWN)
|
||||
return;
|
||||
//@ts-ignore
|
||||
obj[keyValue.value] = value.value;
|
||||
}
|
||||
return { value: obj };
|
||||
},
|
||||
SequenceExpression: async function SequenceExpression(node, walk) {
|
||||
if ('expressions' in node &&
|
||||
node.expressions.length === 2 &&
|
||||
node.expressions[0].type === 'Literal' &&
|
||||
node.expressions[0].value === 0 &&
|
||||
node.expressions[1].type === 'MemberExpression') {
|
||||
const arg = await walk(node.expressions[1]);
|
||||
return arg;
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
TemplateLiteral: async function TemplateLiteral(node, walk) {
|
||||
let val = { value: '' };
|
||||
for (var i = 0; i < node.expressions.length; i++) {
|
||||
if ('value' in val) {
|
||||
val.value += node.quasis[i].value.cooked;
|
||||
}
|
||||
else {
|
||||
val.ifTrue += node.quasis[i].value.cooked;
|
||||
val.else += node.quasis[i].value.cooked;
|
||||
}
|
||||
let exprValue = await walk(node.expressions[i]);
|
||||
if (!exprValue) {
|
||||
if (!this.computeBranches)
|
||||
return undefined;
|
||||
exprValue = { value: exports.WILDCARD, wildcards: [node.expressions[i]] };
|
||||
}
|
||||
if ('value' in exprValue) {
|
||||
if ('value' in val) {
|
||||
val.value += exprValue.value;
|
||||
if (exprValue.wildcards)
|
||||
val.wildcards = [...(val.wildcards || []), ...exprValue.wildcards];
|
||||
}
|
||||
else {
|
||||
if (exprValue.wildcards)
|
||||
return;
|
||||
val.ifTrue += exprValue.value;
|
||||
val.else += exprValue.value;
|
||||
}
|
||||
}
|
||||
else if ('value' in val) {
|
||||
if ('wildcards' in val) {
|
||||
// only support a single branch in a template
|
||||
return;
|
||||
}
|
||||
val = {
|
||||
test: exprValue.test,
|
||||
ifTrue: val.value + exprValue.ifTrue,
|
||||
else: val.value + exprValue.else,
|
||||
};
|
||||
}
|
||||
else {
|
||||
// only support a single branch in a template
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ('value' in val) {
|
||||
val.value += node.quasis[i].value.cooked;
|
||||
}
|
||||
else {
|
||||
val.ifTrue += node.quasis[i].value.cooked;
|
||||
val.else += node.quasis[i].value.cooked;
|
||||
}
|
||||
return val;
|
||||
},
|
||||
ThisExpression: async function ThisExpression(_node, _walk) {
|
||||
if (Object.hasOwnProperty.call(this.vars, 'this'))
|
||||
return this.vars['this'];
|
||||
return undefined;
|
||||
},
|
||||
UnaryExpression: async function UnaryExpression(node, walk) {
|
||||
const val = await walk(node.argument);
|
||||
if (!val)
|
||||
return undefined;
|
||||
if ('value' in val && 'wildcards' in val === false) {
|
||||
if (node.operator === '+')
|
||||
return { value: +val.value };
|
||||
if (node.operator === '-')
|
||||
return { value: -val.value };
|
||||
if (node.operator === '~')
|
||||
return { value: ~val.value };
|
||||
if (node.operator === '!')
|
||||
return { value: !val.value };
|
||||
}
|
||||
else if ('test' in val && 'wildcards' in val === false) {
|
||||
if (node.operator === '+')
|
||||
return { test: val.test, ifTrue: +val.ifTrue, else: +val.else };
|
||||
if (node.operator === '-')
|
||||
return { test: val.test, ifTrue: -val.ifTrue, else: -val.else };
|
||||
if (node.operator === '~')
|
||||
return { test: val.test, ifTrue: ~val.ifTrue, else: ~val.else };
|
||||
if (node.operator === '!')
|
||||
return { test: val.test, ifTrue: !val.ifTrue, else: !val.else };
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
visitors.LogicalExpression = visitors.BinaryExpression;
|
||||
1
node_modules/@vercel/nft/out/utils/static-eval.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/static-eval.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@vercel/nft/out/utils/types.js
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/utils/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
node_modules/@vercel/nft/out/utils/types.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
||||
659
node_modules/@vercel/nft/out/utils/wrappers.js
generated
vendored
Normal file
659
node_modules/@vercel/nft/out/utils/wrappers.js
generated
vendored
Normal file
@@ -0,0 +1,659 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.handleWrappers = handleWrappers;
|
||||
const estree_walker_1 = require("estree-walker");
|
||||
function isUndefinedOrVoid(node) {
|
||||
return ((node.type === 'Identifier' && node.name === 'undefined') ||
|
||||
(node.type === 'UnaryExpression' &&
|
||||
node.operator === 'void' &&
|
||||
node.argument.type === 'Literal' &&
|
||||
node.argument.value === 0));
|
||||
}
|
||||
// Wrapper detection pretransforms to enable static analysis
|
||||
function handleWrappers(ast) {
|
||||
// UglifyJS will convert function wrappers into !function(){}
|
||||
let wrapper;
|
||||
if (ast.body.length === 1 &&
|
||||
ast.body[0].type === 'ExpressionStatement' &&
|
||||
ast.body[0].expression.type === 'UnaryExpression' &&
|
||||
ast.body[0].expression.operator === '!' &&
|
||||
ast.body[0].expression.argument.type === 'CallExpression' &&
|
||||
ast.body[0].expression.argument.callee.type === 'FunctionExpression' &&
|
||||
ast.body[0].expression.argument.arguments.length === 1)
|
||||
wrapper = ast.body[0].expression.argument;
|
||||
else if (ast.body.length === 1 &&
|
||||
ast.body[0].type === 'ExpressionStatement' &&
|
||||
ast.body[0].expression.type === 'CallExpression' &&
|
||||
ast.body[0].expression.callee.type === 'FunctionExpression' &&
|
||||
(ast.body[0].expression.arguments.length === 1 ||
|
||||
ast.body[0].expression.arguments.length === 0))
|
||||
wrapper = ast.body[0].expression;
|
||||
else if (ast.body.length === 1 &&
|
||||
ast.body[0].type === 'ExpressionStatement' &&
|
||||
ast.body[0].expression.type === 'AssignmentExpression' &&
|
||||
ast.body[0].expression.left.type === 'MemberExpression' &&
|
||||
ast.body[0].expression.left.object.type === 'Identifier' &&
|
||||
ast.body[0].expression.left.object.name === 'module' &&
|
||||
ast.body[0].expression.left.property.type === 'Identifier' &&
|
||||
ast.body[0].expression.left.property.name === 'exports' &&
|
||||
ast.body[0].expression.right.type === 'CallExpression' &&
|
||||
ast.body[0].expression.right.callee.type === 'FunctionExpression' &&
|
||||
ast.body[0].expression.right.arguments.length === 1)
|
||||
wrapper = ast.body[0].expression.right;
|
||||
if (wrapper) {
|
||||
let browserifyReturn;
|
||||
let webpackModuleObj;
|
||||
// When.js-style AMD wrapper:
|
||||
// (function (define) { 'use strict' define(function (require) { ... }) })
|
||||
// (typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); })
|
||||
// ->
|
||||
// (function (define) { 'use strict' define(function () { ... }) })
|
||||
// (typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); })
|
||||
if (wrapper.arguments[0] &&
|
||||
wrapper.arguments[0].type === 'ConditionalExpression' &&
|
||||
wrapper.arguments[0].test.type === 'LogicalExpression' &&
|
||||
wrapper.arguments[0].test.operator === '&&' &&
|
||||
wrapper.arguments[0].test.left.type === 'BinaryExpression' &&
|
||||
wrapper.arguments[0].test.left.operator === '===' &&
|
||||
wrapper.arguments[0].test.left.left.type === 'UnaryExpression' &&
|
||||
wrapper.arguments[0].test.left.left.operator === 'typeof' &&
|
||||
'name' in wrapper.arguments[0].test.left.left.argument &&
|
||||
wrapper.arguments[0].test.left.left.argument.name === 'define' &&
|
||||
wrapper.arguments[0].test.left.right.type === 'Literal' &&
|
||||
wrapper.arguments[0].test.left.right.value === 'function' &&
|
||||
wrapper.arguments[0].test.right.type === 'MemberExpression' &&
|
||||
wrapper.arguments[0].test.right.object.type === 'Identifier' &&
|
||||
wrapper.arguments[0].test.right.property.type === 'Identifier' &&
|
||||
wrapper.arguments[0].test.right.property.name === 'amd' &&
|
||||
wrapper.arguments[0].test.right.computed === false &&
|
||||
wrapper.arguments[0].alternate.type === 'FunctionExpression' &&
|
||||
wrapper.arguments[0].alternate.params.length === 1 &&
|
||||
wrapper.arguments[0].alternate.params[0].type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body.length === 1 &&
|
||||
wrapper.arguments[0].alternate.body.body[0].type ===
|
||||
'ExpressionStatement' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.type ===
|
||||
'AssignmentExpression' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.type ===
|
||||
'MemberExpression' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.object
|
||||
.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.object
|
||||
.name === 'module' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.property
|
||||
.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.property
|
||||
.name === 'exports' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.computed ===
|
||||
false &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.type ===
|
||||
'CallExpression' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.callee
|
||||
.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.callee
|
||||
.name === wrapper.arguments[0].alternate.params[0].name &&
|
||||
'body' in wrapper.callee &&
|
||||
'body' in wrapper.callee.body &&
|
||||
Array.isArray(wrapper.callee.body.body) &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.arguments
|
||||
.length === 1 &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.arguments[0]
|
||||
.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.arguments[0]
|
||||
.name === 'require') {
|
||||
let body = wrapper.callee.body.body;
|
||||
if (body[0].type === 'ExpressionStatement' &&
|
||||
body[0].expression.type === 'Literal' &&
|
||||
body[0].expression.value === 'use strict') {
|
||||
body = body.slice(1);
|
||||
}
|
||||
if (body.length === 1 &&
|
||||
body[0].type === 'ExpressionStatement' &&
|
||||
body[0].expression.type === 'CallExpression' &&
|
||||
body[0].expression.callee.type === 'Identifier' &&
|
||||
body[0].expression.callee.name ===
|
||||
wrapper.arguments[0].test.right.object.name &&
|
||||
body[0].expression.arguments.length === 1 &&
|
||||
body[0].expression.arguments[0].type === 'FunctionExpression' &&
|
||||
body[0].expression.arguments[0].params.length === 1 &&
|
||||
body[0].expression.arguments[0].params[0].type === 'Identifier' &&
|
||||
body[0].expression.arguments[0].params[0].name === 'require') {
|
||||
const arg = body[0].expression.arguments[0];
|
||||
arg.params = [];
|
||||
try {
|
||||
// @ts-ignore If it doesn't exist that's ok
|
||||
delete arg.scope.declarations.require;
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
// Browserify-style wrapper
|
||||
// (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bugsnag = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({
|
||||
// 1:[function(require,module,exports){
|
||||
// ...code...
|
||||
// },{"external":undefined}], 2: ...
|
||||
// },{},[24])(24)
|
||||
// });
|
||||
// ->
|
||||
// (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bugsnag = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({
|
||||
// 1:[function(require,module,exports){
|
||||
// ...code...
|
||||
// },{"external":undefined}], 2: ...
|
||||
// },{
|
||||
// "external": { exports: require('external') }
|
||||
// },[24])(24)
|
||||
// });
|
||||
else if (wrapper.arguments[0] &&
|
||||
wrapper.arguments[0].type === 'FunctionExpression' &&
|
||||
wrapper.arguments[0].params.length === 0 &&
|
||||
(wrapper.arguments[0].body.body.length === 1 ||
|
||||
(wrapper.arguments[0].body.body.length === 2 &&
|
||||
wrapper.arguments[0].body.body[0].type === 'VariableDeclaration' &&
|
||||
wrapper.arguments[0].body.body[0].declarations.length === 3 &&
|
||||
wrapper.arguments[0].body.body[0].declarations.every((decl) => decl.init === null && decl.id.type === 'Identifier'))) &&
|
||||
wrapper.arguments[0].body.body[wrapper.arguments[0].body.body.length - 1]
|
||||
.type === 'ReturnStatement' &&
|
||||
(browserifyReturn = wrapper.arguments[0].body.body[wrapper.arguments[0].body.body.length - 1]) &&
|
||||
browserifyReturn.argument?.type === 'CallExpression' &&
|
||||
browserifyReturn.argument.arguments.length &&
|
||||
browserifyReturn.argument.arguments.every((arg) => arg && arg.type === 'Literal' && typeof arg.value === 'number') &&
|
||||
browserifyReturn.argument.callee.type === 'CallExpression' &&
|
||||
(browserifyReturn.argument.callee.callee.type === 'FunctionExpression' ||
|
||||
(browserifyReturn.argument.callee.callee.type === 'CallExpression' &&
|
||||
browserifyReturn.argument.callee.callee.callee.type ===
|
||||
'FunctionExpression' &&
|
||||
browserifyReturn.argument.callee.callee.arguments.length === 0)) &&
|
||||
// (dont go deeper into browserify loader internals than this)
|
||||
browserifyReturn.argument.callee.arguments.length === 3 &&
|
||||
browserifyReturn.argument.callee.arguments[0].type ===
|
||||
'ObjectExpression' &&
|
||||
browserifyReturn.argument.callee.arguments[1].type ===
|
||||
'ObjectExpression' &&
|
||||
browserifyReturn.argument.callee.arguments[2].type === 'ArrayExpression') {
|
||||
const modules = browserifyReturn.argument.callee.arguments[0].properties;
|
||||
// verify modules is the expected data structure
|
||||
// in the process, extract external requires
|
||||
const externals = {};
|
||||
if (modules.every((m) => {
|
||||
if (m.type !== 'Property' ||
|
||||
m.computed !== false ||
|
||||
m.key.type !== 'Literal' ||
|
||||
typeof m.key.value !== 'number' ||
|
||||
m.value.type !== 'ArrayExpression' ||
|
||||
m.value.elements.length !== 2 ||
|
||||
!m.value.elements[0] ||
|
||||
!m.value.elements[1] ||
|
||||
m.value.elements[0].type !== 'FunctionExpression' ||
|
||||
m.value.elements[1].type !== 'ObjectExpression') {
|
||||
return false;
|
||||
}
|
||||
// detect externals from undefined moduleMap values
|
||||
const moduleMap = m.value.elements[1].properties;
|
||||
for (const prop of moduleMap) {
|
||||
if (prop.type !== 'Property' ||
|
||||
(prop.value.type !== 'Identifier' &&
|
||||
prop.value.type !== 'Literal' &&
|
||||
!isUndefinedOrVoid(prop.value)) ||
|
||||
!((prop.key.type === 'Literal' &&
|
||||
typeof prop.key.value === 'string') ||
|
||||
prop.key.type === 'Identifier') ||
|
||||
prop.computed) {
|
||||
return false;
|
||||
}
|
||||
if (isUndefinedOrVoid(prop.value)) {
|
||||
if (prop.key.type === 'Identifier') {
|
||||
externals[prop.key.name] = {
|
||||
type: 'Literal',
|
||||
// @ts-ignore start can be undefined
|
||||
start: prop.key.start,
|
||||
// @ts-ignore end can be undefined
|
||||
end: prop.key.end,
|
||||
value: prop.key.name,
|
||||
raw: JSON.stringify(prop.key.name),
|
||||
};
|
||||
}
|
||||
else if (prop.key.type === 'Literal') {
|
||||
externals[String(prop.key.value)] = prop.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
})) {
|
||||
// if we have externals, inline them into the browserify cache for webpack to pick up
|
||||
const externalIds = Object.keys(externals);
|
||||
const cache = browserifyReturn.argument.callee.arguments[1];
|
||||
cache.properties = externalIds.map((ext) => {
|
||||
return {
|
||||
type: 'Property',
|
||||
method: false,
|
||||
shorthand: false,
|
||||
computed: false,
|
||||
kind: 'init',
|
||||
key: externals[ext],
|
||||
value: {
|
||||
type: 'ObjectExpression',
|
||||
properties: [
|
||||
{
|
||||
type: 'Property',
|
||||
kind: 'init',
|
||||
method: false,
|
||||
shorthand: false,
|
||||
computed: false,
|
||||
key: {
|
||||
type: 'Identifier',
|
||||
name: 'exports',
|
||||
},
|
||||
value: {
|
||||
type: 'CallExpression',
|
||||
optional: false,
|
||||
callee: {
|
||||
type: 'Identifier',
|
||||
name: 'require',
|
||||
},
|
||||
arguments: [externals[ext]],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
// UMD wrapper
|
||||
// (function (factory) {
|
||||
// if (typeof module === "object" && typeof module.exports === "object") {
|
||||
// var v = factory(require, exports);
|
||||
// if (v !== undefined) module.exports = v;
|
||||
// }
|
||||
// else if (typeof define === "function" && define.amd) {
|
||||
// define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory);
|
||||
// }
|
||||
// })(function (require, exports) {
|
||||
// // ...
|
||||
// }
|
||||
// ->
|
||||
// (function (factory) {
|
||||
// if (typeof module === "object" && typeof module.exports === "object") {
|
||||
// var v = factory(require, exports);
|
||||
// if (v !== undefined) module.exports = v;
|
||||
// }
|
||||
// else if (typeof define === "function" && define.amd) {
|
||||
// define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory);
|
||||
// }
|
||||
// })(function () {
|
||||
// // ...
|
||||
// }
|
||||
else if (wrapper.arguments[0] &&
|
||||
wrapper.arguments[0].type === 'FunctionExpression' &&
|
||||
wrapper.arguments[0].params.length === 2 &&
|
||||
wrapper.arguments[0].params[0].type === 'Identifier' &&
|
||||
wrapper.arguments[0].params[1].type === 'Identifier' &&
|
||||
'body' in wrapper.callee &&
|
||||
'body' in wrapper.callee.body &&
|
||||
Array.isArray(wrapper.callee.body.body) &&
|
||||
wrapper.callee.body.body.length === 1) {
|
||||
const statement = wrapper.callee.body.body[0];
|
||||
if (statement.type === 'IfStatement' &&
|
||||
statement.test.type === 'LogicalExpression' &&
|
||||
statement.test.operator === '&&' &&
|
||||
statement.test.left.type === 'BinaryExpression' &&
|
||||
statement.test.left.left.type === 'UnaryExpression' &&
|
||||
statement.test.left.left.operator === 'typeof' &&
|
||||
statement.test.left.left.argument.type === 'Identifier' &&
|
||||
statement.test.left.left.argument.name === 'module' &&
|
||||
statement.test.left.right.type === 'Literal' &&
|
||||
statement.test.left.right.value === 'object' &&
|
||||
statement.test.right.type === 'BinaryExpression' &&
|
||||
statement.test.right.left.type === 'UnaryExpression' &&
|
||||
statement.test.right.left.operator === 'typeof' &&
|
||||
statement.test.right.left.argument.type === 'MemberExpression' &&
|
||||
statement.test.right.left.argument.object.type === 'Identifier' &&
|
||||
statement.test.right.left.argument.object.name === 'module' &&
|
||||
statement.test.right.left.argument.property.type === 'Identifier' &&
|
||||
statement.test.right.left.argument.property.name === 'exports' &&
|
||||
statement.test.right.right.type === 'Literal' &&
|
||||
statement.test.right.right.value === 'object' &&
|
||||
statement.consequent.type === 'BlockStatement' &&
|
||||
statement.consequent.body.length > 0) {
|
||||
let callSite;
|
||||
if (statement.consequent.body[0].type === 'VariableDeclaration' &&
|
||||
statement.consequent.body[0].declarations[0].init &&
|
||||
statement.consequent.body[0].declarations[0].init.type ===
|
||||
'CallExpression')
|
||||
callSite = statement.consequent.body[0].declarations[0].init;
|
||||
else if (statement.consequent.body[0].type === 'ExpressionStatement' &&
|
||||
statement.consequent.body[0].expression.type === 'CallExpression')
|
||||
callSite = statement.consequent.body[0].expression;
|
||||
else if (statement.consequent.body[0].type === 'ExpressionStatement' &&
|
||||
statement.consequent.body[0].expression.type ===
|
||||
'AssignmentExpression' &&
|
||||
statement.consequent.body[0].expression.operator === '=' &&
|
||||
statement.consequent.body[0].expression.right.type ===
|
||||
'CallExpression')
|
||||
callSite = statement.consequent.body[0].expression.right;
|
||||
if (callSite &&
|
||||
callSite.callee.type === 'Identifier' &&
|
||||
'params' in wrapper.callee &&
|
||||
wrapper.callee.params.length > 0 &&
|
||||
'name' in wrapper.callee.params[0] &&
|
||||
callSite.callee.name === wrapper.callee.params[0].name &&
|
||||
callSite.arguments.length === 2 &&
|
||||
callSite.arguments[0].type === 'Identifier' &&
|
||||
callSite.arguments[0].name === 'require' &&
|
||||
callSite.arguments[1].type === 'Identifier' &&
|
||||
callSite.arguments[1].name === 'exports') {
|
||||
const funcExpression = wrapper.arguments[0];
|
||||
funcExpression.params = [];
|
||||
try {
|
||||
// @ts-ignore If scope doesn't exist that's ok
|
||||
const scope = funcExpression.scope;
|
||||
delete scope.declarations.require;
|
||||
delete scope.declarations.exports;
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
// Webpack wrapper
|
||||
//
|
||||
// module.exports = (function(e) {
|
||||
// var t = {};
|
||||
// function r(n) { /*...*/ }
|
||||
// })([
|
||||
// function (e, t) {
|
||||
// e.exports = require("fs");
|
||||
// },
|
||||
// function(e, t, r) {
|
||||
// const n = r(0);
|
||||
// const ns = r.n(n);
|
||||
// ns.a.export;
|
||||
// }
|
||||
// ]);
|
||||
// ->
|
||||
// module.exports = (function(e) {
|
||||
// var t = {};
|
||||
// function r(n) { /*...*/ }
|
||||
// })([
|
||||
// function (e, t) {
|
||||
// e.exports = require("fs");
|
||||
// },
|
||||
// function(e, t, r) {
|
||||
// const n = require("fs");
|
||||
// const ns = Object.assign(a => n, { a: n });
|
||||
// }
|
||||
// ]);
|
||||
//
|
||||
// OR !(function (){})() | (function () {})() variants
|
||||
// OR { 0: function..., 'some-id': function () ... } registry variants
|
||||
// OR Webpack 5 non-runtime variant:
|
||||
//
|
||||
// (function() {
|
||||
// var exports = {};
|
||||
// exports.id = 223;
|
||||
// exports.ids = [223];
|
||||
// exports.modules = { ... };
|
||||
// var __webpack_require__ = require("../../webpack-runtime.js");
|
||||
// ...
|
||||
// })()
|
||||
//
|
||||
else if ((wrapper.callee.type === 'FunctionExpression' &&
|
||||
wrapper.callee.body.body.length > 2 &&
|
||||
wrapper.callee.body.body[0].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[0].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[0].declarations[0].type ===
|
||||
'VariableDeclarator' &&
|
||||
wrapper.callee.body.body[0].declarations[0].id.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[0].declarations[0].init &&
|
||||
((wrapper.callee.body.body[0].declarations[0].init.type ===
|
||||
'ObjectExpression' &&
|
||||
wrapper.callee.body.body[0].declarations[0].init.properties.length ===
|
||||
0) ||
|
||||
(wrapper.callee.body.body[0].declarations[0].init.type ===
|
||||
'CallExpression' &&
|
||||
wrapper.callee.body.body[0].declarations[0].init.arguments
|
||||
.length === 1)) &&
|
||||
((wrapper.callee.body.body[1] &&
|
||||
wrapper.callee.body.body[1].type === 'FunctionDeclaration' &&
|
||||
wrapper.callee.body.body[1].params.length === 1 &&
|
||||
wrapper.callee.body.body[1].body.body.length >= 3) ||
|
||||
(wrapper.callee.body.body[2] &&
|
||||
wrapper.callee.body.body[2].type === 'FunctionDeclaration' &&
|
||||
wrapper.callee.body.body[2].params.length === 1 &&
|
||||
wrapper.callee.body.body[2].body.body.length >= 3)) &&
|
||||
wrapper.arguments[0] &&
|
||||
((wrapper.arguments[0].type === 'ArrayExpression' &&
|
||||
(webpackModuleObj = wrapper.arguments[0]) &&
|
||||
wrapper.arguments[0].elements.length > 0 &&
|
||||
wrapper.arguments[0].elements.every((el) => el && el.type === 'FunctionExpression')) ||
|
||||
(wrapper.arguments[0].type === 'ObjectExpression' &&
|
||||
(webpackModuleObj = wrapper.arguments[0]) &&
|
||||
wrapper.arguments[0].properties &&
|
||||
wrapper.arguments[0].properties.length > 0 &&
|
||||
wrapper.arguments[0].properties.every((prop) => prop &&
|
||||
prop.type === 'Property' &&
|
||||
!prop.computed &&
|
||||
prop.key &&
|
||||
prop.key.type === 'Literal' &&
|
||||
(typeof prop.key.value === 'string' ||
|
||||
typeof prop.key.value === 'number') &&
|
||||
prop.value &&
|
||||
prop.value.type === 'FunctionExpression')))) ||
|
||||
(wrapper.arguments.length === 0 &&
|
||||
wrapper.callee.type === 'FunctionExpression' &&
|
||||
wrapper.callee.params.length === 0 &&
|
||||
wrapper.callee.body.type === 'BlockStatement' &&
|
||||
wrapper.callee.body.body.length > 5 &&
|
||||
wrapper.callee.body.body[0].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[0].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[0].declarations[0].id.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[1].type === 'ExpressionStatement' &&
|
||||
wrapper.callee.body.body[1].expression.type ===
|
||||
'AssignmentExpression' &&
|
||||
wrapper.callee.body.body[2].type === 'ExpressionStatement' &&
|
||||
wrapper.callee.body.body[2].expression.type ===
|
||||
'AssignmentExpression' &&
|
||||
wrapper.callee.body.body[3].type === 'ExpressionStatement' &&
|
||||
wrapper.callee.body.body[3].expression.type ===
|
||||
'AssignmentExpression' &&
|
||||
wrapper.callee.body.body[3].expression.left.type ===
|
||||
'MemberExpression' &&
|
||||
wrapper.callee.body.body[3].expression.left.object.type ===
|
||||
'Identifier' &&
|
||||
wrapper.callee.body.body[3].expression.left.object.name ===
|
||||
wrapper.callee.body.body[0].declarations[0].id.name &&
|
||||
wrapper.callee.body.body[3].expression.left.property.type ===
|
||||
'Identifier' &&
|
||||
wrapper.callee.body.body[3].expression.left.property.name ===
|
||||
'modules' &&
|
||||
wrapper.callee.body.body[3].expression.right.type ===
|
||||
'ObjectExpression' &&
|
||||
wrapper.callee.body.body[3].expression.right.properties.every((prop) => prop &&
|
||||
prop.type === 'Property' &&
|
||||
!prop.computed &&
|
||||
prop.key &&
|
||||
prop.key.type === 'Literal' &&
|
||||
(typeof prop.key.value === 'string' ||
|
||||
typeof prop.key.value === 'number') &&
|
||||
prop.value &&
|
||||
prop.value.type === 'FunctionExpression') &&
|
||||
(webpackModuleObj = wrapper.callee.body.body[3].expression.right) &&
|
||||
((wrapper.callee.body.body[4].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[4].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[4].declarations[0].init &&
|
||||
wrapper.callee.body.body[4].declarations[0].init.type ===
|
||||
'CallExpression' &&
|
||||
wrapper.callee.body.body[4].declarations[0].init.callee.type ===
|
||||
'Identifier' &&
|
||||
wrapper.callee.body.body[4].declarations[0].init.callee.name ===
|
||||
'require') ||
|
||||
(wrapper.callee.body.body[5].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[5].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[5].declarations[0].init &&
|
||||
wrapper.callee.body.body[5].declarations[0].init.type ===
|
||||
'CallExpression' &&
|
||||
wrapper.callee.body.body[5].declarations[0].init.callee.type ===
|
||||
'Identifier' &&
|
||||
wrapper.callee.body.body[5].declarations[0].init.callee.name ===
|
||||
'require')))) {
|
||||
const externalMap = new Map();
|
||||
let modules;
|
||||
if (webpackModuleObj.type === 'ArrayExpression')
|
||||
modules = webpackModuleObj.elements.filter((el) => el?.type === 'FunctionExpression').map((el, i) => [String(i), el]);
|
||||
// Structure already checked in conditional above
|
||||
else
|
||||
modules = webpackModuleObj.properties.map((prop) => [
|
||||
String(prop.key.value),
|
||||
prop.value,
|
||||
]);
|
||||
for (const [k, m] of modules) {
|
||||
const statement = m.body.body.length === 1
|
||||
? m.body.body[0]
|
||||
: (m.body.body.length === 2 ||
|
||||
(m.body.body.length === 3 &&
|
||||
m.body.body[2].type === 'EmptyStatement')) &&
|
||||
m.body.body[0].type === 'ExpressionStatement' &&
|
||||
m.body.body[0].expression.type === 'Literal' &&
|
||||
m.body.body[0].expression.value === 'use strict'
|
||||
? m.body.body[1]
|
||||
: null;
|
||||
if (statement &&
|
||||
statement.type === 'ExpressionStatement' &&
|
||||
statement.expression.type === 'AssignmentExpression' &&
|
||||
statement.expression.operator === '=' &&
|
||||
statement.expression.left.type === 'MemberExpression' &&
|
||||
statement.expression.left.object.type === 'Identifier' &&
|
||||
'params' in m &&
|
||||
m.params.length > 0 &&
|
||||
'name' in m.params[0] &&
|
||||
statement.expression.left.object.name === m.params[0].name &&
|
||||
statement.expression.left.property.type === 'Identifier' &&
|
||||
statement.expression.left.property.name === 'exports' &&
|
||||
statement.expression.right.type === 'CallExpression' &&
|
||||
statement.expression.right.callee.type === 'Identifier' &&
|
||||
statement.expression.right.callee.name === 'require' &&
|
||||
statement.expression.right.arguments.length === 1 &&
|
||||
statement.expression.right.arguments[0].type === 'Literal') {
|
||||
externalMap.set(k, statement.expression.right.arguments[0].value);
|
||||
}
|
||||
}
|
||||
for (const [, m] of modules) {
|
||||
if ('params' in m &&
|
||||
m.params.length === 3 &&
|
||||
m.params[2].type === 'Identifier') {
|
||||
const assignedVars = new Map();
|
||||
(0, estree_walker_1.walk)(m.body, {
|
||||
enter(_node, _maybeParent) {
|
||||
const node = _node;
|
||||
const maybeParent = _maybeParent;
|
||||
if (node.type === 'CallExpression' &&
|
||||
node.callee.type === 'Identifier' &&
|
||||
'name' in m.params[2] &&
|
||||
node.callee.name === m.params[2].name &&
|
||||
node.arguments.length === 1 &&
|
||||
node.arguments[0].type === 'Literal') {
|
||||
const externalId = externalMap.get(String(node.arguments[0].value));
|
||||
if (externalId) {
|
||||
const replacement = {
|
||||
type: 'CallExpression',
|
||||
optional: false,
|
||||
callee: {
|
||||
type: 'Identifier',
|
||||
name: 'require',
|
||||
},
|
||||
arguments: [
|
||||
{
|
||||
type: 'Literal',
|
||||
value: externalId,
|
||||
},
|
||||
],
|
||||
};
|
||||
const parent = maybeParent;
|
||||
if ('right' in parent && parent.right === node) {
|
||||
parent.right = replacement;
|
||||
}
|
||||
else if ('left' in parent && parent.left === node) {
|
||||
parent.left = replacement;
|
||||
}
|
||||
else if ('object' in parent && parent.object === node) {
|
||||
parent.object = replacement;
|
||||
}
|
||||
else if ('callee' in parent && parent.callee === node) {
|
||||
parent.callee = replacement;
|
||||
}
|
||||
else if ('arguments' in parent &&
|
||||
parent.arguments.some((arg) => arg === node)) {
|
||||
parent.arguments = parent.arguments.map((arg) => arg === node ? replacement : arg);
|
||||
}
|
||||
else if ('init' in parent && parent.init === node) {
|
||||
if (parent.type === 'VariableDeclarator' &&
|
||||
parent.id.type === 'Identifier')
|
||||
assignedVars.set(parent.id.name, externalId);
|
||||
parent.init = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.type === 'CallExpression' &&
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'Identifier' &&
|
||||
'name' in m.params[2] &&
|
||||
node.callee.object.name === m.params[2].name &&
|
||||
node.callee.property.type === 'Identifier' &&
|
||||
node.callee.property.name === 'n' &&
|
||||
node.arguments.length === 1 &&
|
||||
node.arguments[0].type === 'Identifier') {
|
||||
if (maybeParent &&
|
||||
'init' in maybeParent &&
|
||||
maybeParent.init === node) {
|
||||
const req = node.arguments[0];
|
||||
const callExpression = {
|
||||
type: 'CallExpression',
|
||||
optional: false,
|
||||
callee: {
|
||||
type: 'MemberExpression',
|
||||
computed: false,
|
||||
optional: false,
|
||||
object: {
|
||||
type: 'Identifier',
|
||||
name: 'Object',
|
||||
},
|
||||
property: {
|
||||
type: 'Identifier',
|
||||
name: 'assign',
|
||||
},
|
||||
},
|
||||
arguments: [
|
||||
{
|
||||
type: 'ArrowFunctionExpression',
|
||||
expression: true,
|
||||
params: [],
|
||||
body: req,
|
||||
},
|
||||
{
|
||||
type: 'ObjectExpression',
|
||||
properties: [
|
||||
{
|
||||
type: 'Property',
|
||||
kind: 'init',
|
||||
method: false,
|
||||
computed: false,
|
||||
shorthand: false,
|
||||
key: {
|
||||
type: 'Identifier',
|
||||
name: 'a',
|
||||
},
|
||||
value: req,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
maybeParent.init = callExpression;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/utils/wrappers.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/wrappers.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user