@uipath/common 1.202.0 → 1.203.0-preview.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-NOTICES.md +32 -1
- package/dist/catch-error.js +17 -1
- package/dist/command-help.d.ts +1 -1
- package/dist/entity-name-rules.js +17 -1
- package/dist/formatter.d.ts +50 -1
- package/dist/guid.js +17 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +70 -16
- package/dist/index.js +384 -36
- package/dist/logger.d.ts +1 -1
- package/dist/output-format-context.d.ts +1 -1
- package/dist/output-formats.d.ts +34 -0
- package/dist/registry.d.ts +5 -0
- package/dist/telemetry/index.js +9 -6
- package/dist/telemetry/telemetry-init.d.ts +1 -1
- package/dist/timings.d.ts +19 -0
- package/dist/zip.d.ts +14 -0
- package/dist/zip.js +1380 -0
- package/package.json +7 -2
package/dist/zip.js
ADDED
|
@@ -0,0 +1,1380 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/is-inside-container/node_modules/is-docker/index.js
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
function hasDockerEnv() {
|
|
20
|
+
try {
|
|
21
|
+
fs.statSync("/.dockerenv");
|
|
22
|
+
return true;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function hasDockerCGroup() {
|
|
28
|
+
try {
|
|
29
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isDocker() {
|
|
35
|
+
if (isDockerCached === undefined) {
|
|
36
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
37
|
+
}
|
|
38
|
+
return isDockerCached;
|
|
39
|
+
}
|
|
40
|
+
var isDockerCached;
|
|
41
|
+
var init_is_docker = () => {};
|
|
42
|
+
|
|
43
|
+
// ../../node_modules/is-inside-container/index.js
|
|
44
|
+
import fs2 from "node:fs";
|
|
45
|
+
function isInsideContainer() {
|
|
46
|
+
if (cachedResult === undefined) {
|
|
47
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
48
|
+
}
|
|
49
|
+
return cachedResult;
|
|
50
|
+
}
|
|
51
|
+
var cachedResult, hasContainerEnv = () => {
|
|
52
|
+
try {
|
|
53
|
+
fs2.statSync("/run/.containerenv");
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var init_is_inside_container = __esm(() => {
|
|
60
|
+
init_is_docker();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ../../node_modules/wsl-utils/node_modules/is-wsl/index.js
|
|
64
|
+
import process2 from "node:process";
|
|
65
|
+
import os from "node:os";
|
|
66
|
+
import fs3 from "node:fs";
|
|
67
|
+
var isWsl = () => {
|
|
68
|
+
if (process2.platform !== "linux") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
72
|
+
if (isInsideContainer()) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
79
|
+
return !isInsideContainer();
|
|
80
|
+
}
|
|
81
|
+
} catch {}
|
|
82
|
+
if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
|
|
83
|
+
return !isInsideContainer();
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}, is_wsl_default;
|
|
87
|
+
var init_is_wsl = __esm(() => {
|
|
88
|
+
init_is_inside_container();
|
|
89
|
+
is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ../../node_modules/powershell-utils/index.js
|
|
93
|
+
import process3 from "node:process";
|
|
94
|
+
import { Buffer } from "node:buffer";
|
|
95
|
+
import { promisify } from "node:util";
|
|
96
|
+
import childProcess from "node:child_process";
|
|
97
|
+
var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
|
|
98
|
+
const {
|
|
99
|
+
powerShellPath: psPath,
|
|
100
|
+
...execFileOptions
|
|
101
|
+
} = options;
|
|
102
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
103
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
104
|
+
...executePowerShell.argumentsPrefix,
|
|
105
|
+
encodedCommand
|
|
106
|
+
], {
|
|
107
|
+
encoding: "utf8",
|
|
108
|
+
...execFileOptions
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
var init_powershell_utils = __esm(() => {
|
|
112
|
+
execFile = promisify(childProcess.execFile);
|
|
113
|
+
executePowerShell.argumentsPrefix = [
|
|
114
|
+
"-NoProfile",
|
|
115
|
+
"-NonInteractive",
|
|
116
|
+
"-ExecutionPolicy",
|
|
117
|
+
"Bypass",
|
|
118
|
+
"-EncodedCommand"
|
|
119
|
+
];
|
|
120
|
+
executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
|
|
121
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ../../node_modules/wsl-utils/utilities.js
|
|
125
|
+
function parseMountPointFromConfig(content) {
|
|
126
|
+
for (const line of content.split(`
|
|
127
|
+
`)) {
|
|
128
|
+
if (/^\s*#/.test(line)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
132
|
+
if (!match) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ../../node_modules/wsl-utils/index.js
|
|
140
|
+
import { promisify as promisify2 } from "node:util";
|
|
141
|
+
import childProcess2 from "node:child_process";
|
|
142
|
+
import fs4, { constants as fsConstants } from "node:fs/promises";
|
|
143
|
+
var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
|
|
144
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
145
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
146
|
+
}, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell = async () => {
|
|
147
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
148
|
+
try {
|
|
149
|
+
const psPath = await powerShellPath2();
|
|
150
|
+
await fs4.access(psPath, fsConstants.X_OK);
|
|
151
|
+
return true;
|
|
152
|
+
} catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
})();
|
|
156
|
+
return canAccessPowerShellPromise;
|
|
157
|
+
}, wslDefaultBrowser = async () => {
|
|
158
|
+
const psPath = await powerShellPath2();
|
|
159
|
+
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
160
|
+
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
161
|
+
return stdout.trim();
|
|
162
|
+
}, convertWslPathToWindows = async (path) => {
|
|
163
|
+
if (/^[a-z]+:\/\//i.test(path)) {
|
|
164
|
+
return path;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
|
|
168
|
+
return stdout.trim();
|
|
169
|
+
} catch {
|
|
170
|
+
return path;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var init_wsl_utils = __esm(() => {
|
|
174
|
+
init_is_wsl();
|
|
175
|
+
init_powershell_utils();
|
|
176
|
+
init_is_wsl();
|
|
177
|
+
execFile2 = promisify2(childProcess2.execFile);
|
|
178
|
+
wslDrivesMountPoint = (() => {
|
|
179
|
+
const defaultMountPoint = "/mnt/";
|
|
180
|
+
let mountPoint;
|
|
181
|
+
return async function() {
|
|
182
|
+
if (mountPoint) {
|
|
183
|
+
return mountPoint;
|
|
184
|
+
}
|
|
185
|
+
const configFilePath = "/etc/wsl.conf";
|
|
186
|
+
let isConfigFileExists = false;
|
|
187
|
+
try {
|
|
188
|
+
await fs4.access(configFilePath, fsConstants.F_OK);
|
|
189
|
+
isConfigFileExists = true;
|
|
190
|
+
} catch {}
|
|
191
|
+
if (!isConfigFileExists) {
|
|
192
|
+
return defaultMountPoint;
|
|
193
|
+
}
|
|
194
|
+
const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
|
|
195
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
196
|
+
if (parsedMountPoint === undefined) {
|
|
197
|
+
return defaultMountPoint;
|
|
198
|
+
}
|
|
199
|
+
mountPoint = parsedMountPoint;
|
|
200
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
201
|
+
return mountPoint;
|
|
202
|
+
};
|
|
203
|
+
})();
|
|
204
|
+
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// ../../node_modules/open/node_modules/define-lazy-prop/index.js
|
|
208
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
209
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
210
|
+
Object.defineProperty(object, propertyName, {
|
|
211
|
+
configurable: true,
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get() {
|
|
214
|
+
const result = valueGetter();
|
|
215
|
+
define(result);
|
|
216
|
+
return result;
|
|
217
|
+
},
|
|
218
|
+
set(value) {
|
|
219
|
+
define(value);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return object;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ../../node_modules/default-browser-id/index.js
|
|
226
|
+
import { promisify as promisify3 } from "node:util";
|
|
227
|
+
import process4 from "node:process";
|
|
228
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
229
|
+
async function defaultBrowserId() {
|
|
230
|
+
if (process4.platform !== "darwin") {
|
|
231
|
+
throw new Error("macOS only");
|
|
232
|
+
}
|
|
233
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
234
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
235
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
236
|
+
if (browserId === "com.apple.safari") {
|
|
237
|
+
return "com.apple.Safari";
|
|
238
|
+
}
|
|
239
|
+
return browserId;
|
|
240
|
+
}
|
|
241
|
+
var execFileAsync;
|
|
242
|
+
var init_default_browser_id = __esm(() => {
|
|
243
|
+
execFileAsync = promisify3(execFile3);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// ../../node_modules/run-applescript/index.js
|
|
247
|
+
import process5 from "node:process";
|
|
248
|
+
import { promisify as promisify4 } from "node:util";
|
|
249
|
+
import { execFile as execFile4, execFileSync } from "node:child_process";
|
|
250
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
251
|
+
if (process5.platform !== "darwin") {
|
|
252
|
+
throw new Error("macOS only");
|
|
253
|
+
}
|
|
254
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
255
|
+
const execOptions = {};
|
|
256
|
+
if (signal) {
|
|
257
|
+
execOptions.signal = signal;
|
|
258
|
+
}
|
|
259
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
260
|
+
return stdout.trim();
|
|
261
|
+
}
|
|
262
|
+
var execFileAsync2;
|
|
263
|
+
var init_run_applescript = __esm(() => {
|
|
264
|
+
execFileAsync2 = promisify4(execFile4);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// ../../node_modules/bundle-name/index.js
|
|
268
|
+
async function bundleName(bundleId) {
|
|
269
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
270
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
271
|
+
}
|
|
272
|
+
var init_bundle_name = __esm(() => {
|
|
273
|
+
init_run_applescript();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// ../../node_modules/default-browser/windows.js
|
|
277
|
+
import { promisify as promisify5 } from "node:util";
|
|
278
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
279
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
280
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
281
|
+
"QUERY",
|
|
282
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
283
|
+
"/v",
|
|
284
|
+
"ProgId"
|
|
285
|
+
]);
|
|
286
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
287
|
+
if (!match) {
|
|
288
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
289
|
+
}
|
|
290
|
+
const { id } = match.groups;
|
|
291
|
+
const dotIndex = id.lastIndexOf(".");
|
|
292
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
293
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
294
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
295
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
296
|
+
}
|
|
297
|
+
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
298
|
+
var init_windows = __esm(() => {
|
|
299
|
+
execFileAsync3 = promisify5(execFile5);
|
|
300
|
+
windowsBrowserProgIds = {
|
|
301
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
302
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
303
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
304
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
305
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
306
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
307
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
308
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
309
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
310
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
311
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
312
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
313
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
314
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
315
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
316
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
317
|
+
};
|
|
318
|
+
_windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
319
|
+
UnknownBrowserError = class UnknownBrowserError extends Error {
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// ../../node_modules/default-browser/index.js
|
|
324
|
+
import { promisify as promisify6 } from "node:util";
|
|
325
|
+
import process6 from "node:process";
|
|
326
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
327
|
+
async function defaultBrowser2() {
|
|
328
|
+
if (process6.platform === "darwin") {
|
|
329
|
+
const id = await defaultBrowserId();
|
|
330
|
+
const name = await bundleName(id);
|
|
331
|
+
return { name, id };
|
|
332
|
+
}
|
|
333
|
+
if (process6.platform === "linux") {
|
|
334
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
335
|
+
const id = stdout.trim();
|
|
336
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
337
|
+
return { name, id };
|
|
338
|
+
}
|
|
339
|
+
if (process6.platform === "win32") {
|
|
340
|
+
return defaultBrowser();
|
|
341
|
+
}
|
|
342
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
343
|
+
}
|
|
344
|
+
var execFileAsync4, titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
345
|
+
var init_default_browser = __esm(() => {
|
|
346
|
+
init_default_browser_id();
|
|
347
|
+
init_bundle_name();
|
|
348
|
+
init_windows();
|
|
349
|
+
init_windows();
|
|
350
|
+
execFileAsync4 = promisify6(execFile6);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// ../../node_modules/is-in-ssh/index.js
|
|
354
|
+
import process7 from "node:process";
|
|
355
|
+
var isInSsh, is_in_ssh_default;
|
|
356
|
+
var init_is_in_ssh = __esm(() => {
|
|
357
|
+
isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
|
|
358
|
+
is_in_ssh_default = isInSsh;
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// ../../node_modules/open/index.js
|
|
362
|
+
var exports_open = {};
|
|
363
|
+
__export(exports_open, {
|
|
364
|
+
apps: () => apps,
|
|
365
|
+
default: () => open_default,
|
|
366
|
+
openApp: () => openApp
|
|
367
|
+
});
|
|
368
|
+
import process8 from "node:process";
|
|
369
|
+
import path from "node:path";
|
|
370
|
+
import { fileURLToPath } from "node:url";
|
|
371
|
+
import childProcess3 from "node:child_process";
|
|
372
|
+
import fs5, { constants as fsConstants2 } from "node:fs/promises";
|
|
373
|
+
function detectArchBinary(binary) {
|
|
374
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
375
|
+
return binary;
|
|
376
|
+
}
|
|
377
|
+
const { [arch]: archBinary } = binary;
|
|
378
|
+
if (!archBinary) {
|
|
379
|
+
throw new Error(`${arch} is not supported`);
|
|
380
|
+
}
|
|
381
|
+
return archBinary;
|
|
382
|
+
}
|
|
383
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
384
|
+
if (wsl && is_wsl_default) {
|
|
385
|
+
return detectArchBinary(wsl);
|
|
386
|
+
}
|
|
387
|
+
if (!platformBinary) {
|
|
388
|
+
throw new Error(`${platform} is not supported`);
|
|
389
|
+
}
|
|
390
|
+
return detectArchBinary(platformBinary);
|
|
391
|
+
}
|
|
392
|
+
var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp = async (apps, opener) => {
|
|
393
|
+
if (apps.length === 0) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const errors = [];
|
|
397
|
+
for (const app of apps) {
|
|
398
|
+
try {
|
|
399
|
+
return await opener(app);
|
|
400
|
+
} catch (error) {
|
|
401
|
+
errors.push(error);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
405
|
+
}, baseOpen = async (options) => {
|
|
406
|
+
options = {
|
|
407
|
+
wait: false,
|
|
408
|
+
background: false,
|
|
409
|
+
newInstance: false,
|
|
410
|
+
allowNonzeroExitCode: false,
|
|
411
|
+
...options
|
|
412
|
+
};
|
|
413
|
+
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
414
|
+
delete options[fallbackAttemptSymbol];
|
|
415
|
+
if (Array.isArray(options.app)) {
|
|
416
|
+
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
417
|
+
...options,
|
|
418
|
+
app: singleApp,
|
|
419
|
+
[fallbackAttemptSymbol]: true
|
|
420
|
+
}));
|
|
421
|
+
}
|
|
422
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
423
|
+
appArguments = [...appArguments];
|
|
424
|
+
if (Array.isArray(app)) {
|
|
425
|
+
return tryEachApp(app, (appName) => baseOpen({
|
|
426
|
+
...options,
|
|
427
|
+
app: {
|
|
428
|
+
name: appName,
|
|
429
|
+
arguments: appArguments
|
|
430
|
+
},
|
|
431
|
+
[fallbackAttemptSymbol]: true
|
|
432
|
+
}));
|
|
433
|
+
}
|
|
434
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
435
|
+
const ids = {
|
|
436
|
+
"com.google.chrome": "chrome",
|
|
437
|
+
"google-chrome.desktop": "chrome",
|
|
438
|
+
"com.brave.browser": "brave",
|
|
439
|
+
"org.mozilla.firefox": "firefox",
|
|
440
|
+
"firefox.desktop": "firefox",
|
|
441
|
+
"com.microsoft.msedge": "edge",
|
|
442
|
+
"com.microsoft.edge": "edge",
|
|
443
|
+
"com.microsoft.edgemac": "edge",
|
|
444
|
+
"microsoft-edge.desktop": "edge",
|
|
445
|
+
"com.apple.safari": "safari"
|
|
446
|
+
};
|
|
447
|
+
const flags = {
|
|
448
|
+
chrome: "--incognito",
|
|
449
|
+
brave: "--incognito",
|
|
450
|
+
firefox: "--private-window",
|
|
451
|
+
edge: "--inPrivate"
|
|
452
|
+
};
|
|
453
|
+
let browser;
|
|
454
|
+
if (is_wsl_default) {
|
|
455
|
+
const progId = await wslDefaultBrowser();
|
|
456
|
+
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
457
|
+
browser = browserInfo ?? {};
|
|
458
|
+
} else {
|
|
459
|
+
browser = await defaultBrowser2();
|
|
460
|
+
}
|
|
461
|
+
if (browser.id in ids) {
|
|
462
|
+
const browserName = ids[browser.id.toLowerCase()];
|
|
463
|
+
if (app === "browserPrivate") {
|
|
464
|
+
if (browserName === "safari") {
|
|
465
|
+
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
466
|
+
}
|
|
467
|
+
appArguments.push(flags[browserName]);
|
|
468
|
+
}
|
|
469
|
+
return baseOpen({
|
|
470
|
+
...options,
|
|
471
|
+
app: {
|
|
472
|
+
name: apps[browserName],
|
|
473
|
+
arguments: appArguments
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
478
|
+
}
|
|
479
|
+
let command;
|
|
480
|
+
const cliArguments = [];
|
|
481
|
+
const childProcessOptions = {};
|
|
482
|
+
let shouldUseWindowsInWsl = false;
|
|
483
|
+
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
484
|
+
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
485
|
+
}
|
|
486
|
+
if (platform === "darwin") {
|
|
487
|
+
command = "open";
|
|
488
|
+
if (options.wait) {
|
|
489
|
+
cliArguments.push("--wait-apps");
|
|
490
|
+
}
|
|
491
|
+
if (options.background) {
|
|
492
|
+
cliArguments.push("--background");
|
|
493
|
+
}
|
|
494
|
+
if (options.newInstance) {
|
|
495
|
+
cliArguments.push("--new");
|
|
496
|
+
}
|
|
497
|
+
if (app) {
|
|
498
|
+
cliArguments.push("-a", app);
|
|
499
|
+
}
|
|
500
|
+
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
501
|
+
command = await powerShellPath2();
|
|
502
|
+
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
503
|
+
if (!is_wsl_default) {
|
|
504
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
505
|
+
}
|
|
506
|
+
if (is_wsl_default && options.target) {
|
|
507
|
+
options.target = await convertWslPathToWindows(options.target);
|
|
508
|
+
}
|
|
509
|
+
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
510
|
+
if (options.wait) {
|
|
511
|
+
encodedArguments.push("-Wait");
|
|
512
|
+
}
|
|
513
|
+
if (app) {
|
|
514
|
+
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
515
|
+
if (options.target) {
|
|
516
|
+
appArguments.push(options.target);
|
|
517
|
+
}
|
|
518
|
+
} else if (options.target) {
|
|
519
|
+
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
520
|
+
}
|
|
521
|
+
if (appArguments.length > 0) {
|
|
522
|
+
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
523
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
524
|
+
}
|
|
525
|
+
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
526
|
+
if (!options.wait) {
|
|
527
|
+
childProcessOptions.stdio = "ignore";
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
if (app) {
|
|
531
|
+
command = app;
|
|
532
|
+
} else {
|
|
533
|
+
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
534
|
+
let exeLocalXdgOpen = false;
|
|
535
|
+
try {
|
|
536
|
+
await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
537
|
+
exeLocalXdgOpen = true;
|
|
538
|
+
} catch {}
|
|
539
|
+
const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
540
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
541
|
+
}
|
|
542
|
+
if (appArguments.length > 0) {
|
|
543
|
+
cliArguments.push(...appArguments);
|
|
544
|
+
}
|
|
545
|
+
if (!options.wait) {
|
|
546
|
+
childProcessOptions.stdio = "ignore";
|
|
547
|
+
childProcessOptions.detached = true;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
551
|
+
cliArguments.push("--args", ...appArguments);
|
|
552
|
+
}
|
|
553
|
+
if (options.target) {
|
|
554
|
+
cliArguments.push(options.target);
|
|
555
|
+
}
|
|
556
|
+
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
557
|
+
if (options.wait) {
|
|
558
|
+
return new Promise((resolve, reject) => {
|
|
559
|
+
subprocess.once("error", reject);
|
|
560
|
+
subprocess.once("close", (exitCode) => {
|
|
561
|
+
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
562
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
resolve(subprocess);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
if (isFallbackAttempt) {
|
|
570
|
+
return new Promise((resolve, reject) => {
|
|
571
|
+
subprocess.once("error", reject);
|
|
572
|
+
subprocess.once("spawn", () => {
|
|
573
|
+
subprocess.once("close", (exitCode) => {
|
|
574
|
+
subprocess.off("error", reject);
|
|
575
|
+
if (exitCode !== 0) {
|
|
576
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
subprocess.unref();
|
|
580
|
+
resolve(subprocess);
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
subprocess.unref();
|
|
586
|
+
return new Promise((resolve, reject) => {
|
|
587
|
+
subprocess.once("error", reject);
|
|
588
|
+
subprocess.once("spawn", () => {
|
|
589
|
+
subprocess.off("error", reject);
|
|
590
|
+
resolve(subprocess);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
}, open = (target, options) => {
|
|
594
|
+
if (typeof target !== "string") {
|
|
595
|
+
throw new TypeError("Expected a `target`");
|
|
596
|
+
}
|
|
597
|
+
return baseOpen({
|
|
598
|
+
...options,
|
|
599
|
+
target
|
|
600
|
+
});
|
|
601
|
+
}, openApp = (name, options) => {
|
|
602
|
+
if (typeof name !== "string" && !Array.isArray(name)) {
|
|
603
|
+
throw new TypeError("Expected a valid `name`");
|
|
604
|
+
}
|
|
605
|
+
const { arguments: appArguments = [] } = options ?? {};
|
|
606
|
+
if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
|
|
607
|
+
throw new TypeError("Expected `appArguments` as Array type");
|
|
608
|
+
}
|
|
609
|
+
return baseOpen({
|
|
610
|
+
...options,
|
|
611
|
+
app: {
|
|
612
|
+
name,
|
|
613
|
+
arguments: appArguments
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}, apps, open_default;
|
|
617
|
+
var init_open = __esm(() => {
|
|
618
|
+
init_wsl_utils();
|
|
619
|
+
init_powershell_utils();
|
|
620
|
+
init_default_browser();
|
|
621
|
+
init_is_inside_container();
|
|
622
|
+
init_is_in_ssh();
|
|
623
|
+
fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
624
|
+
__dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
625
|
+
localXdgOpenPath = path.join(__dirname2, "xdg-open");
|
|
626
|
+
({ platform, arch } = process8);
|
|
627
|
+
apps = {
|
|
628
|
+
browser: "browser",
|
|
629
|
+
browserPrivate: "browserPrivate"
|
|
630
|
+
};
|
|
631
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
632
|
+
darwin: "google chrome",
|
|
633
|
+
win32: "chrome",
|
|
634
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
635
|
+
}, {
|
|
636
|
+
wsl: {
|
|
637
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
638
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
639
|
+
}
|
|
640
|
+
}));
|
|
641
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
642
|
+
darwin: "brave browser",
|
|
643
|
+
win32: "brave",
|
|
644
|
+
linux: ["brave-browser", "brave"]
|
|
645
|
+
}, {
|
|
646
|
+
wsl: {
|
|
647
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
648
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
649
|
+
}
|
|
650
|
+
}));
|
|
651
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
652
|
+
darwin: "firefox",
|
|
653
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
654
|
+
linux: "firefox"
|
|
655
|
+
}, {
|
|
656
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
657
|
+
}));
|
|
658
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
659
|
+
darwin: "microsoft edge",
|
|
660
|
+
win32: "msedge",
|
|
661
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
662
|
+
}, {
|
|
663
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
664
|
+
}));
|
|
665
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
666
|
+
darwin: "Safari"
|
|
667
|
+
}));
|
|
668
|
+
open_default = open;
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
// ../filesystem/src/node.ts
|
|
672
|
+
import { randomUUID } from "node:crypto";
|
|
673
|
+
import { existsSync } from "node:fs";
|
|
674
|
+
import * as fs6 from "node:fs/promises";
|
|
675
|
+
import * as os2 from "node:os";
|
|
676
|
+
import * as path2 from "node:path";
|
|
677
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
678
|
+
var LOCK_STALE_MS = 15000;
|
|
679
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
680
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
681
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
682
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
683
|
+
|
|
684
|
+
class NodeFileSystem {
|
|
685
|
+
path = {
|
|
686
|
+
join: path2.join,
|
|
687
|
+
resolve: path2.resolve,
|
|
688
|
+
relative: path2.relative,
|
|
689
|
+
dirname: path2.dirname,
|
|
690
|
+
isAbsolute: path2.isAbsolute,
|
|
691
|
+
basename: path2.basename
|
|
692
|
+
};
|
|
693
|
+
env = {
|
|
694
|
+
cwd: process.cwd,
|
|
695
|
+
homedir: os2.homedir,
|
|
696
|
+
tmpdir: os2.tmpdir,
|
|
697
|
+
getenv: (key) => process.env[key]
|
|
698
|
+
};
|
|
699
|
+
utils = {
|
|
700
|
+
open: async (url) => {
|
|
701
|
+
const { default: open2 } = await Promise.resolve().then(() => (init_open(), exports_open));
|
|
702
|
+
await open2(url);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
async readFile(path3, options) {
|
|
706
|
+
try {
|
|
707
|
+
if (options) {
|
|
708
|
+
return await fs6.readFile(path3, "utf-8");
|
|
709
|
+
}
|
|
710
|
+
return await fs6.readFile(path3);
|
|
711
|
+
} catch (error) {
|
|
712
|
+
if (this.isEnoent(error))
|
|
713
|
+
return null;
|
|
714
|
+
throw error;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
async writeFile(filePath, data) {
|
|
718
|
+
const dir = path2.dirname(filePath);
|
|
719
|
+
if (dir) {
|
|
720
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
721
|
+
}
|
|
722
|
+
await fs6.writeFile(filePath, data);
|
|
723
|
+
}
|
|
724
|
+
async appendFile(filePath, data) {
|
|
725
|
+
const dir = path2.dirname(filePath);
|
|
726
|
+
if (dir) {
|
|
727
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
728
|
+
}
|
|
729
|
+
await fs6.appendFile(filePath, data);
|
|
730
|
+
}
|
|
731
|
+
async readdir(dirPath) {
|
|
732
|
+
try {
|
|
733
|
+
return await fs6.readdir(dirPath);
|
|
734
|
+
} catch (error) {
|
|
735
|
+
if (this.isEnoent(error))
|
|
736
|
+
return [];
|
|
737
|
+
throw error;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
async stat(filePath) {
|
|
741
|
+
try {
|
|
742
|
+
const stats = await fs6.stat(filePath);
|
|
743
|
+
return {
|
|
744
|
+
isFile: () => stats.isFile(),
|
|
745
|
+
isDirectory: () => stats.isDirectory(),
|
|
746
|
+
size: stats.size,
|
|
747
|
+
mtimeMs: stats.mtimeMs
|
|
748
|
+
};
|
|
749
|
+
} catch (error) {
|
|
750
|
+
if (this.isEnoent(error))
|
|
751
|
+
return null;
|
|
752
|
+
throw error;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
async exists(filePath) {
|
|
756
|
+
return existsSync(filePath);
|
|
757
|
+
}
|
|
758
|
+
async mkdir(dirPath) {
|
|
759
|
+
await fs6.mkdir(dirPath, { recursive: true });
|
|
760
|
+
}
|
|
761
|
+
async acquireLock(lockPath) {
|
|
762
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
763
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
764
|
+
const ownerId = randomUUID();
|
|
765
|
+
const start = Date.now();
|
|
766
|
+
while (true) {
|
|
767
|
+
try {
|
|
768
|
+
await fs6.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
769
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
770
|
+
} catch (error) {
|
|
771
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
772
|
+
throw error;
|
|
773
|
+
}
|
|
774
|
+
const stats = await fs6.stat(lockFile).catch(() => null);
|
|
775
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
776
|
+
const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
777
|
+
if (reclaimed)
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
781
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
782
|
+
}
|
|
783
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
async canonicalizeLockTarget(lockPath) {
|
|
788
|
+
const absolute = path2.resolve(lockPath);
|
|
789
|
+
const fullReal = await fs6.realpath(absolute).catch(() => null);
|
|
790
|
+
if (fullReal)
|
|
791
|
+
return fullReal;
|
|
792
|
+
const parent = path2.dirname(absolute);
|
|
793
|
+
const base = path2.basename(absolute);
|
|
794
|
+
const canonicalParent = await fs6.realpath(parent).catch(() => parent);
|
|
795
|
+
return path2.join(canonicalParent, base);
|
|
796
|
+
}
|
|
797
|
+
createLockRelease(lockFile, ownerId) {
|
|
798
|
+
const heartbeatStart = Date.now();
|
|
799
|
+
let heartbeatTimer;
|
|
800
|
+
let stopped = false;
|
|
801
|
+
const stopHeartbeat = () => {
|
|
802
|
+
stopped = true;
|
|
803
|
+
if (heartbeatTimer)
|
|
804
|
+
clearTimeout(heartbeatTimer);
|
|
805
|
+
};
|
|
806
|
+
const scheduleNextHeartbeat = () => {
|
|
807
|
+
if (stopped)
|
|
808
|
+
return;
|
|
809
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
810
|
+
stopped = true;
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
heartbeatTimer = setTimeout(() => {
|
|
814
|
+
runHeartbeat();
|
|
815
|
+
}, LOCK_HEARTBEAT_MS);
|
|
816
|
+
heartbeatTimer.unref?.();
|
|
817
|
+
};
|
|
818
|
+
const runHeartbeat = async () => {
|
|
819
|
+
if (stopped)
|
|
820
|
+
return;
|
|
821
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
822
|
+
if (stopped)
|
|
823
|
+
return;
|
|
824
|
+
if (current !== ownerId) {
|
|
825
|
+
stopped = true;
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
const now = Date.now() / 1000;
|
|
829
|
+
await fs6.utimes(lockFile, now, now).catch(() => {});
|
|
830
|
+
scheduleNextHeartbeat();
|
|
831
|
+
};
|
|
832
|
+
scheduleNextHeartbeat();
|
|
833
|
+
let released = false;
|
|
834
|
+
return async () => {
|
|
835
|
+
if (released)
|
|
836
|
+
return;
|
|
837
|
+
released = true;
|
|
838
|
+
stopHeartbeat();
|
|
839
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
840
|
+
if (current === ownerId) {
|
|
841
|
+
await fs6.rm(lockFile, { force: true });
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
async rm(filePath) {
|
|
846
|
+
await fs6.rm(filePath, { recursive: true, force: true });
|
|
847
|
+
}
|
|
848
|
+
async rename(oldPath, newPath) {
|
|
849
|
+
await fs6.rename(oldPath, newPath);
|
|
850
|
+
}
|
|
851
|
+
async realpath(filePath) {
|
|
852
|
+
try {
|
|
853
|
+
return await fs6.realpath(filePath);
|
|
854
|
+
} catch (error) {
|
|
855
|
+
if (this.isEnoent(error))
|
|
856
|
+
return filePath;
|
|
857
|
+
throw error;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
async getTempDir() {
|
|
861
|
+
return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
|
|
862
|
+
}
|
|
863
|
+
async copyDirectory(sourcePath, destPath) {
|
|
864
|
+
const sourceStats = await this.stat(sourcePath);
|
|
865
|
+
if (!sourceStats) {
|
|
866
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
867
|
+
}
|
|
868
|
+
if (!sourceStats.isDirectory()) {
|
|
869
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
870
|
+
}
|
|
871
|
+
await this.mkdir(destPath);
|
|
872
|
+
const entries = await this.readdir(sourcePath);
|
|
873
|
+
for (const entry of entries) {
|
|
874
|
+
const srcEntry = path2.join(sourcePath, entry);
|
|
875
|
+
const destEntry = path2.join(destPath, entry);
|
|
876
|
+
const entryStats = await this.stat(srcEntry);
|
|
877
|
+
if (!entryStats)
|
|
878
|
+
continue;
|
|
879
|
+
if (entryStats.isDirectory()) {
|
|
880
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
881
|
+
} else if (entryStats.isFile()) {
|
|
882
|
+
const content = await this.readFile(srcEntry);
|
|
883
|
+
if (content !== null) {
|
|
884
|
+
await this.writeFile(destEntry, content);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
isEnoent(error) {
|
|
890
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
891
|
+
}
|
|
892
|
+
hasErrnoCode(error, code) {
|
|
893
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// ../filesystem/src/index.ts
|
|
898
|
+
var fsInstance = new NodeFileSystem;
|
|
899
|
+
var getFileSystem = () => fsInstance;
|
|
900
|
+
|
|
901
|
+
// ../../node_modules/fflate/esm/index.mjs
|
|
902
|
+
import { createRequire } from "module";
|
|
903
|
+
var require2 = createRequire("/");
|
|
904
|
+
var _a;
|
|
905
|
+
var Worker;
|
|
906
|
+
var isMarkedAsUntransferable;
|
|
907
|
+
try {
|
|
908
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
909
|
+
} catch (e) {}
|
|
910
|
+
var u8 = Uint8Array;
|
|
911
|
+
var u16 = Uint16Array;
|
|
912
|
+
var i32 = Int32Array;
|
|
913
|
+
var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]);
|
|
914
|
+
var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]);
|
|
915
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
916
|
+
var freb = function(eb, start) {
|
|
917
|
+
var b = new u16(31);
|
|
918
|
+
for (var i = 0;i < 31; ++i) {
|
|
919
|
+
b[i] = start += 1 << eb[i - 1];
|
|
920
|
+
}
|
|
921
|
+
var r = new i32(b[30]);
|
|
922
|
+
for (var i = 1;i < 30; ++i) {
|
|
923
|
+
for (var j = b[i];j < b[i + 1]; ++j) {
|
|
924
|
+
r[j] = j - b[i] << 5 | i;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return { b, r };
|
|
928
|
+
};
|
|
929
|
+
var _a = freb(fleb, 2);
|
|
930
|
+
var fl = _a.b;
|
|
931
|
+
var revfl = _a.r;
|
|
932
|
+
fl[28] = 258, revfl[258] = 28;
|
|
933
|
+
var _b = freb(fdeb, 0);
|
|
934
|
+
var fd = _b.b;
|
|
935
|
+
var revfd = _b.r;
|
|
936
|
+
var rev = new u16(32768);
|
|
937
|
+
for (i = 0;i < 32768; ++i) {
|
|
938
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
939
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
940
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
941
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
942
|
+
}
|
|
943
|
+
var x;
|
|
944
|
+
var i;
|
|
945
|
+
var hMap = function(cd, mb, r) {
|
|
946
|
+
var s = cd.length;
|
|
947
|
+
var i2 = 0;
|
|
948
|
+
var l = new u16(mb);
|
|
949
|
+
for (;i2 < s; ++i2) {
|
|
950
|
+
if (cd[i2])
|
|
951
|
+
++l[cd[i2] - 1];
|
|
952
|
+
}
|
|
953
|
+
var le = new u16(mb);
|
|
954
|
+
for (i2 = 1;i2 < mb; ++i2) {
|
|
955
|
+
le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
|
|
956
|
+
}
|
|
957
|
+
var co;
|
|
958
|
+
if (r) {
|
|
959
|
+
co = new u16(1 << mb);
|
|
960
|
+
var rvb = 15 - mb;
|
|
961
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
962
|
+
if (cd[i2]) {
|
|
963
|
+
var sv = i2 << 4 | cd[i2];
|
|
964
|
+
var r_1 = mb - cd[i2];
|
|
965
|
+
var v = le[cd[i2] - 1]++ << r_1;
|
|
966
|
+
for (var m = v | (1 << r_1) - 1;v <= m; ++v) {
|
|
967
|
+
co[rev[v] >> rvb] = sv;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
} else {
|
|
972
|
+
co = new u16(s);
|
|
973
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
974
|
+
if (cd[i2]) {
|
|
975
|
+
co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return co;
|
|
980
|
+
};
|
|
981
|
+
var flt = new u8(288);
|
|
982
|
+
for (i = 0;i < 144; ++i)
|
|
983
|
+
flt[i] = 8;
|
|
984
|
+
var i;
|
|
985
|
+
for (i = 144;i < 256; ++i)
|
|
986
|
+
flt[i] = 9;
|
|
987
|
+
var i;
|
|
988
|
+
for (i = 256;i < 280; ++i)
|
|
989
|
+
flt[i] = 7;
|
|
990
|
+
var i;
|
|
991
|
+
for (i = 280;i < 288; ++i)
|
|
992
|
+
flt[i] = 8;
|
|
993
|
+
var i;
|
|
994
|
+
var fdt = new u8(32);
|
|
995
|
+
for (i = 0;i < 32; ++i)
|
|
996
|
+
fdt[i] = 5;
|
|
997
|
+
var i;
|
|
998
|
+
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
999
|
+
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
1000
|
+
var max = function(a) {
|
|
1001
|
+
var m = a[0];
|
|
1002
|
+
for (var i2 = 1;i2 < a.length; ++i2) {
|
|
1003
|
+
if (a[i2] > m)
|
|
1004
|
+
m = a[i2];
|
|
1005
|
+
}
|
|
1006
|
+
return m;
|
|
1007
|
+
};
|
|
1008
|
+
var bits = function(d, p, m) {
|
|
1009
|
+
var o = p / 8 | 0;
|
|
1010
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
1011
|
+
};
|
|
1012
|
+
var bits16 = function(d, p) {
|
|
1013
|
+
var o = p / 8 | 0;
|
|
1014
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
1015
|
+
};
|
|
1016
|
+
var shft = function(p) {
|
|
1017
|
+
return (p + 7) / 8 | 0;
|
|
1018
|
+
};
|
|
1019
|
+
var slc = function(v, s, e) {
|
|
1020
|
+
if (s == null || s < 0)
|
|
1021
|
+
s = 0;
|
|
1022
|
+
if (e == null || e > v.length)
|
|
1023
|
+
e = v.length;
|
|
1024
|
+
return new u8(v.subarray(s, e));
|
|
1025
|
+
};
|
|
1026
|
+
var ec = [
|
|
1027
|
+
"unexpected EOF",
|
|
1028
|
+
"invalid block type",
|
|
1029
|
+
"invalid length/literal",
|
|
1030
|
+
"invalid distance",
|
|
1031
|
+
"stream finished",
|
|
1032
|
+
"no stream handler",
|
|
1033
|
+
,
|
|
1034
|
+
"no callback",
|
|
1035
|
+
"invalid UTF-8 data",
|
|
1036
|
+
"extra field too long",
|
|
1037
|
+
"date not in range 1980-2099",
|
|
1038
|
+
"filename too long",
|
|
1039
|
+
"stream finishing",
|
|
1040
|
+
"invalid zip data"
|
|
1041
|
+
];
|
|
1042
|
+
var err = function(ind, msg, nt) {
|
|
1043
|
+
var e = new Error(msg || ec[ind]);
|
|
1044
|
+
e.code = ind;
|
|
1045
|
+
if (Error.captureStackTrace)
|
|
1046
|
+
Error.captureStackTrace(e, err);
|
|
1047
|
+
if (!nt)
|
|
1048
|
+
throw e;
|
|
1049
|
+
return e;
|
|
1050
|
+
};
|
|
1051
|
+
var inflt = function(dat, st, buf, dict) {
|
|
1052
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
1053
|
+
if (!sl || st.f && !st.l)
|
|
1054
|
+
return buf || new u8(0);
|
|
1055
|
+
var noBuf = !buf;
|
|
1056
|
+
var resize = noBuf || st.i != 2;
|
|
1057
|
+
var noSt = st.i;
|
|
1058
|
+
if (noBuf)
|
|
1059
|
+
buf = new u8(sl * 3);
|
|
1060
|
+
var cbuf = function(l2) {
|
|
1061
|
+
var bl = buf.length;
|
|
1062
|
+
if (l2 > bl) {
|
|
1063
|
+
var nbuf = new u8(Math.max(bl * 2, l2));
|
|
1064
|
+
nbuf.set(buf);
|
|
1065
|
+
buf = nbuf;
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
1069
|
+
var tbts = sl * 8;
|
|
1070
|
+
do {
|
|
1071
|
+
if (!lm) {
|
|
1072
|
+
final = bits(dat, pos, 1);
|
|
1073
|
+
var type = bits(dat, pos + 1, 3);
|
|
1074
|
+
pos += 3;
|
|
1075
|
+
if (!type) {
|
|
1076
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
1077
|
+
if (t > sl) {
|
|
1078
|
+
if (noSt)
|
|
1079
|
+
err(0);
|
|
1080
|
+
break;
|
|
1081
|
+
}
|
|
1082
|
+
if (resize)
|
|
1083
|
+
cbuf(bt + l);
|
|
1084
|
+
buf.set(dat.subarray(s, t), bt);
|
|
1085
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
1086
|
+
continue;
|
|
1087
|
+
} else if (type == 1)
|
|
1088
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
1089
|
+
else if (type == 2) {
|
|
1090
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
1091
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
1092
|
+
pos += 14;
|
|
1093
|
+
var ldt = new u8(tl);
|
|
1094
|
+
var clt = new u8(19);
|
|
1095
|
+
for (var i2 = 0;i2 < hcLen; ++i2) {
|
|
1096
|
+
clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
|
|
1097
|
+
}
|
|
1098
|
+
pos += hcLen * 3;
|
|
1099
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
1100
|
+
var clm = hMap(clt, clb, 1);
|
|
1101
|
+
for (var i2 = 0;i2 < tl; ) {
|
|
1102
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
1103
|
+
pos += r & 15;
|
|
1104
|
+
var s = r >> 4;
|
|
1105
|
+
if (s < 16) {
|
|
1106
|
+
ldt[i2++] = s;
|
|
1107
|
+
} else {
|
|
1108
|
+
var c = 0, n = 0;
|
|
1109
|
+
if (s == 16)
|
|
1110
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
|
|
1111
|
+
else if (s == 17)
|
|
1112
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
1113
|
+
else if (s == 18)
|
|
1114
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
1115
|
+
while (n--)
|
|
1116
|
+
ldt[i2++] = c;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
1120
|
+
lbt = max(lt);
|
|
1121
|
+
dbt = max(dt);
|
|
1122
|
+
lm = hMap(lt, lbt, 1);
|
|
1123
|
+
dm = hMap(dt, dbt, 1);
|
|
1124
|
+
} else
|
|
1125
|
+
err(1);
|
|
1126
|
+
if (pos > tbts) {
|
|
1127
|
+
if (noSt)
|
|
1128
|
+
err(0);
|
|
1129
|
+
break;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
if (resize)
|
|
1133
|
+
cbuf(bt + 131072);
|
|
1134
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
1135
|
+
var lpos = pos;
|
|
1136
|
+
for (;; lpos = pos) {
|
|
1137
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
1138
|
+
pos += c & 15;
|
|
1139
|
+
if (pos > tbts) {
|
|
1140
|
+
if (noSt)
|
|
1141
|
+
err(0);
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
if (!c)
|
|
1145
|
+
err(2);
|
|
1146
|
+
if (sym < 256)
|
|
1147
|
+
buf[bt++] = sym;
|
|
1148
|
+
else if (sym == 256) {
|
|
1149
|
+
lpos = pos, lm = null;
|
|
1150
|
+
break;
|
|
1151
|
+
} else {
|
|
1152
|
+
var add = sym - 254;
|
|
1153
|
+
if (sym > 264) {
|
|
1154
|
+
var i2 = sym - 257, b = fleb[i2];
|
|
1155
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i2];
|
|
1156
|
+
pos += b;
|
|
1157
|
+
}
|
|
1158
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
1159
|
+
if (!d)
|
|
1160
|
+
err(3);
|
|
1161
|
+
pos += d & 15;
|
|
1162
|
+
var dt = fd[dsym];
|
|
1163
|
+
if (dsym > 3) {
|
|
1164
|
+
var b = fdeb[dsym];
|
|
1165
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
1166
|
+
}
|
|
1167
|
+
if (pos > tbts) {
|
|
1168
|
+
if (noSt)
|
|
1169
|
+
err(0);
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
if (resize)
|
|
1173
|
+
cbuf(bt + 131072);
|
|
1174
|
+
var end = bt + add;
|
|
1175
|
+
if (bt < dt) {
|
|
1176
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
1177
|
+
if (shift + bt < 0)
|
|
1178
|
+
err(3);
|
|
1179
|
+
for (;bt < dend; ++bt)
|
|
1180
|
+
buf[bt] = dict[shift + bt];
|
|
1181
|
+
}
|
|
1182
|
+
for (;bt < end; ++bt)
|
|
1183
|
+
buf[bt] = buf[bt - dt];
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
1187
|
+
if (lm)
|
|
1188
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
1189
|
+
} while (!final);
|
|
1190
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
1191
|
+
};
|
|
1192
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
1193
|
+
var b2 = function(d, b) {
|
|
1194
|
+
return d[b] | d[b + 1] << 8;
|
|
1195
|
+
};
|
|
1196
|
+
var b4 = function(d, b) {
|
|
1197
|
+
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
|
|
1198
|
+
};
|
|
1199
|
+
var b8 = function(d, b) {
|
|
1200
|
+
return b4(d, b) + b4(d, b + 4) * 4294967296;
|
|
1201
|
+
};
|
|
1202
|
+
function inflateSync(data, opts) {
|
|
1203
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
1204
|
+
}
|
|
1205
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
|
|
1206
|
+
var tds = 0;
|
|
1207
|
+
try {
|
|
1208
|
+
td.decode(et, { stream: true });
|
|
1209
|
+
tds = 1;
|
|
1210
|
+
} catch (e) {}
|
|
1211
|
+
var dutf8 = function(d) {
|
|
1212
|
+
for (var r = "", i2 = 0;; ) {
|
|
1213
|
+
var c = d[i2++];
|
|
1214
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
1215
|
+
if (i2 + eb > d.length)
|
|
1216
|
+
return { s: r, r: slc(d, i2 - 1) };
|
|
1217
|
+
if (!eb)
|
|
1218
|
+
r += String.fromCharCode(c);
|
|
1219
|
+
else if (eb == 3) {
|
|
1220
|
+
c = ((c & 15) << 18 | (d[i2++] & 63) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
|
|
1221
|
+
} else if (eb & 1)
|
|
1222
|
+
r += String.fromCharCode((c & 31) << 6 | d[i2++] & 63);
|
|
1223
|
+
else
|
|
1224
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63);
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
function strFromU8(dat, latin1) {
|
|
1228
|
+
if (latin1) {
|
|
1229
|
+
var r = "";
|
|
1230
|
+
for (var i2 = 0;i2 < dat.length; i2 += 16384)
|
|
1231
|
+
r += String.fromCharCode.apply(null, dat.subarray(i2, i2 + 16384));
|
|
1232
|
+
return r;
|
|
1233
|
+
} else if (td) {
|
|
1234
|
+
return td.decode(dat);
|
|
1235
|
+
} else {
|
|
1236
|
+
var _a2 = dutf8(dat), s = _a2.s, r = _a2.r;
|
|
1237
|
+
if (r.length)
|
|
1238
|
+
err(8);
|
|
1239
|
+
return s;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
var slzh = function(d, b) {
|
|
1243
|
+
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
|
|
1244
|
+
};
|
|
1245
|
+
var zh = function(d, b, z) {
|
|
1246
|
+
var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;
|
|
1247
|
+
var _a2 = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a2[0], su = _a2[1], off = _a2[2];
|
|
1248
|
+
return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
|
|
1249
|
+
};
|
|
1250
|
+
var z64hs = function(d, b, l, z, sc, su, off) {
|
|
1251
|
+
var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;
|
|
1252
|
+
var nf = nsc + nsu + noff;
|
|
1253
|
+
if (z && nf) {
|
|
1254
|
+
for (;b + 4 < e; b += 4 + b2(d, b + 2)) {
|
|
1255
|
+
if (b2(d, b) == 1) {
|
|
1256
|
+
return [
|
|
1257
|
+
nsc ? b8(d, b + 4 + 8 * nsu) : sc,
|
|
1258
|
+
nsu ? b8(d, b + 4) : su,
|
|
1259
|
+
noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
|
|
1260
|
+
1
|
|
1261
|
+
];
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
if (z < 2)
|
|
1265
|
+
err(13);
|
|
1266
|
+
}
|
|
1267
|
+
return [sc, su, off, 0];
|
|
1268
|
+
};
|
|
1269
|
+
function unzipSync(data, opts) {
|
|
1270
|
+
var files = {};
|
|
1271
|
+
var e = data.length - 22;
|
|
1272
|
+
for (;b4(data, e) != 101010256; --e) {
|
|
1273
|
+
if (!e || data.length - e > 65558)
|
|
1274
|
+
err(13);
|
|
1275
|
+
}
|
|
1276
|
+
var c = b2(data, e + 8);
|
|
1277
|
+
if (!c)
|
|
1278
|
+
return {};
|
|
1279
|
+
var o = b4(data, e + 16);
|
|
1280
|
+
var z = b4(data, e - 20) == 117853008;
|
|
1281
|
+
if (z) {
|
|
1282
|
+
var ze = b4(data, e - 12);
|
|
1283
|
+
z = b4(data, ze) == 101075792;
|
|
1284
|
+
if (z) {
|
|
1285
|
+
c = b4(data, ze + 32);
|
|
1286
|
+
o = b4(data, ze + 48);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
var fltr = opts && opts.filter;
|
|
1290
|
+
for (var i2 = 0;i2 < c; ++i2) {
|
|
1291
|
+
var _a2 = zh(data, o, z), c_2 = _a2[0], sc = _a2[1], su = _a2[2], fn = _a2[3], no = _a2[4], off = _a2[5], b = slzh(data, off);
|
|
1292
|
+
o = no;
|
|
1293
|
+
if (!fltr || fltr({
|
|
1294
|
+
name: fn,
|
|
1295
|
+
size: sc,
|
|
1296
|
+
originalSize: su,
|
|
1297
|
+
compression: c_2
|
|
1298
|
+
})) {
|
|
1299
|
+
if (!c_2)
|
|
1300
|
+
files[fn] = slc(data, b, b + sc);
|
|
1301
|
+
else if (c_2 == 8)
|
|
1302
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
|
|
1303
|
+
else
|
|
1304
|
+
err(14, "unknown compression type " + c_2);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return files;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/zip.ts
|
|
1311
|
+
function resolveZipEntryPath(fs7, root, entryName) {
|
|
1312
|
+
if (entryName.includes("\x00")) {
|
|
1313
|
+
throw new Error(`Invalid zip entry path: ${entryName}`);
|
|
1314
|
+
}
|
|
1315
|
+
const normalizedEntry = entryName.replace(/\\/g, "/");
|
|
1316
|
+
if (normalizedEntry.startsWith("/")) {
|
|
1317
|
+
throw new Error(`Unsafe absolute zip entry path: ${entryName}`);
|
|
1318
|
+
}
|
|
1319
|
+
const target = fs7.path.resolve(root, normalizedEntry);
|
|
1320
|
+
if (!isUnder(fs7, root, target)) {
|
|
1321
|
+
throw new Error(`Unsafe zip entry path: ${entryName}`);
|
|
1322
|
+
}
|
|
1323
|
+
return target;
|
|
1324
|
+
}
|
|
1325
|
+
function isUnder(fs7, root, path3) {
|
|
1326
|
+
const relative2 = fs7.path.relative(root, path3);
|
|
1327
|
+
return relative2 === "" || !relative2.startsWith("..") && !fs7.path.isAbsolute(relative2);
|
|
1328
|
+
}
|
|
1329
|
+
async function assertNoEscapeThroughSymlink(fs7, lexicalRoot, realRoot, path3, entryName) {
|
|
1330
|
+
const resolved = await fs7.realpath(path3);
|
|
1331
|
+
if (isUnder(fs7, realRoot, resolved) || isUnder(fs7, lexicalRoot, resolved)) {
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
throw new Error(`Unsafe zip entry path (escapes via a symlink at the destination): ${entryName}`);
|
|
1335
|
+
}
|
|
1336
|
+
async function mkdirUnderRoot(fs7, lexicalRoot, realRoot, dir, entryName) {
|
|
1337
|
+
const relative2 = fs7.path.relative(lexicalRoot, dir);
|
|
1338
|
+
if (relative2 === "") {
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
let current = lexicalRoot;
|
|
1342
|
+
for (const segment of relative2.split(/[\\/]/)) {
|
|
1343
|
+
if (segment === "") {
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1346
|
+
current = fs7.path.join(current, segment);
|
|
1347
|
+
await fs7.mkdir(current);
|
|
1348
|
+
await assertNoEscapeThroughSymlink(fs7, lexicalRoot, realRoot, current, entryName);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
async function extractZipDataToDir(fs7, zipData, destinationDir) {
|
|
1352
|
+
await fs7.mkdir(destinationDir);
|
|
1353
|
+
const lexicalRoot = fs7.path.resolve(destinationDir);
|
|
1354
|
+
const realRoot = await fs7.realpath(lexicalRoot);
|
|
1355
|
+
const entries = unzipSync(zipData);
|
|
1356
|
+
for (const [entryName, content] of Object.entries(entries)) {
|
|
1357
|
+
const target = resolveZipEntryPath(fs7, lexicalRoot, entryName);
|
|
1358
|
+
if (entryName.endsWith("/")) {
|
|
1359
|
+
await mkdirUnderRoot(fs7, lexicalRoot, realRoot, target, entryName);
|
|
1360
|
+
continue;
|
|
1361
|
+
}
|
|
1362
|
+
await mkdirUnderRoot(fs7, lexicalRoot, realRoot, fs7.path.dirname(target), entryName);
|
|
1363
|
+
await assertNoEscapeThroughSymlink(fs7, lexicalRoot, realRoot, target, entryName);
|
|
1364
|
+
await fs7.writeFile(target, content);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
async function extractArchive(archivePath, destinationDir) {
|
|
1368
|
+
const fs7 = getFileSystem();
|
|
1369
|
+
const data = await fs7.readFile(archivePath);
|
|
1370
|
+
if (data === null) {
|
|
1371
|
+
throw new Error(`Archive not found: ${archivePath}`);
|
|
1372
|
+
}
|
|
1373
|
+
await extractZipDataToDir(fs7, data, destinationDir);
|
|
1374
|
+
}
|
|
1375
|
+
export {
|
|
1376
|
+
extractArchive,
|
|
1377
|
+
extractZipDataToDir
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
//# debugId=F6A43A121557626864756E2164756E21
|