UNPKG

@jspm/core

Version:

This package contains the core libraries used in jspm 2.

1,499 lines (1,484 loc) 147 kB
import { d as dew$g } from './chunk-DtuTasat.js'; import { e as et } from './chunk-CjPlbOtt.js'; import './chunk-CbQqNoLO.js'; import { X } from './chunk-D3uu3VYh.js'; import { e as exports$i, h } from './chunk-DHWh-hmB.js'; import './chunk-b0rmRow7.js'; import { p as process } from './chunk-DEMDiNwt.js'; import './chunk-DtDiafJB.js'; import { y } from './chunk-tHuMsdT0.js'; import { e as exports$j } from './chunk-B6-G-Ftj.js'; import { Buffer } from './buffer.js'; import { fileURLToPath } from './url.js'; import './chunk-B738Er4n.js'; import './punycode.js'; import './chunk-DtcTpLWz.js'; import './chunk-BlJi4mNy.js'; var exports$h = {}, _dewExec$f = false; function dew$f() { if (_dewExec$f) return exports$h; _dewExec$f = true; Object.defineProperty(exports$h, "__esModule", { value: true }); exports$h.constants = void 0; exports$h.constants = { O_RDONLY: 0, O_WRONLY: 1, O_RDWR: 2, S_IFMT: 61440, S_IFREG: 32768, S_IFDIR: 16384, S_IFCHR: 8192, S_IFBLK: 24576, S_IFIFO: 4096, S_IFLNK: 40960, S_IFSOCK: 49152, O_CREAT: 64, O_EXCL: 128, O_NOCTTY: 256, O_TRUNC: 512, O_APPEND: 1024, O_DIRECTORY: 65536, O_NOATIME: 262144, O_NOFOLLOW: 131072, O_SYNC: 1052672, O_DIRECT: 16384, O_NONBLOCK: 2048, S_IRWXU: 448, S_IRUSR: 256, S_IWUSR: 128, S_IXUSR: 64, S_IRWXG: 56, S_IRGRP: 32, S_IWGRP: 16, S_IXGRP: 8, S_IRWXO: 7, S_IROTH: 4, S_IWOTH: 2, S_IXOTH: 1, F_OK: 0, R_OK: 4, W_OK: 2, X_OK: 1, UV_FS_SYMLINK_DIR: 1, UV_FS_SYMLINK_JUNCTION: 2, UV_FS_COPYFILE_EXCL: 1, UV_FS_COPYFILE_FICLONE: 2, UV_FS_COPYFILE_FICLONE_FORCE: 4, COPYFILE_EXCL: 1, COPYFILE_FICLONE: 2, COPYFILE_FICLONE_FORCE: 4 }; return exports$h; } var exports$g = {}, _dewExec$e = false; function dew$e() { if (_dewExec$e) return exports$g; _dewExec$e = true; if (typeof BigInt === "function") exports$g.default = BigInt;else exports$g.default = function BigIntNotSupported() { throw new Error("BigInt is not supported in this environment."); }; return exports$g; } var exports$f = {}, _dewExec$d = false; function dew$d() { if (_dewExec$d) return exports$f; _dewExec$d = true; Object.defineProperty(exports$f, "__esModule", { value: true }); exports$f.Stats = void 0; var constants_1 = dew$f(); var getBigInt_1 = dew$e(); var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK; /** * Statistics about a file/directory, like `fs.Stats`. */ var Stats = /** @class */function () { function Stats() {} Stats.build = function (node, bigint) { if (bigint === void 0) { bigint = false; } var stats = new Stats(); var uid = node.uid, gid = node.gid, atime = node.atime, mtime = node.mtime, ctime = node.ctime; var getStatNumber = !bigint ? function (number) { return number; } : getBigInt_1.default; // Copy all values on Stats from Node, so that if Node values // change, values on Stats would still be the old ones, // just like in Node fs. stats.uid = getStatNumber(uid); stats.gid = getStatNumber(gid); stats.rdev = getStatNumber(0); stats.blksize = getStatNumber(4096); stats.ino = getStatNumber(node.ino); stats.size = getStatNumber(node.getSize()); stats.blocks = getStatNumber(1); stats.atime = atime; stats.mtime = mtime; stats.ctime = ctime; stats.birthtime = ctime; stats.atimeMs = getStatNumber(atime.getTime()); stats.mtimeMs = getStatNumber(mtime.getTime()); var ctimeMs = getStatNumber(ctime.getTime()); stats.ctimeMs = ctimeMs; stats.birthtimeMs = ctimeMs; stats.dev = getStatNumber(0); stats.mode = getStatNumber(node.mode); stats.nlink = getStatNumber(node.nlink); return stats; }; Stats.prototype._checkModeProperty = function (property) { return (Number(this.mode) & S_IFMT) === property; }; Stats.prototype.isDirectory = function () { return this._checkModeProperty(S_IFDIR); }; Stats.prototype.isFile = function () { return this._checkModeProperty(S_IFREG); }; Stats.prototype.isBlockDevice = function () { return this._checkModeProperty(S_IFBLK); }; Stats.prototype.isCharacterDevice = function () { return this._checkModeProperty(S_IFCHR); }; Stats.prototype.isSymbolicLink = function () { return this._checkModeProperty(S_IFLNK); }; Stats.prototype.isFIFO = function () { return this._checkModeProperty(S_IFIFO); }; Stats.prototype.isSocket = function () { return this._checkModeProperty(S_IFSOCK); }; return Stats; }(); exports$f.Stats = Stats; exports$f.default = Stats; return exports$f; } var exports$e = {}, _dewExec$c = false; function dew$c() { if (_dewExec$c) return exports$e; _dewExec$c = true; var __spreadArray = exports$e && exports$e.__spreadArray || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports$e, "__esModule", { value: true }); exports$e.bufferFrom = exports$e.bufferAllocUnsafe = exports$e.Buffer = void 0; var buffer_1 = dew$g(); Object.defineProperty(exports$e, "Buffer", { enumerable: true, get: function () { return buffer_1.Buffer; } }); function bufferV0P12Ponyfill(arg0) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } return new (buffer_1.Buffer.bind.apply(buffer_1.Buffer, __spreadArray([void 0, arg0], args, false)))(); } var bufferAllocUnsafe = buffer_1.Buffer.allocUnsafe || bufferV0P12Ponyfill; exports$e.bufferAllocUnsafe = bufferAllocUnsafe; var bufferFrom = buffer_1.Buffer.from || bufferV0P12Ponyfill; exports$e.bufferFrom = bufferFrom; return exports$e; } var exports$d = {}, _dewExec$b = false; var _global$3 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; function dew$b() { if (_dewExec$b) return exports$d; _dewExec$b = true; // The whole point behind this internal module is to allow Node.js to no // longer be forced to treat every error message change as a semver-major // change. The NodeError classes here all expose a `code` property whose // value statically and permanently identifies the error. While the error // message may change, the code should not. var __extends = exports$d && exports$d.__extends || function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; } || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); Object.defineProperty(exports$d, "__esModule", { value: true }); exports$d.E = exports$d.AssertionError = exports$d.message = exports$d.RangeError = exports$d.TypeError = exports$d.Error = void 0; var assert = et; var util = X; var kCode = typeof Symbol === "undefined" ? "_kCode" : Symbol("code"); var messages = {}; // new Map(); function makeNodeError(Base) { return /** @class */function (_super) { __extends(NodeError, _super); function NodeError(key) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } var _this = _super.call(this, message(key, args)) || this; _this.code = key; _this[kCode] = key; _this.name = "".concat(_super.prototype.name, " [").concat(_this[kCode], "]"); return _this; } return NodeError; }(Base); } var g = typeof globalThis !== "undefined" ? globalThis : _global$3; var AssertionError = /** @class */function (_super) { __extends(AssertionError, _super); function AssertionError(options) { var _this = this; if (typeof options !== "object" || options === null) { throw new exports$d.TypeError("ERR_INVALID_ARG_TYPE", "options", "object"); } if (options.message) { _this = _super.call(this, options.message) || this; } else { _this = _super.call(this, "".concat(util.inspect(options.actual).slice(0, 128), " ") + "".concat(options.operator, " ").concat(util.inspect(options.expected).slice(0, 128))) || this; } _this.generatedMessage = !options.message; _this.name = "AssertionError [ERR_ASSERTION]"; _this.code = "ERR_ASSERTION"; _this.actual = options.actual; _this.expected = options.expected; _this.operator = options.operator; exports$d.Error.captureStackTrace(_this, options.stackStartFunction); return _this; } return AssertionError; }(g.Error); exports$d.AssertionError = AssertionError; function message(key, args) { assert.strictEqual(typeof key, "string"); // const msg = messages.get(key); var msg = messages[key]; assert(msg, "An invalid error message key was used: ".concat(key, ".")); var fmt; if (typeof msg === "function") { fmt = msg; } else { fmt = util.format; if (args === undefined || args.length === 0) return msg; args.unshift(msg); } return String(fmt.apply(null, args)); } exports$d.message = message; // Utility function for registering the error codes. Only used here. Exported // *only* to allow for testing. function E(sym, val) { messages[sym] = typeof val === "function" ? val : String(val); } exports$d.E = E; exports$d.Error = makeNodeError(g.Error); exports$d.TypeError = makeNodeError(g.TypeError); exports$d.RangeError = makeNodeError(g.RangeError); // To declare an error message, use the E(sym, val) function above. The sym // must be an upper case string. The val can be either a function or a string. // The return value of the function must be a string. // Examples: // E('EXAMPLE_KEY1', 'This is the error value'); // E('EXAMPLE_KEY2', (a, b) => return `${a} ${b}`); // // Once an error code has been assigned, the code itself MUST NOT change and // any given error code must never be reused to identify a different error. // // Any error code added here should also be added to the documentation // // Note: Please try to keep these in alphabetical order E("ERR_ARG_NOT_ITERABLE", "%s must be iterable"); E("ERR_ASSERTION", "%s"); E("ERR_BUFFER_OUT_OF_BOUNDS", bufferOutOfBounds); E("ERR_CHILD_CLOSED_BEFORE_REPLY", "Child closed before reply received"); E("ERR_CONSOLE_WRITABLE_STREAM", "Console expects a writable stream instance for %s"); E("ERR_CPU_USAGE", "Unable to obtain cpu usage %s"); E("ERR_DNS_SET_SERVERS_FAILED", function (err, servers) { return "c-ares failed to set servers: \"".concat(err, "\" [").concat(servers, "]"); }); E("ERR_FALSY_VALUE_REJECTION", "Promise was rejected with falsy value"); E("ERR_ENCODING_NOT_SUPPORTED", function (enc) { return "The \"".concat(enc, "\" encoding is not supported"); }); E("ERR_ENCODING_INVALID_ENCODED_DATA", function (enc) { return "The encoded data was not valid for encoding ".concat(enc); }); E("ERR_HTTP_HEADERS_SENT", "Cannot render headers after they are sent to the client"); E("ERR_HTTP_INVALID_STATUS_CODE", "Invalid status code: %s"); E("ERR_HTTP_TRAILER_INVALID", "Trailers are invalid with this transfer encoding"); E("ERR_INDEX_OUT_OF_RANGE", "Index out of range"); E("ERR_INVALID_ARG_TYPE", invalidArgType); E("ERR_INVALID_ARRAY_LENGTH", function (name, len, actual) { assert.strictEqual(typeof actual, "number"); return "The array \"".concat(name, "\" (length ").concat(actual, ") must be of length ").concat(len, "."); }); E("ERR_INVALID_BUFFER_SIZE", "Buffer size must be a multiple of %s"); E("ERR_INVALID_CALLBACK", "Callback must be a function"); E("ERR_INVALID_CHAR", "Invalid character in %s"); E("ERR_INVALID_CURSOR_POS", "Cannot set cursor row without setting its column"); E("ERR_INVALID_FD", "\"fd\" must be a positive integer: %s"); E("ERR_INVALID_FILE_URL_HOST", "File URL host must be \"localhost\" or empty on %s"); E("ERR_INVALID_FILE_URL_PATH", "File URL path %s"); E("ERR_INVALID_HANDLE_TYPE", "This handle type cannot be sent"); E("ERR_INVALID_IP_ADDRESS", "Invalid IP address: %s"); E("ERR_INVALID_OPT_VALUE", function (name, value) { return "The value \"".concat(String(value), "\" is invalid for option \"").concat(name, "\""); }); E("ERR_INVALID_OPT_VALUE_ENCODING", function (value) { return "The value \"".concat(String(value), "\" is invalid for option \"encoding\""); }); E("ERR_INVALID_REPL_EVAL_CONFIG", "Cannot specify both \"breakEvalOnSigint\" and \"eval\" for REPL"); E("ERR_INVALID_SYNC_FORK_INPUT", "Asynchronous forks do not support Buffer, Uint8Array or string input: %s"); E("ERR_INVALID_THIS", "Value of \"this\" must be of type %s"); E("ERR_INVALID_TUPLE", "%s must be an iterable %s tuple"); E("ERR_INVALID_URL", "Invalid URL: %s"); E("ERR_INVALID_URL_SCHEME", function (expected) { return "The URL must be ".concat(oneOf(expected, "scheme")); }); E("ERR_IPC_CHANNEL_CLOSED", "Channel closed"); E("ERR_IPC_DISCONNECTED", "IPC channel is already disconnected"); E("ERR_IPC_ONE_PIPE", "Child process can have only one IPC pipe"); E("ERR_IPC_SYNC_FORK", "IPC cannot be used with synchronous forks"); E("ERR_MISSING_ARGS", missingArgs); E("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"); E("ERR_NAPI_CONS_FUNCTION", "Constructor must be a function"); E("ERR_NAPI_CONS_PROTOTYPE_OBJECT", "Constructor.prototype must be an object"); E("ERR_NO_CRYPTO", "Node.js is not compiled with OpenSSL crypto support"); E("ERR_NO_LONGER_SUPPORTED", "%s is no longer supported"); E("ERR_PARSE_HISTORY_DATA", "Could not parse history data in %s"); E("ERR_SOCKET_ALREADY_BOUND", "Socket is already bound"); E("ERR_SOCKET_BAD_PORT", "Port should be > 0 and < 65536"); E("ERR_SOCKET_BAD_TYPE", "Bad socket type specified. Valid types are: udp4, udp6"); E("ERR_SOCKET_CANNOT_SEND", "Unable to send data"); E("ERR_SOCKET_CLOSED", "Socket is closed"); E("ERR_SOCKET_DGRAM_NOT_RUNNING", "Not running"); E("ERR_STDERR_CLOSE", "process.stderr cannot be closed"); E("ERR_STDOUT_CLOSE", "process.stdout cannot be closed"); E("ERR_STREAM_WRAP", "Stream has StringDecoder set or is in objectMode"); E("ERR_TLS_CERT_ALTNAME_INVALID", "Hostname/IP does not match certificate's altnames: %s"); E("ERR_TLS_DH_PARAM_SIZE", function (size) { return "DH parameter size ".concat(size, " is less than 2048"); }); E("ERR_TLS_HANDSHAKE_TIMEOUT", "TLS handshake timeout"); E("ERR_TLS_RENEGOTIATION_FAILED", "Failed to renegotiate"); E("ERR_TLS_REQUIRED_SERVER_NAME", "\"servername\" is required parameter for Server.addContext"); E("ERR_TLS_SESSION_ATTACK", "TSL session renegotiation attack detected"); E("ERR_TRANSFORM_ALREADY_TRANSFORMING", "Calling transform done when still transforming"); E("ERR_TRANSFORM_WITH_LENGTH_0", "Calling transform done when writableState.length != 0"); E("ERR_UNKNOWN_ENCODING", "Unknown encoding: %s"); E("ERR_UNKNOWN_SIGNAL", "Unknown signal: %s"); E("ERR_UNKNOWN_STDIN_TYPE", "Unknown stdin file type"); E("ERR_UNKNOWN_STREAM_TYPE", "Unknown stream file type"); E("ERR_V8BREAKITERATOR", "Full ICU data not installed. " + "See https://github.com/nodejs/node/wiki/Intl"); function invalidArgType(name, expected, actual) { assert(name, "name is required"); // determiner: 'must be' or 'must not be' var determiner; if (expected.includes("not ")) { determiner = "must not be"; expected = expected.split("not ")[1]; } else { determiner = "must be"; } var msg; if (Array.isArray(name)) { var names = name.map(function (val) { return "\"".concat(val, "\""); }).join(", "); msg = "The ".concat(names, " arguments ").concat(determiner, " ").concat(oneOf(expected, "type")); } else if (name.includes(" argument")) { // for the case like 'first argument' msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, "type")); } else { var type = name.includes(".") ? "property" : "argument"; msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, "type")); } // if actual value received, output it if (arguments.length >= 3) { msg += ". Received type ".concat(actual !== null ? typeof actual : "null"); } return msg; } function missingArgs() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } assert(args.length > 0, "At least one arg needs to be specified"); var msg = "The "; var len = args.length; args = args.map(function (a) { return "\"".concat(a, "\""); }); switch (len) { case 1: msg += "".concat(args[0], " argument"); break; case 2: msg += "".concat(args[0], " and ").concat(args[1], " arguments"); break; default: msg += args.slice(0, len - 1).join(", "); msg += ", and ".concat(args[len - 1], " arguments"); break; } return "".concat(msg, " must be specified"); } function oneOf(expected, thing) { assert(expected, "expected is required"); assert(typeof thing === "string", "thing is required"); if (Array.isArray(expected)) { var len = expected.length; assert(len > 0, "At least one expected value needs to be specified"); // tslint:disable-next-line expected = expected.map(function (i) { return String(i); }); if (len > 2) { return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(", "), ", or ") + expected[len - 1]; } else if (len === 2) { return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); } else { return "of ".concat(thing, " ").concat(expected[0]); } } else { return "of ".concat(thing, " ").concat(String(expected)); } } function bufferOutOfBounds(name, isWriting) { if (isWriting) { return "Attempt to write outside buffer bounds"; } else { return "\"".concat(name, "\" is outside of buffer bounds"); } } return exports$d; } var exports$c = {}, _dewExec$a = false; function dew$a() { if (_dewExec$a) return exports$c; _dewExec$a = true; Object.defineProperty(exports$c, "__esModule", { value: true }); exports$c.strToEncoding = exports$c.assertEncoding = exports$c.ENCODING_UTF8 = void 0; var buffer_1 = dew$c(); var errors = dew$b(); exports$c.ENCODING_UTF8 = "utf8"; function assertEncoding(encoding) { if (encoding && !buffer_1.Buffer.isEncoding(encoding)) throw new errors.TypeError("ERR_INVALID_OPT_VALUE_ENCODING", encoding); } exports$c.assertEncoding = assertEncoding; function strToEncoding(str, encoding) { if (!encoding || encoding === exports$c.ENCODING_UTF8) return str; // UTF-8 if (encoding === "buffer") return new buffer_1.Buffer(str); // `buffer` encoding return new buffer_1.Buffer(str).toString(encoding); // Custom encoding } exports$c.strToEncoding = strToEncoding; return exports$c; } var exports$b = {}, _dewExec$9 = false; function dew$9() { if (_dewExec$9) return exports$b; _dewExec$9 = true; Object.defineProperty(exports$b, "__esModule", { value: true }); exports$b.Dirent = void 0; var constants_1 = dew$f(); var encoding_1 = dew$a(); var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK; /** * A directory entry, like `fs.Dirent`. */ var Dirent = /** @class */function () { function Dirent() { this.name = ""; this.mode = 0; } Dirent.build = function (link, encoding) { var dirent = new Dirent(); var mode = link.getNode().mode; dirent.name = (0, encoding_1.strToEncoding)(link.getName(), encoding); dirent.mode = mode; return dirent; }; Dirent.prototype._checkModeProperty = function (property) { return (this.mode & S_IFMT) === property; }; Dirent.prototype.isDirectory = function () { return this._checkModeProperty(S_IFDIR); }; Dirent.prototype.isFile = function () { return this._checkModeProperty(S_IFREG); }; Dirent.prototype.isBlockDevice = function () { return this._checkModeProperty(S_IFBLK); }; Dirent.prototype.isCharacterDevice = function () { return this._checkModeProperty(S_IFCHR); }; Dirent.prototype.isSymbolicLink = function () { return this._checkModeProperty(S_IFLNK); }; Dirent.prototype.isFIFO = function () { return this._checkModeProperty(S_IFIFO); }; Dirent.prototype.isSocket = function () { return this._checkModeProperty(S_IFSOCK); }; return Dirent; }(); exports$b.Dirent = Dirent; exports$b.default = Dirent; return exports$b; } exports$i._makeLong; exports$i.basename; exports$i.delimiter; exports$i.dirname; exports$i.extname; exports$i.format; exports$i.isAbsolute; exports$i.join; exports$i.normalize; exports$i.parse; exports$i.posix; exports$i.relative; exports$i.resolve; exports$i.sep; exports$i.win32; var exports$a = {}, _dewExec$8 = false; var _global$2 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; function dew$8() { if (_dewExec$8) return exports$a; _dewExec$8 = true; var process$1 = process; Object.defineProperty(exports$a, "__esModule", { value: true }); var _setImmediate; if (typeof process$1.nextTick === "function") _setImmediate = process$1.nextTick.bind(typeof globalThis !== "undefined" ? globalThis : _global$2);else _setImmediate = setTimeout.bind(typeof globalThis !== "undefined" ? globalThis : _global$2); exports$a.default = _setImmediate; return exports$a; } var exports$9 = {}, _dewExec$7 = false; function dew$7() { if (_dewExec$7) return exports$9; _dewExec$7 = true; var process$1 = process; // Here we mock the global `process` variable in case we are not in Node's environment. Object.defineProperty(exports$9, "__esModule", { value: true }); exports$9.createProcess = void 0; /** * Looks to return a `process` object, if one is available. * * The global `process` is returned if defined; * otherwise `require('process')` is attempted. * * If that fails, `undefined` is returned. * * @return {IProcess | undefined} */ var maybeReturnProcess = function () { if (typeof process$1 !== "undefined") { return process$1; } try { return process; } catch (_a) { return undefined; } }; function createProcess() { var p = maybeReturnProcess() || {}; if (!p.cwd) p.cwd = function () { return "/"; }; if (!p.nextTick) p.nextTick = dew$8().default; if (!p.emitWarning) p.emitWarning = function (message, type) { // tslint:disable-next-line:no-console console.warn("".concat(type).concat(type ? ": " : "").concat(message)); }; if (!p.env) p.env = {}; return p; } exports$9.createProcess = createProcess; exports$9.default = createProcess(); return exports$9; } var exports$8 = {}, _dewExec$6 = false; function dew$6() { if (_dewExec$6) return exports$8; _dewExec$6 = true; var __extends = exports$8 && exports$8.__extends || function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; } || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); Object.defineProperty(exports$8, "__esModule", { value: true }); exports$8.File = exports$8.Link = exports$8.Node = exports$8.SEP = void 0; var process_1 = dew$7(); var buffer_1 = dew$c(); var constants_1 = dew$f(); var events_1 = y; var Stats_1 = dew$d(); var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFLNK = constants_1.constants.S_IFLNK, O_APPEND = constants_1.constants.O_APPEND; var getuid = function () { var _a, _b; return (_b = (_a = process_1.default.getuid) === null || _a === void 0 ? void 0 : _a.call(process_1.default)) !== null && _b !== void 0 ? _b : 0; }; var getgid = function () { var _a, _b; return (_b = (_a = process_1.default.getgid) === null || _a === void 0 ? void 0 : _a.call(process_1.default)) !== null && _b !== void 0 ? _b : 0; }; exports$8.SEP = "/"; /** * Node in a file system (like i-node, v-node). */ var Node = /** @class */function (_super) { __extends(Node, _super); function Node(ino, perm) { if (perm === void 0) { perm = 438; } var _this = _super.call(this) || this; // User ID and group ID. _this._uid = getuid(); _this._gid = getgid(); _this._atime = new Date(); _this._mtime = new Date(); _this._ctime = new Date(); _this._perm = 438; // Permissions `chmod`, `fchmod` _this.mode = S_IFREG; // S_IFDIR, S_IFREG, etc.. (file by default?) // Number of hard links pointing at this Node. _this._nlink = 1; _this._perm = perm; _this.mode |= perm; _this.ino = ino; return _this; } Object.defineProperty(Node.prototype, "ctime", { get: function () { return this._ctime; }, set: function (ctime) { this._ctime = ctime; }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "uid", { get: function () { return this._uid; }, set: function (uid) { this._uid = uid; this.ctime = new Date(); }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "gid", { get: function () { return this._gid; }, set: function (gid) { this._gid = gid; this.ctime = new Date(); }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "atime", { get: function () { return this._atime; }, set: function (atime) { this._atime = atime; this.ctime = new Date(); }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "mtime", { get: function () { return this._mtime; }, set: function (mtime) { this._mtime = mtime; this.ctime = new Date(); }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "perm", { get: function () { return this._perm; }, set: function (perm) { this._perm = perm; this.ctime = new Date(); }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "nlink", { get: function () { return this._nlink; }, set: function (nlink) { this._nlink = nlink; this.ctime = new Date(); }, enumerable: false, configurable: true }); Node.prototype.getString = function (encoding) { if (encoding === void 0) { encoding = "utf8"; } this.atime = new Date(); return this.getBuffer().toString(encoding); }; Node.prototype.setString = function (str) { // this.setBuffer(bufferFrom(str, 'utf8')); this.buf = (0, buffer_1.bufferFrom)(str, "utf8"); this.touch(); }; Node.prototype.getBuffer = function () { this.atime = new Date(); if (!this.buf) this.setBuffer((0, buffer_1.bufferAllocUnsafe)(0)); return (0, buffer_1.bufferFrom)(this.buf); // Return a copy. }; Node.prototype.setBuffer = function (buf) { this.buf = (0, buffer_1.bufferFrom)(buf); // Creates a copy of data. this.touch(); }; Node.prototype.getSize = function () { return this.buf ? this.buf.length : 0; }; Node.prototype.setModeProperty = function (property) { this.mode = this.mode & ~S_IFMT | property; }; Node.prototype.setIsFile = function () { this.setModeProperty(S_IFREG); }; Node.prototype.setIsDirectory = function () { this.setModeProperty(S_IFDIR); }; Node.prototype.setIsSymlink = function () { this.setModeProperty(S_IFLNK); }; Node.prototype.isFile = function () { return (this.mode & S_IFMT) === S_IFREG; }; Node.prototype.isDirectory = function () { return (this.mode & S_IFMT) === S_IFDIR; }; Node.prototype.isSymlink = function () { // return !!this.symlink; return (this.mode & S_IFMT) === S_IFLNK; }; Node.prototype.makeSymlink = function (steps) { this.symlink = steps; this.setIsSymlink(); }; Node.prototype.write = function (buf, off, len, pos) { if (off === void 0) { off = 0; } if (len === void 0) { len = buf.length; } if (pos === void 0) { pos = 0; } if (!this.buf) this.buf = (0, buffer_1.bufferAllocUnsafe)(0); if (pos + len > this.buf.length) { var newBuf = (0, buffer_1.bufferAllocUnsafe)(pos + len); this.buf.copy(newBuf, 0, 0, this.buf.length); this.buf = newBuf; } buf.copy(this.buf, pos, off, off + len); this.touch(); return len; }; // Returns the number of bytes read. Node.prototype.read = function (buf, off, len, pos) { if (off === void 0) { off = 0; } if (len === void 0) { len = buf.byteLength; } if (pos === void 0) { pos = 0; } this.atime = new Date(); if (!this.buf) this.buf = (0, buffer_1.bufferAllocUnsafe)(0); var actualLen = len; if (actualLen > buf.byteLength) { actualLen = buf.byteLength; } if (actualLen + pos > this.buf.length) { actualLen = this.buf.length - pos; } this.buf.copy(buf, off, pos, pos + actualLen); return actualLen; }; Node.prototype.truncate = function (len) { if (len === void 0) { len = 0; } if (!len) this.buf = (0, buffer_1.bufferAllocUnsafe)(0);else { if (!this.buf) this.buf = (0, buffer_1.bufferAllocUnsafe)(0); if (len <= this.buf.length) { this.buf = this.buf.slice(0, len); } else { var buf = (0, buffer_1.bufferAllocUnsafe)(len); this.buf.copy(buf); buf.fill(0, this.buf.length); this.buf = buf; } } this.touch(); }; Node.prototype.chmod = function (perm) { this.perm = perm; this.mode = this.mode & ~511 | perm; this.touch(); }; Node.prototype.chown = function (uid, gid) { this.uid = uid; this.gid = gid; this.touch(); }; Node.prototype.touch = function () { this.mtime = new Date(); this.emit("change", this); }; Node.prototype.canRead = function (uid, gid) { if (uid === void 0) { uid = getuid(); } if (gid === void 0) { gid = getgid(); } if (this.perm & 4 /* S.IROTH */) { return true; } if (gid === this.gid) { if (this.perm & 32 /* S.IRGRP */) { return true; } } if (uid === this.uid) { if (this.perm & 256 /* S.IRUSR */) { return true; } } return false; }; Node.prototype.canWrite = function (uid, gid) { if (uid === void 0) { uid = getuid(); } if (gid === void 0) { gid = getgid(); } if (this.perm & 2 /* S.IWOTH */) { return true; } if (gid === this.gid) { if (this.perm & 16 /* S.IWGRP */) { return true; } } if (uid === this.uid) { if (this.perm & 128 /* S.IWUSR */) { return true; } } return false; }; Node.prototype.del = function () { this.emit("delete", this); }; Node.prototype.toJSON = function () { return { ino: this.ino, uid: this.uid, gid: this.gid, atime: this.atime.getTime(), mtime: this.mtime.getTime(), ctime: this.ctime.getTime(), perm: this.perm, mode: this.mode, nlink: this.nlink, symlink: this.symlink, data: this.getString() }; }; return Node; }(events_1.EventEmitter); exports$8.Node = Node; /** * Represents a hard link that points to an i-node `node`. */ var Link = /** @class */function (_super) { __extends(Link, _super); function Link(vol, parent, name) { var _this = _super.call(this) || this; _this.children = {}; // Path to this node as Array: ['usr', 'bin', 'node']. _this._steps = []; // "i-node" number of the node. _this.ino = 0; // Number of children. _this.length = 0; _this.vol = vol; _this.parent = parent; _this.name = name; _this.syncSteps(); return _this; } Object.defineProperty(Link.prototype, "steps", { get: function () { return this._steps; }, // Recursively sync children steps, e.g. in case of dir rename set: function (val) { this._steps = val; for (var _i = 0, _a = Object.entries(this.children); _i < _a.length; _i++) { var _b = _a[_i], child = _b[0], link = _b[1]; if (child === "." || child === "..") { continue; } link === null || link === void 0 ? void 0 : link.syncSteps(); } }, enumerable: false, configurable: true }); Link.prototype.setNode = function (node) { this.node = node; this.ino = node.ino; }; Link.prototype.getNode = function () { return this.node; }; Link.prototype.createChild = function (name, node) { if (node === void 0) { node = this.vol.createNode(); } var link = new Link(this.vol, this, name); link.setNode(node); if (node.isDirectory()) { link.children["."] = link; link.getNode().nlink++; } this.setChild(name, link); return link; }; Link.prototype.setChild = function (name, link) { if (link === void 0) { link = new Link(this.vol, this, name); } this.children[name] = link; link.parent = this; this.length++; var node = link.getNode(); if (node.isDirectory()) { link.children[".."] = this; this.getNode().nlink++; } this.getNode().mtime = new Date(); this.emit("child:add", link, this); return link; }; Link.prototype.deleteChild = function (link) { var node = link.getNode(); if (node.isDirectory()) { delete link.children[".."]; this.getNode().nlink--; } delete this.children[link.getName()]; this.length--; this.getNode().mtime = new Date(); this.emit("child:delete", link, this); }; Link.prototype.getChild = function (name) { this.getNode().mtime = new Date(); if (Object.hasOwnProperty.call(this.children, name)) { return this.children[name]; } }; Link.prototype.getPath = function () { return this.steps.join(exports$8.SEP); }; Link.prototype.getName = function () { return this.steps[this.steps.length - 1]; }; // del() { // const parent = this.parent; // if(parent) { // parent.deleteChild(link); // } // this.parent = null; // this.vol = null; // } /** * Walk the tree path and return the `Link` at that location, if any. * @param steps {string[]} Desired location. * @param stop {number} Max steps to go into. * @param i {number} Current step in the `steps` array. * * @return {Link|null} */ Link.prototype.walk = function (steps, stop, i) { if (stop === void 0) { stop = steps.length; } if (i === void 0) { i = 0; } if (i >= steps.length) return this; if (i >= stop) return this; var step = steps[i]; var link = this.getChild(step); if (!link) return null; return link.walk(steps, stop, i + 1); }; Link.prototype.toJSON = function () { return { steps: this.steps, ino: this.ino, children: Object.keys(this.children) }; }; Link.prototype.syncSteps = function () { this.steps = this.parent ? this.parent.steps.concat([this.name]) : [this.name]; }; return Link; }(events_1.EventEmitter); exports$8.Link = Link; /** * Represents an open file (file descriptor) that points to a `Link` (Hard-link) and a `Node`. */ var File = /** @class */function () { /** * Open a Link-Node pair. `node` is provided separately as that might be a different node * rather the one `link` points to, because it might be a symlink. * @param link * @param node * @param flags * @param fd */ function File(link, node, flags, fd) { /** * A cursor/offset position in a file, where data will be written on write. * User can "seek" this position. */ this.position = 0; this.link = link; this.node = node; this.flags = flags; this.fd = fd; } File.prototype.getString = function (encoding) { return this.node.getString(); }; File.prototype.setString = function (str) { this.node.setString(str); }; File.prototype.getBuffer = function () { return this.node.getBuffer(); }; File.prototype.setBuffer = function (buf) { this.node.setBuffer(buf); }; File.prototype.getSize = function () { return this.node.getSize(); }; File.prototype.truncate = function (len) { this.node.truncate(len); }; File.prototype.seekTo = function (position) { this.position = position; }; File.prototype.stats = function () { return Stats_1.default.build(this.node); }; File.prototype.write = function (buf, offset, length, position) { if (offset === void 0) { offset = 0; } if (length === void 0) { length = buf.length; } if (typeof position !== "number") position = this.position; if (this.flags & O_APPEND) position = this.getSize(); var bytes = this.node.write(buf, offset, length, position); this.position = position + bytes; return bytes; }; File.prototype.read = function (buf, offset, length, position) { if (offset === void 0) { offset = 0; } if (length === void 0) { length = buf.byteLength; } if (typeof position !== "number") position = this.position; var bytes = this.node.read(buf, offset, length, position); this.position = position + bytes; return bytes; }; File.prototype.chmod = function (perm) { this.node.chmod(perm); }; File.prototype.chown = function (uid, gid) { this.node.chown(uid, gid); }; return File; }(); exports$8.File = File; return exports$8; } var exports$7 = {}, _dewExec$5 = false; var _global$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; function dew$5() { if (_dewExec$5) return exports$7; _dewExec$5 = true; Object.defineProperty(exports$7, "__esModule", { value: true }); /** * `setTimeoutUnref` is just like `setTimeout`, * only in Node's environment it will "unref" its macro task. */ function setTimeoutUnref(callback, time, args) { var ref = setTimeout.apply(typeof globalThis !== "undefined" ? globalThis : _global$1, arguments); if (ref && typeof ref === "object" && typeof ref.unref === "function") ref.unref(); return ref; } exports$7.default = setTimeoutUnref; return exports$7; } var exports$6 = {}, _dewExec$4 = false; function dew$4() { if (_dewExec$4) return exports$6; _dewExec$4 = true; var __spreadArray = exports$6 && exports$6.__spreadArray || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports$6, "__esModule", { value: true }); exports$6.FileHandle = void 0; function promisify(vol, fn, getResult) { if (getResult === void 0) { getResult = function (input) { return input; }; } return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return new Promise(function (resolve, reject) { vol[fn].bind(vol).apply(void 0, __spreadArray(__spreadArray([], args, false), [function (error, result) { if (error) return reject(error); return resolve(getResult(result)); }], false)); }); }; } var FileHandle = /** @class */function () { function FileHandle(vol, fd) { this.vol = vol; this.fd = fd; } FileHandle.prototype.appendFile = function (data, options) { return promisify(this.vol, "appendFile")(this.fd, data, options); }; FileHandle.prototype.chmod = function (mode) { return promisify(this.vol, "fchmod")(this.fd, mode); }; FileHandle.prototype.chown = function (uid, gid) { return promisify(this.vol, "fchown")(this.fd, uid, gid); }; FileHandle.prototype.close = function () { return promisify(this.vol, "close")(this.fd); }; FileHandle.prototype.datasync = function () { return promisify(this.vol, "fdatasync")(this.fd); }; FileHandle.prototype.read = function (buffer, offset, length, position) { return promisify(this.vol, "read", function (bytesRead) { return { bytesRead: bytesRead, buffer: buffer }; })(this.fd, buffer, offset, length, position); }; FileHandle.prototype.readFile = function (options) { return promisify(this.vol, "readFile")(this.fd, options); }; FileHandle.prototype.stat = function (options) { return promisify(this.vol, "fstat")(this.fd, options); }; FileHandle.prototype.sync = function () { return promisify(this.vol, "fsync")(this.fd); }; FileHandle.prototype.truncate = function (len) { return promisify(this.vol, "ftruncate")(this.fd, len); }; FileHandle.prototype.utimes = function (atime, mtime) { return promisify(this.vol, "futimes")(this.fd, atime, mtime); }; FileHandle.prototype.write = function (buffer, offset, length, position) { return promisify(this.vol, "write", function (bytesWritten) { return { bytesWritten: bytesWritten, buffer: buffer }; })(this.fd, buffer, offset, length, position); }; FileHandle.prototype.writeFile = function (data, options) { return promisify(this.vol, "writeFile")(this.fd, data, options); }; return FileHandle; }(); exports$6.FileHandle = FileHandle; function createPromisesApi(vol) { if (typeof Promise === "undefined") return null; return { FileHandle: FileHandle, access: function (path, mode) { return promisify(vol, "access")(path, mode); }, appendFile: function (path, data, options) { return promisify(vol, "appendFile")(path instanceof FileHandle ? path.fd : path, data, options); }, chmod: function (path, mode) { return promisify(vol, "chmod")(path, mode); }, chown: function (path, uid, gid) { return promisify(vol, "chown")(path, uid, gid); }, copyFile: function (src, dest, flags) { return promisify(vol, "copyFile")(src, dest, flags); }, lchmod: function (path, mode) { return promisify(vol, "lchmod")(path, mode); }, lchown: function (path, uid, gid) { return promisify(vol, "lchown")(path, uid, gid); }, link: function (existingPath, newPath) { return promisify(vol, "link")(existingPath, newPath); }, lstat: function (path, options) { return promisify(vol, "lstat")(path, options); }, mkdir: function (path, options) { return promisify(vol, "mkdir")(path, options); }, mkdtemp: function (prefix, options) { return promisify(vol, "mkdtemp")(prefix, options); }, open: function (path, flags, mode) { return promisify(vol, "open", function (fd) { return new FileHandle(vol, fd); })(path, flags, mode); }, readdir: function (path, options) { return promisify(vol, "readdir")(path, options); }, readFile: function (id, options) { return promisify(vol, "readFile")(id instanceof FileHandle ? id.fd : id, options); }, readlink: function (path, options) { return promisify(vol, "readlink")(path, options); }, realpath: function (path, options) { return promisify(vol, "realpath")(path, options); }, rename: function (oldPath, newPath) { return promisify(vol, "rename")(oldPath, newPath); }, rmdir: function (path) { return promisify(vol, "rmdir")(path); }, rm: function (path, options) { return promisify(vol, "rm")(path, options); }, stat: function (path, options) { return promisify(vol, "stat")(path, options); }, symlink: function (target, path, type) { return promisify(vol, "symlink")(target, path, type); }, truncate: function (path, len) { return promisify(vol, "truncate")(path, len); }, unlink: function (path) { return promisify(vol, "unlink")(path); }, utimes: function (path, atime, mtime) { return promisify(vol, "utimes")(path, atime, mtime); }, writeFile: function (id, data, options) { return promisify(vol, "writeFile")(id instanceof FileHandle ? id.fd : id, data, options); } }; } exports$6.default = createPromisesApi; return exports$6; } var exports$5 = {}, _dewExec$3 = false; function dew$3() { if (_dewExec$3) return exports$5; _dewExec$3 = true; var process$1 = process; Object.defineProperty(exports$5, "__esModule", { value: true }); exports$5.correctPath = correctPath; exports$5.unixify = unixify; var isWin = process$1.platform === "win32"; function removeTrailingSeparator(str) { var i = str.length - 1; if (i < 2) { return str; } while (isSeparator(str, i)) { i--; } return str.substr(0, i + 1); } function isSeparator(str, i) { var _char = str[i]; return i > 0 && (_char === "/" || isWin && _char === "\\"); } function normalizePath(str, stripTrailing) { if (typeof str !== "string") { throw new TypeError("expected a string"); } str = str.replace(/[\\\/]+/g, "/"); if (stripTrailing !== false) { str = removeTrailingSeparator(str); } return str; } function unixify(filepath) { var stripTrailing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (isWin) { filepath = normalizePath(filepath, stripTrailing); return filepath.replace(/^([a-zA-Z]+:|\.\/)/, ""); } return filepath; } function correctPath(filepath) { return unixify(filepath.replace(/^\\\\\?\\.:\\/, "\\")); } return exports$5; } var exports$4 = {}, _dewExec$2 = false; var _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; function dew$2() { if (_dewExec