@uipath/maestro-tool 1.202.0 → 1.202.1
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 +6 -6
- package/dist/{binding-service-9cpz0tqq.js → binding-service-mys9xgtq.js} +8 -6
- package/dist/{bpmn-branch-t8b8rfmt.js → bpmn-branch-2ebce3qk.js} +1 -1
- package/dist/{connector-service-v4yh0eyv.js → connector-service-3bgm62za.js} +7 -5
- package/dist/{debug-conversation-trigger-cayhnvaq.js → debug-conversation-trigger-4wwf0q8y.js} +6 -4
- package/dist/{edge-service-a1ebhenc.js → edge-service-xn2a6p72.js} +6 -4
- package/dist/{flow-debug-service-5jadwsy2.js → flow-debug-service-yk2d27p1.js} +26 -16
- package/dist/{flow-eval-node-target-0pb6zbcd.js → flow-eval-node-target-13ek4f1p.js} +6 -4
- package/dist/{flow-eval-run-service-tta4zrh6.js → flow-eval-run-service-86tpst0m.js} +17 -9
- package/dist/{flow-eval-service-w4md0ckf.js → flow-eval-service-y6ex6rke.js} +6 -4
- package/dist/{flow-init-service-w2p3bwen.js → flow-init-service-mpf8h2rc.js} +14 -6
- package/dist/{flow-io-9btcd4zv.js → flow-io-hgw3em5c.js} +6 -4
- package/dist/{flow-migrate-service-81x84kjq.js → flow-migrate-service-6j2rpfzt.js} +6 -4
- package/dist/{flow-pack-service-med0b4fd.js → flow-pack-service-1gnvp34k.js} +17 -9
- package/dist/{flow-validate-service-5npqgneg.js → flow-validate-service-9wjnacww.js} +15 -13
- package/dist/{hitl-service-809d7e9f.js → hitl-service-f3zvaq6r.js} +6 -4
- package/dist/index.js +2 -2
- package/dist/maestro-automate-entry-gwntzkvj.js +22 -0
- package/dist/{node-39h6t9g1.js → node-jkh8qtrz.js} +5 -3
- package/dist/{node-service-57wz87mt.js → node-service-z7akfnxt.js} +8 -6
- package/dist/packager-tool-2513jrxr.js +898 -0
- package/dist/{packager-tool-5wpa21t9.js → packager-tool-35rk0942.js} +1 -1
- package/dist/{packager-tool-syzagd6j.js → packager-tool-7p56pr16.js} +2 -2
- package/dist/packager-tool-7rz102fw.js +53 -0
- package/dist/packager-tool-9cq9atem.js +2 -0
- package/dist/{packager-tool-jd6h2c82.js → packager-tool-a25ctv7h.js} +1 -1
- package/dist/{packager-tool-e01rnrh2.js → packager-tool-ahj646v3.js} +35 -9
- package/dist/{packager-tool-t46k3943.js → packager-tool-fs8d9nzm.js} +2 -2
- package/dist/{packager-tool-965eyt0n.js → packager-tool-k4x5yn3p.js} +2 -897
- package/dist/{packager-tool-01nr6e51.js → packager-tool-m4gbq68e.js} +2 -2
- package/dist/{packager-tool-xbg254pp.js → packager-tool-q1227jxk.js} +6 -3
- package/dist/{packager-tool-hre2xt0n.js → packager-tool-spgs86me.js} +1 -1
- package/dist/{packager-tool-z37jh0t0.js → packager-tool-tb9ea902.js} +1 -1
- package/dist/{packager-tool-nxegf0n0.js → packager-tool-wp25zdm0.js} +4 -4
- package/dist/packager-tool.js +5 -3
- package/dist/{tidy-service-trwrg13b.js → tidy-service-rm7y4dn2.js} +7 -5
- package/dist/{tool-g4bdpah8.js → tool-hm0yzjxd.js} +59 -46
- package/dist/tool.js +2 -2
- package/dist/{variable-service-13g804gy.js → variable-service-25vdpt12.js} +6 -4
- package/package.json +2 -2
- /package/dist/{localization-v39c1e4y.js → localization-bbsjxbj4.js} +0 -0
- /package/dist/{tool-gxc0e75g.js → tool-xpmr8bsy.js} +0 -0
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
// ../filesystem/dist/index.js
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import fs2 from "node:fs";
|
|
4
|
+
import process2 from "node:process";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import fs3 from "node:fs";
|
|
7
|
+
import process3 from "node:process";
|
|
8
|
+
import { Buffer } from "node:buffer";
|
|
9
|
+
import { promisify } from "node:util";
|
|
10
|
+
import childProcess from "node:child_process";
|
|
11
|
+
import { promisify as promisify2 } from "node:util";
|
|
12
|
+
import childProcess2 from "node:child_process";
|
|
13
|
+
import fs4, { constants as fsConstants } from "node:fs/promises";
|
|
14
|
+
import { promisify as promisify3 } from "node:util";
|
|
15
|
+
import process4 from "node:process";
|
|
16
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
17
|
+
import process5 from "node:process";
|
|
18
|
+
import { promisify as promisify4 } from "node:util";
|
|
19
|
+
import { execFile as execFile4, execFileSync } from "node:child_process";
|
|
20
|
+
import { promisify as promisify5 } from "node:util";
|
|
21
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
22
|
+
import { promisify as promisify6 } from "node:util";
|
|
23
|
+
import process6 from "node:process";
|
|
24
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
25
|
+
import process7 from "node:process";
|
|
26
|
+
import process8 from "node:process";
|
|
27
|
+
import path from "node:path";
|
|
28
|
+
import { fileURLToPath } from "node:url";
|
|
29
|
+
import childProcess3 from "node:child_process";
|
|
30
|
+
import fs5, { constants as fsConstants2 } from "node:fs/promises";
|
|
31
|
+
import { randomUUID } from "node:crypto";
|
|
32
|
+
import { existsSync } from "node:fs";
|
|
33
|
+
import * as fs6 from "node:fs/promises";
|
|
34
|
+
import * as os2 from "node:os";
|
|
35
|
+
import * as path2 from "node:path";
|
|
36
|
+
var __defProp = Object.defineProperty;
|
|
37
|
+
var __returnValue = (v) => v;
|
|
38
|
+
function __exportSetter(name, newValue) {
|
|
39
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
40
|
+
}
|
|
41
|
+
var __export = (target, all) => {
|
|
42
|
+
for (var name in all)
|
|
43
|
+
__defProp(target, name, {
|
|
44
|
+
get: all[name],
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
set: __exportSetter.bind(all, name)
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
51
|
+
function hasDockerEnv() {
|
|
52
|
+
try {
|
|
53
|
+
fs.statSync("/.dockerenv");
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function hasDockerCGroup() {
|
|
60
|
+
try {
|
|
61
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function isDocker() {
|
|
67
|
+
if (isDockerCached === undefined) {
|
|
68
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
69
|
+
}
|
|
70
|
+
return isDockerCached;
|
|
71
|
+
}
|
|
72
|
+
var isDockerCached;
|
|
73
|
+
var init_is_docker = () => {};
|
|
74
|
+
function isInsideContainer() {
|
|
75
|
+
if (cachedResult === undefined) {
|
|
76
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
77
|
+
}
|
|
78
|
+
return cachedResult;
|
|
79
|
+
}
|
|
80
|
+
var cachedResult;
|
|
81
|
+
var hasContainerEnv = () => {
|
|
82
|
+
try {
|
|
83
|
+
fs2.statSync("/run/.containerenv");
|
|
84
|
+
return true;
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var init_is_inside_container = __esm(() => {
|
|
90
|
+
init_is_docker();
|
|
91
|
+
});
|
|
92
|
+
var isWsl = () => {
|
|
93
|
+
if (process2.platform !== "linux") {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
97
|
+
if (isInsideContainer()) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
104
|
+
return !isInsideContainer();
|
|
105
|
+
}
|
|
106
|
+
} catch {}
|
|
107
|
+
if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
|
|
108
|
+
return !isInsideContainer();
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
};
|
|
112
|
+
var is_wsl_default;
|
|
113
|
+
var init_is_wsl = __esm(() => {
|
|
114
|
+
init_is_inside_container();
|
|
115
|
+
is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
116
|
+
});
|
|
117
|
+
var execFile;
|
|
118
|
+
var powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
119
|
+
var executePowerShell = async (command, options = {}) => {
|
|
120
|
+
const {
|
|
121
|
+
powerShellPath: psPath,
|
|
122
|
+
...execFileOptions
|
|
123
|
+
} = options;
|
|
124
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
125
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
126
|
+
...executePowerShell.argumentsPrefix,
|
|
127
|
+
encodedCommand
|
|
128
|
+
], {
|
|
129
|
+
encoding: "utf8",
|
|
130
|
+
...execFileOptions
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
var init_powershell_utils = __esm(() => {
|
|
134
|
+
execFile = promisify(childProcess.execFile);
|
|
135
|
+
executePowerShell.argumentsPrefix = [
|
|
136
|
+
"-NoProfile",
|
|
137
|
+
"-NonInteractive",
|
|
138
|
+
"-ExecutionPolicy",
|
|
139
|
+
"Bypass",
|
|
140
|
+
"-EncodedCommand"
|
|
141
|
+
];
|
|
142
|
+
executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
|
|
143
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
144
|
+
});
|
|
145
|
+
function parseMountPointFromConfig(content) {
|
|
146
|
+
for (const line of content.split(`
|
|
147
|
+
`)) {
|
|
148
|
+
if (/^\s*#/.test(line)) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
152
|
+
if (!match) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
var execFile2;
|
|
159
|
+
var wslDrivesMountPoint;
|
|
160
|
+
var powerShellPathFromWsl = async () => {
|
|
161
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
162
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
163
|
+
};
|
|
164
|
+
var powerShellPath2;
|
|
165
|
+
var canAccessPowerShellPromise;
|
|
166
|
+
var canAccessPowerShell = async () => {
|
|
167
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
168
|
+
try {
|
|
169
|
+
const psPath = await powerShellPath2();
|
|
170
|
+
await fs4.access(psPath, fsConstants.X_OK);
|
|
171
|
+
return true;
|
|
172
|
+
} catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
})();
|
|
176
|
+
return canAccessPowerShellPromise;
|
|
177
|
+
};
|
|
178
|
+
var wslDefaultBrowser = async () => {
|
|
179
|
+
const psPath = await powerShellPath2();
|
|
180
|
+
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
181
|
+
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
182
|
+
return stdout.trim();
|
|
183
|
+
};
|
|
184
|
+
var convertWslPathToWindows = async (path3) => {
|
|
185
|
+
if (/^[a-z]+:\/\//i.test(path3)) {
|
|
186
|
+
return path3;
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path3], { encoding: "utf8" });
|
|
190
|
+
return stdout.trim();
|
|
191
|
+
} catch {
|
|
192
|
+
return path3;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var init_wsl_utils = __esm(() => {
|
|
196
|
+
init_is_wsl();
|
|
197
|
+
init_powershell_utils();
|
|
198
|
+
init_is_wsl();
|
|
199
|
+
execFile2 = promisify2(childProcess2.execFile);
|
|
200
|
+
wslDrivesMountPoint = (() => {
|
|
201
|
+
const defaultMountPoint = "/mnt/";
|
|
202
|
+
let mountPoint;
|
|
203
|
+
return async function() {
|
|
204
|
+
if (mountPoint) {
|
|
205
|
+
return mountPoint;
|
|
206
|
+
}
|
|
207
|
+
const configFilePath = "/etc/wsl.conf";
|
|
208
|
+
let isConfigFileExists = false;
|
|
209
|
+
try {
|
|
210
|
+
await fs4.access(configFilePath, fsConstants.F_OK);
|
|
211
|
+
isConfigFileExists = true;
|
|
212
|
+
} catch {}
|
|
213
|
+
if (!isConfigFileExists) {
|
|
214
|
+
return defaultMountPoint;
|
|
215
|
+
}
|
|
216
|
+
const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
|
|
217
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
218
|
+
if (parsedMountPoint === undefined) {
|
|
219
|
+
return defaultMountPoint;
|
|
220
|
+
}
|
|
221
|
+
mountPoint = parsedMountPoint;
|
|
222
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
223
|
+
return mountPoint;
|
|
224
|
+
};
|
|
225
|
+
})();
|
|
226
|
+
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
227
|
+
});
|
|
228
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
229
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
230
|
+
Object.defineProperty(object, propertyName, {
|
|
231
|
+
configurable: true,
|
|
232
|
+
enumerable: true,
|
|
233
|
+
get() {
|
|
234
|
+
const result = valueGetter();
|
|
235
|
+
define(result);
|
|
236
|
+
return result;
|
|
237
|
+
},
|
|
238
|
+
set(value) {
|
|
239
|
+
define(value);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
return object;
|
|
243
|
+
}
|
|
244
|
+
async function defaultBrowserId() {
|
|
245
|
+
if (process4.platform !== "darwin") {
|
|
246
|
+
throw new Error("macOS only");
|
|
247
|
+
}
|
|
248
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
249
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
250
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
251
|
+
if (browserId === "com.apple.safari") {
|
|
252
|
+
return "com.apple.Safari";
|
|
253
|
+
}
|
|
254
|
+
return browserId;
|
|
255
|
+
}
|
|
256
|
+
var execFileAsync;
|
|
257
|
+
var init_default_browser_id = __esm(() => {
|
|
258
|
+
execFileAsync = promisify3(execFile3);
|
|
259
|
+
});
|
|
260
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
261
|
+
if (process5.platform !== "darwin") {
|
|
262
|
+
throw new Error("macOS only");
|
|
263
|
+
}
|
|
264
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
265
|
+
const execOptions = {};
|
|
266
|
+
if (signal) {
|
|
267
|
+
execOptions.signal = signal;
|
|
268
|
+
}
|
|
269
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
270
|
+
return stdout.trim();
|
|
271
|
+
}
|
|
272
|
+
var execFileAsync2;
|
|
273
|
+
var init_run_applescript = __esm(() => {
|
|
274
|
+
execFileAsync2 = promisify4(execFile4);
|
|
275
|
+
});
|
|
276
|
+
async function bundleName(bundleId) {
|
|
277
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
278
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
279
|
+
}
|
|
280
|
+
var init_bundle_name = __esm(() => {
|
|
281
|
+
init_run_applescript();
|
|
282
|
+
});
|
|
283
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
284
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
285
|
+
"QUERY",
|
|
286
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
287
|
+
"/v",
|
|
288
|
+
"ProgId"
|
|
289
|
+
]);
|
|
290
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
291
|
+
if (!match) {
|
|
292
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
293
|
+
}
|
|
294
|
+
const { id } = match.groups;
|
|
295
|
+
const dotIndex = id.lastIndexOf(".");
|
|
296
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
297
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
298
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
299
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
300
|
+
}
|
|
301
|
+
var execFileAsync3;
|
|
302
|
+
var windowsBrowserProgIds;
|
|
303
|
+
var _windowsBrowserProgIdMap;
|
|
304
|
+
var UnknownBrowserError;
|
|
305
|
+
var init_windows = __esm(() => {
|
|
306
|
+
execFileAsync3 = promisify5(execFile5);
|
|
307
|
+
windowsBrowserProgIds = {
|
|
308
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
309
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
310
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
311
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
312
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
313
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
314
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
315
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
316
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
317
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
318
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
319
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
320
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
321
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
322
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
323
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
324
|
+
};
|
|
325
|
+
_windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
326
|
+
UnknownBrowserError = class UnknownBrowserError2 extends Error {
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
async function defaultBrowser2() {
|
|
330
|
+
if (process6.platform === "darwin") {
|
|
331
|
+
const id = await defaultBrowserId();
|
|
332
|
+
const name = await bundleName(id);
|
|
333
|
+
return { name, id };
|
|
334
|
+
}
|
|
335
|
+
if (process6.platform === "linux") {
|
|
336
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
337
|
+
const id = stdout.trim();
|
|
338
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
339
|
+
return { name, id };
|
|
340
|
+
}
|
|
341
|
+
if (process6.platform === "win32") {
|
|
342
|
+
return defaultBrowser();
|
|
343
|
+
}
|
|
344
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
345
|
+
}
|
|
346
|
+
var execFileAsync4;
|
|
347
|
+
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
348
|
+
var init_default_browser = __esm(() => {
|
|
349
|
+
init_default_browser_id();
|
|
350
|
+
init_bundle_name();
|
|
351
|
+
init_windows();
|
|
352
|
+
init_windows();
|
|
353
|
+
execFileAsync4 = promisify6(execFile6);
|
|
354
|
+
});
|
|
355
|
+
var isInSsh;
|
|
356
|
+
var is_in_ssh_default;
|
|
357
|
+
var init_is_in_ssh = __esm(() => {
|
|
358
|
+
isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
|
|
359
|
+
is_in_ssh_default = isInSsh;
|
|
360
|
+
});
|
|
361
|
+
var exports_open = {};
|
|
362
|
+
__export(exports_open, {
|
|
363
|
+
apps: () => apps,
|
|
364
|
+
default: () => open_default,
|
|
365
|
+
openApp: () => openApp
|
|
366
|
+
});
|
|
367
|
+
function detectArchBinary(binary) {
|
|
368
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
369
|
+
return binary;
|
|
370
|
+
}
|
|
371
|
+
const { [arch]: archBinary } = binary;
|
|
372
|
+
if (!archBinary) {
|
|
373
|
+
throw new Error(`${arch} is not supported`);
|
|
374
|
+
}
|
|
375
|
+
return archBinary;
|
|
376
|
+
}
|
|
377
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
378
|
+
if (wsl && is_wsl_default) {
|
|
379
|
+
return detectArchBinary(wsl);
|
|
380
|
+
}
|
|
381
|
+
if (!platformBinary) {
|
|
382
|
+
throw new Error(`${platform} is not supported`);
|
|
383
|
+
}
|
|
384
|
+
return detectArchBinary(platformBinary);
|
|
385
|
+
}
|
|
386
|
+
var fallbackAttemptSymbol;
|
|
387
|
+
var __dirname2;
|
|
388
|
+
var localXdgOpenPath;
|
|
389
|
+
var platform;
|
|
390
|
+
var arch;
|
|
391
|
+
var tryEachApp = async (apps, opener) => {
|
|
392
|
+
if (apps.length === 0) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const errors = [];
|
|
396
|
+
for (const app of apps) {
|
|
397
|
+
try {
|
|
398
|
+
return await opener(app);
|
|
399
|
+
} catch (error) {
|
|
400
|
+
errors.push(error);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
404
|
+
};
|
|
405
|
+
var 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((resolve2, 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
|
+
resolve2(subprocess);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
if (isFallbackAttempt) {
|
|
570
|
+
return new Promise((resolve2, 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
|
+
resolve2(subprocess);
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
subprocess.unref();
|
|
586
|
+
return new Promise((resolve2, reject) => {
|
|
587
|
+
subprocess.once("error", reject);
|
|
588
|
+
subprocess.once("spawn", () => {
|
|
589
|
+
subprocess.off("error", reject);
|
|
590
|
+
resolve2(subprocess);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
var open = (target, options) => {
|
|
595
|
+
if (typeof target !== "string") {
|
|
596
|
+
throw new TypeError("Expected a `target`");
|
|
597
|
+
}
|
|
598
|
+
return baseOpen({
|
|
599
|
+
...options,
|
|
600
|
+
target
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
var openApp = (name, options) => {
|
|
604
|
+
if (typeof name !== "string" && !Array.isArray(name)) {
|
|
605
|
+
throw new TypeError("Expected a valid `name`");
|
|
606
|
+
}
|
|
607
|
+
const { arguments: appArguments = [] } = options ?? {};
|
|
608
|
+
if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
|
|
609
|
+
throw new TypeError("Expected `appArguments` as Array type");
|
|
610
|
+
}
|
|
611
|
+
return baseOpen({
|
|
612
|
+
...options,
|
|
613
|
+
app: {
|
|
614
|
+
name,
|
|
615
|
+
arguments: appArguments
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
var apps;
|
|
620
|
+
var open_default;
|
|
621
|
+
var init_open = __esm(() => {
|
|
622
|
+
init_wsl_utils();
|
|
623
|
+
init_powershell_utils();
|
|
624
|
+
init_default_browser();
|
|
625
|
+
init_is_inside_container();
|
|
626
|
+
init_is_in_ssh();
|
|
627
|
+
fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
628
|
+
__dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
629
|
+
localXdgOpenPath = path.join(__dirname2, "xdg-open");
|
|
630
|
+
({ platform, arch } = process8);
|
|
631
|
+
apps = {
|
|
632
|
+
browser: "browser",
|
|
633
|
+
browserPrivate: "browserPrivate"
|
|
634
|
+
};
|
|
635
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
636
|
+
darwin: "google chrome",
|
|
637
|
+
win32: "chrome",
|
|
638
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
639
|
+
}, {
|
|
640
|
+
wsl: {
|
|
641
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
642
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
643
|
+
}
|
|
644
|
+
}));
|
|
645
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
646
|
+
darwin: "brave browser",
|
|
647
|
+
win32: "brave",
|
|
648
|
+
linux: ["brave-browser", "brave"]
|
|
649
|
+
}, {
|
|
650
|
+
wsl: {
|
|
651
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
652
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
653
|
+
}
|
|
654
|
+
}));
|
|
655
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
656
|
+
darwin: "firefox",
|
|
657
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
658
|
+
linux: "firefox"
|
|
659
|
+
}, {
|
|
660
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
661
|
+
}));
|
|
662
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
663
|
+
darwin: "microsoft edge",
|
|
664
|
+
win32: "msedge",
|
|
665
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
666
|
+
}, {
|
|
667
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
668
|
+
}));
|
|
669
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
670
|
+
darwin: "Safari"
|
|
671
|
+
}));
|
|
672
|
+
open_default = open;
|
|
673
|
+
});
|
|
674
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
675
|
+
var LOCK_STALE_MS = 15000;
|
|
676
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
677
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
678
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
679
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
680
|
+
|
|
681
|
+
class NodeFileSystem {
|
|
682
|
+
path = {
|
|
683
|
+
join: path2.join,
|
|
684
|
+
resolve: path2.resolve,
|
|
685
|
+
relative: path2.relative,
|
|
686
|
+
dirname: path2.dirname,
|
|
687
|
+
isAbsolute: path2.isAbsolute,
|
|
688
|
+
basename: path2.basename
|
|
689
|
+
};
|
|
690
|
+
env = {
|
|
691
|
+
cwd: process.cwd,
|
|
692
|
+
homedir: os2.homedir,
|
|
693
|
+
tmpdir: os2.tmpdir,
|
|
694
|
+
getenv: (key) => process.env[key]
|
|
695
|
+
};
|
|
696
|
+
utils = {
|
|
697
|
+
open: async (url) => {
|
|
698
|
+
const { default: open2 } = await Promise.resolve().then(() => (init_open(), exports_open));
|
|
699
|
+
await open2(url);
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
async readFile(path3, options) {
|
|
703
|
+
try {
|
|
704
|
+
if (options) {
|
|
705
|
+
return await fs6.readFile(path3, "utf-8");
|
|
706
|
+
}
|
|
707
|
+
return await fs6.readFile(path3);
|
|
708
|
+
} catch (error) {
|
|
709
|
+
if (this.isEnoent(error))
|
|
710
|
+
return null;
|
|
711
|
+
throw error;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async writeFile(filePath, data) {
|
|
715
|
+
const dir = path2.dirname(filePath);
|
|
716
|
+
if (dir) {
|
|
717
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
718
|
+
}
|
|
719
|
+
await fs6.writeFile(filePath, data);
|
|
720
|
+
}
|
|
721
|
+
async appendFile(filePath, data) {
|
|
722
|
+
const dir = path2.dirname(filePath);
|
|
723
|
+
if (dir) {
|
|
724
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
725
|
+
}
|
|
726
|
+
await fs6.appendFile(filePath, data);
|
|
727
|
+
}
|
|
728
|
+
async readdir(dirPath) {
|
|
729
|
+
try {
|
|
730
|
+
return await fs6.readdir(dirPath);
|
|
731
|
+
} catch (error) {
|
|
732
|
+
if (this.isEnoent(error))
|
|
733
|
+
return [];
|
|
734
|
+
throw error;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
async stat(filePath) {
|
|
738
|
+
try {
|
|
739
|
+
const stats = await fs6.stat(filePath);
|
|
740
|
+
return {
|
|
741
|
+
isFile: () => stats.isFile(),
|
|
742
|
+
isDirectory: () => stats.isDirectory(),
|
|
743
|
+
size: stats.size,
|
|
744
|
+
mtimeMs: stats.mtimeMs
|
|
745
|
+
};
|
|
746
|
+
} catch (error) {
|
|
747
|
+
if (this.isEnoent(error))
|
|
748
|
+
return null;
|
|
749
|
+
throw error;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
async exists(filePath) {
|
|
753
|
+
return existsSync(filePath);
|
|
754
|
+
}
|
|
755
|
+
async mkdir(dirPath) {
|
|
756
|
+
await fs6.mkdir(dirPath, { recursive: true });
|
|
757
|
+
}
|
|
758
|
+
async acquireLock(lockPath) {
|
|
759
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
760
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
761
|
+
const ownerId = randomUUID();
|
|
762
|
+
const start = Date.now();
|
|
763
|
+
while (true) {
|
|
764
|
+
try {
|
|
765
|
+
await fs6.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
766
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
767
|
+
} catch (error) {
|
|
768
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
769
|
+
throw error;
|
|
770
|
+
}
|
|
771
|
+
const stats = await fs6.stat(lockFile).catch(() => null);
|
|
772
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
773
|
+
const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
774
|
+
if (reclaimed)
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
777
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
778
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
779
|
+
}
|
|
780
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
async canonicalizeLockTarget(lockPath) {
|
|
785
|
+
const absolute = path2.resolve(lockPath);
|
|
786
|
+
const fullReal = await fs6.realpath(absolute).catch(() => null);
|
|
787
|
+
if (fullReal)
|
|
788
|
+
return fullReal;
|
|
789
|
+
const parent = path2.dirname(absolute);
|
|
790
|
+
const base = path2.basename(absolute);
|
|
791
|
+
const canonicalParent = await fs6.realpath(parent).catch(() => parent);
|
|
792
|
+
return path2.join(canonicalParent, base);
|
|
793
|
+
}
|
|
794
|
+
createLockRelease(lockFile, ownerId) {
|
|
795
|
+
const heartbeatStart = Date.now();
|
|
796
|
+
let heartbeatTimer;
|
|
797
|
+
let stopped = false;
|
|
798
|
+
const stopHeartbeat = () => {
|
|
799
|
+
stopped = true;
|
|
800
|
+
if (heartbeatTimer)
|
|
801
|
+
clearTimeout(heartbeatTimer);
|
|
802
|
+
};
|
|
803
|
+
const scheduleNextHeartbeat = () => {
|
|
804
|
+
if (stopped)
|
|
805
|
+
return;
|
|
806
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
807
|
+
stopped = true;
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
heartbeatTimer = setTimeout(() => {
|
|
811
|
+
runHeartbeat();
|
|
812
|
+
}, LOCK_HEARTBEAT_MS);
|
|
813
|
+
heartbeatTimer.unref?.();
|
|
814
|
+
};
|
|
815
|
+
const runHeartbeat = async () => {
|
|
816
|
+
if (stopped)
|
|
817
|
+
return;
|
|
818
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
819
|
+
if (stopped)
|
|
820
|
+
return;
|
|
821
|
+
if (current !== ownerId) {
|
|
822
|
+
stopped = true;
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const now = Date.now() / 1000;
|
|
826
|
+
await fs6.utimes(lockFile, now, now).catch(() => {});
|
|
827
|
+
scheduleNextHeartbeat();
|
|
828
|
+
};
|
|
829
|
+
scheduleNextHeartbeat();
|
|
830
|
+
let released = false;
|
|
831
|
+
return async () => {
|
|
832
|
+
if (released)
|
|
833
|
+
return;
|
|
834
|
+
released = true;
|
|
835
|
+
stopHeartbeat();
|
|
836
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
837
|
+
if (current === ownerId) {
|
|
838
|
+
await fs6.rm(lockFile, { force: true });
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
async rm(filePath) {
|
|
843
|
+
await fs6.rm(filePath, { recursive: true, force: true });
|
|
844
|
+
}
|
|
845
|
+
async rename(oldPath, newPath) {
|
|
846
|
+
await fs6.rename(oldPath, newPath);
|
|
847
|
+
}
|
|
848
|
+
async realpath(filePath) {
|
|
849
|
+
try {
|
|
850
|
+
return await fs6.realpath(filePath);
|
|
851
|
+
} catch (error) {
|
|
852
|
+
if (this.isEnoent(error))
|
|
853
|
+
return filePath;
|
|
854
|
+
throw error;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async getTempDir() {
|
|
858
|
+
return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
|
|
859
|
+
}
|
|
860
|
+
async copyDirectory(sourcePath, destPath) {
|
|
861
|
+
const sourceStats = await this.stat(sourcePath);
|
|
862
|
+
if (!sourceStats) {
|
|
863
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
864
|
+
}
|
|
865
|
+
if (!sourceStats.isDirectory()) {
|
|
866
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
867
|
+
}
|
|
868
|
+
await this.mkdir(destPath);
|
|
869
|
+
const entries = await this.readdir(sourcePath);
|
|
870
|
+
for (const entry of entries) {
|
|
871
|
+
const srcEntry = path2.join(sourcePath, entry);
|
|
872
|
+
const destEntry = path2.join(destPath, entry);
|
|
873
|
+
const entryStats = await this.stat(srcEntry);
|
|
874
|
+
if (!entryStats)
|
|
875
|
+
continue;
|
|
876
|
+
if (entryStats.isDirectory()) {
|
|
877
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
878
|
+
} else if (entryStats.isFile()) {
|
|
879
|
+
const content = await this.readFile(srcEntry);
|
|
880
|
+
if (content !== null) {
|
|
881
|
+
await this.writeFile(destEntry, content);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
isEnoent(error) {
|
|
887
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
888
|
+
}
|
|
889
|
+
hasErrnoCode(error, code) {
|
|
890
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
var fsInstance = new NodeFileSystem;
|
|
894
|
+
var getFileSystem = () => fsInstance;
|
|
895
|
+
|
|
896
|
+
export { NodeFileSystem, getFileSystem };
|
|
897
|
+
|
|
898
|
+
//# debugId=FA480E52DCE4334F64756E2164756E21
|