initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

8
node_modules/@vercel/nft/out/analyze.d.ts generated vendored Normal file
View 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>;

887
node_modules/@vercel/nft/out/analyze.js generated vendored Normal file
View File

@@ -0,0 +1,887 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const estree_walker_1 = require("estree-walker");
const pluginutils_1 = require("@rollup/pluginutils");
const static_eval_1 = require("./utils/static-eval");
const acorn_1 = require("acorn");
const bindings_1 = __importDefault(require("bindings"));
const ast_helpers_1 = require("./utils/ast-helpers");
const glob_1 = __importDefault(require("glob"));
const get_package_base_1 = require("./utils/get-package-base");
const binary_locators_1 = require("./utils/binary-locators");
const interop_require_1 = require("./utils/interop-require");
const special_cases_1 = __importDefault(require("./utils/special-cases"));
const resolve_dependency_js_1 = __importDefault(require("./resolve-dependency.js"));
//@ts-ignore
const node_gyp_build_1 = __importDefault(require("node-gyp-build"));
//@ts-ignore
const node_pre_gyp_1 = __importDefault(require("@mapbox/node-pre-gyp"));
const url_1 = require("url");
// Note: these should be deprecated over time as they ship in Acorn core
const acorn = acorn_1.Parser.extend(
//require("acorn-class-fields"),
//require("acorn-static-class-features"),
//require("acorn-private-class-elements")
);
const os_1 = __importDefault(require("os"));
const wrappers_1 = require("./utils/wrappers");
const resolve_from_1 = __importDefault(require("resolve-from"));
const staticProcess = {
cwd: () => {
return cwd;
},
env: {
NODE_ENV: static_eval_1.UNKNOWN,
[static_eval_1.UNKNOWN]: true
},
[static_eval_1.UNKNOWN]: true
};
// unique symbol value to identify express instance in static analysis
const EXPRESS_SET = Symbol();
const EXPRESS_ENGINE = Symbol();
const NBIND_INIT = Symbol();
const SET_ROOT_DIR = Symbol();
const PKG_INFO = Symbol();
const FS_FN = Symbol();
const FS_DIR_FN = Symbol();
const BINDINGS = Symbol();
const NODE_GYP_BUILD = Symbol();
const fsSymbols = {
access: FS_FN,
accessSync: FS_FN,
createReadStream: FS_FN,
exists: FS_FN,
existsSync: FS_FN,
fstat: FS_FN,
fstatSync: FS_FN,
lstat: FS_FN,
lstatSync: FS_FN,
open: FS_FN,
readdir: FS_DIR_FN,
readdirSync: FS_DIR_FN,
readFile: FS_FN,
readFileSync: FS_FN,
stat: FS_FN,
statSync: FS_FN
};
const fsExtraSymbols = {
...fsSymbols,
pathExists: FS_FN,
pathExistsSync: FS_FN,
readJson: FS_FN,
readJSON: FS_FN,
readJsonSync: FS_FN,
readJSONSync: FS_FN,
};
const staticModules = Object.assign(Object.create(null), {
bindings: {
default: BINDINGS
},
express: {
default: function () {
return {
[static_eval_1.UNKNOWN]: true,
set: EXPRESS_SET,
engine: EXPRESS_ENGINE
};
}
},
fs: {
default: fsSymbols,
...fsSymbols
},
'fs-extra': {
default: fsExtraSymbols,
...fsExtraSymbols
},
'graceful-fs': {
default: fsSymbols,
...fsSymbols
},
process: {
default: staticProcess,
...staticProcess
},
// populated below
path: {
default: {}
},
os: {
default: os_1.default,
...os_1.default
},
'@mapbox/node-pre-gyp': {
default: node_pre_gyp_1.default,
...node_pre_gyp_1.default
},
'node-pre-gyp': binary_locators_1.pregyp,
'node-pre-gyp/lib/pre-binding': binary_locators_1.pregyp,
'node-pre-gyp/lib/pre-binding.js': binary_locators_1.pregyp,
'node-gyp-build': {
default: NODE_GYP_BUILD
},
'nbind': {
init: NBIND_INIT,
default: {
init: NBIND_INIT
}
},
'resolve-from': {
default: resolve_from_1.default
},
'strong-globalize': {
default: {
SetRootDir: SET_ROOT_DIR
},
SetRootDir: SET_ROOT_DIR
},
'pkginfo': {
default: PKG_INFO
}
});
const globalBindings = {
// Support for require calls generated from `import` statements by babel
_interopRequireDefault: interop_require_1.normalizeDefaultRequire,
_interopRequireWildcard: interop_require_1.normalizeWildcardRequire,
// Support for require calls generated from `import` statements by tsc
__importDefault: interop_require_1.normalizeDefaultRequire,
__importStar: interop_require_1.normalizeWildcardRequire,
MONGOOSE_DRIVER_PATH: undefined,
URL: url_1.URL,
Object: {
assign: Object.assign
}
};
globalBindings.global = globalBindings.GLOBAL = globalBindings.globalThis = globalBindings;
// call expression triggers
const TRIGGER = Symbol();
binary_locators_1.pregyp.find[TRIGGER] = true;
const staticPath = staticModules.path;
Object.keys(path_1.default).forEach(name => {
const pathFn = path_1.default[name];
if (typeof pathFn === 'function') {
const fn = function mockPath() {
return pathFn.apply(mockPath, arguments);
};
fn[TRIGGER] = true;
staticPath[name] = staticPath.default[name] = fn;
}
else {
staticPath[name] = staticPath.default[name] = pathFn;
}
});
// overload path.resolve to support custom cwd
staticPath.resolve = staticPath.default.resolve = function (...args) {
return path_1.default.resolve.apply(this, [cwd, ...args]);
};
staticPath.resolve[TRIGGER] = true;
const excludeAssetExtensions = new Set(['.h', '.cmake', '.c', '.cpp']);
const excludeAssetFiles = new Set(['CHANGELOG.md', 'README.md', 'readme.md', 'changelog.md']);
let cwd;
const absoluteRegEx = /^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;
function isAbsolutePathOrUrl(str) {
if (str instanceof url_1.URL)
return str.protocol === 'file:';
if (typeof str === 'string') {
if (str.startsWith('file:')) {
try {
new url_1.URL(str);
return true;
}
catch {
return false;
}
}
return absoluteRegEx.test(str);
}
return false;
}
const BOUND_REQUIRE = Symbol();
const repeatGlobRegEx = /([\/\\]\*\*[\/\\]\*)+/g;
;
async function analyze(id, code, job) {
const assets = new Set();
const deps = new Set();
const imports = new Set();
const dir = path_1.default.dirname(id);
// if (typeof options.production === 'boolean' && staticProcess.env.NODE_ENV === UNKNOWN)
// staticProcess.env.NODE_ENV = options.production ? 'production' : 'dev';
cwd = job.cwd;
const pkgBase = (0, get_package_base_1.getPackageBase)(id);
const emitAssetDirectory = (wildcardPath) => {
if (!job.analysis.emitGlobs)
return;
const wildcardIndex = wildcardPath.indexOf(static_eval_1.WILDCARD);
const dirIndex = wildcardIndex === -1 ? wildcardPath.length : wildcardPath.lastIndexOf(path_1.default.sep, wildcardIndex);
const assetDirPath = wildcardPath.substring(0, dirIndex);
const patternPath = wildcardPath.slice(dirIndex);
const wildcardPattern = patternPath.replace(static_eval_1.wildcardRegEx, (_match, index) => {
return patternPath[index - 1] === path_1.default.sep ? '**/*' : '*';
}).replace(repeatGlobRegEx, '/**/*') || '/**/*';
if (job.ignoreFn(path_1.default.relative(job.base, assetDirPath + wildcardPattern)))
return;
assetEmissionPromises = assetEmissionPromises.then(async () => {
if (job.log)
console.log('Globbing ' + assetDirPath + wildcardPattern);
const files = (await new Promise((resolve, reject) => (0, glob_1.default)(assetDirPath + wildcardPattern, { mark: true, ignore: assetDirPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files))));
files
.filter(name => !excludeAssetExtensions.has(path_1.default.extname(name)) &&
!excludeAssetFiles.has(path_1.default.basename(name)) &&
!name.endsWith('/'))
.forEach(file => assets.add(file));
});
};
let assetEmissionPromises = Promise.resolve();
// remove shebang
code = code.replace(/^#![^\n\r]*[\r\n]/, '');
let ast;
let isESM = false;
try {
ast = acorn.parse(code, { ecmaVersion: 'latest', allowReturnOutsideFunction: true });
isESM = false;
}
catch (e) {
const isModule = e && e.message && e.message.includes('sourceType: module');
if (!isModule) {
job.warnings.add(new Error(`Failed to parse ${id} as script:\n${e && e.message}`));
}
}
//@ts-ignore
if (!ast) {
try {
ast = acorn.parse(code, { ecmaVersion: 'latest', sourceType: 'module', allowAwaitOutsideFunction: true });
isESM = true;
}
catch (e) {
job.warnings.add(new Error(`Failed to parse ${id} as module:\n${e && e.message}`));
// Parser errors just skip analysis
return { assets, deps, imports, isESM: false };
}
}
const importMetaUrl = (0, url_1.pathToFileURL)(id).href;
const knownBindings = Object.assign(Object.create(null), {
__dirname: {
shadowDepth: 0,
value: { value: path_1.default.resolve(id, '..') }
},
__filename: {
shadowDepth: 0,
value: { value: id }
},
process: {
shadowDepth: 0,
value: { value: staticProcess }
}
});
if (!isESM || job.mixedModules) {
knownBindings.require = {
shadowDepth: 0,
value: {
value: {
[static_eval_1.FUNCTION](specifier) {
deps.add(specifier);
const m = staticModules[specifier.startsWith('node:') ? specifier.slice(5) : specifier];
return m.default;
},
resolve(specifier) {
return (0, resolve_dependency_js_1.default)(specifier, id, job);
}
}
}
};
knownBindings.require.value.value.resolve[TRIGGER] = true;
}
function setKnownBinding(name, value) {
// require is somewhat special in that we shadow it but don't
// statically analyze it ("known unknown" of sorts)
if (name === 'require')
return;
knownBindings[name] = {
shadowDepth: 0,
value: value
};
}
function getKnownBinding(name) {
const binding = knownBindings[name];
if (binding) {
if (binding.shadowDepth === 0) {
return binding.value;
}
}
return undefined;
}
function hasKnownBindingValue(name) {
const binding = knownBindings[name];
return binding && binding.shadowDepth === 0;
}
if ((isESM || job.mixedModules) && isAst(ast)) {
for (const decl of ast.body) {
if (decl.type === 'ImportDeclaration') {
const source = String(decl.source.value);
deps.add(source);
const staticModule = staticModules[source.startsWith('node:') ? source.slice(5) : source];
if (staticModule) {
for (const impt of decl.specifiers) {
if (impt.type === 'ImportNamespaceSpecifier')
setKnownBinding(impt.local.name, { value: staticModule });
else if (impt.type === 'ImportDefaultSpecifier' && 'default' in staticModule)
setKnownBinding(impt.local.name, { value: staticModule.default });
else if (impt.type === 'ImportSpecifier' && impt.imported.name in staticModule)
setKnownBinding(impt.local.name, { value: staticModule[impt.imported.name] });
}
}
}
else if (decl.type === 'ExportNamedDeclaration' || decl.type === 'ExportAllDeclaration') {
if (decl.source)
deps.add(String(decl.source.value));
}
}
}
async function computePureStaticValue(expr, computeBranches = true) {
const vars = Object.create(null);
Object.keys(globalBindings).forEach(name => {
vars[name] = { value: globalBindings[name] };
});
Object.keys(knownBindings).forEach(name => {
vars[name] = getKnownBinding(name);
});
vars['import.meta'] = { url: importMetaUrl };
// evaluate returns undefined for non-statically-analyzable
const result = await (0, static_eval_1.evaluate)(expr, vars, computeBranches);
return result;
}
// statically determinable leaves are tracked, and inlined when the
// greatest parent statically known leaf computation corresponds to an asset path
let staticChildNode;
let staticChildValue;
// Express engine opt-out
let definedExpressEngines = false;
function emitWildcardRequire(wildcardRequire) {
if (!job.analysis.emitGlobs || !wildcardRequire.startsWith('./') && !wildcardRequire.startsWith('../'))
return;
wildcardRequire = path_1.default.resolve(dir, wildcardRequire);
const wildcardIndex = wildcardRequire.indexOf(static_eval_1.WILDCARD);
const dirIndex = wildcardIndex === -1 ? wildcardRequire.length : wildcardRequire.lastIndexOf(path_1.default.sep, wildcardIndex);
const wildcardDirPath = wildcardRequire.substring(0, dirIndex);
const patternPath = wildcardRequire.slice(dirIndex);
let wildcardPattern = patternPath.replace(static_eval_1.wildcardRegEx, (_match, index) => {
return patternPath[index - 1] === path_1.default.sep ? '**/*' : '*';
}) || '/**/*';
if (!wildcardPattern.endsWith('*'))
wildcardPattern += '?(' + (job.ts ? '.ts|.tsx|' : '') + '.js|.json|.node)';
if (job.ignoreFn(path_1.default.relative(job.base, wildcardDirPath + wildcardPattern)))
return;
assetEmissionPromises = assetEmissionPromises.then(async () => {
if (job.log)
console.log('Globbing ' + wildcardDirPath + wildcardPattern);
const files = (await new Promise((resolve, reject) => (0, glob_1.default)(wildcardDirPath + wildcardPattern, { mark: true, ignore: wildcardDirPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files))));
files
.filter(name => !excludeAssetExtensions.has(path_1.default.extname(name)) &&
!excludeAssetFiles.has(path_1.default.basename(name)) &&
!name.endsWith('/'))
.forEach(file => deps.add(file));
});
}
async function processRequireArg(expression, isImport = false) {
if (expression.type === 'ConditionalExpression') {
await processRequireArg(expression.consequent, isImport);
await processRequireArg(expression.alternate, isImport);
return;
}
if (expression.type === 'LogicalExpression') {
await processRequireArg(expression.left, isImport);
await processRequireArg(expression.right, isImport);
return;
}
let computed = await computePureStaticValue(expression, true);
if (!computed)
return;
if ('value' in computed && typeof computed.value === 'string') {
if (!computed.wildcards)
(isImport ? imports : deps).add(computed.value);
else if (computed.wildcards.length >= 1)
emitWildcardRequire(computed.value);
}
else {
if ('then' in computed && typeof computed.then === 'string')
(isImport ? imports : deps).add(computed.then);
if ('else' in computed && typeof computed.else === 'string')
(isImport ? imports : deps).add(computed.else);
}
}
let scope = (0, pluginutils_1.attachScopes)(ast, 'scope');
if (isAst(ast)) {
(0, wrappers_1.handleWrappers)(ast);
await (0, special_cases_1.default)({ id, ast, emitDependency: path => deps.add(path), emitAsset: path => assets.add(path), emitAssetDirectory, job });
}
async function backtrack(parent, context) {
// computing a static expression outward
// -> compute and backtrack
// Note that `context` can be undefined in `leave()`
if (!staticChildNode)
throw new Error('Internal error: No staticChildNode for backtrack.');
const curStaticValue = await computePureStaticValue(parent, true);
if (curStaticValue) {
if ('value' in curStaticValue && typeof curStaticValue.value !== 'symbol' ||
'then' in curStaticValue && typeof curStaticValue.then !== 'symbol' && typeof curStaticValue.else !== 'symbol') {
staticChildValue = curStaticValue;
staticChildNode = parent;
if (context)
context.skip();
return;
}
}
// no static value -> see if we should emit the asset if it exists
await emitStaticChildAsset();
}
await (0, estree_walker_1.asyncWalk)(ast, {
async enter(_node, _parent) {
const node = _node;
const parent = _parent;
if (node.scope) {
scope = node.scope;
for (const id in node.scope.declarations) {
if (id in knownBindings)
knownBindings[id].shadowDepth++;
}
}
// currently backtracking
if (staticChildNode)
return;
if (!parent)
return;
if (node.type === 'Identifier') {
if ((0, ast_helpers_1.isIdentifierRead)(node, parent) && job.analysis.computeFileReferences) {
let binding;
// detect asset leaf expression triggers (if not already)
// __dirname, __filename
if (typeof (binding = getKnownBinding(node.name)?.value) === 'string' && binding.match(absoluteRegEx) ||
binding && (typeof binding === 'function' || typeof binding === 'object') && binding[TRIGGER]) {
staticChildValue = { value: typeof binding === 'string' ? binding : undefined };
staticChildNode = node;
await backtrack(parent, this);
}
}
}
else if (job.analysis.computeFileReferences && node.type === 'MemberExpression' && node.object.type === 'MetaProperty' && node.object.meta.name === 'import' && node.object.property.name === 'meta' && (node.property.computed ? node.property.value : node.property.name) === 'url') {
// import.meta.url leaf trigger
staticChildValue = { value: importMetaUrl };
staticChildNode = node;
await backtrack(parent, this);
}
else if (node.type === 'ImportExpression') {
await processRequireArg(node.source, true);
return;
}
// Call expression cases and asset triggers
// - fs triggers: fs.readFile(...)
// - require.resolve()
// - bindings()(...)
// - nodegyp()
// - etc.
else if (node.type === 'CallExpression') {
if ((!isESM || job.mixedModules) && node.callee.type === 'Identifier' && node.arguments.length) {
if (node.callee.name === 'require' && knownBindings.require.shadowDepth === 0) {
await processRequireArg(node.arguments[0]);
return;
}
}
else if ((!isESM || job.mixedModules) &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'module' &&
'module' in knownBindings === false &&
node.callee.property.type === 'Identifier' &&
!node.callee.computed &&
node.callee.property.name === 'require' &&
node.arguments.length) {
await processRequireArg(node.arguments[0]);
return;
}
else if ((!isESM || job.mixedModules) &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'require' &&
knownBindings.require.shadowDepth === 0 &&
node.callee.property.type === 'Identifier' &&
!node.callee.computed &&
node.callee.property.name === 'resolve' &&
node.arguments.length) {
await processRequireArg(node.arguments[0]);
return;
}
const calleeValue = job.analysis.evaluatePureExpressions && await computePureStaticValue(node.callee, false);
// if we have a direct pure static function,
// and that function has a [TRIGGER] symbol -> trigger asset emission from it
if (calleeValue && 'value' in calleeValue && typeof calleeValue.value === 'function' && calleeValue.value[TRIGGER] && job.analysis.computeFileReferences) {
staticChildValue = await computePureStaticValue(node, true);
// if it computes, then we start backtracking
if (staticChildValue && parent) {
staticChildNode = node;
await backtrack(parent, this);
}
}
// handle well-known function symbol cases
else if (calleeValue && 'value' in calleeValue && typeof calleeValue.value === 'symbol') {
switch (calleeValue.value) {
// customRequireWrapper('...')
case BOUND_REQUIRE:
if (node.arguments.length === 1 &&
node.arguments[0].type === 'Literal' &&
node.callee.type === 'Identifier' &&
knownBindings.require.shadowDepth === 0) {
await processRequireArg(node.arguments[0]);
}
break;
// require('bindings')(...)
case BINDINGS:
if (node.arguments.length) {
const arg = await computePureStaticValue(node.arguments[0], false);
if (arg && 'value' in arg && arg.value) {
let opts;
if (typeof arg.value === 'object')
opts = arg.value;
else if (typeof arg.value === 'string')
opts = { bindings: arg.value };
if (!opts.path) {
opts.path = true;
}
opts.module_root = pkgBase;
let resolved;
try {
resolved = (0, bindings_1.default)(opts);
}
catch (e) { }
if (resolved) {
staticChildValue = { value: resolved };
staticChildNode = node;
await emitStaticChildAsset();
}
}
}
break;
case NODE_GYP_BUILD:
if (node.arguments.length === 1 && node.arguments[0].type === 'Identifier' &&
node.arguments[0].name === '__dirname' && knownBindings.__dirname.shadowDepth === 0) {
let resolved;
try {
// use installed version of node-gyp-build since resolving
// binaries can differ among versions
const nodeGypBuildPath = (0, resolve_from_1.default)(dir, 'node-gyp-build');
resolved = require(nodeGypBuildPath).path(dir);
}
catch (e) {
try {
resolved = node_gyp_build_1.default.path(dir);
}
catch (e) { }
}
if (resolved) {
staticChildValue = { value: resolved };
staticChildNode = node;
await emitStaticChildAsset();
}
}
break;
// nbind.init(...) -> require('./resolved.node')
case NBIND_INIT:
if (node.arguments.length) {
const arg = await computePureStaticValue(node.arguments[0], false);
if (arg && 'value' in arg && (typeof arg.value === 'string' || typeof arg.value === 'undefined')) {
const bindingInfo = (0, binary_locators_1.nbind)(arg.value);
if (bindingInfo && bindingInfo.path) {
deps.add(path_1.default.relative(dir, bindingInfo.path).replace(/\\/g, '/'));
return this.skip();
}
}
}
break;
// Express templates:
// app.set("view engine", [name]) -> 'name' is a require
case EXPRESS_SET:
if (node.arguments.length === 2 &&
node.arguments[0].type === 'Literal' &&
node.arguments[0].value === 'view engine' &&
!definedExpressEngines) {
await processRequireArg(node.arguments[1]);
return this.skip();
}
break;
// app.engine('name', ...) causes opt-out of express dynamic require
case EXPRESS_ENGINE:
definedExpressEngines = true;
break;
case FS_FN:
case FS_DIR_FN:
if (node.arguments[0] && job.analysis.computeFileReferences) {
staticChildValue = await computePureStaticValue(node.arguments[0], true);
// if it computes, then we start backtracking
if (staticChildValue) {
staticChildNode = node.arguments[0];
if (calleeValue.value === FS_DIR_FN && node.arguments[0].type === 'Identifier' && node.arguments[0].name === '__dirname') {
// Special case `fs.readdirSync(__dirname)` to emit right away
emitAssetDirectory(dir);
}
else {
await backtrack(parent, this);
}
return this.skip();
}
}
break;
// strong globalize (emits intl folder)
case SET_ROOT_DIR:
if (node.arguments[0]) {
const rootDir = await computePureStaticValue(node.arguments[0], false);
if (rootDir && 'value' in rootDir && rootDir.value)
emitAssetDirectory(rootDir.value + '/intl');
return this.skip();
}
break;
// pkginfo - require('pkginfo')(module) -> loads package.json
case PKG_INFO:
let pjsonPath = path_1.default.resolve(id, '../package.json');
const rootPjson = path_1.default.resolve('/package.json');
while (pjsonPath !== rootPjson && (await job.stat(pjsonPath) === null))
pjsonPath = path_1.default.resolve(pjsonPath, '../../package.json');
if (pjsonPath !== rootPjson)
assets.add(pjsonPath);
break;
}
}
}
else if (node.type === 'VariableDeclaration' && parent && !(0, ast_helpers_1.isVarLoop)(parent) && job.analysis.evaluatePureExpressions) {
for (const decl of node.declarations) {
if (!decl.init)
continue;
const computed = await computePureStaticValue(decl.init, true);
if (computed) {
// var known = ...;
if (decl.id.type === 'Identifier') {
setKnownBinding(decl.id.name, computed);
}
// var { known } = ...;
else if (decl.id.type === 'ObjectPattern' && 'value' in computed) {
for (const prop of decl.id.properties) {
if (prop.type !== 'Property' ||
prop.key.type !== 'Identifier' ||
prop.value.type !== 'Identifier' ||
typeof computed.value !== 'object' ||
computed.value === null ||
!(prop.key.name in computed.value))
continue;
setKnownBinding(prop.value.name, { value: computed.value[prop.key.name] });
}
}
if (!('value' in computed) && isAbsolutePathOrUrl(computed.then) && isAbsolutePathOrUrl(computed.else)) {
staticChildValue = computed;
staticChildNode = decl.init;
await emitStaticChildAsset();
}
}
}
}
else if (node.type === 'AssignmentExpression' && parent && !(0, ast_helpers_1.isLoop)(parent) && job.analysis.evaluatePureExpressions) {
if (!hasKnownBindingValue(node.left.name)) {
const computed = await computePureStaticValue(node.right, false);
if (computed && 'value' in computed) {
// var known = ...
if (node.left.type === 'Identifier') {
setKnownBinding(node.left.name, computed);
}
// var { known } = ...
else if (node.left.type === 'ObjectPattern') {
for (const prop of node.left.properties) {
if (prop.type !== 'Property' ||
prop.key.type !== 'Identifier' ||
prop.value.type !== 'Identifier' ||
typeof computed.value !== 'object' ||
computed.value === null ||
!(prop.key.name in computed.value))
continue;
setKnownBinding(prop.value.name, { value: computed.value[prop.key.name] });
}
}
if (isAbsolutePathOrUrl(computed.value)) {
staticChildValue = computed;
staticChildNode = node.right;
await emitStaticChildAsset();
}
}
}
}
// Support require wrappers like function p (x) { ...; var y = require(x); ...; return y; }
else if ((!isESM || job.mixedModules) &&
(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') &&
(node.arguments || node.params)[0] && (node.arguments || node.params)[0].type === 'Identifier') {
let fnName;
let args;
if ((node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') &&
parent &&
parent.type === 'VariableDeclarator' &&
parent.id.type === 'Identifier') {
fnName = parent.id;
args = node.arguments || node.params;
}
else if (node.id) {
fnName = node.id;
args = node.arguments || node.params;
}
if (fnName && node.body.body) {
let requireDecl, returned = false;
for (let i = 0; i < node.body.body.length; i++) {
if (node.body.body[i].type === 'VariableDeclaration' && !requireDecl) {
requireDecl = node.body.body[i].declarations.find((decl) => decl &&
decl.id &&
decl.id.type === 'Identifier' &&
decl.init &&
decl.init.type === 'CallExpression' &&
decl.init.callee.type === 'Identifier' &&
decl.init.callee.name === 'require' &&
knownBindings.require.shadowDepth === 0 &&
decl.init.arguments[0] &&
decl.init.arguments[0].type === 'Identifier' &&
decl.init.arguments[0].name === args[0].name);
}
if (requireDecl &&
node.body.body[i].type === 'ReturnStatement' &&
node.body.body[i].argument &&
node.body.body[i].argument.type === 'Identifier' &&
node.body.body[i].argument.name === requireDecl.id.name) {
returned = true;
break;
}
}
if (returned)
setKnownBinding(fnName.name, { value: BOUND_REQUIRE });
}
}
},
async leave(_node, _parent) {
const node = _node;
const parent = _parent;
if (node.scope) {
if (scope.parent) {
scope = scope.parent;
}
for (const id in node.scope.declarations) {
if (id in knownBindings) {
if (knownBindings[id].shadowDepth > 0)
knownBindings[id].shadowDepth--;
else
delete knownBindings[id];
}
}
}
if (staticChildNode && parent)
await backtrack(parent, this);
}
});
await assetEmissionPromises;
return { assets, deps, imports, isESM };
async function emitAssetPath(assetPath) {
// verify the asset file / directory exists
const wildcardIndex = assetPath.indexOf(static_eval_1.WILDCARD);
const dirIndex = wildcardIndex === -1 ? assetPath.length : assetPath.lastIndexOf(path_1.default.sep, wildcardIndex);
const basePath = assetPath.substring(0, dirIndex);
try {
var stats = await job.stat(basePath);
if (stats === null) {
throw new Error('file not found');
}
}
catch (e) {
return;
}
if (wildcardIndex !== -1 && stats.isFile())
return;
if (stats.isFile()) {
assets.add(assetPath);
}
else if (stats.isDirectory()) {
if (validWildcard(assetPath))
emitAssetDirectory(assetPath);
}
}
function validWildcard(assetPath) {
let wildcardSuffix = '';
if (assetPath.endsWith(path_1.default.sep))
wildcardSuffix = path_1.default.sep;
else if (assetPath.endsWith(path_1.default.sep + static_eval_1.WILDCARD))
wildcardSuffix = path_1.default.sep + static_eval_1.WILDCARD;
else if (assetPath.endsWith(static_eval_1.WILDCARD))
wildcardSuffix = static_eval_1.WILDCARD;
// do not emit __dirname
if (assetPath === dir + wildcardSuffix)
return false;
// do not emit cwd
if (assetPath === cwd + wildcardSuffix)
return false;
// do not emit node_modules
if (assetPath.endsWith(path_1.default.sep + 'node_modules' + wildcardSuffix))
return false;
// do not emit directories above __dirname
if (dir.startsWith(assetPath.slice(0, assetPath.length - wildcardSuffix.length) + path_1.default.sep))
return false;
// do not emit asset directories higher than the node_modules base if a package
if (pkgBase) {
const nodeModulesBase = id.substring(0, id.indexOf(path_1.default.sep + 'node_modules')) + path_1.default.sep + 'node_modules' + path_1.default.sep;
if (!assetPath.startsWith(nodeModulesBase)) {
if (job.log)
console.log('Skipping asset emission of ' + assetPath.replace(static_eval_1.wildcardRegEx, '*') + ' for ' + id + ' as it is outside the package base ' + pkgBase);
return false;
}
}
return true;
}
function resolveAbsolutePathOrUrl(value) {
return value instanceof url_1.URL ? (0, url_1.fileURLToPath)(value) : value.startsWith('file:') ? (0, url_1.fileURLToPath)(new url_1.URL(value)) : path_1.default.resolve(value);
}
async function emitStaticChildAsset() {
if (!staticChildValue) {
return;
}
if ('value' in staticChildValue && isAbsolutePathOrUrl(staticChildValue.value)) {
try {
const resolved = resolveAbsolutePathOrUrl(staticChildValue.value);
await emitAssetPath(resolved);
}
catch (e) { }
}
else if ('then' in staticChildValue && 'else' in staticChildValue && isAbsolutePathOrUrl(staticChildValue.then) && isAbsolutePathOrUrl(staticChildValue.else)) {
let resolvedThen;
try {
resolvedThen = resolveAbsolutePathOrUrl(staticChildValue.then);
}
catch (e) { }
let resolvedElse;
try {
resolvedElse = resolveAbsolutePathOrUrl(staticChildValue.else);
}
catch (e) { }
if (resolvedThen)
await emitAssetPath(resolvedThen);
if (resolvedElse)
await emitAssetPath(resolvedElse);
}
else if (staticChildNode && staticChildNode.type === 'ArrayExpression' && 'value' in staticChildValue && staticChildValue.value instanceof Array) {
for (const value of staticChildValue.value) {
try {
const resolved = resolveAbsolutePathOrUrl(value);
await emitAssetPath(resolved);
}
catch (e) { }
}
}
staticChildNode = staticChildValue = undefined;
}
}
exports.default = analyze;
;
function isAst(ast) {
return 'body' in ast;
}

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
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

95
node_modules/@vercel/nft/out/cli.js generated vendored Executable file
View File

@@ -0,0 +1,95 @@
#!/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 } = graceful_fs_1.promises;
const rimraf = require('rimraf');
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') {
rimraf.sync((0, path_1.join)(cwd, outputDir));
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
View File

@@ -0,0 +1 @@
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,+BAAgE;AAChE,6CAA4D;AAC5D,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,sBAAQ,CAAC;AACrC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,uDAAkD;AAGlD,SAAS,UAAU,CAAC,IAAY,EAAE,OAA6B,EAAE,MAAgB,EAAE,GAAW;IAC5F,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEjC,IACE,CAAC,MAAM;QACP,CAAC,MAAM,CAAC,OAAO;QACf,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,EAC1F;QACA,OAAO;KACR;IAED,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;QACjC,UAAU,CAA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,0 +1,23 @@
/// <reference types="node" />
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;
}

102
node_modules/@vercel/nft/out/fs.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
"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 {
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
View File

@@ -0,0 +1 @@
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":";;;;;;AACA,+BAA+B;AAC/B,8DAA6B;AAC7B,2CAAkC;AAElC,MAAM,UAAU,GAAG,qBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACxC,MAAM,UAAU,GAAG,qBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACxC,MAAM,MAAM,GAAG,qBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEhC,MAAa,gBAAgB;IAM3B,YAAY,EACV,KAAK,EACL,iBAAiB,GAIlB;QACC,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,IAA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KAAK,CAAC,aAAa,CAAC,IAAY;QACtC,IAAI;YACF,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3B;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,OAAO,IAAI,CAAC;aACb;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CACzB,IAAY,EACZ,MAAyC;QAEzC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAEjC,IAAI;YACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAChC;gBAAS;YACR,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;SAC5B;IACH,CAAC;CACF;AA1GD,4CA0GC"}

2
node_modules/@vercel/nft/out/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export * from './types';
export { nodeFileTrace } from './node-file-trace';

20
node_modules/@vercel/nft/out/index.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
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; } });

