diff --git a/.pnp.cjs b/.pnp.cjs index a08d24e..7c22d25 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -2012,10 +2012,10 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["micromatch", [\ - ["npm:4.0.5", {\ - "packageLocation": "../../.yarn/berry/cache/micromatch-npm-4.0.5-cfab5d7669-10c0.zip/node_modules/micromatch/",\ + ["npm:4.0.8", {\ + "packageLocation": "../../.yarn/berry/cache/micromatch-npm-4.0.8-c9570e4aca-10c0.zip/node_modules/micromatch/",\ "packageDependencies": [\ - ["micromatch", "npm:4.0.5"],\ + ["micromatch", "npm:4.0.8"],\ ["braces", "npm:3.0.3"],\ ["picomatch", "npm:2.3.1"]\ ],\ @@ -3107,7 +3107,7 @@ const RAW_RUNTIME_STATE = ["@types/webpack", null],\ ["chalk", "npm:4.1.2"],\ ["enhanced-resolve", "npm:5.15.1"],\ - ["micromatch", "npm:4.0.5"],\ + ["micromatch", "npm:4.0.8"],\ ["semver", "npm:7.6.0"],\ ["source-map", "npm:0.7.4"],\ ["typescript", "patch:typescript@npm%3A5.5.4#optional!builtin::version=5.5.4&hash=379a07"],\ @@ -3645,26 +3645,24 @@ function ERR_DIR_CLOSED() { const DEFAULT_MODE = S_IFREG | 420; class StatEntry { - constructor() { - this.uid = 0; - this.gid = 0; - this.size = 0; - this.blksize = 0; - this.atimeMs = 0; - this.mtimeMs = 0; - this.ctimeMs = 0; - this.birthtimeMs = 0; - this.atime = new Date(0); - this.mtime = new Date(0); - this.ctime = new Date(0); - this.birthtime = new Date(0); - this.dev = 0; - this.ino = 0; - this.mode = DEFAULT_MODE; - this.nlink = 1; - this.rdev = 0; - this.blocks = 1; - } + uid = 0; + gid = 0; + size = 0; + blksize = 0; + atimeMs = 0; + mtimeMs = 0; + ctimeMs = 0; + birthtimeMs = 0; + atime = /* @__PURE__ */ new Date(0); + mtime = /* @__PURE__ */ new Date(0); + ctime = /* @__PURE__ */ new Date(0); + birthtime = /* @__PURE__ */ new Date(0); + dev = 0; + ino = 0; + mode = DEFAULT_MODE; + nlink = 1; + rdev = 0; + blocks = 1; isBlockDevice() { return false; } @@ -3688,30 +3686,28 @@ class StatEntry { } } class BigIntStatsEntry { - constructor() { - this.uid = BigInt(0); - this.gid = BigInt(0); - this.size = BigInt(0); - this.blksize = BigInt(0); - this.atimeMs = BigInt(0); - this.mtimeMs = BigInt(0); - this.ctimeMs = BigInt(0); - this.birthtimeMs = BigInt(0); - this.atimeNs = BigInt(0); - this.mtimeNs = BigInt(0); - this.ctimeNs = BigInt(0); - this.birthtimeNs = BigInt(0); - this.atime = new Date(0); - this.mtime = new Date(0); - this.ctime = new Date(0); - this.birthtime = new Date(0); - this.dev = BigInt(0); - this.ino = BigInt(0); - this.mode = BigInt(DEFAULT_MODE); - this.nlink = BigInt(1); - this.rdev = BigInt(0); - this.blocks = BigInt(1); - } + uid = BigInt(0); + gid = BigInt(0); + size = BigInt(0); + blksize = BigInt(0); + atimeMs = BigInt(0); + mtimeMs = BigInt(0); + ctimeMs = BigInt(0); + birthtimeMs = BigInt(0); + atimeNs = BigInt(0); + mtimeNs = BigInt(0); + ctimeNs = BigInt(0); + birthtimeNs = BigInt(0); + atime = /* @__PURE__ */ new Date(0); + mtime = /* @__PURE__ */ new Date(0); + ctime = /* @__PURE__ */ new Date(0); + birthtime = /* @__PURE__ */ new Date(0); + dev = BigInt(0); + ino = BigInt(0); + mode = BigInt(DEFAULT_MODE); + nlink = BigInt(1); + rdev = BigInt(0); + blocks = BigInt(1); isBlockDevice() { return false; } @@ -3746,7 +3742,7 @@ function clearStats(stats) { } else if (typeof element === `bigint`) { stats[key] = BigInt(0); } else if (nodeUtils__namespace.types.isDate(element)) { - stats[key] = new Date(0); + stats[key] = /* @__PURE__ */ new Date(0); } } } @@ -3837,6 +3833,9 @@ const Filename = { manifest: `package.json`, lockfile: `yarn.lock`, virtual: `__virtual__`, + /** + * @deprecated + */ pnpJs: `.pnp.js`, pnpCjs: `.pnp.cjs`, pnpData: `.pnp.data.json`, @@ -4118,8 +4117,8 @@ class CustomDir { this.path = path; this.nextDirent = nextDirent; this.opts = opts; - this.closed = false; } + closed = false; throwIfClosed() { if (this.closed) { throw ERR_DIR_CLOSED(); @@ -4177,21 +4176,25 @@ function assertStatus(current, expected) { } } class CustomStatWatcher extends events.EventEmitter { + fakeFs; + path; + bigint; + status = "ready" /* Ready */; + changeListeners = /* @__PURE__ */ new Map(); + lastStats; + startTimeout = null; + static create(fakeFs, path, opts) { + const statWatcher = new CustomStatWatcher(fakeFs, path, opts); + statWatcher.start(); + return statWatcher; + } constructor(fakeFs, path, { bigint = false } = {}) { super(); - this.status = "ready" /* Ready */; - this.changeListeners = /* @__PURE__ */ new Map(); - this.startTimeout = null; this.fakeFs = fakeFs; this.path = path; this.bigint = bigint; this.lastStats = this.stat(); } - static create(fakeFs, path, opts) { - const statWatcher = new CustomStatWatcher(fakeFs, path, opts); - statWatcher.start(); - return statWatcher; - } start() { assertStatus(this.status, "ready" /* Ready */); this.status = "running" /* Running */; @@ -4219,6 +4222,11 @@ class CustomStatWatcher extends events.EventEmitter { return clearStats(statInstance); } } + /** + * Creates an interval whose callback compares the current stats with the previous stats and notifies all listeners in case of changes. + * + * @param opts.persistent Decides whether the interval should be immediately unref-ed. + */ makeInterval(opts) { const interval = setInterval(() => { const currentStats = this.stat(); @@ -4230,10 +4238,16 @@ class CustomStatWatcher extends events.EventEmitter { }, opts.interval); return opts.persistent ? interval : interval.unref(); } + /** + * Registers a listener and assigns it an interval. + */ registerChangeListener(listener, opts) { this.addListener("change" /* Change */, listener); this.changeListeners.set(listener, this.makeInterval(opts)); } + /** + * Unregisters the listener and clears the assigned interval. + */ unregisterChangeListener(listener) { this.removeListener("change" /* Change */, listener); const interval = this.changeListeners.get(listener); @@ -4241,6 +4255,9 @@ class CustomStatWatcher extends events.EventEmitter { clearInterval(interval); this.changeListeners.delete(listener); } + /** + * Unregisters all listeners and clears all assigned intervals. + */ unregisterAllChangeListeners() { for (const listener of this.changeListeners.keys()) { this.unregisterChangeListener(listener); @@ -4249,11 +4266,17 @@ class CustomStatWatcher extends events.EventEmitter { hasChangeListeners() { return this.changeListeners.size > 0; } + /** + * Refs all stored intervals. + */ ref() { for (const interval of this.changeListeners.values()) interval.ref(); return this; } + /** + * Unrefs all stored intervals. + */ unref() { for (const interval of this.changeListeners.values()) interval.unref(); @@ -4324,6 +4347,7 @@ function unwatchAllFiles(fakeFs) { } class FakeFS { + pathUtils; constructor(pathUtils) { this.pathUtils = pathUtils; } @@ -4932,6 +4956,7 @@ class ProxiedFS extends FakeFS { watch(p, a, b) { return this.baseFs.watch( this.mapToBase(p), + // @ts-expect-error a, b ); @@ -4939,6 +4964,7 @@ class ProxiedFS extends FakeFS { watchFile(p, a, b) { return this.baseFs.watchFile( this.mapToBase(p), + // @ts-expect-error a, b ); @@ -4962,6 +4988,7 @@ function direntToPortable(dirent) { return portableDirent; } class NodeFS extends BasePortableFakeFS { + realFs; constructor(realFs = fs__default.default) { super(); this.realFs = realFs; @@ -5357,6 +5384,7 @@ class NodeFS extends BasePortableFakeFS { watch(p, a, b) { return this.realFs.watch( npath.fromPortablePath(p), + // @ts-expect-error a, b ); @@ -5364,6 +5392,7 @@ class NodeFS extends BasePortableFakeFS { watchFile(p, a, b) { return this.realFs.watchFile( npath.fromPortablePath(p), + // @ts-expect-error a, b ); @@ -5384,16 +5413,25 @@ class NodeFS extends BasePortableFakeFS { const MOUNT_MASK = 4278190080; class MountFS extends BasePortableFakeFS { + baseFs; + mountInstances; + fdMap = /* @__PURE__ */ new Map(); + nextFd = 3; + factoryPromise; + factorySync; + filter; + getMountPoint; + magic; + maxAge; + maxOpenFiles; + typeCheck; + isMount = /* @__PURE__ */ new Set(); + notMount = /* @__PURE__ */ new Set(); + realPaths = /* @__PURE__ */ new Map(); constructor({ baseFs = new NodeFS(), filter = null, magicByte = 42, maxOpenFiles = Infinity, useCache = true, maxAge = 5e3, typeCheck = fs.constants.S_IFREG, getMountPoint, factoryPromise, factorySync }) { if (Math.floor(magicByte) !== magicByte || !(magicByte > 1 && magicByte <= 127)) throw new Error(`The magic byte must be set to a round value between 1 and 127 included`); super(); - this.fdMap = /* @__PURE__ */ new Map(); - this.nextFd = 3; - this.isMount = /* @__PURE__ */ new Set(); - this.notMount = /* @__PURE__ */ new Set(); - this.realPaths = /* @__PURE__ */ new Map(); - this.limitOpenFilesTimeout = null; this.baseFs = baseFs; this.mountInstances = useCache ? /* @__PURE__ */ new Map() : null; this.factoryPromise = factoryPromise; @@ -6049,12 +6087,14 @@ class MountFS extends BasePortableFakeFS { return this.makeCallSync(p, () => { return this.baseFs.watch( p, + // @ts-expect-error a, b ); }, (mountFs, { subPath }) => { return mountFs.watch( subPath, + // @ts-expect-error a, b ); @@ -6064,6 +6104,7 @@ class MountFS extends BasePortableFakeFS { return this.makeCallSync(p, () => { return this.baseFs.watchFile( p, + // @ts-expect-error a, b ); @@ -6129,6 +6170,7 @@ class MountFS extends BasePortableFakeFS { }; } } + limitOpenFilesTimeout = null; limitOpenFiles(max) { if (this.mountInstances === null) return; @@ -6218,6 +6260,7 @@ class MountFS extends BasePortableFakeFS { } class PosixFS extends ProxiedFS { + baseFs; constructor(baseFs) { super(npath); this.baseFs = baseFs; @@ -6234,10 +6277,7 @@ const NUMBER_REGEXP = /^[0-9]+$/; const VIRTUAL_REGEXP = /^(\/(?:[^/]+\/)*?(?:\$\$virtual|__virtual__))((?:\/((?:[^/]+-)?[a-f0-9]+)(?:\/([^/]+))?)?((?:\/.*)?))$/; const VALID_COMPONENT = /^([^/]+-)?[a-f0-9]+$/; class VirtualFS extends ProxiedFS { - constructor({ baseFs = new NodeFS() } = {}) { - super(ppath); - this.baseFs = baseFs; - } + baseFs; static makeVirtualPath(base, component, to) { if (ppath.basename(base) !== `__virtual__`) throw new Error(`Assertion failed: Virtual folders must be named "__virtual__"`); @@ -6267,6 +6307,10 @@ class VirtualFS extends ProxiedFS { const subpath = match[5] || `.`; return VirtualFS.resolveVirtual(ppath.join(target, backstep, subpath)); } + constructor({ baseFs = new NodeFS() } = {}) { + super(ppath); + this.baseFs = baseFs; + } getExtractHint(hints) { return this.baseFs.getExtractHint(hints); } @@ -6308,6 +6352,7 @@ class VirtualFS extends ProxiedFS { const URL = Number(process.versions.node.split('.', 1)[0]) < 20 ? url.URL : globalThis.URL; class NodePathFS extends ProxiedFS { + baseFs; constructor(baseFs) { super(npath); this.baseFs = baseFs; @@ -6335,7 +6380,6 @@ function isUtf8(buf, str) { return Buffer.byteLength(str) === buf.byteLength; } -var _a, _b, _c, _d; const kBaseFs = Symbol(`kBaseFs`); const kFd = Symbol(`kFd`); const kClosePromise = Symbol(`kClosePromise`); @@ -6345,11 +6389,13 @@ const kRefs = Symbol(`kRefs`); const kRef = Symbol(`kRef`); const kUnref = Symbol(`kUnref`); class FileHandle { + [kBaseFs]; + [kFd]; + [kRefs] = 1; + [kClosePromise] = void 0; + [kCloseResolve] = void 0; + [kCloseReject] = void 0; constructor(fd, baseFs) { - this[_a] = 1; - this[_b] = void 0; - this[_c] = void 0; - this[_d] = void 0; this[kBaseFs] = baseFs; this[kFd] = fd; } @@ -6387,9 +6433,11 @@ class FileHandle { createWriteStream(options) { return this[kBaseFs].createWriteStream(null, { ...options, fd: this.fd }); } + // FIXME: Missing FakeFS version datasync() { throw new Error(`Method not implemented.`); } + // FIXME: Missing FakeFS version sync() { throw new Error(`Method not implemented.`); } @@ -6454,6 +6502,7 @@ class FileHandle { this[kUnref](); } } + // FIXME: Missing FakeFS version utimes(atime, mtime) { throw new Error(`Method not implemented.`); } @@ -6482,6 +6531,7 @@ class FileHandle { this[kUnref](); } } + // TODO: Use writev from FakeFS when that is implemented async writev(buffers, position) { try { this[kRef](this.writev); @@ -6506,14 +6556,13 @@ class FileHandle { this[kUnref](); } } + // FIXME: Missing FakeFS version readv(buffers, position) { throw new Error(`Method not implemented.`); } close() { - if (this[kFd] === -1) - return Promise.resolve(); - if (this[kClosePromise]) - return this[kClosePromise]; + if (this[kFd] === -1) return Promise.resolve(); + if (this[kClosePromise]) return this[kClosePromise]; this[kRefs]--; if (this[kRefs] === 0) { const fd = this[kFd]; @@ -6533,7 +6582,7 @@ class FileHandle { } return this[kClosePromise]; } - [(_a = kRefs, _b = kClosePromise, _c = kCloseResolve, _d = kCloseReject, kRef)](caller) { + [kRef](caller) { if (this[kFd] === -1) { const err = new Error(`file closed`); err.code = `EBADF`; @@ -6793,8 +6842,7 @@ var libzipSync = {exports: {}}; var frozenFs = Object.assign({}, fs__default.default); var createModule = function() { var _scriptDir = void 0; - if (typeof __filename !== "undefined") - _scriptDir = _scriptDir || __filename; + if (typeof __filename !== "undefined") _scriptDir = _scriptDir || __filename; return function(createModule2) { createModule2 = createModule2 || {}; var Module = typeof createModule2 !== "undefined" ? createModule2 : {}; @@ -6829,10 +6877,8 @@ var createModule = function() { if (ret) { return binary ? ret : ret.toString(); } - if (!nodeFS) - nodeFS = frozenFs; - if (!nodePath) - nodePath = path__default.default; + if (!nodeFS) nodeFS = frozenFs; + if (!nodePath) nodePath = path__default.default; filename = nodePath["normalize"](filename); return nodeFS["readFileSync"](filename, binary ? null : "utf8"); }; @@ -6860,23 +6906,18 @@ var createModule = function() { } } moduleOverrides = null; - if (Module["arguments"]) - ; - if (Module["thisProgram"]) - ; - if (Module["quit"]) - ; + if (Module["arguments"]) ; + if (Module["thisProgram"]) ; + if (Module["quit"]) ; var wasmBinary; - if (Module["wasmBinary"]) - wasmBinary = Module["wasmBinary"]; + if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"]; Module["noExitRuntime"] || true; if (typeof WebAssembly !== "object") { abort("no native wasm support detected"); } function getValue(ptr, type, noSafe) { type = type || "i8"; - if (type.charAt(type.length - 1) === "*") - type = "i32"; + if (type.charAt(type.length - 1) === "*") type = "i32"; switch (type) { case "i1": return HEAP8[ptr >> 0]; @@ -6930,10 +6971,8 @@ var createModule = function() { } }; function convertReturnValue(ret2) { - if (returnType === "string") - return UTF8ToString(ret2); - if (returnType === "boolean") - return Boolean(ret2); + if (returnType === "string") return UTF8ToString(ret2); + if (returnType === "boolean") return Boolean(ret2); return ret2; } var func = getCFunc(ident); @@ -6943,8 +6982,7 @@ var createModule = function() { for (var i = 0; i < args.length; i++) { var converter = toC[argTypes[i]]; if (converter) { - if (stack === 0) - stack = stackSave(); + if (stack === 0) stack = stackSave(); cArgs[i] = converter(args[i]); } else { cArgs[i] = args[i]; @@ -6953,8 +6991,7 @@ var createModule = function() { } var ret = func.apply(null, cArgs); ret = convertReturnValue(ret); - if (stack !== 0) - stackRestore(stack); + if (stack !== 0) stackRestore(stack); return ret; } function cwrap(ident, returnType, argTypes, opts) { @@ -6972,16 +7009,13 @@ var createModule = function() { } var UTF8Decoder = new TextDecoder("utf8"); function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) - return ""; + if (!ptr) return ""; var maxPtr = ptr + maxBytesToRead; - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) - ++end; + for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end; return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)); } function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) - return 0; + if (!(maxBytesToWrite > 0)) return 0; var startIdx = outIdx; var endIdx = outIdx + maxBytesToWrite - 1; for (var i = 0; i < str.length; ++i) { @@ -6991,23 +7025,19 @@ var createModule = function() { u = 65536 + ((u & 1023) << 10) | u1 & 1023; } if (u <= 127) { - if (outIdx >= endIdx) - break; + if (outIdx >= endIdx) break; heap[outIdx++] = u; } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) - break; + if (outIdx + 1 >= endIdx) break; heap[outIdx++] = 192 | u >> 6; heap[outIdx++] = 128 | u & 63; } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) - break; + if (outIdx + 2 >= endIdx) break; heap[outIdx++] = 224 | u >> 12; heap[outIdx++] = 128 | u >> 6 & 63; heap[outIdx++] = 128 | u & 63; } else { - if (outIdx + 3 >= endIdx) - break; + if (outIdx + 3 >= endIdx) break; heap[outIdx++] = 240 | u >> 18; heap[outIdx++] = 128 | u >> 12 & 63; heap[outIdx++] = 128 | u >> 6 & 63; @@ -7026,22 +7056,17 @@ var createModule = function() { var u = str.charCodeAt(i); if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str.charCodeAt(++i) & 1023; - if (u <= 127) - ++len; - else if (u <= 2047) - len += 2; - else if (u <= 65535) - len += 3; - else - len += 4; + if (u <= 127) ++len; + else if (u <= 2047) len += 2; + else if (u <= 65535) len += 3; + else len += 4; } return len; } function allocateUTF8(str) { var size = lengthBytesUTF8(str) + 1; var ret = _malloc(size); - if (ret) - stringToUTF8Array(str, HEAP8, ret, size); + if (ret) stringToUTF8Array(str, HEAP8, ret, size); return ret; } function writeArrayToMemory(array, buffer2) { @@ -7258,8 +7283,7 @@ var createModule = function() { var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0); var yday = (date.getTime() - start) / (1e3 * 60 * 60 * 24) | 0; LE_HEAP_STORE_I32((tmPtr + 28 >> 2) * 4, yday); - if (!_gmtime_r.GMTString) - _gmtime_r.GMTString = allocateUTF8("GMT"); + if (!_gmtime_r.GMTString) _gmtime_r.GMTString = allocateUTF8("GMT"); LE_HEAP_STORE_I32((tmPtr + 40 >> 2) * 4, _gmtime_r.GMTString); return tmPtr; } @@ -7311,10 +7335,9 @@ var createModule = function() { return ret; } function _tzset() { - if (_tzset.called) - return; + if (_tzset.called) return; _tzset.called = true; - var currentYear = new Date().getFullYear(); + var currentYear = (/* @__PURE__ */ new Date()).getFullYear(); var winter = new Date(currentYear, 0, 1); var summer = new Date(currentYear, 6, 1); var winterOffset = winter.getTimezoneOffset(); @@ -7442,10 +7465,8 @@ var createModule = function() { Module["getValue"] = getValue; var calledRun; dependenciesFulfilled = function runCaller() { - if (!calledRun) - run(); - if (!calledRun) - dependenciesFulfilled = runCaller; + if (!calledRun) run(); + if (!calledRun) dependenciesFulfilled = runCaller; }; function run(args) { if (runDependencies > 0) { @@ -7456,16 +7477,13 @@ var createModule = function() { return; } function doRun() { - if (calledRun) - return; + if (calledRun) return; calledRun = true; Module["calledRun"] = true; - if (ABORT) - return; + if (ABORT) return; initRuntime(); readyPromiseResolve(Module); - if (Module["onRuntimeInitialized"]) - Module["onRuntimeInitialized"](); + if (Module["onRuntimeInitialized"]) Module["onRuntimeInitialized"](); postRun(); } if (Module["setStatus"]) { @@ -7499,7 +7517,9 @@ const createModule = libzipSync.exports; const number64 = [ `number`, + // low `number` + // high ]; var Errors = /* @__PURE__ */ ((Errors2) => { Errors2[Errors2["ZIP_ER_OK"] = 0] = "ZIP_ER_OK"; @@ -7537,6 +7557,7 @@ var Errors = /* @__PURE__ */ ((Errors2) => { return Errors2; })(Errors || {}); const makeInterface = (emZip) => ({ + // Those are getters because they can change after memory growth get HEAPU8() { return emZip.HEAPU8; }, @@ -7739,6 +7760,7 @@ function makeEmptyArchive() { ]); } class LibzipError extends Error { + code; constructor(message, code) { super(message); this.name = `Libzip Error`; @@ -7746,15 +7768,28 @@ class LibzipError extends Error { } } class ZipFS extends BasePortableFakeFS { + libzip; + baseFs; + path; + stats; + zip; + lzSource; + level; + listings = /* @__PURE__ */ new Map(); + entries = /* @__PURE__ */ new Map(); + /** + * A cache of indices mapped to file sources. + * Populated by `setFileSource` calls. + * Required for supporting read after write. + */ + fileSources = /* @__PURE__ */ new Map(); + symlinkCount; + fds = /* @__PURE__ */ new Map(); + nextFd = 0; + ready = false; + readOnly = false; constructor(source, opts = {}) { super(); - this.listings = /* @__PURE__ */ new Map(); - this.entries = /* @__PURE__ */ new Map(); - this.fileSources = /* @__PURE__ */ new Map(); - this.fds = /* @__PURE__ */ new Map(); - this.nextFd = 0; - this.ready = false; - this.readOnly = false; const pathOptions = opts; this.level = typeof pathOptions.level !== `undefined` ? pathOptions.level : DEFAULT_COMPRESSION_LEVEL; source ??= makeEmptyArchive(); @@ -8003,6 +8038,7 @@ class ZipFS extends BasePortableFakeFS { }, bytesRead: 0, path: p, + // "This property is `true` if the underlying file has not been opened yet" pending: false } ); @@ -8049,6 +8085,7 @@ class ZipFS extends BasePortableFakeFS { }, bytesWritten: 0, path: p, + // "This property is `true` if the underlying file has not been opened yet" pending: false } ); @@ -9188,6 +9225,8 @@ function hydrateRuntimeState(data, { basePath }) { packagePeers: new Set(packageInformationData.packagePeers), linkType: packageInformationData.linkType, discardFromLookup, + // we only need this for packages that are used by the currently running script + // this is a lazy getter because `ppath.join` has some overhead get packageLocation() { return resolvedPackageLocation || (resolvedPackageLocation = ppath.join(absolutePortablePath, packageInformationData.packageLocation)); } @@ -9449,8 +9488,7 @@ function resolvePackageTargetString(target, subpath, match, packageJSONUrl, base const packagePath = new URL(".", packageJSONUrl).pathname; if (!StringPrototypeStartsWith(resolvedPath, packagePath)) throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); - if (subpath === "") - return resolved; + if (subpath === "") return resolved; if (RegExpPrototypeExec(invalidSegmentRegEx, subpath) !== null) { const request = pattern ? StringPrototypeReplace(match, "*", () => subpath) : match + subpath; throwInvalidSubpath(request, packageJSONUrl, internal, base); @@ -9464,8 +9502,7 @@ function resolvePackageTargetString(target, subpath, match, packageJSONUrl, base } function isArrayIndex(key) { const keyNum = +key; - if (`${keyNum}` !== key) - return false; + if (`${keyNum}` !== key) return false; return keyNum >= 0 && keyNum < 4294967295; } function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, base, pattern, internal, conditions) { @@ -9542,8 +9579,7 @@ function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, b internal, conditions ); - if (resolveResult === void 0) - continue; + if (resolveResult === void 0) continue; return resolveResult; } } @@ -9564,25 +9600,17 @@ function patternKeyCompare(a, b) { const bPatternIndex = StringPrototypeIndexOf(b, "*"); const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1; const baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1; - if (baseLenA > baseLenB) - return -1; - if (baseLenB > baseLenA) - return 1; - if (aPatternIndex === -1) - return 1; - if (bPatternIndex === -1) - return -1; - if (a.length > b.length) - return -1; - if (b.length > a.length) - return 1; + if (baseLenA > baseLenB) return -1; + if (baseLenB > baseLenA) return 1; + if (aPatternIndex === -1) return 1; + if (bPatternIndex === -1) return -1; + if (a.length > b.length) return -1; + if (b.length > a.length) return 1; return 0; } function isConditionalExportsMainSugar(exports, packageJSONUrl, base) { - if (typeof exports === "string" || ArrayIsArray(exports)) - return true; - if (typeof exports !== "object" || exports === null) - return false; + if (typeof exports === "string" || ArrayIsArray(exports)) return true; + if (typeof exports !== "object" || exports === null) return false; const keys = ObjectGetOwnPropertyNames(exports); let isConditionalSugar = false; let i = 0; @@ -9611,8 +9639,7 @@ function throwExportsNotFound(subpath, packageJSONUrl, base) { const emittedPackageWarnings = /* @__PURE__ */ new Set(); function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) { const pjsonPath = url.fileURLToPath(pjsonUrl); - if (emittedPackageWarnings.has(pjsonPath + "|" + match)) - return; + if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return; emittedPackageWarnings.add(pjsonPath + "|" + match); process.emitWarning( `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${url.fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, @@ -10881,9 +10908,9 @@ const defaultFsLayer = new VirtualFS({ }) }); class DynamicFS extends ProxiedFS { + baseFs = defaultFsLayer; constructor() { super(ppath); - this.baseFs = defaultFsLayer; } mapToBase(p) { return p; @@ -10898,6 +10925,11 @@ const defaultApi = Object.assign(makeApi(defaultRuntimeState, { fakeFs: dynamicFsLayer, pnpapiResolution: defaultPnpapiResolution }), { + /** + * Can be used to generate a different API than the default one (for example + * to map it on `/` rather than the local directory path, or to use a + * different FS layer than the default one). + */ makeApi: ({ basePath = void 0, fakeFs = dynamicFsLayer, @@ -10911,6 +10943,10 @@ const defaultApi = Object.assign(makeApi(defaultRuntimeState, { ...rest }); }, + /** + * Will inject the specified API into the environment, monkey-patching FS. Is + * automatically called when the hook is loaded through `--require`. + */ setup: (api) => { applyPatch(api || defaultApi, { fakeFs: defaultFsLayer, diff --git a/yarn.lock b/yarn.lock index 2573915..e46a775 100644 --- a/yarn.lock +++ b/yarn.lock @@ -536,7 +536,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^3.0.2": +"braces@npm:^3.0.3": version: 3.0.3 resolution: "braces@npm:3.0.3" dependencies: @@ -1664,12 +1664,12 @@ __metadata: linkType: hard "micromatch@npm:^4.0.0": - version: 4.0.5 - resolution: "micromatch@npm:4.0.5" + version: 4.0.8 + resolution: "micromatch@npm:4.0.8" dependencies: - braces: "npm:^3.0.2" + braces: "npm:^3.0.3" picomatch: "npm:^2.3.1" - checksum: 10c0/3d6505b20f9fa804af5d8c596cb1c5e475b9b0cd05f652c5b56141cf941bd72adaeb7a436fda344235cef93a7f29b7472efc779fcdb83b478eab0867b95cdeff + checksum: 10c0/166fa6eb926b9553f32ef81f5f531d27b4ce7da60e5baf8c021d043b27a388fb95e46a8038d5045877881e673f8134122b59624d5cecbd16eb50a42e7a6b5ca8 languageName: node linkType: hard