@nebulahome/integration-sdk 0.0.0-stage → 1.1.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/CHANGELOG.md +33 -0
- package/FILES.md +703 -0
- package/LICENSE +21 -0
- package/README.md +128 -2
- package/dist/chunks/node-dist.js +9253 -0
- package/dist/chunks/node-index.d.ts +2090 -0
- package/dist/chunks/node-project.js +545 -0
- package/dist/chunks/node-rolldown-runtime.js +24 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3783 -0
- package/dist/index.d.ts +1427 -0
- package/dist/index.js +53 -0
- package/dist/schemas.d.ts +741 -0
- package/dist/schemas.js +53 -0
- package/dist/testing.d.ts +286 -0
- package/dist/testing.js +271 -0
- package/package.json +76 -3
- package/schemas/account.schema.json +595 -0
- package/schemas/discovery.schema.json +613 -0
- package/schemas/driver.schema.json +119 -0
- package/schemas/manifest.schema.json +557 -0
- package/schemas/profile.schema.json +1480 -0
- package/schemas/setup.schema.json +1166 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,3783 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as readVendorDirectory, t as instantiateVendor } from "./chunks/node-dist.js";
|
|
3
|
+
import { a as sourceModule, i as runtimeVersion, n as isFile, o as createFakeSdk, r as readProject, t as IntegrationError } from "./chunks/node-project.js";
|
|
4
|
+
import { builtinModules } from "node:module";
|
|
5
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
6
|
+
import ro, { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
7
|
+
import path, { basename, join, posix, win32 } from "node:path";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
9
|
+
import { parseArgs } from "node:util";
|
|
10
|
+
import { rolldown } from "rolldown";
|
|
11
|
+
import Qr, { EventEmitter } from "events";
|
|
12
|
+
import I from "fs";
|
|
13
|
+
import { EventEmitter as EventEmitter$1 } from "node:events";
|
|
14
|
+
import Cs from "node:stream";
|
|
15
|
+
import { StringDecoder } from "node:string_decoder";
|
|
16
|
+
import Br from "node:fs";
|
|
17
|
+
import ar, { dirname, parse } from "path";
|
|
18
|
+
import zi from "assert";
|
|
19
|
+
import { Buffer as Buffer$1 } from "buffer";
|
|
20
|
+
import * as Ps from "zlib";
|
|
21
|
+
import en from "zlib";
|
|
22
|
+
import co from "node:assert";
|
|
23
|
+
//#region src/check.ts
|
|
24
|
+
/**
|
|
25
|
+
* `nebulahome-integration validate`: the sources hold together, the way `hub` reads a bundle
|
|
26
|
+
* (INTEGRATIONS_DOCS.md 8.2).
|
|
27
|
+
*
|
|
28
|
+
* It runs the hub's own loader over `src/` - the same schemas, the same checks of every id
|
|
29
|
+
* against its folder, of the runtime range, of the logo, of the containers, of every file and
|
|
30
|
+
* module the bundle names - with the version and the range the build will write, and imports no
|
|
31
|
+
* code. What it passes, `hub` loads; a driver or a `discovery.json` that does not hold is a
|
|
32
|
+
* problem here, though `hub` would load the rest of the vendor without it.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Says where a problem is, from the repository's folder.
|
|
36
|
+
*
|
|
37
|
+
* @param project - The project.
|
|
38
|
+
* @param directory - Where it is.
|
|
39
|
+
* @returns The folder, relative.
|
|
40
|
+
*/
|
|
41
|
+
function where(project, directory) {
|
|
42
|
+
const relative = directory.slice(project.root.length).replaceAll("\\", "/").replace(/^\//u, "");
|
|
43
|
+
return relative === "" ? "src" : relative;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Checks an integration's sources the way `hub` reads a bundle, importing nothing.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Where the repository is.
|
|
49
|
+
* @param options.root - Its folder.
|
|
50
|
+
* @returns The project and what it declares.
|
|
51
|
+
* @throws {IntegrationError} With every problem found.
|
|
52
|
+
*/
|
|
53
|
+
async function checkIntegration(options) {
|
|
54
|
+
const project = await readProject(options.root);
|
|
55
|
+
let declaration;
|
|
56
|
+
try {
|
|
57
|
+
declaration = await readVendorDirectory(project.sourceDirectory, {
|
|
58
|
+
expectedId: project.vendorId,
|
|
59
|
+
stamp: project.stamp,
|
|
60
|
+
runtimeVersion: runtimeVersion(),
|
|
61
|
+
resolveModule: sourceModule
|
|
62
|
+
});
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new IntegrationError([`src: ${error instanceof Error ? error.message : String(error)}`]);
|
|
65
|
+
}
|
|
66
|
+
if (declaration.failures.length > 0) throw new IntegrationError(declaration.failures.map((failure) => `${where(project, failure.directory)}: ${failure.message}`));
|
|
67
|
+
return {
|
|
68
|
+
project,
|
|
69
|
+
declaration
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/build.ts
|
|
74
|
+
/**
|
|
75
|
+
* `nebulahome-integration build`: the sources, checked, built into `dist/<vendor>/` - the vendor
|
|
76
|
+
* directory as `hub` loads it (INTEGRATIONS_DOCS.md 8.3).
|
|
77
|
+
*
|
|
78
|
+
* 1. `validate`'s checks: nothing is written for sources that would not load.
|
|
79
|
+
* 2. Every file that is not code is copied: the JSON with its `$schema` dropped - an editor's,
|
|
80
|
+
* not the bundle's - and the manifest with the release's version and runtime range written in.
|
|
81
|
+
* 3. Every module the bundle names - its transports, streams, account, discovery modules, code
|
|
82
|
+
* drivers - is built in one go, each where the bundle names it (`./lan/transport.js`), what
|
|
83
|
+
* they share in `_chunks/`, what they import bundled in: an installed bundle has no
|
|
84
|
+
* `node_modules`. Node's own modules stay imports. zod is refused: a module validates with
|
|
85
|
+
* `sdk.z`, the hub's own, never a copy of its own.
|
|
86
|
+
* 4. The build is loaded back the way `hub` loads it, its code handed a fake SDK.
|
|
87
|
+
*/
|
|
88
|
+
/** The extensions of code: built from the modules the bundle names, never copied. */
|
|
89
|
+
const CODE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
90
|
+
".ts",
|
|
91
|
+
".mts",
|
|
92
|
+
".cts",
|
|
93
|
+
".tsx",
|
|
94
|
+
".js",
|
|
95
|
+
".mjs",
|
|
96
|
+
".cjs",
|
|
97
|
+
".jsx"
|
|
98
|
+
]);
|
|
99
|
+
/** Where what the modules share is written, inside the vendor: no driver can be called so. */
|
|
100
|
+
const CHUNKS_DIRECTORY = "_chunks";
|
|
101
|
+
/**
|
|
102
|
+
* Every module the bundle names, by its source.
|
|
103
|
+
*
|
|
104
|
+
* @param declaration - What the sources declare.
|
|
105
|
+
* @returns The sources' paths, each once.
|
|
106
|
+
*/
|
|
107
|
+
function modulesOf(declaration) {
|
|
108
|
+
return [.../* @__PURE__ */ new Set([
|
|
109
|
+
...declaration.transports.map((module) => module.path),
|
|
110
|
+
...declaration.streams.map((module) => module.path),
|
|
111
|
+
...declaration.account === void 0 ? [] : [declaration.account.module],
|
|
112
|
+
...declaration.discovery === void 0 ? [] : declaration.discovery.modules.values(),
|
|
113
|
+
...declaration.drivers.flatMap((driver) => driver.entry === void 0 ? [] : [driver.entry])
|
|
114
|
+
])];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A module's name in the build: its path under `src/` without the extension, `lan/transport`,
|
|
118
|
+
* which the build writes as `lan/transport.js` - where the bundle names it.
|
|
119
|
+
*
|
|
120
|
+
* @param project - The project.
|
|
121
|
+
* @param file - The module's source.
|
|
122
|
+
* @returns The name.
|
|
123
|
+
*/
|
|
124
|
+
function entryNameOf(project, file) {
|
|
125
|
+
const relative = path.relative(project.sourceDirectory, file);
|
|
126
|
+
return relative.slice(0, relative.length - path.extname(relative).length).split(path.sep).join("/");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Whether an import is one of Node's own modules, which the hub's Node provides.
|
|
130
|
+
*
|
|
131
|
+
* @param id - What is imported.
|
|
132
|
+
* @returns True when it is.
|
|
133
|
+
*/
|
|
134
|
+
function isNodeBuiltin(id) {
|
|
135
|
+
return id.startsWith("node:") || builtinModules.includes(id) || builtinModules.includes(id.split("/")[0] ?? "");
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Refuses what an integration's code must not import, and keeps the author's paths out of what
|
|
139
|
+
* it writes.
|
|
140
|
+
*
|
|
141
|
+
* @returns The plugin.
|
|
142
|
+
*/
|
|
143
|
+
function refusedImports() {
|
|
144
|
+
return {
|
|
145
|
+
name: "nebulahome:integration-imports",
|
|
146
|
+
/**
|
|
147
|
+
* Refuses zod, and the SDK's testing.
|
|
148
|
+
*
|
|
149
|
+
* @param source - What is imported.
|
|
150
|
+
* @param importer - Who imports it.
|
|
151
|
+
* @returns Nothing: what is not refused is resolved as usual.
|
|
152
|
+
* @throws {Error} When it is refused.
|
|
153
|
+
*/
|
|
154
|
+
resolveId(source, importer) {
|
|
155
|
+
const by = importer === void 0 ? "" : ` (in ${importer})`;
|
|
156
|
+
if (source === "zod" || source.startsWith("zod/")) throw new Error(`An integration's code builds its schemas with sdk.z, the hub's zod, and does not import zod${by}`);
|
|
157
|
+
if (source.startsWith("@nebulahome/integration-sdk/testing")) throw new Error(`@nebulahome/integration-sdk/testing is for tests, not for a module${by}`);
|
|
158
|
+
return null;
|
|
159
|
+
},
|
|
160
|
+
/**
|
|
161
|
+
* Drops the comments that say which file each part of a chunk came from: they name the
|
|
162
|
+
* author's own disk, which a release has no business carrying, and would make two machines
|
|
163
|
+
* build the same sources to different bytes.
|
|
164
|
+
*
|
|
165
|
+
* @param code - The chunk.
|
|
166
|
+
* @returns The chunk, without them.
|
|
167
|
+
*/
|
|
168
|
+
renderChunk(code) {
|
|
169
|
+
return code.replace(/^\/\/#(?:end)?region\b.*(?:\r?\n|$)/gmu, "");
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Copies every file of the sources that is not code: the JSON without its `$schema`, the manifest
|
|
175
|
+
* with the release's version and runtime range.
|
|
176
|
+
*
|
|
177
|
+
* @param project - The project.
|
|
178
|
+
* @returns How many files were copied.
|
|
179
|
+
*/
|
|
180
|
+
async function copyFiles(project) {
|
|
181
|
+
const entries = await readdir(project.sourceDirectory, {
|
|
182
|
+
recursive: true,
|
|
183
|
+
withFileTypes: true
|
|
184
|
+
});
|
|
185
|
+
let copied = 0;
|
|
186
|
+
await Promise.all(entries.map(async (entry) => {
|
|
187
|
+
const source = path.join(entry.parentPath, entry.name);
|
|
188
|
+
const relative = path.relative(project.sourceDirectory, source);
|
|
189
|
+
if (!entry.isFile() || entry.name.startsWith(".") || CODE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) return;
|
|
190
|
+
const target = path.join(project.outputDirectory, relative);
|
|
191
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
192
|
+
copied += 1;
|
|
193
|
+
if (path.extname(entry.name).toLowerCase() !== ".json") {
|
|
194
|
+
await writeFile(target, await readFile(source));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const parsed = JSON.parse(await readFile(source, "utf8"));
|
|
198
|
+
let written = parsed;
|
|
199
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
200
|
+
const { id, ...rest } = Object.fromEntries(Object.entries(parsed).filter(([key]) => key !== "$schema"));
|
|
201
|
+
written = relative === "manifest.json" ? {
|
|
202
|
+
id,
|
|
203
|
+
version: project.stamp.version,
|
|
204
|
+
sdk: project.stamp.sdk,
|
|
205
|
+
...rest
|
|
206
|
+
} : {
|
|
207
|
+
...id === void 0 ? {} : { id },
|
|
208
|
+
...rest
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
await writeFile(target, `${JSON.stringify(written, null, 2)}\n`);
|
|
212
|
+
}));
|
|
213
|
+
return copied;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Builds every module the bundle names into the vendor directory.
|
|
217
|
+
*
|
|
218
|
+
* @param project - The project.
|
|
219
|
+
* @param modules - The modules' sources.
|
|
220
|
+
* @returns Once they are written.
|
|
221
|
+
* @throws {IntegrationError} When the code does not build, or imports what it must not.
|
|
222
|
+
*/
|
|
223
|
+
async function buildModules(project, modules) {
|
|
224
|
+
if (modules.length === 0) return;
|
|
225
|
+
try {
|
|
226
|
+
const bundle = await rolldown({
|
|
227
|
+
input: Object.fromEntries(modules.map((file) => [entryNameOf(project, file), file])),
|
|
228
|
+
cwd: project.root,
|
|
229
|
+
platform: "node",
|
|
230
|
+
resolve: { extensionAlias: {
|
|
231
|
+
".js": [".ts", ".js"],
|
|
232
|
+
".mjs": [".mts", ".mjs"]
|
|
233
|
+
} },
|
|
234
|
+
external: isNodeBuiltin,
|
|
235
|
+
plugins: [refusedImports()],
|
|
236
|
+
logLevel: "warn",
|
|
237
|
+
/**
|
|
238
|
+
* Refuses an import nothing resolves, which rolldown would leave an import: an installed
|
|
239
|
+
* bundle has no `node_modules`, so it would fail only once the hub loads it.
|
|
240
|
+
*
|
|
241
|
+
* @param level - How much it matters.
|
|
242
|
+
* @param log - What happened.
|
|
243
|
+
* @param handle - Hands a log on as rolldown would.
|
|
244
|
+
* @throws {Error} For an import nothing resolves.
|
|
245
|
+
*/
|
|
246
|
+
onLog: (level, log, handle) => {
|
|
247
|
+
if (log.code === "UNRESOLVED_IMPORT") {
|
|
248
|
+
const [first = log.message] = log.message.split(/\r?\n/u);
|
|
249
|
+
throw new Error(`${first}: install it - a bundle carries what its code imports`);
|
|
250
|
+
}
|
|
251
|
+
handle(level, log);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
try {
|
|
255
|
+
await bundle.write({
|
|
256
|
+
dir: project.outputDirectory,
|
|
257
|
+
format: "esm",
|
|
258
|
+
entryFileNames: "[name].js",
|
|
259
|
+
chunkFileNames: `${CHUNKS_DIRECTORY}/[name]-[hash].js`,
|
|
260
|
+
sourcemap: false
|
|
261
|
+
});
|
|
262
|
+
} finally {
|
|
263
|
+
await bundle.close();
|
|
264
|
+
}
|
|
265
|
+
} catch (error) {
|
|
266
|
+
throw new IntegrationError([`The code does not build: ${error instanceof Error ? error.message : String(error)}`]);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Loads the build back the way `hub` loads it, its code handed a fake SDK.
|
|
271
|
+
*
|
|
272
|
+
* @param project - The project.
|
|
273
|
+
* @returns Once it loaded.
|
|
274
|
+
* @throws {IntegrationError} When it does not, every driver included.
|
|
275
|
+
*/
|
|
276
|
+
async function loadBack(project) {
|
|
277
|
+
const fake = createFakeSdk();
|
|
278
|
+
try {
|
|
279
|
+
const declaration = await readVendorDirectory(project.outputDirectory, {
|
|
280
|
+
expectedId: project.vendorId,
|
|
281
|
+
runtimeVersion: runtimeVersion()
|
|
282
|
+
});
|
|
283
|
+
const { vendor, failures } = await instantiateVendor(declaration, {
|
|
284
|
+
sdk: fake.sdk,
|
|
285
|
+
release: fake.release,
|
|
286
|
+
/**
|
|
287
|
+
* Imports a module of the build.
|
|
288
|
+
*
|
|
289
|
+
* @param file - The module.
|
|
290
|
+
* @returns The module.
|
|
291
|
+
*/
|
|
292
|
+
importModule: async (file) => import(pathToFileURL(file).href)
|
|
293
|
+
});
|
|
294
|
+
await vendor?.release();
|
|
295
|
+
if (vendor === null || failures.length > 0) throw new IntegrationError(failures.map((failure) => `dist: ${failure.message}`));
|
|
296
|
+
} catch (error) {
|
|
297
|
+
if (error instanceof IntegrationError) throw error;
|
|
298
|
+
throw new IntegrationError([`The build does not load: ${error instanceof Error ? error.message : String(error)}`]);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Checks the sources and builds them into `dist/<vendor>/`.
|
|
303
|
+
*
|
|
304
|
+
* @param options - Where the repository is.
|
|
305
|
+
* @param options.root - Its folder.
|
|
306
|
+
* @returns What was written.
|
|
307
|
+
* @throws {IntegrationError} With every problem found.
|
|
308
|
+
*/
|
|
309
|
+
async function buildIntegration(options) {
|
|
310
|
+
const { project, declaration } = await checkIntegration(options);
|
|
311
|
+
const modules = modulesOf(declaration);
|
|
312
|
+
await rm(project.outputRoot, {
|
|
313
|
+
recursive: true,
|
|
314
|
+
force: true
|
|
315
|
+
});
|
|
316
|
+
const files = await copyFiles(project);
|
|
317
|
+
await buildModules(project, modules);
|
|
318
|
+
await loadBack(project);
|
|
319
|
+
return {
|
|
320
|
+
project,
|
|
321
|
+
outputDirectory: project.outputDirectory,
|
|
322
|
+
files,
|
|
323
|
+
modules: modules.length
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region ../../node_modules/.pnpm/tar@7.5.22/node_modules/tar/dist/esm/index.min.js
|
|
328
|
+
var zr = Object.defineProperty;
|
|
329
|
+
var Ur = (s, t) => {
|
|
330
|
+
for (var e in t) zr(s, e, {
|
|
331
|
+
get: t[e],
|
|
332
|
+
enumerable: !0
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
var Ds = typeof process == "object" && process ? process : {
|
|
336
|
+
stdout: null,
|
|
337
|
+
stderr: null
|
|
338
|
+
};
|
|
339
|
+
var Wr = (s) => !!s && typeof s == "object" && (s instanceof A || s instanceof Cs || Gr(s) || Zr(s));
|
|
340
|
+
var Gr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter$1 && typeof s.pipe == "function" && s.pipe !== Cs.Writable.prototype.pipe;
|
|
341
|
+
var Zr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter$1 && typeof s.write == "function" && typeof s.end == "function";
|
|
342
|
+
var Q = Symbol("EOF");
|
|
343
|
+
var J = Symbol("maybeEmitEnd");
|
|
344
|
+
var nt = Symbol("emittedEnd");
|
|
345
|
+
var De = Symbol("emittingEnd");
|
|
346
|
+
var qt = Symbol("emittedError");
|
|
347
|
+
var Ne = Symbol("closed");
|
|
348
|
+
var Ns = Symbol("read");
|
|
349
|
+
var Ae = Symbol("flush");
|
|
350
|
+
var As = Symbol("flushChunk");
|
|
351
|
+
var z = Symbol("encoding");
|
|
352
|
+
var Mt = Symbol("decoder");
|
|
353
|
+
var g = Symbol("flowing");
|
|
354
|
+
var Qt = Symbol("paused");
|
|
355
|
+
var Bt = Symbol("resume");
|
|
356
|
+
var b = Symbol("buffer");
|
|
357
|
+
var N = Symbol("pipes");
|
|
358
|
+
var _ = Symbol("bufferLength");
|
|
359
|
+
var bi = Symbol("bufferPush");
|
|
360
|
+
var Ie = Symbol("bufferShift");
|
|
361
|
+
var L = Symbol("objectMode");
|
|
362
|
+
var S = Symbol("destroyed");
|
|
363
|
+
var _i = Symbol("error");
|
|
364
|
+
var Oi = Symbol("emitData");
|
|
365
|
+
var Is = Symbol("emitEnd");
|
|
366
|
+
var Ti = Symbol("emitEnd2");
|
|
367
|
+
var Z = Symbol("async");
|
|
368
|
+
var xi = Symbol("abort");
|
|
369
|
+
var Ce = Symbol("aborted");
|
|
370
|
+
var Jt = Symbol("signal");
|
|
371
|
+
var Rt = Symbol("dataListeners");
|
|
372
|
+
var C = Symbol("discarded");
|
|
373
|
+
var jt = (s) => Promise.resolve().then(s);
|
|
374
|
+
var Yr = (s) => s();
|
|
375
|
+
var Kr = (s) => s === "end" || s === "finish" || s === "prefinish";
|
|
376
|
+
var Vr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0;
|
|
377
|
+
var $r = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s);
|
|
378
|
+
var Fe = class {
|
|
379
|
+
src;
|
|
380
|
+
dest;
|
|
381
|
+
opts;
|
|
382
|
+
ondrain;
|
|
383
|
+
constructor(t, e, i) {
|
|
384
|
+
this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
|
|
385
|
+
}
|
|
386
|
+
unpipe() {
|
|
387
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
388
|
+
}
|
|
389
|
+
proxyErrors(t) {}
|
|
390
|
+
end() {
|
|
391
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
var Li = class extends Fe {
|
|
395
|
+
unpipe() {
|
|
396
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
397
|
+
}
|
|
398
|
+
constructor(t, e, i) {
|
|
399
|
+
super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
var Xr = (s) => !!s.objectMode;
|
|
403
|
+
var qr = (s) => !s.objectMode && !!s.encoding && s.encoding !== "buffer";
|
|
404
|
+
var A = class extends EventEmitter$1 {
|
|
405
|
+
[g] = !1;
|
|
406
|
+
[Qt] = !1;
|
|
407
|
+
[N] = [];
|
|
408
|
+
[b] = [];
|
|
409
|
+
[L];
|
|
410
|
+
[z];
|
|
411
|
+
[Z];
|
|
412
|
+
[Mt];
|
|
413
|
+
[Q] = !1;
|
|
414
|
+
[nt] = !1;
|
|
415
|
+
[De] = !1;
|
|
416
|
+
[Ne] = !1;
|
|
417
|
+
[qt] = null;
|
|
418
|
+
[_] = 0;
|
|
419
|
+
[S] = !1;
|
|
420
|
+
[Jt];
|
|
421
|
+
[Ce] = !1;
|
|
422
|
+
[Rt] = 0;
|
|
423
|
+
[C] = !1;
|
|
424
|
+
writable = !0;
|
|
425
|
+
readable = !0;
|
|
426
|
+
constructor(...t) {
|
|
427
|
+
let e = t[0] || {};
|
|
428
|
+
if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
|
|
429
|
+
Xr(e) ? (this[L] = !0, this[z] = null) : qr(e) ? (this[z] = e.encoding, this[L] = !1) : (this[L] = !1, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[b] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[N] });
|
|
430
|
+
let { signal: i } = e;
|
|
431
|
+
i && (this[Jt] = i, i.aborted ? this[xi]() : i.addEventListener("abort", () => this[xi]()));
|
|
432
|
+
}
|
|
433
|
+
get bufferLength() {
|
|
434
|
+
return this[_];
|
|
435
|
+
}
|
|
436
|
+
get encoding() {
|
|
437
|
+
return this[z];
|
|
438
|
+
}
|
|
439
|
+
set encoding(t) {
|
|
440
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
441
|
+
}
|
|
442
|
+
setEncoding(t) {
|
|
443
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
444
|
+
}
|
|
445
|
+
get objectMode() {
|
|
446
|
+
return this[L];
|
|
447
|
+
}
|
|
448
|
+
set objectMode(t) {
|
|
449
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
450
|
+
}
|
|
451
|
+
get async() {
|
|
452
|
+
return this[Z];
|
|
453
|
+
}
|
|
454
|
+
set async(t) {
|
|
455
|
+
this[Z] = this[Z] || !!t;
|
|
456
|
+
}
|
|
457
|
+
[xi]() {
|
|
458
|
+
this[Ce] = !0, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
|
|
459
|
+
}
|
|
460
|
+
get aborted() {
|
|
461
|
+
return this[Ce];
|
|
462
|
+
}
|
|
463
|
+
set aborted(t) {}
|
|
464
|
+
write(t, e, i) {
|
|
465
|
+
if (this[Ce]) return !1;
|
|
466
|
+
if (this[Q]) throw new Error("write after end");
|
|
467
|
+
if (this[S]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
|
|
468
|
+
typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
|
|
469
|
+
let r = this[Z] ? jt : Yr;
|
|
470
|
+
if (!this[L] && !Buffer.isBuffer(t)) {
|
|
471
|
+
if ($r(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
472
|
+
else if (Vr(t)) t = Buffer.from(t);
|
|
473
|
+
else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
474
|
+
}
|
|
475
|
+
return this[L] ? (this[g] && this[_] !== 0 && this[Ae](!0), this[g] ? this.emit("data", t) : this[bi](t), this[_] !== 0 && this.emit("readable"), i && r(i), this[g]) : t.length ? (typeof t == "string" && (e !== this[z] || this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[g] && this[_] !== 0 && this[Ae](!0), this[g] ? this.emit("data", t) : this[bi](t), this[_] !== 0 && this.emit("readable"), i && r(i), this[g]) : (this[_] !== 0 && this.emit("readable"), i && r(i), this[g]);
|
|
476
|
+
}
|
|
477
|
+
read(t) {
|
|
478
|
+
if (this[S]) return null;
|
|
479
|
+
if (this[C] = !1, this[_] === 0 || t === 0 || t && t > this[_]) return this[J](), null;
|
|
480
|
+
this[L] && (t = null), this[b].length > 1 && !this[L] && (this[b] = [this[z] ? this[b].join("") : Buffer.concat(this[b], this[_])]);
|
|
481
|
+
let e = this[Ns](t || null, this[b][0]);
|
|
482
|
+
return this[J](), e;
|
|
483
|
+
}
|
|
484
|
+
[Ns](t, e) {
|
|
485
|
+
if (this[L]) this[Ie]();
|
|
486
|
+
else {
|
|
487
|
+
let i = e;
|
|
488
|
+
t === i.length || t === null ? this[Ie]() : typeof i == "string" ? (this[b][0] = i.slice(t), e = i.slice(0, t), this[_] -= t) : (this[b][0] = i.subarray(t), e = i.subarray(0, t), this[_] -= t);
|
|
489
|
+
}
|
|
490
|
+
return this.emit("data", e), !this[b].length && !this[Q] && this.emit("drain"), e;
|
|
491
|
+
}
|
|
492
|
+
end(t, e, i) {
|
|
493
|
+
return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = "utf8"), t !== void 0 && this.write(t, e), i && this.once("end", i), this[Q] = !0, this.writable = !1, (this[g] || !this[Qt]) && this[J](), this;
|
|
494
|
+
}
|
|
495
|
+
[Bt]() {
|
|
496
|
+
this[S] || (!this[Rt] && !this[N].length && (this[C] = !0), this[Qt] = !1, this[g] = !0, this.emit("resume"), this[b].length ? this[Ae]() : this[Q] ? this[J]() : this.emit("drain"));
|
|
497
|
+
}
|
|
498
|
+
resume() {
|
|
499
|
+
return this[Bt]();
|
|
500
|
+
}
|
|
501
|
+
pause() {
|
|
502
|
+
this[g] = !1, this[Qt] = !0, this[C] = !1;
|
|
503
|
+
}
|
|
504
|
+
get destroyed() {
|
|
505
|
+
return this[S];
|
|
506
|
+
}
|
|
507
|
+
get flowing() {
|
|
508
|
+
return this[g];
|
|
509
|
+
}
|
|
510
|
+
get paused() {
|
|
511
|
+
return this[Qt];
|
|
512
|
+
}
|
|
513
|
+
[bi](t) {
|
|
514
|
+
this[L] ? this[_] += 1 : this[_] += t.length, this[b].push(t);
|
|
515
|
+
}
|
|
516
|
+
[Ie]() {
|
|
517
|
+
return this[L] ? this[_] -= 1 : this[_] -= this[b][0].length, this[b].shift();
|
|
518
|
+
}
|
|
519
|
+
[Ae](t = !1) {
|
|
520
|
+
do ;
|
|
521
|
+
while (this[As](this[Ie]()) && this[b].length);
|
|
522
|
+
!t && !this[b].length && !this[Q] && this.emit("drain");
|
|
523
|
+
}
|
|
524
|
+
[As](t) {
|
|
525
|
+
return this.emit("data", t), this[g];
|
|
526
|
+
}
|
|
527
|
+
pipe(t, e) {
|
|
528
|
+
if (this[S]) return t;
|
|
529
|
+
this[C] = !1;
|
|
530
|
+
let i = this[nt];
|
|
531
|
+
return e = e || {}, t === Ds.stdout || t === Ds.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[N].push(e.proxyErrors ? new Li(this, t, e) : new Fe(this, t, e)), this[Z] ? jt(() => this[Bt]()) : this[Bt]()), t;
|
|
532
|
+
}
|
|
533
|
+
unpipe(t) {
|
|
534
|
+
let e = this[N].find((i) => i.dest === t);
|
|
535
|
+
e && (this[N].length === 1 ? (this[g] && this[Rt] === 0 && (this[g] = !1), this[N] = []) : this[N].splice(this[N].indexOf(e), 1), e.unpipe());
|
|
536
|
+
}
|
|
537
|
+
addListener(t, e) {
|
|
538
|
+
return this.on(t, e);
|
|
539
|
+
}
|
|
540
|
+
on(t, e) {
|
|
541
|
+
let i = super.on(t, e);
|
|
542
|
+
if (t === "data") this[C] = !1, this[Rt]++, !this[N].length && !this[g] && this[Bt]();
|
|
543
|
+
else if (t === "readable" && this[_] !== 0) super.emit("readable");
|
|
544
|
+
else if (Kr(t) && this[nt]) super.emit(t), this.removeAllListeners(t);
|
|
545
|
+
else if (t === "error" && this[qt]) {
|
|
546
|
+
let r = e;
|
|
547
|
+
this[Z] ? jt(() => r.call(this, this[qt])) : r.call(this, this[qt]);
|
|
548
|
+
}
|
|
549
|
+
return i;
|
|
550
|
+
}
|
|
551
|
+
removeListener(t, e) {
|
|
552
|
+
return this.off(t, e);
|
|
553
|
+
}
|
|
554
|
+
off(t, e) {
|
|
555
|
+
let i = super.off(t, e);
|
|
556
|
+
return t === "data" && (this[Rt] = this.listeners("data").length, this[Rt] === 0 && !this[C] && !this[N].length && (this[g] = !1)), i;
|
|
557
|
+
}
|
|
558
|
+
removeAllListeners(t) {
|
|
559
|
+
let e = super.removeAllListeners(t);
|
|
560
|
+
return (t === "data" || t === void 0) && (this[Rt] = 0, !this[C] && !this[N].length && (this[g] = !1)), e;
|
|
561
|
+
}
|
|
562
|
+
get emittedEnd() {
|
|
563
|
+
return this[nt];
|
|
564
|
+
}
|
|
565
|
+
[J]() {
|
|
566
|
+
!this[De] && !this[nt] && !this[S] && this[b].length === 0 && this[Q] && (this[De] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[De] = !1);
|
|
567
|
+
}
|
|
568
|
+
emit(t, ...e) {
|
|
569
|
+
let i = e[0];
|
|
570
|
+
if (t !== "error" && t !== "close" && t !== S && this[S]) return !1;
|
|
571
|
+
if (t === "data") return !this[L] && !i ? !1 : this[Z] ? (jt(() => this[Oi](i)), !0) : this[Oi](i);
|
|
572
|
+
if (t === "end") return this[Is]();
|
|
573
|
+
if (t === "close") {
|
|
574
|
+
if (this[Ne] = !0, !this[nt] && !this[S]) return !1;
|
|
575
|
+
let n = super.emit("close");
|
|
576
|
+
return this.removeAllListeners("close"), n;
|
|
577
|
+
} else if (t === "error") {
|
|
578
|
+
this[qt] = i, super.emit(_i, i);
|
|
579
|
+
let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : !1;
|
|
580
|
+
return this[J](), n;
|
|
581
|
+
} else if (t === "resume") {
|
|
582
|
+
let n = super.emit("resume");
|
|
583
|
+
return this[J](), n;
|
|
584
|
+
} else if (t === "finish" || t === "prefinish") {
|
|
585
|
+
let n = super.emit(t);
|
|
586
|
+
return this.removeAllListeners(t), n;
|
|
587
|
+
}
|
|
588
|
+
let r = super.emit(t, ...e);
|
|
589
|
+
return this[J](), r;
|
|
590
|
+
}
|
|
591
|
+
[Oi](t) {
|
|
592
|
+
for (let i of this[N]) i.dest.write(t) === !1 && this.pause();
|
|
593
|
+
let e = this[C] ? !1 : super.emit("data", t);
|
|
594
|
+
return this[J](), e;
|
|
595
|
+
}
|
|
596
|
+
[Is]() {
|
|
597
|
+
return this[nt] ? !1 : (this[nt] = !0, this.readable = !1, this[Z] ? (jt(() => this[Ti]()), !0) : this[Ti]());
|
|
598
|
+
}
|
|
599
|
+
[Ti]() {
|
|
600
|
+
if (this[Mt]) {
|
|
601
|
+
let e = this[Mt].end();
|
|
602
|
+
if (e) {
|
|
603
|
+
for (let i of this[N]) i.dest.write(e);
|
|
604
|
+
this[C] || super.emit("data", e);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
for (let e of this[N]) e.end();
|
|
608
|
+
let t = super.emit("end");
|
|
609
|
+
return this.removeAllListeners("end"), t;
|
|
610
|
+
}
|
|
611
|
+
async collect() {
|
|
612
|
+
let t = Object.assign([], { dataLength: 0 });
|
|
613
|
+
this[L] || (t.dataLength = 0);
|
|
614
|
+
let e = this.promise();
|
|
615
|
+
return this.on("data", (i) => {
|
|
616
|
+
t.push(i), this[L] || (t.dataLength += i.length);
|
|
617
|
+
}), await e, t;
|
|
618
|
+
}
|
|
619
|
+
async concat() {
|
|
620
|
+
if (this[L]) throw new Error("cannot concat in objectMode");
|
|
621
|
+
let t = await this.collect();
|
|
622
|
+
return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
623
|
+
}
|
|
624
|
+
async promise() {
|
|
625
|
+
return new Promise((t, e) => {
|
|
626
|
+
this.on(S, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
[Symbol.asyncIterator]() {
|
|
630
|
+
this[C] = !1;
|
|
631
|
+
let t = !1, e = async () => (this.pause(), t = !0, {
|
|
632
|
+
value: void 0,
|
|
633
|
+
done: !0
|
|
634
|
+
});
|
|
635
|
+
return {
|
|
636
|
+
next: () => {
|
|
637
|
+
if (t) return e();
|
|
638
|
+
let r = this.read();
|
|
639
|
+
if (r !== null) return Promise.resolve({
|
|
640
|
+
done: !1,
|
|
641
|
+
value: r
|
|
642
|
+
});
|
|
643
|
+
if (this[Q]) return e();
|
|
644
|
+
let n, o, h = (d) => {
|
|
645
|
+
this.off("data", a), this.off("end", l), this.off(S, c), e(), o(d);
|
|
646
|
+
}, a = (d) => {
|
|
647
|
+
this.off("error", h), this.off("end", l), this.off(S, c), this.pause(), n({
|
|
648
|
+
value: d,
|
|
649
|
+
done: !!this[Q]
|
|
650
|
+
});
|
|
651
|
+
}, l = () => {
|
|
652
|
+
this.off("error", h), this.off("data", a), this.off(S, c), e(), n({
|
|
653
|
+
done: !0,
|
|
654
|
+
value: void 0
|
|
655
|
+
});
|
|
656
|
+
}, c = () => h(/* @__PURE__ */ new Error("stream destroyed"));
|
|
657
|
+
return new Promise((d, y) => {
|
|
658
|
+
o = y, n = d, this.once(S, c), this.once("error", h), this.once("end", l), this.once("data", a);
|
|
659
|
+
});
|
|
660
|
+
},
|
|
661
|
+
throw: e,
|
|
662
|
+
return: e,
|
|
663
|
+
[Symbol.asyncIterator]() {
|
|
664
|
+
return this;
|
|
665
|
+
},
|
|
666
|
+
[Symbol.asyncDispose]: async () => {}
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
[Symbol.iterator]() {
|
|
670
|
+
this[C] = !1;
|
|
671
|
+
let t = !1, e = () => (this.pause(), this.off(_i, e), this.off(S, e), this.off("end", e), t = !0, {
|
|
672
|
+
done: !0,
|
|
673
|
+
value: void 0
|
|
674
|
+
}), i = () => {
|
|
675
|
+
if (t) return e();
|
|
676
|
+
let r = this.read();
|
|
677
|
+
return r === null ? e() : {
|
|
678
|
+
done: !1,
|
|
679
|
+
value: r
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
return this.once("end", e), this.once(_i, e), this.once(S, e), {
|
|
683
|
+
next: i,
|
|
684
|
+
throw: e,
|
|
685
|
+
return: e,
|
|
686
|
+
[Symbol.iterator]() {
|
|
687
|
+
return this;
|
|
688
|
+
},
|
|
689
|
+
[Symbol.dispose]: () => {}
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
destroy(t) {
|
|
693
|
+
if (this[S]) return t ? this.emit("error", t) : this.emit(S), this;
|
|
694
|
+
this[S] = !0, this[C] = !0, this[b].length = 0, this[_] = 0;
|
|
695
|
+
let e = this;
|
|
696
|
+
return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(S), this;
|
|
697
|
+
}
|
|
698
|
+
static get isStream() {
|
|
699
|
+
return Wr;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var Jr = I.writev;
|
|
703
|
+
var ht = Symbol("_autoClose");
|
|
704
|
+
var H = Symbol("_close");
|
|
705
|
+
var te = Symbol("_ended");
|
|
706
|
+
var m = Symbol("_fd");
|
|
707
|
+
var Ni = Symbol("_finished");
|
|
708
|
+
var tt = Symbol("_flags");
|
|
709
|
+
var Ai = Symbol("_flush");
|
|
710
|
+
var ki = Symbol("_handleChunk");
|
|
711
|
+
var vi = Symbol("_makeBuf");
|
|
712
|
+
var ie = Symbol("_mode");
|
|
713
|
+
var ke = Symbol("_needDrain");
|
|
714
|
+
var Ut = Symbol("_onerror");
|
|
715
|
+
var Ht = Symbol("_onopen");
|
|
716
|
+
var Ii = Symbol("_onread");
|
|
717
|
+
var Pt = Symbol("_onwrite");
|
|
718
|
+
var at = Symbol("_open");
|
|
719
|
+
var U = Symbol("_path");
|
|
720
|
+
var ot = Symbol("_pos");
|
|
721
|
+
var Y = Symbol("_queue");
|
|
722
|
+
var zt = Symbol("_read");
|
|
723
|
+
var Ci = Symbol("_readSize");
|
|
724
|
+
var j = Symbol("_reading");
|
|
725
|
+
var ee = Symbol("_remain");
|
|
726
|
+
var Fi = Symbol("_size");
|
|
727
|
+
var ve = Symbol("_write");
|
|
728
|
+
var gt = Symbol("_writing");
|
|
729
|
+
var Me = Symbol("_defaultFlag");
|
|
730
|
+
var bt = Symbol("_errored");
|
|
731
|
+
var _t = class extends A {
|
|
732
|
+
[bt] = !1;
|
|
733
|
+
[m];
|
|
734
|
+
[U];
|
|
735
|
+
[Ci];
|
|
736
|
+
[j] = !1;
|
|
737
|
+
[Fi];
|
|
738
|
+
[ee];
|
|
739
|
+
[ht];
|
|
740
|
+
constructor(t, e) {
|
|
741
|
+
if (e = e || {}, super(e), this.readable = !0, this.writable = !1, typeof t != "string") throw new TypeError("path must be a string");
|
|
742
|
+
this[bt] = !1, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ci] = e.readSize || 16777216, this[j] = !1, this[Fi] = typeof e.size == "number" ? e.size : 1 / 0, this[ee] = this[Fi], this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : !0, typeof this[m] == "number" ? this[zt]() : this[at]();
|
|
743
|
+
}
|
|
744
|
+
get fd() {
|
|
745
|
+
return this[m];
|
|
746
|
+
}
|
|
747
|
+
get path() {
|
|
748
|
+
return this[U];
|
|
749
|
+
}
|
|
750
|
+
write() {
|
|
751
|
+
throw new TypeError("this is a readable stream");
|
|
752
|
+
}
|
|
753
|
+
end() {
|
|
754
|
+
throw new TypeError("this is a readable stream");
|
|
755
|
+
}
|
|
756
|
+
[at]() {
|
|
757
|
+
I.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
758
|
+
}
|
|
759
|
+
[Ht](t, e) {
|
|
760
|
+
t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
|
|
761
|
+
}
|
|
762
|
+
[vi]() {
|
|
763
|
+
return Buffer.allocUnsafe(Math.min(this[Ci], this[ee]));
|
|
764
|
+
}
|
|
765
|
+
[zt]() {
|
|
766
|
+
if (!this[j]) {
|
|
767
|
+
this[j] = !0;
|
|
768
|
+
let t = this[vi]();
|
|
769
|
+
if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
|
|
770
|
+
I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
[Ii](t, e, i) {
|
|
774
|
+
this[j] = !1, t ? this[Ut](t) : this[ki](e, i) && this[zt]();
|
|
775
|
+
}
|
|
776
|
+
[H]() {
|
|
777
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
778
|
+
let t = this[m];
|
|
779
|
+
this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
[Ut](t) {
|
|
783
|
+
this[j] = !0, this[H](), this.emit("error", t);
|
|
784
|
+
}
|
|
785
|
+
[ki](t, e) {
|
|
786
|
+
let i = !1;
|
|
787
|
+
return this[ee] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ee] <= 0) && (i = !1, this[H](), super.end()), i;
|
|
788
|
+
}
|
|
789
|
+
emit(t, ...e) {
|
|
790
|
+
switch (t) {
|
|
791
|
+
case "prefinish":
|
|
792
|
+
case "finish": return !1;
|
|
793
|
+
case "drain": return typeof this[m] == "number" && this[zt](), !1;
|
|
794
|
+
case "error": return this[bt] ? !1 : (this[bt] = !0, super.emit(t, ...e));
|
|
795
|
+
default: return super.emit(t, ...e);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
var Be = class extends _t {
|
|
800
|
+
[at]() {
|
|
801
|
+
let t = !0;
|
|
802
|
+
try {
|
|
803
|
+
this[Ht](null, I.openSync(this[U], "r")), t = !1;
|
|
804
|
+
} finally {
|
|
805
|
+
t && this[H]();
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
[zt]() {
|
|
809
|
+
let t = !0;
|
|
810
|
+
try {
|
|
811
|
+
if (!this[j]) {
|
|
812
|
+
this[j] = !0;
|
|
813
|
+
do {
|
|
814
|
+
let e = this[vi](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
|
|
815
|
+
if (!this[ki](i, e)) break;
|
|
816
|
+
} while (!0);
|
|
817
|
+
this[j] = !1;
|
|
818
|
+
}
|
|
819
|
+
t = !1;
|
|
820
|
+
} finally {
|
|
821
|
+
t && this[H]();
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
[H]() {
|
|
825
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
826
|
+
let t = this[m];
|
|
827
|
+
this[m] = void 0, I.closeSync(t), this.emit("close");
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
var et = class extends Qr {
|
|
832
|
+
readable = !1;
|
|
833
|
+
writable = !0;
|
|
834
|
+
[bt] = !1;
|
|
835
|
+
[gt] = !1;
|
|
836
|
+
[te] = !1;
|
|
837
|
+
[Y] = [];
|
|
838
|
+
[ke] = !1;
|
|
839
|
+
[U];
|
|
840
|
+
[ie];
|
|
841
|
+
[ht];
|
|
842
|
+
[m];
|
|
843
|
+
[Me];
|
|
844
|
+
[tt];
|
|
845
|
+
[Ni] = !1;
|
|
846
|
+
[ot];
|
|
847
|
+
constructor(t, e) {
|
|
848
|
+
e = e || {}, super(e), this[U] = t, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[ot] = typeof e.start == "number" ? e.start : void 0, this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : !0;
|
|
849
|
+
let i = this[ot] !== void 0 ? "r+" : "w";
|
|
850
|
+
this[Me] = e.flags === void 0, this[tt] = e.flags === void 0 ? i : e.flags, this[m] === void 0 && this[at]();
|
|
851
|
+
}
|
|
852
|
+
emit(t, ...e) {
|
|
853
|
+
if (t === "error") {
|
|
854
|
+
if (this[bt]) return !1;
|
|
855
|
+
this[bt] = !0;
|
|
856
|
+
}
|
|
857
|
+
return super.emit(t, ...e);
|
|
858
|
+
}
|
|
859
|
+
get fd() {
|
|
860
|
+
return this[m];
|
|
861
|
+
}
|
|
862
|
+
get path() {
|
|
863
|
+
return this[U];
|
|
864
|
+
}
|
|
865
|
+
[Ut](t) {
|
|
866
|
+
this[H](), this[gt] = !0, this.emit("error", t);
|
|
867
|
+
}
|
|
868
|
+
[at]() {
|
|
869
|
+
I.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
|
|
870
|
+
}
|
|
871
|
+
[Ht](t, e) {
|
|
872
|
+
this[Me] && this[tt] === "r+" && t && t.code === "ENOENT" ? (this[tt] = "w", this[at]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[gt] || this[Ai]());
|
|
873
|
+
}
|
|
874
|
+
end(t, e) {
|
|
875
|
+
return t && this.write(t, e), this[te] = !0, !this[gt] && !this[Y].length && typeof this[m] == "number" && this[Pt](null, 0), this;
|
|
876
|
+
}
|
|
877
|
+
write(t, e) {
|
|
878
|
+
return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", /* @__PURE__ */ new Error("write() after end()")), !1) : this[m] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[ke] = !0, !1) : (this[gt] = !0, this[ve](t), !0);
|
|
879
|
+
}
|
|
880
|
+
[ve](t) {
|
|
881
|
+
I.write(this[m], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
|
|
882
|
+
}
|
|
883
|
+
[Pt](t, e) {
|
|
884
|
+
t ? this[Ut](t) : (this[ot] !== void 0 && typeof e == "number" && (this[ot] += e), this[Y].length ? this[Ai]() : (this[gt] = !1, this[te] && !this[Ni] ? (this[Ni] = !0, this[H](), this.emit("finish")) : this[ke] && (this[ke] = !1, this.emit("drain"))));
|
|
885
|
+
}
|
|
886
|
+
[Ai]() {
|
|
887
|
+
if (this[Y].length === 0) this[te] && this[Pt](null, 0);
|
|
888
|
+
else if (this[Y].length === 1) this[ve](this[Y].pop());
|
|
889
|
+
else {
|
|
890
|
+
let t = this[Y];
|
|
891
|
+
this[Y] = [], Jr(this[m], t, this[ot], (e, i) => this[Pt](e, i));
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
[H]() {
|
|
895
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
896
|
+
let t = this[m];
|
|
897
|
+
this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
var Wt = class extends et {
|
|
902
|
+
[at]() {
|
|
903
|
+
let t;
|
|
904
|
+
if (this[Me] && this[tt] === "r+") try {
|
|
905
|
+
t = I.openSync(this[U], this[tt], this[ie]);
|
|
906
|
+
} catch (e) {
|
|
907
|
+
if (e?.code === "ENOENT") return this[tt] = "w", this[at]();
|
|
908
|
+
throw e;
|
|
909
|
+
}
|
|
910
|
+
else t = I.openSync(this[U], this[tt], this[ie]);
|
|
911
|
+
this[Ht](null, t);
|
|
912
|
+
}
|
|
913
|
+
[H]() {
|
|
914
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
915
|
+
let t = this[m];
|
|
916
|
+
this[m] = void 0, I.closeSync(t), this.emit("close");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
[ve](t) {
|
|
920
|
+
let e = !0;
|
|
921
|
+
try {
|
|
922
|
+
this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[ot])), e = !1;
|
|
923
|
+
} finally {
|
|
924
|
+
if (e) try {
|
|
925
|
+
this[H]();
|
|
926
|
+
} catch {}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
var jr = /* @__PURE__ */ new Map([
|
|
931
|
+
["C", "cwd"],
|
|
932
|
+
["f", "file"],
|
|
933
|
+
["z", "gzip"],
|
|
934
|
+
["P", "preservePaths"],
|
|
935
|
+
["U", "unlink"],
|
|
936
|
+
["strip-components", "strip"],
|
|
937
|
+
["stripComponents", "strip"],
|
|
938
|
+
["keep-newer", "newer"],
|
|
939
|
+
["keepNewer", "newer"],
|
|
940
|
+
["keep-newer-files", "newer"],
|
|
941
|
+
["keepNewerFiles", "newer"],
|
|
942
|
+
["k", "keep"],
|
|
943
|
+
["keep-existing", "keep"],
|
|
944
|
+
["keepExisting", "keep"],
|
|
945
|
+
["m", "noMtime"],
|
|
946
|
+
["no-mtime", "noMtime"],
|
|
947
|
+
["p", "preserveOwner"],
|
|
948
|
+
["L", "follow"],
|
|
949
|
+
["h", "follow"],
|
|
950
|
+
["onentry", "onReadEntry"]
|
|
951
|
+
]);
|
|
952
|
+
var Fs = (s) => !!s.sync && !!s.file;
|
|
953
|
+
var ks = (s) => !s.sync && !!s.file;
|
|
954
|
+
var vs = (s) => !!s.sync && !s.file;
|
|
955
|
+
var Ms = (s) => !s.sync && !s.file;
|
|
956
|
+
var Bs = (s) => !!s.file;
|
|
957
|
+
var tn = (s) => {
|
|
958
|
+
return jr.get(s) || s;
|
|
959
|
+
};
|
|
960
|
+
var se = (s = {}) => {
|
|
961
|
+
if (!s) return {};
|
|
962
|
+
let t = {};
|
|
963
|
+
for (let [e, i] of Object.entries(s)) {
|
|
964
|
+
let r = tn(e);
|
|
965
|
+
t[r] = i;
|
|
966
|
+
}
|
|
967
|
+
return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
|
|
968
|
+
};
|
|
969
|
+
var K = (s, t, e, i, r) => Object.assign((n = [], o, h) => {
|
|
970
|
+
Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (h = o, o = void 0), o = o ? Array.from(o) : [];
|
|
971
|
+
let a = se(n);
|
|
972
|
+
if (r?.(a, o), Fs(a)) {
|
|
973
|
+
if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
|
|
974
|
+
return s(a, o);
|
|
975
|
+
} else if (ks(a)) {
|
|
976
|
+
let l = t(a, o);
|
|
977
|
+
return h ? l.then(() => h(), h) : l;
|
|
978
|
+
} else if (vs(a)) {
|
|
979
|
+
if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
|
|
980
|
+
return e(a, o);
|
|
981
|
+
} else if (Ms(a)) {
|
|
982
|
+
if (typeof h == "function") throw new TypeError("callback only supported with file option");
|
|
983
|
+
return i(a, o);
|
|
984
|
+
}
|
|
985
|
+
throw new Error("impossible options??");
|
|
986
|
+
}, {
|
|
987
|
+
syncFile: s,
|
|
988
|
+
asyncFile: t,
|
|
989
|
+
syncNoFile: e,
|
|
990
|
+
asyncNoFile: i,
|
|
991
|
+
validate: r
|
|
992
|
+
});
|
|
993
|
+
var sn = en.constants || { ZLIB_VERNUM: 4736 };
|
|
994
|
+
var M = Object.freeze(Object.assign(Object.create(null), {
|
|
995
|
+
Z_NO_FLUSH: 0,
|
|
996
|
+
Z_PARTIAL_FLUSH: 1,
|
|
997
|
+
Z_SYNC_FLUSH: 2,
|
|
998
|
+
Z_FULL_FLUSH: 3,
|
|
999
|
+
Z_FINISH: 4,
|
|
1000
|
+
Z_BLOCK: 5,
|
|
1001
|
+
Z_OK: 0,
|
|
1002
|
+
Z_STREAM_END: 1,
|
|
1003
|
+
Z_NEED_DICT: 2,
|
|
1004
|
+
Z_ERRNO: -1,
|
|
1005
|
+
Z_STREAM_ERROR: -2,
|
|
1006
|
+
Z_DATA_ERROR: -3,
|
|
1007
|
+
Z_MEM_ERROR: -4,
|
|
1008
|
+
Z_BUF_ERROR: -5,
|
|
1009
|
+
Z_VERSION_ERROR: -6,
|
|
1010
|
+
Z_NO_COMPRESSION: 0,
|
|
1011
|
+
Z_BEST_SPEED: 1,
|
|
1012
|
+
Z_BEST_COMPRESSION: 9,
|
|
1013
|
+
Z_DEFAULT_COMPRESSION: -1,
|
|
1014
|
+
Z_FILTERED: 1,
|
|
1015
|
+
Z_HUFFMAN_ONLY: 2,
|
|
1016
|
+
Z_RLE: 3,
|
|
1017
|
+
Z_FIXED: 4,
|
|
1018
|
+
Z_DEFAULT_STRATEGY: 0,
|
|
1019
|
+
DEFLATE: 1,
|
|
1020
|
+
INFLATE: 2,
|
|
1021
|
+
GZIP: 3,
|
|
1022
|
+
GUNZIP: 4,
|
|
1023
|
+
DEFLATERAW: 5,
|
|
1024
|
+
INFLATERAW: 6,
|
|
1025
|
+
UNZIP: 7,
|
|
1026
|
+
BROTLI_DECODE: 8,
|
|
1027
|
+
BROTLI_ENCODE: 9,
|
|
1028
|
+
Z_MIN_WINDOWBITS: 8,
|
|
1029
|
+
Z_MAX_WINDOWBITS: 15,
|
|
1030
|
+
Z_DEFAULT_WINDOWBITS: 15,
|
|
1031
|
+
Z_MIN_CHUNK: 64,
|
|
1032
|
+
Z_MAX_CHUNK: 1 / 0,
|
|
1033
|
+
Z_DEFAULT_CHUNK: 16384,
|
|
1034
|
+
Z_MIN_MEMLEVEL: 1,
|
|
1035
|
+
Z_MAX_MEMLEVEL: 9,
|
|
1036
|
+
Z_DEFAULT_MEMLEVEL: 8,
|
|
1037
|
+
Z_MIN_LEVEL: -1,
|
|
1038
|
+
Z_MAX_LEVEL: 9,
|
|
1039
|
+
Z_DEFAULT_LEVEL: -1,
|
|
1040
|
+
BROTLI_OPERATION_PROCESS: 0,
|
|
1041
|
+
BROTLI_OPERATION_FLUSH: 1,
|
|
1042
|
+
BROTLI_OPERATION_FINISH: 2,
|
|
1043
|
+
BROTLI_OPERATION_EMIT_METADATA: 3,
|
|
1044
|
+
BROTLI_MODE_GENERIC: 0,
|
|
1045
|
+
BROTLI_MODE_TEXT: 1,
|
|
1046
|
+
BROTLI_MODE_FONT: 2,
|
|
1047
|
+
BROTLI_DEFAULT_MODE: 0,
|
|
1048
|
+
BROTLI_MIN_QUALITY: 0,
|
|
1049
|
+
BROTLI_MAX_QUALITY: 11,
|
|
1050
|
+
BROTLI_DEFAULT_QUALITY: 11,
|
|
1051
|
+
BROTLI_MIN_WINDOW_BITS: 10,
|
|
1052
|
+
BROTLI_MAX_WINDOW_BITS: 24,
|
|
1053
|
+
BROTLI_LARGE_MAX_WINDOW_BITS: 30,
|
|
1054
|
+
BROTLI_DEFAULT_WINDOW: 22,
|
|
1055
|
+
BROTLI_MIN_INPUT_BLOCK_BITS: 16,
|
|
1056
|
+
BROTLI_MAX_INPUT_BLOCK_BITS: 24,
|
|
1057
|
+
BROTLI_PARAM_MODE: 0,
|
|
1058
|
+
BROTLI_PARAM_QUALITY: 1,
|
|
1059
|
+
BROTLI_PARAM_LGWIN: 2,
|
|
1060
|
+
BROTLI_PARAM_LGBLOCK: 3,
|
|
1061
|
+
BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
|
|
1062
|
+
BROTLI_PARAM_SIZE_HINT: 5,
|
|
1063
|
+
BROTLI_PARAM_LARGE_WINDOW: 6,
|
|
1064
|
+
BROTLI_PARAM_NPOSTFIX: 7,
|
|
1065
|
+
BROTLI_PARAM_NDIRECT: 8,
|
|
1066
|
+
BROTLI_DECODER_RESULT_ERROR: 0,
|
|
1067
|
+
BROTLI_DECODER_RESULT_SUCCESS: 1,
|
|
1068
|
+
BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
|
|
1069
|
+
BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
|
|
1070
|
+
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
|
|
1071
|
+
BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
|
|
1072
|
+
BROTLI_DECODER_NO_ERROR: 0,
|
|
1073
|
+
BROTLI_DECODER_SUCCESS: 1,
|
|
1074
|
+
BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
|
|
1075
|
+
BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
|
|
1076
|
+
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
|
|
1077
|
+
BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
|
|
1078
|
+
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
|
|
1079
|
+
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
|
|
1080
|
+
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
|
|
1081
|
+
BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
|
|
1082
|
+
BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
|
|
1083
|
+
BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
|
|
1084
|
+
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
|
|
1085
|
+
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
|
|
1086
|
+
BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
|
|
1087
|
+
BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
|
|
1088
|
+
BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
|
|
1089
|
+
BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
|
|
1090
|
+
BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
|
|
1091
|
+
BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
|
|
1092
|
+
BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
|
|
1093
|
+
BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
|
|
1094
|
+
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
|
|
1095
|
+
BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
|
|
1096
|
+
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
|
|
1097
|
+
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
|
|
1098
|
+
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
|
|
1099
|
+
BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
|
|
1100
|
+
BROTLI_DECODER_ERROR_UNREACHABLE: -31
|
|
1101
|
+
}, sn));
|
|
1102
|
+
var rn = Buffer$1.concat;
|
|
1103
|
+
var zs = Object.getOwnPropertyDescriptor(Buffer$1, "concat");
|
|
1104
|
+
var nn = (s) => s;
|
|
1105
|
+
var Bi = zs?.writable === !0 || zs?.set !== void 0 ? (s) => {
|
|
1106
|
+
Buffer$1.concat = s ? nn : rn;
|
|
1107
|
+
} : (s) => {};
|
|
1108
|
+
var Tt = Symbol("_superWrite");
|
|
1109
|
+
var Gt = class extends Error {
|
|
1110
|
+
code;
|
|
1111
|
+
errno;
|
|
1112
|
+
constructor(t, e) {
|
|
1113
|
+
super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
|
|
1114
|
+
}
|
|
1115
|
+
get name() {
|
|
1116
|
+
return "ZlibError";
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
var Pi = Symbol("flushFlag");
|
|
1120
|
+
var re = class extends A {
|
|
1121
|
+
#t = !1;
|
|
1122
|
+
#i = !1;
|
|
1123
|
+
#s;
|
|
1124
|
+
#n;
|
|
1125
|
+
#r;
|
|
1126
|
+
#e;
|
|
1127
|
+
#o;
|
|
1128
|
+
get sawError() {
|
|
1129
|
+
return this.#t;
|
|
1130
|
+
}
|
|
1131
|
+
get handle() {
|
|
1132
|
+
return this.#e;
|
|
1133
|
+
}
|
|
1134
|
+
get flushFlag() {
|
|
1135
|
+
return this.#s;
|
|
1136
|
+
}
|
|
1137
|
+
constructor(t, e) {
|
|
1138
|
+
if (!t || typeof t != "object") throw new TypeError("invalid options for ZlibBase constructor");
|
|
1139
|
+
if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof Ps[e] != "function") throw new TypeError("Compression method not supported: " + e);
|
|
1140
|
+
try {
|
|
1141
|
+
this.#e = new Ps[e](t);
|
|
1142
|
+
} catch (i) {
|
|
1143
|
+
throw new Gt(i, this.constructor);
|
|
1144
|
+
}
|
|
1145
|
+
this.#o = (i) => {
|
|
1146
|
+
this.#t || (this.#t = !0, this.close(), this.emit("error", i));
|
|
1147
|
+
}, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
|
|
1148
|
+
}
|
|
1149
|
+
close() {
|
|
1150
|
+
this.#e && (this.#e.close(), this.#e = void 0, this.emit("close"));
|
|
1151
|
+
}
|
|
1152
|
+
reset() {
|
|
1153
|
+
if (!this.#t) return zi(this.#e, "zlib binding closed"), this.#e.reset?.();
|
|
1154
|
+
}
|
|
1155
|
+
flush(t) {
|
|
1156
|
+
this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(Buffer$1.alloc(0), { [Pi]: t })));
|
|
1157
|
+
}
|
|
1158
|
+
end(t, e, i) {
|
|
1159
|
+
return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = !0, super.end(i);
|
|
1160
|
+
}
|
|
1161
|
+
get ended() {
|
|
1162
|
+
return this.#i;
|
|
1163
|
+
}
|
|
1164
|
+
[Tt](t) {
|
|
1165
|
+
return super.write(t);
|
|
1166
|
+
}
|
|
1167
|
+
write(t, e, i) {
|
|
1168
|
+
if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = Buffer$1.from(t, e)), this.#t) return;
|
|
1169
|
+
zi(this.#e, "zlib binding closed");
|
|
1170
|
+
let r = this.#e._handle, n = r.close;
|
|
1171
|
+
r.close = () => {};
|
|
1172
|
+
let o = this.#e.close;
|
|
1173
|
+
this.#e.close = () => {}, Bi(!0);
|
|
1174
|
+
let h;
|
|
1175
|
+
try {
|
|
1176
|
+
let l = typeof t[Pi] == "number" ? t[Pi] : this.#s;
|
|
1177
|
+
h = this.#e._processChunk(t, l), Bi(!1);
|
|
1178
|
+
} catch (l) {
|
|
1179
|
+
Bi(!1), this.#o(new Gt(l, this.write));
|
|
1180
|
+
} finally {
|
|
1181
|
+
this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
|
|
1182
|
+
}
|
|
1183
|
+
this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
|
|
1184
|
+
let a;
|
|
1185
|
+
if (h) if (Array.isArray(h) && h.length > 0) {
|
|
1186
|
+
let l = h[0];
|
|
1187
|
+
a = this[Tt](Buffer$1.from(l));
|
|
1188
|
+
for (let c = 1; c < h.length; c++) a = this[Tt](h[c]);
|
|
1189
|
+
} else a = this[Tt](Buffer$1.from(h));
|
|
1190
|
+
return i && i(), a;
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
var Pe = class extends re {
|
|
1194
|
+
#t;
|
|
1195
|
+
#i;
|
|
1196
|
+
constructor(t, e) {
|
|
1197
|
+
t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
|
|
1198
|
+
}
|
|
1199
|
+
params(t, e) {
|
|
1200
|
+
if (!this.sawError) {
|
|
1201
|
+
if (!this.handle) throw new Error("cannot switch params when binding is closed");
|
|
1202
|
+
if (!this.handle.params) throw new Error("not supported in this implementation");
|
|
1203
|
+
if (this.#t !== t || this.#i !== e) {
|
|
1204
|
+
this.flush(M.Z_SYNC_FLUSH), zi(this.handle, "zlib binding closed");
|
|
1205
|
+
let i = this.handle.flush;
|
|
1206
|
+
this.handle.flush = (r, n) => {
|
|
1207
|
+
typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
|
|
1208
|
+
};
|
|
1209
|
+
try {
|
|
1210
|
+
this.handle.params(t, e);
|
|
1211
|
+
} finally {
|
|
1212
|
+
this.handle.flush = i;
|
|
1213
|
+
}
|
|
1214
|
+
this.handle && (this.#t = t, this.#i = e);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
var ze = class extends Pe {
|
|
1220
|
+
#t;
|
|
1221
|
+
constructor(t) {
|
|
1222
|
+
super(t, "Gzip"), this.#t = t && !!t.portable;
|
|
1223
|
+
}
|
|
1224
|
+
[Tt](t) {
|
|
1225
|
+
return this.#t ? (this.#t = !1, t[9] = 255, super[Tt](t)) : super[Tt](t);
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
var Ue = class extends Pe {
|
|
1229
|
+
constructor(t) {
|
|
1230
|
+
super(t, "Unzip");
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
var He = class extends re {
|
|
1234
|
+
constructor(t, e) {
|
|
1235
|
+
t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
var We = class extends He {
|
|
1239
|
+
constructor(t) {
|
|
1240
|
+
super(t, "BrotliCompress");
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
var Ge = class extends He {
|
|
1244
|
+
constructor(t) {
|
|
1245
|
+
super(t, "BrotliDecompress");
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
var Ze = class extends re {
|
|
1249
|
+
constructor(t, e) {
|
|
1250
|
+
t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
var Ye = class extends Ze {
|
|
1254
|
+
constructor(t) {
|
|
1255
|
+
super(t, "ZstdCompress");
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
var Ke = class extends Ze {
|
|
1259
|
+
constructor(t) {
|
|
1260
|
+
super(t, "ZstdDecompress");
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
var Us = (s, t) => {
|
|
1264
|
+
if (Number.isSafeInteger(s)) s < 0 ? an(s, t) : hn(s, t);
|
|
1265
|
+
else throw Error("cannot encode number outside of javascript safe integer range");
|
|
1266
|
+
return t;
|
|
1267
|
+
};
|
|
1268
|
+
var hn = (s, t) => {
|
|
1269
|
+
t[0] = 128;
|
|
1270
|
+
for (var e = t.length; e > 1; e--) t[e - 1] = s & 255, s = Math.floor(s / 256);
|
|
1271
|
+
};
|
|
1272
|
+
var an = (s, t) => {
|
|
1273
|
+
t[0] = 255;
|
|
1274
|
+
var e = !1;
|
|
1275
|
+
s = s * -1;
|
|
1276
|
+
for (var i = t.length; i > 1; i--) {
|
|
1277
|
+
var r = s & 255;
|
|
1278
|
+
s = Math.floor(s / 256), e ? t[i - 1] = Ws(r) : r === 0 ? t[i - 1] = 0 : (e = !0, t[i - 1] = Gs(r));
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
var Hs = (s) => {
|
|
1282
|
+
let t = s[0], e = t === 128 ? cn(s.subarray(1, s.length)) : t === 255 ? ln(s) : null;
|
|
1283
|
+
if (e === null) throw Error("invalid base256 encoding");
|
|
1284
|
+
if (!Number.isSafeInteger(e)) throw Error("parsed number outside of javascript safe integer range");
|
|
1285
|
+
return e;
|
|
1286
|
+
};
|
|
1287
|
+
var ln = (s) => {
|
|
1288
|
+
for (var t = s.length, e = 0, i = !1, r = t - 1; r > -1; r--) {
|
|
1289
|
+
var n = Number(s[r]), o;
|
|
1290
|
+
i ? o = Ws(n) : n === 0 ? o = n : (i = !0, o = Gs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
|
|
1291
|
+
}
|
|
1292
|
+
return e;
|
|
1293
|
+
};
|
|
1294
|
+
var cn = (s) => {
|
|
1295
|
+
for (var t = s.length, e = 0, i = t - 1; i > -1; i--) {
|
|
1296
|
+
var r = Number(s[i]);
|
|
1297
|
+
r !== 0 && (e += r * Math.pow(256, t - i - 1));
|
|
1298
|
+
}
|
|
1299
|
+
return e;
|
|
1300
|
+
};
|
|
1301
|
+
var Ws = (s) => (255 ^ s) & 255;
|
|
1302
|
+
var Gs = (s) => (255 ^ s) + 1 & 255;
|
|
1303
|
+
Ur({}, {
|
|
1304
|
+
code: () => Ve,
|
|
1305
|
+
isCode: () => ne,
|
|
1306
|
+
isName: () => dn,
|
|
1307
|
+
name: () => oe,
|
|
1308
|
+
normalFsTypes: () => Ui
|
|
1309
|
+
});
|
|
1310
|
+
var ne = (s) => oe.has(s);
|
|
1311
|
+
var dn = (s) => Ve.has(s);
|
|
1312
|
+
var Ui = /* @__PURE__ */ new Set([
|
|
1313
|
+
"0",
|
|
1314
|
+
"",
|
|
1315
|
+
"1",
|
|
1316
|
+
"2",
|
|
1317
|
+
"3",
|
|
1318
|
+
"4",
|
|
1319
|
+
"5",
|
|
1320
|
+
"6",
|
|
1321
|
+
"7",
|
|
1322
|
+
"D"
|
|
1323
|
+
]);
|
|
1324
|
+
var oe = /* @__PURE__ */ new Map([
|
|
1325
|
+
["0", "File"],
|
|
1326
|
+
["", "OldFile"],
|
|
1327
|
+
["1", "Link"],
|
|
1328
|
+
["2", "SymbolicLink"],
|
|
1329
|
+
["3", "CharacterDevice"],
|
|
1330
|
+
["4", "BlockDevice"],
|
|
1331
|
+
["5", "Directory"],
|
|
1332
|
+
["6", "FIFO"],
|
|
1333
|
+
["7", "ContiguousFile"],
|
|
1334
|
+
["g", "GlobalExtendedHeader"],
|
|
1335
|
+
["x", "ExtendedHeader"],
|
|
1336
|
+
["A", "SolarisACL"],
|
|
1337
|
+
["D", "GNUDumpDir"],
|
|
1338
|
+
["I", "Inode"],
|
|
1339
|
+
["K", "NextFileHasLongLinkpath"],
|
|
1340
|
+
["L", "NextFileHasLongPath"],
|
|
1341
|
+
["M", "ContinuationFile"],
|
|
1342
|
+
["N", "OldGnuLongPath"],
|
|
1343
|
+
["S", "SparseFile"],
|
|
1344
|
+
["V", "TapeVolumeHeader"],
|
|
1345
|
+
["X", "OldExtendedHeader"]
|
|
1346
|
+
]);
|
|
1347
|
+
var Ve = new Map(Array.from(oe).map((s) => [s[1], s[0]]));
|
|
1348
|
+
var un = (s) => s === void 0 || s < 0 ? void 0 : s;
|
|
1349
|
+
var F = class {
|
|
1350
|
+
cksumValid = !1;
|
|
1351
|
+
needPax = !1;
|
|
1352
|
+
nullBlock = !1;
|
|
1353
|
+
block;
|
|
1354
|
+
path;
|
|
1355
|
+
mode;
|
|
1356
|
+
uid;
|
|
1357
|
+
gid;
|
|
1358
|
+
size;
|
|
1359
|
+
cksum;
|
|
1360
|
+
#t = "Unsupported";
|
|
1361
|
+
linkpath;
|
|
1362
|
+
uname;
|
|
1363
|
+
gname;
|
|
1364
|
+
devmaj = 0;
|
|
1365
|
+
devmin = 0;
|
|
1366
|
+
atime;
|
|
1367
|
+
ctime;
|
|
1368
|
+
mtime;
|
|
1369
|
+
charset;
|
|
1370
|
+
comment;
|
|
1371
|
+
constructor(t, e = 0, i, r) {
|
|
1372
|
+
Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
|
|
1373
|
+
}
|
|
1374
|
+
decode(t, e, i, r) {
|
|
1375
|
+
if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
|
|
1376
|
+
let n = xt(t, e + 156, 1), o = Ui.has(n), h = o ? i : void 0, a = o ? r : void 0;
|
|
1377
|
+
if (this.path = h?.path ?? xt(t, e, 100), this.mode = h?.mode ?? a?.mode ?? lt(t, e + 100, 8), this.uid = h?.uid ?? a?.uid ?? lt(t, e + 108, 8), this.gid = h?.gid ?? a?.gid ?? lt(t, e + 116, 8), this.size = un(h?.size ?? a?.size ?? lt(t, e + 124, 12)), this.mtime = h?.mtime ?? a?.mtime ?? Wi(t, e + 136, 12), this.cksum = lt(t, e + 148, 12), a && this.#i(a, !0), h && this.#i(h), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = h?.uname ?? a?.uname ?? xt(t, e + 265, 32), this.gname = h?.gname ?? a?.gname ?? xt(t, e + 297, 32), this.devmaj = h?.devmaj ?? a?.devmaj ?? lt(t, e + 329, 8) ?? 0, this.devmin = h?.devmin ?? a?.devmin ?? lt(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
|
|
1378
|
+
let c = xt(t, e + 345, 155);
|
|
1379
|
+
this.path = c + "/" + this.path;
|
|
1380
|
+
} else {
|
|
1381
|
+
let c = xt(t, e + 345, 130);
|
|
1382
|
+
c && (this.path = c + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Wi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Wi(t, e + 488, 12);
|
|
1383
|
+
}
|
|
1384
|
+
let l = 256;
|
|
1385
|
+
for (let c = e; c < e + 148; c++) l += t[c];
|
|
1386
|
+
for (let c = e + 156; c < e + 512; c++) l += t[c];
|
|
1387
|
+
this.cksumValid = l === this.cksum, this.cksum === void 0 && l === 256 && (this.nullBlock = !0);
|
|
1388
|
+
}
|
|
1389
|
+
#i(t, e = !1) {
|
|
1390
|
+
Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "size" && Number(r) < 0 || i === "path" && e || i === "linkpath" && e || i === "global"))));
|
|
1391
|
+
}
|
|
1392
|
+
encode(t, e = 0) {
|
|
1393
|
+
if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
|
|
1394
|
+
let i = this.ctime || this.atime ? 130 : 155, r = mn(this.path || "", i), n = r[0], o = r[1];
|
|
1395
|
+
this.needPax = !!r[2], this.needPax = Lt(t, e, 100, n) || this.needPax, this.needPax = ct(t, e + 100, 8, this.mode) || this.needPax, this.needPax = ct(t, e + 108, 8, this.uid) || this.needPax, this.needPax = ct(t, e + 116, 8, this.gid) || this.needPax, this.needPax = ct(t, e + 124, 12, this.size) || this.needPax, this.needPax = Gi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = Lt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = Lt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = Lt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = ct(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = ct(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = Lt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = Lt(t, e + 345, 155, o) || this.needPax : (this.needPax = Lt(t, e + 345, 130, o) || this.needPax, this.needPax = Gi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = Gi(t, e + 488, 12, this.ctime) || this.needPax);
|
|
1396
|
+
let h = 256;
|
|
1397
|
+
for (let a = e; a < e + 148; a++) h += t[a];
|
|
1398
|
+
for (let a = e + 156; a < e + 512; a++) h += t[a];
|
|
1399
|
+
return this.cksum = h, ct(t, e + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
|
|
1400
|
+
}
|
|
1401
|
+
get type() {
|
|
1402
|
+
return this.#t === "Unsupported" ? this.#t : oe.get(this.#t);
|
|
1403
|
+
}
|
|
1404
|
+
get typeKey() {
|
|
1405
|
+
return this.#t;
|
|
1406
|
+
}
|
|
1407
|
+
set type(t) {
|
|
1408
|
+
let e = String(Ve.get(t));
|
|
1409
|
+
if (ne(e) || e === "Unsupported") this.#t = e;
|
|
1410
|
+
else if (ne(t)) this.#t = t;
|
|
1411
|
+
else throw new TypeError("invalid entry type: " + t);
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
var mn = (s, t) => {
|
|
1415
|
+
let i = s, r = "", n, o = posix.parse(s).root || ".";
|
|
1416
|
+
if (Buffer.byteLength(i) < 100) n = [
|
|
1417
|
+
i,
|
|
1418
|
+
r,
|
|
1419
|
+
!1
|
|
1420
|
+
];
|
|
1421
|
+
else {
|
|
1422
|
+
r = posix.dirname(i), i = posix.basename(i);
|
|
1423
|
+
do
|
|
1424
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [
|
|
1425
|
+
i,
|
|
1426
|
+
r,
|
|
1427
|
+
!1
|
|
1428
|
+
] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [
|
|
1429
|
+
i.slice(0, 99),
|
|
1430
|
+
r,
|
|
1431
|
+
!0
|
|
1432
|
+
] : (i = posix.join(posix.basename(r), i), r = posix.dirname(r));
|
|
1433
|
+
while (r !== o && n === void 0);
|
|
1434
|
+
n || (n = [
|
|
1435
|
+
s.slice(0, 99),
|
|
1436
|
+
"",
|
|
1437
|
+
!0
|
|
1438
|
+
]);
|
|
1439
|
+
}
|
|
1440
|
+
return n;
|
|
1441
|
+
};
|
|
1442
|
+
var xt = (s, t, e) => s.subarray(t, t + e).toString("utf8").replace(/\0.*/, "");
|
|
1443
|
+
var Wi = (s, t, e) => pn(lt(s, t, e));
|
|
1444
|
+
var pn = (s) => s === void 0 ? void 0 : /* @__PURE__ */ new Date(s * 1e3);
|
|
1445
|
+
var lt = (s, t, e) => Number(s[t]) & 128 ? Hs(s.subarray(t, t + e)) : wn(s, t, e);
|
|
1446
|
+
var En = (s) => isNaN(s) ? void 0 : s;
|
|
1447
|
+
var wn = (s, t, e) => En(parseInt(s.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8));
|
|
1448
|
+
var Sn = {
|
|
1449
|
+
12: 8589934591,
|
|
1450
|
+
8: 2097151
|
|
1451
|
+
};
|
|
1452
|
+
var ct = (s, t, e, i) => i === void 0 ? !1 : i > Sn[e] || i < 0 ? (Us(i, s.subarray(t, t + e)), !0) : (yn(s, t, e, i), !1);
|
|
1453
|
+
var yn = (s, t, e, i) => s.write(Rn(i, e), t, e, "ascii");
|
|
1454
|
+
var Rn = (s, t) => gn(Math.floor(s).toString(8), t);
|
|
1455
|
+
var gn = (s, t) => (s.length === t - 1 ? s : new Array(t - s.length - 1).join("0") + s + " ") + "\0";
|
|
1456
|
+
var Gi = (s, t, e, i) => i === void 0 ? !1 : ct(s, t, e, i.getTime() / 1e3);
|
|
1457
|
+
var bn = new Array(156).join("\0");
|
|
1458
|
+
var Lt = (s, t, e, i) => i === void 0 ? !1 : (s.write(i + bn, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
|
|
1459
|
+
var ft = class s {
|
|
1460
|
+
atime;
|
|
1461
|
+
mtime;
|
|
1462
|
+
ctime;
|
|
1463
|
+
charset;
|
|
1464
|
+
comment;
|
|
1465
|
+
gid;
|
|
1466
|
+
uid;
|
|
1467
|
+
gname;
|
|
1468
|
+
uname;
|
|
1469
|
+
linkpath;
|
|
1470
|
+
dev;
|
|
1471
|
+
ino;
|
|
1472
|
+
nlink;
|
|
1473
|
+
path;
|
|
1474
|
+
size;
|
|
1475
|
+
mode;
|
|
1476
|
+
global;
|
|
1477
|
+
constructor(t, e = !1) {
|
|
1478
|
+
this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
|
|
1479
|
+
}
|
|
1480
|
+
encode() {
|
|
1481
|
+
let t = this.encodeBody();
|
|
1482
|
+
if (t === "") return Buffer.allocUnsafe(0);
|
|
1483
|
+
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
1484
|
+
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
1485
|
+
new F({
|
|
1486
|
+
path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
|
|
1487
|
+
mode: this.mode || 420,
|
|
1488
|
+
uid: this.uid,
|
|
1489
|
+
gid: this.gid,
|
|
1490
|
+
size: e,
|
|
1491
|
+
mtime: this.mtime,
|
|
1492
|
+
type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
|
|
1493
|
+
linkpath: "",
|
|
1494
|
+
uname: this.uname || "",
|
|
1495
|
+
gname: this.gname || "",
|
|
1496
|
+
devmaj: 0,
|
|
1497
|
+
devmin: 0,
|
|
1498
|
+
atime: this.atime,
|
|
1499
|
+
ctime: this.ctime
|
|
1500
|
+
}).encode(r), r.write(t, 512, e, "utf8");
|
|
1501
|
+
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
1502
|
+
return r;
|
|
1503
|
+
}
|
|
1504
|
+
encodeBody() {
|
|
1505
|
+
return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
|
|
1506
|
+
}
|
|
1507
|
+
encodeField(t) {
|
|
1508
|
+
if (this[t] === void 0) return "";
|
|
1509
|
+
let e = this[t], i = e instanceof Date ? e.getTime() / 1e3 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
|
|
1510
|
+
`, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
|
|
1511
|
+
return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
|
|
1512
|
+
}
|
|
1513
|
+
static parse(t, e, i = !1) {
|
|
1514
|
+
return new s(On(Tn(t), e), i);
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
var On = (s, t) => t ? Object.assign({}, t, s) : s;
|
|
1518
|
+
var Tn = (s) => s.replace(/\n$/, "").split(`
|
|
1519
|
+
`).reduce(xn, Object.create(null));
|
|
1520
|
+
var xn = (s, t) => {
|
|
1521
|
+
let e = parseInt(t, 10);
|
|
1522
|
+
if (e !== Buffer.byteLength(t) + 1) return s;
|
|
1523
|
+
t = t.slice((e + " ").length);
|
|
1524
|
+
let i = t.split("="), r = i.shift();
|
|
1525
|
+
if (!r) return s;
|
|
1526
|
+
let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=").replace(/\0.*/, "");
|
|
1527
|
+
switch (n) {
|
|
1528
|
+
case "path":
|
|
1529
|
+
case "linkpath":
|
|
1530
|
+
case "type":
|
|
1531
|
+
case "charset":
|
|
1532
|
+
case "comment":
|
|
1533
|
+
case "gname":
|
|
1534
|
+
case "uname":
|
|
1535
|
+
s[n] = o;
|
|
1536
|
+
break;
|
|
1537
|
+
case "ctime":
|
|
1538
|
+
case "atime":
|
|
1539
|
+
case "mtime":
|
|
1540
|
+
s[n] = /* @__PURE__ */ new Date(Number(o) * 1e3);
|
|
1541
|
+
break;
|
|
1542
|
+
case "size":
|
|
1543
|
+
let h = +o;
|
|
1544
|
+
h >= 0 && (s[n] = h);
|
|
1545
|
+
break;
|
|
1546
|
+
case "gid":
|
|
1547
|
+
case "uid":
|
|
1548
|
+
case "dev":
|
|
1549
|
+
case "ino":
|
|
1550
|
+
case "nlink":
|
|
1551
|
+
case "mode": s[n] = +o;
|
|
1552
|
+
}
|
|
1553
|
+
return s;
|
|
1554
|
+
};
|
|
1555
|
+
var f = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) !== "win32" ? (s) => String(s) : (s) => String(s).replaceAll(/\\/g, "/");
|
|
1556
|
+
var $e = class extends A {
|
|
1557
|
+
extended;
|
|
1558
|
+
globalExtended;
|
|
1559
|
+
header;
|
|
1560
|
+
startBlockSize;
|
|
1561
|
+
blockRemain;
|
|
1562
|
+
remain;
|
|
1563
|
+
type;
|
|
1564
|
+
meta = !1;
|
|
1565
|
+
ignore = !1;
|
|
1566
|
+
path;
|
|
1567
|
+
mode;
|
|
1568
|
+
uid;
|
|
1569
|
+
gid;
|
|
1570
|
+
uname;
|
|
1571
|
+
gname;
|
|
1572
|
+
size = 0;
|
|
1573
|
+
mtime;
|
|
1574
|
+
atime;
|
|
1575
|
+
ctime;
|
|
1576
|
+
linkpath;
|
|
1577
|
+
dev;
|
|
1578
|
+
ino;
|
|
1579
|
+
nlink;
|
|
1580
|
+
invalid = !1;
|
|
1581
|
+
absolute;
|
|
1582
|
+
unsupported = !1;
|
|
1583
|
+
constructor(t, e, i) {
|
|
1584
|
+
switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
|
|
1585
|
+
case "File":
|
|
1586
|
+
case "OldFile":
|
|
1587
|
+
case "Link":
|
|
1588
|
+
case "SymbolicLink":
|
|
1589
|
+
case "CharacterDevice":
|
|
1590
|
+
case "BlockDevice":
|
|
1591
|
+
case "Directory":
|
|
1592
|
+
case "FIFO":
|
|
1593
|
+
case "ContiguousFile":
|
|
1594
|
+
case "GNUDumpDir": break;
|
|
1595
|
+
case "NextFileHasLongLinkpath":
|
|
1596
|
+
case "NextFileHasLongPath":
|
|
1597
|
+
case "OldGnuLongPath":
|
|
1598
|
+
case "GlobalExtendedHeader":
|
|
1599
|
+
case "ExtendedHeader":
|
|
1600
|
+
case "OldExtendedHeader":
|
|
1601
|
+
this.meta = !0;
|
|
1602
|
+
break;
|
|
1603
|
+
default: this.ignore = !0;
|
|
1604
|
+
}
|
|
1605
|
+
if (!t.path) throw new Error("no path provided for tar.ReadEntry");
|
|
1606
|
+
this.path = f(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f(t.linkpath) : void 0, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, !0);
|
|
1607
|
+
}
|
|
1608
|
+
write(t) {
|
|
1609
|
+
let e = t.length;
|
|
1610
|
+
if (e > this.blockRemain) throw new Error("writing more to entry than is appropriate");
|
|
1611
|
+
let i = this.remain, r = this.blockRemain;
|
|
1612
|
+
return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? !0 : i >= e ? super.write(t) : super.write(t.subarray(0, i));
|
|
1613
|
+
}
|
|
1614
|
+
#t(t, e = !1) {
|
|
1615
|
+
t.path && (t.path = f(t.path)), t.linkpath && (t.linkpath = f(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
var Dt = (s, t, e, i = {}) => {
|
|
1619
|
+
s.file && (i.file = s.file), s.cwd && (i.cwd = s.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s.strict && i.recoverable !== !1 ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s.emit("warn", t, e, i)) : e instanceof Error ? s.emit("error", Object.assign(e, i)) : s.emit("error", Object.assign(/* @__PURE__ */ new Error(`${t}: ${e}`), i));
|
|
1620
|
+
};
|
|
1621
|
+
var Nn = 1048576;
|
|
1622
|
+
var Xi = Buffer.from([31, 139]);
|
|
1623
|
+
var qi = Buffer.from([
|
|
1624
|
+
40,
|
|
1625
|
+
181,
|
|
1626
|
+
47,
|
|
1627
|
+
253
|
|
1628
|
+
]);
|
|
1629
|
+
var An = Math.max(Xi.length, qi.length);
|
|
1630
|
+
var B = Symbol("state");
|
|
1631
|
+
var Nt = Symbol("writeEntry");
|
|
1632
|
+
var it = Symbol("readEntry");
|
|
1633
|
+
var Zi = Symbol("nextEntry");
|
|
1634
|
+
var Zs = Symbol("processEntry");
|
|
1635
|
+
var V = Symbol("extendedHeader");
|
|
1636
|
+
var he = Symbol("globalExtendedHeader");
|
|
1637
|
+
var dt = Symbol("meta");
|
|
1638
|
+
var Ys = Symbol("emitMeta");
|
|
1639
|
+
var p = Symbol("buffer");
|
|
1640
|
+
var st = Symbol("queue");
|
|
1641
|
+
var ut = Symbol("ended");
|
|
1642
|
+
var Yi = Symbol("emittedEnd");
|
|
1643
|
+
var At = Symbol("emit");
|
|
1644
|
+
var w = Symbol("unzip");
|
|
1645
|
+
var Xe = Symbol("consumeChunk");
|
|
1646
|
+
var qe = Symbol("consumeChunkSub");
|
|
1647
|
+
var Ki = Symbol("consumeBody");
|
|
1648
|
+
var Ks = Symbol("consumeMeta");
|
|
1649
|
+
var Vs = Symbol("consumeHeader");
|
|
1650
|
+
var ae = Symbol("consuming");
|
|
1651
|
+
var Vi = Symbol("bufferConcat");
|
|
1652
|
+
var Qe = Symbol("maybeEnd");
|
|
1653
|
+
var Yt = Symbol("writing");
|
|
1654
|
+
var $ = Symbol("aborted");
|
|
1655
|
+
var Je = Symbol("onDone");
|
|
1656
|
+
var It = Symbol("sawValidEntry");
|
|
1657
|
+
var je = Symbol("sawNullBlock");
|
|
1658
|
+
var ti = Symbol("sawEOF");
|
|
1659
|
+
var $s = Symbol("closeStream");
|
|
1660
|
+
var In = 1e3;
|
|
1661
|
+
var le = Symbol("compressedBytesRead");
|
|
1662
|
+
var $i = Symbol("decompressedBytesRead");
|
|
1663
|
+
var Xs = Symbol("checkDecompressionRatio");
|
|
1664
|
+
var Cn = () => !0;
|
|
1665
|
+
var rt = class extends EventEmitter {
|
|
1666
|
+
file;
|
|
1667
|
+
strict;
|
|
1668
|
+
maxMetaEntrySize;
|
|
1669
|
+
filter;
|
|
1670
|
+
brotli;
|
|
1671
|
+
zstd;
|
|
1672
|
+
maxDecompressionRatio;
|
|
1673
|
+
writable = !0;
|
|
1674
|
+
readable = !1;
|
|
1675
|
+
[st] = [];
|
|
1676
|
+
[p];
|
|
1677
|
+
[it];
|
|
1678
|
+
[Nt];
|
|
1679
|
+
[B] = "begin";
|
|
1680
|
+
[dt] = "";
|
|
1681
|
+
[V];
|
|
1682
|
+
[he];
|
|
1683
|
+
[ut] = !1;
|
|
1684
|
+
[w];
|
|
1685
|
+
[$] = !1;
|
|
1686
|
+
[It];
|
|
1687
|
+
[je] = !1;
|
|
1688
|
+
[ti] = !1;
|
|
1689
|
+
[Yt] = !1;
|
|
1690
|
+
[ae] = !1;
|
|
1691
|
+
[Yi] = !1;
|
|
1692
|
+
[le] = 0;
|
|
1693
|
+
[$i] = 0;
|
|
1694
|
+
constructor(t = {}) {
|
|
1695
|
+
super(), this.file = t.file || "", this.on(Je, () => {
|
|
1696
|
+
(this[B] === "begin" || this[It] === !1) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
|
|
1697
|
+
}), t.ondone ? this.on(Je, t.ondone) : this.on(Je, () => {
|
|
1698
|
+
this.emit("prefinish"), this.emit("finish"), this.emit("end");
|
|
1699
|
+
}), this.strict = !!t.strict, this.maxDecompressionRatio = typeof t.maxDecompressionRatio == "number" ? t.maxDecompressionRatio : In, this.maxMetaEntrySize = t.maxMetaEntrySize || Nn, this.filter = typeof t.filter == "function" ? t.filter : Cn;
|
|
1700
|
+
let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
|
|
1701
|
+
this.brotli = !(t.gzip || t.zstd) && t.brotli !== void 0 ? t.brotli : e ? void 0 : !1;
|
|
1702
|
+
let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
|
|
1703
|
+
this.zstd = !(t.gzip || t.brotli) && t.zstd !== void 0 ? t.zstd : i ? !0 : void 0, this.on("end", () => this[$s]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
|
|
1704
|
+
}
|
|
1705
|
+
warn(t, e, i = {}) {
|
|
1706
|
+
Dt(this, t, e, i);
|
|
1707
|
+
}
|
|
1708
|
+
[Vs](t, e) {
|
|
1709
|
+
this[It] === void 0 && (this[It] = !1);
|
|
1710
|
+
let i;
|
|
1711
|
+
try {
|
|
1712
|
+
i = new F(t, e, this[V], this[he]);
|
|
1713
|
+
} catch (r) {
|
|
1714
|
+
return this.warn("TAR_ENTRY_INVALID", r);
|
|
1715
|
+
}
|
|
1716
|
+
if (i.nullBlock) this[je] ? (this[ti] = !0, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[je] = !0, this[At]("nullBlock"));
|
|
1717
|
+
else if (this[je] = !1, !i.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
|
|
1718
|
+
else if (!i.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
|
|
1719
|
+
else {
|
|
1720
|
+
let r = i.type;
|
|
1721
|
+
if (/^(Symbolic)?Link$/.test(r) && !i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
|
|
1722
|
+
else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
|
|
1723
|
+
else {
|
|
1724
|
+
let n = this[Nt] = new $e(i, this[V], this[he]);
|
|
1725
|
+
if (!this[It]) if (n.remain) {
|
|
1726
|
+
let o = () => {
|
|
1727
|
+
n.invalid || (this[It] = !0);
|
|
1728
|
+
};
|
|
1729
|
+
n.on("end", o);
|
|
1730
|
+
} else this[It] = !0;
|
|
1731
|
+
n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = !0, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[dt] = "", n.on("data", (o) => this[dt] += o), this[B] = "meta") : (this[V] = void 0, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[it] ? this[st].push(n) : (this[st].push(n), this[Zi]())));
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
[$s]() {
|
|
1736
|
+
queueMicrotask(() => this.emit("close"));
|
|
1737
|
+
}
|
|
1738
|
+
[Zs](t) {
|
|
1739
|
+
let e = !0;
|
|
1740
|
+
if (!t) this[it] = void 0, e = !1;
|
|
1741
|
+
else if (Array.isArray(t)) {
|
|
1742
|
+
let [i, ...r] = t;
|
|
1743
|
+
this.emit(i, ...r);
|
|
1744
|
+
} else this[it] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Zi]()), e = !1);
|
|
1745
|
+
return e;
|
|
1746
|
+
}
|
|
1747
|
+
[Zi]() {
|
|
1748
|
+
do ;
|
|
1749
|
+
while (this[Zs](this[st].shift()));
|
|
1750
|
+
if (this[st].length === 0) {
|
|
1751
|
+
let t = this[it];
|
|
1752
|
+
!t || t.flowing || t.size === t.remain ? this[Yt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
[Ki](t, e) {
|
|
1756
|
+
let i = this[Nt];
|
|
1757
|
+
if (!i) throw new Error("attempt to consume body without entry??");
|
|
1758
|
+
let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
|
|
1759
|
+
return i.write(n), i.blockRemain || (this[B] = "header", this[Nt] = void 0, i.end()), n.length;
|
|
1760
|
+
}
|
|
1761
|
+
[Ks](t, e) {
|
|
1762
|
+
let i = this[Nt], r = this[Ki](t, e);
|
|
1763
|
+
return !this[Nt] && i && this[Ys](i), r;
|
|
1764
|
+
}
|
|
1765
|
+
[At](t, e, i) {
|
|
1766
|
+
this[st].length === 0 && !this[it] ? this.emit(t, e, i) : this[st].push([
|
|
1767
|
+
t,
|
|
1768
|
+
e,
|
|
1769
|
+
i
|
|
1770
|
+
]);
|
|
1771
|
+
}
|
|
1772
|
+
[Ys](t) {
|
|
1773
|
+
switch (this[At]("meta", this[dt]), t.type) {
|
|
1774
|
+
case "ExtendedHeader":
|
|
1775
|
+
case "OldExtendedHeader":
|
|
1776
|
+
this[V] = ft.parse(this[dt], this[V], !1);
|
|
1777
|
+
break;
|
|
1778
|
+
case "GlobalExtendedHeader":
|
|
1779
|
+
this[he] = ft.parse(this[dt], this[he], !0);
|
|
1780
|
+
break;
|
|
1781
|
+
case "NextFileHasLongPath":
|
|
1782
|
+
case "OldGnuLongPath": {
|
|
1783
|
+
let e = this[V] ?? Object.create(null);
|
|
1784
|
+
this[V] = e, e.path = this[dt].replace(/\0.*/, "");
|
|
1785
|
+
break;
|
|
1786
|
+
}
|
|
1787
|
+
case "NextFileHasLongLinkpath": {
|
|
1788
|
+
let e = this[V] || Object.create(null);
|
|
1789
|
+
this[V] = e, e.linkpath = this[dt].replace(/\0.*/, "");
|
|
1790
|
+
break;
|
|
1791
|
+
}
|
|
1792
|
+
default: throw new Error("unknown meta: " + t.type);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
abort(t) {
|
|
1796
|
+
if (!this[$]) {
|
|
1797
|
+
if (this[w]) {
|
|
1798
|
+
let e = this[w];
|
|
1799
|
+
e.write = () => !0, e.end = () => e, e.emit = () => !1, e.destroy?.();
|
|
1800
|
+
}
|
|
1801
|
+
this[$] = !0, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: !1 });
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
[Xs](t) {
|
|
1805
|
+
this[$i] += t.length;
|
|
1806
|
+
let e = this[$i] / this[le];
|
|
1807
|
+
return e > this.maxDecompressionRatio ? (this.abort(/* @__PURE__ */ new Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${this.maxDecompressionRatio}`)), !1) : !0;
|
|
1808
|
+
}
|
|
1809
|
+
write(t, e, i) {
|
|
1810
|
+
if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[$]) return i?.(), !1;
|
|
1811
|
+
if ((this[w] === void 0 || this.brotli === void 0 && this[w] === !1) && t) {
|
|
1812
|
+
if (this[p] && (t = Buffer.concat([this[p], t]), this[p] = void 0), t.length < An) return this[p] = t, i?.(), !0;
|
|
1813
|
+
for (let a = 0; this[w] === void 0 && a < Xi.length; a++) t[a] !== Xi[a] && (this[w] = !1);
|
|
1814
|
+
let o = !1;
|
|
1815
|
+
if (this[w] === !1 && this.zstd !== !1) {
|
|
1816
|
+
o = !0;
|
|
1817
|
+
for (let a = 0; a < qi.length; a++) if (t[a] !== qi[a]) {
|
|
1818
|
+
o = !1;
|
|
1819
|
+
break;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
let h = this.brotli === void 0 && !o;
|
|
1823
|
+
if (this[w] === !1 && h) if (t.length < 512) if (this[ut]) this.brotli = !0;
|
|
1824
|
+
else return this[p] = t, i?.(), !0;
|
|
1825
|
+
else try {
|
|
1826
|
+
new F(t.subarray(0, 512)), this.brotli = !1;
|
|
1827
|
+
} catch {
|
|
1828
|
+
this.brotli = !0;
|
|
1829
|
+
}
|
|
1830
|
+
if (this[w] === void 0 || this[w] === !1 && (this.brotli || o)) {
|
|
1831
|
+
let a = this[ut];
|
|
1832
|
+
this[ut] = !1, this[w] = this[w] === void 0 ? new Ue({}) : o ? new Ke({}) : new Ge({}), this[w].on("data", (c) => {
|
|
1833
|
+
this[Xs](c) && this[Xe](c);
|
|
1834
|
+
}), this[w].on("error", (c) => {
|
|
1835
|
+
this[$] || this.abort(c);
|
|
1836
|
+
}), this[w].on("end", () => {
|
|
1837
|
+
this[ut] = !0, this[Xe]();
|
|
1838
|
+
}), this[Yt] = !0, this[le] += t.length;
|
|
1839
|
+
let l = !!this[w][a ? "end" : "write"](t);
|
|
1840
|
+
return this[Yt] = !1, i?.(), l;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
this[Yt] = !0, this[w] ? (this[le] += t.length, this[w].write(t)) : this[Xe](t), this[Yt] = !1;
|
|
1844
|
+
let n = this[st].length > 0 ? !1 : this[it] ? this[it].flowing : !0;
|
|
1845
|
+
return !n && this[st].length === 0 && this[it]?.once("drain", () => this.emit("drain")), i?.(), n;
|
|
1846
|
+
}
|
|
1847
|
+
[Vi](t) {
|
|
1848
|
+
t && !this[$] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
|
|
1849
|
+
}
|
|
1850
|
+
[Qe]() {
|
|
1851
|
+
if (this[ut] && !this[Yi] && !this[$] && !this[ae]) {
|
|
1852
|
+
this[Yi] = !0;
|
|
1853
|
+
let t = this[Nt];
|
|
1854
|
+
if (t?.blockRemain) {
|
|
1855
|
+
let e = this[p] ? this[p].length : 0;
|
|
1856
|
+
this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p] && t.write(this[p]), t.end();
|
|
1857
|
+
}
|
|
1858
|
+
this[At](Je);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
[Xe](t) {
|
|
1862
|
+
if (this[ae] && t) this[Vi](t);
|
|
1863
|
+
else if (!t && !this[p]) this[Qe]();
|
|
1864
|
+
else if (t) {
|
|
1865
|
+
if (this[ae] = !0, this[p]) {
|
|
1866
|
+
this[Vi](t);
|
|
1867
|
+
let e = this[p];
|
|
1868
|
+
this[p] = void 0, this[qe](e);
|
|
1869
|
+
} else this[qe](t);
|
|
1870
|
+
for (; this[p] && this[p]?.length >= 512 && !this[$] && !this[ti];) {
|
|
1871
|
+
let e = this[p];
|
|
1872
|
+
this[p] = void 0, this[qe](e);
|
|
1873
|
+
}
|
|
1874
|
+
this[ae] = !1;
|
|
1875
|
+
}
|
|
1876
|
+
(!this[p] || this[ut]) && this[Qe]();
|
|
1877
|
+
}
|
|
1878
|
+
[qe](t) {
|
|
1879
|
+
let e = 0, i = t.length;
|
|
1880
|
+
for (; e + 512 <= i && !this[$] && !this[ti];) switch (this[B]) {
|
|
1881
|
+
case "begin":
|
|
1882
|
+
case "header":
|
|
1883
|
+
this[Vs](t, e), e += 512;
|
|
1884
|
+
break;
|
|
1885
|
+
case "ignore":
|
|
1886
|
+
case "body":
|
|
1887
|
+
e += this[Ki](t, e);
|
|
1888
|
+
break;
|
|
1889
|
+
case "meta":
|
|
1890
|
+
e += this[Ks](t, e);
|
|
1891
|
+
break;
|
|
1892
|
+
default: throw new Error("invalid state: " + this[B]);
|
|
1893
|
+
}
|
|
1894
|
+
e < i && (this[p] = this[p] ? Buffer.concat([t.subarray(e), this[p]]) : t.subarray(e));
|
|
1895
|
+
}
|
|
1896
|
+
end(t, e, i) {
|
|
1897
|
+
return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[$] || (this[w] ? (t && (this[le] += t.length, this[w].write(t)), this[w].end()) : (this[ut] = !0, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Qe]())), this;
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
var mt = (s) => {
|
|
1901
|
+
let t = s.length - 1, e = -1;
|
|
1902
|
+
for (; t > -1 && s.charAt(t) === "/";) e = t, t--;
|
|
1903
|
+
return e === -1 ? s : s.slice(0, e);
|
|
1904
|
+
};
|
|
1905
|
+
var vn = (s) => {
|
|
1906
|
+
let t = s.onReadEntry;
|
|
1907
|
+
s.onReadEntry = t ? (e) => {
|
|
1908
|
+
t(e), e.resume();
|
|
1909
|
+
} : (e) => e.resume();
|
|
1910
|
+
};
|
|
1911
|
+
var Qi = (s, t) => {
|
|
1912
|
+
let e = new Map(t.map((o) => [mt(o), !0])), i = s.filter, r = 100, n = (o, h = "", a = 0) => {
|
|
1913
|
+
if (a >= r) return e.set(o, !1), !1;
|
|
1914
|
+
let l = h || parse(o).root || ".", c;
|
|
1915
|
+
if (o === l) c = !1;
|
|
1916
|
+
else {
|
|
1917
|
+
let d = e.get(o);
|
|
1918
|
+
c = d !== void 0 ? d : n(dirname(o), l, a + 1);
|
|
1919
|
+
}
|
|
1920
|
+
return e.set(o, c), c;
|
|
1921
|
+
};
|
|
1922
|
+
s.filter = i ? (o, h) => i(o, h) && n(mt(o)) : (o) => n(mt(o));
|
|
1923
|
+
};
|
|
1924
|
+
var Mn = (s) => {
|
|
1925
|
+
let t = new rt(s), e = s.file, i;
|
|
1926
|
+
try {
|
|
1927
|
+
i = Br.openSync(e, "r");
|
|
1928
|
+
let r = Br.fstatSync(i), n = s.maxReadSize || 16777216;
|
|
1929
|
+
if (r.size < n) {
|
|
1930
|
+
let o = Buffer.allocUnsafe(r.size), h = Br.readSync(i, o, 0, r.size, 0);
|
|
1931
|
+
t.end(h === o.byteLength ? o : o.subarray(0, h));
|
|
1932
|
+
} else {
|
|
1933
|
+
let o = 0, h = Buffer.allocUnsafe(n);
|
|
1934
|
+
for (; o < r.size;) {
|
|
1935
|
+
let a = Br.readSync(i, h, 0, n, o);
|
|
1936
|
+
if (a === 0) break;
|
|
1937
|
+
o += a, t.write(h.subarray(0, a));
|
|
1938
|
+
}
|
|
1939
|
+
t.end();
|
|
1940
|
+
}
|
|
1941
|
+
} finally {
|
|
1942
|
+
if (typeof i == "number") try {
|
|
1943
|
+
Br.closeSync(i);
|
|
1944
|
+
} catch {}
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1947
|
+
var Bn = (s, t) => {
|
|
1948
|
+
let e = new rt(s), i = s.maxReadSize || 16777216, r = s.file;
|
|
1949
|
+
return new Promise((o, h) => {
|
|
1950
|
+
e.on("error", h), e.on("end", o), Br.stat(r, (a, l) => {
|
|
1951
|
+
if (a) h(a);
|
|
1952
|
+
else {
|
|
1953
|
+
let c = new _t(r, {
|
|
1954
|
+
readSize: i,
|
|
1955
|
+
size: l.size
|
|
1956
|
+
});
|
|
1957
|
+
c.on("error", h), c.pipe(e);
|
|
1958
|
+
}
|
|
1959
|
+
});
|
|
1960
|
+
});
|
|
1961
|
+
};
|
|
1962
|
+
var Ct = K(Mn, Bn, (s) => new rt(s), (s) => new rt(s), (s, t) => {
|
|
1963
|
+
t?.length && Qi(s, t), s.noResume || vn(s);
|
|
1964
|
+
});
|
|
1965
|
+
var Ji = (s, t, e) => (s &= 4095, e && (s = (s | 384) & -19), t && (s & 256 && (s |= 64), s & 32 && (s |= 8), s & 4 && (s |= 1)), s);
|
|
1966
|
+
var { isAbsolute: zn, parse: qs } = win32, ce = (s) => {
|
|
1967
|
+
let t = "", e = qs(s);
|
|
1968
|
+
for (; zn(s) || e.root;) {
|
|
1969
|
+
let i = s.charAt(0) === "/" && s.slice(0, 4) !== "//?/" ? "/" : e.root;
|
|
1970
|
+
s = s.slice(i.length), t += i, e = qs(s);
|
|
1971
|
+
}
|
|
1972
|
+
return [t, s];
|
|
1973
|
+
};
|
|
1974
|
+
var ei = [
|
|
1975
|
+
"|",
|
|
1976
|
+
"<",
|
|
1977
|
+
">",
|
|
1978
|
+
"?",
|
|
1979
|
+
":"
|
|
1980
|
+
];
|
|
1981
|
+
var ji = ei.map((s) => String.fromCodePoint(61440 + Number(s.codePointAt(0))));
|
|
1982
|
+
var Un = new Map(ei.map((s, t) => [s, ji[t]]));
|
|
1983
|
+
var Hn = new Map(ji.map((s, t) => [s, ei[t]]));
|
|
1984
|
+
var ts = (s) => ei.reduce((t, e) => t.split(e).join(Un.get(e)), s);
|
|
1985
|
+
var Qs = (s) => ji.reduce((t, e) => t.split(e).join(Hn.get(e)), s);
|
|
1986
|
+
var rr = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(s);
|
|
1987
|
+
var Wn = 16777216;
|
|
1988
|
+
var tr = Symbol("process");
|
|
1989
|
+
var er = Symbol("file");
|
|
1990
|
+
var ir = Symbol("directory");
|
|
1991
|
+
var is = Symbol("symlink");
|
|
1992
|
+
var sr = Symbol("hardlink");
|
|
1993
|
+
var fe = Symbol("header");
|
|
1994
|
+
var ii = Symbol("read");
|
|
1995
|
+
var ss = Symbol("lstat");
|
|
1996
|
+
var si = Symbol("onlstat");
|
|
1997
|
+
var rs = Symbol("onread");
|
|
1998
|
+
var ns = Symbol("onreadlink");
|
|
1999
|
+
var os = Symbol("openfile");
|
|
2000
|
+
var hs = Symbol("onopenfile");
|
|
2001
|
+
var pt = Symbol("close");
|
|
2002
|
+
var ri = Symbol("mode");
|
|
2003
|
+
var as = Symbol("awaitDrain");
|
|
2004
|
+
var es = Symbol("ondrain");
|
|
2005
|
+
var q = Symbol("prefix");
|
|
2006
|
+
var de = class extends A {
|
|
2007
|
+
path;
|
|
2008
|
+
portable;
|
|
2009
|
+
myuid = process.getuid && process.getuid() || 0;
|
|
2010
|
+
myuser = process.env.USER || "";
|
|
2011
|
+
maxReadSize;
|
|
2012
|
+
linkCache;
|
|
2013
|
+
statCache;
|
|
2014
|
+
preservePaths;
|
|
2015
|
+
cwd;
|
|
2016
|
+
strict;
|
|
2017
|
+
mtime;
|
|
2018
|
+
noPax;
|
|
2019
|
+
noMtime;
|
|
2020
|
+
prefix;
|
|
2021
|
+
fd;
|
|
2022
|
+
blockLen = 0;
|
|
2023
|
+
blockRemain = 0;
|
|
2024
|
+
buf;
|
|
2025
|
+
pos = 0;
|
|
2026
|
+
remain = 0;
|
|
2027
|
+
length = 0;
|
|
2028
|
+
offset = 0;
|
|
2029
|
+
win32;
|
|
2030
|
+
absolute;
|
|
2031
|
+
header;
|
|
2032
|
+
type;
|
|
2033
|
+
linkpath;
|
|
2034
|
+
stat;
|
|
2035
|
+
onWriteEntry;
|
|
2036
|
+
#t = !1;
|
|
2037
|
+
constructor(t, e = {}) {
|
|
2038
|
+
let i = se(e);
|
|
2039
|
+
super(), this.path = f(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || Wn, this.linkCache = i.linkCache || /* @__PURE__ */ new Map(), this.statCache = i.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!i.preservePaths, this.cwd = f(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f(i.prefix) : void 0, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
2040
|
+
let r = !1;
|
|
2041
|
+
if (!this.preservePaths) {
|
|
2042
|
+
let [o, h] = ce(this.path);
|
|
2043
|
+
o && typeof h == "string" && (this.path = h, r = o);
|
|
2044
|
+
}
|
|
2045
|
+
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || ar.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
|
|
2046
|
+
entry: this,
|
|
2047
|
+
path: r + this.path
|
|
2048
|
+
});
|
|
2049
|
+
let n = this.statCache.get(this.absolute);
|
|
2050
|
+
n ? this[si](n) : this[ss]();
|
|
2051
|
+
}
|
|
2052
|
+
warn(t, e, i = {}) {
|
|
2053
|
+
return Dt(this, t, e, i);
|
|
2054
|
+
}
|
|
2055
|
+
emit(t, ...e) {
|
|
2056
|
+
return t === "error" && (this.#t = !0), super.emit(t, ...e);
|
|
2057
|
+
}
|
|
2058
|
+
[ss]() {
|
|
2059
|
+
I.lstat(this.absolute, (t, e) => {
|
|
2060
|
+
if (t) return this.emit("error", t);
|
|
2061
|
+
this[si](e);
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
[si](t) {
|
|
2065
|
+
this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Gn(t), this.emit("stat", t), this[tr]();
|
|
2066
|
+
}
|
|
2067
|
+
[tr]() {
|
|
2068
|
+
switch (this.type) {
|
|
2069
|
+
case "File": return this[er]();
|
|
2070
|
+
case "Directory": return this[ir]();
|
|
2071
|
+
case "SymbolicLink": return this[is]();
|
|
2072
|
+
default: return this.end();
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
[ri](t) {
|
|
2076
|
+
return Ji(t, this.type === "Directory", this.portable);
|
|
2077
|
+
}
|
|
2078
|
+
[q](t) {
|
|
2079
|
+
return rr(t, this.prefix);
|
|
2080
|
+
}
|
|
2081
|
+
[fe]() {
|
|
2082
|
+
if (!this.stat) throw new Error("cannot write header before stat");
|
|
2083
|
+
this.type === "Directory" && this.portable && (this.noMtime = !0), this.onWriteEntry?.(this), this.header = new F({
|
|
2084
|
+
path: this[q](this.path),
|
|
2085
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2086
|
+
mode: this[ri](this.stat.mode),
|
|
2087
|
+
uid: this.portable ? void 0 : this.stat.uid,
|
|
2088
|
+
gid: this.portable ? void 0 : this.stat.gid,
|
|
2089
|
+
size: this.stat.size,
|
|
2090
|
+
mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
|
|
2091
|
+
type: this.type === "Unsupported" ? void 0 : this.type,
|
|
2092
|
+
uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
|
|
2093
|
+
atime: this.portable ? void 0 : this.stat.atime,
|
|
2094
|
+
ctime: this.portable ? void 0 : this.stat.ctime
|
|
2095
|
+
}), this.header.encode() && !this.noPax && super.write(new ft({
|
|
2096
|
+
atime: this.portable ? void 0 : this.header.atime,
|
|
2097
|
+
ctime: this.portable ? void 0 : this.header.ctime,
|
|
2098
|
+
gid: this.portable ? void 0 : this.header.gid,
|
|
2099
|
+
mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
|
|
2100
|
+
path: this[q](this.path),
|
|
2101
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2102
|
+
size: this.header.size,
|
|
2103
|
+
uid: this.portable ? void 0 : this.header.uid,
|
|
2104
|
+
uname: this.portable ? void 0 : this.header.uname,
|
|
2105
|
+
dev: this.portable ? void 0 : this.stat.dev,
|
|
2106
|
+
ino: this.portable ? void 0 : this.stat.ino,
|
|
2107
|
+
nlink: this.portable ? void 0 : this.stat.nlink
|
|
2108
|
+
}).encode());
|
|
2109
|
+
let t = this.header?.block;
|
|
2110
|
+
if (!t) throw new Error("failed to encode header");
|
|
2111
|
+
super.write(t);
|
|
2112
|
+
}
|
|
2113
|
+
[ir]() {
|
|
2114
|
+
if (!this.stat) throw new Error("cannot create directory entry without stat");
|
|
2115
|
+
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
|
|
2116
|
+
}
|
|
2117
|
+
[is]() {
|
|
2118
|
+
I.readlink(this.absolute, (t, e) => {
|
|
2119
|
+
if (t) return this.emit("error", t);
|
|
2120
|
+
this[ns](e);
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
[ns](t) {
|
|
2124
|
+
this.linkpath = f(t), this[fe](), this.end();
|
|
2125
|
+
}
|
|
2126
|
+
[sr](t) {
|
|
2127
|
+
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
2128
|
+
this.type = "Link", this.linkpath = f(ar.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
|
|
2129
|
+
}
|
|
2130
|
+
[er]() {
|
|
2131
|
+
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
2132
|
+
if (this.stat.nlink > 1) {
|
|
2133
|
+
let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
|
|
2134
|
+
if (e?.indexOf(this.cwd) === 0) return this[sr](e);
|
|
2135
|
+
this.linkCache.set(t, this.absolute);
|
|
2136
|
+
}
|
|
2137
|
+
if (this[fe](), this.stat.size === 0) return this.end();
|
|
2138
|
+
this[os]();
|
|
2139
|
+
}
|
|
2140
|
+
[os]() {
|
|
2141
|
+
I.open(this.absolute, "r", (t, e) => {
|
|
2142
|
+
if (t) return this.emit("error", t);
|
|
2143
|
+
this[hs](e);
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
[hs](t) {
|
|
2147
|
+
if (this.fd = t, this.#t) return this[pt]();
|
|
2148
|
+
if (!this.stat) throw new Error("should stat before calling onopenfile");
|
|
2149
|
+
this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
|
|
2150
|
+
let e = Math.min(this.blockLen, this.maxReadSize);
|
|
2151
|
+
this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ii]();
|
|
2152
|
+
}
|
|
2153
|
+
[ii]() {
|
|
2154
|
+
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
2155
|
+
if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
|
|
2156
|
+
I.read(t, e, i, r, n, (o, h) => {
|
|
2157
|
+
if (o) return this[pt](() => this.emit("error", o));
|
|
2158
|
+
this[rs](h);
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
[pt](t = () => {}) {
|
|
2162
|
+
this.fd !== void 0 && I.close(this.fd, t);
|
|
2163
|
+
}
|
|
2164
|
+
[rs](t) {
|
|
2165
|
+
if (t <= 0 && this.remain > 0) {
|
|
2166
|
+
let r = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
|
|
2167
|
+
path: this.absolute,
|
|
2168
|
+
syscall: "read",
|
|
2169
|
+
code: "EOF"
|
|
2170
|
+
});
|
|
2171
|
+
return this[pt](() => this.emit("error", r));
|
|
2172
|
+
}
|
|
2173
|
+
if (t > this.remain) {
|
|
2174
|
+
let r = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
|
|
2175
|
+
path: this.absolute,
|
|
2176
|
+
syscall: "read",
|
|
2177
|
+
code: "EOF"
|
|
2178
|
+
});
|
|
2179
|
+
return this[pt](() => this.emit("error", r));
|
|
2180
|
+
}
|
|
2181
|
+
if (!this.buf) throw new Error("should have created buffer prior to reading");
|
|
2182
|
+
if (t === this.remain) for (let r = t; r < this.length && t < this.blockRemain; r++) this.buf[r + this.offset] = 0, t++, this.remain++;
|
|
2183
|
+
let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
|
|
2184
|
+
this.write(e) ? this[es]() : this[as](() => this[es]());
|
|
2185
|
+
}
|
|
2186
|
+
[as](t) {
|
|
2187
|
+
this.once("drain", t);
|
|
2188
|
+
}
|
|
2189
|
+
write(t, e, i) {
|
|
2190
|
+
if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
|
|
2191
|
+
let r = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
|
|
2192
|
+
return this.emit("error", r);
|
|
2193
|
+
}
|
|
2194
|
+
return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
|
|
2195
|
+
}
|
|
2196
|
+
[es]() {
|
|
2197
|
+
if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
|
|
2198
|
+
if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
|
|
2199
|
+
this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ii]();
|
|
2200
|
+
}
|
|
2201
|
+
};
|
|
2202
|
+
var ni = class extends de {
|
|
2203
|
+
sync = !0;
|
|
2204
|
+
[ss]() {
|
|
2205
|
+
this[si](I.lstatSync(this.absolute));
|
|
2206
|
+
}
|
|
2207
|
+
[is]() {
|
|
2208
|
+
this[ns](I.readlinkSync(this.absolute));
|
|
2209
|
+
}
|
|
2210
|
+
[os]() {
|
|
2211
|
+
this[hs](I.openSync(this.absolute, "r"));
|
|
2212
|
+
}
|
|
2213
|
+
[ii]() {
|
|
2214
|
+
let t = !0;
|
|
2215
|
+
try {
|
|
2216
|
+
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
2217
|
+
if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
|
|
2218
|
+
let h = I.readSync(e, i, r, n, o);
|
|
2219
|
+
this[rs](h), t = !1;
|
|
2220
|
+
} finally {
|
|
2221
|
+
if (t) try {
|
|
2222
|
+
this[pt](() => {});
|
|
2223
|
+
} catch {}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
[as](t) {
|
|
2227
|
+
t();
|
|
2228
|
+
}
|
|
2229
|
+
[pt](t = () => {}) {
|
|
2230
|
+
this.fd !== void 0 && I.closeSync(this.fd), t();
|
|
2231
|
+
}
|
|
2232
|
+
};
|
|
2233
|
+
var oi = class extends A {
|
|
2234
|
+
blockLen = 0;
|
|
2235
|
+
blockRemain = 0;
|
|
2236
|
+
buf = 0;
|
|
2237
|
+
pos = 0;
|
|
2238
|
+
remain = 0;
|
|
2239
|
+
length = 0;
|
|
2240
|
+
preservePaths;
|
|
2241
|
+
portable;
|
|
2242
|
+
strict;
|
|
2243
|
+
noPax;
|
|
2244
|
+
noMtime;
|
|
2245
|
+
readEntry;
|
|
2246
|
+
type;
|
|
2247
|
+
prefix;
|
|
2248
|
+
path;
|
|
2249
|
+
mode;
|
|
2250
|
+
uid;
|
|
2251
|
+
gid;
|
|
2252
|
+
uname;
|
|
2253
|
+
gname;
|
|
2254
|
+
header;
|
|
2255
|
+
mtime;
|
|
2256
|
+
atime;
|
|
2257
|
+
ctime;
|
|
2258
|
+
linkpath;
|
|
2259
|
+
size;
|
|
2260
|
+
onWriteEntry;
|
|
2261
|
+
warn(t, e, i = {}) {
|
|
2262
|
+
return Dt(this, t, e, i);
|
|
2263
|
+
}
|
|
2264
|
+
constructor(t, e = {}) {
|
|
2265
|
+
let i = se(e);
|
|
2266
|
+
super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
|
|
2267
|
+
let { type: r } = t;
|
|
2268
|
+
if (r === "Unsupported") throw new Error("writing entry that should be ignored");
|
|
2269
|
+
this.type = r, this.type === "Directory" && this.portable && (this.noMtime = !0), this.prefix = i.prefix, this.path = f(t.path), this.mode = t.mode !== void 0 ? this[ri](t.mode) : void 0, this.uid = this.portable ? void 0 : t.uid, this.gid = this.portable ? void 0 : t.gid, this.uname = this.portable ? void 0 : t.uname, this.gname = this.portable ? void 0 : t.gname, this.size = t.size, this.mtime = this.noMtime ? void 0 : i.mtime || t.mtime, this.atime = this.portable ? void 0 : t.atime, this.ctime = this.portable ? void 0 : t.ctime, this.linkpath = t.linkpath !== void 0 ? f(t.linkpath) : void 0, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
2270
|
+
let n = !1;
|
|
2271
|
+
if (!this.preservePaths) {
|
|
2272
|
+
let [h, a] = ce(this.path);
|
|
2273
|
+
h && typeof a == "string" && (this.path = a, n = h);
|
|
2274
|
+
}
|
|
2275
|
+
this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({
|
|
2276
|
+
path: this[q](this.path),
|
|
2277
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2278
|
+
mode: this.mode,
|
|
2279
|
+
uid: this.portable ? void 0 : this.uid,
|
|
2280
|
+
gid: this.portable ? void 0 : this.gid,
|
|
2281
|
+
size: this.size,
|
|
2282
|
+
mtime: this.noMtime ? void 0 : this.mtime,
|
|
2283
|
+
type: this.type,
|
|
2284
|
+
uname: this.portable ? void 0 : this.uname,
|
|
2285
|
+
atime: this.portable ? void 0 : this.atime,
|
|
2286
|
+
ctime: this.portable ? void 0 : this.ctime
|
|
2287
|
+
}), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, {
|
|
2288
|
+
entry: this,
|
|
2289
|
+
path: n + this.path
|
|
2290
|
+
}), this.header.encode() && !this.noPax && super.write(new ft({
|
|
2291
|
+
atime: this.portable ? void 0 : this.atime,
|
|
2292
|
+
ctime: this.portable ? void 0 : this.ctime,
|
|
2293
|
+
gid: this.portable ? void 0 : this.gid,
|
|
2294
|
+
mtime: this.noMtime ? void 0 : this.mtime,
|
|
2295
|
+
path: this[q](this.path),
|
|
2296
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2297
|
+
size: this.size,
|
|
2298
|
+
uid: this.portable ? void 0 : this.uid,
|
|
2299
|
+
uname: this.portable ? void 0 : this.uname,
|
|
2300
|
+
dev: this.portable ? void 0 : this.readEntry.dev,
|
|
2301
|
+
ino: this.portable ? void 0 : this.readEntry.ino,
|
|
2302
|
+
nlink: this.portable ? void 0 : this.readEntry.nlink
|
|
2303
|
+
}).encode());
|
|
2304
|
+
let o = this.header?.block;
|
|
2305
|
+
if (!o) throw new Error("failed to encode header");
|
|
2306
|
+
super.write(o), t.pipe(this);
|
|
2307
|
+
}
|
|
2308
|
+
[q](t) {
|
|
2309
|
+
return rr(t, this.prefix);
|
|
2310
|
+
}
|
|
2311
|
+
[ri](t) {
|
|
2312
|
+
return Ji(t, this.type === "Directory", this.portable);
|
|
2313
|
+
}
|
|
2314
|
+
write(t, e, i) {
|
|
2315
|
+
typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
|
|
2316
|
+
let r = t.length;
|
|
2317
|
+
if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
|
|
2318
|
+
return this.blockRemain -= r, super.write(t, i);
|
|
2319
|
+
}
|
|
2320
|
+
end(t, e, i) {
|
|
2321
|
+
return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
var Gn = (s) => s.isFile() ? "File" : s.isDirectory() ? "Directory" : s.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
|
|
2325
|
+
var hi = class s {
|
|
2326
|
+
tail;
|
|
2327
|
+
head;
|
|
2328
|
+
length = 0;
|
|
2329
|
+
static create(t = []) {
|
|
2330
|
+
return new s(t);
|
|
2331
|
+
}
|
|
2332
|
+
constructor(t = []) {
|
|
2333
|
+
for (let e of t) this.push(e);
|
|
2334
|
+
}
|
|
2335
|
+
*[Symbol.iterator]() {
|
|
2336
|
+
for (let t = this.head; t; t = t.next) yield t.value;
|
|
2337
|
+
}
|
|
2338
|
+
removeNode(t) {
|
|
2339
|
+
if (t.list !== this) throw new Error("removing node which does not belong to this list");
|
|
2340
|
+
let e = t.next, i = t.prev;
|
|
2341
|
+
return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = void 0, t.prev = void 0, t.list = void 0, e;
|
|
2342
|
+
}
|
|
2343
|
+
unshiftNode(t) {
|
|
2344
|
+
if (t === this.head) return;
|
|
2345
|
+
t.list && t.list.removeNode(t);
|
|
2346
|
+
let e = this.head;
|
|
2347
|
+
t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
|
|
2348
|
+
}
|
|
2349
|
+
pushNode(t) {
|
|
2350
|
+
if (t === this.tail) return;
|
|
2351
|
+
t.list && t.list.removeNode(t);
|
|
2352
|
+
let e = this.tail;
|
|
2353
|
+
t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
|
|
2354
|
+
}
|
|
2355
|
+
push(...t) {
|
|
2356
|
+
for (let e = 0, i = t.length; e < i; e++) Yn(this, t[e]);
|
|
2357
|
+
return this.length;
|
|
2358
|
+
}
|
|
2359
|
+
unshift(...t) {
|
|
2360
|
+
for (var e = 0, i = t.length; e < i; e++) Kn(this, t[e]);
|
|
2361
|
+
return this.length;
|
|
2362
|
+
}
|
|
2363
|
+
pop() {
|
|
2364
|
+
if (!this.tail) return;
|
|
2365
|
+
let t = this.tail.value, e = this.tail;
|
|
2366
|
+
return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, e.list = void 0, this.length--, t;
|
|
2367
|
+
}
|
|
2368
|
+
shift() {
|
|
2369
|
+
if (!this.head) return;
|
|
2370
|
+
let t = this.head.value, e = this.head;
|
|
2371
|
+
return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, e.list = void 0, this.length--, t;
|
|
2372
|
+
}
|
|
2373
|
+
forEach(t, e) {
|
|
2374
|
+
e = e || this;
|
|
2375
|
+
for (let i = this.head, r = 0; i; r++) t.call(e, i.value, r, this), i = i.next;
|
|
2376
|
+
}
|
|
2377
|
+
forEachReverse(t, e) {
|
|
2378
|
+
e = e || this;
|
|
2379
|
+
for (let i = this.tail, r = this.length - 1; i; r--) t.call(e, i.value, r, this), i = i.prev;
|
|
2380
|
+
}
|
|
2381
|
+
get(t) {
|
|
2382
|
+
let e = 0, i = this.head;
|
|
2383
|
+
for (; i && e < t; e++) i = i.next;
|
|
2384
|
+
if (e === t && i) return i.value;
|
|
2385
|
+
}
|
|
2386
|
+
getReverse(t) {
|
|
2387
|
+
let e = 0, i = this.tail;
|
|
2388
|
+
for (; i && e < t; e++) i = i.prev;
|
|
2389
|
+
if (e === t && i) return i.value;
|
|
2390
|
+
}
|
|
2391
|
+
map(t, e) {
|
|
2392
|
+
e = e || this;
|
|
2393
|
+
let i = new s();
|
|
2394
|
+
for (let r = this.head; r;) i.push(t.call(e, r.value, this)), r = r.next;
|
|
2395
|
+
return i;
|
|
2396
|
+
}
|
|
2397
|
+
mapReverse(t, e) {
|
|
2398
|
+
e = e || this;
|
|
2399
|
+
var i = new s();
|
|
2400
|
+
for (let r = this.tail; r;) i.push(t.call(e, r.value, this)), r = r.prev;
|
|
2401
|
+
return i;
|
|
2402
|
+
}
|
|
2403
|
+
reduce(t, e) {
|
|
2404
|
+
let i, r = this.head;
|
|
2405
|
+
if (arguments.length > 1) i = e;
|
|
2406
|
+
else if (this.head) r = this.head.next, i = this.head.value;
|
|
2407
|
+
else throw new TypeError("Reduce of empty list with no initial value");
|
|
2408
|
+
for (var n = 0; r; n++) i = t(i, r.value, n), r = r.next;
|
|
2409
|
+
return i;
|
|
2410
|
+
}
|
|
2411
|
+
reduceReverse(t, e) {
|
|
2412
|
+
let i, r = this.tail;
|
|
2413
|
+
if (arguments.length > 1) i = e;
|
|
2414
|
+
else if (this.tail) r = this.tail.prev, i = this.tail.value;
|
|
2415
|
+
else throw new TypeError("Reduce of empty list with no initial value");
|
|
2416
|
+
for (let n = this.length - 1; r; n--) i = t(i, r.value, n), r = r.prev;
|
|
2417
|
+
return i;
|
|
2418
|
+
}
|
|
2419
|
+
toArray() {
|
|
2420
|
+
let t = new Array(this.length);
|
|
2421
|
+
for (let e = 0, i = this.head; i; e++) t[e] = i.value, i = i.next;
|
|
2422
|
+
return t;
|
|
2423
|
+
}
|
|
2424
|
+
toArrayReverse() {
|
|
2425
|
+
let t = new Array(this.length);
|
|
2426
|
+
for (let e = 0, i = this.tail; i; e++) t[e] = i.value, i = i.prev;
|
|
2427
|
+
return t;
|
|
2428
|
+
}
|
|
2429
|
+
slice(t = 0, e = this.length) {
|
|
2430
|
+
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
2431
|
+
let i = new s();
|
|
2432
|
+
if (e < t || e < 0) return i;
|
|
2433
|
+
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
2434
|
+
let r = this.head, n = 0;
|
|
2435
|
+
for (n = 0; r && n < t; n++) r = r.next;
|
|
2436
|
+
for (; r && n < e; n++, r = r.next) i.push(r.value);
|
|
2437
|
+
return i;
|
|
2438
|
+
}
|
|
2439
|
+
sliceReverse(t = 0, e = this.length) {
|
|
2440
|
+
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
2441
|
+
let i = new s();
|
|
2442
|
+
if (e < t || e < 0) return i;
|
|
2443
|
+
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
2444
|
+
let r = this.length, n = this.tail;
|
|
2445
|
+
for (; n && r > e; r--) n = n.prev;
|
|
2446
|
+
for (; n && r > t; r--, n = n.prev) i.push(n.value);
|
|
2447
|
+
return i;
|
|
2448
|
+
}
|
|
2449
|
+
splice(t, e = 0, ...i) {
|
|
2450
|
+
t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
|
|
2451
|
+
let r = this.head;
|
|
2452
|
+
for (let o = 0; r && o < t; o++) r = r.next;
|
|
2453
|
+
let n = [];
|
|
2454
|
+
for (let o = 0; r && o < e; o++) n.push(r.value), r = this.removeNode(r);
|
|
2455
|
+
r ? r !== this.tail && (r = r.prev) : r = this.tail;
|
|
2456
|
+
for (let o of i) r = Zn(this, r, o);
|
|
2457
|
+
return n;
|
|
2458
|
+
}
|
|
2459
|
+
reverse() {
|
|
2460
|
+
let t = this.head, e = this.tail;
|
|
2461
|
+
for (let i = t; i; i = i.prev) {
|
|
2462
|
+
let r = i.prev;
|
|
2463
|
+
i.prev = i.next, i.next = r;
|
|
2464
|
+
}
|
|
2465
|
+
return this.head = e, this.tail = t, this;
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
function Zn(s, t, e) {
|
|
2469
|
+
let n = new ue(e, t, t ? t.next : s.head, s);
|
|
2470
|
+
return n.next === void 0 && (s.tail = n), n.prev === void 0 && (s.head = n), s.length++, n;
|
|
2471
|
+
}
|
|
2472
|
+
function Yn(s, t) {
|
|
2473
|
+
s.tail = new ue(t, s.tail, void 0, s), s.head || (s.head = s.tail), s.length++;
|
|
2474
|
+
}
|
|
2475
|
+
function Kn(s, t) {
|
|
2476
|
+
s.head = new ue(t, void 0, s.head, s), s.tail || (s.tail = s.head), s.length++;
|
|
2477
|
+
}
|
|
2478
|
+
var ue = class {
|
|
2479
|
+
list;
|
|
2480
|
+
next;
|
|
2481
|
+
prev;
|
|
2482
|
+
value;
|
|
2483
|
+
constructor(t, e, i, r) {
|
|
2484
|
+
this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = void 0, i ? (i.prev = this, this.next = i) : this.next = void 0;
|
|
2485
|
+
}
|
|
2486
|
+
};
|
|
2487
|
+
var pi = class {
|
|
2488
|
+
path;
|
|
2489
|
+
absolute;
|
|
2490
|
+
entry;
|
|
2491
|
+
stat;
|
|
2492
|
+
readdir;
|
|
2493
|
+
pending = !1;
|
|
2494
|
+
pendingLink = !1;
|
|
2495
|
+
ignore = !1;
|
|
2496
|
+
piped = !1;
|
|
2497
|
+
constructor(t, e) {
|
|
2498
|
+
this.path = t || "./", this.absolute = e;
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
var nr = Buffer.alloc(1024);
|
|
2502
|
+
var li = Symbol("onStat");
|
|
2503
|
+
var me = Symbol("ended");
|
|
2504
|
+
var W = Symbol("queue");
|
|
2505
|
+
var pe = Symbol("pendingLinks");
|
|
2506
|
+
var Et = Symbol("current");
|
|
2507
|
+
var Ft = Symbol("process");
|
|
2508
|
+
var Ee = Symbol("processing");
|
|
2509
|
+
var ai = Symbol("processJob");
|
|
2510
|
+
var G = Symbol("jobs");
|
|
2511
|
+
var ls = Symbol("jobDone");
|
|
2512
|
+
var ci = Symbol("addFSEntry");
|
|
2513
|
+
var or = Symbol("addTarEntry");
|
|
2514
|
+
var ds = Symbol("stat");
|
|
2515
|
+
var us = Symbol("readdir");
|
|
2516
|
+
var fi = Symbol("onreaddir");
|
|
2517
|
+
var di = Symbol("pipe");
|
|
2518
|
+
var hr = Symbol("entry");
|
|
2519
|
+
var cs = Symbol("entryOpt");
|
|
2520
|
+
var ui = Symbol("writeEntryClass");
|
|
2521
|
+
var lr = Symbol("write");
|
|
2522
|
+
var fs = Symbol("ondrain");
|
|
2523
|
+
var wt = class extends A {
|
|
2524
|
+
sync = !1;
|
|
2525
|
+
opt;
|
|
2526
|
+
cwd;
|
|
2527
|
+
maxReadSize;
|
|
2528
|
+
preservePaths;
|
|
2529
|
+
strict;
|
|
2530
|
+
noPax;
|
|
2531
|
+
prefix;
|
|
2532
|
+
linkCache;
|
|
2533
|
+
statCache;
|
|
2534
|
+
file;
|
|
2535
|
+
portable;
|
|
2536
|
+
zip;
|
|
2537
|
+
readdirCache;
|
|
2538
|
+
noDirRecurse;
|
|
2539
|
+
follow;
|
|
2540
|
+
noMtime;
|
|
2541
|
+
mtime;
|
|
2542
|
+
filter;
|
|
2543
|
+
jobs;
|
|
2544
|
+
[ui];
|
|
2545
|
+
onWriteEntry;
|
|
2546
|
+
[W];
|
|
2547
|
+
[pe] = /* @__PURE__ */ new Map();
|
|
2548
|
+
[G] = 0;
|
|
2549
|
+
[Ee] = !1;
|
|
2550
|
+
[me] = !1;
|
|
2551
|
+
constructor(t = {}) {
|
|
2552
|
+
if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[ui] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
|
|
2553
|
+
if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
|
|
2554
|
+
if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new ze(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new We(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ye(t.zstd)), !this.zip) throw new Error("impossible");
|
|
2555
|
+
let e = this.zip;
|
|
2556
|
+
e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[fs]()), this.on("resume", () => e.resume());
|
|
2557
|
+
} else this.on("drain", this[fs]);
|
|
2558
|
+
this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => !0, this[W] = new hi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[Ee] = !1, this[me] = !1;
|
|
2559
|
+
}
|
|
2560
|
+
[lr](t) {
|
|
2561
|
+
return super.write(t);
|
|
2562
|
+
}
|
|
2563
|
+
add(t) {
|
|
2564
|
+
return this.write(t), this;
|
|
2565
|
+
}
|
|
2566
|
+
end(t, e, i) {
|
|
2567
|
+
return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[me] = !0, this[Ft](), i && i(), this;
|
|
2568
|
+
}
|
|
2569
|
+
write(t) {
|
|
2570
|
+
if (this[me]) throw new Error("write after end");
|
|
2571
|
+
return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
|
|
2572
|
+
}
|
|
2573
|
+
[or](t) {
|
|
2574
|
+
let e = f(ar.resolve(this.cwd, t.path));
|
|
2575
|
+
if (!this.filter(t.path, t)) t.resume();
|
|
2576
|
+
else {
|
|
2577
|
+
let i = new pi(t.path, e);
|
|
2578
|
+
i.entry = new oi(t, this[cs](i)), i.entry.on("end", () => this[ls](i)), this[G] += 1, this[W].push(i);
|
|
2579
|
+
}
|
|
2580
|
+
this[Ft]();
|
|
2581
|
+
}
|
|
2582
|
+
[ci](t) {
|
|
2583
|
+
let e = f(ar.resolve(this.cwd, t));
|
|
2584
|
+
this[W].push(new pi(t, e)), this[Ft]();
|
|
2585
|
+
}
|
|
2586
|
+
[ds](t) {
|
|
2587
|
+
t.pending = !0, this[G] += 1;
|
|
2588
|
+
let e = this.follow ? "stat" : "lstat";
|
|
2589
|
+
I[e](t.absolute, (i, r) => {
|
|
2590
|
+
t.pending = !1, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
[li](t, e) {
|
|
2594
|
+
if (this.statCache.set(t.absolute, e), t.stat = e, !this.filter(t.path, e)) t.ignore = !0;
|
|
2595
|
+
else if (e.isFile() && e.nlink > 1 && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync) if (t === this[Et]) this[ai](t);
|
|
2596
|
+
else {
|
|
2597
|
+
let i = `${e.dev}:${e.ino}`, r = this[pe].get(i);
|
|
2598
|
+
r ? r.push(t) : this[pe].set(i, [t]), t.pendingLink = !0, t.pending = !0;
|
|
2599
|
+
}
|
|
2600
|
+
this[Ft]();
|
|
2601
|
+
}
|
|
2602
|
+
[us](t) {
|
|
2603
|
+
t.pending = !0, this[G] += 1, I.readdir(t.absolute, (e, i) => {
|
|
2604
|
+
if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
|
|
2605
|
+
this[fi](t, i);
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
[fi](t, e) {
|
|
2609
|
+
this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ft]();
|
|
2610
|
+
}
|
|
2611
|
+
[Ft]() {
|
|
2612
|
+
if (!this[Ee]) {
|
|
2613
|
+
this[Ee] = !0;
|
|
2614
|
+
for (let t = this[W].head; t && this[G] < this.jobs; t = t.next) if (this[ai](t.value), t.value.ignore) {
|
|
2615
|
+
let e = t.next;
|
|
2616
|
+
this[W].removeNode(t), t.next = e;
|
|
2617
|
+
}
|
|
2618
|
+
this[Ee] = !1, this[me] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(nr) : (super.write(nr), super.end()));
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
get [Et]() {
|
|
2622
|
+
return this[W] && this[W].head && this[W].head.value;
|
|
2623
|
+
}
|
|
2624
|
+
[ls](t) {
|
|
2625
|
+
this[W].shift(), this[G] -= 1;
|
|
2626
|
+
let { stat: e } = t;
|
|
2627
|
+
if (e && e.isFile() && e.nlink > 1) {
|
|
2628
|
+
let i = `${e.dev}:${e.ino}`, r = this[pe].get(i);
|
|
2629
|
+
if (r) {
|
|
2630
|
+
this[pe].delete(i);
|
|
2631
|
+
for (let n of r) n.pending = !1, this[ai](n);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
this[Ft]();
|
|
2635
|
+
}
|
|
2636
|
+
[ai](t) {
|
|
2637
|
+
if (t.pending && t.pendingLink && t === this[Et] && (t.pending = !1, t.pendingLink = !1), !t.pending) {
|
|
2638
|
+
if (t.entry) {
|
|
2639
|
+
t === this[Et] && !t.piped && this[di](t);
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
if (!t.stat) {
|
|
2643
|
+
let e = this.statCache.get(t.absolute);
|
|
2644
|
+
e ? this[li](t, e) : this[ds](t);
|
|
2645
|
+
}
|
|
2646
|
+
if (t.stat && !t.ignore) {
|
|
2647
|
+
if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
|
|
2648
|
+
let e = this.readdirCache.get(t.absolute);
|
|
2649
|
+
if (e ? this[fi](t, e) : this[us](t), !t.readdir) return;
|
|
2650
|
+
}
|
|
2651
|
+
if (t.entry = this[hr](t), !t.entry) {
|
|
2652
|
+
t.ignore = !0;
|
|
2653
|
+
return;
|
|
2654
|
+
}
|
|
2655
|
+
t === this[Et] && !t.piped && this[di](t);
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
[cs](t) {
|
|
2660
|
+
return {
|
|
2661
|
+
onwarn: (e, i, r) => this.warn(e, i, r),
|
|
2662
|
+
noPax: this.noPax,
|
|
2663
|
+
cwd: this.cwd,
|
|
2664
|
+
absolute: t.absolute,
|
|
2665
|
+
preservePaths: this.preservePaths,
|
|
2666
|
+
maxReadSize: this.maxReadSize,
|
|
2667
|
+
strict: this.strict,
|
|
2668
|
+
portable: this.portable,
|
|
2669
|
+
linkCache: this.linkCache,
|
|
2670
|
+
statCache: this.statCache,
|
|
2671
|
+
noMtime: this.noMtime,
|
|
2672
|
+
mtime: this.mtime,
|
|
2673
|
+
prefix: this.prefix,
|
|
2674
|
+
onWriteEntry: this.onWriteEntry
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
[hr](t) {
|
|
2678
|
+
this[G] += 1;
|
|
2679
|
+
try {
|
|
2680
|
+
return new this[ui](t.path, this[cs](t)).on("end", () => this[ls](t)).on("error", (i) => this.emit("error", i));
|
|
2681
|
+
} catch (e) {
|
|
2682
|
+
this.emit("error", e);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
[fs]() {
|
|
2686
|
+
this[Et] && this[Et].entry && this[Et].entry.resume();
|
|
2687
|
+
}
|
|
2688
|
+
[di](t) {
|
|
2689
|
+
t.piped = !0, t.readdir && t.readdir.forEach((r) => {
|
|
2690
|
+
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2691
|
+
this[ci](o + r);
|
|
2692
|
+
});
|
|
2693
|
+
let e = t.entry, i = this.zip;
|
|
2694
|
+
if (!e) throw new Error("cannot pipe without source");
|
|
2695
|
+
i ? e.on("data", (r) => {
|
|
2696
|
+
i.write(r) || e.pause();
|
|
2697
|
+
}) : e.on("data", (r) => {
|
|
2698
|
+
super.write(r) || e.pause();
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
pause() {
|
|
2702
|
+
return this.zip && this.zip.pause(), super.pause();
|
|
2703
|
+
}
|
|
2704
|
+
warn(t, e, i = {}) {
|
|
2705
|
+
Dt(this, t, e, i);
|
|
2706
|
+
}
|
|
2707
|
+
};
|
|
2708
|
+
var kt = class extends wt {
|
|
2709
|
+
sync = !0;
|
|
2710
|
+
constructor(t) {
|
|
2711
|
+
super(t), this[ui] = ni;
|
|
2712
|
+
}
|
|
2713
|
+
pause() {}
|
|
2714
|
+
resume() {}
|
|
2715
|
+
[ds](t) {
|
|
2716
|
+
let e = this.follow ? "statSync" : "lstatSync";
|
|
2717
|
+
this[li](t, I[e](t.absolute));
|
|
2718
|
+
}
|
|
2719
|
+
[us](t) {
|
|
2720
|
+
this[fi](t, I.readdirSync(t.absolute));
|
|
2721
|
+
}
|
|
2722
|
+
[di](t) {
|
|
2723
|
+
let e = t.entry, i = this.zip;
|
|
2724
|
+
if (t.readdir && t.readdir.forEach((r) => {
|
|
2725
|
+
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2726
|
+
this[ci](o + r);
|
|
2727
|
+
}), !e) throw new Error("Cannot pipe without source");
|
|
2728
|
+
i ? e.on("data", (r) => {
|
|
2729
|
+
i.write(r);
|
|
2730
|
+
}) : e.on("data", (r) => {
|
|
2731
|
+
super[lr](r);
|
|
2732
|
+
});
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
var Vn = (s, t) => {
|
|
2736
|
+
let e = new kt(s), i = new Wt(s.file, { mode: s.mode || 438 });
|
|
2737
|
+
e.pipe(i), fr(e, t);
|
|
2738
|
+
};
|
|
2739
|
+
var $n = (s, t) => {
|
|
2740
|
+
let e = new wt(s), i = new et(s.file, { mode: s.mode || 438 });
|
|
2741
|
+
e.pipe(i);
|
|
2742
|
+
let r = new Promise((n, o) => {
|
|
2743
|
+
i.on("error", o), i.on("close", n), e.on("error", o);
|
|
2744
|
+
});
|
|
2745
|
+
return dr(e, t).catch((n) => e.emit("error", n)), r;
|
|
2746
|
+
};
|
|
2747
|
+
var fr = (s, t) => {
|
|
2748
|
+
t.forEach((e) => {
|
|
2749
|
+
e.charAt(0) === "@" ? Ct({
|
|
2750
|
+
file: path.resolve(s.cwd, e.slice(1)),
|
|
2751
|
+
sync: !0,
|
|
2752
|
+
noResume: !0,
|
|
2753
|
+
onReadEntry: (i) => s.add(i)
|
|
2754
|
+
}) : s.add(e);
|
|
2755
|
+
}), s.end();
|
|
2756
|
+
};
|
|
2757
|
+
var dr = async (s, t) => {
|
|
2758
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({
|
|
2759
|
+
file: path.resolve(String(s.cwd), e.slice(1)),
|
|
2760
|
+
noResume: !0,
|
|
2761
|
+
onReadEntry: (i) => {
|
|
2762
|
+
s.add(i);
|
|
2763
|
+
}
|
|
2764
|
+
}) : s.add(e);
|
|
2765
|
+
s.end();
|
|
2766
|
+
};
|
|
2767
|
+
var Xn = (s, t) => {
|
|
2768
|
+
let e = new kt(s);
|
|
2769
|
+
return fr(e, t), e;
|
|
2770
|
+
};
|
|
2771
|
+
var qn = (s, t) => {
|
|
2772
|
+
let e = new wt(s);
|
|
2773
|
+
return dr(e, t).catch((i) => e.emit("error", i)), e;
|
|
2774
|
+
};
|
|
2775
|
+
var Qn = K(Vn, $n, Xn, qn, (s, t) => {
|
|
2776
|
+
if (!t?.length) throw new TypeError("no paths specified to add to archive");
|
|
2777
|
+
});
|
|
2778
|
+
var Er = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: wr, O_NOFOLLOW: ur, O_TRUNC: Sr, O_WRONLY: yr } = I.constants, Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, jn = Er && !!Rr, to = 524288, eo = Rr | Sr | wr | yr, mr = !Er && typeof ur == "number" ? ur | Sr | wr | yr : null, ms = mr !== null ? () => mr : jn ? (s) => s < to ? eo : "w" : () => "w";
|
|
2779
|
+
var ps = (s, t, e) => {
|
|
2780
|
+
try {
|
|
2781
|
+
return Br.lchownSync(s, t, e);
|
|
2782
|
+
} catch (i) {
|
|
2783
|
+
if (i?.code !== "ENOENT") throw i;
|
|
2784
|
+
}
|
|
2785
|
+
};
|
|
2786
|
+
var Ei = (s, t, e, i) => {
|
|
2787
|
+
Br.lchown(s, t, e, (r) => {
|
|
2788
|
+
i(r && r?.code !== "ENOENT" ? r : null);
|
|
2789
|
+
});
|
|
2790
|
+
};
|
|
2791
|
+
var io = (s, t, e, i, r) => {
|
|
2792
|
+
if (t.isDirectory()) Es(path.resolve(s, t.name), e, i, (n) => {
|
|
2793
|
+
if (n) return r(n);
|
|
2794
|
+
Ei(path.resolve(s, t.name), e, i, r);
|
|
2795
|
+
});
|
|
2796
|
+
else Ei(path.resolve(s, t.name), e, i, r);
|
|
2797
|
+
};
|
|
2798
|
+
var Es = (s, t, e, i) => {
|
|
2799
|
+
Br.readdir(s, { withFileTypes: !0 }, (r, n) => {
|
|
2800
|
+
if (r) {
|
|
2801
|
+
if (r.code === "ENOENT") return i();
|
|
2802
|
+
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
2803
|
+
}
|
|
2804
|
+
if (r || !n.length) return Ei(s, t, e, i);
|
|
2805
|
+
let o = n.length, h = null, a = (l) => {
|
|
2806
|
+
if (!h) {
|
|
2807
|
+
if (l) return i(h = l);
|
|
2808
|
+
if (--o === 0) return Ei(s, t, e, i);
|
|
2809
|
+
}
|
|
2810
|
+
};
|
|
2811
|
+
for (let l of n) io(s, l, t, e, a);
|
|
2812
|
+
});
|
|
2813
|
+
};
|
|
2814
|
+
var so = (s, t, e, i) => {
|
|
2815
|
+
t.isDirectory() && ws(path.resolve(s, t.name), e, i), ps(path.resolve(s, t.name), e, i);
|
|
2816
|
+
};
|
|
2817
|
+
var ws = (s, t, e) => {
|
|
2818
|
+
let i;
|
|
2819
|
+
try {
|
|
2820
|
+
i = Br.readdirSync(s, { withFileTypes: !0 });
|
|
2821
|
+
} catch (r) {
|
|
2822
|
+
let n = r;
|
|
2823
|
+
if (n?.code === "ENOENT") return;
|
|
2824
|
+
if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return ps(s, t, e);
|
|
2825
|
+
throw n;
|
|
2826
|
+
}
|
|
2827
|
+
for (let r of i) so(s, r, t, e);
|
|
2828
|
+
return ps(s, t, e);
|
|
2829
|
+
};
|
|
2830
|
+
var Se = class extends Error {
|
|
2831
|
+
path;
|
|
2832
|
+
code;
|
|
2833
|
+
syscall = "chdir";
|
|
2834
|
+
constructor(t, e) {
|
|
2835
|
+
super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
|
|
2836
|
+
}
|
|
2837
|
+
get name() {
|
|
2838
|
+
return "CwdError";
|
|
2839
|
+
}
|
|
2840
|
+
};
|
|
2841
|
+
var St = class extends Error {
|
|
2842
|
+
path;
|
|
2843
|
+
symlink;
|
|
2844
|
+
syscall = "symlink";
|
|
2845
|
+
code = "TAR_SYMLINK_ERROR";
|
|
2846
|
+
constructor(t, e) {
|
|
2847
|
+
super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
|
|
2848
|
+
}
|
|
2849
|
+
get name() {
|
|
2850
|
+
return "SymlinkError";
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
var no = (s, t) => {
|
|
2854
|
+
Br.stat(s, (e, i) => {
|
|
2855
|
+
(e || !i.isDirectory()) && (e = new Se(s, e?.code || "ENOTDIR")), t(e);
|
|
2856
|
+
});
|
|
2857
|
+
};
|
|
2858
|
+
var gr = (s, t, e) => {
|
|
2859
|
+
s = f(s);
|
|
2860
|
+
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), y = (E, x) => {
|
|
2861
|
+
E ? e(E) : x && a ? Es(x, o, h, (Le) => y(Le)) : n ? Br.chmod(s, r, e) : e();
|
|
2862
|
+
};
|
|
2863
|
+
if (s === d) return no(s, y);
|
|
2864
|
+
if (l) return ro.mkdir(s, {
|
|
2865
|
+
mode: r,
|
|
2866
|
+
recursive: !0
|
|
2867
|
+
}).then((E) => y(null, E ?? void 0), y);
|
|
2868
|
+
Ss(d, f(path.relative(d, s)).split("/"), r, c, d, void 0, y);
|
|
2869
|
+
};
|
|
2870
|
+
var Ss = (s, t, e, i, r, n, o) => {
|
|
2871
|
+
if (t.length === 0) return o(null, n);
|
|
2872
|
+
let h = t.shift(), a = f(path.resolve(s + "/" + h));
|
|
2873
|
+
Br.mkdir(a, e, br(a, t, e, i, r, n, o));
|
|
2874
|
+
};
|
|
2875
|
+
var br = (s, t, e, i, r, n, o) => (h) => {
|
|
2876
|
+
h ? Br.lstat(s, (a, l) => {
|
|
2877
|
+
if (a) a.path = a.path && f(a.path), o(a);
|
|
2878
|
+
else if (l.isDirectory()) Ss(s, t, e, i, r, n, o);
|
|
2879
|
+
else if (i) Br.unlink(s, (c) => {
|
|
2880
|
+
if (c) return o(c);
|
|
2881
|
+
Br.mkdir(s, e, br(s, t, e, i, r, n, o));
|
|
2882
|
+
});
|
|
2883
|
+
else {
|
|
2884
|
+
if (l.isSymbolicLink()) return o(new St(s, s + "/" + t.join("/")));
|
|
2885
|
+
o(h);
|
|
2886
|
+
}
|
|
2887
|
+
}) : (n = n || s, Ss(s, t, e, i, r, n, o));
|
|
2888
|
+
};
|
|
2889
|
+
var oo = (s) => {
|
|
2890
|
+
let t = !1, e;
|
|
2891
|
+
try {
|
|
2892
|
+
t = Br.statSync(s).isDirectory();
|
|
2893
|
+
} catch (i) {
|
|
2894
|
+
e = i?.code;
|
|
2895
|
+
} finally {
|
|
2896
|
+
if (!t) throw new Se(s, e ?? "ENOTDIR");
|
|
2897
|
+
}
|
|
2898
|
+
};
|
|
2899
|
+
var _r = (s, t) => {
|
|
2900
|
+
s = f(s);
|
|
2901
|
+
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
|
|
2902
|
+
E && h && ws(E, n, o), r && Br.chmodSync(s, i);
|
|
2903
|
+
};
|
|
2904
|
+
if (s === c) return oo(c), d();
|
|
2905
|
+
if (a) return d(Br.mkdirSync(s, {
|
|
2906
|
+
mode: i,
|
|
2907
|
+
recursive: !0
|
|
2908
|
+
}) ?? void 0);
|
|
2909
|
+
let T = f(path.relative(c, s)).split("/"), D;
|
|
2910
|
+
for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
|
|
2911
|
+
x = f(path.resolve(x));
|
|
2912
|
+
try {
|
|
2913
|
+
Br.mkdirSync(x, i), D = D || x;
|
|
2914
|
+
} catch {
|
|
2915
|
+
let Le = Br.lstatSync(x);
|
|
2916
|
+
if (Le.isDirectory()) continue;
|
|
2917
|
+
if (l) {
|
|
2918
|
+
Br.unlinkSync(x), Br.mkdirSync(x, i), D = D || x;
|
|
2919
|
+
continue;
|
|
2920
|
+
} else if (Le.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
return d(D);
|
|
2924
|
+
};
|
|
2925
|
+
var ys = Object.create(null);
|
|
2926
|
+
var Or = 1e4;
|
|
2927
|
+
var Vt = /* @__PURE__ */ new Set();
|
|
2928
|
+
var Tr = (s) => {
|
|
2929
|
+
Vt.has(s) ? Vt.delete(s) : ys[s] = s.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), Vt.add(s);
|
|
2930
|
+
let t = ys[s], e = Vt.size - Or;
|
|
2931
|
+
if (e > Or / 10) {
|
|
2932
|
+
for (let i of Vt) if (Vt.delete(i), delete ys[i], --e <= 0) break;
|
|
2933
|
+
}
|
|
2934
|
+
return t;
|
|
2935
|
+
};
|
|
2936
|
+
var ao = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
|
|
2937
|
+
var lo = (s) => s.split("/").slice(0, -1).reduce((e, i) => {
|
|
2938
|
+
let r = e.at(-1);
|
|
2939
|
+
return r !== void 0 && (i = join(r, i)), e.push(i || "/"), e;
|
|
2940
|
+
}, []);
|
|
2941
|
+
var yi = class {
|
|
2942
|
+
#t = /* @__PURE__ */ new Map();
|
|
2943
|
+
#i = /* @__PURE__ */ new Map();
|
|
2944
|
+
#s = /* @__PURE__ */ new Set();
|
|
2945
|
+
reserve(t, e) {
|
|
2946
|
+
t = ao ? ["win32 parallelization disabled"] : t.map((r) => mt(join(Tr(r))));
|
|
2947
|
+
let i = new Set(t.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
|
|
2948
|
+
this.#i.set(e, {
|
|
2949
|
+
dirs: i,
|
|
2950
|
+
paths: t
|
|
2951
|
+
});
|
|
2952
|
+
for (let r of t) {
|
|
2953
|
+
let n = this.#t.get(r);
|
|
2954
|
+
n ? n.push(e) : this.#t.set(r, [e]);
|
|
2955
|
+
}
|
|
2956
|
+
for (let r of i) {
|
|
2957
|
+
let n = this.#t.get(r);
|
|
2958
|
+
if (!n) this.#t.set(r, [/* @__PURE__ */ new Set([e])]);
|
|
2959
|
+
else {
|
|
2960
|
+
let o = n.at(-1);
|
|
2961
|
+
o instanceof Set ? o.add(e) : n.push(/* @__PURE__ */ new Set([e]));
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
return this.#r(e);
|
|
2965
|
+
}
|
|
2966
|
+
#n(t) {
|
|
2967
|
+
let e = this.#i.get(t);
|
|
2968
|
+
if (!e) throw new Error("function does not have any path reservations");
|
|
2969
|
+
return {
|
|
2970
|
+
paths: e.paths.map((i) => this.#t.get(i)),
|
|
2971
|
+
dirs: [...e.dirs].map((i) => this.#t.get(i))
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
check(t) {
|
|
2975
|
+
let { paths: e, dirs: i } = this.#n(t);
|
|
2976
|
+
return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
|
|
2977
|
+
}
|
|
2978
|
+
#r(t) {
|
|
2979
|
+
return this.#s.has(t) || !this.check(t) ? !1 : (this.#s.add(t), t(() => this.#e(t)), !0);
|
|
2980
|
+
}
|
|
2981
|
+
#e(t) {
|
|
2982
|
+
if (!this.#s.has(t)) return !1;
|
|
2983
|
+
let e = this.#i.get(t);
|
|
2984
|
+
if (!e) throw new Error("invalid reservation");
|
|
2985
|
+
let { paths: i, dirs: r } = e, n = /* @__PURE__ */ new Set();
|
|
2986
|
+
for (let o of i) {
|
|
2987
|
+
let h = this.#t.get(o);
|
|
2988
|
+
if (!h || h?.[0] !== t) continue;
|
|
2989
|
+
let a = h[1];
|
|
2990
|
+
if (!a) {
|
|
2991
|
+
this.#t.delete(o);
|
|
2992
|
+
continue;
|
|
2993
|
+
}
|
|
2994
|
+
if (h.shift(), typeof a == "function") n.add(a);
|
|
2995
|
+
else for (let l of a) n.add(l);
|
|
2996
|
+
}
|
|
2997
|
+
for (let o of r) {
|
|
2998
|
+
let h = this.#t.get(o), a = h?.[0];
|
|
2999
|
+
if (!(!h || !(a instanceof Set))) if (a.size === 1 && h.length === 1) {
|
|
3000
|
+
this.#t.delete(o);
|
|
3001
|
+
continue;
|
|
3002
|
+
} else if (a.size === 1) {
|
|
3003
|
+
h.shift();
|
|
3004
|
+
let l = h[0];
|
|
3005
|
+
typeof l == "function" && n.add(l);
|
|
3006
|
+
} else a.delete(t);
|
|
3007
|
+
}
|
|
3008
|
+
return this.#s.delete(t), n.forEach((o) => this.#r(o)), !0;
|
|
3009
|
+
}
|
|
3010
|
+
};
|
|
3011
|
+
var Lr = () => process.umask();
|
|
3012
|
+
var Dr = Symbol("onEntry");
|
|
3013
|
+
var _s = Symbol("checkFs");
|
|
3014
|
+
var Nr = Symbol("checkFs2");
|
|
3015
|
+
var Os = Symbol("isReusable");
|
|
3016
|
+
var P = Symbol("makeFs");
|
|
3017
|
+
var Ts = Symbol("file");
|
|
3018
|
+
var xs = Symbol("directory");
|
|
3019
|
+
var gi = Symbol("link");
|
|
3020
|
+
var Ar = Symbol("symlink");
|
|
3021
|
+
var Ir = Symbol("hardlink");
|
|
3022
|
+
var Re = Symbol("ensureNoSymlink");
|
|
3023
|
+
var Cr = Symbol("unsupported");
|
|
3024
|
+
var Fr = Symbol("checkPath");
|
|
3025
|
+
var Rs = Symbol("stripAbsolutePath");
|
|
3026
|
+
var yt = Symbol("mkdir");
|
|
3027
|
+
var O = Symbol("onError");
|
|
3028
|
+
var Ri = Symbol("pending");
|
|
3029
|
+
var kr = Symbol("pend");
|
|
3030
|
+
var $t = Symbol("unpend");
|
|
3031
|
+
var gs = Symbol("ended");
|
|
3032
|
+
var bs = Symbol("maybeClose");
|
|
3033
|
+
var Ls = Symbol("skip");
|
|
3034
|
+
var ge = Symbol("doChown");
|
|
3035
|
+
var be = Symbol("uid");
|
|
3036
|
+
var _e = Symbol("gid");
|
|
3037
|
+
var Oe = Symbol("checkedCwd");
|
|
3038
|
+
var Te = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32";
|
|
3039
|
+
var uo = 1024;
|
|
3040
|
+
var mo = (s, t) => {
|
|
3041
|
+
if (!Te) return Br.unlink(s, t);
|
|
3042
|
+
let e = s + ".DELETE." + randomBytes(16).toString("hex");
|
|
3043
|
+
Br.rename(s, e, (i) => {
|
|
3044
|
+
if (i) return t(i);
|
|
3045
|
+
Br.unlink(e, t);
|
|
3046
|
+
});
|
|
3047
|
+
};
|
|
3048
|
+
var po = (s) => {
|
|
3049
|
+
if (!Te) return Br.unlinkSync(s);
|
|
3050
|
+
let t = s + ".DELETE." + randomBytes(16).toString("hex");
|
|
3051
|
+
Br.renameSync(s, t), Br.unlinkSync(t);
|
|
3052
|
+
};
|
|
3053
|
+
var vr = (s, t, e) => s !== void 0 && s === s >>> 0 ? s : t !== void 0 && t === t >>> 0 ? t : e;
|
|
3054
|
+
var Xt = class extends rt {
|
|
3055
|
+
[gs] = !1;
|
|
3056
|
+
[Oe] = !1;
|
|
3057
|
+
[Ri] = 0;
|
|
3058
|
+
reservations = new yi();
|
|
3059
|
+
transform;
|
|
3060
|
+
writable = !0;
|
|
3061
|
+
readable = !1;
|
|
3062
|
+
uid;
|
|
3063
|
+
gid;
|
|
3064
|
+
setOwner;
|
|
3065
|
+
preserveOwner;
|
|
3066
|
+
processGid;
|
|
3067
|
+
processUid;
|
|
3068
|
+
maxDepth;
|
|
3069
|
+
forceChown;
|
|
3070
|
+
win32;
|
|
3071
|
+
newer;
|
|
3072
|
+
keep;
|
|
3073
|
+
noMtime;
|
|
3074
|
+
preservePaths;
|
|
3075
|
+
unlink;
|
|
3076
|
+
cwd;
|
|
3077
|
+
strip;
|
|
3078
|
+
processUmask;
|
|
3079
|
+
umask;
|
|
3080
|
+
dmode;
|
|
3081
|
+
fmode;
|
|
3082
|
+
chmod;
|
|
3083
|
+
constructor(t = {}) {
|
|
3084
|
+
if (t.ondone = () => {
|
|
3085
|
+
this[gs] = !0, this[bs]();
|
|
3086
|
+
}, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
|
|
3087
|
+
if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
|
|
3088
|
+
if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
3089
|
+
this.uid = t.uid, this.gid = t.gid, this.setOwner = !0;
|
|
3090
|
+
} else this.uid = void 0, this.gid = void 0, this.setOwner = !1;
|
|
3091
|
+
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : uo, this.forceChown = t.forceChown === !0, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(path.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
|
|
3092
|
+
}
|
|
3093
|
+
warn(t, e, i = {}) {
|
|
3094
|
+
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = !1), super.warn(t, e, i);
|
|
3095
|
+
}
|
|
3096
|
+
[bs]() {
|
|
3097
|
+
this[gs] && this[Ri] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
|
|
3098
|
+
}
|
|
3099
|
+
[Rs](t, e) {
|
|
3100
|
+
let i = t[e], { type: r } = t;
|
|
3101
|
+
if (!i || this.preservePaths) return !0;
|
|
3102
|
+
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
3103
|
+
if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
3104
|
+
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, {
|
|
3105
|
+
entry: t,
|
|
3106
|
+
[e]: i
|
|
3107
|
+
}), !1;
|
|
3108
|
+
let a = path.posix.dirname(t.path), l = path.posix.normalize(path.posix.join(a, h.join("/")));
|
|
3109
|
+
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, {
|
|
3110
|
+
entry: t,
|
|
3111
|
+
[e]: i
|
|
3112
|
+
}), !1;
|
|
3113
|
+
}
|
|
3114
|
+
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, {
|
|
3115
|
+
entry: t,
|
|
3116
|
+
[e]: i
|
|
3117
|
+
})), !0;
|
|
3118
|
+
}
|
|
3119
|
+
[Fr](t) {
|
|
3120
|
+
let e = f(t.path), i = e.split("/");
|
|
3121
|
+
if (this.strip) {
|
|
3122
|
+
if (i.length < this.strip) return !1;
|
|
3123
|
+
if (t.type === "Link") {
|
|
3124
|
+
let r = f(String(t.linkpath)).split("/");
|
|
3125
|
+
if (r.length >= this.strip) t.linkpath = r.slice(this.strip).join("/");
|
|
3126
|
+
else return !1;
|
|
3127
|
+
}
|
|
3128
|
+
i.splice(0, this.strip), t.path = i.join("/");
|
|
3129
|
+
}
|
|
3130
|
+
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
|
|
3131
|
+
entry: t,
|
|
3132
|
+
path: e,
|
|
3133
|
+
depth: i.length,
|
|
3134
|
+
maxDepth: this.maxDepth
|
|
3135
|
+
}), !1;
|
|
3136
|
+
if (!this[Rs](t, "path") || !this[Rs](t, "linkpath")) return !1;
|
|
3137
|
+
if (t.absolute = path.isAbsolute(t.path) ? f(path.resolve(t.path)) : f(path.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
|
|
3138
|
+
entry: t,
|
|
3139
|
+
path: f(t.path),
|
|
3140
|
+
resolvedPath: t.absolute,
|
|
3141
|
+
cwd: this.cwd
|
|
3142
|
+
}), !1;
|
|
3143
|
+
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return !1;
|
|
3144
|
+
if (this.win32) {
|
|
3145
|
+
let { root: r } = path.win32.parse(String(t.absolute));
|
|
3146
|
+
t.absolute = r + ts(String(t.absolute).slice(r.length));
|
|
3147
|
+
let { root: n } = path.win32.parse(t.path);
|
|
3148
|
+
t.path = n + ts(t.path.slice(n.length));
|
|
3149
|
+
}
|
|
3150
|
+
return !0;
|
|
3151
|
+
}
|
|
3152
|
+
[Dr](t) {
|
|
3153
|
+
if (!this[Fr](t)) return t.resume();
|
|
3154
|
+
switch (co.equal(typeof t.absolute, "string"), t.type) {
|
|
3155
|
+
case "Directory":
|
|
3156
|
+
case "GNUDumpDir": t.mode && (t.mode = t.mode | 448);
|
|
3157
|
+
case "File":
|
|
3158
|
+
case "OldFile":
|
|
3159
|
+
case "ContiguousFile":
|
|
3160
|
+
case "Link":
|
|
3161
|
+
case "SymbolicLink": return this[_s](t);
|
|
3162
|
+
default: return this[Cr](t);
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
[O](t, e) {
|
|
3166
|
+
t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[$t](), e.resume());
|
|
3167
|
+
}
|
|
3168
|
+
[yt](t, e, i) {
|
|
3169
|
+
gr(f(t), {
|
|
3170
|
+
uid: this.uid,
|
|
3171
|
+
gid: this.gid,
|
|
3172
|
+
processUid: this.processUid,
|
|
3173
|
+
processGid: this.processGid,
|
|
3174
|
+
umask: this.processUmask,
|
|
3175
|
+
preserve: this.preservePaths,
|
|
3176
|
+
unlink: this.unlink,
|
|
3177
|
+
cwd: this.cwd,
|
|
3178
|
+
mode: e
|
|
3179
|
+
}, i);
|
|
3180
|
+
}
|
|
3181
|
+
[ge](t) {
|
|
3182
|
+
return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
|
|
3183
|
+
}
|
|
3184
|
+
[be](t) {
|
|
3185
|
+
return vr(this.uid, t.uid, this.processUid);
|
|
3186
|
+
}
|
|
3187
|
+
[_e](t) {
|
|
3188
|
+
return vr(this.gid, t.gid, this.processGid);
|
|
3189
|
+
}
|
|
3190
|
+
[Ts](t, e) {
|
|
3191
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), {
|
|
3192
|
+
flags: ms(t.size),
|
|
3193
|
+
mode: i,
|
|
3194
|
+
autoClose: !1
|
|
3195
|
+
});
|
|
3196
|
+
r.on("error", (a) => {
|
|
3197
|
+
r.fd && Br.close(r.fd, () => {}), r.write = () => !0, this[O](a, t), e();
|
|
3198
|
+
});
|
|
3199
|
+
let n = 1, o = (a) => {
|
|
3200
|
+
if (a) {
|
|
3201
|
+
r.fd && Br.close(r.fd, () => {}), this[O](a, t), e();
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
--n === 0 && r.fd !== void 0 && Br.close(r.fd, (l) => {
|
|
3205
|
+
l ? this[O](l, t) : this[$t](), e();
|
|
3206
|
+
});
|
|
3207
|
+
};
|
|
3208
|
+
r.on("finish", () => {
|
|
3209
|
+
let a = String(t.absolute), l = r.fd;
|
|
3210
|
+
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
3211
|
+
n++;
|
|
3212
|
+
let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
|
|
3213
|
+
Br.futimes(l, c, d, (y) => y ? Br.utimes(a, c, d, (T) => o(T && y)) : o());
|
|
3214
|
+
}
|
|
3215
|
+
if (typeof l == "number" && this[ge](t)) {
|
|
3216
|
+
n++;
|
|
3217
|
+
let c = this[be](t), d = this[_e](t);
|
|
3218
|
+
typeof c == "number" && typeof d == "number" && Br.fchown(l, c, d, (y) => y ? Br.chown(a, c, d, (T) => o(T && y)) : o());
|
|
3219
|
+
}
|
|
3220
|
+
o();
|
|
3221
|
+
});
|
|
3222
|
+
let h = this.transform && this.transform(t) || t;
|
|
3223
|
+
h !== t && (h.on("error", (a) => {
|
|
3224
|
+
this[O](a, t), e();
|
|
3225
|
+
}), t.pipe(h)), h.pipe(r);
|
|
3226
|
+
}
|
|
3227
|
+
[xs](t, e) {
|
|
3228
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
|
|
3229
|
+
this[yt](String(t.absolute), i, (r) => {
|
|
3230
|
+
if (r) {
|
|
3231
|
+
this[O](r, t), e();
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
let n = 1, o = () => {
|
|
3235
|
+
--n === 0 && (e(), this[$t](), t.resume());
|
|
3236
|
+
};
|
|
3237
|
+
t.mtime && !this.noMtime && (n++, Br.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, Br.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
|
|
3238
|
+
});
|
|
3239
|
+
}
|
|
3240
|
+
[Cr](t) {
|
|
3241
|
+
t.unsupported = !0, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
3242
|
+
}
|
|
3243
|
+
[Ar](t, e) {
|
|
3244
|
+
let i = f(path.relative(this.cwd, path.resolve(path.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
3245
|
+
this[Re](t, this.cwd, i, () => this[gi](t, String(t.linkpath), "symlink", e), (r) => {
|
|
3246
|
+
this[O](r, t), e();
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
[Ir](t, e) {
|
|
3250
|
+
let i = f(path.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
|
|
3251
|
+
this[Re](t, this.cwd, r, () => this[gi](t, i, "link", e), (n) => {
|
|
3252
|
+
this[O](n, t), e();
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
[Re](t, e, i, r, n) {
|
|
3256
|
+
let o = i.shift();
|
|
3257
|
+
if (this.preservePaths || o === void 0) return r();
|
|
3258
|
+
let h = path.resolve(e, o);
|
|
3259
|
+
Br.lstat(h, (a, l) => {
|
|
3260
|
+
if (a) return r();
|
|
3261
|
+
if (l?.isSymbolicLink()) return n(new St(h, path.resolve(h, i.join("/"))));
|
|
3262
|
+
this[Re](t, h, i, r, n);
|
|
3263
|
+
});
|
|
3264
|
+
}
|
|
3265
|
+
[kr]() {
|
|
3266
|
+
this[Ri]++;
|
|
3267
|
+
}
|
|
3268
|
+
[$t]() {
|
|
3269
|
+
this[Ri]--, this[bs]();
|
|
3270
|
+
}
|
|
3271
|
+
[Ls](t) {
|
|
3272
|
+
this[$t](), t.resume();
|
|
3273
|
+
}
|
|
3274
|
+
[Os](t, e) {
|
|
3275
|
+
return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Te;
|
|
3276
|
+
}
|
|
3277
|
+
[_s](t) {
|
|
3278
|
+
this[kr]();
|
|
3279
|
+
let e = [t.path];
|
|
3280
|
+
t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[Nr](t, i));
|
|
3281
|
+
}
|
|
3282
|
+
[Nr](t, e) {
|
|
3283
|
+
let i = (h) => {
|
|
3284
|
+
e(h);
|
|
3285
|
+
}, r = () => {
|
|
3286
|
+
this[yt](this.cwd, this.dmode, (h) => {
|
|
3287
|
+
if (h) {
|
|
3288
|
+
this[O](h, t), i();
|
|
3289
|
+
return;
|
|
3290
|
+
}
|
|
3291
|
+
this[Oe] = !0, n();
|
|
3292
|
+
});
|
|
3293
|
+
}, n = () => {
|
|
3294
|
+
if (t.absolute !== this.cwd) {
|
|
3295
|
+
let h = f(path.dirname(String(t.absolute)));
|
|
3296
|
+
if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
|
|
3297
|
+
if (a) {
|
|
3298
|
+
this[O](a, t), i();
|
|
3299
|
+
return;
|
|
3300
|
+
}
|
|
3301
|
+
o();
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
o();
|
|
3305
|
+
}, o = () => {
|
|
3306
|
+
Br.lstat(String(t.absolute), (h, a) => {
|
|
3307
|
+
if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
|
|
3308
|
+
this[Ls](t), i();
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
if (h || this[Os](t, a)) return this[P](null, t, i);
|
|
3312
|
+
if (a.isDirectory()) {
|
|
3313
|
+
if (t.type === "Directory") {
|
|
3314
|
+
let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
|
|
3315
|
+
return l ? Br.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
3316
|
+
}
|
|
3317
|
+
if (t.absolute !== this.cwd) return Br.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
3318
|
+
}
|
|
3319
|
+
if (t.absolute === this.cwd) return this[P](null, t, i);
|
|
3320
|
+
mo(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
3321
|
+
});
|
|
3322
|
+
};
|
|
3323
|
+
this[Oe] ? n() : r();
|
|
3324
|
+
}
|
|
3325
|
+
[P](t, e, i) {
|
|
3326
|
+
if (t) {
|
|
3327
|
+
this[O](t, e), i();
|
|
3328
|
+
return;
|
|
3329
|
+
}
|
|
3330
|
+
switch (e.type) {
|
|
3331
|
+
case "File":
|
|
3332
|
+
case "OldFile":
|
|
3333
|
+
case "ContiguousFile": return this[Ts](e, i);
|
|
3334
|
+
case "Link": return this[Ir](e, i);
|
|
3335
|
+
case "SymbolicLink": return this[Ar](e, i);
|
|
3336
|
+
case "Directory":
|
|
3337
|
+
case "GNUDumpDir": return this[xs](e, i);
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
[gi](t, e, i, r) {
|
|
3341
|
+
Br[i](e, String(t.absolute), (n) => {
|
|
3342
|
+
n ? this[O](n, t) : (this[$t](), t.resume()), r();
|
|
3343
|
+
});
|
|
3344
|
+
}
|
|
3345
|
+
};
|
|
3346
|
+
var ye = (s) => {
|
|
3347
|
+
try {
|
|
3348
|
+
return [null, s()];
|
|
3349
|
+
} catch (t) {
|
|
3350
|
+
return [t, null];
|
|
3351
|
+
}
|
|
3352
|
+
};
|
|
3353
|
+
var xe = class extends Xt {
|
|
3354
|
+
sync = !0;
|
|
3355
|
+
[P](t, e) {
|
|
3356
|
+
return super[P](t, e, () => {});
|
|
3357
|
+
}
|
|
3358
|
+
[_s](t) {
|
|
3359
|
+
if (!this[Oe]) {
|
|
3360
|
+
let n = this[yt](this.cwd, this.dmode);
|
|
3361
|
+
if (n) return this[O](n, t);
|
|
3362
|
+
this[Oe] = !0;
|
|
3363
|
+
}
|
|
3364
|
+
if (t.absolute !== this.cwd) {
|
|
3365
|
+
let n = f(path.dirname(String(t.absolute)));
|
|
3366
|
+
if (n !== this.cwd) {
|
|
3367
|
+
let o = this[yt](n, this.dmode);
|
|
3368
|
+
if (o) return this[O](o, t);
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
let [e, i] = ye(() => Br.lstatSync(String(t.absolute)));
|
|
3372
|
+
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ls](t);
|
|
3373
|
+
if (e || this[Os](t, i)) return this[P](null, t);
|
|
3374
|
+
if (i.isDirectory()) {
|
|
3375
|
+
if (t.type === "Directory") {
|
|
3376
|
+
let [h] = this.chmod && t.mode && (i.mode & 4095) !== t.mode ? ye(() => {
|
|
3377
|
+
Br.chmodSync(String(t.absolute), Number(t.mode));
|
|
3378
|
+
}) : [];
|
|
3379
|
+
return this[P](h, t);
|
|
3380
|
+
}
|
|
3381
|
+
let [n] = ye(() => Br.rmdirSync(String(t.absolute)));
|
|
3382
|
+
this[P](n, t);
|
|
3383
|
+
}
|
|
3384
|
+
let [r] = t.absolute === this.cwd ? [] : ye(() => po(String(t.absolute)));
|
|
3385
|
+
this[P](r, t);
|
|
3386
|
+
}
|
|
3387
|
+
[Ts](t, e) {
|
|
3388
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
|
|
3389
|
+
let a;
|
|
3390
|
+
try {
|
|
3391
|
+
Br.closeSync(n);
|
|
3392
|
+
} catch (l) {
|
|
3393
|
+
a = l;
|
|
3394
|
+
}
|
|
3395
|
+
(h || a) && this[O](h || a, t), e();
|
|
3396
|
+
}, n;
|
|
3397
|
+
try {
|
|
3398
|
+
n = Br.openSync(String(t.absolute), ms(t.size), i);
|
|
3399
|
+
} catch (h) {
|
|
3400
|
+
return r(h);
|
|
3401
|
+
}
|
|
3402
|
+
let o = this.transform && this.transform(t) || t;
|
|
3403
|
+
o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
|
|
3404
|
+
try {
|
|
3405
|
+
Br.writeSync(n, h, 0, h.length);
|
|
3406
|
+
} catch (a) {
|
|
3407
|
+
r(a);
|
|
3408
|
+
}
|
|
3409
|
+
}), o.on("end", () => {
|
|
3410
|
+
let h = null;
|
|
3411
|
+
if (t.mtime && !this.noMtime) {
|
|
3412
|
+
let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
|
|
3413
|
+
try {
|
|
3414
|
+
Br.futimesSync(n, a, l);
|
|
3415
|
+
} catch (c) {
|
|
3416
|
+
try {
|
|
3417
|
+
Br.utimesSync(String(t.absolute), a, l);
|
|
3418
|
+
} catch {
|
|
3419
|
+
h = c;
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
if (this[ge](t)) {
|
|
3424
|
+
let a = this[be](t), l = this[_e](t);
|
|
3425
|
+
try {
|
|
3426
|
+
Br.fchownSync(n, Number(a), Number(l));
|
|
3427
|
+
} catch (c) {
|
|
3428
|
+
try {
|
|
3429
|
+
Br.chownSync(String(t.absolute), Number(a), Number(l));
|
|
3430
|
+
} catch {
|
|
3431
|
+
h = h || c;
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
r(h);
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
[xs](t, e) {
|
|
3439
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[yt](String(t.absolute), i);
|
|
3440
|
+
if (r) {
|
|
3441
|
+
this[O](r, t), e();
|
|
3442
|
+
return;
|
|
3443
|
+
}
|
|
3444
|
+
if (t.mtime && !this.noMtime) try {
|
|
3445
|
+
Br.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
|
|
3446
|
+
} catch {}
|
|
3447
|
+
if (this[ge](t)) try {
|
|
3448
|
+
Br.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
|
|
3449
|
+
} catch {}
|
|
3450
|
+
e(), t.resume();
|
|
3451
|
+
}
|
|
3452
|
+
[yt](t, e) {
|
|
3453
|
+
try {
|
|
3454
|
+
return _r(f(t), {
|
|
3455
|
+
uid: this.uid,
|
|
3456
|
+
gid: this.gid,
|
|
3457
|
+
processUid: this.processUid,
|
|
3458
|
+
processGid: this.processGid,
|
|
3459
|
+
umask: this.processUmask,
|
|
3460
|
+
preserve: this.preservePaths,
|
|
3461
|
+
unlink: this.unlink,
|
|
3462
|
+
cwd: this.cwd,
|
|
3463
|
+
mode: e
|
|
3464
|
+
});
|
|
3465
|
+
} catch (i) {
|
|
3466
|
+
return i;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
[Re](t, e, i, r, n) {
|
|
3470
|
+
if (this.preservePaths || i.length === 0) return r();
|
|
3471
|
+
let o = e;
|
|
3472
|
+
for (let h of i) {
|
|
3473
|
+
o = path.resolve(o, h);
|
|
3474
|
+
let [a, l] = ye(() => Br.lstatSync(o));
|
|
3475
|
+
if (a) return r();
|
|
3476
|
+
if (l.isSymbolicLink()) return n(new St(o, path.resolve(e, i.join("/"))));
|
|
3477
|
+
}
|
|
3478
|
+
r();
|
|
3479
|
+
}
|
|
3480
|
+
[gi](t, e, i, r) {
|
|
3481
|
+
let n = `${i}Sync`;
|
|
3482
|
+
try {
|
|
3483
|
+
Br[n](e, String(t.absolute)), r(), t.resume();
|
|
3484
|
+
} catch (o) {
|
|
3485
|
+
return this[O](o, t);
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
};
|
|
3489
|
+
var Eo = (s) => {
|
|
3490
|
+
let t = new xe(s), e = s.file, i = Br.statSync(e);
|
|
3491
|
+
new Be(e, {
|
|
3492
|
+
readSize: s.maxReadSize || 16777216,
|
|
3493
|
+
size: i.size
|
|
3494
|
+
}).pipe(t);
|
|
3495
|
+
};
|
|
3496
|
+
var wo = (s, t) => {
|
|
3497
|
+
let e = new Xt(s), i = s.maxReadSize || 16777216, r = s.file;
|
|
3498
|
+
return new Promise((o, h) => {
|
|
3499
|
+
e.on("error", h), e.on("close", o), Br.stat(r, (a, l) => {
|
|
3500
|
+
if (a) h(a);
|
|
3501
|
+
else {
|
|
3502
|
+
let c = new _t(r, {
|
|
3503
|
+
readSize: i,
|
|
3504
|
+
size: l.size
|
|
3505
|
+
});
|
|
3506
|
+
c.on("error", h), c.pipe(e);
|
|
3507
|
+
}
|
|
3508
|
+
});
|
|
3509
|
+
});
|
|
3510
|
+
};
|
|
3511
|
+
K(Eo, wo, (s) => new xe(s), (s) => new Xt(s), (s, t) => {
|
|
3512
|
+
t?.length && Qi(s, t);
|
|
3513
|
+
});
|
|
3514
|
+
var yo = (s, t) => {
|
|
3515
|
+
let e = new kt(s), i = !0, r, n;
|
|
3516
|
+
try {
|
|
3517
|
+
try {
|
|
3518
|
+
r = Br.openSync(s.file, "r+");
|
|
3519
|
+
} catch (a) {
|
|
3520
|
+
if (a?.code === "ENOENT") r = Br.openSync(s.file, "w+");
|
|
3521
|
+
else throw a;
|
|
3522
|
+
}
|
|
3523
|
+
let o = Br.fstatSync(r), h = Buffer.alloc(512);
|
|
3524
|
+
t: for (n = 0; n < o.size; n += 512) {
|
|
3525
|
+
for (let c = 0, d = 0; c < 512; c += d) {
|
|
3526
|
+
if (d = Br.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
|
|
3527
|
+
if (!d) break t;
|
|
3528
|
+
}
|
|
3529
|
+
let a = new F(h);
|
|
3530
|
+
if (!a.cksumValid) break;
|
|
3531
|
+
let l = 512 * Math.ceil((a.size || 0) / 512);
|
|
3532
|
+
if (n + l + 512 > o.size) break;
|
|
3533
|
+
n += l, s.mtimeCache && a.mtime && s.mtimeCache.set(String(a.path), a.mtime);
|
|
3534
|
+
}
|
|
3535
|
+
i = !1, Ro(s, e, n, r, t);
|
|
3536
|
+
} finally {
|
|
3537
|
+
if (i) try {
|
|
3538
|
+
Br.closeSync(r);
|
|
3539
|
+
} catch {}
|
|
3540
|
+
}
|
|
3541
|
+
};
|
|
3542
|
+
var Ro = (s, t, e, i, r) => {
|
|
3543
|
+
let n = new Wt(s.file, {
|
|
3544
|
+
fd: i,
|
|
3545
|
+
start: e
|
|
3546
|
+
});
|
|
3547
|
+
t.pipe(n), bo(t, r);
|
|
3548
|
+
};
|
|
3549
|
+
var go = (s, t) => {
|
|
3550
|
+
t = Array.from(t);
|
|
3551
|
+
let e = new wt(s), i = (n, o, h) => {
|
|
3552
|
+
let a = (T, D) => {
|
|
3553
|
+
T ? Br.close(n, (E) => h(T)) : h(null, D);
|
|
3554
|
+
}, l = 0;
|
|
3555
|
+
if (o === 0) return a(null, 0);
|
|
3556
|
+
let c = 0, d = Buffer.alloc(512), y = (T, D) => {
|
|
3557
|
+
if (T || D === void 0) return a(T);
|
|
3558
|
+
if (c += D, c < 512 && D) return Br.read(n, d, c, d.length - c, l + c, y);
|
|
3559
|
+
if (l === 0 && d[0] === 31 && d[1] === 139) return a(/* @__PURE__ */ new Error("cannot append to compressed archives"));
|
|
3560
|
+
if (c < 512) return a(null, l);
|
|
3561
|
+
let E = new F(d);
|
|
3562
|
+
if (!E.cksumValid) return a(null, l);
|
|
3563
|
+
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
3564
|
+
if (l + x + 512 > o || (l += x + 512, l >= o)) return a(null, l);
|
|
3565
|
+
s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0, Br.read(n, d, 0, 512, l, y);
|
|
3566
|
+
};
|
|
3567
|
+
Br.read(n, d, 0, 512, l, y);
|
|
3568
|
+
};
|
|
3569
|
+
return new Promise((n, o) => {
|
|
3570
|
+
e.on("error", o);
|
|
3571
|
+
let h = "r+", a = (l, c) => {
|
|
3572
|
+
if (l && l.code === "ENOENT" && h === "r+") return h = "w+", Br.open(s.file, h, a);
|
|
3573
|
+
if (l || !c) return o(l);
|
|
3574
|
+
Br.fstat(c, (d, y) => {
|
|
3575
|
+
if (d) return Br.close(c, () => o(d));
|
|
3576
|
+
i(c, y.size, (T, D) => {
|
|
3577
|
+
if (T) return o(T);
|
|
3578
|
+
let E = new et(s.file, {
|
|
3579
|
+
fd: c,
|
|
3580
|
+
start: D
|
|
3581
|
+
});
|
|
3582
|
+
e.pipe(E), E.on("error", o), E.on("close", n), _o(e, t);
|
|
3583
|
+
});
|
|
3584
|
+
});
|
|
3585
|
+
};
|
|
3586
|
+
Br.open(s.file, h, a);
|
|
3587
|
+
});
|
|
3588
|
+
};
|
|
3589
|
+
var bo = (s, t) => {
|
|
3590
|
+
t.forEach((e) => {
|
|
3591
|
+
e.charAt(0) === "@" ? Ct({
|
|
3592
|
+
file: path.resolve(s.cwd, e.slice(1)),
|
|
3593
|
+
sync: !0,
|
|
3594
|
+
noResume: !0,
|
|
3595
|
+
onReadEntry: (i) => s.add(i)
|
|
3596
|
+
}) : s.add(e);
|
|
3597
|
+
}), s.end();
|
|
3598
|
+
};
|
|
3599
|
+
var _o = async (s, t) => {
|
|
3600
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({
|
|
3601
|
+
file: path.resolve(String(s.cwd), e.slice(1)),
|
|
3602
|
+
noResume: !0,
|
|
3603
|
+
onReadEntry: (i) => s.add(i)
|
|
3604
|
+
}) : s.add(e);
|
|
3605
|
+
s.end();
|
|
3606
|
+
};
|
|
3607
|
+
var vt = K(yo, go, () => {
|
|
3608
|
+
throw new TypeError("file is required");
|
|
3609
|
+
}, () => {
|
|
3610
|
+
throw new TypeError("file is required");
|
|
3611
|
+
}, (s, t) => {
|
|
3612
|
+
if (!Bs(s)) throw new TypeError("file is required");
|
|
3613
|
+
if (s.gzip || s.brotli || s.zstd || s.file.endsWith(".br") || s.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
|
|
3614
|
+
if (!t?.length) throw new TypeError("no paths specified to add/replace");
|
|
3615
|
+
});
|
|
3616
|
+
K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s, t = []) => {
|
|
3617
|
+
vt.validate?.(s, t), To(s);
|
|
3618
|
+
});
|
|
3619
|
+
var To = (s) => {
|
|
3620
|
+
let t = s.filter;
|
|
3621
|
+
s.mtimeCache || (s.mtimeCache = /* @__PURE__ */ new Map()), s.filter = t ? (e, i) => t(e, i) && !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
|
|
3622
|
+
};
|
|
3623
|
+
//#endregion
|
|
3624
|
+
//#region src/config.ts
|
|
3625
|
+
/**
|
|
3626
|
+
* What the command reads from its environment - and nothing else of the SDK reads it: on GitHub
|
|
3627
|
+
* Actions, where a release is being made, the repository it is made from, which `pack` checks is
|
|
3628
|
+
* the one the Community Hub imports the vendor from.
|
|
3629
|
+
*/
|
|
3630
|
+
/**
|
|
3631
|
+
* The GitHub repository a GitHub Actions run is for.
|
|
3632
|
+
*
|
|
3633
|
+
* @returns `<owner>/<name>`, or undefined outside a run.
|
|
3634
|
+
*/
|
|
3635
|
+
function githubRepository() {
|
|
3636
|
+
const { GITHUB_ACTIONS: isActions, GITHUB_REPOSITORY: repository } = process.env;
|
|
3637
|
+
return isActions === "true" ? repository : void 0;
|
|
3638
|
+
}
|
|
3639
|
+
//#endregion
|
|
3640
|
+
//#region src/pack.ts
|
|
3641
|
+
/**
|
|
3642
|
+
* `nebulahome-integration pack`: the build, packed into the archive a release carries
|
|
3643
|
+
* (INTEGRATIONS_DOCS.md 10).
|
|
3644
|
+
*
|
|
3645
|
+
* `<vendor>-<version>.tgz`, a gzipped tar of the vendor's folder - `acme/manifest.json`,
|
|
3646
|
+
* `acme/panels/driver.json`, … - written in a fixed order without times or links, so the same
|
|
3647
|
+
* build packs to the same bytes. The Community Hub imports a GitHub release of
|
|
3648
|
+
* `<owner>/integration-<vendor>` tagged `v<version>` with exactly this one archive, and reads the
|
|
3649
|
+
* vendor and its drivers out of it; on GitHub Actions the command checks the repository's name,
|
|
3650
|
+
* which the Hub would otherwise refuse without saying so to anyone watching the release.
|
|
3651
|
+
*/
|
|
3652
|
+
/**
|
|
3653
|
+
* Packs the build.
|
|
3654
|
+
*
|
|
3655
|
+
* @param options - Where the repository is, and the GitHub repository it is released from.
|
|
3656
|
+
* @param options.root - Its folder.
|
|
3657
|
+
* @param options.repository - `<owner>/<name>` on GitHub Actions, null elsewhere; read from the
|
|
3658
|
+
* environment when not said.
|
|
3659
|
+
* @returns The archive, its digest and its size.
|
|
3660
|
+
* @throws {IntegrationError} When there is no build of this version, or the repository is not
|
|
3661
|
+
* named for the vendor.
|
|
3662
|
+
*/
|
|
3663
|
+
async function packIntegration(options) {
|
|
3664
|
+
const project = await readProject(options.root);
|
|
3665
|
+
const manifestFile = path.join(project.outputDirectory, "manifest.json");
|
|
3666
|
+
if (!await isFile(manifestFile)) throw new IntegrationError([`dist/${project.vendorId} holds no build: run nebulahome-integration build first`]);
|
|
3667
|
+
const built = JSON.parse(await readFile(manifestFile, "utf8"));
|
|
3668
|
+
if (built.version !== project.version) throw new IntegrationError([`The build is of ${String(built.version)} and package.json says ${project.version}: run nebulahome-integration build again`]);
|
|
3669
|
+
const repository = options.repository === void 0 ? githubRepository() : options.repository ?? void 0;
|
|
3670
|
+
const expected = `integration-${project.vendorId}`;
|
|
3671
|
+
if (repository !== void 0 && repository.split("/")[1] !== expected) throw new IntegrationError([`The repository is ${repository}, and the Community Hub imports ${project.vendorId} only from one called ${expected}`]);
|
|
3672
|
+
const files = (await readdir(project.outputDirectory, {
|
|
3673
|
+
recursive: true,
|
|
3674
|
+
withFileTypes: true
|
|
3675
|
+
})).filter((entry) => entry.isFile()).map((entry) => path.relative(project.outputRoot, path.join(entry.parentPath, entry.name)).split(path.sep).join("/")).sort();
|
|
3676
|
+
const archive = path.join(project.root, `${project.vendorId}-${project.version}.tgz`);
|
|
3677
|
+
await Qn({
|
|
3678
|
+
gzip: true,
|
|
3679
|
+
cwd: project.outputRoot,
|
|
3680
|
+
file: archive,
|
|
3681
|
+
portable: true,
|
|
3682
|
+
follow: false,
|
|
3683
|
+
noMtime: true
|
|
3684
|
+
}, files);
|
|
3685
|
+
const bytes = await readFile(archive);
|
|
3686
|
+
return {
|
|
3687
|
+
project,
|
|
3688
|
+
archive,
|
|
3689
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
3690
|
+
size: bytes.length
|
|
3691
|
+
};
|
|
3692
|
+
}
|
|
3693
|
+
//#endregion
|
|
3694
|
+
//#region src/cli/index.ts
|
|
3695
|
+
/**
|
|
3696
|
+
* `nebulahome-integration`: the command an integration is checked, built and packed with
|
|
3697
|
+
* (INTEGRATIONS_DOCS.md 8).
|
|
3698
|
+
*
|
|
3699
|
+
* ```
|
|
3700
|
+
* nebulahome-integration validate the sources hold together, the way the hub reads a bundle
|
|
3701
|
+
* nebulahome-integration build validate, then build src/ into dist/<vendor>/
|
|
3702
|
+
* nebulahome-integration pack pack dist/<vendor>/ into <vendor>-<version>.tgz
|
|
3703
|
+
* ```
|
|
3704
|
+
*
|
|
3705
|
+
* Every command takes `--root <folder>`, the repository - the working directory when not said.
|
|
3706
|
+
* A problem ends it with exit code 1, every problem printed.
|
|
3707
|
+
*/
|
|
3708
|
+
/** How the command is used. */
|
|
3709
|
+
const USAGE = `Usage: nebulahome-integration <validate | build | pack> [--root <folder>]
|
|
3710
|
+
|
|
3711
|
+
validate check src/ the way the hub reads a bundle
|
|
3712
|
+
build validate, then build src/ into dist/<vendor>/ and load it back
|
|
3713
|
+
pack pack dist/<vendor>/ into <vendor>-<version>.tgz, for a release or a local folder
|
|
3714
|
+
`;
|
|
3715
|
+
/**
|
|
3716
|
+
* Writes a line for whoever runs the command.
|
|
3717
|
+
*
|
|
3718
|
+
* @param line - What it says.
|
|
3719
|
+
*/
|
|
3720
|
+
function say(line) {
|
|
3721
|
+
process.stdout.write(`${line}\n`);
|
|
3722
|
+
}
|
|
3723
|
+
/**
|
|
3724
|
+
* Runs the command.
|
|
3725
|
+
*
|
|
3726
|
+
* @param args - Its arguments, after the program's name.
|
|
3727
|
+
* @returns Its exit code.
|
|
3728
|
+
*/
|
|
3729
|
+
async function run(args) {
|
|
3730
|
+
const { positionals, values } = parseArgs({
|
|
3731
|
+
args: [...args],
|
|
3732
|
+
allowPositionals: true,
|
|
3733
|
+
options: {
|
|
3734
|
+
root: { type: "string" },
|
|
3735
|
+
help: {
|
|
3736
|
+
type: "boolean",
|
|
3737
|
+
short: "h"
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
});
|
|
3741
|
+
const [command] = positionals;
|
|
3742
|
+
const root = path.resolve(values.root ?? ".");
|
|
3743
|
+
if (values.help === true || command === void 0) {
|
|
3744
|
+
say(USAGE);
|
|
3745
|
+
return command === void 0 && values.help !== true ? 1 : 0;
|
|
3746
|
+
}
|
|
3747
|
+
try {
|
|
3748
|
+
switch (command) {
|
|
3749
|
+
case "validate": {
|
|
3750
|
+
const { project, declaration } = await checkIntegration({ root });
|
|
3751
|
+
say(`${declaration.manifest.name} ${project.version} holds together: ${String(declaration.drivers.length)} driver${declaration.drivers.length === 1 ? "" : "s"}.`);
|
|
3752
|
+
return 0;
|
|
3753
|
+
}
|
|
3754
|
+
case "build": {
|
|
3755
|
+
const { project, outputDirectory, files, modules } = await buildIntegration({ root });
|
|
3756
|
+
say(`Built ${project.vendorId} ${project.version} into ${path.relative(root, outputDirectory)}: ${String(files)} files, ${String(modules)} modules.`);
|
|
3757
|
+
return 0;
|
|
3758
|
+
}
|
|
3759
|
+
case "pack": {
|
|
3760
|
+
const { archive, sha256, size } = await packIntegration({ root });
|
|
3761
|
+
say(`Packed ${path.relative(root, archive)}: ${String(size)} bytes, sha256 ${sha256}.`);
|
|
3762
|
+
return 0;
|
|
3763
|
+
}
|
|
3764
|
+
default:
|
|
3765
|
+
say(`Unknown command: ${command}\n\n${USAGE}`);
|
|
3766
|
+
return 1;
|
|
3767
|
+
}
|
|
3768
|
+
} catch (error) {
|
|
3769
|
+
if (error instanceof IntegrationError) {
|
|
3770
|
+
for (const problem of error.problems) process.stderr.write(`✖ ${problem}\n`);
|
|
3771
|
+
return 1;
|
|
3772
|
+
}
|
|
3773
|
+
throw error;
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
//#endregion
|
|
3777
|
+
//#region src/cli/bin.ts
|
|
3778
|
+
/**
|
|
3779
|
+
* The `nebulahome-integration` executable: runs the command, and ends with its exit code.
|
|
3780
|
+
*/
|
|
3781
|
+
process.exitCode = await run(process.argv.slice(2));
|
|
3782
|
+
//#endregion
|
|
3783
|
+
export {};
|