1
node_modules/@vercel/nft/out/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA"}

39
node_modules/@vercel/nft/out/node-file-trace.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/// <reference types="node" />
/// <reference types="node" />
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;
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;
constructor({ base, processCwd, exports, conditions, exportsOnly, paths, ignore, log, mixedModules, ts, analysis, cache, fileIOConcurrency, }: NodeFileTraceOptions);
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): Promise<void>;
}

322
node_modules/@vercel/nft/out/node-file-trace.js generated vendored Normal file
View File

@@ -0,0 +1,322 @@
"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 (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__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 = exports.nodeFileTrace = void 0;
const path_1 = require("path");
const analyze_1 = __importDefault(require("./analyze"));
const resolve_dependency_1 = __importStar(require("./resolve-dependency"));
const micromatch_1 = require("micromatch");
const sharedlib_emit_1 = require("./utils/sharedlib-emit");
const path_2 = require("path");
const fs_1 = require("./fs");
function inPath(path, parent) {
const pathWithSep = (0, path_2.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;
}
exports.nodeFileTrace = nodeFileTrace;
;
class Job {
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, }) {
this.reasons = new Map();
this.maybeEmitDep = async (dep, path, cjsResolve) => {
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);
}
}
else {
// ignore builtins
if (resolved.startsWith('node:'))
return;
await this.emitDependency(resolved, path);
}
};
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, micromatch_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.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();
}
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);
}
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_2.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) {
if (this.processed.has(path)) {
if (parent) {
await this.emitFile(path, 'dependency', parent);
}
return;
}
;
this.processed.add(path);
const emitted = await this.emitFile(path, 'dependency', parent);
if (!emitted)
return;
if (path.endsWith('.json'))
return;
if (path.endsWith('.node'))
return await (0, sharedlib_emit_1.sharedLibEmit)(path, 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 (path.endsWith('.js') || path.endsWith('.ts')) {
const pjsonBoundary = await this.getPjsonBoundary(path);
if (pjsonBoundary)
await this.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', path);
}
let analyzeResult;
const cachedAnalysis = this.analysisCache.get(path);
if (cachedAnalysis) {
analyzeResult = cachedAnalysis;
}
else {
const source = await this.readFile(path);
if (source === null)
throw new Error('File ' + path + ' 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)(path, source.toString(), this);
this.analysisCache.set(path, analyzeResult);
}
const { deps, imports, assets, isESM } = analyzeResult;
if (isESM) {
this.esmFileList.add((0, path_1.relative)(this.base, path));
}
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, path);
else
await this.emitFile(asset, 'asset', path);
}),
...[...deps].map(async (dep) => this.maybeEmitDep(dep, path, !isESM)),
...[...imports].map(async (dep) => this.maybeEmitDep(dep, path, false)),
]);
}
}
exports.Job = Job;

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
View 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);
}

