代码拉取完成,页面将自动刷新
import createRequire from 'create-require';
import pkgDir from 'pkg-dir';
/**
* @param {string} path
*/
const resolvePath = (path) => {
let resolvedPath;
try {
resolvedPath = require.resolve(path);
} catch {
resolvedPath = (
globalThis.require ?? createRequire(import.meta.url)
).resolve(path);
}
if (!path.includes('./')) {
const directory = pkgDir.sync(resolvedPath) ?? '';
return directory;
}
return resolvedPath;
};
const assert = resolvePath('assert/');
const buffer = resolvePath('buffer/');
const child_process = resolvePath('./mock/empty.js');
const cluster = resolvePath('./mock/empty.js');
const _console = resolvePath('console-browserify');
const constants = resolvePath('constants-browserify');
const crypto = resolvePath('crypto-browserify');
const dgram = resolvePath('./mock/empty.js');
const dns = resolvePath('./mock/empty.js');
const domain = resolvePath('domain-browser');
const events = resolvePath('events/');
const fs = resolvePath('./mock/empty.js');
const http = resolvePath('stream-http');
const https = resolvePath('https-browserify');
const http2 = resolvePath('./mock/empty.js');
const _module = resolvePath('./mock/empty.js');
const net = resolvePath('./mock/empty.js');
const os = resolvePath('os-browserify/browser.js');
const path = resolvePath('path-browserify');
const punycode = resolvePath('punycode/');
const _process = resolvePath('./proxy/process').replace('.js', '');
const querystring = resolvePath('./proxy/querystring.js');
const readline = resolvePath('./mock/empty.js');
const repl = resolvePath('./mock/empty.js');
const stream = resolvePath('stream-browserify');
const _stream_duplex = resolvePath('readable-stream/lib/_stream_duplex.js');
const _stream_passthrough = resolvePath(
'readable-stream/lib/_stream_passthrough.js'
);
const _stream_readable = resolvePath('readable-stream/lib/_stream_readable.js');
const _stream_transform = resolvePath(
'readable-stream/lib/_stream_transform.js'
);
const _stream_writable = resolvePath('readable-stream/lib/_stream_writable.js');
const string_decoder = resolvePath('string_decoder/');
const sys = resolvePath('util/util.js');
const timers = resolvePath('timers-browserify');
const timersPromises = resolvePath('isomorphic-timers-promises');
const tls = resolvePath('./mock/empty.js');
const tty = resolvePath('tty-browserify');
const url = resolvePath('./proxy/url.js');
const util = resolvePath('util/util.js');
const vm = resolvePath('vm-browserify');
const zlib = resolvePath('browserify-zlib');
const packages = {
assert,
buffer,
child_process,
cluster,
console: _console,
constants,
crypto,
dgram,
dns,
domain,
events,
fs,
http,
https,
http2,
module: _module,
net,
os,
path,
punycode,
process: _process,
querystring,
readline,
repl,
stream,
_stream_duplex,
_stream_passthrough,
_stream_readable,
_stream_transform,
_stream_writable,
string_decoder,
sys,
'timers/promises': timersPromises,
timers,
tls,
tty,
url,
util,
vm,
zlib
};
/** @typedef {typeof packages} Packages */
/** @typedef {keyof Packages} PackageNames */
/** @typedef {{ [Property in PackageNames as `node:${Property}`]: Packages[Property] }} NodeProtocolPackages */
const packagesWithNodeProtocol = /** @type NodeProtocolPackages */ ({});
for (const [packageName, packagePath] of Object.entries(packages)) {
packagesWithNodeProtocol[
`node:${/** @type PackageNames */ (packageName)}`
] = /** @type PackageNames */ packagePath;
}
export default {
...packages,
...packagesWithNodeProtocol
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。