snyk 1.1264.0 → 1.1265.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/245.index.js +2924 -1036
- package/dist/cli/245.index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +65 -2
- package/package.json +1 -1
- package/src/generated/sha256sums.txt +8 -8
- package/src/generated/version +1 -1
- package/wrapper_dist/generated/sha256sums.txt +8 -8
- package/wrapper_dist/generated/version +1 -1
package/dist/cli/245.index.js
CHANGED
|
@@ -18194,6 +18194,28 @@ exports.JSON = "application/json";
|
|
|
18194
18194
|
|
|
18195
18195
|
/***/ }),
|
|
18196
18196
|
|
|
18197
|
+
/***/ 72614:
|
|
18198
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
18199
|
+
|
|
18200
|
+
"use strict";
|
|
18201
|
+
|
|
18202
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
18203
|
+
exports.downloadLayer = void 0;
|
|
18204
|
+
const registry_call_1 = __webpack_require__(15271);
|
|
18205
|
+
const contentTypes = __webpack_require__(42625);
|
|
18206
|
+
async function downloadLayer(output, registryBase, repo, digest, username, password, options = {}) {
|
|
18207
|
+
var _a;
|
|
18208
|
+
const accept = `${(_a = options.acceptLayer) !== null && _a !== void 0 ? _a : contentTypes.LAYER}`;
|
|
18209
|
+
const endpoint = `/${repo}/blobs/${digest}`;
|
|
18210
|
+
options = Object.assign({ json: false, encoding: null, snykInternalOutputStream: output }, options);
|
|
18211
|
+
const layerResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, username, password, options);
|
|
18212
|
+
return layerResponse;
|
|
18213
|
+
}
|
|
18214
|
+
exports.downloadLayer = downloadLayer;
|
|
18215
|
+
//# sourceMappingURL=download-layer.js.map
|
|
18216
|
+
|
|
18217
|
+
/***/ }),
|
|
18218
|
+
|
|
18197
18219
|
/***/ 80290:
|
|
18198
18220
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
18199
18221
|
|
|
@@ -18296,6 +18318,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
18296
18318
|
exports.getLayer = void 0;
|
|
18297
18319
|
const registry_call_1 = __webpack_require__(15271);
|
|
18298
18320
|
const contentTypes = __webpack_require__(42625);
|
|
18321
|
+
/** @deprecated use downloadLayer instead. */
|
|
18299
18322
|
async function getLayer(registryBase, repo, digest, username, password, options = {}) {
|
|
18300
18323
|
var _a;
|
|
18301
18324
|
const accept = `${(_a = options.acceptLayer) !== null && _a !== void 0 ? _a : contentTypes.LAYER}`;
|
|
@@ -18460,9 +18483,11 @@ exports.getTags = getTags;
|
|
|
18460
18483
|
"use strict";
|
|
18461
18484
|
|
|
18462
18485
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
18463
|
-
exports.contentTypes = exports.types = exports.validation = exports.registryCall = exports.getTags = exports.getRepos = exports.getManifest = exports.getLayer = exports.getImageSize = exports.getImageConfig = exports.getAuthTokenForEndpoint = exports.checkSupport = void 0;
|
|
18486
|
+
exports.contentTypes = exports.types = exports.validation = exports.registryCall = exports.getTags = exports.getRepos = exports.getManifest = exports.getLayer = exports.getImageSize = exports.getImageConfig = exports.getAuthTokenForEndpoint = exports.downloadLayer = exports.checkSupport = void 0;
|
|
18464
18487
|
const check_support_1 = __webpack_require__(87315);
|
|
18465
18488
|
Object.defineProperty(exports, "checkSupport", ({ enumerable: true, get: function () { return check_support_1.checkSupport; } }));
|
|
18489
|
+
const download_layer_1 = __webpack_require__(72614);
|
|
18490
|
+
Object.defineProperty(exports, "downloadLayer", ({ enumerable: true, get: function () { return download_layer_1.downloadLayer; } }));
|
|
18466
18491
|
const get_auth_token_for_endpoint_1 = __webpack_require__(80290);
|
|
18467
18492
|
Object.defineProperty(exports, "getAuthTokenForEndpoint", ({ enumerable: true, get: function () { return get_auth_token_for_endpoint_1.getAuthTokenForEndpoint; } }));
|
|
18468
18493
|
const get_image_config_1 = __webpack_require__(50702);
|
|
@@ -18496,7 +18521,9 @@ exports.contentTypes = contentTypes;
|
|
|
18496
18521
|
|
|
18497
18522
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
18498
18523
|
exports.NeedleWrapperException = exports.parseResponseBody = exports.needleWrapper = void 0;
|
|
18524
|
+
const fs = __webpack_require__(57147);
|
|
18499
18525
|
const needle = __webpack_require__(57441);
|
|
18526
|
+
const stream_1 = __webpack_require__(12781);
|
|
18500
18527
|
// TODO: this is a temporary code that allows setting needle default timeout (alias for
|
|
18501
18528
|
// open_timeout) to check how it affects the stability of our system, and specifically
|
|
18502
18529
|
// if it helps reducing 'socket hang up' errors.
|
|
@@ -18534,7 +18561,17 @@ async function needleWrapper(options, maxRetries) {
|
|
|
18534
18561
|
while (!response && retries >= 0) {
|
|
18535
18562
|
retries--;
|
|
18536
18563
|
try {
|
|
18537
|
-
|
|
18564
|
+
if (options.snykInternalOutputStream) {
|
|
18565
|
+
response = await stream(needle.get(uri, Object.assign(Object.assign({}, options), {
|
|
18566
|
+
// needle streams the response to file and memory as convenience if output is set.
|
|
18567
|
+
// causes high memory usage for large binaries.
|
|
18568
|
+
output: null,
|
|
18569
|
+
// we treat the response body as a binary stream
|
|
18570
|
+
parse_response: false })), fs.createWriteStream(options.snykInternalOutputStream));
|
|
18571
|
+
}
|
|
18572
|
+
else {
|
|
18573
|
+
response = await needle("get", uri, options);
|
|
18574
|
+
}
|
|
18538
18575
|
}
|
|
18539
18576
|
catch (err) {
|
|
18540
18577
|
lastError = err;
|
|
@@ -18583,6 +18620,43 @@ class NeedleWrapperException extends Error {
|
|
|
18583
18620
|
}
|
|
18584
18621
|
}
|
|
18585
18622
|
exports.NeedleWrapperException = NeedleWrapperException;
|
|
18623
|
+
/**
|
|
18624
|
+
* Streams the readable stream to the writeable stream and returns the response
|
|
18625
|
+
* of the underlying http.ClientRequest.
|
|
18626
|
+
*/
|
|
18627
|
+
async function stream(readable, writeable) {
|
|
18628
|
+
return new Promise((resolve, reject) => {
|
|
18629
|
+
let response;
|
|
18630
|
+
// Emitted when the underlying http.ClientRequest emits a response event.
|
|
18631
|
+
// This is after the connection is established and the header received, but
|
|
18632
|
+
// before any of it is processed (e.g. authorization required or redirect
|
|
18633
|
+
// to be followed). No data has been consumed at this point.
|
|
18634
|
+
readable.on("response", inner => {
|
|
18635
|
+
response = inner;
|
|
18636
|
+
});
|
|
18637
|
+
// Triggered after the header has been processed, and just before the data
|
|
18638
|
+
// is to be consumed. This implies that no redirect was followed and/or
|
|
18639
|
+
// authentication header was received. In other words, we got a "valid"
|
|
18640
|
+
// response.
|
|
18641
|
+
readable.on("header", (statusCode, headers) => {
|
|
18642
|
+
response.statusCode = statusCode;
|
|
18643
|
+
response.headers = headers;
|
|
18644
|
+
});
|
|
18645
|
+
// Emitted when an error ocurrs. This should only happen once in the
|
|
18646
|
+
// lifecycle of a Needle request.
|
|
18647
|
+
readable.on("err", err => {
|
|
18648
|
+
reject(err);
|
|
18649
|
+
});
|
|
18650
|
+
// Emitted when an timeout error occurs. Type can be either 'open',
|
|
18651
|
+
// 'response', or 'read'. This will called right before aborting the
|
|
18652
|
+
// request, which will also trigger an err event, a described above, with
|
|
18653
|
+
// an ECONNRESET (Socket hang up) exception.
|
|
18654
|
+
readable.on("timeout", type => {
|
|
18655
|
+
reject(new Error(type + " timeout"));
|
|
18656
|
+
});
|
|
18657
|
+
(0, stream_1.pipeline)(readable, writeable, err => err ? reject(err) : resolve(response));
|
|
18658
|
+
});
|
|
18659
|
+
}
|
|
18586
18660
|
//# sourceMappingURL=needle.js.map
|
|
18587
18661
|
|
|
18588
18662
|
/***/ }),
|
|
@@ -18704,7 +18778,9 @@ async function getToken(registryBase, authBase, service, scope, username, passwo
|
|
|
18704
18778
|
reqConfig.username = username;
|
|
18705
18779
|
reqConfig.password = password;
|
|
18706
18780
|
}
|
|
18707
|
-
const response = await (0, needle_1.needleWrapper)(reqConfig)
|
|
18781
|
+
const response = await (0, needle_1.needleWrapper)(Object.assign(Object.assign({}, reqConfig), {
|
|
18782
|
+
// we always want to read the credentials through the body
|
|
18783
|
+
snykInternalOutputStream: undefined }));
|
|
18708
18784
|
const body = (0, needle_1.parseResponseBody)(response);
|
|
18709
18785
|
return body.token || body.access_token;
|
|
18710
18786
|
}
|
|
@@ -38904,10 +38980,11 @@ const crypto = __webpack_require__(6113);
|
|
|
38904
38980
|
const fs = __webpack_require__(57147);
|
|
38905
38981
|
const os = __webpack_require__(22037);
|
|
38906
38982
|
const path = __webpack_require__(71017);
|
|
38907
|
-
const
|
|
38908
|
-
const
|
|
38909
|
-
const tar = __webpack_require__(53871);
|
|
38983
|
+
const tar = __webpack_require__(75993);
|
|
38984
|
+
const crypto_1 = __webpack_require__(6113);
|
|
38910
38985
|
const util_1 = __webpack_require__(73837);
|
|
38986
|
+
const subProcess = __webpack_require__(77685);
|
|
38987
|
+
const tmp = __webpack_require__(62697);
|
|
38911
38988
|
const errors_1 = __webpack_require__(26518);
|
|
38912
38989
|
const readFile = (0, util_1.promisify)(fs.readFile);
|
|
38913
38990
|
const link = (0, util_1.promisify)(fs.link);
|
|
@@ -38956,16 +39033,20 @@ class DockerPull {
|
|
|
38956
39033
|
const imageConfig = await registryClient.getImageConfig(registryBase, repo, imageConfigMetadata.digest, opt === null || opt === void 0 ? void 0 : opt.username, opt === null || opt === void 0 ? void 0 : opt.password, opt === null || opt === void 0 ? void 0 : opt.reqOptions);
|
|
38957
39034
|
const t0 = Date.now();
|
|
38958
39035
|
const layersConfigs = manifest.layers;
|
|
38959
|
-
const
|
|
39036
|
+
const blobDir = tmp.dirSync();
|
|
39037
|
+
const missingLayers = await this.downloadLayers(blobDir, layersConfigs, registryBase, repo, opt === null || opt === void 0 ? void 0 : opt.username, opt === null || opt === void 0 ? void 0 : opt.password, opt === null || opt === void 0 ? void 0 : opt.reqOptions);
|
|
39038
|
+
const stagingDirPath = opt.stagingDirPath
|
|
39039
|
+
? opt.stagingDirPath
|
|
39040
|
+
: os.tmpdir();
|
|
38960
39041
|
const pullDuration = Date.now() - t0;
|
|
38961
39042
|
let imageDigest;
|
|
38962
|
-
const stagingDir = this.createDownloadedImageDestination(opt === null || opt === void 0 ? void 0 : opt.imageSavePath);
|
|
39043
|
+
const stagingDir = this.createDownloadedImageDestination(stagingDirPath, opt === null || opt === void 0 ? void 0 : opt.imageSavePath);
|
|
38963
39044
|
try {
|
|
38964
39045
|
if ((manifest === null || manifest === void 0 ? void 0 : manifest.manifestContentType) === docker_registry_v2_client_1.contentTypes.OCI_MANIFEST_V1) {
|
|
38965
|
-
await this.buildOCIImage(imageConfigMetadata.digest, manifest, imageConfig, missingLayers, stagingDir);
|
|
39046
|
+
await this.buildOCIImage(imageConfigMetadata.digest, manifest, imageConfig, missingLayers, blobDir, stagingDir);
|
|
38966
39047
|
}
|
|
38967
39048
|
else {
|
|
38968
|
-
await this.buildImage(imageConfigMetadata.digest, imageConfig, layersConfigs, missingLayers, stagingDir);
|
|
39049
|
+
await this.buildImage(imageConfigMetadata.digest, imageConfig, layersConfigs, missingLayers, blobDir, stagingDir);
|
|
38969
39050
|
}
|
|
38970
39051
|
if (loadImage) {
|
|
38971
39052
|
imageDigest = await this.loadImage(registryBase, repo, tag, stagingDir);
|
|
@@ -38982,7 +39063,7 @@ class DockerPull {
|
|
|
38982
39063
|
tag });
|
|
38983
39064
|
for (const [name, requestMatcher] of Object.entries(await this.saveRequests())) {
|
|
38984
39065
|
if (Object.keys(requestMatcher).every((key) => requestMatcher[key] === saveMatcher[key])) {
|
|
38985
|
-
await link(path.join(stagingDir.name, "image.tar"),
|
|
39066
|
+
await link(path.join(stagingDir.name, "image.tar"), path.join(stagingDirPath, `${name}-${(0, crypto_1.randomUUID)()}.tar`));
|
|
38986
39067
|
break;
|
|
38987
39068
|
}
|
|
38988
39069
|
}
|
|
@@ -38990,6 +39071,7 @@ class DockerPull {
|
|
|
38990
39071
|
catch (err) {
|
|
38991
39072
|
console.error("pullSaveRequest error: ", err);
|
|
38992
39073
|
}
|
|
39074
|
+
blobDir.removeCallback();
|
|
38993
39075
|
if (loadImage) {
|
|
38994
39076
|
stagingDir.removeCallback();
|
|
38995
39077
|
}
|
|
@@ -39000,30 +39082,20 @@ class DockerPull {
|
|
|
39000
39082
|
cachedLayersDigests: [],
|
|
39001
39083
|
missingLayersDigests: missingLayers.map((layer) => layer.config.digest),
|
|
39002
39084
|
pullDuration,
|
|
39003
|
-
missingLayersCalculatedDigests: opt.calculateMissingLayersDigests
|
|
39004
|
-
? missingLayers.map((layer) => this.calculateLayerDigest(layer))
|
|
39005
|
-
: [],
|
|
39006
39085
|
indexDigest,
|
|
39007
39086
|
manifestDigest,
|
|
39008
39087
|
};
|
|
39009
39088
|
}
|
|
39010
|
-
async
|
|
39089
|
+
async downloadLayers(blobDir, layersConfigs, registryBase, repo, username, password,
|
|
39011
39090
|
// weak typing on the client
|
|
39012
39091
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39013
39092
|
reqOptions = {}) {
|
|
39014
39093
|
return await Promise.all(layersConfigs.map(async (config) => {
|
|
39015
|
-
const
|
|
39016
|
-
|
|
39094
|
+
const blobName = crypto.randomUUID();
|
|
39095
|
+
await registryClient.downloadLayer(path.join(blobDir.name, blobName), registryBase, repo, config.digest, username, password, reqOptions);
|
|
39096
|
+
return { config, blobName };
|
|
39017
39097
|
}));
|
|
39018
39098
|
}
|
|
39019
|
-
calculateLayerDigest(layer) {
|
|
39020
|
-
const hashAlgorithm = layer.config.digest.split(":")[0];
|
|
39021
|
-
const calculatedDigest = crypto
|
|
39022
|
-
.createHash(hashAlgorithm)
|
|
39023
|
-
.update(layer.blob)
|
|
39024
|
-
.digest("hex");
|
|
39025
|
-
return `${hashAlgorithm}:${calculatedDigest}`;
|
|
39026
|
-
}
|
|
39027
39099
|
async saveRequests() {
|
|
39028
39100
|
const saveRequestsPath = path.join(os.tmpdir(), "pullSaveRequest.json");
|
|
39029
39101
|
try {
|
|
@@ -39035,44 +39107,54 @@ class DockerPull {
|
|
|
39035
39107
|
return {};
|
|
39036
39108
|
}
|
|
39037
39109
|
}
|
|
39038
|
-
async buildOCIImage(imageDigest, manifest, imageConfig, layers, stagingDir) {
|
|
39039
|
-
const pack = tar.pack(
|
|
39040
|
-
|
|
39041
|
-
|
|
39042
|
-
|
|
39043
|
-
|
|
39044
|
-
|
|
39045
|
-
|
|
39046
|
-
|
|
39047
|
-
|
|
39048
|
-
|
|
39049
|
-
|
|
39050
|
-
|
|
39051
|
-
|
|
39052
|
-
|
|
39053
|
-
|
|
39054
|
-
|
|
39055
|
-
|
|
39056
|
-
|
|
39057
|
-
|
|
39058
|
-
|
|
39059
|
-
|
|
39060
|
-
|
|
39061
|
-
|
|
39062
|
-
|
|
39063
|
-
|
|
39064
|
-
|
|
39065
|
-
|
|
39066
|
-
|
|
39067
|
-
|
|
39068
|
-
|
|
39069
|
-
|
|
39070
|
-
|
|
39071
|
-
|
|
39072
|
-
|
|
39073
|
-
|
|
39074
|
-
|
|
39075
|
-
|
|
39110
|
+
async buildOCIImage(imageDigest, manifest, imageConfig, layers, blobDir, stagingDir) {
|
|
39111
|
+
const pack = tar.pack(blobDir.name, {
|
|
39112
|
+
// write layers
|
|
39113
|
+
entries: layers.map((layer) => layer.blobName),
|
|
39114
|
+
map(header) {
|
|
39115
|
+
const layer = layers.find((layer) => layer.blobName == header.name);
|
|
39116
|
+
const digest = layer.config.digest.replace("sha256:", "");
|
|
39117
|
+
header.name = path.join("blobs", "sha256", digest);
|
|
39118
|
+
return header;
|
|
39119
|
+
},
|
|
39120
|
+
finalize: false,
|
|
39121
|
+
finish(pack) {
|
|
39122
|
+
const configContent = JSON.stringify(imageConfig);
|
|
39123
|
+
const configDigest = imageDigest.replace("sha256:", "");
|
|
39124
|
+
pack.entry({ name: path.join("blobs", "sha256", configDigest) }, configContent);
|
|
39125
|
+
// Ensure config digest and size is accurate following serialization round trip
|
|
39126
|
+
manifest.config.digest = `sha256:${configDigest}`;
|
|
39127
|
+
manifest.config.size = Buffer.byteLength(configContent, "utf8");
|
|
39128
|
+
// Unset properties added by docker-registry-v2-client
|
|
39129
|
+
manifest.indexDigest = undefined;
|
|
39130
|
+
manifest.manifestDigest = undefined;
|
|
39131
|
+
manifest.manifestContentType = undefined;
|
|
39132
|
+
const manifestContent = JSON.stringify(manifest);
|
|
39133
|
+
const manifestDigest = crypto
|
|
39134
|
+
.createHash("sha256")
|
|
39135
|
+
.update(manifestContent)
|
|
39136
|
+
.digest("hex")
|
|
39137
|
+
.toLowerCase();
|
|
39138
|
+
pack.entry({ name: path.join("blobs", "sha256", manifestDigest) }, manifestContent);
|
|
39139
|
+
const indexContent = JSON.stringify({
|
|
39140
|
+
schemaVersion: 2,
|
|
39141
|
+
mediaType: docker_registry_v2_client_1.contentTypes.OCI_INDEX_V1,
|
|
39142
|
+
manifests: [
|
|
39143
|
+
{
|
|
39144
|
+
mediaType: docker_registry_v2_client_1.contentTypes.OCI_MANIFEST_V1,
|
|
39145
|
+
size: Buffer.byteLength(manifestContent, "utf8"),
|
|
39146
|
+
digest: `sha256:${manifestDigest}`,
|
|
39147
|
+
},
|
|
39148
|
+
],
|
|
39149
|
+
});
|
|
39150
|
+
pack.entry({ name: "index.json" }, indexContent);
|
|
39151
|
+
const ociLayoutContent = JSON.stringify({
|
|
39152
|
+
imageLayoutVersion: "1.0.0",
|
|
39153
|
+
});
|
|
39154
|
+
pack.entry({ name: "oci-layout" }, ociLayoutContent, () => {
|
|
39155
|
+
pack.finalize();
|
|
39156
|
+
});
|
|
39157
|
+
},
|
|
39076
39158
|
});
|
|
39077
39159
|
const imagePath = path.join(stagingDir.name, "image.tar");
|
|
39078
39160
|
const file = fs.createWriteStream(imagePath);
|
|
@@ -39082,55 +39164,61 @@ class DockerPull {
|
|
|
39082
39164
|
file.on("error", (err) => reject(err));
|
|
39083
39165
|
});
|
|
39084
39166
|
}
|
|
39085
|
-
async buildImage(imageDigest, imageConfig, layersConfigs, layers, stagingDir) {
|
|
39086
|
-
|
|
39087
|
-
// write layers
|
|
39167
|
+
async buildImage(imageDigest, imageConfig, layersConfigs, layers, blobDir, stagingDir) {
|
|
39168
|
+
// generate layer metadata
|
|
39088
39169
|
let parentDigest;
|
|
39170
|
+
const layerMetadata = {};
|
|
39089
39171
|
for (const layerConfig of layersConfigs) {
|
|
39090
39172
|
const digest = layerConfig.digest.replace("sha256:", "");
|
|
39091
|
-
// write layer.tar
|
|
39092
|
-
let blob;
|
|
39093
|
-
for (const layer of layers) {
|
|
39094
|
-
if (layerConfig.digest === layer.config.digest) {
|
|
39095
|
-
blob = layer.blob;
|
|
39096
|
-
break;
|
|
39097
|
-
}
|
|
39098
|
-
}
|
|
39099
|
-
if (!blob) {
|
|
39100
|
-
throw new Error(`missing blob during build: ${digest}`);
|
|
39101
|
-
}
|
|
39102
|
-
pack.entry({ name: path.join(digest, "layer.tar") }, blob);
|
|
39103
|
-
// write json
|
|
39104
39173
|
let json = Object.assign({}, { id: digest }, DEFAULT_LAYER_JSON);
|
|
39105
39174
|
if (parentDigest) {
|
|
39106
39175
|
json = Object.assign({ parent: parentDigest });
|
|
39107
39176
|
}
|
|
39108
|
-
pack.entry({ name: path.join(digest, "json") }, JSON.stringify(json));
|
|
39109
39177
|
parentDigest = digest;
|
|
39110
|
-
|
|
39111
|
-
|
|
39112
|
-
|
|
39113
|
-
|
|
39114
|
-
|
|
39115
|
-
pack.
|
|
39116
|
-
|
|
39117
|
-
|
|
39118
|
-
{
|
|
39119
|
-
|
|
39120
|
-
|
|
39121
|
-
|
|
39178
|
+
layerMetadata[digest] = {
|
|
39179
|
+
json: JSON.stringify(json),
|
|
39180
|
+
version: "1.0",
|
|
39181
|
+
};
|
|
39182
|
+
}
|
|
39183
|
+
const pack = tar.pack(blobDir.name, {
|
|
39184
|
+
// write layers
|
|
39185
|
+
entries: layers.map((layer) => layer.blobName),
|
|
39186
|
+
map(header) {
|
|
39187
|
+
const layer = layers.find((layer) => layer.blobName === header.name);
|
|
39188
|
+
const digest = layer.config.digest.replace("sha256:", "");
|
|
39189
|
+
header.name = path.join(digest, "layer.tar");
|
|
39190
|
+
return header;
|
|
39191
|
+
},
|
|
39192
|
+
finalize: false,
|
|
39193
|
+
finish(pack) {
|
|
39194
|
+
// write layer metadata
|
|
39195
|
+
for (const digest of Object.keys(layerMetadata)) {
|
|
39196
|
+
const metadata = layerMetadata[digest];
|
|
39197
|
+
pack.entry({ name: path.join(digest, "json") }, metadata.json);
|
|
39198
|
+
pack.entry({ name: path.join(digest, "VERSION") }, metadata.version);
|
|
39199
|
+
}
|
|
39200
|
+
imageDigest = imageDigest.replace("sha256:", "");
|
|
39201
|
+
// write image json
|
|
39202
|
+
pack.entry({ name: `${imageDigest}.json` }, JSON.stringify(imageConfig));
|
|
39203
|
+
// write manifest.json
|
|
39204
|
+
const manifestJson = [
|
|
39205
|
+
{
|
|
39206
|
+
Config: `${imageDigest}.json`,
|
|
39207
|
+
RepoTags: null,
|
|
39208
|
+
Layers: layersConfigs.map((config) => `${config.digest.replace("sha256:", "")}/layer.tar`),
|
|
39209
|
+
},
|
|
39210
|
+
];
|
|
39211
|
+
pack.entry({ name: "manifest.json" }, JSON.stringify(manifestJson), () => {
|
|
39212
|
+
pack.finalize();
|
|
39213
|
+
});
|
|
39122
39214
|
},
|
|
39123
|
-
];
|
|
39124
|
-
pack.entry({ name: "manifest.json" }, JSON.stringify(manifestJson), () => {
|
|
39125
|
-
pack.finalize();
|
|
39126
39215
|
});
|
|
39127
39216
|
const imagePath = path.join(stagingDir.name, "image.tar");
|
|
39128
39217
|
const file = fs.createWriteStream(imagePath);
|
|
39129
39218
|
pack.pipe(file);
|
|
39130
|
-
return new Promise((resolve) => {
|
|
39131
|
-
file.on("close", () =>
|
|
39132
|
-
|
|
39133
|
-
});
|
|
39219
|
+
return new Promise((resolve, reject) => {
|
|
39220
|
+
file.on("close", () => resolve(path.join(imagePath)));
|
|
39221
|
+
file.on("error", (err) => reject(err));
|
|
39134
39222
|
});
|
|
39135
39223
|
}
|
|
39136
39224
|
async loadImage(registryBase, repo, tag, stagingDir) {
|
|
@@ -39145,17 +39233,16 @@ class DockerPull {
|
|
|
39145
39233
|
]);
|
|
39146
39234
|
return imgDigest;
|
|
39147
39235
|
}
|
|
39148
|
-
createDownloadedImageDestination(imageSavePath) {
|
|
39236
|
+
createDownloadedImageDestination(stagingDirPath, imageSavePath) {
|
|
39149
39237
|
if (!imageSavePath) {
|
|
39150
|
-
return tmp.dirSync({
|
|
39238
|
+
return tmp.dirSync({ path: stagingDirPath });
|
|
39151
39239
|
}
|
|
39152
|
-
|
|
39240
|
+
return {
|
|
39153
39241
|
name: imageSavePath,
|
|
39154
39242
|
removeCallback: () => {
|
|
39155
39243
|
/* do nothing */
|
|
39156
39244
|
},
|
|
39157
39245
|
};
|
|
39158
|
-
return dirResult;
|
|
39159
39246
|
}
|
|
39160
39247
|
}
|
|
39161
39248
|
exports.DockerPull = DockerPull;
|
|
@@ -39236,1156 +39323,1472 @@ exports.execute = execute;
|
|
|
39236
39323
|
|
|
39237
39324
|
/***/ }),
|
|
39238
39325
|
|
|
39239
|
-
/***/
|
|
39240
|
-
/***/ ((
|
|
39326
|
+
/***/ 62697:
|
|
39327
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
39241
39328
|
|
|
39242
|
-
|
|
39243
|
-
const path = __webpack_require__(71017)
|
|
39244
|
-
const fs = __webpack_require__(57147)
|
|
39245
|
-
let glob = undefined
|
|
39246
|
-
try {
|
|
39247
|
-
glob = __webpack_require__(12884)
|
|
39248
|
-
} catch (_err) {
|
|
39249
|
-
// treat glob as optional.
|
|
39250
|
-
}
|
|
39329
|
+
"use strict";
|
|
39251
39330
|
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
|
|
39331
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
39332
|
+
exports.dirSync = void 0;
|
|
39333
|
+
const fs = __webpack_require__(57147);
|
|
39334
|
+
const os = __webpack_require__(22037);
|
|
39335
|
+
const path = __webpack_require__(71017);
|
|
39336
|
+
/**
|
|
39337
|
+
* Creates a temporary directory.
|
|
39338
|
+
*/
|
|
39339
|
+
function dirSync(options) {
|
|
39340
|
+
var _a;
|
|
39341
|
+
const name = fs.mkdtempSync(`${(_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : os.tmpdir()}${path.sep}`);
|
|
39342
|
+
return {
|
|
39343
|
+
name,
|
|
39344
|
+
removeCallback() {
|
|
39345
|
+
fs.rmSync(name, { recursive: true });
|
|
39346
|
+
},
|
|
39347
|
+
};
|
|
39255
39348
|
}
|
|
39349
|
+
exports.dirSync = dirSync;
|
|
39350
|
+
//# sourceMappingURL=tmp.js.map
|
|
39256
39351
|
|
|
39257
|
-
|
|
39258
|
-
let timeout = 0
|
|
39352
|
+
/***/ }),
|
|
39259
39353
|
|
|
39260
|
-
|
|
39354
|
+
/***/ 75993:
|
|
39355
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
39261
39356
|
|
|
39262
|
-
const
|
|
39263
|
-
|
|
39264
|
-
|
|
39265
|
-
|
|
39266
|
-
|
|
39267
|
-
'lstat',
|
|
39268
|
-
'rmdir',
|
|
39269
|
-
'readdir'
|
|
39270
|
-
]
|
|
39271
|
-
methods.forEach(m => {
|
|
39272
|
-
options[m] = options[m] || fs[m]
|
|
39273
|
-
m = m + 'Sync'
|
|
39274
|
-
options[m] = options[m] || fs[m]
|
|
39275
|
-
})
|
|
39357
|
+
const tar = __webpack_require__(5464)
|
|
39358
|
+
const pump = __webpack_require__(74286)
|
|
39359
|
+
const mkdirp = __webpack_require__(42986)
|
|
39360
|
+
const fs = __webpack_require__(57147)
|
|
39361
|
+
const path = __webpack_require__(71017)
|
|
39276
39362
|
|
|
39277
|
-
|
|
39278
|
-
|
|
39279
|
-
|
|
39280
|
-
|
|
39363
|
+
const win32 = process.platform === 'win32'
|
|
39364
|
+
|
|
39365
|
+
exports.pack = function pack (cwd, opts) {
|
|
39366
|
+
if (!cwd) cwd = '.'
|
|
39367
|
+
if (!opts) opts = {}
|
|
39368
|
+
|
|
39369
|
+
const xfs = opts.fs || fs
|
|
39370
|
+
const ignore = opts.ignore || opts.filter || noop
|
|
39371
|
+
const mapStream = opts.mapStream || echo
|
|
39372
|
+
const statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort)
|
|
39373
|
+
const strict = opts.strict !== false
|
|
39374
|
+
const umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()
|
|
39375
|
+
const pack = opts.pack || tar.pack()
|
|
39376
|
+
const finish = opts.finish || noop
|
|
39377
|
+
|
|
39378
|
+
let map = opts.map || noop
|
|
39379
|
+
let dmode = typeof opts.dmode === 'number' ? opts.dmode : 0
|
|
39380
|
+
let fmode = typeof opts.fmode === 'number' ? opts.fmode : 0
|
|
39381
|
+
|
|
39382
|
+
if (opts.strip) map = strip(map, opts.strip)
|
|
39383
|
+
|
|
39384
|
+
if (opts.readable) {
|
|
39385
|
+
dmode |= parseInt(555, 8)
|
|
39386
|
+
fmode |= parseInt(444, 8)
|
|
39281
39387
|
}
|
|
39282
|
-
if (
|
|
39283
|
-
|
|
39388
|
+
if (opts.writable) {
|
|
39389
|
+
dmode |= parseInt(333, 8)
|
|
39390
|
+
fmode |= parseInt(222, 8)
|
|
39284
39391
|
}
|
|
39285
|
-
options.disableGlob = options.disableGlob || false
|
|
39286
|
-
options.glob = options.glob || defaultGlobOpts
|
|
39287
|
-
}
|
|
39288
39392
|
|
|
39289
|
-
|
|
39290
|
-
|
|
39291
|
-
|
|
39292
|
-
|
|
39393
|
+
onnextentry()
|
|
39394
|
+
|
|
39395
|
+
function onsymlink (filename, header) {
|
|
39396
|
+
xfs.readlink(path.join(cwd, filename), function (err, linkname) {
|
|
39397
|
+
if (err) return pack.destroy(err)
|
|
39398
|
+
header.linkname = normalize(linkname)
|
|
39399
|
+
pack.entry(header, onnextentry)
|
|
39400
|
+
})
|
|
39293
39401
|
}
|
|
39294
39402
|
|
|
39295
|
-
|
|
39296
|
-
|
|
39297
|
-
|
|
39298
|
-
|
|
39299
|
-
|
|
39403
|
+
function onstat (err, filename, stat) {
|
|
39404
|
+
if (err) return pack.destroy(err)
|
|
39405
|
+
if (!filename) {
|
|
39406
|
+
if (opts.finalize !== false) pack.finalize()
|
|
39407
|
+
return finish(pack)
|
|
39408
|
+
}
|
|
39300
39409
|
|
|
39301
|
-
|
|
39410
|
+
if (stat.isSocket()) return onnextentry() // tar does not support sockets...
|
|
39302
39411
|
|
|
39303
|
-
|
|
39304
|
-
|
|
39305
|
-
|
|
39412
|
+
let header = {
|
|
39413
|
+
name: normalize(filename),
|
|
39414
|
+
mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,
|
|
39415
|
+
mtime: stat.mtime,
|
|
39416
|
+
size: stat.size,
|
|
39417
|
+
type: 'file',
|
|
39418
|
+
uid: stat.uid,
|
|
39419
|
+
gid: stat.gid
|
|
39420
|
+
}
|
|
39306
39421
|
|
|
39307
|
-
|
|
39308
|
-
|
|
39309
|
-
|
|
39310
|
-
|
|
39311
|
-
|
|
39422
|
+
if (stat.isDirectory()) {
|
|
39423
|
+
header.size = 0
|
|
39424
|
+
header.type = 'directory'
|
|
39425
|
+
header = map(header) || header
|
|
39426
|
+
return pack.entry(header, onnextentry)
|
|
39427
|
+
}
|
|
39312
39428
|
|
|
39313
|
-
|
|
39314
|
-
|
|
39315
|
-
|
|
39429
|
+
if (stat.isSymbolicLink()) {
|
|
39430
|
+
header.size = 0
|
|
39431
|
+
header.type = 'symlink'
|
|
39432
|
+
header = map(header) || header
|
|
39433
|
+
return onsymlink(filename, header)
|
|
39434
|
+
}
|
|
39316
39435
|
|
|
39317
|
-
|
|
39318
|
-
if (n === 0)
|
|
39319
|
-
return cb()
|
|
39436
|
+
// TODO: add fifo etc...
|
|
39320
39437
|
|
|
39321
|
-
|
|
39322
|
-
const CB = (er) => {
|
|
39323
|
-
if (er) {
|
|
39324
|
-
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
|
|
39325
|
-
busyTries < options.maxBusyTries) {
|
|
39326
|
-
busyTries ++
|
|
39327
|
-
// try again, with the same exact callback as this one.
|
|
39328
|
-
return setTimeout(() => rimraf_(p, options, CB), busyTries * 100)
|
|
39329
|
-
}
|
|
39438
|
+
header = map(header) || header
|
|
39330
39439
|
|
|
39331
|
-
|
|
39332
|
-
|
|
39333
|
-
|
|
39334
|
-
|
|
39440
|
+
if (!stat.isFile()) {
|
|
39441
|
+
if (strict) return pack.destroy(new Error('unsupported type for ' + filename))
|
|
39442
|
+
return onnextentry()
|
|
39443
|
+
}
|
|
39335
39444
|
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
}
|
|
39445
|
+
const entry = pack.entry(header, onnextentry)
|
|
39446
|
+
const rs = mapStream(xfs.createReadStream(path.join(cwd, filename), { start: 0, end: header.size > 0 ? header.size - 1 : header.size }), header)
|
|
39339
39447
|
|
|
39340
|
-
|
|
39341
|
-
|
|
39342
|
-
}
|
|
39343
|
-
rimraf_(p, options, CB)
|
|
39448
|
+
rs.on('error', function (err) { // always forward errors on destroy
|
|
39449
|
+
entry.destroy(err)
|
|
39344
39450
|
})
|
|
39451
|
+
|
|
39452
|
+
pump(rs, entry)
|
|
39345
39453
|
}
|
|
39346
39454
|
|
|
39347
|
-
|
|
39348
|
-
return
|
|
39455
|
+
function onnextentry (err) {
|
|
39456
|
+
if (err) return pack.destroy(err)
|
|
39457
|
+
statNext(onstat)
|
|
39458
|
+
}
|
|
39349
39459
|
|
|
39350
|
-
|
|
39351
|
-
|
|
39352
|
-
return afterGlob(null, [p])
|
|
39460
|
+
return pack
|
|
39461
|
+
}
|
|
39353
39462
|
|
|
39354
|
-
|
|
39355
|
-
|
|
39463
|
+
function head (list) {
|
|
39464
|
+
return list.length ? list[list.length - 1] : null
|
|
39465
|
+
}
|
|
39356
39466
|
|
|
39467
|
+
function processGetuid () {
|
|
39468
|
+
return process.getuid ? process.getuid() : -1
|
|
39357
39469
|
}
|
|
39358
39470
|
|
|
39359
|
-
|
|
39360
|
-
|
|
39361
|
-
|
|
39362
|
-
//
|
|
39363
|
-
// Both result in an extra syscall when you guess wrong. However, there
|
|
39364
|
-
// are likely far more normal files in the world than directories. This
|
|
39365
|
-
// is based on the assumption that a the average number of files per
|
|
39366
|
-
// directory is >= 1.
|
|
39367
|
-
//
|
|
39368
|
-
// If anyone ever complains about this, then I guess the strategy could
|
|
39369
|
-
// be made configurable somehow. But until then, YAGNI.
|
|
39370
|
-
const rimraf_ = (p, options, cb) => {
|
|
39371
|
-
assert(p)
|
|
39372
|
-
assert(options)
|
|
39373
|
-
assert(typeof cb === 'function')
|
|
39471
|
+
function processUmask () {
|
|
39472
|
+
return process.umask ? process.umask() : 0
|
|
39473
|
+
}
|
|
39374
39474
|
|
|
39375
|
-
|
|
39376
|
-
|
|
39377
|
-
|
|
39378
|
-
if (er && er.code === "ENOENT")
|
|
39379
|
-
return cb(null)
|
|
39475
|
+
exports.extract = function extract (cwd, opts) {
|
|
39476
|
+
if (!cwd) cwd = '.'
|
|
39477
|
+
if (!opts) opts = {}
|
|
39380
39478
|
|
|
39381
|
-
|
|
39382
|
-
|
|
39383
|
-
|
|
39479
|
+
const xfs = opts.fs || fs
|
|
39480
|
+
const ignore = opts.ignore || opts.filter || noop
|
|
39481
|
+
const mapStream = opts.mapStream || echo
|
|
39482
|
+
const own = opts.chown !== false && !win32 && processGetuid() === 0
|
|
39483
|
+
const extract = opts.extract || tar.extract()
|
|
39484
|
+
const stack = []
|
|
39485
|
+
const now = new Date()
|
|
39486
|
+
const umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()
|
|
39487
|
+
const strict = opts.strict !== false
|
|
39384
39488
|
|
|
39385
|
-
|
|
39386
|
-
|
|
39489
|
+
let map = opts.map || noop
|
|
39490
|
+
let dmode = typeof opts.dmode === 'number' ? opts.dmode : 0
|
|
39491
|
+
let fmode = typeof opts.fmode === 'number' ? opts.fmode : 0
|
|
39387
39492
|
|
|
39388
|
-
|
|
39389
|
-
|
|
39390
|
-
|
|
39391
|
-
|
|
39392
|
-
|
|
39393
|
-
|
|
39394
|
-
|
|
39395
|
-
|
|
39396
|
-
|
|
39397
|
-
|
|
39398
|
-
|
|
39399
|
-
|
|
39493
|
+
if (opts.strip) map = strip(map, opts.strip)
|
|
39494
|
+
|
|
39495
|
+
if (opts.readable) {
|
|
39496
|
+
dmode |= parseInt(555, 8)
|
|
39497
|
+
fmode |= parseInt(444, 8)
|
|
39498
|
+
}
|
|
39499
|
+
if (opts.writable) {
|
|
39500
|
+
dmode |= parseInt(333, 8)
|
|
39501
|
+
fmode |= parseInt(222, 8)
|
|
39502
|
+
}
|
|
39503
|
+
|
|
39504
|
+
extract.on('entry', onentry)
|
|
39505
|
+
|
|
39506
|
+
if (opts.finish) extract.on('finish', opts.finish)
|
|
39507
|
+
|
|
39508
|
+
return extract
|
|
39509
|
+
|
|
39510
|
+
function onentry (header, stream, next) {
|
|
39511
|
+
header = map(header) || header
|
|
39512
|
+
header.name = normalize(header.name)
|
|
39513
|
+
|
|
39514
|
+
const name = path.join(cwd, path.join('/', header.name))
|
|
39515
|
+
|
|
39516
|
+
if (ignore(name, header)) {
|
|
39517
|
+
stream.resume()
|
|
39518
|
+
return next()
|
|
39519
|
+
}
|
|
39520
|
+
|
|
39521
|
+
if (header.type === 'directory') {
|
|
39522
|
+
stack.push([name, header.mtime])
|
|
39523
|
+
return mkdirfix(name, {
|
|
39524
|
+
fs: xfs,
|
|
39525
|
+
own,
|
|
39526
|
+
uid: header.uid,
|
|
39527
|
+
gid: header.gid,
|
|
39528
|
+
mode: header.mode
|
|
39529
|
+
}, stat)
|
|
39530
|
+
}
|
|
39531
|
+
|
|
39532
|
+
const dir = path.dirname(name)
|
|
39533
|
+
|
|
39534
|
+
validate(xfs, dir, path.join(cwd, '.'), function (err, valid) {
|
|
39535
|
+
if (err) return next(err)
|
|
39536
|
+
if (!valid) return next(new Error(dir + ' is not a valid path'))
|
|
39537
|
+
|
|
39538
|
+
mkdirfix(dir, {
|
|
39539
|
+
fs: xfs,
|
|
39540
|
+
own,
|
|
39541
|
+
uid: header.uid,
|
|
39542
|
+
gid: header.gid,
|
|
39543
|
+
// normally, the folders with rights and owner should be part of the TAR file
|
|
39544
|
+
// if this is not the case, create folder for same user as file and with
|
|
39545
|
+
// standard permissions of 0o755 (rwxr-xr-x)
|
|
39546
|
+
mode: 0o755
|
|
39547
|
+
}, function (err) {
|
|
39548
|
+
if (err) return next(err)
|
|
39549
|
+
|
|
39550
|
+
switch (header.type) {
|
|
39551
|
+
case 'file': return onfile()
|
|
39552
|
+
case 'link': return onlink()
|
|
39553
|
+
case 'symlink': return onsymlink()
|
|
39554
|
+
}
|
|
39555
|
+
|
|
39556
|
+
if (strict) return next(new Error('unsupported type for ' + name + ' (' + header.type + ')'))
|
|
39557
|
+
|
|
39558
|
+
stream.resume()
|
|
39559
|
+
next()
|
|
39560
|
+
})
|
|
39400
39561
|
})
|
|
39401
|
-
})
|
|
39402
|
-
}
|
|
39403
39562
|
|
|
39404
|
-
|
|
39405
|
-
|
|
39406
|
-
|
|
39407
|
-
|
|
39563
|
+
function stat (err) {
|
|
39564
|
+
if (err) return next(err)
|
|
39565
|
+
utimes(name, header, function (err) {
|
|
39566
|
+
if (err) return next(err)
|
|
39567
|
+
if (win32) return next()
|
|
39568
|
+
chperm(name, header, next)
|
|
39569
|
+
})
|
|
39570
|
+
}
|
|
39408
39571
|
|
|
39409
|
-
|
|
39410
|
-
|
|
39411
|
-
|
|
39412
|
-
|
|
39413
|
-
options.stat(p, (er3, stats) => {
|
|
39414
|
-
if (er3)
|
|
39415
|
-
cb(er3.code === "ENOENT" ? null : er)
|
|
39416
|
-
else if (stats.isDirectory())
|
|
39417
|
-
rmdir(p, options, er, cb)
|
|
39418
|
-
else
|
|
39419
|
-
options.unlink(p, cb)
|
|
39572
|
+
function onsymlink () {
|
|
39573
|
+
if (win32) return next() // skip symlinks on win for now before it can be tested
|
|
39574
|
+
xfs.unlink(name, function () {
|
|
39575
|
+
xfs.symlink(header.linkname, name, stat)
|
|
39420
39576
|
})
|
|
39421
|
-
|
|
39422
|
-
}
|
|
39577
|
+
}
|
|
39423
39578
|
|
|
39424
|
-
|
|
39425
|
-
|
|
39426
|
-
|
|
39579
|
+
function onlink () {
|
|
39580
|
+
if (win32) return next() // skip links on win for now before it can be tested
|
|
39581
|
+
xfs.unlink(name, function () {
|
|
39582
|
+
const srcpath = path.join(cwd, path.join('/', header.linkname))
|
|
39427
39583
|
|
|
39428
|
-
|
|
39429
|
-
|
|
39430
|
-
|
|
39431
|
-
|
|
39432
|
-
|
|
39433
|
-
|
|
39434
|
-
|
|
39584
|
+
xfs.link(srcpath, name, function (err) {
|
|
39585
|
+
if (err && err.code === 'EPERM' && opts.hardlinkAsFilesFallback) {
|
|
39586
|
+
stream = xfs.createReadStream(srcpath)
|
|
39587
|
+
return onfile()
|
|
39588
|
+
}
|
|
39589
|
+
|
|
39590
|
+
stat(err)
|
|
39591
|
+
})
|
|
39592
|
+
})
|
|
39593
|
+
}
|
|
39594
|
+
|
|
39595
|
+
function onfile () {
|
|
39596
|
+
const ws = xfs.createWriteStream(name)
|
|
39597
|
+
const rs = mapStream(stream, header)
|
|
39598
|
+
|
|
39599
|
+
ws.on('error', function (err) { // always forward errors on destroy
|
|
39600
|
+
rs.destroy(err)
|
|
39601
|
+
})
|
|
39602
|
+
|
|
39603
|
+
pump(rs, ws, function (err) {
|
|
39604
|
+
if (err) return next(err)
|
|
39605
|
+
ws.on('close', stat)
|
|
39606
|
+
})
|
|
39607
|
+
}
|
|
39435
39608
|
}
|
|
39436
39609
|
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
|
|
39440
|
-
|
|
39441
|
-
|
|
39442
|
-
return
|
|
39443
|
-
else
|
|
39444
|
-
throw er
|
|
39610
|
+
function utimesParent (name, cb) { // we just set the mtime on the parent dir again everytime we write an entry
|
|
39611
|
+
let top
|
|
39612
|
+
while ((top = head(stack)) && name.slice(0, top[0].length) !== top[0]) stack.pop()
|
|
39613
|
+
if (!top) return cb()
|
|
39614
|
+
xfs.utimes(top[0], now, top[1], cb)
|
|
39445
39615
|
}
|
|
39446
39616
|
|
|
39447
|
-
|
|
39448
|
-
|
|
39449
|
-
else
|
|
39450
|
-
options.unlinkSync(p)
|
|
39451
|
-
}
|
|
39617
|
+
function utimes (name, header, cb) {
|
|
39618
|
+
if (opts.utimes === false) return cb()
|
|
39452
39619
|
|
|
39453
|
-
|
|
39454
|
-
|
|
39455
|
-
assert(options)
|
|
39456
|
-
assert(typeof cb === 'function')
|
|
39620
|
+
if (header.type === 'directory') return xfs.utimes(name, now, header.mtime, cb)
|
|
39621
|
+
if (header.type === 'symlink') return utimesParent(name, cb) // TODO: how to set mtime on link?
|
|
39457
39622
|
|
|
39458
|
-
|
|
39459
|
-
|
|
39460
|
-
|
|
39461
|
-
|
|
39462
|
-
|
|
39463
|
-
|
|
39464
|
-
|
|
39465
|
-
|
|
39466
|
-
|
|
39467
|
-
|
|
39623
|
+
xfs.utimes(name, now, header.mtime, function (err) {
|
|
39624
|
+
if (err) return cb(err)
|
|
39625
|
+
utimesParent(name, cb)
|
|
39626
|
+
})
|
|
39627
|
+
}
|
|
39628
|
+
|
|
39629
|
+
function chperm (name, header, cb) {
|
|
39630
|
+
const link = header.type === 'symlink'
|
|
39631
|
+
|
|
39632
|
+
/* eslint-disable n/no-deprecated-api */
|
|
39633
|
+
const chmod = link ? xfs.lchmod : xfs.chmod
|
|
39634
|
+
const chown = link ? xfs.lchown : xfs.chown
|
|
39635
|
+
/* eslint-enable n/no-deprecated-api */
|
|
39636
|
+
|
|
39637
|
+
if (!chmod) return cb()
|
|
39638
|
+
|
|
39639
|
+
const mode = (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask
|
|
39640
|
+
|
|
39641
|
+
if (chown && own) chown.call(xfs, name, header.uid, header.gid, onchown)
|
|
39642
|
+
else onchown(null)
|
|
39643
|
+
|
|
39644
|
+
function onchown (err) {
|
|
39645
|
+
if (err) return cb(err)
|
|
39646
|
+
if (!chmod) return cb()
|
|
39647
|
+
chmod.call(xfs, name, mode, cb)
|
|
39648
|
+
}
|
|
39649
|
+
}
|
|
39650
|
+
|
|
39651
|
+
function mkdirfix (name, opts, cb) {
|
|
39652
|
+
// when mkdir is called on an existing directory, the permissions
|
|
39653
|
+
// will be overwritten (?), to avoid this we check for its existance first
|
|
39654
|
+
xfs.stat(name, function (err) {
|
|
39655
|
+
if (!err) return cb(null)
|
|
39656
|
+
if (err.code !== 'ENOENT') return cb(err)
|
|
39657
|
+
mkdirp(name, { fs: opts.fs, mode: opts.mode }, function (err, made) {
|
|
39658
|
+
if (err) return cb(err)
|
|
39659
|
+
chperm(name, opts, cb)
|
|
39660
|
+
})
|
|
39661
|
+
})
|
|
39662
|
+
}
|
|
39663
|
+
}
|
|
39664
|
+
|
|
39665
|
+
function validate (fs, name, root, cb) {
|
|
39666
|
+
if (name === root) return cb(null, true)
|
|
39667
|
+
fs.lstat(name, function (err, st) {
|
|
39668
|
+
if (err && err.code === 'ENOENT') return validate(fs, path.join(name, '..'), root, cb)
|
|
39669
|
+
else if (err) return cb(err)
|
|
39670
|
+
cb(null, st.isDirectory())
|
|
39468
39671
|
})
|
|
39469
39672
|
}
|
|
39470
39673
|
|
|
39471
|
-
|
|
39472
|
-
assert(p)
|
|
39473
|
-
assert(options)
|
|
39474
|
-
assert(typeof cb === 'function')
|
|
39674
|
+
function noop () {}
|
|
39475
39675
|
|
|
39476
|
-
|
|
39477
|
-
|
|
39478
|
-
|
|
39479
|
-
|
|
39480
|
-
|
|
39481
|
-
|
|
39482
|
-
|
|
39483
|
-
|
|
39484
|
-
|
|
39485
|
-
|
|
39486
|
-
|
|
39487
|
-
|
|
39488
|
-
|
|
39489
|
-
|
|
39490
|
-
|
|
39676
|
+
function echo (name) {
|
|
39677
|
+
return name
|
|
39678
|
+
}
|
|
39679
|
+
|
|
39680
|
+
function normalize (name) {
|
|
39681
|
+
return win32 ? name.replace(/\\/g, '/').replace(/[:?<>|]/g, '_') : name
|
|
39682
|
+
}
|
|
39683
|
+
|
|
39684
|
+
function statAll (fs, stat, cwd, ignore, entries, sort) {
|
|
39685
|
+
if (!entries) entries = ['.']
|
|
39686
|
+
const queue = entries.slice(0)
|
|
39687
|
+
|
|
39688
|
+
return function loop (callback) {
|
|
39689
|
+
if (!queue.length) return callback(null)
|
|
39690
|
+
|
|
39691
|
+
const next = queue.shift()
|
|
39692
|
+
const nextAbs = path.join(cwd, next)
|
|
39693
|
+
|
|
39694
|
+
stat.call(fs, nextAbs, function (err, stat) {
|
|
39695
|
+
// ignore errors if the files were deleted while buffering
|
|
39696
|
+
if (err) return callback(entries.indexOf(next) === -1 && err.code === 'ENOENT' ? null : err)
|
|
39697
|
+
|
|
39698
|
+
if (!stat.isDirectory()) return callback(null, next, stat)
|
|
39699
|
+
|
|
39700
|
+
fs.readdir(nextAbs, function (err, files) {
|
|
39701
|
+
if (err) return callback(err)
|
|
39702
|
+
|
|
39703
|
+
if (sort) files.sort()
|
|
39704
|
+
|
|
39705
|
+
for (let i = 0; i < files.length; i++) {
|
|
39706
|
+
if (!ignore(path.join(cwd, next, files[i]))) queue.push(path.join(next, files[i]))
|
|
39707
|
+
}
|
|
39708
|
+
|
|
39709
|
+
callback(null, next, stat)
|
|
39491
39710
|
})
|
|
39492
39711
|
})
|
|
39493
|
-
}
|
|
39712
|
+
}
|
|
39494
39713
|
}
|
|
39495
39714
|
|
|
39496
|
-
|
|
39497
|
-
|
|
39498
|
-
|
|
39499
|
-
const rimrafSync = (p, options) => {
|
|
39500
|
-
options = options || {}
|
|
39501
|
-
defaults(options)
|
|
39715
|
+
function strip (map, level) {
|
|
39716
|
+
return function (header) {
|
|
39717
|
+
header.name = header.name.split('/').slice(level).join('/')
|
|
39502
39718
|
|
|
39503
|
-
|
|
39504
|
-
|
|
39505
|
-
|
|
39506
|
-
|
|
39719
|
+
const linkname = header.linkname
|
|
39720
|
+
if (linkname && (header.type === 'link' || path.isAbsolute(linkname))) {
|
|
39721
|
+
header.linkname = linkname.split('/').slice(level).join('/')
|
|
39722
|
+
}
|
|
39507
39723
|
|
|
39508
|
-
|
|
39724
|
+
return map(header)
|
|
39725
|
+
}
|
|
39726
|
+
}
|
|
39509
39727
|
|
|
39510
|
-
|
|
39511
|
-
|
|
39512
|
-
|
|
39513
|
-
|
|
39514
|
-
|
|
39515
|
-
|
|
39516
|
-
|
|
39517
|
-
|
|
39728
|
+
|
|
39729
|
+
/***/ }),
|
|
39730
|
+
|
|
39731
|
+
/***/ 44152:
|
|
39732
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
39733
|
+
|
|
39734
|
+
const constants = { // just for envs without fs
|
|
39735
|
+
S_IFMT: 61440,
|
|
39736
|
+
S_IFDIR: 16384,
|
|
39737
|
+
S_IFCHR: 8192,
|
|
39738
|
+
S_IFBLK: 24576,
|
|
39739
|
+
S_IFIFO: 4096,
|
|
39740
|
+
S_IFLNK: 40960
|
|
39741
|
+
}
|
|
39742
|
+
|
|
39743
|
+
try {
|
|
39744
|
+
module.exports = __webpack_require__(57147).constants || constants
|
|
39745
|
+
} catch {
|
|
39746
|
+
module.exports = constants
|
|
39747
|
+
}
|
|
39748
|
+
|
|
39749
|
+
|
|
39750
|
+
/***/ }),
|
|
39751
|
+
|
|
39752
|
+
/***/ 32374:
|
|
39753
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
39754
|
+
|
|
39755
|
+
const { Writable, Readable, getStreamError } = __webpack_require__(81237)
|
|
39756
|
+
const FIFO = __webpack_require__(91607)
|
|
39757
|
+
const b4a = __webpack_require__(85792)
|
|
39758
|
+
const headers = __webpack_require__(33335)
|
|
39759
|
+
|
|
39760
|
+
const EMPTY = b4a.alloc(0)
|
|
39761
|
+
|
|
39762
|
+
class BufferList {
|
|
39763
|
+
constructor () {
|
|
39764
|
+
this.buffered = 0
|
|
39765
|
+
this.shifted = 0
|
|
39766
|
+
this.queue = new FIFO()
|
|
39767
|
+
|
|
39768
|
+
this._offset = 0
|
|
39769
|
+
}
|
|
39770
|
+
|
|
39771
|
+
push (buffer) {
|
|
39772
|
+
this.buffered += buffer.byteLength
|
|
39773
|
+
this.queue.push(buffer)
|
|
39774
|
+
}
|
|
39775
|
+
|
|
39776
|
+
shiftFirst (size) {
|
|
39777
|
+
return this._buffered === 0 ? null : this._next(size)
|
|
39778
|
+
}
|
|
39779
|
+
|
|
39780
|
+
shift (size) {
|
|
39781
|
+
if (size > this.buffered) return null
|
|
39782
|
+
if (size === 0) return EMPTY
|
|
39783
|
+
|
|
39784
|
+
let chunk = this._next(size)
|
|
39785
|
+
|
|
39786
|
+
if (size === chunk.byteLength) return chunk // likely case
|
|
39787
|
+
|
|
39788
|
+
const chunks = [chunk]
|
|
39789
|
+
|
|
39790
|
+
while ((size -= chunk.byteLength) > 0) {
|
|
39791
|
+
chunk = this._next(size)
|
|
39792
|
+
chunks.push(chunk)
|
|
39518
39793
|
}
|
|
39794
|
+
|
|
39795
|
+
return b4a.concat(chunks)
|
|
39519
39796
|
}
|
|
39520
39797
|
|
|
39521
|
-
|
|
39522
|
-
|
|
39798
|
+
_next (size) {
|
|
39799
|
+
const buf = this.queue.peek()
|
|
39800
|
+
const rem = buf.byteLength - this._offset
|
|
39523
39801
|
|
|
39524
|
-
|
|
39525
|
-
|
|
39802
|
+
if (size >= rem) {
|
|
39803
|
+
const sub = this._offset ? buf.subarray(this._offset, buf.byteLength) : buf
|
|
39804
|
+
this.queue.shift()
|
|
39805
|
+
this._offset = 0
|
|
39806
|
+
this.buffered -= rem
|
|
39807
|
+
this.shifted += rem
|
|
39808
|
+
return sub
|
|
39809
|
+
}
|
|
39526
39810
|
|
|
39527
|
-
|
|
39528
|
-
|
|
39529
|
-
st = options.lstatSync(p)
|
|
39530
|
-
} catch (er) {
|
|
39531
|
-
if (er.code === "ENOENT")
|
|
39532
|
-
return
|
|
39811
|
+
this.buffered -= size
|
|
39812
|
+
this.shifted += size
|
|
39533
39813
|
|
|
39534
|
-
|
|
39535
|
-
|
|
39536
|
-
|
|
39814
|
+
return buf.subarray(this._offset, (this._offset += size))
|
|
39815
|
+
}
|
|
39816
|
+
}
|
|
39817
|
+
|
|
39818
|
+
class Source extends Readable {
|
|
39819
|
+
constructor (self, header, offset) {
|
|
39820
|
+
super()
|
|
39821
|
+
|
|
39822
|
+
this.header = header
|
|
39823
|
+
this.offset = offset
|
|
39824
|
+
|
|
39825
|
+
this._parent = self
|
|
39826
|
+
}
|
|
39827
|
+
|
|
39828
|
+
_read (cb) {
|
|
39829
|
+
if (this.header.size === 0) {
|
|
39830
|
+
this.push(null)
|
|
39831
|
+
}
|
|
39832
|
+
if (this._parent._stream === this) {
|
|
39833
|
+
this._parent._update()
|
|
39537
39834
|
}
|
|
39835
|
+
cb(null)
|
|
39836
|
+
}
|
|
39538
39837
|
|
|
39539
|
-
|
|
39540
|
-
|
|
39541
|
-
|
|
39542
|
-
rmdirSync(p, options, null)
|
|
39543
|
-
else
|
|
39544
|
-
options.unlinkSync(p)
|
|
39545
|
-
} catch (er) {
|
|
39546
|
-
if (er.code === "ENOENT")
|
|
39547
|
-
return
|
|
39548
|
-
if (er.code === "EPERM")
|
|
39549
|
-
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
|
|
39550
|
-
if (er.code !== "EISDIR")
|
|
39551
|
-
throw er
|
|
39838
|
+
_predestroy () {
|
|
39839
|
+
this._parent.destroy(getStreamError(this))
|
|
39840
|
+
}
|
|
39552
39841
|
|
|
39553
|
-
|
|
39842
|
+
_detach () {
|
|
39843
|
+
if (this._parent._stream === this) {
|
|
39844
|
+
this._parent._stream = null
|
|
39845
|
+
this._parent._missing = overflow(this.header.size)
|
|
39846
|
+
this._parent._update()
|
|
39554
39847
|
}
|
|
39555
39848
|
}
|
|
39849
|
+
|
|
39850
|
+
_destroy (cb) {
|
|
39851
|
+
this._detach()
|
|
39852
|
+
cb(null)
|
|
39853
|
+
}
|
|
39556
39854
|
}
|
|
39557
39855
|
|
|
39558
|
-
|
|
39559
|
-
|
|
39560
|
-
|
|
39856
|
+
class Extract extends Writable {
|
|
39857
|
+
constructor (opts) {
|
|
39858
|
+
super(opts)
|
|
39561
39859
|
|
|
39562
|
-
|
|
39563
|
-
|
|
39564
|
-
|
|
39565
|
-
|
|
39860
|
+
if (!opts) opts = {}
|
|
39861
|
+
|
|
39862
|
+
this._buffer = new BufferList()
|
|
39863
|
+
this._offset = 0
|
|
39864
|
+
this._header = null
|
|
39865
|
+
this._stream = null
|
|
39866
|
+
this._missing = 0
|
|
39867
|
+
this._longHeader = false
|
|
39868
|
+
this._callback = noop
|
|
39869
|
+
this._locked = false
|
|
39870
|
+
this._finished = false
|
|
39871
|
+
this._pax = null
|
|
39872
|
+
this._paxGlobal = null
|
|
39873
|
+
this._gnuLongPath = null
|
|
39874
|
+
this._gnuLongLinkPath = null
|
|
39875
|
+
this._filenameEncoding = opts.filenameEncoding || 'utf-8'
|
|
39876
|
+
this._allowUnknownFormat = !!opts.allowUnknownFormat
|
|
39877
|
+
this._unlockBound = this._unlock.bind(this)
|
|
39878
|
+
}
|
|
39879
|
+
|
|
39880
|
+
_unlock (err) {
|
|
39881
|
+
this._locked = false
|
|
39882
|
+
|
|
39883
|
+
if (err) {
|
|
39884
|
+
this.destroy(err)
|
|
39885
|
+
this._continueWrite(err)
|
|
39566
39886
|
return
|
|
39567
|
-
|
|
39568
|
-
|
|
39569
|
-
|
|
39570
|
-
rmkidsSync(p, options)
|
|
39887
|
+
}
|
|
39888
|
+
|
|
39889
|
+
this._update()
|
|
39571
39890
|
}
|
|
39572
|
-
}
|
|
39573
39891
|
|
|
39574
|
-
|
|
39575
|
-
|
|
39576
|
-
|
|
39577
|
-
|
|
39892
|
+
_consumeHeader () {
|
|
39893
|
+
if (this._locked) return false
|
|
39894
|
+
|
|
39895
|
+
this._offset = this._buffer.shifted
|
|
39578
39896
|
|
|
39579
|
-
// We only end up here once we got ENOTEMPTY at least once, and
|
|
39580
|
-
// at this point, we are guaranteed to have removed all the kids.
|
|
39581
|
-
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
|
|
39582
|
-
// try really hard to delete stuff on windows, because it has a
|
|
39583
|
-
// PROFOUNDLY annoying habit of not closing handles promptly when
|
|
39584
|
-
// files are deleted, resulting in spurious ENOTEMPTY errors.
|
|
39585
|
-
const retries = isWindows ? 100 : 1
|
|
39586
|
-
let i = 0
|
|
39587
|
-
do {
|
|
39588
|
-
let threw = true
|
|
39589
39897
|
try {
|
|
39590
|
-
|
|
39591
|
-
|
|
39592
|
-
|
|
39593
|
-
|
|
39594
|
-
if (++i < retries && threw)
|
|
39595
|
-
continue
|
|
39898
|
+
this._header = headers.decode(this._buffer.shift(512), this._filenameEncoding, this._allowUnknownFormat)
|
|
39899
|
+
} catch (err) {
|
|
39900
|
+
this._continueWrite(err)
|
|
39901
|
+
return false
|
|
39596
39902
|
}
|
|
39597
|
-
} while (true)
|
|
39598
|
-
}
|
|
39599
39903
|
|
|
39600
|
-
|
|
39601
|
-
rimraf.sync = rimrafSync
|
|
39904
|
+
if (!this._header) return true
|
|
39602
39905
|
|
|
39906
|
+
switch (this._header.type) {
|
|
39907
|
+
case 'gnu-long-path':
|
|
39908
|
+
case 'gnu-long-link-path':
|
|
39909
|
+
case 'pax-global-header':
|
|
39910
|
+
case 'pax-header':
|
|
39911
|
+
this._longHeader = true
|
|
39912
|
+
this._missing = this._header.size
|
|
39913
|
+
return true
|
|
39914
|
+
}
|
|
39603
39915
|
|
|
39604
|
-
|
|
39916
|
+
this._locked = true
|
|
39917
|
+
this._applyLongHeaders()
|
|
39605
39918
|
|
|
39606
|
-
|
|
39607
|
-
|
|
39919
|
+
if (this._header.size === 0 || this._header.type === 'directory') {
|
|
39920
|
+
this.emit('entry', this._header, this._createStream(), this._unlockBound)
|
|
39921
|
+
return true
|
|
39922
|
+
}
|
|
39608
39923
|
|
|
39609
|
-
|
|
39610
|
-
|
|
39611
|
-
*
|
|
39612
|
-
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
39613
|
-
*
|
|
39614
|
-
* MIT Licensed
|
|
39615
|
-
*/
|
|
39924
|
+
this._stream = this._createStream()
|
|
39925
|
+
this._missing = this._header.size
|
|
39616
39926
|
|
|
39617
|
-
|
|
39618
|
-
|
|
39619
|
-
|
|
39620
|
-
const fs = __webpack_require__(57147);
|
|
39621
|
-
const os = __webpack_require__(22037);
|
|
39622
|
-
const path = __webpack_require__(71017);
|
|
39623
|
-
const crypto = __webpack_require__(6113);
|
|
39624
|
-
const _c = { fs: fs.constants, os: os.constants };
|
|
39625
|
-
const rimraf = __webpack_require__(37129);
|
|
39927
|
+
this.emit('entry', this._header, this._stream, this._unlockBound)
|
|
39928
|
+
return true
|
|
39929
|
+
}
|
|
39626
39930
|
|
|
39627
|
-
|
|
39628
|
-
|
|
39629
|
-
|
|
39630
|
-
|
|
39631
|
-
|
|
39632
|
-
RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
|
|
39931
|
+
_applyLongHeaders () {
|
|
39932
|
+
if (this._gnuLongPath) {
|
|
39933
|
+
this._header.name = this._gnuLongPath
|
|
39934
|
+
this._gnuLongPath = null
|
|
39935
|
+
}
|
|
39633
39936
|
|
|
39634
|
-
|
|
39937
|
+
if (this._gnuLongLinkPath) {
|
|
39938
|
+
this._header.linkname = this._gnuLongLinkPath
|
|
39939
|
+
this._gnuLongLinkPath = null
|
|
39940
|
+
}
|
|
39635
39941
|
|
|
39636
|
-
|
|
39942
|
+
if (this._pax) {
|
|
39943
|
+
if (this._pax.path) this._header.name = this._pax.path
|
|
39944
|
+
if (this._pax.linkpath) this._header.linkname = this._pax.linkpath
|
|
39945
|
+
if (this._pax.size) this._header.size = parseInt(this._pax.size, 10)
|
|
39946
|
+
this._header.pax = this._pax
|
|
39947
|
+
this._pax = null
|
|
39948
|
+
}
|
|
39949
|
+
}
|
|
39637
39950
|
|
|
39638
|
-
|
|
39951
|
+
_decodeLongHeader (buf) {
|
|
39952
|
+
switch (this._header.type) {
|
|
39953
|
+
case 'gnu-long-path':
|
|
39954
|
+
this._gnuLongPath = headers.decodeLongPath(buf, this._filenameEncoding)
|
|
39955
|
+
break
|
|
39956
|
+
case 'gnu-long-link-path':
|
|
39957
|
+
this._gnuLongLinkPath = headers.decodeLongPath(buf, this._filenameEncoding)
|
|
39958
|
+
break
|
|
39959
|
+
case 'pax-global-header':
|
|
39960
|
+
this._paxGlobal = headers.decodePax(buf)
|
|
39961
|
+
break
|
|
39962
|
+
case 'pax-header':
|
|
39963
|
+
this._pax = this._paxGlobal === null
|
|
39964
|
+
? headers.decodePax(buf)
|
|
39965
|
+
: Object.assign({}, this._paxGlobal, headers.decodePax(buf))
|
|
39966
|
+
break
|
|
39967
|
+
}
|
|
39968
|
+
}
|
|
39639
39969
|
|
|
39640
|
-
|
|
39641
|
-
|
|
39642
|
-
|
|
39643
|
-
ENOENT = _c.ENOENT || _c.os.errno.ENOENT,
|
|
39970
|
+
_consumeLongHeader () {
|
|
39971
|
+
this._longHeader = false
|
|
39972
|
+
this._missing = overflow(this._header.size)
|
|
39644
39973
|
|
|
39645
|
-
|
|
39646
|
-
FILE_MODE = 0o600 /* 384 */,
|
|
39974
|
+
const buf = this._buffer.shift(this._header.size)
|
|
39647
39975
|
|
|
39648
|
-
|
|
39976
|
+
try {
|
|
39977
|
+
this._decodeLongHeader(buf)
|
|
39978
|
+
} catch (err) {
|
|
39979
|
+
this._continueWrite(err)
|
|
39980
|
+
return false
|
|
39981
|
+
}
|
|
39649
39982
|
|
|
39650
|
-
|
|
39651
|
-
|
|
39983
|
+
return true
|
|
39984
|
+
}
|
|
39652
39985
|
|
|
39653
|
-
|
|
39654
|
-
|
|
39655
|
-
|
|
39986
|
+
_consumeStream () {
|
|
39987
|
+
const buf = this._buffer.shiftFirst(this._missing)
|
|
39988
|
+
if (buf === null) return false
|
|
39656
39989
|
|
|
39657
|
-
|
|
39658
|
-
|
|
39990
|
+
this._missing -= buf.byteLength
|
|
39991
|
+
const drained = this._stream.push(buf)
|
|
39659
39992
|
|
|
39660
|
-
|
|
39661
|
-
|
|
39662
|
-
|
|
39663
|
-
|
|
39664
|
-
|
|
39665
|
-
*/
|
|
39666
|
-
function tmpName(options, callback) {
|
|
39667
|
-
const
|
|
39668
|
-
args = _parseArguments(options, callback),
|
|
39669
|
-
opts = args[0],
|
|
39670
|
-
cb = args[1];
|
|
39993
|
+
if (this._missing === 0) {
|
|
39994
|
+
this._stream.push(null)
|
|
39995
|
+
if (drained) this._stream._detach()
|
|
39996
|
+
return drained && this._locked === false
|
|
39997
|
+
}
|
|
39671
39998
|
|
|
39672
|
-
|
|
39673
|
-
_assertAndSanitizeOptions(opts);
|
|
39674
|
-
} catch (err) {
|
|
39675
|
-
return cb(err);
|
|
39999
|
+
return drained
|
|
39676
40000
|
}
|
|
39677
40001
|
|
|
39678
|
-
|
|
39679
|
-
|
|
39680
|
-
|
|
39681
|
-
const name = _generateTmpName(opts);
|
|
40002
|
+
_createStream () {
|
|
40003
|
+
return new Source(this, this._header, this._offset)
|
|
40004
|
+
}
|
|
39682
40005
|
|
|
39683
|
-
|
|
39684
|
-
|
|
39685
|
-
|
|
39686
|
-
if (
|
|
39687
|
-
|
|
39688
|
-
|
|
40006
|
+
_update () {
|
|
40007
|
+
while (this._buffer.buffered > 0 && !this.destroying) {
|
|
40008
|
+
if (this._missing > 0) {
|
|
40009
|
+
if (this._stream !== null) {
|
|
40010
|
+
if (this._consumeStream() === false) return
|
|
40011
|
+
continue
|
|
40012
|
+
}
|
|
39689
40013
|
|
|
39690
|
-
|
|
40014
|
+
if (this._longHeader === true) {
|
|
40015
|
+
if (this._missing > this._buffer.buffered) break
|
|
40016
|
+
if (this._consumeLongHeader() === false) return false
|
|
40017
|
+
continue
|
|
39691
40018
|
}
|
|
39692
40019
|
|
|
39693
|
-
|
|
39694
|
-
|
|
39695
|
-
|
|
39696
|
-
|
|
40020
|
+
const ignore = this._buffer.shiftFirst(this._missing)
|
|
40021
|
+
if (ignore !== null) this._missing -= ignore.byteLength
|
|
40022
|
+
continue
|
|
40023
|
+
}
|
|
40024
|
+
|
|
40025
|
+
if (this._buffer.buffered < 512) break
|
|
40026
|
+
if (this._stream !== null || this._consumeHeader() === false) return
|
|
39697
40027
|
}
|
|
39698
|
-
}());
|
|
39699
|
-
}
|
|
39700
40028
|
|
|
39701
|
-
|
|
39702
|
-
|
|
39703
|
-
*
|
|
39704
|
-
* @param {Object} options
|
|
39705
|
-
* @returns {string} the generated random name
|
|
39706
|
-
* @throws {Error} if the options are invalid or could not generate a filename
|
|
39707
|
-
*/
|
|
39708
|
-
function tmpNameSync(options) {
|
|
39709
|
-
const
|
|
39710
|
-
args = _parseArguments(options),
|
|
39711
|
-
opts = args[0];
|
|
40029
|
+
this._continueWrite(null)
|
|
40030
|
+
}
|
|
39712
40031
|
|
|
39713
|
-
|
|
40032
|
+
_continueWrite (err) {
|
|
40033
|
+
const cb = this._callback
|
|
40034
|
+
this._callback = noop
|
|
40035
|
+
cb(err)
|
|
40036
|
+
}
|
|
39714
40037
|
|
|
39715
|
-
|
|
39716
|
-
|
|
39717
|
-
|
|
39718
|
-
|
|
39719
|
-
|
|
39720
|
-
|
|
39721
|
-
|
|
40038
|
+
_write (data, cb) {
|
|
40039
|
+
this._callback = cb
|
|
40040
|
+
this._buffer.push(data)
|
|
40041
|
+
this._update()
|
|
40042
|
+
}
|
|
40043
|
+
|
|
40044
|
+
_final (cb) {
|
|
40045
|
+
this._finished = this._missing === 0 && this._buffer.buffered === 0
|
|
40046
|
+
cb(this._finished ? null : new Error('Unexpected end of data'))
|
|
40047
|
+
}
|
|
40048
|
+
|
|
40049
|
+
_predestroy () {
|
|
40050
|
+
this._continueWrite(null)
|
|
40051
|
+
}
|
|
40052
|
+
|
|
40053
|
+
_destroy (cb) {
|
|
40054
|
+
if (this._stream) this._stream.destroy(getStreamError(this))
|
|
40055
|
+
cb(null)
|
|
40056
|
+
}
|
|
40057
|
+
|
|
40058
|
+
[Symbol.asyncIterator] () {
|
|
40059
|
+
let error = null
|
|
40060
|
+
|
|
40061
|
+
let promiseResolve = null
|
|
40062
|
+
let promiseReject = null
|
|
40063
|
+
|
|
40064
|
+
let entryStream = null
|
|
40065
|
+
let entryCallback = null
|
|
40066
|
+
|
|
40067
|
+
const extract = this
|
|
40068
|
+
|
|
40069
|
+
this.on('entry', onentry)
|
|
40070
|
+
this.on('error', (err) => { error = err })
|
|
40071
|
+
this.on('close', onclose)
|
|
40072
|
+
|
|
40073
|
+
return {
|
|
40074
|
+
[Symbol.asyncIterator] () {
|
|
40075
|
+
return this
|
|
40076
|
+
},
|
|
40077
|
+
next () {
|
|
40078
|
+
return new Promise(onnext)
|
|
40079
|
+
},
|
|
40080
|
+
return () {
|
|
40081
|
+
return destroy(null)
|
|
40082
|
+
},
|
|
40083
|
+
throw (err) {
|
|
40084
|
+
return destroy(err)
|
|
40085
|
+
}
|
|
39722
40086
|
}
|
|
39723
|
-
} while (tries-- > 0);
|
|
39724
40087
|
|
|
39725
|
-
|
|
39726
|
-
|
|
40088
|
+
function consumeCallback (err) {
|
|
40089
|
+
if (!entryCallback) return
|
|
40090
|
+
const cb = entryCallback
|
|
40091
|
+
entryCallback = null
|
|
40092
|
+
cb(err)
|
|
40093
|
+
}
|
|
39727
40094
|
|
|
39728
|
-
|
|
39729
|
-
|
|
39730
|
-
|
|
39731
|
-
|
|
39732
|
-
* @param {?fileCallback} callback
|
|
39733
|
-
*/
|
|
39734
|
-
function file(options, callback) {
|
|
39735
|
-
const
|
|
39736
|
-
args = _parseArguments(options, callback),
|
|
39737
|
-
opts = args[0],
|
|
39738
|
-
cb = args[1];
|
|
40095
|
+
function onnext (resolve, reject) {
|
|
40096
|
+
if (error) {
|
|
40097
|
+
return reject(error)
|
|
40098
|
+
}
|
|
39739
40099
|
|
|
39740
|
-
|
|
39741
|
-
|
|
39742
|
-
|
|
39743
|
-
|
|
40100
|
+
if (entryStream) {
|
|
40101
|
+
resolve({ value: entryStream, done: false })
|
|
40102
|
+
entryStream = null
|
|
40103
|
+
return
|
|
40104
|
+
}
|
|
39744
40105
|
|
|
39745
|
-
|
|
39746
|
-
|
|
39747
|
-
/* istanbu ignore else */
|
|
39748
|
-
if (err) return cb(err);
|
|
40106
|
+
promiseResolve = resolve
|
|
40107
|
+
promiseReject = reject
|
|
39749
40108
|
|
|
39750
|
-
|
|
39751
|
-
|
|
39752
|
-
|
|
39753
|
-
|
|
39754
|
-
|
|
40109
|
+
consumeCallback(null)
|
|
40110
|
+
|
|
40111
|
+
if (extract._finished && promiseResolve) {
|
|
40112
|
+
promiseResolve({ value: undefined, done: true })
|
|
40113
|
+
promiseResolve = promiseReject = null
|
|
40114
|
+
}
|
|
40115
|
+
}
|
|
40116
|
+
|
|
40117
|
+
function onentry (header, stream, callback) {
|
|
40118
|
+
entryCallback = callback
|
|
40119
|
+
stream.on('error', noop) // no way around this due to tick sillyness
|
|
40120
|
+
|
|
40121
|
+
if (promiseResolve) {
|
|
40122
|
+
promiseResolve({ value: stream, done: false })
|
|
40123
|
+
promiseResolve = promiseReject = null
|
|
39755
40124
|
} else {
|
|
39756
|
-
|
|
39757
|
-
// about the descriptor
|
|
39758
|
-
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
39759
|
-
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, false));
|
|
40125
|
+
entryStream = stream
|
|
39760
40126
|
}
|
|
39761
|
-
}
|
|
39762
|
-
});
|
|
39763
|
-
}
|
|
40127
|
+
}
|
|
39764
40128
|
|
|
39765
|
-
|
|
39766
|
-
|
|
39767
|
-
|
|
39768
|
-
|
|
39769
|
-
|
|
39770
|
-
|
|
39771
|
-
|
|
39772
|
-
function fileSync(options) {
|
|
39773
|
-
const
|
|
39774
|
-
args = _parseArguments(options),
|
|
39775
|
-
opts = args[0];
|
|
40129
|
+
function onclose () {
|
|
40130
|
+
consumeCallback(error)
|
|
40131
|
+
if (!promiseResolve) return
|
|
40132
|
+
if (error) promiseReject(error)
|
|
40133
|
+
else promiseResolve({ value: undefined, done: true })
|
|
40134
|
+
promiseResolve = promiseReject = null
|
|
40135
|
+
}
|
|
39776
40136
|
|
|
39777
|
-
|
|
39778
|
-
|
|
39779
|
-
|
|
39780
|
-
|
|
39781
|
-
|
|
39782
|
-
|
|
39783
|
-
|
|
40137
|
+
function destroy (err) {
|
|
40138
|
+
extract.destroy(err)
|
|
40139
|
+
consumeCallback(err)
|
|
40140
|
+
return new Promise((resolve, reject) => {
|
|
40141
|
+
if (extract.destroyed) return resolve({ value: undefined, done: true })
|
|
40142
|
+
extract.once('close', function () {
|
|
40143
|
+
if (err) reject(err)
|
|
40144
|
+
else resolve({ value: undefined, done: true })
|
|
40145
|
+
})
|
|
40146
|
+
})
|
|
40147
|
+
}
|
|
39784
40148
|
}
|
|
40149
|
+
}
|
|
39785
40150
|
|
|
39786
|
-
|
|
39787
|
-
|
|
39788
|
-
fd: fd,
|
|
39789
|
-
removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, true)
|
|
39790
|
-
};
|
|
40151
|
+
module.exports = function extract (opts) {
|
|
40152
|
+
return new Extract(opts)
|
|
39791
40153
|
}
|
|
39792
40154
|
|
|
39793
|
-
|
|
39794
|
-
* Creates a temporary directory.
|
|
39795
|
-
*
|
|
39796
|
-
* @param {(Options|dirCallback)} options the options or the callback function
|
|
39797
|
-
* @param {?dirCallback} callback
|
|
39798
|
-
*/
|
|
39799
|
-
function dir(options, callback) {
|
|
39800
|
-
const
|
|
39801
|
-
args = _parseArguments(options, callback),
|
|
39802
|
-
opts = args[0],
|
|
39803
|
-
cb = args[1];
|
|
40155
|
+
function noop () {}
|
|
39804
40156
|
|
|
39805
|
-
|
|
39806
|
-
|
|
39807
|
-
|
|
39808
|
-
|
|
40157
|
+
function overflow (size) {
|
|
40158
|
+
size &= 511
|
|
40159
|
+
return size && 512 - size
|
|
40160
|
+
}
|
|
39809
40161
|
|
|
39810
|
-
// create the directory
|
|
39811
|
-
fs.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err) {
|
|
39812
|
-
/* istanbul ignore else */
|
|
39813
|
-
if (err) return cb(err);
|
|
39814
40162
|
|
|
39815
|
-
|
|
39816
|
-
});
|
|
39817
|
-
});
|
|
39818
|
-
}
|
|
40163
|
+
/***/ }),
|
|
39819
40164
|
|
|
39820
|
-
|
|
39821
|
-
|
|
39822
|
-
*
|
|
39823
|
-
* @param {Options} options
|
|
39824
|
-
* @returns {DirSyncObject} object consists of name and removeCallback
|
|
39825
|
-
* @throws {Error} if it cannot create a directory
|
|
39826
|
-
*/
|
|
39827
|
-
function dirSync(options) {
|
|
39828
|
-
const
|
|
39829
|
-
args = _parseArguments(options),
|
|
39830
|
-
opts = args[0];
|
|
40165
|
+
/***/ 33335:
|
|
40166
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
39831
40167
|
|
|
39832
|
-
|
|
39833
|
-
fs.mkdirSync(name, opts.mode || DIR_MODE);
|
|
40168
|
+
const b4a = __webpack_require__(85792)
|
|
39834
40169
|
|
|
39835
|
-
|
|
39836
|
-
|
|
39837
|
-
|
|
39838
|
-
|
|
40170
|
+
const ZEROS = '0000000000000000000'
|
|
40171
|
+
const SEVENS = '7777777777777777777'
|
|
40172
|
+
const ZERO_OFFSET = '0'.charCodeAt(0)
|
|
40173
|
+
const USTAR_MAGIC = b4a.from([0x75, 0x73, 0x74, 0x61, 0x72, 0x00]) // ustar\x00
|
|
40174
|
+
const USTAR_VER = b4a.from([ZERO_OFFSET, ZERO_OFFSET])
|
|
40175
|
+
const GNU_MAGIC = b4a.from([0x75, 0x73, 0x74, 0x61, 0x72, 0x20]) // ustar\x20
|
|
40176
|
+
const GNU_VER = b4a.from([0x20, 0x00])
|
|
40177
|
+
const MASK = 0o7777
|
|
40178
|
+
const MAGIC_OFFSET = 257
|
|
40179
|
+
const VERSION_OFFSET = 263
|
|
40180
|
+
|
|
40181
|
+
exports.decodeLongPath = function decodeLongPath (buf, encoding) {
|
|
40182
|
+
return decodeStr(buf, 0, buf.length, encoding)
|
|
39839
40183
|
}
|
|
39840
40184
|
|
|
39841
|
-
|
|
39842
|
-
|
|
39843
|
-
|
|
39844
|
-
|
|
39845
|
-
|
|
39846
|
-
|
|
39847
|
-
|
|
39848
|
-
|
|
39849
|
-
const _handler = function (err) {
|
|
39850
|
-
if (err && !_isENOENT(err)) {
|
|
39851
|
-
// reraise any unanticipated error
|
|
39852
|
-
return next(err);
|
|
40185
|
+
exports.encodePax = function encodePax (opts) { // TODO: encode more stuff in pax
|
|
40186
|
+
let result = ''
|
|
40187
|
+
if (opts.name) result += addLength(' path=' + opts.name + '\n')
|
|
40188
|
+
if (opts.linkname) result += addLength(' linkpath=' + opts.linkname + '\n')
|
|
40189
|
+
const pax = opts.pax
|
|
40190
|
+
if (pax) {
|
|
40191
|
+
for (const key in pax) {
|
|
40192
|
+
result += addLength(' ' + key + '=' + pax[key] + '\n')
|
|
39853
40193
|
}
|
|
39854
|
-
|
|
39855
|
-
|
|
40194
|
+
}
|
|
40195
|
+
return b4a.from(result)
|
|
40196
|
+
}
|
|
39856
40197
|
|
|
39857
|
-
|
|
39858
|
-
|
|
39859
|
-
|
|
39860
|
-
|
|
39861
|
-
|
|
40198
|
+
exports.decodePax = function decodePax (buf) {
|
|
40199
|
+
const result = {}
|
|
40200
|
+
|
|
40201
|
+
while (buf.length) {
|
|
40202
|
+
let i = 0
|
|
40203
|
+
while (i < buf.length && buf[i] !== 32) i++
|
|
40204
|
+
const len = parseInt(buf.subarray(0, i).toString(), 10)
|
|
40205
|
+
if (!len) return result
|
|
40206
|
+
|
|
40207
|
+
const b = b4a.toString(buf.subarray(i + 1, len - 1))
|
|
40208
|
+
const keyIndex = b.indexOf('=')
|
|
40209
|
+
if (keyIndex === -1) return result
|
|
40210
|
+
result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1)
|
|
40211
|
+
|
|
40212
|
+
buf = buf.subarray(len)
|
|
40213
|
+
}
|
|
40214
|
+
|
|
40215
|
+
return result
|
|
39862
40216
|
}
|
|
39863
40217
|
|
|
39864
|
-
|
|
39865
|
-
|
|
39866
|
-
|
|
39867
|
-
|
|
39868
|
-
|
|
39869
|
-
|
|
39870
|
-
|
|
39871
|
-
|
|
39872
|
-
|
|
39873
|
-
|
|
39874
|
-
|
|
39875
|
-
|
|
39876
|
-
|
|
39877
|
-
}
|
|
39878
|
-
|
|
39879
|
-
|
|
39880
|
-
|
|
39881
|
-
|
|
39882
|
-
|
|
39883
|
-
|
|
40218
|
+
exports.encode = function encode (opts) {
|
|
40219
|
+
const buf = b4a.alloc(512)
|
|
40220
|
+
let name = opts.name
|
|
40221
|
+
let prefix = ''
|
|
40222
|
+
|
|
40223
|
+
if (opts.typeflag === 5 && name[name.length - 1] !== '/') name += '/'
|
|
40224
|
+
if (b4a.byteLength(name) !== name.length) return null // utf-8
|
|
40225
|
+
|
|
40226
|
+
while (b4a.byteLength(name) > 100) {
|
|
40227
|
+
const i = name.indexOf('/')
|
|
40228
|
+
if (i === -1) return null
|
|
40229
|
+
prefix += prefix ? '/' + name.slice(0, i) : name.slice(0, i)
|
|
40230
|
+
name = name.slice(i + 1)
|
|
40231
|
+
}
|
|
40232
|
+
|
|
40233
|
+
if (b4a.byteLength(name) > 100 || b4a.byteLength(prefix) > 155) return null
|
|
40234
|
+
if (opts.linkname && b4a.byteLength(opts.linkname) > 100) return null
|
|
40235
|
+
|
|
40236
|
+
b4a.write(buf, name)
|
|
40237
|
+
b4a.write(buf, encodeOct(opts.mode & MASK, 6), 100)
|
|
40238
|
+
b4a.write(buf, encodeOct(opts.uid, 6), 108)
|
|
40239
|
+
b4a.write(buf, encodeOct(opts.gid, 6), 116)
|
|
40240
|
+
encodeSize(opts.size, buf, 124)
|
|
40241
|
+
b4a.write(buf, encodeOct((opts.mtime.getTime() / 1000) | 0, 11), 136)
|
|
40242
|
+
|
|
40243
|
+
buf[156] = ZERO_OFFSET + toTypeflag(opts.type)
|
|
40244
|
+
|
|
40245
|
+
if (opts.linkname) b4a.write(buf, opts.linkname, 157)
|
|
40246
|
+
|
|
40247
|
+
b4a.copy(USTAR_MAGIC, buf, MAGIC_OFFSET)
|
|
40248
|
+
b4a.copy(USTAR_VER, buf, VERSION_OFFSET)
|
|
40249
|
+
if (opts.uname) b4a.write(buf, opts.uname, 265)
|
|
40250
|
+
if (opts.gname) b4a.write(buf, opts.gname, 297)
|
|
40251
|
+
b4a.write(buf, encodeOct(opts.devmajor || 0, 6), 329)
|
|
40252
|
+
b4a.write(buf, encodeOct(opts.devminor || 0, 6), 337)
|
|
40253
|
+
|
|
40254
|
+
if (prefix) b4a.write(buf, prefix, 345)
|
|
40255
|
+
|
|
40256
|
+
b4a.write(buf, encodeOct(cksum(buf), 6), 148)
|
|
40257
|
+
|
|
40258
|
+
return buf
|
|
40259
|
+
}
|
|
40260
|
+
|
|
40261
|
+
exports.decode = function decode (buf, filenameEncoding, allowUnknownFormat) {
|
|
40262
|
+
let typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET
|
|
40263
|
+
|
|
40264
|
+
let name = decodeStr(buf, 0, 100, filenameEncoding)
|
|
40265
|
+
const mode = decodeOct(buf, 100, 8)
|
|
40266
|
+
const uid = decodeOct(buf, 108, 8)
|
|
40267
|
+
const gid = decodeOct(buf, 116, 8)
|
|
40268
|
+
const size = decodeOct(buf, 124, 12)
|
|
40269
|
+
const mtime = decodeOct(buf, 136, 12)
|
|
40270
|
+
const type = toType(typeflag)
|
|
40271
|
+
const linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding)
|
|
40272
|
+
const uname = decodeStr(buf, 265, 32)
|
|
40273
|
+
const gname = decodeStr(buf, 297, 32)
|
|
40274
|
+
const devmajor = decodeOct(buf, 329, 8)
|
|
40275
|
+
const devminor = decodeOct(buf, 337, 8)
|
|
40276
|
+
|
|
40277
|
+
const c = cksum(buf)
|
|
40278
|
+
|
|
40279
|
+
// checksum is still initial value if header was null.
|
|
40280
|
+
if (c === 8 * 32) return null
|
|
40281
|
+
|
|
40282
|
+
// valid checksum
|
|
40283
|
+
if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?')
|
|
40284
|
+
|
|
40285
|
+
if (isUSTAR(buf)) {
|
|
40286
|
+
// ustar (posix) format.
|
|
40287
|
+
// prepend prefix, if present.
|
|
40288
|
+
if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name
|
|
40289
|
+
} else if (isGNU(buf)) {
|
|
40290
|
+
// 'gnu'/'oldgnu' format. Similar to ustar, but has support for incremental and
|
|
40291
|
+
// multi-volume tarballs.
|
|
40292
|
+
} else {
|
|
40293
|
+
if (!allowUnknownFormat) {
|
|
40294
|
+
throw new Error('Invalid tar header: unknown format.')
|
|
39884
40295
|
}
|
|
39885
40296
|
}
|
|
39886
|
-
|
|
39887
|
-
|
|
40297
|
+
|
|
40298
|
+
// to support old tar versions that use trailing / to indicate dirs
|
|
40299
|
+
if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5
|
|
40300
|
+
|
|
40301
|
+
return {
|
|
40302
|
+
name,
|
|
40303
|
+
mode,
|
|
40304
|
+
uid,
|
|
40305
|
+
gid,
|
|
40306
|
+
size,
|
|
40307
|
+
mtime: new Date(1000 * mtime),
|
|
40308
|
+
type,
|
|
40309
|
+
linkname,
|
|
40310
|
+
uname,
|
|
40311
|
+
gname,
|
|
40312
|
+
devmajor,
|
|
40313
|
+
devminor,
|
|
40314
|
+
pax: null
|
|
39888
40315
|
}
|
|
39889
40316
|
}
|
|
39890
40317
|
|
|
39891
|
-
|
|
39892
|
-
|
|
39893
|
-
|
|
39894
|
-
* Returns either a sync callback or a async callback depending on whether
|
|
39895
|
-
* fileSync or file was called, which is expressed by the sync parameter.
|
|
39896
|
-
*
|
|
39897
|
-
* @param {string} name the path of the file
|
|
39898
|
-
* @param {number} fd file descriptor
|
|
39899
|
-
* @param {Object} opts
|
|
39900
|
-
* @param {boolean} sync
|
|
39901
|
-
* @returns {fileCallback | fileCallbackSync}
|
|
39902
|
-
* @private
|
|
39903
|
-
*/
|
|
39904
|
-
function _prepareTmpFileRemoveCallback(name, fd, opts, sync) {
|
|
39905
|
-
const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name], sync);
|
|
39906
|
-
const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], sync, removeCallbackSync);
|
|
40318
|
+
function isUSTAR (buf) {
|
|
40319
|
+
return b4a.equals(USTAR_MAGIC, buf.subarray(MAGIC_OFFSET, MAGIC_OFFSET + 6))
|
|
40320
|
+
}
|
|
39907
40321
|
|
|
39908
|
-
|
|
40322
|
+
function isGNU (buf) {
|
|
40323
|
+
return b4a.equals(GNU_MAGIC, buf.subarray(MAGIC_OFFSET, MAGIC_OFFSET + 6)) &&
|
|
40324
|
+
b4a.equals(GNU_VER, buf.subarray(VERSION_OFFSET, VERSION_OFFSET + 2))
|
|
40325
|
+
}
|
|
39909
40326
|
|
|
39910
|
-
|
|
40327
|
+
function clamp (index, len, defaultValue) {
|
|
40328
|
+
if (typeof index !== 'number') return defaultValue
|
|
40329
|
+
index = ~~index // Coerce to integer.
|
|
40330
|
+
if (index >= len) return len
|
|
40331
|
+
if (index >= 0) return index
|
|
40332
|
+
index += len
|
|
40333
|
+
if (index >= 0) return index
|
|
40334
|
+
return 0
|
|
39911
40335
|
}
|
|
39912
40336
|
|
|
39913
|
-
|
|
39914
|
-
|
|
39915
|
-
|
|
39916
|
-
|
|
39917
|
-
|
|
39918
|
-
|
|
39919
|
-
|
|
39920
|
-
|
|
39921
|
-
|
|
39922
|
-
|
|
39923
|
-
|
|
39924
|
-
|
|
39925
|
-
|
|
39926
|
-
|
|
39927
|
-
|
|
39928
|
-
|
|
39929
|
-
|
|
39930
|
-
|
|
40337
|
+
function toType (flag) {
|
|
40338
|
+
switch (flag) {
|
|
40339
|
+
case 0:
|
|
40340
|
+
return 'file'
|
|
40341
|
+
case 1:
|
|
40342
|
+
return 'link'
|
|
40343
|
+
case 2:
|
|
40344
|
+
return 'symlink'
|
|
40345
|
+
case 3:
|
|
40346
|
+
return 'character-device'
|
|
40347
|
+
case 4:
|
|
40348
|
+
return 'block-device'
|
|
40349
|
+
case 5:
|
|
40350
|
+
return 'directory'
|
|
40351
|
+
case 6:
|
|
40352
|
+
return 'fifo'
|
|
40353
|
+
case 7:
|
|
40354
|
+
return 'contiguous-file'
|
|
40355
|
+
case 72:
|
|
40356
|
+
return 'pax-header'
|
|
40357
|
+
case 55:
|
|
40358
|
+
return 'pax-global-header'
|
|
40359
|
+
case 27:
|
|
40360
|
+
return 'gnu-long-link-path'
|
|
40361
|
+
case 28:
|
|
40362
|
+
case 30:
|
|
40363
|
+
return 'gnu-long-path'
|
|
40364
|
+
}
|
|
39931
40365
|
|
|
39932
|
-
return
|
|
40366
|
+
return null
|
|
39933
40367
|
}
|
|
39934
40368
|
|
|
39935
|
-
|
|
39936
|
-
|
|
39937
|
-
|
|
39938
|
-
|
|
39939
|
-
|
|
39940
|
-
|
|
39941
|
-
|
|
39942
|
-
|
|
39943
|
-
|
|
39944
|
-
|
|
39945
|
-
|
|
39946
|
-
|
|
39947
|
-
|
|
39948
|
-
|
|
39949
|
-
|
|
40369
|
+
function toTypeflag (flag) {
|
|
40370
|
+
switch (flag) {
|
|
40371
|
+
case 'file':
|
|
40372
|
+
return 0
|
|
40373
|
+
case 'link':
|
|
40374
|
+
return 1
|
|
40375
|
+
case 'symlink':
|
|
40376
|
+
return 2
|
|
40377
|
+
case 'character-device':
|
|
40378
|
+
return 3
|
|
40379
|
+
case 'block-device':
|
|
40380
|
+
return 4
|
|
40381
|
+
case 'directory':
|
|
40382
|
+
return 5
|
|
40383
|
+
case 'fifo':
|
|
40384
|
+
return 6
|
|
40385
|
+
case 'contiguous-file':
|
|
40386
|
+
return 7
|
|
40387
|
+
case 'pax-header':
|
|
40388
|
+
return 72
|
|
40389
|
+
}
|
|
39950
40390
|
|
|
39951
|
-
|
|
39952
|
-
|
|
40391
|
+
return 0
|
|
40392
|
+
}
|
|
39953
40393
|
|
|
39954
|
-
|
|
39955
|
-
|
|
39956
|
-
|
|
39957
|
-
|
|
39958
|
-
|
|
39959
|
-
|
|
39960
|
-
if (index >= 0) _removeObjects.splice(index, 1);
|
|
40394
|
+
function indexOf (block, num, offset, end) {
|
|
40395
|
+
for (; offset < end; offset++) {
|
|
40396
|
+
if (block[offset] === num) return offset
|
|
40397
|
+
}
|
|
40398
|
+
return end
|
|
40399
|
+
}
|
|
39961
40400
|
|
|
39962
|
-
|
|
39963
|
-
|
|
39964
|
-
|
|
39965
|
-
|
|
39966
|
-
|
|
39967
|
-
}
|
|
39968
|
-
}
|
|
39969
|
-
};
|
|
40401
|
+
function cksum (block) {
|
|
40402
|
+
let sum = 8 * 32
|
|
40403
|
+
for (let i = 0; i < 148; i++) sum += block[i]
|
|
40404
|
+
for (let j = 156; j < 512; j++) sum += block[j]
|
|
40405
|
+
return sum
|
|
39970
40406
|
}
|
|
39971
40407
|
|
|
39972
|
-
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39977
|
-
function _garbageCollector() {
|
|
39978
|
-
/* istanbul ignore else */
|
|
39979
|
-
if (!_gracefulCleanup) return;
|
|
40408
|
+
function encodeOct (val, n) {
|
|
40409
|
+
val = val.toString(8)
|
|
40410
|
+
if (val.length > n) return SEVENS.slice(0, n) + ' '
|
|
40411
|
+
return ZEROS.slice(0, n - val.length) + val + ' '
|
|
40412
|
+
}
|
|
39980
40413
|
|
|
39981
|
-
|
|
39982
|
-
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
|
|
39986
|
-
} catch (e) {
|
|
39987
|
-
// already removed?
|
|
39988
|
-
}
|
|
40414
|
+
function encodeSizeBin (num, buf, off) {
|
|
40415
|
+
buf[off] = 0x80
|
|
40416
|
+
for (let i = 11; i > 0; i--) {
|
|
40417
|
+
buf[off + i] = num & 0xff
|
|
40418
|
+
num = Math.floor(num / 0x100)
|
|
39989
40419
|
}
|
|
39990
40420
|
}
|
|
39991
40421
|
|
|
39992
|
-
|
|
39993
|
-
|
|
39994
|
-
|
|
40422
|
+
function encodeSize (num, buf, off) {
|
|
40423
|
+
if (num.toString(8).length > 11) {
|
|
40424
|
+
encodeSizeBin(num, buf, off)
|
|
40425
|
+
} else {
|
|
40426
|
+
b4a.write(buf, encodeOct(num, 11), off)
|
|
40427
|
+
}
|
|
40428
|
+
}
|
|
40429
|
+
|
|
40430
|
+
/* Copied from the node-tar repo and modified to meet
|
|
40431
|
+
* tar-stream coding standard.
|
|
39995
40432
|
*
|
|
39996
|
-
*
|
|
39997
|
-
* @returns {string} the generated random name
|
|
39998
|
-
* @private
|
|
40433
|
+
* Source: https://github.com/npm/node-tar/blob/51b6627a1f357d2eb433e7378e5f05e83b7aa6cd/lib/header.js#L349
|
|
39999
40434
|
*/
|
|
40000
|
-
function
|
|
40001
|
-
|
|
40002
|
-
|
|
40003
|
-
|
|
40435
|
+
function parse256 (buf) {
|
|
40436
|
+
// first byte MUST be either 80 or FF
|
|
40437
|
+
// 80 for positive, FF for 2's comp
|
|
40438
|
+
let positive
|
|
40439
|
+
if (buf[0] === 0x80) positive = true
|
|
40440
|
+
else if (buf[0] === 0xFF) positive = false
|
|
40441
|
+
else return null
|
|
40004
40442
|
|
|
40005
|
-
//
|
|
40006
|
-
|
|
40007
|
-
|
|
40008
|
-
|
|
40009
|
-
|
|
40443
|
+
// build up a base-256 tuple from the least sig to the highest
|
|
40444
|
+
const tuple = []
|
|
40445
|
+
let i
|
|
40446
|
+
for (i = buf.length - 1; i > 0; i--) {
|
|
40447
|
+
const byte = buf[i]
|
|
40448
|
+
if (positive) tuple.push(byte)
|
|
40449
|
+
else tuple.push(0xFF - byte)
|
|
40010
40450
|
}
|
|
40011
40451
|
|
|
40012
|
-
|
|
40013
|
-
|
|
40452
|
+
let sum = 0
|
|
40453
|
+
const l = tuple.length
|
|
40454
|
+
for (i = 0; i < l; i++) {
|
|
40455
|
+
sum += tuple[i] * Math.pow(256, i)
|
|
40014
40456
|
}
|
|
40015
40457
|
|
|
40016
|
-
return
|
|
40458
|
+
return positive ? sum : -1 * sum
|
|
40017
40459
|
}
|
|
40018
40460
|
|
|
40019
|
-
|
|
40020
|
-
|
|
40021
|
-
|
|
40022
|
-
|
|
40023
|
-
|
|
40024
|
-
|
|
40025
|
-
|
|
40026
|
-
|
|
40027
|
-
|
|
40461
|
+
function decodeOct (val, offset, length) {
|
|
40462
|
+
val = val.subarray(offset, offset + length)
|
|
40463
|
+
offset = 0
|
|
40464
|
+
|
|
40465
|
+
// If prefixed with 0x80 then parse as a base-256 integer
|
|
40466
|
+
if (val[offset] & 0x80) {
|
|
40467
|
+
return parse256(val)
|
|
40468
|
+
} else {
|
|
40469
|
+
// Older versions of tar can prefix with spaces
|
|
40470
|
+
while (offset < val.length && val[offset] === 32) offset++
|
|
40471
|
+
const end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length)
|
|
40472
|
+
while (offset < end && val[offset] === 0) offset++
|
|
40473
|
+
if (end === offset) return 0
|
|
40474
|
+
return parseInt(val.subarray(offset, end).toString(), 8)
|
|
40475
|
+
}
|
|
40028
40476
|
}
|
|
40029
40477
|
|
|
40030
|
-
|
|
40031
|
-
|
|
40032
|
-
*
|
|
40033
|
-
* @param {Object} obj
|
|
40034
|
-
* @returns {boolean} true if the object is undefined
|
|
40035
|
-
* @private
|
|
40036
|
-
*/
|
|
40037
|
-
function _isUndefined(obj) {
|
|
40038
|
-
return typeof obj === 'undefined';
|
|
40478
|
+
function decodeStr (val, offset, length, encoding) {
|
|
40479
|
+
return b4a.toString(val.subarray(offset, indexOf(val, 0, offset, offset + length)), encoding)
|
|
40039
40480
|
}
|
|
40040
40481
|
|
|
40041
|
-
|
|
40042
|
-
|
|
40043
|
-
|
|
40044
|
-
|
|
40045
|
-
|
|
40046
|
-
|
|
40047
|
-
|
|
40048
|
-
|
|
40049
|
-
|
|
40050
|
-
|
|
40051
|
-
|
|
40052
|
-
|
|
40053
|
-
|
|
40054
|
-
|
|
40482
|
+
function addLength (str) {
|
|
40483
|
+
const len = b4a.byteLength(str)
|
|
40484
|
+
let digits = Math.floor(Math.log(len) / Math.log(10)) + 1
|
|
40485
|
+
if (len + digits >= Math.pow(10, digits)) digits++
|
|
40486
|
+
|
|
40487
|
+
return (len + digits) + str
|
|
40488
|
+
}
|
|
40489
|
+
|
|
40490
|
+
|
|
40491
|
+
/***/ }),
|
|
40492
|
+
|
|
40493
|
+
/***/ 5464:
|
|
40494
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
40495
|
+
|
|
40496
|
+
exports.extract = __webpack_require__(32374)
|
|
40497
|
+
exports.pack = __webpack_require__(80349)
|
|
40498
|
+
|
|
40499
|
+
|
|
40500
|
+
/***/ }),
|
|
40501
|
+
|
|
40502
|
+
/***/ 80349:
|
|
40503
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
40504
|
+
|
|
40505
|
+
const { Readable, Writable, getStreamError } = __webpack_require__(81237)
|
|
40506
|
+
const b4a = __webpack_require__(85792)
|
|
40507
|
+
|
|
40508
|
+
const constants = __webpack_require__(44152)
|
|
40509
|
+
const headers = __webpack_require__(33335)
|
|
40510
|
+
|
|
40511
|
+
const DMODE = 0o755
|
|
40512
|
+
const FMODE = 0o644
|
|
40513
|
+
|
|
40514
|
+
const END_OF_TAR = b4a.alloc(1024)
|
|
40515
|
+
|
|
40516
|
+
class Sink extends Writable {
|
|
40517
|
+
constructor (pack, header, callback) {
|
|
40518
|
+
super({ mapWritable, eagerOpen: true })
|
|
40519
|
+
|
|
40520
|
+
this.written = 0
|
|
40521
|
+
this.header = header
|
|
40522
|
+
|
|
40523
|
+
this._callback = callback
|
|
40524
|
+
this._linkname = null
|
|
40525
|
+
this._isLinkname = header.type === 'symlink' && !header.linkname
|
|
40526
|
+
this._isVoid = header.type !== 'file' && header.type !== 'contiguous-file'
|
|
40527
|
+
this._finished = false
|
|
40528
|
+
this._pack = pack
|
|
40529
|
+
this._openCallback = null
|
|
40530
|
+
|
|
40531
|
+
if (this._pack._stream === null) this._pack._stream = this
|
|
40532
|
+
else this._pack._pending.push(this)
|
|
40055
40533
|
}
|
|
40056
40534
|
|
|
40057
|
-
|
|
40058
|
-
|
|
40059
|
-
|
|
40535
|
+
_open (cb) {
|
|
40536
|
+
this._openCallback = cb
|
|
40537
|
+
if (this._pack._stream === this) this._continueOpen()
|
|
40060
40538
|
}
|
|
40061
40539
|
|
|
40062
|
-
|
|
40063
|
-
|
|
40064
|
-
|
|
40065
|
-
|
|
40540
|
+
_continuePack (err) {
|
|
40541
|
+
if (this._callback === null) return
|
|
40542
|
+
|
|
40543
|
+
const callback = this._callback
|
|
40544
|
+
this._callback = null
|
|
40545
|
+
|
|
40546
|
+
callback(err)
|
|
40066
40547
|
}
|
|
40067
40548
|
|
|
40068
|
-
|
|
40069
|
-
|
|
40549
|
+
_continueOpen () {
|
|
40550
|
+
if (this._pack._stream === null) this._pack._stream = this
|
|
40070
40551
|
|
|
40071
|
-
|
|
40072
|
-
|
|
40073
|
-
|
|
40074
|
-
* @param {Object} opts
|
|
40075
|
-
* @returns {string} the new random name according to opts
|
|
40076
|
-
* @private
|
|
40077
|
-
*/
|
|
40078
|
-
function _generateTmpName(opts) {
|
|
40552
|
+
const cb = this._openCallback
|
|
40553
|
+
this._openCallback = null
|
|
40554
|
+
if (cb === null) return
|
|
40079
40555
|
|
|
40080
|
-
|
|
40556
|
+
if (this._pack.destroying) return cb(new Error('pack stream destroyed'))
|
|
40557
|
+
if (this._pack._finalized) return cb(new Error('pack stream is already finalized'))
|
|
40081
40558
|
|
|
40082
|
-
|
|
40083
|
-
if (!_isUndefined(opts.name))
|
|
40084
|
-
return path.join(tmpDir, opts.dir, opts.name);
|
|
40559
|
+
this._pack._stream = this
|
|
40085
40560
|
|
|
40086
|
-
|
|
40087
|
-
|
|
40088
|
-
|
|
40561
|
+
if (!this._isLinkname) {
|
|
40562
|
+
this._pack._encode(this.header)
|
|
40563
|
+
}
|
|
40089
40564
|
|
|
40090
|
-
|
|
40091
|
-
|
|
40092
|
-
|
|
40093
|
-
|
|
40094
|
-
process.pid,
|
|
40095
|
-
'-',
|
|
40096
|
-
_randomChars(12),
|
|
40097
|
-
opts.postfix ? '-' + opts.postfix : ''
|
|
40098
|
-
].join('');
|
|
40565
|
+
if (this._isVoid) {
|
|
40566
|
+
this._finish()
|
|
40567
|
+
this._continuePack(null)
|
|
40568
|
+
}
|
|
40099
40569
|
|
|
40100
|
-
|
|
40101
|
-
}
|
|
40570
|
+
cb(null)
|
|
40571
|
+
}
|
|
40102
40572
|
|
|
40103
|
-
|
|
40104
|
-
|
|
40105
|
-
|
|
40106
|
-
|
|
40107
|
-
|
|
40108
|
-
* @private
|
|
40109
|
-
*/
|
|
40110
|
-
function _assertAndSanitizeOptions(options) {
|
|
40573
|
+
_write (data, cb) {
|
|
40574
|
+
if (this._isLinkname) {
|
|
40575
|
+
this._linkname = this._linkname ? b4a.concat([this._linkname, data]) : data
|
|
40576
|
+
return cb(null)
|
|
40577
|
+
}
|
|
40111
40578
|
|
|
40112
|
-
|
|
40579
|
+
if (this._isVoid) {
|
|
40580
|
+
if (data.byteLength > 0) {
|
|
40581
|
+
return cb(new Error('No body allowed for this entry'))
|
|
40582
|
+
}
|
|
40583
|
+
return cb()
|
|
40584
|
+
}
|
|
40113
40585
|
|
|
40114
|
-
|
|
40586
|
+
this.written += data.byteLength
|
|
40587
|
+
if (this._pack.push(data)) return cb()
|
|
40588
|
+
this._pack._drain = cb
|
|
40589
|
+
}
|
|
40115
40590
|
|
|
40116
|
-
|
|
40117
|
-
|
|
40118
|
-
|
|
40119
|
-
|
|
40120
|
-
|
|
40121
|
-
|
|
40122
|
-
|
|
40123
|
-
|
|
40124
|
-
|
|
40125
|
-
|
|
40126
|
-
|
|
40591
|
+
_finish () {
|
|
40592
|
+
if (this._finished) return
|
|
40593
|
+
this._finished = true
|
|
40594
|
+
|
|
40595
|
+
if (this._isLinkname) {
|
|
40596
|
+
this.header.linkname = this._linkname ? b4a.toString(this._linkname, 'utf-8') : ''
|
|
40597
|
+
this._pack._encode(this.header)
|
|
40598
|
+
}
|
|
40599
|
+
|
|
40600
|
+
overflow(this._pack, this.header.size)
|
|
40601
|
+
|
|
40602
|
+
this._pack._done(this)
|
|
40127
40603
|
}
|
|
40128
|
-
/* istanbul ignore else */
|
|
40129
|
-
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0)
|
|
40130
|
-
throw new Error(`Invalid tries, found "${options.tries}".`);
|
|
40131
40604
|
|
|
40132
|
-
|
|
40133
|
-
|
|
40134
|
-
|
|
40135
|
-
|
|
40136
|
-
options.discardDescriptor = !!options.discardDescriptor;
|
|
40137
|
-
options.unsafeCleanup = !!options.unsafeCleanup;
|
|
40605
|
+
_final (cb) {
|
|
40606
|
+
if (this.written !== this.header.size) { // corrupting tar
|
|
40607
|
+
return cb(new Error('Size mismatch'))
|
|
40608
|
+
}
|
|
40138
40609
|
|
|
40139
|
-
|
|
40140
|
-
|
|
40141
|
-
|
|
40142
|
-
// sanitize further if template is relative to options.dir
|
|
40143
|
-
options.template = _isBlank(options.template) ? undefined : path.relative(options.dir, options.template);
|
|
40610
|
+
this._finish()
|
|
40611
|
+
cb(null)
|
|
40612
|
+
}
|
|
40144
40613
|
|
|
40145
|
-
|
|
40146
|
-
|
|
40147
|
-
|
|
40148
|
-
options.postfix = _isUndefined(options.postfix) ? '' : options.postfix;
|
|
40149
|
-
}
|
|
40614
|
+
_getError () {
|
|
40615
|
+
return getStreamError(this) || new Error('tar entry destroyed')
|
|
40616
|
+
}
|
|
40150
40617
|
|
|
40151
|
-
|
|
40152
|
-
|
|
40153
|
-
*
|
|
40154
|
-
* The specified name might include relative path components, e.g. ../
|
|
40155
|
-
* so we need to resolve in order to be sure that is is located inside tmpDir
|
|
40156
|
-
*
|
|
40157
|
-
* @param name
|
|
40158
|
-
* @param tmpDir
|
|
40159
|
-
* @returns {string}
|
|
40160
|
-
* @private
|
|
40161
|
-
*/
|
|
40162
|
-
function _resolvePath(name, tmpDir) {
|
|
40163
|
-
const sanitizedName = _sanitizeName(name);
|
|
40164
|
-
if (sanitizedName.startsWith(tmpDir)) {
|
|
40165
|
-
return path.resolve(sanitizedName);
|
|
40166
|
-
} else {
|
|
40167
|
-
return path.resolve(path.join(tmpDir, sanitizedName));
|
|
40618
|
+
_predestroy () {
|
|
40619
|
+
this._pack.destroy(this._getError())
|
|
40168
40620
|
}
|
|
40169
|
-
}
|
|
40170
40621
|
|
|
40171
|
-
|
|
40172
|
-
|
|
40173
|
-
|
|
40174
|
-
|
|
40175
|
-
|
|
40176
|
-
|
|
40177
|
-
*/
|
|
40178
|
-
function _sanitizeName(name) {
|
|
40179
|
-
if (_isBlank(name)) {
|
|
40180
|
-
return name;
|
|
40622
|
+
_destroy (cb) {
|
|
40623
|
+
this._pack._done(this)
|
|
40624
|
+
|
|
40625
|
+
this._continuePack(this._finished ? null : this._getError())
|
|
40626
|
+
|
|
40627
|
+
cb()
|
|
40181
40628
|
}
|
|
40182
|
-
return name.replace(/["']/g, '');
|
|
40183
40629
|
}
|
|
40184
40630
|
|
|
40185
|
-
|
|
40186
|
-
|
|
40187
|
-
|
|
40188
|
-
|
|
40189
|
-
|
|
40190
|
-
|
|
40191
|
-
|
|
40192
|
-
|
|
40193
|
-
*/
|
|
40194
|
-
function _assertIsRelative(name, option, tmpDir) {
|
|
40195
|
-
if (option === 'name') {
|
|
40196
|
-
// assert that name is not absolute and does not contain a path
|
|
40197
|
-
if (path.isAbsolute(name))
|
|
40198
|
-
throw new Error(`${option} option must not contain an absolute path, found "${name}".`);
|
|
40199
|
-
// must not fail on valid .<name> or ..<name> or similar such constructs
|
|
40200
|
-
let basename = path.basename(name);
|
|
40201
|
-
if (basename === '..' || basename === '.' || basename !== name)
|
|
40202
|
-
throw new Error(`${option} option must not contain a path, found "${name}".`);
|
|
40631
|
+
class Pack extends Readable {
|
|
40632
|
+
constructor (opts) {
|
|
40633
|
+
super(opts)
|
|
40634
|
+
this._drain = noop
|
|
40635
|
+
this._finalized = false
|
|
40636
|
+
this._finalizing = false
|
|
40637
|
+
this._pending = []
|
|
40638
|
+
this._stream = null
|
|
40203
40639
|
}
|
|
40204
|
-
|
|
40205
|
-
|
|
40206
|
-
if (
|
|
40207
|
-
|
|
40640
|
+
|
|
40641
|
+
entry (header, buffer, callback) {
|
|
40642
|
+
if (this._finalized || this.destroying) throw new Error('already finalized or destroyed')
|
|
40643
|
+
|
|
40644
|
+
if (typeof buffer === 'function') {
|
|
40645
|
+
callback = buffer
|
|
40646
|
+
buffer = null
|
|
40208
40647
|
}
|
|
40209
|
-
|
|
40210
|
-
if (!
|
|
40211
|
-
|
|
40648
|
+
|
|
40649
|
+
if (!callback) callback = noop
|
|
40650
|
+
|
|
40651
|
+
if (!header.size || header.type === 'symlink') header.size = 0
|
|
40652
|
+
if (!header.type) header.type = modeToType(header.mode)
|
|
40653
|
+
if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE
|
|
40654
|
+
if (!header.uid) header.uid = 0
|
|
40655
|
+
if (!header.gid) header.gid = 0
|
|
40656
|
+
if (!header.mtime) header.mtime = new Date()
|
|
40657
|
+
|
|
40658
|
+
if (typeof buffer === 'string') buffer = b4a.from(buffer)
|
|
40659
|
+
|
|
40660
|
+
const sink = new Sink(this, header, callback)
|
|
40661
|
+
|
|
40662
|
+
if (b4a.isBuffer(buffer)) {
|
|
40663
|
+
header.size = buffer.byteLength
|
|
40664
|
+
sink.write(buffer)
|
|
40665
|
+
sink.end()
|
|
40666
|
+
return sink
|
|
40667
|
+
}
|
|
40668
|
+
|
|
40669
|
+
if (sink._isVoid) {
|
|
40670
|
+
return sink
|
|
40671
|
+
}
|
|
40672
|
+
|
|
40673
|
+
return sink
|
|
40212
40674
|
}
|
|
40213
|
-
}
|
|
40214
40675
|
|
|
40215
|
-
|
|
40216
|
-
|
|
40217
|
-
|
|
40218
|
-
|
|
40219
|
-
|
|
40220
|
-
function _isEBADF(error) {
|
|
40221
|
-
return _isExpectedError(error, -EBADF, 'EBADF');
|
|
40222
|
-
}
|
|
40676
|
+
finalize () {
|
|
40677
|
+
if (this._stream || this._pending.length > 0) {
|
|
40678
|
+
this._finalizing = true
|
|
40679
|
+
return
|
|
40680
|
+
}
|
|
40223
40681
|
|
|
40224
|
-
|
|
40225
|
-
|
|
40226
|
-
*
|
|
40227
|
-
* @private
|
|
40228
|
-
*/
|
|
40229
|
-
function _isENOENT(error) {
|
|
40230
|
-
return _isExpectedError(error, -ENOENT, 'ENOENT');
|
|
40231
|
-
}
|
|
40682
|
+
if (this._finalized) return
|
|
40683
|
+
this._finalized = true
|
|
40232
40684
|
|
|
40233
|
-
|
|
40234
|
-
|
|
40235
|
-
|
|
40236
|
-
*
|
|
40237
|
-
* - Node >= 7.0:
|
|
40238
|
-
* error.code {string}
|
|
40239
|
-
* error.errno {number} any numerical value will be negated
|
|
40240
|
-
*
|
|
40241
|
-
* CAVEAT
|
|
40242
|
-
*
|
|
40243
|
-
* On windows, the errno for EBADF is -4083 but os.constants.errno.EBADF is different and we must assume that ENOENT
|
|
40244
|
-
* is no different here.
|
|
40245
|
-
*
|
|
40246
|
-
* @param {SystemError} error
|
|
40247
|
-
* @param {number} errno
|
|
40248
|
-
* @param {string} code
|
|
40249
|
-
* @private
|
|
40250
|
-
*/
|
|
40251
|
-
function _isExpectedError(error, errno, code) {
|
|
40252
|
-
return IS_WIN32 ? error.code === code : error.code === code && error.errno === errno;
|
|
40253
|
-
}
|
|
40685
|
+
this.push(END_OF_TAR)
|
|
40686
|
+
this.push(null)
|
|
40687
|
+
}
|
|
40254
40688
|
|
|
40255
|
-
|
|
40256
|
-
|
|
40257
|
-
*
|
|
40258
|
-
* If graceful cleanup is set, tmp will remove all controlled temporary objects on process exit, otherwise the
|
|
40259
|
-
* temporary objects will remain in place, waiting to be cleaned up on system restart or otherwise scheduled temporary
|
|
40260
|
-
* object removals.
|
|
40261
|
-
*/
|
|
40262
|
-
function setGracefulCleanup() {
|
|
40263
|
-
_gracefulCleanup = true;
|
|
40264
|
-
}
|
|
40689
|
+
_done (stream) {
|
|
40690
|
+
if (stream !== this._stream) return
|
|
40265
40691
|
|
|
40266
|
-
|
|
40267
|
-
* Returns the currently configured tmp dir from os.tmpdir().
|
|
40268
|
-
*
|
|
40269
|
-
* @private
|
|
40270
|
-
* @param {?Options} options
|
|
40271
|
-
* @returns {string} the currently configured tmp dir
|
|
40272
|
-
*/
|
|
40273
|
-
function _getTmpDir(options) {
|
|
40274
|
-
return path.resolve(_sanitizeName(options && options.tmpdir || os.tmpdir()));
|
|
40275
|
-
}
|
|
40692
|
+
this._stream = null
|
|
40276
40693
|
|
|
40277
|
-
|
|
40278
|
-
|
|
40694
|
+
if (this._finalizing) this.finalize()
|
|
40695
|
+
if (this._pending.length) this._pending.shift()._continueOpen()
|
|
40696
|
+
}
|
|
40279
40697
|
|
|
40280
|
-
|
|
40281
|
-
|
|
40282
|
-
|
|
40283
|
-
|
|
40284
|
-
|
|
40285
|
-
|
|
40286
|
-
|
|
40287
|
-
|
|
40288
|
-
|
|
40289
|
-
|
|
40290
|
-
* @property {?string} prefix prefix for the generated name
|
|
40291
|
-
* @property {?string} postfix postfix for the generated name
|
|
40292
|
-
* @property {?string} tmpdir the root tmp directory which overrides the os tmpdir
|
|
40293
|
-
* @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty
|
|
40294
|
-
* @property {?boolean} detachDescriptor detaches the file descriptor, caller is responsible for closing the file, tmp will no longer try closing the file during garbage collection
|
|
40295
|
-
* @property {?boolean} discardDescriptor discards the file descriptor (closes file, fd is -1), tmp will no longer try closing the file during garbage collection
|
|
40296
|
-
*/
|
|
40698
|
+
_encode (header) {
|
|
40699
|
+
if (!header.pax) {
|
|
40700
|
+
const buf = headers.encode(header)
|
|
40701
|
+
if (buf) {
|
|
40702
|
+
this.push(buf)
|
|
40703
|
+
return
|
|
40704
|
+
}
|
|
40705
|
+
}
|
|
40706
|
+
this._encodePax(header)
|
|
40707
|
+
}
|
|
40297
40708
|
|
|
40298
|
-
|
|
40299
|
-
|
|
40300
|
-
|
|
40301
|
-
|
|
40302
|
-
|
|
40303
|
-
|
|
40709
|
+
_encodePax (header) {
|
|
40710
|
+
const paxHeader = headers.encodePax({
|
|
40711
|
+
name: header.name,
|
|
40712
|
+
linkname: header.linkname,
|
|
40713
|
+
pax: header.pax
|
|
40714
|
+
})
|
|
40304
40715
|
|
|
40305
|
-
|
|
40306
|
-
|
|
40307
|
-
|
|
40308
|
-
|
|
40309
|
-
|
|
40716
|
+
const newHeader = {
|
|
40717
|
+
name: 'PaxHeader',
|
|
40718
|
+
mode: header.mode,
|
|
40719
|
+
uid: header.uid,
|
|
40720
|
+
gid: header.gid,
|
|
40721
|
+
size: paxHeader.byteLength,
|
|
40722
|
+
mtime: header.mtime,
|
|
40723
|
+
type: 'pax-header',
|
|
40724
|
+
linkname: header.linkname && 'PaxHeader',
|
|
40725
|
+
uname: header.uname,
|
|
40726
|
+
gname: header.gname,
|
|
40727
|
+
devmajor: header.devmajor,
|
|
40728
|
+
devminor: header.devminor
|
|
40729
|
+
}
|
|
40310
40730
|
|
|
40311
|
-
|
|
40312
|
-
|
|
40313
|
-
|
|
40314
|
-
* @param {string} name the temporary file name
|
|
40315
|
-
*/
|
|
40731
|
+
this.push(headers.encode(newHeader))
|
|
40732
|
+
this.push(paxHeader)
|
|
40733
|
+
overflow(this, paxHeader.byteLength)
|
|
40316
40734
|
|
|
40317
|
-
|
|
40318
|
-
|
|
40319
|
-
|
|
40320
|
-
|
|
40321
|
-
* @param {number} fd the file descriptor or -1 if the fd had been discarded
|
|
40322
|
-
* @param {cleanupCallback} fn the cleanup callback function
|
|
40323
|
-
*/
|
|
40735
|
+
newHeader.size = header.size
|
|
40736
|
+
newHeader.type = header.type
|
|
40737
|
+
this.push(headers.encode(newHeader))
|
|
40738
|
+
}
|
|
40324
40739
|
|
|
40325
|
-
|
|
40326
|
-
|
|
40327
|
-
|
|
40328
|
-
|
|
40329
|
-
|
|
40330
|
-
* @param {cleanupCallbackSync} fn the cleanup callback function
|
|
40331
|
-
*/
|
|
40740
|
+
_doDrain () {
|
|
40741
|
+
const drain = this._drain
|
|
40742
|
+
this._drain = noop
|
|
40743
|
+
drain()
|
|
40744
|
+
}
|
|
40332
40745
|
|
|
40333
|
-
|
|
40334
|
-
|
|
40335
|
-
* @param {?Error} err the error object if anything goes wrong
|
|
40336
|
-
* @param {string} name the temporary file name
|
|
40337
|
-
* @param {cleanupCallback} fn the cleanup callback function
|
|
40338
|
-
*/
|
|
40746
|
+
_predestroy () {
|
|
40747
|
+
const err = getStreamError(this)
|
|
40339
40748
|
|
|
40340
|
-
|
|
40341
|
-
* @callback dirCallbackSync
|
|
40342
|
-
* @param {?Error} err the error object if anything goes wrong
|
|
40343
|
-
* @param {string} name the temporary file name
|
|
40344
|
-
* @param {cleanupCallbackSync} fn the cleanup callback function
|
|
40345
|
-
*/
|
|
40749
|
+
if (this._stream) this._stream.destroy(err)
|
|
40346
40750
|
|
|
40347
|
-
|
|
40348
|
-
|
|
40349
|
-
|
|
40350
|
-
|
|
40351
|
-
|
|
40352
|
-
*/
|
|
40751
|
+
while (this._pending.length) {
|
|
40752
|
+
const stream = this._pending.shift()
|
|
40753
|
+
stream.destroy(err)
|
|
40754
|
+
stream._continueOpen()
|
|
40755
|
+
}
|
|
40353
40756
|
|
|
40354
|
-
|
|
40355
|
-
|
|
40356
|
-
*
|
|
40357
|
-
* @callback cleanupCallbackSync
|
|
40358
|
-
*/
|
|
40757
|
+
this._doDrain()
|
|
40758
|
+
}
|
|
40359
40759
|
|
|
40360
|
-
|
|
40361
|
-
|
|
40362
|
-
|
|
40363
|
-
|
|
40364
|
-
|
|
40365
|
-
*/
|
|
40760
|
+
_read (cb) {
|
|
40761
|
+
this._doDrain()
|
|
40762
|
+
cb()
|
|
40763
|
+
}
|
|
40764
|
+
}
|
|
40366
40765
|
|
|
40367
|
-
|
|
40766
|
+
module.exports = function pack (opts) {
|
|
40767
|
+
return new Pack(opts)
|
|
40768
|
+
}
|
|
40368
40769
|
|
|
40369
|
-
|
|
40370
|
-
|
|
40371
|
-
|
|
40372
|
-
|
|
40373
|
-
|
|
40374
|
-
|
|
40375
|
-
return
|
|
40770
|
+
function modeToType (mode) {
|
|
40771
|
+
switch (mode & constants.S_IFMT) {
|
|
40772
|
+
case constants.S_IFBLK: return 'block-device'
|
|
40773
|
+
case constants.S_IFCHR: return 'character-device'
|
|
40774
|
+
case constants.S_IFDIR: return 'directory'
|
|
40775
|
+
case constants.S_IFIFO: return 'fifo'
|
|
40776
|
+
case constants.S_IFLNK: return 'symlink'
|
|
40376
40777
|
}
|
|
40377
|
-
}));
|
|
40378
40778
|
|
|
40379
|
-
|
|
40380
|
-
|
|
40779
|
+
return 'file'
|
|
40780
|
+
}
|
|
40381
40781
|
|
|
40382
|
-
|
|
40383
|
-
module.exports.fileSync = fileSync;
|
|
40782
|
+
function noop () {}
|
|
40384
40783
|
|
|
40385
|
-
|
|
40386
|
-
|
|
40784
|
+
function overflow (self, size) {
|
|
40785
|
+
size &= 511
|
|
40786
|
+
if (size) self.push(END_OF_TAR.subarray(0, 512 - size))
|
|
40787
|
+
}
|
|
40387
40788
|
|
|
40388
|
-
|
|
40789
|
+
function mapWritable (buf) {
|
|
40790
|
+
return b4a.isBuffer(buf) ? buf : b4a.from(buf)
|
|
40791
|
+
}
|
|
40389
40792
|
|
|
40390
40793
|
|
|
40391
40794
|
/***/ }),
|
|
@@ -83466,6 +83869,161 @@ module.exports = {
|
|
|
83466
83869
|
};
|
|
83467
83870
|
|
|
83468
83871
|
|
|
83872
|
+
/***/ }),
|
|
83873
|
+
|
|
83874
|
+
/***/ 85792:
|
|
83875
|
+
/***/ ((module) => {
|
|
83876
|
+
|
|
83877
|
+
function isBuffer (value) {
|
|
83878
|
+
return Buffer.isBuffer(value) || value instanceof Uint8Array
|
|
83879
|
+
}
|
|
83880
|
+
|
|
83881
|
+
function isEncoding (encoding) {
|
|
83882
|
+
return Buffer.isEncoding(encoding)
|
|
83883
|
+
}
|
|
83884
|
+
|
|
83885
|
+
function alloc (size, fill, encoding) {
|
|
83886
|
+
return Buffer.alloc(size, fill, encoding)
|
|
83887
|
+
}
|
|
83888
|
+
|
|
83889
|
+
function allocUnsafe (size) {
|
|
83890
|
+
return Buffer.allocUnsafe(size)
|
|
83891
|
+
}
|
|
83892
|
+
|
|
83893
|
+
function allocUnsafeSlow (size) {
|
|
83894
|
+
return Buffer.allocUnsafeSlow(size)
|
|
83895
|
+
}
|
|
83896
|
+
|
|
83897
|
+
function byteLength (string, encoding) {
|
|
83898
|
+
return Buffer.byteLength(string, encoding)
|
|
83899
|
+
}
|
|
83900
|
+
|
|
83901
|
+
function compare (a, b) {
|
|
83902
|
+
return Buffer.compare(a, b)
|
|
83903
|
+
}
|
|
83904
|
+
|
|
83905
|
+
function concat (buffers, totalLength) {
|
|
83906
|
+
return Buffer.concat(buffers, totalLength)
|
|
83907
|
+
}
|
|
83908
|
+
|
|
83909
|
+
function copy (source, target, targetStart, start, end) {
|
|
83910
|
+
return toBuffer(source).copy(target, targetStart, start, end)
|
|
83911
|
+
}
|
|
83912
|
+
|
|
83913
|
+
function equals (a, b) {
|
|
83914
|
+
return toBuffer(a).equals(b)
|
|
83915
|
+
}
|
|
83916
|
+
|
|
83917
|
+
function fill (buffer, value, offset, end, encoding) {
|
|
83918
|
+
return toBuffer(buffer).fill(value, offset, end, encoding)
|
|
83919
|
+
}
|
|
83920
|
+
|
|
83921
|
+
function from (value, encodingOrOffset, length) {
|
|
83922
|
+
return Buffer.from(value, encodingOrOffset, length)
|
|
83923
|
+
}
|
|
83924
|
+
|
|
83925
|
+
function includes (buffer, value, byteOffset, encoding) {
|
|
83926
|
+
return toBuffer(buffer).includes(value, byteOffset, encoding)
|
|
83927
|
+
}
|
|
83928
|
+
|
|
83929
|
+
function indexOf (buffer, value, byfeOffset, encoding) {
|
|
83930
|
+
return toBuffer(buffer).indexOf(value, byfeOffset, encoding)
|
|
83931
|
+
}
|
|
83932
|
+
|
|
83933
|
+
function lastIndexOf (buffer, value, byteOffset, encoding) {
|
|
83934
|
+
return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding)
|
|
83935
|
+
}
|
|
83936
|
+
|
|
83937
|
+
function swap16 (buffer) {
|
|
83938
|
+
return toBuffer(buffer).swap16()
|
|
83939
|
+
}
|
|
83940
|
+
|
|
83941
|
+
function swap32 (buffer) {
|
|
83942
|
+
return toBuffer(buffer).swap32()
|
|
83943
|
+
}
|
|
83944
|
+
|
|
83945
|
+
function swap64 (buffer) {
|
|
83946
|
+
return toBuffer(buffer).swap64()
|
|
83947
|
+
}
|
|
83948
|
+
|
|
83949
|
+
function toBuffer (buffer) {
|
|
83950
|
+
if (Buffer.isBuffer(buffer)) return buffer
|
|
83951
|
+
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
|
83952
|
+
}
|
|
83953
|
+
|
|
83954
|
+
function toString (buffer, encoding, start, end) {
|
|
83955
|
+
return toBuffer(buffer).toString(encoding, start, end)
|
|
83956
|
+
}
|
|
83957
|
+
|
|
83958
|
+
function write (buffer, string, offset, length, encoding) {
|
|
83959
|
+
return toBuffer(buffer).write(string, offset, length, encoding)
|
|
83960
|
+
}
|
|
83961
|
+
|
|
83962
|
+
function writeDoubleLE (buffer, value, offset) {
|
|
83963
|
+
return toBuffer(buffer).writeDoubleLE(value, offset)
|
|
83964
|
+
}
|
|
83965
|
+
|
|
83966
|
+
function writeFloatLE (buffer, value, offset) {
|
|
83967
|
+
return toBuffer(buffer).writeFloatLE(value, offset)
|
|
83968
|
+
}
|
|
83969
|
+
|
|
83970
|
+
function writeUInt32LE (buffer, value, offset) {
|
|
83971
|
+
return toBuffer(buffer).writeUInt32LE(value, offset)
|
|
83972
|
+
}
|
|
83973
|
+
|
|
83974
|
+
function writeInt32LE (buffer, value, offset) {
|
|
83975
|
+
return toBuffer(buffer).writeInt32LE(value, offset)
|
|
83976
|
+
}
|
|
83977
|
+
|
|
83978
|
+
function readDoubleLE (buffer, offset) {
|
|
83979
|
+
return toBuffer(buffer).readDoubleLE(offset)
|
|
83980
|
+
}
|
|
83981
|
+
|
|
83982
|
+
function readFloatLE (buffer, offset) {
|
|
83983
|
+
return toBuffer(buffer).readFloatLE(offset)
|
|
83984
|
+
}
|
|
83985
|
+
|
|
83986
|
+
function readUInt32LE (buffer, offset) {
|
|
83987
|
+
return toBuffer(buffer).readUInt32LE(offset)
|
|
83988
|
+
}
|
|
83989
|
+
|
|
83990
|
+
function readInt32LE (buffer, offset) {
|
|
83991
|
+
return toBuffer(buffer).readInt32LE(offset)
|
|
83992
|
+
}
|
|
83993
|
+
|
|
83994
|
+
module.exports = {
|
|
83995
|
+
isBuffer,
|
|
83996
|
+
isEncoding,
|
|
83997
|
+
alloc,
|
|
83998
|
+
allocUnsafe,
|
|
83999
|
+
allocUnsafeSlow,
|
|
84000
|
+
byteLength,
|
|
84001
|
+
compare,
|
|
84002
|
+
concat,
|
|
84003
|
+
copy,
|
|
84004
|
+
equals,
|
|
84005
|
+
fill,
|
|
84006
|
+
from,
|
|
84007
|
+
includes,
|
|
84008
|
+
indexOf,
|
|
84009
|
+
lastIndexOf,
|
|
84010
|
+
swap16,
|
|
84011
|
+
swap32,
|
|
84012
|
+
swap64,
|
|
84013
|
+
toBuffer,
|
|
84014
|
+
toString,
|
|
84015
|
+
write,
|
|
84016
|
+
writeDoubleLE,
|
|
84017
|
+
writeFloatLE,
|
|
84018
|
+
writeUInt32LE,
|
|
84019
|
+
writeInt32LE,
|
|
84020
|
+
readDoubleLE,
|
|
84021
|
+
readFloatLE,
|
|
84022
|
+
readUInt32LE,
|
|
84023
|
+
readInt32LE
|
|
84024
|
+
}
|
|
84025
|
+
|
|
84026
|
+
|
|
83469
84027
|
/***/ }),
|
|
83470
84028
|
|
|
83471
84029
|
/***/ 62703:
|
|
@@ -98703,6 +99261,107 @@ const event_loop_spinner_1 = __webpack_require__(17234);
|
|
|
98703
99261
|
exports.eventLoopSpinner = new event_loop_spinner_1.EventLoopSpinner();
|
|
98704
99262
|
//# sourceMappingURL=index.js.map
|
|
98705
99263
|
|
|
99264
|
+
/***/ }),
|
|
99265
|
+
|
|
99266
|
+
/***/ 3975:
|
|
99267
|
+
/***/ ((module) => {
|
|
99268
|
+
|
|
99269
|
+
module.exports = class FixedFIFO {
|
|
99270
|
+
constructor (hwm) {
|
|
99271
|
+
if (!(hwm > 0) || ((hwm - 1) & hwm) !== 0) throw new Error('Max size for a FixedFIFO should be a power of two')
|
|
99272
|
+
this.buffer = new Array(hwm)
|
|
99273
|
+
this.mask = hwm - 1
|
|
99274
|
+
this.top = 0
|
|
99275
|
+
this.btm = 0
|
|
99276
|
+
this.next = null
|
|
99277
|
+
}
|
|
99278
|
+
|
|
99279
|
+
clear () {
|
|
99280
|
+
this.top = this.btm = 0
|
|
99281
|
+
this.next = null
|
|
99282
|
+
this.buffer.fill(undefined)
|
|
99283
|
+
}
|
|
99284
|
+
|
|
99285
|
+
push (data) {
|
|
99286
|
+
if (this.buffer[this.top] !== undefined) return false
|
|
99287
|
+
this.buffer[this.top] = data
|
|
99288
|
+
this.top = (this.top + 1) & this.mask
|
|
99289
|
+
return true
|
|
99290
|
+
}
|
|
99291
|
+
|
|
99292
|
+
shift () {
|
|
99293
|
+
const last = this.buffer[this.btm]
|
|
99294
|
+
if (last === undefined) return undefined
|
|
99295
|
+
this.buffer[this.btm] = undefined
|
|
99296
|
+
this.btm = (this.btm + 1) & this.mask
|
|
99297
|
+
return last
|
|
99298
|
+
}
|
|
99299
|
+
|
|
99300
|
+
peek () {
|
|
99301
|
+
return this.buffer[this.btm]
|
|
99302
|
+
}
|
|
99303
|
+
|
|
99304
|
+
isEmpty () {
|
|
99305
|
+
return this.buffer[this.btm] === undefined
|
|
99306
|
+
}
|
|
99307
|
+
}
|
|
99308
|
+
|
|
99309
|
+
|
|
99310
|
+
/***/ }),
|
|
99311
|
+
|
|
99312
|
+
/***/ 91607:
|
|
99313
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
99314
|
+
|
|
99315
|
+
const FixedFIFO = __webpack_require__(3975)
|
|
99316
|
+
|
|
99317
|
+
module.exports = class FastFIFO {
|
|
99318
|
+
constructor (hwm) {
|
|
99319
|
+
this.hwm = hwm || 16
|
|
99320
|
+
this.head = new FixedFIFO(this.hwm)
|
|
99321
|
+
this.tail = this.head
|
|
99322
|
+
this.length = 0
|
|
99323
|
+
}
|
|
99324
|
+
|
|
99325
|
+
clear () {
|
|
99326
|
+
this.head = this.tail
|
|
99327
|
+
this.head.clear()
|
|
99328
|
+
this.length = 0
|
|
99329
|
+
}
|
|
99330
|
+
|
|
99331
|
+
push (val) {
|
|
99332
|
+
this.length++
|
|
99333
|
+
if (!this.head.push(val)) {
|
|
99334
|
+
const prev = this.head
|
|
99335
|
+
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length)
|
|
99336
|
+
this.head.push(val)
|
|
99337
|
+
}
|
|
99338
|
+
}
|
|
99339
|
+
|
|
99340
|
+
shift () {
|
|
99341
|
+
if (this.length !== 0) this.length--
|
|
99342
|
+
const val = this.tail.shift()
|
|
99343
|
+
if (val === undefined && this.tail.next) {
|
|
99344
|
+
const next = this.tail.next
|
|
99345
|
+
this.tail.next = null
|
|
99346
|
+
this.tail = next
|
|
99347
|
+
return this.tail.shift()
|
|
99348
|
+
}
|
|
99349
|
+
|
|
99350
|
+
return val
|
|
99351
|
+
}
|
|
99352
|
+
|
|
99353
|
+
peek () {
|
|
99354
|
+
const val = this.tail.peek()
|
|
99355
|
+
if (val === undefined && this.tail.next) return this.tail.next.peek()
|
|
99356
|
+
return val
|
|
99357
|
+
}
|
|
99358
|
+
|
|
99359
|
+
isEmpty () {
|
|
99360
|
+
return this.length === 0
|
|
99361
|
+
}
|
|
99362
|
+
}
|
|
99363
|
+
|
|
99364
|
+
|
|
98706
99365
|
/***/ }),
|
|
98707
99366
|
|
|
98708
99367
|
/***/ 66004:
|
|
@@ -180712,6 +181371,111 @@ module.exports = (fromStream, toStream) => {
|
|
|
180712
181371
|
};
|
|
180713
181372
|
|
|
180714
181373
|
|
|
181374
|
+
/***/ }),
|
|
181375
|
+
|
|
181376
|
+
/***/ 42986:
|
|
181377
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
181378
|
+
|
|
181379
|
+
var path = __webpack_require__(71017);
|
|
181380
|
+
var fs = __webpack_require__(57147);
|
|
181381
|
+
var _0777 = parseInt('0777', 8);
|
|
181382
|
+
|
|
181383
|
+
module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
|
|
181384
|
+
|
|
181385
|
+
function mkdirP (p, opts, f, made) {
|
|
181386
|
+
if (typeof opts === 'function') {
|
|
181387
|
+
f = opts;
|
|
181388
|
+
opts = {};
|
|
181389
|
+
}
|
|
181390
|
+
else if (!opts || typeof opts !== 'object') {
|
|
181391
|
+
opts = { mode: opts };
|
|
181392
|
+
}
|
|
181393
|
+
|
|
181394
|
+
var mode = opts.mode;
|
|
181395
|
+
var xfs = opts.fs || fs;
|
|
181396
|
+
|
|
181397
|
+
if (mode === undefined) {
|
|
181398
|
+
mode = _0777 & (~process.umask());
|
|
181399
|
+
}
|
|
181400
|
+
if (!made) made = null;
|
|
181401
|
+
|
|
181402
|
+
var cb = f || function () {};
|
|
181403
|
+
p = path.resolve(p);
|
|
181404
|
+
|
|
181405
|
+
xfs.mkdir(p, mode, function (er) {
|
|
181406
|
+
if (!er) {
|
|
181407
|
+
made = made || p;
|
|
181408
|
+
return cb(null, made);
|
|
181409
|
+
}
|
|
181410
|
+
switch (er.code) {
|
|
181411
|
+
case 'ENOENT':
|
|
181412
|
+
mkdirP(path.dirname(p), opts, function (er, made) {
|
|
181413
|
+
if (er) cb(er, made);
|
|
181414
|
+
else mkdirP(p, opts, cb, made);
|
|
181415
|
+
});
|
|
181416
|
+
break;
|
|
181417
|
+
|
|
181418
|
+
// In the case of any other error, just see if there's a dir
|
|
181419
|
+
// there already. If so, then hooray! If not, then something
|
|
181420
|
+
// is borked.
|
|
181421
|
+
default:
|
|
181422
|
+
xfs.stat(p, function (er2, stat) {
|
|
181423
|
+
// if the stat fails, then that's super weird.
|
|
181424
|
+
// let the original error be the failure reason.
|
|
181425
|
+
if (er2 || !stat.isDirectory()) cb(er, made)
|
|
181426
|
+
else cb(null, made);
|
|
181427
|
+
});
|
|
181428
|
+
break;
|
|
181429
|
+
}
|
|
181430
|
+
});
|
|
181431
|
+
}
|
|
181432
|
+
|
|
181433
|
+
mkdirP.sync = function sync (p, opts, made) {
|
|
181434
|
+
if (!opts || typeof opts !== 'object') {
|
|
181435
|
+
opts = { mode: opts };
|
|
181436
|
+
}
|
|
181437
|
+
|
|
181438
|
+
var mode = opts.mode;
|
|
181439
|
+
var xfs = opts.fs || fs;
|
|
181440
|
+
|
|
181441
|
+
if (mode === undefined) {
|
|
181442
|
+
mode = _0777 & (~process.umask());
|
|
181443
|
+
}
|
|
181444
|
+
if (!made) made = null;
|
|
181445
|
+
|
|
181446
|
+
p = path.resolve(p);
|
|
181447
|
+
|
|
181448
|
+
try {
|
|
181449
|
+
xfs.mkdirSync(p, mode);
|
|
181450
|
+
made = made || p;
|
|
181451
|
+
}
|
|
181452
|
+
catch (err0) {
|
|
181453
|
+
switch (err0.code) {
|
|
181454
|
+
case 'ENOENT' :
|
|
181455
|
+
made = sync(path.dirname(p), opts, made);
|
|
181456
|
+
sync(p, opts, made);
|
|
181457
|
+
break;
|
|
181458
|
+
|
|
181459
|
+
// In the case of any other error, just see if there's a dir
|
|
181460
|
+
// there already. If so, then hooray! If not, then something
|
|
181461
|
+
// is borked.
|
|
181462
|
+
default:
|
|
181463
|
+
var stat;
|
|
181464
|
+
try {
|
|
181465
|
+
stat = xfs.statSync(p);
|
|
181466
|
+
}
|
|
181467
|
+
catch (err1) {
|
|
181468
|
+
throw err0;
|
|
181469
|
+
}
|
|
181470
|
+
if (!stat.isDirectory()) throw err0;
|
|
181471
|
+
break;
|
|
181472
|
+
}
|
|
181473
|
+
}
|
|
181474
|
+
|
|
181475
|
+
return made;
|
|
181476
|
+
};
|
|
181477
|
+
|
|
181478
|
+
|
|
180715
181479
|
/***/ }),
|
|
180716
181480
|
|
|
180717
181481
|
/***/ 23424:
|
|
@@ -186377,6 +187141,24 @@ module.exports = typeof queueMicrotask === 'function'
|
|
|
186377
187141
|
.catch(err => setTimeout(() => { throw err }, 0))
|
|
186378
187142
|
|
|
186379
187143
|
|
|
187144
|
+
/***/ }),
|
|
187145
|
+
|
|
187146
|
+
/***/ 63522:
|
|
187147
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
187148
|
+
|
|
187149
|
+
module.exports = (typeof process !== 'undefined' && typeof process.nextTick === 'function')
|
|
187150
|
+
? process.nextTick.bind(process)
|
|
187151
|
+
: __webpack_require__(83527)
|
|
187152
|
+
|
|
187153
|
+
|
|
187154
|
+
/***/ }),
|
|
187155
|
+
|
|
187156
|
+
/***/ 83527:
|
|
187157
|
+
/***/ ((module) => {
|
|
187158
|
+
|
|
187159
|
+
module.exports = typeof queueMicrotask === 'function' ? queueMicrotask : (fn) => Promise.resolve().then(fn)
|
|
187160
|
+
|
|
187161
|
+
|
|
186380
187162
|
/***/ }),
|
|
186381
187163
|
|
|
186382
187164
|
/***/ 45322:
|
|
@@ -274582,6 +275364,1112 @@ function getStateLength (state) {
|
|
|
274582
275364
|
}
|
|
274583
275365
|
|
|
274584
275366
|
|
|
275367
|
+
/***/ }),
|
|
275368
|
+
|
|
275369
|
+
/***/ 81237:
|
|
275370
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
275371
|
+
|
|
275372
|
+
const { EventEmitter } = __webpack_require__(82361)
|
|
275373
|
+
const STREAM_DESTROYED = new Error('Stream was destroyed')
|
|
275374
|
+
const PREMATURE_CLOSE = new Error('Premature close')
|
|
275375
|
+
|
|
275376
|
+
const queueTick = __webpack_require__(63522)
|
|
275377
|
+
const FIFO = __webpack_require__(91607)
|
|
275378
|
+
|
|
275379
|
+
/* eslint-disable no-multi-spaces */
|
|
275380
|
+
|
|
275381
|
+
// 27 bits used total (4 from shared, 13 from read, and 10 from write)
|
|
275382
|
+
const MAX = ((1 << 27) - 1)
|
|
275383
|
+
|
|
275384
|
+
// Shared state
|
|
275385
|
+
const OPENING = 0b0001
|
|
275386
|
+
const PREDESTROYING = 0b0010
|
|
275387
|
+
const DESTROYING = 0b0100
|
|
275388
|
+
const DESTROYED = 0b1000
|
|
275389
|
+
|
|
275390
|
+
const NOT_OPENING = MAX ^ OPENING
|
|
275391
|
+
const NOT_PREDESTROYING = MAX ^ PREDESTROYING
|
|
275392
|
+
|
|
275393
|
+
// Read state (4 bit offset from shared state)
|
|
275394
|
+
const READ_ACTIVE = 0b0000000000001 << 4
|
|
275395
|
+
const READ_UPDATING = 0b0000000000010 << 4
|
|
275396
|
+
const READ_PRIMARY = 0b0000000000100 << 4
|
|
275397
|
+
const READ_QUEUED = 0b0000000001000 << 4
|
|
275398
|
+
const READ_RESUMED = 0b0000000010000 << 4
|
|
275399
|
+
const READ_PIPE_DRAINED = 0b0000000100000 << 4
|
|
275400
|
+
const READ_ENDING = 0b0000001000000 << 4
|
|
275401
|
+
const READ_EMIT_DATA = 0b0000010000000 << 4
|
|
275402
|
+
const READ_EMIT_READABLE = 0b0000100000000 << 4
|
|
275403
|
+
const READ_EMITTED_READABLE = 0b0001000000000 << 4
|
|
275404
|
+
const READ_DONE = 0b0010000000000 << 4
|
|
275405
|
+
const READ_NEXT_TICK = 0b0100000000000 << 4
|
|
275406
|
+
const READ_NEEDS_PUSH = 0b1000000000000 << 4
|
|
275407
|
+
|
|
275408
|
+
// Combined read state
|
|
275409
|
+
const READ_FLOWING = READ_RESUMED | READ_PIPE_DRAINED
|
|
275410
|
+
const READ_ACTIVE_AND_NEEDS_PUSH = READ_ACTIVE | READ_NEEDS_PUSH
|
|
275411
|
+
const READ_PRIMARY_AND_ACTIVE = READ_PRIMARY | READ_ACTIVE
|
|
275412
|
+
const READ_EMIT_READABLE_AND_QUEUED = READ_EMIT_READABLE | READ_QUEUED
|
|
275413
|
+
|
|
275414
|
+
const READ_NOT_ACTIVE = MAX ^ READ_ACTIVE
|
|
275415
|
+
const READ_NON_PRIMARY = MAX ^ READ_PRIMARY
|
|
275416
|
+
const READ_NON_PRIMARY_AND_PUSHED = MAX ^ (READ_PRIMARY | READ_NEEDS_PUSH)
|
|
275417
|
+
const READ_PUSHED = MAX ^ READ_NEEDS_PUSH
|
|
275418
|
+
const READ_PAUSED = MAX ^ READ_RESUMED
|
|
275419
|
+
const READ_NOT_QUEUED = MAX ^ (READ_QUEUED | READ_EMITTED_READABLE)
|
|
275420
|
+
const READ_NOT_ENDING = MAX ^ READ_ENDING
|
|
275421
|
+
const READ_PIPE_NOT_DRAINED = MAX ^ READ_FLOWING
|
|
275422
|
+
const READ_NOT_NEXT_TICK = MAX ^ READ_NEXT_TICK
|
|
275423
|
+
const READ_NOT_UPDATING = MAX ^ READ_UPDATING
|
|
275424
|
+
|
|
275425
|
+
// Write state (17 bit offset, 4 bit offset from shared state and 13 from read state)
|
|
275426
|
+
const WRITE_ACTIVE = 0b0000000001 << 17
|
|
275427
|
+
const WRITE_UPDATING = 0b0000000010 << 17
|
|
275428
|
+
const WRITE_PRIMARY = 0b0000000100 << 17
|
|
275429
|
+
const WRITE_QUEUED = 0b0000001000 << 17
|
|
275430
|
+
const WRITE_UNDRAINED = 0b0000010000 << 17
|
|
275431
|
+
const WRITE_DONE = 0b0000100000 << 17
|
|
275432
|
+
const WRITE_EMIT_DRAIN = 0b0001000000 << 17
|
|
275433
|
+
const WRITE_NEXT_TICK = 0b0010000000 << 17
|
|
275434
|
+
const WRITE_WRITING = 0b0100000000 << 17
|
|
275435
|
+
const WRITE_FINISHING = 0b1000000000 << 17
|
|
275436
|
+
|
|
275437
|
+
const WRITE_NOT_ACTIVE = MAX ^ (WRITE_ACTIVE | WRITE_WRITING)
|
|
275438
|
+
const WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY
|
|
275439
|
+
const WRITE_NOT_FINISHING = MAX ^ WRITE_FINISHING
|
|
275440
|
+
const WRITE_DRAINED = MAX ^ WRITE_UNDRAINED
|
|
275441
|
+
const WRITE_NOT_QUEUED = MAX ^ WRITE_QUEUED
|
|
275442
|
+
const WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK
|
|
275443
|
+
const WRITE_NOT_UPDATING = MAX ^ WRITE_UPDATING
|
|
275444
|
+
|
|
275445
|
+
// Combined shared state
|
|
275446
|
+
const ACTIVE = READ_ACTIVE | WRITE_ACTIVE
|
|
275447
|
+
const NOT_ACTIVE = MAX ^ ACTIVE
|
|
275448
|
+
const DONE = READ_DONE | WRITE_DONE
|
|
275449
|
+
const DESTROY_STATUS = DESTROYING | DESTROYED | PREDESTROYING
|
|
275450
|
+
const OPEN_STATUS = DESTROY_STATUS | OPENING
|
|
275451
|
+
const AUTO_DESTROY = DESTROY_STATUS | DONE
|
|
275452
|
+
const NON_PRIMARY = WRITE_NON_PRIMARY & READ_NON_PRIMARY
|
|
275453
|
+
const ACTIVE_OR_TICKING = WRITE_NEXT_TICK | READ_NEXT_TICK
|
|
275454
|
+
const TICKING = ACTIVE_OR_TICKING & NOT_ACTIVE
|
|
275455
|
+
const IS_OPENING = OPEN_STATUS | TICKING
|
|
275456
|
+
|
|
275457
|
+
// Combined shared state and read state
|
|
275458
|
+
const READ_PRIMARY_STATUS = OPEN_STATUS | READ_ENDING | READ_DONE
|
|
275459
|
+
const READ_STATUS = OPEN_STATUS | READ_DONE | READ_QUEUED
|
|
275460
|
+
const READ_ENDING_STATUS = OPEN_STATUS | READ_ENDING | READ_QUEUED
|
|
275461
|
+
const READ_READABLE_STATUS = OPEN_STATUS | READ_EMIT_READABLE | READ_QUEUED | READ_EMITTED_READABLE
|
|
275462
|
+
const SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH
|
|
275463
|
+
const READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE
|
|
275464
|
+
const READ_UPDATE_SYNC_STATUS = READ_UPDATING | OPEN_STATUS | READ_NEXT_TICK | READ_PRIMARY
|
|
275465
|
+
|
|
275466
|
+
// Combined write state
|
|
275467
|
+
const WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE
|
|
275468
|
+
const WRITE_QUEUED_AND_UNDRAINED = WRITE_QUEUED | WRITE_UNDRAINED
|
|
275469
|
+
const WRITE_QUEUED_AND_ACTIVE = WRITE_QUEUED | WRITE_ACTIVE
|
|
275470
|
+
const WRITE_DRAIN_STATUS = WRITE_QUEUED | WRITE_UNDRAINED | OPEN_STATUS | WRITE_ACTIVE
|
|
275471
|
+
const WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED
|
|
275472
|
+
const WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE
|
|
275473
|
+
const WRITE_ACTIVE_AND_WRITING = WRITE_ACTIVE | WRITE_WRITING
|
|
275474
|
+
const WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED_AND_ACTIVE | WRITE_DONE
|
|
275475
|
+
const WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE
|
|
275476
|
+
const WRITE_UPDATE_SYNC_STATUS = WRITE_UPDATING | OPEN_STATUS | WRITE_NEXT_TICK | WRITE_PRIMARY
|
|
275477
|
+
|
|
275478
|
+
const asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator')
|
|
275479
|
+
|
|
275480
|
+
class WritableState {
|
|
275481
|
+
constructor (stream, { highWaterMark = 16384, map = null, mapWritable, byteLength, byteLengthWritable } = {}) {
|
|
275482
|
+
this.stream = stream
|
|
275483
|
+
this.queue = new FIFO()
|
|
275484
|
+
this.highWaterMark = highWaterMark
|
|
275485
|
+
this.buffered = 0
|
|
275486
|
+
this.error = null
|
|
275487
|
+
this.pipeline = null
|
|
275488
|
+
this.drains = null // if we add more seldomly used helpers we might them into a subobject so its a single ptr
|
|
275489
|
+
this.byteLength = byteLengthWritable || byteLength || defaultByteLength
|
|
275490
|
+
this.map = mapWritable || map
|
|
275491
|
+
this.afterWrite = afterWrite.bind(this)
|
|
275492
|
+
this.afterUpdateNextTick = updateWriteNT.bind(this)
|
|
275493
|
+
}
|
|
275494
|
+
|
|
275495
|
+
get ended () {
|
|
275496
|
+
return (this.stream._duplexState & WRITE_DONE) !== 0
|
|
275497
|
+
}
|
|
275498
|
+
|
|
275499
|
+
push (data) {
|
|
275500
|
+
if (this.map !== null) data = this.map(data)
|
|
275501
|
+
|
|
275502
|
+
this.buffered += this.byteLength(data)
|
|
275503
|
+
this.queue.push(data)
|
|
275504
|
+
|
|
275505
|
+
if (this.buffered < this.highWaterMark) {
|
|
275506
|
+
this.stream._duplexState |= WRITE_QUEUED
|
|
275507
|
+
return true
|
|
275508
|
+
}
|
|
275509
|
+
|
|
275510
|
+
this.stream._duplexState |= WRITE_QUEUED_AND_UNDRAINED
|
|
275511
|
+
return false
|
|
275512
|
+
}
|
|
275513
|
+
|
|
275514
|
+
shift () {
|
|
275515
|
+
const data = this.queue.shift()
|
|
275516
|
+
|
|
275517
|
+
this.buffered -= this.byteLength(data)
|
|
275518
|
+
if (this.buffered === 0) this.stream._duplexState &= WRITE_NOT_QUEUED
|
|
275519
|
+
|
|
275520
|
+
return data
|
|
275521
|
+
}
|
|
275522
|
+
|
|
275523
|
+
end (data) {
|
|
275524
|
+
if (typeof data === 'function') this.stream.once('finish', data)
|
|
275525
|
+
else if (data !== undefined && data !== null) this.push(data)
|
|
275526
|
+
this.stream._duplexState = (this.stream._duplexState | WRITE_FINISHING) & WRITE_NON_PRIMARY
|
|
275527
|
+
}
|
|
275528
|
+
|
|
275529
|
+
autoBatch (data, cb) {
|
|
275530
|
+
const buffer = []
|
|
275531
|
+
const stream = this.stream
|
|
275532
|
+
|
|
275533
|
+
buffer.push(data)
|
|
275534
|
+
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED_AND_ACTIVE) {
|
|
275535
|
+
buffer.push(stream._writableState.shift())
|
|
275536
|
+
}
|
|
275537
|
+
|
|
275538
|
+
if ((stream._duplexState & OPEN_STATUS) !== 0) return cb(null)
|
|
275539
|
+
stream._writev(buffer, cb)
|
|
275540
|
+
}
|
|
275541
|
+
|
|
275542
|
+
update () {
|
|
275543
|
+
const stream = this.stream
|
|
275544
|
+
|
|
275545
|
+
stream._duplexState |= WRITE_UPDATING
|
|
275546
|
+
|
|
275547
|
+
do {
|
|
275548
|
+
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
|
|
275549
|
+
const data = this.shift()
|
|
275550
|
+
stream._duplexState |= WRITE_ACTIVE_AND_WRITING
|
|
275551
|
+
stream._write(data, this.afterWrite)
|
|
275552
|
+
}
|
|
275553
|
+
|
|
275554
|
+
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
|
|
275555
|
+
} while (this.continueUpdate() === true)
|
|
275556
|
+
|
|
275557
|
+
stream._duplexState &= WRITE_NOT_UPDATING
|
|
275558
|
+
}
|
|
275559
|
+
|
|
275560
|
+
updateNonPrimary () {
|
|
275561
|
+
const stream = this.stream
|
|
275562
|
+
|
|
275563
|
+
if ((stream._duplexState & WRITE_FINISHING_STATUS) === WRITE_FINISHING) {
|
|
275564
|
+
stream._duplexState = (stream._duplexState | WRITE_ACTIVE) & WRITE_NOT_FINISHING
|
|
275565
|
+
stream._final(afterFinal.bind(this))
|
|
275566
|
+
return
|
|
275567
|
+
}
|
|
275568
|
+
|
|
275569
|
+
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
275570
|
+
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
275571
|
+
stream._duplexState |= ACTIVE
|
|
275572
|
+
stream._destroy(afterDestroy.bind(this))
|
|
275573
|
+
}
|
|
275574
|
+
return
|
|
275575
|
+
}
|
|
275576
|
+
|
|
275577
|
+
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
275578
|
+
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING
|
|
275579
|
+
stream._open(afterOpen.bind(this))
|
|
275580
|
+
}
|
|
275581
|
+
}
|
|
275582
|
+
|
|
275583
|
+
continueUpdate () {
|
|
275584
|
+
if ((this.stream._duplexState & WRITE_NEXT_TICK) === 0) return false
|
|
275585
|
+
this.stream._duplexState &= WRITE_NOT_NEXT_TICK
|
|
275586
|
+
return true
|
|
275587
|
+
}
|
|
275588
|
+
|
|
275589
|
+
updateCallback () {
|
|
275590
|
+
if ((this.stream._duplexState & WRITE_UPDATE_SYNC_STATUS) === WRITE_PRIMARY) this.update()
|
|
275591
|
+
else this.updateNextTick()
|
|
275592
|
+
}
|
|
275593
|
+
|
|
275594
|
+
updateNextTick () {
|
|
275595
|
+
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return
|
|
275596
|
+
this.stream._duplexState |= WRITE_NEXT_TICK
|
|
275597
|
+
if ((this.stream._duplexState & WRITE_UPDATING) === 0) queueTick(this.afterUpdateNextTick)
|
|
275598
|
+
}
|
|
275599
|
+
}
|
|
275600
|
+
|
|
275601
|
+
class ReadableState {
|
|
275602
|
+
constructor (stream, { highWaterMark = 16384, map = null, mapReadable, byteLength, byteLengthReadable } = {}) {
|
|
275603
|
+
this.stream = stream
|
|
275604
|
+
this.queue = new FIFO()
|
|
275605
|
+
this.highWaterMark = highWaterMark
|
|
275606
|
+
this.buffered = 0
|
|
275607
|
+
this.error = null
|
|
275608
|
+
this.pipeline = null
|
|
275609
|
+
this.byteLength = byteLengthReadable || byteLength || defaultByteLength
|
|
275610
|
+
this.map = mapReadable || map
|
|
275611
|
+
this.pipeTo = null
|
|
275612
|
+
this.afterRead = afterRead.bind(this)
|
|
275613
|
+
this.afterUpdateNextTick = updateReadNT.bind(this)
|
|
275614
|
+
}
|
|
275615
|
+
|
|
275616
|
+
get ended () {
|
|
275617
|
+
return (this.stream._duplexState & READ_DONE) !== 0
|
|
275618
|
+
}
|
|
275619
|
+
|
|
275620
|
+
pipe (pipeTo, cb) {
|
|
275621
|
+
if (this.pipeTo !== null) throw new Error('Can only pipe to one destination')
|
|
275622
|
+
if (typeof cb !== 'function') cb = null
|
|
275623
|
+
|
|
275624
|
+
this.stream._duplexState |= READ_PIPE_DRAINED
|
|
275625
|
+
this.pipeTo = pipeTo
|
|
275626
|
+
this.pipeline = new Pipeline(this.stream, pipeTo, cb)
|
|
275627
|
+
|
|
275628
|
+
if (cb) this.stream.on('error', noop) // We already error handle this so supress crashes
|
|
275629
|
+
|
|
275630
|
+
if (isStreamx(pipeTo)) {
|
|
275631
|
+
pipeTo._writableState.pipeline = this.pipeline
|
|
275632
|
+
if (cb) pipeTo.on('error', noop) // We already error handle this so supress crashes
|
|
275633
|
+
pipeTo.on('finish', this.pipeline.finished.bind(this.pipeline)) // TODO: just call finished from pipeTo itself
|
|
275634
|
+
} else {
|
|
275635
|
+
const onerror = this.pipeline.done.bind(this.pipeline, pipeTo)
|
|
275636
|
+
const onclose = this.pipeline.done.bind(this.pipeline, pipeTo, null) // onclose has a weird bool arg
|
|
275637
|
+
pipeTo.on('error', onerror)
|
|
275638
|
+
pipeTo.on('close', onclose)
|
|
275639
|
+
pipeTo.on('finish', this.pipeline.finished.bind(this.pipeline))
|
|
275640
|
+
}
|
|
275641
|
+
|
|
275642
|
+
pipeTo.on('drain', afterDrain.bind(this))
|
|
275643
|
+
this.stream.emit('piping', pipeTo)
|
|
275644
|
+
pipeTo.emit('pipe', this.stream)
|
|
275645
|
+
}
|
|
275646
|
+
|
|
275647
|
+
push (data) {
|
|
275648
|
+
const stream = this.stream
|
|
275649
|
+
|
|
275650
|
+
if (data === null) {
|
|
275651
|
+
this.highWaterMark = 0
|
|
275652
|
+
stream._duplexState = (stream._duplexState | READ_ENDING) & READ_NON_PRIMARY_AND_PUSHED
|
|
275653
|
+
return false
|
|
275654
|
+
}
|
|
275655
|
+
|
|
275656
|
+
if (this.map !== null) data = this.map(data)
|
|
275657
|
+
this.buffered += this.byteLength(data)
|
|
275658
|
+
this.queue.push(data)
|
|
275659
|
+
|
|
275660
|
+
stream._duplexState = (stream._duplexState | READ_QUEUED) & READ_PUSHED
|
|
275661
|
+
|
|
275662
|
+
return this.buffered < this.highWaterMark
|
|
275663
|
+
}
|
|
275664
|
+
|
|
275665
|
+
shift () {
|
|
275666
|
+
const data = this.queue.shift()
|
|
275667
|
+
|
|
275668
|
+
this.buffered -= this.byteLength(data)
|
|
275669
|
+
if (this.buffered === 0) this.stream._duplexState &= READ_NOT_QUEUED
|
|
275670
|
+
return data
|
|
275671
|
+
}
|
|
275672
|
+
|
|
275673
|
+
unshift (data) {
|
|
275674
|
+
const pending = [this.map !== null ? this.map(data) : data]
|
|
275675
|
+
while (this.buffered > 0) pending.push(this.shift())
|
|
275676
|
+
|
|
275677
|
+
for (let i = 0; i < pending.length - 1; i++) {
|
|
275678
|
+
const data = pending[i]
|
|
275679
|
+
this.buffered += this.byteLength(data)
|
|
275680
|
+
this.queue.push(data)
|
|
275681
|
+
}
|
|
275682
|
+
|
|
275683
|
+
this.push(pending[pending.length - 1])
|
|
275684
|
+
}
|
|
275685
|
+
|
|
275686
|
+
read () {
|
|
275687
|
+
const stream = this.stream
|
|
275688
|
+
|
|
275689
|
+
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
|
|
275690
|
+
const data = this.shift()
|
|
275691
|
+
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED
|
|
275692
|
+
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit('data', data)
|
|
275693
|
+
return data
|
|
275694
|
+
}
|
|
275695
|
+
|
|
275696
|
+
return null
|
|
275697
|
+
}
|
|
275698
|
+
|
|
275699
|
+
drain () {
|
|
275700
|
+
const stream = this.stream
|
|
275701
|
+
|
|
275702
|
+
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
|
|
275703
|
+
const data = this.shift()
|
|
275704
|
+
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED
|
|
275705
|
+
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit('data', data)
|
|
275706
|
+
}
|
|
275707
|
+
}
|
|
275708
|
+
|
|
275709
|
+
update () {
|
|
275710
|
+
const stream = this.stream
|
|
275711
|
+
|
|
275712
|
+
stream._duplexState |= READ_UPDATING
|
|
275713
|
+
|
|
275714
|
+
do {
|
|
275715
|
+
this.drain()
|
|
275716
|
+
|
|
275717
|
+
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === 0) {
|
|
275718
|
+
stream._duplexState |= READ_ACTIVE_AND_NEEDS_PUSH
|
|
275719
|
+
stream._read(this.afterRead)
|
|
275720
|
+
this.drain()
|
|
275721
|
+
}
|
|
275722
|
+
|
|
275723
|
+
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
|
|
275724
|
+
stream._duplexState |= READ_EMITTED_READABLE
|
|
275725
|
+
stream.emit('readable')
|
|
275726
|
+
}
|
|
275727
|
+
|
|
275728
|
+
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
|
|
275729
|
+
} while (this.continueUpdate() === true)
|
|
275730
|
+
|
|
275731
|
+
stream._duplexState &= READ_NOT_UPDATING
|
|
275732
|
+
}
|
|
275733
|
+
|
|
275734
|
+
updateNonPrimary () {
|
|
275735
|
+
const stream = this.stream
|
|
275736
|
+
|
|
275737
|
+
if ((stream._duplexState & READ_ENDING_STATUS) === READ_ENDING) {
|
|
275738
|
+
stream._duplexState = (stream._duplexState | READ_DONE) & READ_NOT_ENDING
|
|
275739
|
+
stream.emit('end')
|
|
275740
|
+
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING
|
|
275741
|
+
if (this.pipeTo !== null) this.pipeTo.end()
|
|
275742
|
+
}
|
|
275743
|
+
|
|
275744
|
+
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
275745
|
+
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
275746
|
+
stream._duplexState |= ACTIVE
|
|
275747
|
+
stream._destroy(afterDestroy.bind(this))
|
|
275748
|
+
}
|
|
275749
|
+
return
|
|
275750
|
+
}
|
|
275751
|
+
|
|
275752
|
+
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
275753
|
+
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING
|
|
275754
|
+
stream._open(afterOpen.bind(this))
|
|
275755
|
+
}
|
|
275756
|
+
}
|
|
275757
|
+
|
|
275758
|
+
continueUpdate () {
|
|
275759
|
+
if ((this.stream._duplexState & READ_NEXT_TICK) === 0) return false
|
|
275760
|
+
this.stream._duplexState &= READ_NOT_NEXT_TICK
|
|
275761
|
+
return true
|
|
275762
|
+
}
|
|
275763
|
+
|
|
275764
|
+
updateCallback () {
|
|
275765
|
+
if ((this.stream._duplexState & READ_UPDATE_SYNC_STATUS) === READ_PRIMARY) this.update()
|
|
275766
|
+
else this.updateNextTick()
|
|
275767
|
+
}
|
|
275768
|
+
|
|
275769
|
+
updateNextTick () {
|
|
275770
|
+
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return
|
|
275771
|
+
this.stream._duplexState |= READ_NEXT_TICK
|
|
275772
|
+
if ((this.stream._duplexState & READ_UPDATING) === 0) queueTick(this.afterUpdateNextTick)
|
|
275773
|
+
}
|
|
275774
|
+
}
|
|
275775
|
+
|
|
275776
|
+
class TransformState {
|
|
275777
|
+
constructor (stream) {
|
|
275778
|
+
this.data = null
|
|
275779
|
+
this.afterTransform = afterTransform.bind(stream)
|
|
275780
|
+
this.afterFinal = null
|
|
275781
|
+
}
|
|
275782
|
+
}
|
|
275783
|
+
|
|
275784
|
+
class Pipeline {
|
|
275785
|
+
constructor (src, dst, cb) {
|
|
275786
|
+
this.from = src
|
|
275787
|
+
this.to = dst
|
|
275788
|
+
this.afterPipe = cb
|
|
275789
|
+
this.error = null
|
|
275790
|
+
this.pipeToFinished = false
|
|
275791
|
+
}
|
|
275792
|
+
|
|
275793
|
+
finished () {
|
|
275794
|
+
this.pipeToFinished = true
|
|
275795
|
+
}
|
|
275796
|
+
|
|
275797
|
+
done (stream, err) {
|
|
275798
|
+
if (err) this.error = err
|
|
275799
|
+
|
|
275800
|
+
if (stream === this.to) {
|
|
275801
|
+
this.to = null
|
|
275802
|
+
|
|
275803
|
+
if (this.from !== null) {
|
|
275804
|
+
if ((this.from._duplexState & READ_DONE) === 0 || !this.pipeToFinished) {
|
|
275805
|
+
this.from.destroy(this.error || new Error('Writable stream closed prematurely'))
|
|
275806
|
+
}
|
|
275807
|
+
return
|
|
275808
|
+
}
|
|
275809
|
+
}
|
|
275810
|
+
|
|
275811
|
+
if (stream === this.from) {
|
|
275812
|
+
this.from = null
|
|
275813
|
+
|
|
275814
|
+
if (this.to !== null) {
|
|
275815
|
+
if ((stream._duplexState & READ_DONE) === 0) {
|
|
275816
|
+
this.to.destroy(this.error || new Error('Readable stream closed before ending'))
|
|
275817
|
+
}
|
|
275818
|
+
return
|
|
275819
|
+
}
|
|
275820
|
+
}
|
|
275821
|
+
|
|
275822
|
+
if (this.afterPipe !== null) this.afterPipe(this.error)
|
|
275823
|
+
this.to = this.from = this.afterPipe = null
|
|
275824
|
+
}
|
|
275825
|
+
}
|
|
275826
|
+
|
|
275827
|
+
function afterDrain () {
|
|
275828
|
+
this.stream._duplexState |= READ_PIPE_DRAINED
|
|
275829
|
+
this.updateCallback()
|
|
275830
|
+
}
|
|
275831
|
+
|
|
275832
|
+
function afterFinal (err) {
|
|
275833
|
+
const stream = this.stream
|
|
275834
|
+
if (err) stream.destroy(err)
|
|
275835
|
+
if ((stream._duplexState & DESTROY_STATUS) === 0) {
|
|
275836
|
+
stream._duplexState |= WRITE_DONE
|
|
275837
|
+
stream.emit('finish')
|
|
275838
|
+
}
|
|
275839
|
+
if ((stream._duplexState & AUTO_DESTROY) === DONE) {
|
|
275840
|
+
stream._duplexState |= DESTROYING
|
|
275841
|
+
}
|
|
275842
|
+
|
|
275843
|
+
stream._duplexState &= WRITE_NOT_ACTIVE
|
|
275844
|
+
|
|
275845
|
+
// no need to wait the extra tick here, so we short circuit that
|
|
275846
|
+
if ((stream._duplexState & WRITE_UPDATING) === 0) this.update()
|
|
275847
|
+
else this.updateNextTick()
|
|
275848
|
+
}
|
|
275849
|
+
|
|
275850
|
+
function afterDestroy (err) {
|
|
275851
|
+
const stream = this.stream
|
|
275852
|
+
|
|
275853
|
+
if (!err && this.error !== STREAM_DESTROYED) err = this.error
|
|
275854
|
+
if (err) stream.emit('error', err)
|
|
275855
|
+
stream._duplexState |= DESTROYED
|
|
275856
|
+
stream.emit('close')
|
|
275857
|
+
|
|
275858
|
+
const rs = stream._readableState
|
|
275859
|
+
const ws = stream._writableState
|
|
275860
|
+
|
|
275861
|
+
if (rs !== null && rs.pipeline !== null) rs.pipeline.done(stream, err)
|
|
275862
|
+
|
|
275863
|
+
if (ws !== null) {
|
|
275864
|
+
while (ws.drains !== null && ws.drains.length > 0) ws.drains.shift().resolve(false)
|
|
275865
|
+
if (ws.pipeline !== null) ws.pipeline.done(stream, err)
|
|
275866
|
+
}
|
|
275867
|
+
}
|
|
275868
|
+
|
|
275869
|
+
function afterWrite (err) {
|
|
275870
|
+
const stream = this.stream
|
|
275871
|
+
|
|
275872
|
+
if (err) stream.destroy(err)
|
|
275873
|
+
stream._duplexState &= WRITE_NOT_ACTIVE
|
|
275874
|
+
|
|
275875
|
+
if (this.drains !== null) tickDrains(this.drains)
|
|
275876
|
+
|
|
275877
|
+
if ((stream._duplexState & WRITE_DRAIN_STATUS) === WRITE_UNDRAINED) {
|
|
275878
|
+
stream._duplexState &= WRITE_DRAINED
|
|
275879
|
+
if ((stream._duplexState & WRITE_EMIT_DRAIN) === WRITE_EMIT_DRAIN) {
|
|
275880
|
+
stream.emit('drain')
|
|
275881
|
+
}
|
|
275882
|
+
}
|
|
275883
|
+
|
|
275884
|
+
this.updateCallback()
|
|
275885
|
+
}
|
|
275886
|
+
|
|
275887
|
+
function afterRead (err) {
|
|
275888
|
+
if (err) this.stream.destroy(err)
|
|
275889
|
+
this.stream._duplexState &= READ_NOT_ACTIVE
|
|
275890
|
+
this.updateCallback()
|
|
275891
|
+
}
|
|
275892
|
+
|
|
275893
|
+
function updateReadNT () {
|
|
275894
|
+
if ((this.stream._duplexState & READ_UPDATING) === 0) {
|
|
275895
|
+
this.stream._duplexState &= READ_NOT_NEXT_TICK
|
|
275896
|
+
this.update()
|
|
275897
|
+
}
|
|
275898
|
+
}
|
|
275899
|
+
|
|
275900
|
+
function updateWriteNT () {
|
|
275901
|
+
if ((this.stream._duplexState & WRITE_UPDATING) === 0) {
|
|
275902
|
+
this.stream._duplexState &= WRITE_NOT_NEXT_TICK
|
|
275903
|
+
this.update()
|
|
275904
|
+
}
|
|
275905
|
+
}
|
|
275906
|
+
|
|
275907
|
+
function tickDrains (drains) {
|
|
275908
|
+
for (let i = 0; i < drains.length; i++) {
|
|
275909
|
+
// drains.writes are monotonic, so if one is 0 its always the first one
|
|
275910
|
+
if (--drains[i].writes === 0) {
|
|
275911
|
+
drains.shift().resolve(true)
|
|
275912
|
+
i--
|
|
275913
|
+
}
|
|
275914
|
+
}
|
|
275915
|
+
}
|
|
275916
|
+
|
|
275917
|
+
function afterOpen (err) {
|
|
275918
|
+
const stream = this.stream
|
|
275919
|
+
|
|
275920
|
+
if (err) stream.destroy(err)
|
|
275921
|
+
|
|
275922
|
+
if ((stream._duplexState & DESTROYING) === 0) {
|
|
275923
|
+
if ((stream._duplexState & READ_PRIMARY_STATUS) === 0) stream._duplexState |= READ_PRIMARY
|
|
275924
|
+
if ((stream._duplexState & WRITE_PRIMARY_STATUS) === 0) stream._duplexState |= WRITE_PRIMARY
|
|
275925
|
+
stream.emit('open')
|
|
275926
|
+
}
|
|
275927
|
+
|
|
275928
|
+
stream._duplexState &= NOT_ACTIVE
|
|
275929
|
+
|
|
275930
|
+
if (stream._writableState !== null) {
|
|
275931
|
+
stream._writableState.updateCallback()
|
|
275932
|
+
}
|
|
275933
|
+
|
|
275934
|
+
if (stream._readableState !== null) {
|
|
275935
|
+
stream._readableState.updateCallback()
|
|
275936
|
+
}
|
|
275937
|
+
}
|
|
275938
|
+
|
|
275939
|
+
function afterTransform (err, data) {
|
|
275940
|
+
if (data !== undefined && data !== null) this.push(data)
|
|
275941
|
+
this._writableState.afterWrite(err)
|
|
275942
|
+
}
|
|
275943
|
+
|
|
275944
|
+
function newListener (name) {
|
|
275945
|
+
if (this._readableState !== null) {
|
|
275946
|
+
if (name === 'data') {
|
|
275947
|
+
this._duplexState |= (READ_EMIT_DATA | READ_RESUMED)
|
|
275948
|
+
this._readableState.updateNextTick()
|
|
275949
|
+
}
|
|
275950
|
+
if (name === 'readable') {
|
|
275951
|
+
this._duplexState |= READ_EMIT_READABLE
|
|
275952
|
+
this._readableState.updateNextTick()
|
|
275953
|
+
}
|
|
275954
|
+
}
|
|
275955
|
+
|
|
275956
|
+
if (this._writableState !== null) {
|
|
275957
|
+
if (name === 'drain') {
|
|
275958
|
+
this._duplexState |= WRITE_EMIT_DRAIN
|
|
275959
|
+
this._writableState.updateNextTick()
|
|
275960
|
+
}
|
|
275961
|
+
}
|
|
275962
|
+
}
|
|
275963
|
+
|
|
275964
|
+
class Stream extends EventEmitter {
|
|
275965
|
+
constructor (opts) {
|
|
275966
|
+
super()
|
|
275967
|
+
|
|
275968
|
+
this._duplexState = 0
|
|
275969
|
+
this._readableState = null
|
|
275970
|
+
this._writableState = null
|
|
275971
|
+
|
|
275972
|
+
if (opts) {
|
|
275973
|
+
if (opts.open) this._open = opts.open
|
|
275974
|
+
if (opts.destroy) this._destroy = opts.destroy
|
|
275975
|
+
if (opts.predestroy) this._predestroy = opts.predestroy
|
|
275976
|
+
if (opts.signal) {
|
|
275977
|
+
opts.signal.addEventListener('abort', abort.bind(this))
|
|
275978
|
+
}
|
|
275979
|
+
}
|
|
275980
|
+
|
|
275981
|
+
this.on('newListener', newListener)
|
|
275982
|
+
}
|
|
275983
|
+
|
|
275984
|
+
_open (cb) {
|
|
275985
|
+
cb(null)
|
|
275986
|
+
}
|
|
275987
|
+
|
|
275988
|
+
_destroy (cb) {
|
|
275989
|
+
cb(null)
|
|
275990
|
+
}
|
|
275991
|
+
|
|
275992
|
+
_predestroy () {
|
|
275993
|
+
// does nothing
|
|
275994
|
+
}
|
|
275995
|
+
|
|
275996
|
+
get readable () {
|
|
275997
|
+
return this._readableState !== null ? true : undefined
|
|
275998
|
+
}
|
|
275999
|
+
|
|
276000
|
+
get writable () {
|
|
276001
|
+
return this._writableState !== null ? true : undefined
|
|
276002
|
+
}
|
|
276003
|
+
|
|
276004
|
+
get destroyed () {
|
|
276005
|
+
return (this._duplexState & DESTROYED) !== 0
|
|
276006
|
+
}
|
|
276007
|
+
|
|
276008
|
+
get destroying () {
|
|
276009
|
+
return (this._duplexState & DESTROY_STATUS) !== 0
|
|
276010
|
+
}
|
|
276011
|
+
|
|
276012
|
+
destroy (err) {
|
|
276013
|
+
if ((this._duplexState & DESTROY_STATUS) === 0) {
|
|
276014
|
+
if (!err) err = STREAM_DESTROYED
|
|
276015
|
+
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY
|
|
276016
|
+
|
|
276017
|
+
if (this._readableState !== null) {
|
|
276018
|
+
this._readableState.highWaterMark = 0
|
|
276019
|
+
this._readableState.error = err
|
|
276020
|
+
}
|
|
276021
|
+
if (this._writableState !== null) {
|
|
276022
|
+
this._writableState.highWaterMark = 0
|
|
276023
|
+
this._writableState.error = err
|
|
276024
|
+
}
|
|
276025
|
+
|
|
276026
|
+
this._duplexState |= PREDESTROYING
|
|
276027
|
+
this._predestroy()
|
|
276028
|
+
this._duplexState &= NOT_PREDESTROYING
|
|
276029
|
+
|
|
276030
|
+
if (this._readableState !== null) this._readableState.updateNextTick()
|
|
276031
|
+
if (this._writableState !== null) this._writableState.updateNextTick()
|
|
276032
|
+
}
|
|
276033
|
+
}
|
|
276034
|
+
}
|
|
276035
|
+
|
|
276036
|
+
class Readable extends Stream {
|
|
276037
|
+
constructor (opts) {
|
|
276038
|
+
super(opts)
|
|
276039
|
+
|
|
276040
|
+
this._duplexState |= OPENING | WRITE_DONE
|
|
276041
|
+
this._readableState = new ReadableState(this, opts)
|
|
276042
|
+
|
|
276043
|
+
if (opts) {
|
|
276044
|
+
if (opts.read) this._read = opts.read
|
|
276045
|
+
if (opts.eagerOpen) this._readableState.updateNextTick()
|
|
276046
|
+
}
|
|
276047
|
+
}
|
|
276048
|
+
|
|
276049
|
+
_read (cb) {
|
|
276050
|
+
cb(null)
|
|
276051
|
+
}
|
|
276052
|
+
|
|
276053
|
+
pipe (dest, cb) {
|
|
276054
|
+
this._readableState.updateNextTick()
|
|
276055
|
+
this._readableState.pipe(dest, cb)
|
|
276056
|
+
return dest
|
|
276057
|
+
}
|
|
276058
|
+
|
|
276059
|
+
read () {
|
|
276060
|
+
this._readableState.updateNextTick()
|
|
276061
|
+
return this._readableState.read()
|
|
276062
|
+
}
|
|
276063
|
+
|
|
276064
|
+
push (data) {
|
|
276065
|
+
this._readableState.updateNextTick()
|
|
276066
|
+
return this._readableState.push(data)
|
|
276067
|
+
}
|
|
276068
|
+
|
|
276069
|
+
unshift (data) {
|
|
276070
|
+
this._readableState.updateNextTick()
|
|
276071
|
+
return this._readableState.unshift(data)
|
|
276072
|
+
}
|
|
276073
|
+
|
|
276074
|
+
resume () {
|
|
276075
|
+
this._duplexState |= READ_RESUMED
|
|
276076
|
+
this._readableState.updateNextTick()
|
|
276077
|
+
return this
|
|
276078
|
+
}
|
|
276079
|
+
|
|
276080
|
+
pause () {
|
|
276081
|
+
this._duplexState &= READ_PAUSED
|
|
276082
|
+
return this
|
|
276083
|
+
}
|
|
276084
|
+
|
|
276085
|
+
static _fromAsyncIterator (ite, opts) {
|
|
276086
|
+
let destroy
|
|
276087
|
+
|
|
276088
|
+
const rs = new Readable({
|
|
276089
|
+
...opts,
|
|
276090
|
+
read (cb) {
|
|
276091
|
+
ite.next().then(push).then(cb.bind(null, null)).catch(cb)
|
|
276092
|
+
},
|
|
276093
|
+
predestroy () {
|
|
276094
|
+
destroy = ite.return()
|
|
276095
|
+
},
|
|
276096
|
+
destroy (cb) {
|
|
276097
|
+
if (!destroy) return cb(null)
|
|
276098
|
+
destroy.then(cb.bind(null, null)).catch(cb)
|
|
276099
|
+
}
|
|
276100
|
+
})
|
|
276101
|
+
|
|
276102
|
+
return rs
|
|
276103
|
+
|
|
276104
|
+
function push (data) {
|
|
276105
|
+
if (data.done) rs.push(null)
|
|
276106
|
+
else rs.push(data.value)
|
|
276107
|
+
}
|
|
276108
|
+
}
|
|
276109
|
+
|
|
276110
|
+
static from (data, opts) {
|
|
276111
|
+
if (isReadStreamx(data)) return data
|
|
276112
|
+
if (data[asyncIterator]) return this._fromAsyncIterator(data[asyncIterator](), opts)
|
|
276113
|
+
if (!Array.isArray(data)) data = data === undefined ? [] : [data]
|
|
276114
|
+
|
|
276115
|
+
let i = 0
|
|
276116
|
+
return new Readable({
|
|
276117
|
+
...opts,
|
|
276118
|
+
read (cb) {
|
|
276119
|
+
this.push(i === data.length ? null : data[i++])
|
|
276120
|
+
cb(null)
|
|
276121
|
+
}
|
|
276122
|
+
})
|
|
276123
|
+
}
|
|
276124
|
+
|
|
276125
|
+
static isBackpressured (rs) {
|
|
276126
|
+
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark
|
|
276127
|
+
}
|
|
276128
|
+
|
|
276129
|
+
static isPaused (rs) {
|
|
276130
|
+
return (rs._duplexState & READ_RESUMED) === 0
|
|
276131
|
+
}
|
|
276132
|
+
|
|
276133
|
+
[asyncIterator] () {
|
|
276134
|
+
const stream = this
|
|
276135
|
+
|
|
276136
|
+
let error = null
|
|
276137
|
+
let promiseResolve = null
|
|
276138
|
+
let promiseReject = null
|
|
276139
|
+
|
|
276140
|
+
this.on('error', (err) => { error = err })
|
|
276141
|
+
this.on('readable', onreadable)
|
|
276142
|
+
this.on('close', onclose)
|
|
276143
|
+
|
|
276144
|
+
return {
|
|
276145
|
+
[asyncIterator] () {
|
|
276146
|
+
return this
|
|
276147
|
+
},
|
|
276148
|
+
next () {
|
|
276149
|
+
return new Promise(function (resolve, reject) {
|
|
276150
|
+
promiseResolve = resolve
|
|
276151
|
+
promiseReject = reject
|
|
276152
|
+
const data = stream.read()
|
|
276153
|
+
if (data !== null) ondata(data)
|
|
276154
|
+
else if ((stream._duplexState & DESTROYED) !== 0) ondata(null)
|
|
276155
|
+
})
|
|
276156
|
+
},
|
|
276157
|
+
return () {
|
|
276158
|
+
return destroy(null)
|
|
276159
|
+
},
|
|
276160
|
+
throw (err) {
|
|
276161
|
+
return destroy(err)
|
|
276162
|
+
}
|
|
276163
|
+
}
|
|
276164
|
+
|
|
276165
|
+
function onreadable () {
|
|
276166
|
+
if (promiseResolve !== null) ondata(stream.read())
|
|
276167
|
+
}
|
|
276168
|
+
|
|
276169
|
+
function onclose () {
|
|
276170
|
+
if (promiseResolve !== null) ondata(null)
|
|
276171
|
+
}
|
|
276172
|
+
|
|
276173
|
+
function ondata (data) {
|
|
276174
|
+
if (promiseReject === null) return
|
|
276175
|
+
if (error) promiseReject(error)
|
|
276176
|
+
else if (data === null && (stream._duplexState & READ_DONE) === 0) promiseReject(STREAM_DESTROYED)
|
|
276177
|
+
else promiseResolve({ value: data, done: data === null })
|
|
276178
|
+
promiseReject = promiseResolve = null
|
|
276179
|
+
}
|
|
276180
|
+
|
|
276181
|
+
function destroy (err) {
|
|
276182
|
+
stream.destroy(err)
|
|
276183
|
+
return new Promise((resolve, reject) => {
|
|
276184
|
+
if (stream._duplexState & DESTROYED) return resolve({ value: undefined, done: true })
|
|
276185
|
+
stream.once('close', function () {
|
|
276186
|
+
if (err) reject(err)
|
|
276187
|
+
else resolve({ value: undefined, done: true })
|
|
276188
|
+
})
|
|
276189
|
+
})
|
|
276190
|
+
}
|
|
276191
|
+
}
|
|
276192
|
+
}
|
|
276193
|
+
|
|
276194
|
+
class Writable extends Stream {
|
|
276195
|
+
constructor (opts) {
|
|
276196
|
+
super(opts)
|
|
276197
|
+
|
|
276198
|
+
this._duplexState |= OPENING | READ_DONE
|
|
276199
|
+
this._writableState = new WritableState(this, opts)
|
|
276200
|
+
|
|
276201
|
+
if (opts) {
|
|
276202
|
+
if (opts.writev) this._writev = opts.writev
|
|
276203
|
+
if (opts.write) this._write = opts.write
|
|
276204
|
+
if (opts.final) this._final = opts.final
|
|
276205
|
+
if (opts.eagerOpen) this._writableState.updateNextTick()
|
|
276206
|
+
}
|
|
276207
|
+
}
|
|
276208
|
+
|
|
276209
|
+
_writev (batch, cb) {
|
|
276210
|
+
cb(null)
|
|
276211
|
+
}
|
|
276212
|
+
|
|
276213
|
+
_write (data, cb) {
|
|
276214
|
+
this._writableState.autoBatch(data, cb)
|
|
276215
|
+
}
|
|
276216
|
+
|
|
276217
|
+
_final (cb) {
|
|
276218
|
+
cb(null)
|
|
276219
|
+
}
|
|
276220
|
+
|
|
276221
|
+
static isBackpressured (ws) {
|
|
276222
|
+
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0
|
|
276223
|
+
}
|
|
276224
|
+
|
|
276225
|
+
static drained (ws) {
|
|
276226
|
+
if (ws.destroyed) return Promise.resolve(false)
|
|
276227
|
+
const state = ws._writableState
|
|
276228
|
+
const pending = (isWritev(ws) ? Math.min(1, state.queue.length) : state.queue.length)
|
|
276229
|
+
const writes = pending + ((ws._duplexState & WRITE_WRITING) ? 1 : 0)
|
|
276230
|
+
if (writes === 0) return Promise.resolve(true)
|
|
276231
|
+
if (state.drains === null) state.drains = []
|
|
276232
|
+
return new Promise((resolve) => {
|
|
276233
|
+
state.drains.push({ writes, resolve })
|
|
276234
|
+
})
|
|
276235
|
+
}
|
|
276236
|
+
|
|
276237
|
+
write (data) {
|
|
276238
|
+
this._writableState.updateNextTick()
|
|
276239
|
+
return this._writableState.push(data)
|
|
276240
|
+
}
|
|
276241
|
+
|
|
276242
|
+
end (data) {
|
|
276243
|
+
this._writableState.updateNextTick()
|
|
276244
|
+
this._writableState.end(data)
|
|
276245
|
+
return this
|
|
276246
|
+
}
|
|
276247
|
+
}
|
|
276248
|
+
|
|
276249
|
+
class Duplex extends Readable { // and Writable
|
|
276250
|
+
constructor (opts) {
|
|
276251
|
+
super(opts)
|
|
276252
|
+
|
|
276253
|
+
this._duplexState = OPENING
|
|
276254
|
+
this._writableState = new WritableState(this, opts)
|
|
276255
|
+
|
|
276256
|
+
if (opts) {
|
|
276257
|
+
if (opts.writev) this._writev = opts.writev
|
|
276258
|
+
if (opts.write) this._write = opts.write
|
|
276259
|
+
if (opts.final) this._final = opts.final
|
|
276260
|
+
}
|
|
276261
|
+
}
|
|
276262
|
+
|
|
276263
|
+
_writev (batch, cb) {
|
|
276264
|
+
cb(null)
|
|
276265
|
+
}
|
|
276266
|
+
|
|
276267
|
+
_write (data, cb) {
|
|
276268
|
+
this._writableState.autoBatch(data, cb)
|
|
276269
|
+
}
|
|
276270
|
+
|
|
276271
|
+
_final (cb) {
|
|
276272
|
+
cb(null)
|
|
276273
|
+
}
|
|
276274
|
+
|
|
276275
|
+
write (data) {
|
|
276276
|
+
this._writableState.updateNextTick()
|
|
276277
|
+
return this._writableState.push(data)
|
|
276278
|
+
}
|
|
276279
|
+
|
|
276280
|
+
end (data) {
|
|
276281
|
+
this._writableState.updateNextTick()
|
|
276282
|
+
this._writableState.end(data)
|
|
276283
|
+
return this
|
|
276284
|
+
}
|
|
276285
|
+
}
|
|
276286
|
+
|
|
276287
|
+
class Transform extends Duplex {
|
|
276288
|
+
constructor (opts) {
|
|
276289
|
+
super(opts)
|
|
276290
|
+
this._transformState = new TransformState(this)
|
|
276291
|
+
|
|
276292
|
+
if (opts) {
|
|
276293
|
+
if (opts.transform) this._transform = opts.transform
|
|
276294
|
+
if (opts.flush) this._flush = opts.flush
|
|
276295
|
+
}
|
|
276296
|
+
}
|
|
276297
|
+
|
|
276298
|
+
_write (data, cb) {
|
|
276299
|
+
if (this._readableState.buffered >= this._readableState.highWaterMark) {
|
|
276300
|
+
this._transformState.data = data
|
|
276301
|
+
} else {
|
|
276302
|
+
this._transform(data, this._transformState.afterTransform)
|
|
276303
|
+
}
|
|
276304
|
+
}
|
|
276305
|
+
|
|
276306
|
+
_read (cb) {
|
|
276307
|
+
if (this._transformState.data !== null) {
|
|
276308
|
+
const data = this._transformState.data
|
|
276309
|
+
this._transformState.data = null
|
|
276310
|
+
cb(null)
|
|
276311
|
+
this._transform(data, this._transformState.afterTransform)
|
|
276312
|
+
} else {
|
|
276313
|
+
cb(null)
|
|
276314
|
+
}
|
|
276315
|
+
}
|
|
276316
|
+
|
|
276317
|
+
destroy (err) {
|
|
276318
|
+
super.destroy(err)
|
|
276319
|
+
if (this._transformState.data !== null) {
|
|
276320
|
+
this._transformState.data = null
|
|
276321
|
+
this._transformState.afterTransform()
|
|
276322
|
+
}
|
|
276323
|
+
}
|
|
276324
|
+
|
|
276325
|
+
_transform (data, cb) {
|
|
276326
|
+
cb(null, data)
|
|
276327
|
+
}
|
|
276328
|
+
|
|
276329
|
+
_flush (cb) {
|
|
276330
|
+
cb(null)
|
|
276331
|
+
}
|
|
276332
|
+
|
|
276333
|
+
_final (cb) {
|
|
276334
|
+
this._transformState.afterFinal = cb
|
|
276335
|
+
this._flush(transformAfterFlush.bind(this))
|
|
276336
|
+
}
|
|
276337
|
+
}
|
|
276338
|
+
|
|
276339
|
+
class PassThrough extends Transform {}
|
|
276340
|
+
|
|
276341
|
+
function transformAfterFlush (err, data) {
|
|
276342
|
+
const cb = this._transformState.afterFinal
|
|
276343
|
+
if (err) return cb(err)
|
|
276344
|
+
if (data !== null && data !== undefined) this.push(data)
|
|
276345
|
+
this.push(null)
|
|
276346
|
+
cb(null)
|
|
276347
|
+
}
|
|
276348
|
+
|
|
276349
|
+
function pipelinePromise (...streams) {
|
|
276350
|
+
return new Promise((resolve, reject) => {
|
|
276351
|
+
return pipeline(...streams, (err) => {
|
|
276352
|
+
if (err) return reject(err)
|
|
276353
|
+
resolve()
|
|
276354
|
+
})
|
|
276355
|
+
})
|
|
276356
|
+
}
|
|
276357
|
+
|
|
276358
|
+
function pipeline (stream, ...streams) {
|
|
276359
|
+
const all = Array.isArray(stream) ? [...stream, ...streams] : [stream, ...streams]
|
|
276360
|
+
const done = (all.length && typeof all[all.length - 1] === 'function') ? all.pop() : null
|
|
276361
|
+
|
|
276362
|
+
if (all.length < 2) throw new Error('Pipeline requires at least 2 streams')
|
|
276363
|
+
|
|
276364
|
+
let src = all[0]
|
|
276365
|
+
let dest = null
|
|
276366
|
+
let error = null
|
|
276367
|
+
|
|
276368
|
+
for (let i = 1; i < all.length; i++) {
|
|
276369
|
+
dest = all[i]
|
|
276370
|
+
|
|
276371
|
+
if (isStreamx(src)) {
|
|
276372
|
+
src.pipe(dest, onerror)
|
|
276373
|
+
} else {
|
|
276374
|
+
errorHandle(src, true, i > 1, onerror)
|
|
276375
|
+
src.pipe(dest)
|
|
276376
|
+
}
|
|
276377
|
+
|
|
276378
|
+
src = dest
|
|
276379
|
+
}
|
|
276380
|
+
|
|
276381
|
+
if (done) {
|
|
276382
|
+
let fin = false
|
|
276383
|
+
|
|
276384
|
+
const autoDestroy = isStreamx(dest) || !!(dest._writableState && dest._writableState.autoDestroy)
|
|
276385
|
+
|
|
276386
|
+
dest.on('error', (err) => {
|
|
276387
|
+
if (error === null) error = err
|
|
276388
|
+
})
|
|
276389
|
+
|
|
276390
|
+
dest.on('finish', () => {
|
|
276391
|
+
fin = true
|
|
276392
|
+
if (!autoDestroy) done(error)
|
|
276393
|
+
})
|
|
276394
|
+
|
|
276395
|
+
if (autoDestroy) {
|
|
276396
|
+
dest.on('close', () => done(error || (fin ? null : PREMATURE_CLOSE)))
|
|
276397
|
+
}
|
|
276398
|
+
}
|
|
276399
|
+
|
|
276400
|
+
return dest
|
|
276401
|
+
|
|
276402
|
+
function errorHandle (s, rd, wr, onerror) {
|
|
276403
|
+
s.on('error', onerror)
|
|
276404
|
+
s.on('close', onclose)
|
|
276405
|
+
|
|
276406
|
+
function onclose () {
|
|
276407
|
+
if (rd && s._readableState && !s._readableState.ended) return onerror(PREMATURE_CLOSE)
|
|
276408
|
+
if (wr && s._writableState && !s._writableState.ended) return onerror(PREMATURE_CLOSE)
|
|
276409
|
+
}
|
|
276410
|
+
}
|
|
276411
|
+
|
|
276412
|
+
function onerror (err) {
|
|
276413
|
+
if (!err || error) return
|
|
276414
|
+
error = err
|
|
276415
|
+
|
|
276416
|
+
for (const s of all) {
|
|
276417
|
+
s.destroy(err)
|
|
276418
|
+
}
|
|
276419
|
+
}
|
|
276420
|
+
}
|
|
276421
|
+
|
|
276422
|
+
function isStream (stream) {
|
|
276423
|
+
return !!stream._readableState || !!stream._writableState
|
|
276424
|
+
}
|
|
276425
|
+
|
|
276426
|
+
function isStreamx (stream) {
|
|
276427
|
+
return typeof stream._duplexState === 'number' && isStream(stream)
|
|
276428
|
+
}
|
|
276429
|
+
|
|
276430
|
+
function getStreamError (stream) {
|
|
276431
|
+
const err = (stream._readableState && stream._readableState.error) || (stream._writableState && stream._writableState.error)
|
|
276432
|
+
return err === STREAM_DESTROYED ? null : err // only explicit errors
|
|
276433
|
+
}
|
|
276434
|
+
|
|
276435
|
+
function isReadStreamx (stream) {
|
|
276436
|
+
return isStreamx(stream) && stream.readable
|
|
276437
|
+
}
|
|
276438
|
+
|
|
276439
|
+
function isTypedArray (data) {
|
|
276440
|
+
return typeof data === 'object' && data !== null && typeof data.byteLength === 'number'
|
|
276441
|
+
}
|
|
276442
|
+
|
|
276443
|
+
function defaultByteLength (data) {
|
|
276444
|
+
return isTypedArray(data) ? data.byteLength : 1024
|
|
276445
|
+
}
|
|
276446
|
+
|
|
276447
|
+
function noop () {}
|
|
276448
|
+
|
|
276449
|
+
function abort () {
|
|
276450
|
+
this.destroy(new Error('Stream aborted.'))
|
|
276451
|
+
}
|
|
276452
|
+
|
|
276453
|
+
function isWritev (s) {
|
|
276454
|
+
return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev
|
|
276455
|
+
}
|
|
276456
|
+
|
|
276457
|
+
module.exports = {
|
|
276458
|
+
pipeline,
|
|
276459
|
+
pipelinePromise,
|
|
276460
|
+
isStream,
|
|
276461
|
+
isStreamx,
|
|
276462
|
+
getStreamError,
|
|
276463
|
+
Stream,
|
|
276464
|
+
Writable,
|
|
276465
|
+
Readable,
|
|
276466
|
+
Duplex,
|
|
276467
|
+
Transform,
|
|
276468
|
+
// Export PassThrough for compatibility with Node.js core's stream module
|
|
276469
|
+
PassThrough
|
|
276470
|
+
}
|
|
276471
|
+
|
|
276472
|
+
|
|
274585
276473
|
/***/ }),
|
|
274586
276474
|
|
|
274587
276475
|
/***/ 64028:
|