264
node_modules/@vercel/nft/out/resolve-dependency.js generated vendored Normal file
View File

@@ -0,0 +1,264 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotFoundError = void 0;
const path_1 = require("path");
// 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);
}
}
exports.default = resolveDependency;
;
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 {
constructor(specifier, parent) {
super("Cannot find module '" + specifier + "' loaded from " + parent);
this.code = 'MODULE_NOT_FOUND';
}
}
exports.NotFoundError = NotFoundError;
const nodeBuiltins = new Set([...require("repl")._builtinLibs, "constants", "module", "timers", "console", "_stream_writable", "_stream_readable", "_stream_duplex", "process", "sys"]);
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 ||
conditions.includes(condition)) {
const target = getExportsTarget(exports[condition], conditions, cjsResolve);
if (target !== undefined)
return target;
}
}
}
return undefined;
}
function resolveExportsImports(pkgPath, obj, subpath, job, isImports, cjsResolve) {
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('./'))
return pkgPath + target.slice(1);
}
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('./'))
return pkgPath + target.slice(1).replace(/\*/g, subpath.slice(match.length - 1));
}
if (!match.endsWith('/'))
continue;
if (subpath.startsWith(match)) {
const target = getExportsTarget(matchObj[match], job.conditions, cjsResolve);
if (typeof target === 'string' && target.endsWith('/') && target.startsWith('./'))
return pkgPath + target.slice(1) + subpath.slice(match.length);
}
}
return undefined;
}
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) {
let importsResolved = resolveExportsImports(pjsonBoundary, pkgImports, name, job, true, cjsResolve);
if (importsResolved) {
if (cjsResolve)
importsResolved = await resolveFile(importsResolved, parent, job) || await resolveDir(importsResolved, parent, job);
else if (!await job.isFile(importsResolved))
throw new NotFoundError(importsResolved, 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 = resolveExportsImports(pjsonBoundary, pkgExports, '.' + name.slice(pkgName.length), job, false, cjsResolve);
if (selfResolved) {
if (cjsResolve)
selfResolved = await resolveFile(selfResolved, parent, job) || await resolveDir(selfResolved, parent, job);
else if (!await job.isFile(selfResolved))
throw new NotFoundError(selfResolved, 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 (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);
let resolved = resolveExportsImports(nodeModulesDir + path_1.sep + pkgName, pkgExports, '.' + name.slice(pkgName.length), job, false, cjsResolve);
if (resolved) {
if (cjsResolve)
resolved = await resolveFile(resolved, parent, job) || await resolveDir(resolved, parent, job);
else if (!await job.isFile(resolved))
throw new NotFoundError(resolved, parent);
}
if (resolved) {
await job.emitFile(nodeModulesDir + path_1.sep + pkgName + path_1.sep + 'package.json', 'resolve', parent);
if (legacyResolved && legacyResolved !== resolved)
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 && 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);
}

File diff suppressed because one or more lines are too long

65
node_modules/@vercel/nft/out/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/// <reference types="node" />
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;
}
export declare 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
View 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
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}

44
node_modules/@vercel/nft/out/utils/ast-helpers.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLoop = exports.isVarLoop = exports.isIdentifierRead = void 0;
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;
}
}
exports.isIdentifierRead = isIdentifierRead;
function isVarLoop(node) {
return node.type === 'ForStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement';
}
exports.isVarLoop = isVarLoop;
function isLoop(node) {
return node.type === 'ForStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement' || node.type === 'WhileStatement' || node.type === 'DoWhileStatement';
}
exports.isLoop = isLoop;

