diff --git a/.pnp.cjs b/.pnp.cjs index 6ec5213..95c82a6 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -1206,7 +1206,7 @@ const RAW_RUNTIME_STATE = ["minipass-pipeline", "npm:1.2.4"],\ ["p-map", "npm:7.0.3"],\ ["ssri", "npm:12.0.0"],\ - ["tar", "npm:7.5.7"],\ + ["tar", "npm:7.5.9"],\ ["unique-filename", "npm:4.0.0"]\ ],\ "linkType": "HARD"\ @@ -1974,7 +1974,7 @@ const RAW_RUNTIME_STATE = ["nopt", "npm:8.1.0"],\ ["proc-log", "npm:5.0.0"],\ ["semver", "npm:7.7.2"],\ - ["tar", "npm:7.5.7"],\ + ["tar", "npm:7.5.9"],\ ["tinyglobby", "npm:0.2.15"],\ ["which", "npm:5.0.0"]\ ],\ @@ -2411,14 +2411,14 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["tar", [\ - ["npm:7.5.7", {\ - "packageLocation": "../../.yarn/berry/cache/tar-npm-7.5.7-053aec5a88-10c0.zip/node_modules/tar/",\ + ["npm:7.5.9", {\ + "packageLocation": "../../.yarn/berry/cache/tar-npm-7.5.9-dd42dd386e-10c0.zip/node_modules/tar/",\ "packageDependencies": [\ ["@isaacs/fs-minipass", "npm:4.0.1"],\ ["chownr", "npm:3.0.0"],\ ["minipass", "npm:7.1.2"],\ ["minizlib", "npm:3.1.0"],\ - ["tar", "npm:7.5.7"],\ + ["tar", "npm:7.5.9"],\ ["yallist", "npm:5.0.0"]\ ],\ "linkType": "HARD"\ @@ -5642,28 +5642,40 @@ class FileHandle { sync() { throw new Error(`Method not implemented.`); } - async read(bufferOrOptions, offset, length, position) { + async read(bufferOrOptions, offsetOrOptions, length, position) { try { this[kRef](this.read); let buffer; - if (!Buffer.isBuffer(bufferOrOptions)) { - bufferOrOptions ??= {}; - buffer = bufferOrOptions.buffer ?? Buffer.alloc(16384); - offset = bufferOrOptions.offset || 0; - length = bufferOrOptions.length ?? buffer.byteLength; - position = bufferOrOptions.position ?? null; + let offset; + if (!ArrayBuffer.isView(bufferOrOptions)) { + buffer = bufferOrOptions?.buffer ?? Buffer.alloc(16384); + offset = bufferOrOptions?.offset ?? 0; + length = bufferOrOptions?.length ?? buffer.byteLength - offset; + position = bufferOrOptions?.position ?? null; + } else if (typeof offsetOrOptions === `object` && offsetOrOptions !== null) { + buffer = bufferOrOptions; + offset = offsetOrOptions?.offset ?? 0; + length = offsetOrOptions?.length ?? buffer.byteLength - offset; + position = offsetOrOptions?.position ?? null; } else { buffer = bufferOrOptions; + offset = offsetOrOptions ?? 0; + length ??= 0; } - offset ??= 0; - length ??= 0; if (length === 0) { return { bytesRead: length, buffer }; } - const bytesRead = await this[kBaseFs].readPromise(this.fd, buffer, offset, length, position); + const bytesRead = await this[kBaseFs].readPromise( + this.fd, + // FIXME: FakeFS should support ArrayBufferViews directly + Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength), + offset, + length, + position + ); return { bytesRead, buffer @@ -8568,6 +8580,7 @@ function applyPatch(pnpapi, opts) { const optionNames = new Set(Object.keys(options)); optionNames.delete(`paths`); optionNames.delete(`plugnplay`); + optionNames.delete(`conditions`); if (optionNames.size > 0) { throw makeError( ErrorCode.UNSUPPORTED, @@ -8596,11 +8609,15 @@ function applyPatch(pnpapi, opts) { const issuerApi = apiPath !== null ? opts.manager.getApiEntry(apiPath, true).instance : null; try { if (issuerApi !== null) { - resolution = issuerApi.resolveRequest(request, path !== null ? `${path}/` : null); + resolution = issuerApi.resolveRequest(request, path !== null ? `${path}/` : null, { + conditions: options?.conditions + }); } else { if (path === null) throw new Error(`Assertion failed: Expected the path to be set`); - resolution = originalModuleResolveFilename.call(require$$0.Module, request, module || makeFakeParent(path), isMain); + resolution = originalModuleResolveFilename.call(require$$0.Module, request, module || makeFakeParent(path), isMain, { + conditions: options?.conditions + }); } } catch (error) { firstError = firstError || error; diff --git a/yarn.lock b/yarn.lock index ca70a59..415ffe3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2079,15 +2079,15 @@ __metadata: linkType: hard "tar@npm:^7.4.3": - version: 7.5.7 - resolution: "tar@npm:7.5.7" + version: 7.5.9 + resolution: "tar@npm:7.5.9" dependencies: "@isaacs/fs-minipass": "npm:^4.0.0" chownr: "npm:^3.0.0" minipass: "npm:^7.1.2" minizlib: "npm:^3.1.0" yallist: "npm:^5.0.0" - checksum: 10c0/51f261afc437e1112c3e7919478d6176ea83f7f7727864d8c2cce10f0b03a631d1911644a567348c3063c45abdae39718ba97abb073d22aa3538b9a53ae1e31c + checksum: 10c0/e870beb1b2477135ca2abe86b2d18f7b35d0a4e3a37bbc523d3b8f7adca268dfab543f26528a431d569897f8c53a7cac745cdfbc4411c2f89aeeacc652b81b0a languageName: node linkType: hard