View File

@@ -0,0 +1 @@
{"version":3,"file":"ast-helpers.js","sourceRoot":"","sources":["../../src/utils/ast-helpers.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,IAAU,EAAE,MAAY;IACvD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,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;KACf;AACH,CAAC;AA/BD,4CA+BC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC;AAC1G,CAAC;AAFD,8BAEC;AAED,SAAgB,MAAM,CAAC,IAAU;IAC/B,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAChL,CAAC;AAFD,wBAEC"}

88
node_modules/@vercel/nft/out/utils/binary-locators.js generated vendored Normal file
View 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.nbind = exports.pregyp = void 0;
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;
}
exports.nbind = nbind;

View File

@@ -0,0 +1 @@
{"version":3,"file":"binary-locators.js","sourceRoot":"","sources":["../../src/utils/binary-locators.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,8DAA6B;AAE7B,SAAS;AACT,MAAM,UAAU,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAC1E,MAAM,IAAI,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAC;AAC9D,MAAM,UAAU,GAAG,CAAC,iBAAyB,EAAE,IAAS,EAAE,EAAE;IAC1D,MAAM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AS,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YACvB,IAAI,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,cAAI,EAAE,SAAS,CAAC,CAAC;YACvD,IAAI;gBACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,+BAA+B,CAAC,CAAC;aACnD;YACD,OAAO,GAAG,EAAE;gBACV,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAChC,SAAS;aACV;YACD,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AACD,SAAgB,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;IAC5C,MAAM,KAAK,GAAG,kBAAkB,CAAC,QAAQ,EAAE;QACzC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE;QAClD,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;KAC/C,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAND,sBAMC"}

32
node_modules/@vercel/nft/out/utils/get-package-base.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPackageName = exports.getPackageBase = void 0;
// 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;
}
exports.getPackageBase = getPackageBase;
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;
}
exports.getPackageName = getPackageName;
;

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-package-base.js","sourceRoot":"","sources":["../../src/utils/get-package-base.ts"],"names":[],"mappings":";;;AAAA,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,IAAI,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,EAAE;QAC7D,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;KAC9D;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAVD,wCAUC;AAED,SAAgB,cAAc,CAAC,EAAU;IACvC,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAChD,IAAI,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,EAAE;QAC7D,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;YAC3C,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAG,GAAG,CAAC,CAAC;SAC7C;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,wCAWC;AAAA,CAAC"}

25
node_modules/@vercel/nft/out/utils/interop-require.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeWildcardRequire = exports.normalizeDefaultRequire = void 0;
function normalizeDefaultRequire(obj) {
if (obj && obj.__esModule)
return obj;
return { default: obj };
}
exports.normalizeDefaultRequire = normalizeDefaultRequire;
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;
}
exports.normalizeWildcardRequire = normalizeWildcardRequire;

View File

@@ -0,0 +1 @@
{"version":3,"file":"interop-require.js","sourceRoot":"","sources":["../../src/utils/interop-require.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,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;AAHD,0DAGC;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;QACrB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;YAAE,SAAS;QAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;KACrB;IACD,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC;IACrB,OAAO,GAAG,CAAC;AACb,CAAC;AAXD,4DAWC"}

31
node_modules/@vercel/nft/out/utils/sharedlib-emit.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sharedLibEmit = void 0;
const os_1 = __importDefault(require("os"));
const glob_1 = __importDefault(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(path, job) {
// console.log('Emitting shared libs for ' + path);
const pkgPath = (0, get_package_base_1.getPackageBase)(path);
if (!pkgPath)
return;
const files = await new Promise((resolve, reject) => (0, glob_1.default)(pkgPath + sharedlibGlob, { ignore: pkgPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files)));
await Promise.all(files.map(file => job.emitFile(file, 'sharedlib', path)));
}
exports.sharedLibEmit = sharedLibEmit;
;

View File

@@ -0,0 +1 @@
{"version":3,"file":"sharedlib-emit.js","sourceRoot":"","sources":["../../src/utils/sharedlib-emit.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,yDAAoD;AAGpD,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,QAAQ,YAAE,CAAC,QAAQ,EAAE,EAAE;IACrB,KAAK,QAAQ;QACX,aAAa,GAAG,wBAAwB,CAAC;QAC3C,MAAM;IACN,KAAK,OAAO;QACV,aAAa,GAAG,WAAW,CAAC;QAC9B,MAAM;IACN;QACE,aAAa,GAAG,eAAe,CAAC;CACnC;AAED,+EAA+E;AACxE,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,GAAQ;IACxD,mDAAmD;IACnD,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,OAAO;QACV,OAAO;IAET,MAAM,KAAK,GAAG,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAC5D,IAAA,cAAI,EAAC,OAAO,GAAG,aAAa,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,uBAAuB,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CACjI,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC;AAVD,sCAUC;AAAA,CAAC"}

246
node_modules/@vercel/nft/out/utils/special-cases.js generated vendored Normal file
View File

@@ -0,0 +1,246 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
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/'));
}
},
'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);
}
}
},
'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')));
}
},
'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'));
}
}
};
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 });
}
exports.default = handleSpecialCases;
;

File diff suppressed because one or more lines are too long

562
node_modules/@vercel/nft/out/utils/static-eval.js generated vendored Normal file
View File

@@ -0,0 +1,562 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wildcardRegEx = exports.WILDCARD = exports.FUNCTION = exports.UNKNOWN = exports.evaluate = void 0;
const url_1 = require("url");
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, then, else }
// 3. Unknown value: undefined
function walk(node) {
const visitor = visitors[node.type];
if (visitor) {
return visitor.call(state, node, walk);
}
return undefined;
}
}
exports.evaluate = evaluate;
;
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, then: l.then == v, else: l.else == v };
if (op === '===')
return { test: l.test, then: l.then === v, else: l.else === v };
if (op === '!=')
return { test: l.test, then: l.then != v, else: l.else != v };
if (op === '!==')
return { test: l.test, then: l.then !== v, else: l.else !== v };
if (op === '+')
return { test: l.test, then: l.then + v, else: l.else + v };
if (op === '-')
return { test: l.test, then: l.then - v, else: l.else - v };
if (op === '*')
return { test: l.test, then: l.then * v, else: l.else * v };
if (op === '/')
return { test: l.test, then: l.then / v, else: l.else / v };
if (op === '%')
return { test: l.test, then: l.then % v, else: l.else % v };
if (op === '<')
return { test: l.test, then: l.then < v, else: l.else < v };
if (op === '<=')
return { test: l.test, then: l.then <= v, else: l.else <= v };
if (op === '>')
return { test: l.test, then: l.then > v, else: l.else > v };
if (op === '>=')
return { test: l.test, then: l.then >= v, else: l.else >= v };
if (op === '|')
return { test: l.test, then: l.then | v, else: l.else | v };
if (op === '&')
return { test: l.test, then: l.then & v, else: l.else & v };
if (op === '^')
return { test: l.test, then: l.then ^ v, else: l.else ^ v };
if (op === '&&')
return { test: l.test, then: l.then && v, else: l.else && v };
if (op === '||')
return { test: l.test, then: l.then || v, else: l.else || v };
}
else if ('test' in r && 'value' in l) {
const v = l.value;
if (op === '==')
return { test: r.test, then: v == r.then, else: v == r.else };
if (op === '===')
return { test: r.test, then: v === r.then, else: v === r.else };
if (op === '!=')
return { test: r.test, then: v != r.then, else: v != r.else };
if (op === '!==')
return { test: r.test, then: v !== r.then, else: v !== r.else };
if (op === '+')
return { test: r.test, then: v + r.then, else: v + r.else };
if (op === '-')
return { test: r.test, then: v - r.then, else: v - r.else };
if (op === '*')
return { test: r.test, then: v * r.then, else: v * r.else };
if (op === '/')
return { test: r.test, then: v / r.then, else: v / r.else };
if (op === '%')
return { test: r.test, then: v % r.then, else: v % r.else };
if (op === '<')
return { test: r.test, then: v < r.then, else: v < r.else };
if (op === '<=')
return { test: r.test, then: v <= r.then, else: v <= r.else };
if (op === '>')
return { test: r.test, then: v > r.then, else: v > r.else };
if (op === '>=')
return { test: r.test, then: v >= r.then, else: v >= r.else };
if (op === '|')
return { test: r.test, then: v | r.then, else: v | r.else };
if (op === '&')
return { test: r.test, then: v & r.then, else: v & r.else };
if (op === '^')
return { test: r.test, then: v ^ r.then, else: v ^ r.else };
if (op === '&&')
return { test: r.test, then: v && r.then, else: l && r.else };
if (op === '||')
return { test: r.test, then: v || r.then, 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.then);
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, then: 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,
then: 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_1.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_1.URL(arg.value, parent.value) };
}
catch {
return undefined;
}
}
try {
return { value: new url_1.URL(arg.value) };
}
catch {
return undefined;
}
}
else {
const test = arg.test;
if (parent) {
try {
return {
test,
then: new url_1.URL(arg.then, parent.value),
else: new url_1.URL(arg.else, parent.value)
};
}
catch {
return undefined;
}
}
try {
return {
test,
then: new url_1.URL(arg.then),
else: new url_1.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.then += 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.then += 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,
then: val.value + exprValue.then,
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.then += 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, then: +val.then, else: +val.else };
if (node.operator === '-')
return { test: val.test, then: -val.then, else: -val.else };
if (node.operator === '~')
return { test: val.test, then: ~val.then, else: ~val.else };
if (node.operator === '!')
return { test: val.test, then: !val.then, else: !val.else };
}
return undefined;
}
};
visitors.LogicalExpression = visitors.BinaryExpression;

File diff suppressed because one or more lines are too long

2
node_modules/@vercel/nft/out/utils/types.js generated vendored Normal file
View 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
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}

569
node_modules/@vercel/nft/out/utils/wrappers.js generated vendored Normal file
View File

@@ -0,0 +1,569 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleWrappers = void 0;
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 thats 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 thats 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;
}
}
}
});
}
}
}
}
}
exports.handleWrappers = handleWrappers;

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