camstack 1.2.14 → 1.2.16
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/chunk-LMMQX4CK.js +49 -0
- package/dist/{chunk-EA6763XQ.js → chunk-O5WJH4RV.js} +312 -135
- package/dist/chunk-RA674VWL.js +2785 -0
- package/dist/cli.js +27 -13
- package/dist/{discover-UMBUCPOL.js → discover-XMMUBDEM.js} +2 -2
- package/dist/{discover-addons-MHWUAAMX.js → discover-addons-3N32LTH7.js} +1 -1
- package/dist/dist-RV3V7TEU.js +902 -0
- package/dist/launcher-QKPDMXLY.js +382860 -0
- package/dist/main-IM5JIKX5.js +2302 -0
- package/package.json +1 -1
- package/dist/chunk-K3NQKI34.js +0 -10
|
@@ -0,0 +1,2302 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
require_semver,
|
|
4
|
+
require_src
|
|
5
|
+
} from "./chunk-RA674VWL.js";
|
|
6
|
+
import {
|
|
7
|
+
__commonJS,
|
|
8
|
+
__esm,
|
|
9
|
+
__require,
|
|
10
|
+
__toESM
|
|
11
|
+
} from "./chunk-LMMQX4CK.js";
|
|
12
|
+
|
|
13
|
+
// ../../node_modules/@electron/rebuild/node_modules/node-abi/getNextTarget.js
|
|
14
|
+
function getNextTarget(runtime, targets) {
|
|
15
|
+
const latest = targets.filter((t) => {
|
|
16
|
+
return t.runtime === runtime;
|
|
17
|
+
}).slice(-1)[0];
|
|
18
|
+
const increment = runtime === "electron" ? "minor" : "major";
|
|
19
|
+
let next = import_semver.default.inc(latest.target, increment);
|
|
20
|
+
if (runtime === "electron" && import_semver.default.parse(latest.target).prerelease.length) {
|
|
21
|
+
next = import_semver.default.inc(next, "major");
|
|
22
|
+
}
|
|
23
|
+
return next;
|
|
24
|
+
}
|
|
25
|
+
var import_semver;
|
|
26
|
+
var init_getNextTarget = __esm({
|
|
27
|
+
"../../node_modules/@electron/rebuild/node_modules/node-abi/getNextTarget.js"() {
|
|
28
|
+
"use strict";
|
|
29
|
+
import_semver = __toESM(require_semver(), 1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/@electron/rebuild/node_modules/node-abi/index.js
|
|
34
|
+
import fs from "fs";
|
|
35
|
+
import path from "path";
|
|
36
|
+
import { fileURLToPath } from "url";
|
|
37
|
+
function getAbi(target, runtime) {
|
|
38
|
+
if (target === String(Number(target))) return target;
|
|
39
|
+
if (target) target = target.replace(/^v/, "");
|
|
40
|
+
if (!runtime) runtime = "node";
|
|
41
|
+
if (runtime === "node") {
|
|
42
|
+
if (!target) return process.versions.modules;
|
|
43
|
+
if (target === process.versions.node) return process.versions.modules;
|
|
44
|
+
}
|
|
45
|
+
let abi;
|
|
46
|
+
let lastTarget;
|
|
47
|
+
for (let i = 0; i < allTargets.length; i++) {
|
|
48
|
+
const t = allTargets[i];
|
|
49
|
+
if (t.runtime !== runtime) continue;
|
|
50
|
+
if (import_semver2.default.lte(t.target, target) && (!lastTarget || import_semver2.default.gte(t.target, lastTarget))) {
|
|
51
|
+
abi = t.abi;
|
|
52
|
+
lastTarget = t.target;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (abi && import_semver2.default.lt(target, getNextTarget(runtime, allTargets))) return abi;
|
|
56
|
+
throw new Error(
|
|
57
|
+
"Could not detect abi for version " + target + " and runtime " + runtime + '. Updating "node-abi" might help solve this issue if it is a new release of ' + runtime
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function sortByTargetFn(a, b) {
|
|
61
|
+
const abiComp = Number(a.abi) - Number(b.abi);
|
|
62
|
+
if (abiComp !== 0) return abiComp;
|
|
63
|
+
if (a.target < b.target) return -1;
|
|
64
|
+
if (a.target > b.target) return 1;
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
function loadGeneratedTargets() {
|
|
68
|
+
const registry = JSON.parse(
|
|
69
|
+
fs.readFileSync(
|
|
70
|
+
path.join(path.dirname(fileURLToPath(import.meta.url)), "abi_registry.json"),
|
|
71
|
+
"utf8"
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
const targets = {
|
|
75
|
+
supported: [],
|
|
76
|
+
additional: [],
|
|
77
|
+
future: []
|
|
78
|
+
};
|
|
79
|
+
registry.forEach(function(item) {
|
|
80
|
+
const target = {
|
|
81
|
+
runtime: item.runtime,
|
|
82
|
+
target: item.target,
|
|
83
|
+
abi: item.abi
|
|
84
|
+
};
|
|
85
|
+
if (item.lts) {
|
|
86
|
+
const startDate = new Date(Date.parse(item.lts[0]));
|
|
87
|
+
const endDate = new Date(Date.parse(item.lts[1]));
|
|
88
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
89
|
+
target.lts = startDate < currentDate && currentDate < endDate;
|
|
90
|
+
} else {
|
|
91
|
+
target.lts = false;
|
|
92
|
+
}
|
|
93
|
+
if (target.runtime === "node-webkit") {
|
|
94
|
+
targets.additional.push(target);
|
|
95
|
+
} else if (item.future) {
|
|
96
|
+
targets.future.push(target);
|
|
97
|
+
} else {
|
|
98
|
+
targets.supported.push(target);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
targets.supported.sort(sortByTargetFn);
|
|
102
|
+
targets.additional.sort(sortByTargetFn);
|
|
103
|
+
targets.future.sort(sortByTargetFn);
|
|
104
|
+
return targets;
|
|
105
|
+
}
|
|
106
|
+
var import_semver2, generatedTargets, supportedTargets, additionalTargets, deprecatedTargets, futureTargets, allTargets;
|
|
107
|
+
var init_node_abi = __esm({
|
|
108
|
+
"../../node_modules/@electron/rebuild/node_modules/node-abi/index.js"() {
|
|
109
|
+
"use strict";
|
|
110
|
+
import_semver2 = __toESM(require_semver(), 1);
|
|
111
|
+
init_getNextTarget();
|
|
112
|
+
generatedTargets = loadGeneratedTargets();
|
|
113
|
+
supportedTargets = [
|
|
114
|
+
{ runtime: "node", target: "5.0.0", abi: "47", lts: false },
|
|
115
|
+
{ runtime: "node", target: "6.0.0", abi: "48", lts: false },
|
|
116
|
+
{ runtime: "node", target: "7.0.0", abi: "51", lts: false },
|
|
117
|
+
{ runtime: "node", target: "8.0.0", abi: "57", lts: false },
|
|
118
|
+
{ runtime: "node", target: "9.0.0", abi: "59", lts: false },
|
|
119
|
+
{
|
|
120
|
+
runtime: "node",
|
|
121
|
+
target: "10.0.0",
|
|
122
|
+
abi: "64",
|
|
123
|
+
lts: new Date(2018, 10, 1) < /* @__PURE__ */ new Date() && /* @__PURE__ */ new Date() < new Date(2020, 4, 31)
|
|
124
|
+
},
|
|
125
|
+
{ runtime: "electron", target: "0.36.0", abi: "47", lts: false },
|
|
126
|
+
{ runtime: "electron", target: "1.1.0", abi: "48", lts: false },
|
|
127
|
+
{ runtime: "electron", target: "1.3.0", abi: "49", lts: false },
|
|
128
|
+
{ runtime: "electron", target: "1.4.0", abi: "50", lts: false },
|
|
129
|
+
{ runtime: "electron", target: "1.5.0", abi: "51", lts: false },
|
|
130
|
+
{ runtime: "electron", target: "1.6.0", abi: "53", lts: false },
|
|
131
|
+
{ runtime: "electron", target: "1.7.0", abi: "54", lts: false },
|
|
132
|
+
{ runtime: "electron", target: "1.8.0", abi: "57", lts: false },
|
|
133
|
+
{ runtime: "electron", target: "2.0.0", abi: "57", lts: false },
|
|
134
|
+
{ runtime: "electron", target: "3.0.0", abi: "64", lts: false },
|
|
135
|
+
{ runtime: "electron", target: "4.0.0", abi: "64", lts: false },
|
|
136
|
+
{ runtime: "electron", target: "4.0.4", abi: "69", lts: false },
|
|
137
|
+
...generatedTargets.supported
|
|
138
|
+
];
|
|
139
|
+
additionalTargets = [
|
|
140
|
+
{ runtime: "node-webkit", target: "0.13.0", abi: "47", lts: false },
|
|
141
|
+
{ runtime: "node-webkit", target: "0.15.0", abi: "48", lts: false },
|
|
142
|
+
{ runtime: "node-webkit", target: "0.18.3", abi: "51", lts: false },
|
|
143
|
+
{ runtime: "node-webkit", target: "0.23.0", abi: "57", lts: false },
|
|
144
|
+
{ runtime: "node-webkit", target: "0.26.5", abi: "59", lts: false },
|
|
145
|
+
...generatedTargets.additional
|
|
146
|
+
];
|
|
147
|
+
deprecatedTargets = [
|
|
148
|
+
{ runtime: "node", target: "0.2.0", abi: "1", lts: false },
|
|
149
|
+
{ runtime: "node", target: "0.9.1", abi: "0x000A", lts: false },
|
|
150
|
+
{ runtime: "node", target: "0.9.9", abi: "0x000B", lts: false },
|
|
151
|
+
{ runtime: "node", target: "0.10.4", abi: "11", lts: false },
|
|
152
|
+
{ runtime: "node", target: "0.11.0", abi: "0x000C", lts: false },
|
|
153
|
+
{ runtime: "node", target: "0.11.8", abi: "13", lts: false },
|
|
154
|
+
{ runtime: "node", target: "0.11.11", abi: "14", lts: false },
|
|
155
|
+
{ runtime: "node", target: "1.0.0", abi: "42", lts: false },
|
|
156
|
+
{ runtime: "node", target: "1.1.0", abi: "43", lts: false },
|
|
157
|
+
{ runtime: "node", target: "2.0.0", abi: "44", lts: false },
|
|
158
|
+
{ runtime: "node", target: "3.0.0", abi: "45", lts: false },
|
|
159
|
+
{ runtime: "node", target: "4.0.0", abi: "46", lts: false },
|
|
160
|
+
{ runtime: "electron", target: "0.30.0", abi: "44", lts: false },
|
|
161
|
+
{ runtime: "electron", target: "0.31.0", abi: "45", lts: false },
|
|
162
|
+
{ runtime: "electron", target: "0.33.0", abi: "46", lts: false }
|
|
163
|
+
];
|
|
164
|
+
futureTargets = generatedTargets.future;
|
|
165
|
+
allTargets = deprecatedTargets.concat(supportedTargets).concat(additionalTargets).concat(futureTargets);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ../../node_modules/@electron/rebuild/lib/cache.js
|
|
170
|
+
import crypto from "crypto";
|
|
171
|
+
import fs2 from "fs";
|
|
172
|
+
import path2 from "path";
|
|
173
|
+
import zlib from "zlib";
|
|
174
|
+
function dHashTree(tree, hash) {
|
|
175
|
+
for (const key of Object.keys(tree).sort()) {
|
|
176
|
+
hash.update(key);
|
|
177
|
+
if (typeof tree[key] === "string") {
|
|
178
|
+
hash.update(tree[key]);
|
|
179
|
+
} else {
|
|
180
|
+
dHashTree(tree[key], hash);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function hashDirectory(dir, relativeTo) {
|
|
185
|
+
relativeTo ??= dir;
|
|
186
|
+
d("hashing dir", dir);
|
|
187
|
+
const dirTree = {};
|
|
188
|
+
await Promise.all((await fs2.promises.readdir(dir)).map(async (child) => {
|
|
189
|
+
d("found child", child, "in dir", dir);
|
|
190
|
+
if (dir === relativeTo && (child === "build" || child === "bin"))
|
|
191
|
+
return;
|
|
192
|
+
if (child === "node_modules")
|
|
193
|
+
return;
|
|
194
|
+
const childPath = path2.resolve(dir, child);
|
|
195
|
+
const relative = path2.relative(relativeTo, childPath);
|
|
196
|
+
if ((await fs2.promises.stat(childPath)).isDirectory()) {
|
|
197
|
+
dirTree[relative] = await hashDirectory(childPath, relativeTo);
|
|
198
|
+
} else {
|
|
199
|
+
dirTree[relative] = crypto.createHash("SHA256").update(await fs2.promises.readFile(childPath)).digest("hex");
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
202
|
+
return dirTree;
|
|
203
|
+
}
|
|
204
|
+
async function generateCacheKey(opts) {
|
|
205
|
+
const tree = await hashDirectory(opts.modulePath);
|
|
206
|
+
const hasher = crypto.createHash("SHA256").update(`${ELECTRON_REBUILD_CACHE_ID}`).update(path2.basename(opts.modulePath)).update(opts.ABI).update(opts.arch).update(opts.platform).update(opts.debug ? "debug" : "not debug").update(opts.headerURL).update(opts.electronVersion);
|
|
207
|
+
dHashTree(tree, hasher);
|
|
208
|
+
const hash = hasher.digest("hex");
|
|
209
|
+
d("calculated hash of", opts.modulePath, "to be", hash);
|
|
210
|
+
return hash;
|
|
211
|
+
}
|
|
212
|
+
var import_debug, d, ELECTRON_REBUILD_CACHE_ID, Snap, takeSnapshot, writeSnapshot, serialize, unserialize, cacheModuleState, lookupModuleState;
|
|
213
|
+
var init_cache = __esm({
|
|
214
|
+
"../../node_modules/@electron/rebuild/lib/cache.js"() {
|
|
215
|
+
"use strict";
|
|
216
|
+
import_debug = __toESM(require_src(), 1);
|
|
217
|
+
d = (0, import_debug.default)("electron-rebuild");
|
|
218
|
+
ELECTRON_REBUILD_CACHE_ID = 1;
|
|
219
|
+
Snap = class {
|
|
220
|
+
hash;
|
|
221
|
+
data;
|
|
222
|
+
constructor(hash, data) {
|
|
223
|
+
this.hash = hash;
|
|
224
|
+
this.data = data;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
takeSnapshot = async (dir, relativeTo = dir) => {
|
|
228
|
+
const snap = {};
|
|
229
|
+
await Promise.all((await fs2.promises.readdir(dir)).map(async (child) => {
|
|
230
|
+
if (child === "node_modules")
|
|
231
|
+
return;
|
|
232
|
+
const childPath = path2.resolve(dir, child);
|
|
233
|
+
const relative = path2.relative(relativeTo, childPath);
|
|
234
|
+
if ((await fs2.promises.stat(childPath)).isDirectory()) {
|
|
235
|
+
snap[relative] = await takeSnapshot(childPath, relativeTo);
|
|
236
|
+
} else {
|
|
237
|
+
const data = await fs2.promises.readFile(childPath);
|
|
238
|
+
snap[relative] = new Snap(crypto.createHash("SHA256").update(data).digest("hex"), data);
|
|
239
|
+
}
|
|
240
|
+
}));
|
|
241
|
+
return snap;
|
|
242
|
+
};
|
|
243
|
+
writeSnapshot = async (diff, dir) => {
|
|
244
|
+
for (const key in diff) {
|
|
245
|
+
if (diff[key] instanceof Snap) {
|
|
246
|
+
await fs2.promises.mkdir(path2.dirname(path2.resolve(dir, key)), { recursive: true });
|
|
247
|
+
await fs2.promises.writeFile(path2.resolve(dir, key), diff[key].data);
|
|
248
|
+
} else {
|
|
249
|
+
await fs2.promises.mkdir(path2.resolve(dir, key), { recursive: true });
|
|
250
|
+
await writeSnapshot(diff[key], dir);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
serialize = (snap) => {
|
|
255
|
+
const jsonReady = {};
|
|
256
|
+
for (const key in snap) {
|
|
257
|
+
if (snap[key] instanceof Snap) {
|
|
258
|
+
const s = snap[key];
|
|
259
|
+
jsonReady[key] = {
|
|
260
|
+
__isSnap: true,
|
|
261
|
+
hash: s.hash,
|
|
262
|
+
data: s.data.toString("base64")
|
|
263
|
+
};
|
|
264
|
+
} else {
|
|
265
|
+
jsonReady[key] = serialize(snap[key]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return jsonReady;
|
|
269
|
+
};
|
|
270
|
+
unserialize = (jsonReady) => {
|
|
271
|
+
const snap = {};
|
|
272
|
+
for (const key in jsonReady) {
|
|
273
|
+
if (jsonReady[key].__isSnap) {
|
|
274
|
+
snap[key] = new Snap(jsonReady[key].hash, Buffer.from(jsonReady[key].data, "base64"));
|
|
275
|
+
} else {
|
|
276
|
+
snap[key] = unserialize(jsonReady[key]);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return snap;
|
|
280
|
+
};
|
|
281
|
+
cacheModuleState = async (dir, cachePath, key) => {
|
|
282
|
+
const snap = await takeSnapshot(dir);
|
|
283
|
+
const moduleBuffer = Buffer.from(JSON.stringify(serialize(snap)));
|
|
284
|
+
const zipped = await new Promise((resolve) => zlib.gzip(moduleBuffer, (_, result) => resolve(result)));
|
|
285
|
+
await fs2.promises.mkdir(cachePath, { recursive: true });
|
|
286
|
+
await fs2.promises.writeFile(path2.resolve(cachePath, key), zipped);
|
|
287
|
+
};
|
|
288
|
+
lookupModuleState = async (cachePath, key) => {
|
|
289
|
+
if (fs2.existsSync(path2.resolve(cachePath, key))) {
|
|
290
|
+
return async function applyDiff(dir) {
|
|
291
|
+
const zipped = await fs2.promises.readFile(path2.resolve(cachePath, key));
|
|
292
|
+
const unzipped = await new Promise((resolve) => {
|
|
293
|
+
zlib.gunzip(zipped, (_, result) => resolve(result));
|
|
294
|
+
});
|
|
295
|
+
const diff = unserialize(JSON.parse(unzipped.toString()));
|
|
296
|
+
await writeSnapshot(diff, dir);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// ../../node_modules/@electron/rebuild/lib/types.js
|
|
305
|
+
var BuildType;
|
|
306
|
+
var init_types = __esm({
|
|
307
|
+
"../../node_modules/@electron/rebuild/lib/types.js"() {
|
|
308
|
+
"use strict";
|
|
309
|
+
(function(BuildType2) {
|
|
310
|
+
BuildType2["Debug"] = "Debug";
|
|
311
|
+
BuildType2["Release"] = "Release";
|
|
312
|
+
})(BuildType || (BuildType = {}));
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// ../../node_modules/@electron/rebuild/lib/constants.js
|
|
317
|
+
import os from "os";
|
|
318
|
+
import path3 from "path";
|
|
319
|
+
var ELECTRON_GYP_DIR;
|
|
320
|
+
var init_constants = __esm({
|
|
321
|
+
"../../node_modules/@electron/rebuild/lib/constants.js"() {
|
|
322
|
+
"use strict";
|
|
323
|
+
ELECTRON_GYP_DIR = path3.resolve(os.homedir(), ".electron-gyp");
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// ../../node_modules/@electron/rebuild/lib/fetcher.js
|
|
328
|
+
import { setTimeout as sleep } from "timers/promises";
|
|
329
|
+
async function fetchUrl(url, responseType, retries = 3) {
|
|
330
|
+
if (retries === 0)
|
|
331
|
+
throw new Error("Failed to fetch a clang resource, run with DEBUG=electron-rebuild for more information");
|
|
332
|
+
d2("downloading:", url);
|
|
333
|
+
try {
|
|
334
|
+
const response = await globalThis.fetch(url);
|
|
335
|
+
if (!response.ok) {
|
|
336
|
+
d2("got bad status code:", response.status);
|
|
337
|
+
await sleep(2e3);
|
|
338
|
+
return fetchUrl(url, responseType, retries - 1);
|
|
339
|
+
}
|
|
340
|
+
d2("response came back OK");
|
|
341
|
+
if (responseType === "buffer") {
|
|
342
|
+
return Buffer.from(await response.arrayBuffer());
|
|
343
|
+
}
|
|
344
|
+
return await response.text();
|
|
345
|
+
} catch (err) {
|
|
346
|
+
d2("request failed for some reason", err);
|
|
347
|
+
await sleep(2e3);
|
|
348
|
+
return fetchUrl(url, responseType, retries - 1);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
var import_debug2, d2;
|
|
352
|
+
var init_fetcher = __esm({
|
|
353
|
+
"../../node_modules/@electron/rebuild/lib/fetcher.js"() {
|
|
354
|
+
"use strict";
|
|
355
|
+
import_debug2 = __toESM(require_src(), 1);
|
|
356
|
+
d2 = (0, import_debug2.default)("electron-rebuild");
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// ../../node_modules/isexe/windows.js
|
|
361
|
+
var require_windows = __commonJS({
|
|
362
|
+
"../../node_modules/isexe/windows.js"(exports, module) {
|
|
363
|
+
"use strict";
|
|
364
|
+
module.exports = isexe;
|
|
365
|
+
isexe.sync = sync;
|
|
366
|
+
var fs13 = __require("fs");
|
|
367
|
+
function checkPathExt(path15, options) {
|
|
368
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
369
|
+
if (!pathext) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
pathext = pathext.split(";");
|
|
373
|
+
if (pathext.indexOf("") !== -1) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
377
|
+
var p = pathext[i].toLowerCase();
|
|
378
|
+
if (p && path15.substr(-p.length).toLowerCase() === p) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
function checkStat(stat, path15, options) {
|
|
385
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
return checkPathExt(path15, options);
|
|
389
|
+
}
|
|
390
|
+
function isexe(path15, options, cb) {
|
|
391
|
+
fs13.stat(path15, function(er, stat) {
|
|
392
|
+
cb(er, er ? false : checkStat(stat, path15, options));
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
function sync(path15, options) {
|
|
396
|
+
return checkStat(fs13.statSync(path15), path15, options);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// ../../node_modules/isexe/mode.js
|
|
402
|
+
var require_mode = __commonJS({
|
|
403
|
+
"../../node_modules/isexe/mode.js"(exports, module) {
|
|
404
|
+
"use strict";
|
|
405
|
+
module.exports = isexe;
|
|
406
|
+
isexe.sync = sync;
|
|
407
|
+
var fs13 = __require("fs");
|
|
408
|
+
function isexe(path15, options, cb) {
|
|
409
|
+
fs13.stat(path15, function(er, stat) {
|
|
410
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
function sync(path15, options) {
|
|
414
|
+
return checkStat(fs13.statSync(path15), options);
|
|
415
|
+
}
|
|
416
|
+
function checkStat(stat, options) {
|
|
417
|
+
return stat.isFile() && checkMode(stat, options);
|
|
418
|
+
}
|
|
419
|
+
function checkMode(stat, options) {
|
|
420
|
+
var mod = stat.mode;
|
|
421
|
+
var uid = stat.uid;
|
|
422
|
+
var gid = stat.gid;
|
|
423
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
424
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
425
|
+
var u = parseInt("100", 8);
|
|
426
|
+
var g = parseInt("010", 8);
|
|
427
|
+
var o = parseInt("001", 8);
|
|
428
|
+
var ug = u | g;
|
|
429
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
430
|
+
return ret;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// ../../node_modules/isexe/index.js
|
|
436
|
+
var require_isexe = __commonJS({
|
|
437
|
+
"../../node_modules/isexe/index.js"(exports, module) {
|
|
438
|
+
"use strict";
|
|
439
|
+
var fs13 = __require("fs");
|
|
440
|
+
var core;
|
|
441
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
442
|
+
core = require_windows();
|
|
443
|
+
} else {
|
|
444
|
+
core = require_mode();
|
|
445
|
+
}
|
|
446
|
+
module.exports = isexe;
|
|
447
|
+
isexe.sync = sync;
|
|
448
|
+
function isexe(path15, options, cb) {
|
|
449
|
+
if (typeof options === "function") {
|
|
450
|
+
cb = options;
|
|
451
|
+
options = {};
|
|
452
|
+
}
|
|
453
|
+
if (!cb) {
|
|
454
|
+
if (typeof Promise !== "function") {
|
|
455
|
+
throw new TypeError("callback not provided");
|
|
456
|
+
}
|
|
457
|
+
return new Promise(function(resolve, reject) {
|
|
458
|
+
isexe(path15, options || {}, function(er, is) {
|
|
459
|
+
if (er) {
|
|
460
|
+
reject(er);
|
|
461
|
+
} else {
|
|
462
|
+
resolve(is);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
core(path15, options || {}, function(er, is) {
|
|
468
|
+
if (er) {
|
|
469
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
470
|
+
er = null;
|
|
471
|
+
is = false;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
cb(er, is);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function sync(path15, options) {
|
|
478
|
+
try {
|
|
479
|
+
return core.sync(path15, options || {});
|
|
480
|
+
} catch (er) {
|
|
481
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
482
|
+
return false;
|
|
483
|
+
} else {
|
|
484
|
+
throw er;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
// ../../node_modules/which/which.js
|
|
492
|
+
var require_which = __commonJS({
|
|
493
|
+
"../../node_modules/which/which.js"(exports, module) {
|
|
494
|
+
"use strict";
|
|
495
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
496
|
+
var path15 = __require("path");
|
|
497
|
+
var COLON = isWindows ? ";" : ":";
|
|
498
|
+
var isexe = require_isexe();
|
|
499
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
500
|
+
var getPathInfo = (cmd, opt) => {
|
|
501
|
+
const colon = opt.colon || COLON;
|
|
502
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
503
|
+
// windows always checks the cwd first
|
|
504
|
+
...isWindows ? [process.cwd()] : [],
|
|
505
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
506
|
+
"").split(colon)
|
|
507
|
+
];
|
|
508
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
509
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
510
|
+
if (isWindows) {
|
|
511
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
512
|
+
pathExt.unshift("");
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
pathEnv,
|
|
516
|
+
pathExt,
|
|
517
|
+
pathExtExe
|
|
518
|
+
};
|
|
519
|
+
};
|
|
520
|
+
var which = (cmd, opt, cb) => {
|
|
521
|
+
if (typeof opt === "function") {
|
|
522
|
+
cb = opt;
|
|
523
|
+
opt = {};
|
|
524
|
+
}
|
|
525
|
+
if (!opt)
|
|
526
|
+
opt = {};
|
|
527
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
528
|
+
const found = [];
|
|
529
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
530
|
+
if (i === pathEnv.length)
|
|
531
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
532
|
+
const ppRaw = pathEnv[i];
|
|
533
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
534
|
+
const pCmd = path15.join(pathPart, cmd);
|
|
535
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
536
|
+
resolve(subStep(p, i, 0));
|
|
537
|
+
});
|
|
538
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
539
|
+
if (ii === pathExt.length)
|
|
540
|
+
return resolve(step(i + 1));
|
|
541
|
+
const ext = pathExt[ii];
|
|
542
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
543
|
+
if (!er && is) {
|
|
544
|
+
if (opt.all)
|
|
545
|
+
found.push(p + ext);
|
|
546
|
+
else
|
|
547
|
+
return resolve(p + ext);
|
|
548
|
+
}
|
|
549
|
+
return resolve(subStep(p, i, ii + 1));
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
553
|
+
};
|
|
554
|
+
var whichSync = (cmd, opt) => {
|
|
555
|
+
opt = opt || {};
|
|
556
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
557
|
+
const found = [];
|
|
558
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
559
|
+
const ppRaw = pathEnv[i];
|
|
560
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
561
|
+
const pCmd = path15.join(pathPart, cmd);
|
|
562
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
563
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
564
|
+
const cur = p + pathExt[j];
|
|
565
|
+
try {
|
|
566
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
567
|
+
if (is) {
|
|
568
|
+
if (opt.all)
|
|
569
|
+
found.push(cur);
|
|
570
|
+
else
|
|
571
|
+
return cur;
|
|
572
|
+
}
|
|
573
|
+
} catch (ex) {
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (opt.all && found.length)
|
|
578
|
+
return found;
|
|
579
|
+
if (opt.nothrow)
|
|
580
|
+
return null;
|
|
581
|
+
throw getNotFoundError(cmd);
|
|
582
|
+
};
|
|
583
|
+
module.exports = which;
|
|
584
|
+
which.sync = whichSync;
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
// ../../node_modules/path-key/index.js
|
|
589
|
+
var require_path_key = __commonJS({
|
|
590
|
+
"../../node_modules/path-key/index.js"(exports, module) {
|
|
591
|
+
"use strict";
|
|
592
|
+
var pathKey = (options = {}) => {
|
|
593
|
+
const environment = options.env || process.env;
|
|
594
|
+
const platform = options.platform || process.platform;
|
|
595
|
+
if (platform !== "win32") {
|
|
596
|
+
return "PATH";
|
|
597
|
+
}
|
|
598
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
599
|
+
};
|
|
600
|
+
module.exports = pathKey;
|
|
601
|
+
module.exports.default = pathKey;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
// ../../node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
606
|
+
var require_resolveCommand = __commonJS({
|
|
607
|
+
"../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
608
|
+
"use strict";
|
|
609
|
+
var path15 = __require("path");
|
|
610
|
+
var which = require_which();
|
|
611
|
+
var getPathKey = require_path_key();
|
|
612
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
613
|
+
const env = parsed.options.env || process.env;
|
|
614
|
+
const cwd = process.cwd();
|
|
615
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
616
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
617
|
+
if (shouldSwitchCwd) {
|
|
618
|
+
try {
|
|
619
|
+
process.chdir(parsed.options.cwd);
|
|
620
|
+
} catch (err) {
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
let resolved;
|
|
624
|
+
try {
|
|
625
|
+
resolved = which.sync(parsed.command, {
|
|
626
|
+
path: env[getPathKey({ env })],
|
|
627
|
+
pathExt: withoutPathExt ? path15.delimiter : void 0
|
|
628
|
+
});
|
|
629
|
+
} catch (e) {
|
|
630
|
+
} finally {
|
|
631
|
+
if (shouldSwitchCwd) {
|
|
632
|
+
process.chdir(cwd);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (resolved) {
|
|
636
|
+
resolved = path15.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
637
|
+
}
|
|
638
|
+
return resolved;
|
|
639
|
+
}
|
|
640
|
+
function resolveCommand(parsed) {
|
|
641
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
642
|
+
}
|
|
643
|
+
module.exports = resolveCommand;
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
// ../../node_modules/cross-spawn/lib/util/escape.js
|
|
648
|
+
var require_escape = __commonJS({
|
|
649
|
+
"../../node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
|
|
650
|
+
"use strict";
|
|
651
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
652
|
+
function escapeCommand(arg) {
|
|
653
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
654
|
+
return arg;
|
|
655
|
+
}
|
|
656
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
657
|
+
arg = `${arg}`;
|
|
658
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
659
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
660
|
+
arg = `"${arg}"`;
|
|
661
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
662
|
+
if (doubleEscapeMetaChars) {
|
|
663
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
664
|
+
}
|
|
665
|
+
return arg;
|
|
666
|
+
}
|
|
667
|
+
module.exports.command = escapeCommand;
|
|
668
|
+
module.exports.argument = escapeArgument;
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// ../../node_modules/shebang-regex/index.js
|
|
673
|
+
var require_shebang_regex = __commonJS({
|
|
674
|
+
"../../node_modules/shebang-regex/index.js"(exports, module) {
|
|
675
|
+
"use strict";
|
|
676
|
+
module.exports = /^#!(.*)/;
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// ../../node_modules/shebang-command/index.js
|
|
681
|
+
var require_shebang_command = __commonJS({
|
|
682
|
+
"../../node_modules/shebang-command/index.js"(exports, module) {
|
|
683
|
+
"use strict";
|
|
684
|
+
var shebangRegex = require_shebang_regex();
|
|
685
|
+
module.exports = (string = "") => {
|
|
686
|
+
const match = string.match(shebangRegex);
|
|
687
|
+
if (!match) {
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
690
|
+
const [path15, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
691
|
+
const binary = path15.split("/").pop();
|
|
692
|
+
if (binary === "env") {
|
|
693
|
+
return argument;
|
|
694
|
+
}
|
|
695
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
// ../../node_modules/cross-spawn/lib/util/readShebang.js
|
|
701
|
+
var require_readShebang = __commonJS({
|
|
702
|
+
"../../node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
703
|
+
"use strict";
|
|
704
|
+
var fs13 = __require("fs");
|
|
705
|
+
var shebangCommand = require_shebang_command();
|
|
706
|
+
function readShebang(command) {
|
|
707
|
+
const size = 150;
|
|
708
|
+
const buffer = Buffer.alloc(size);
|
|
709
|
+
let fd;
|
|
710
|
+
try {
|
|
711
|
+
fd = fs13.openSync(command, "r");
|
|
712
|
+
fs13.readSync(fd, buffer, 0, size, 0);
|
|
713
|
+
fs13.closeSync(fd);
|
|
714
|
+
} catch (e) {
|
|
715
|
+
}
|
|
716
|
+
return shebangCommand(buffer.toString());
|
|
717
|
+
}
|
|
718
|
+
module.exports = readShebang;
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// ../../node_modules/cross-spawn/lib/parse.js
|
|
723
|
+
var require_parse = __commonJS({
|
|
724
|
+
"../../node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
725
|
+
"use strict";
|
|
726
|
+
var path15 = __require("path");
|
|
727
|
+
var resolveCommand = require_resolveCommand();
|
|
728
|
+
var escape = require_escape();
|
|
729
|
+
var readShebang = require_readShebang();
|
|
730
|
+
var isWin = process.platform === "win32";
|
|
731
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
732
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
733
|
+
function detectShebang(parsed) {
|
|
734
|
+
parsed.file = resolveCommand(parsed);
|
|
735
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
736
|
+
if (shebang) {
|
|
737
|
+
parsed.args.unshift(parsed.file);
|
|
738
|
+
parsed.command = shebang;
|
|
739
|
+
return resolveCommand(parsed);
|
|
740
|
+
}
|
|
741
|
+
return parsed.file;
|
|
742
|
+
}
|
|
743
|
+
function parseNonShell(parsed) {
|
|
744
|
+
if (!isWin) {
|
|
745
|
+
return parsed;
|
|
746
|
+
}
|
|
747
|
+
const commandFile = detectShebang(parsed);
|
|
748
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
749
|
+
if (parsed.options.forceShell || needsShell) {
|
|
750
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
751
|
+
parsed.command = path15.normalize(parsed.command);
|
|
752
|
+
parsed.command = escape.command(parsed.command);
|
|
753
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
754
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
755
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
756
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
757
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
758
|
+
}
|
|
759
|
+
return parsed;
|
|
760
|
+
}
|
|
761
|
+
function parse(command, args, options) {
|
|
762
|
+
if (args && !Array.isArray(args)) {
|
|
763
|
+
options = args;
|
|
764
|
+
args = null;
|
|
765
|
+
}
|
|
766
|
+
args = args ? args.slice(0) : [];
|
|
767
|
+
options = Object.assign({}, options);
|
|
768
|
+
const parsed = {
|
|
769
|
+
command,
|
|
770
|
+
args,
|
|
771
|
+
options,
|
|
772
|
+
file: void 0,
|
|
773
|
+
original: {
|
|
774
|
+
command,
|
|
775
|
+
args
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
779
|
+
}
|
|
780
|
+
module.exports = parse;
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
// ../../node_modules/cross-spawn/lib/enoent.js
|
|
785
|
+
var require_enoent = __commonJS({
|
|
786
|
+
"../../node_modules/cross-spawn/lib/enoent.js"(exports, module) {
|
|
787
|
+
"use strict";
|
|
788
|
+
var isWin = process.platform === "win32";
|
|
789
|
+
function notFoundError(original, syscall) {
|
|
790
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
791
|
+
code: "ENOENT",
|
|
792
|
+
errno: "ENOENT",
|
|
793
|
+
syscall: `${syscall} ${original.command}`,
|
|
794
|
+
path: original.command,
|
|
795
|
+
spawnargs: original.args
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
function hookChildProcess(cp2, parsed) {
|
|
799
|
+
if (!isWin) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const originalEmit = cp2.emit;
|
|
803
|
+
cp2.emit = function(name, arg1) {
|
|
804
|
+
if (name === "exit") {
|
|
805
|
+
const err = verifyENOENT(arg1, parsed);
|
|
806
|
+
if (err) {
|
|
807
|
+
return originalEmit.call(cp2, "error", err);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return originalEmit.apply(cp2, arguments);
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function verifyENOENT(status, parsed) {
|
|
814
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
815
|
+
return notFoundError(parsed.original, "spawn");
|
|
816
|
+
}
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
function verifyENOENTSync(status, parsed) {
|
|
820
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
821
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
822
|
+
}
|
|
823
|
+
return null;
|
|
824
|
+
}
|
|
825
|
+
module.exports = {
|
|
826
|
+
hookChildProcess,
|
|
827
|
+
verifyENOENT,
|
|
828
|
+
verifyENOENTSync,
|
|
829
|
+
notFoundError
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
// ../../node_modules/cross-spawn/index.js
|
|
835
|
+
var require_cross_spawn = __commonJS({
|
|
836
|
+
"../../node_modules/cross-spawn/index.js"(exports, module) {
|
|
837
|
+
"use strict";
|
|
838
|
+
var cp2 = __require("child_process");
|
|
839
|
+
var parse = require_parse();
|
|
840
|
+
var enoent = require_enoent();
|
|
841
|
+
function spawn5(command, args, options) {
|
|
842
|
+
const parsed = parse(command, args, options);
|
|
843
|
+
const spawned = cp2.spawn(parsed.command, parsed.args, parsed.options);
|
|
844
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
845
|
+
return spawned;
|
|
846
|
+
}
|
|
847
|
+
function spawnSync(command, args, options) {
|
|
848
|
+
const parsed = parse(command, args, options);
|
|
849
|
+
const result = cp2.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
850
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
851
|
+
return result;
|
|
852
|
+
}
|
|
853
|
+
module.exports = spawn5;
|
|
854
|
+
module.exports.spawn = spawn5;
|
|
855
|
+
module.exports.sync = spawnSync;
|
|
856
|
+
module.exports._parse = parse;
|
|
857
|
+
module.exports._enoent = enoent;
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
// ../../node_modules/@malept/cross-spawn-promise/dist/src/index.js
|
|
862
|
+
var require_src2 = __commonJS({
|
|
863
|
+
"../../node_modules/@malept/cross-spawn-promise/dist/src/index.js"(exports) {
|
|
864
|
+
"use strict";
|
|
865
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
866
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
867
|
+
};
|
|
868
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
869
|
+
exports.spawn = exports.ExitSignalError = exports.ExitCodeError = exports.ExitError = exports.CrossSpawnError = void 0;
|
|
870
|
+
var cross_spawn_1 = __importDefault(require_cross_spawn());
|
|
871
|
+
function stringifyCommand(cmd, args) {
|
|
872
|
+
if (args && Array.isArray(args) && args.length > 0) {
|
|
873
|
+
return `${cmd} ${args.join(" ")}`;
|
|
874
|
+
} else {
|
|
875
|
+
return cmd;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
var CrossSpawnError = class extends Error {
|
|
879
|
+
constructor(cmd, args, originalError, stderr) {
|
|
880
|
+
const fullCommand = stringifyCommand(cmd, args);
|
|
881
|
+
const errorMessage = originalError.message || originalError;
|
|
882
|
+
super(`Error executing command (${fullCommand}):
|
|
883
|
+
${errorMessage}
|
|
884
|
+
${stderr}`.trim());
|
|
885
|
+
this.originalError = originalError;
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
exports.CrossSpawnError = CrossSpawnError;
|
|
889
|
+
var ExitError = class extends Error {
|
|
890
|
+
constructor(cmd, args, message, stdout, stderr) {
|
|
891
|
+
super(message);
|
|
892
|
+
this.cmd = cmd;
|
|
893
|
+
this.args = args;
|
|
894
|
+
this.stdout = stdout;
|
|
895
|
+
this.stderr = stderr;
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
exports.ExitError = ExitError;
|
|
899
|
+
var ExitCodeError = class extends ExitError {
|
|
900
|
+
constructor(cmd, args, code, stdout, stderr) {
|
|
901
|
+
const fullCommand = stringifyCommand(cmd, args);
|
|
902
|
+
super(cmd, args, `Command failed with a non-zero return code (${code}):
|
|
903
|
+
${fullCommand}
|
|
904
|
+
${stdout}
|
|
905
|
+
${stderr}`.trim(), stdout, stderr);
|
|
906
|
+
this.code = code;
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
exports.ExitCodeError = ExitCodeError;
|
|
910
|
+
var ExitSignalError = class extends ExitError {
|
|
911
|
+
constructor(cmd, args, signal, stdout, stderr) {
|
|
912
|
+
const fullCommand = stringifyCommand(cmd, args);
|
|
913
|
+
super(cmd, args, `Command terminated via a signal (${signal}):
|
|
914
|
+
${fullCommand}
|
|
915
|
+
${stdout}
|
|
916
|
+
${stderr}`.trim(), stdout, stderr);
|
|
917
|
+
this.signal = signal;
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
exports.ExitSignalError = ExitSignalError;
|
|
921
|
+
async function spawn5(cmd, args, options) {
|
|
922
|
+
if (!options) {
|
|
923
|
+
options = {};
|
|
924
|
+
}
|
|
925
|
+
const { logger, updateErrorCallback, ...spawnOptions } = options;
|
|
926
|
+
if (logger)
|
|
927
|
+
logger(`Executing command ${stringifyCommand(cmd, args)}`);
|
|
928
|
+
return new Promise((resolve, reject) => {
|
|
929
|
+
let stdout = "";
|
|
930
|
+
let stderr = "";
|
|
931
|
+
const process2 = cross_spawn_1.default(cmd, args, spawnOptions);
|
|
932
|
+
if (process2.stdout) {
|
|
933
|
+
process2.stdout.on("data", (data) => {
|
|
934
|
+
stdout += data.toString();
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
if (process2.stderr) {
|
|
938
|
+
process2.stderr.on(
|
|
939
|
+
"data",
|
|
940
|
+
/* istanbul ignore next */
|
|
941
|
+
(data) => {
|
|
942
|
+
stderr += data.toString();
|
|
943
|
+
}
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
process2.on("close", (code, signal) => {
|
|
947
|
+
if (code === 0) {
|
|
948
|
+
resolve(stdout);
|
|
949
|
+
} else if (code === null) {
|
|
950
|
+
reject(new ExitSignalError(cmd, args, signal, stdout, stderr));
|
|
951
|
+
} else {
|
|
952
|
+
reject(new ExitCodeError(cmd, args, code, stdout, stderr));
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
process2.on("error", (err) => {
|
|
956
|
+
if (updateErrorCallback) {
|
|
957
|
+
updateErrorCallback(err, !!logger);
|
|
958
|
+
}
|
|
959
|
+
reject(new CrossSpawnError(cmd, args, err, stderr));
|
|
960
|
+
});
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
exports.spawn = spawn5;
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
// ../../node_modules/@electron/rebuild/lib/sysroot-fetcher.js
|
|
968
|
+
import crypto2 from "crypto";
|
|
969
|
+
import fs3 from "fs";
|
|
970
|
+
import path4 from "path";
|
|
971
|
+
async function downloadLinuxSysroot(electronVersion, targetArch) {
|
|
972
|
+
d3("fetching sysroot for Electron:", electronVersion);
|
|
973
|
+
const sysrootDir = path4.resolve(ELECTRON_GYP_DIR, `${electronVersion}-sysroot`);
|
|
974
|
+
if (fs3.existsSync(path4.resolve(sysrootDir, "lib")))
|
|
975
|
+
return sysrootDir;
|
|
976
|
+
await fs3.promises.mkdir(sysrootDir, { recursive: true });
|
|
977
|
+
const linuxArch = sysrootArchAliases[targetArch] || targetArch;
|
|
978
|
+
const electronSysroots = JSON.parse(await fetchUrl(`https://raw.githubusercontent.com/electron/electron/v${electronVersion}/script/sysroots.json`, "text"));
|
|
979
|
+
const { Sha1Sum: sha, Tarball: fileName } = electronSysroots[`sid_${linuxArch}`] || electronSysroots[`bullseye_${linuxArch}`];
|
|
980
|
+
const sysrootURL = `${SYSROOT_BASE_URL}/${sha}/${fileName}`;
|
|
981
|
+
const sysrootBuffer = await fetchUrl(sysrootURL, "buffer");
|
|
982
|
+
const actualSha = crypto2.createHash("SHA1").update(sysrootBuffer).digest("hex");
|
|
983
|
+
d3("expected sha:", sha);
|
|
984
|
+
d3("actual sha:", actualSha);
|
|
985
|
+
if (sha !== actualSha)
|
|
986
|
+
throw new Error(`Attempted to download the linux sysroot for ${electronVersion} but the SHA checksum did not match`);
|
|
987
|
+
d3("writing sysroot to disk");
|
|
988
|
+
const tmpTarFile = path4.resolve(ELECTRON_GYP_DIR, `${electronVersion}-${fileName}`);
|
|
989
|
+
if (fs3.existsSync(tmpTarFile))
|
|
990
|
+
await fs3.promises.rm(tmpTarFile, { recursive: true, force: true });
|
|
991
|
+
await fs3.promises.writeFile(tmpTarFile, sysrootBuffer);
|
|
992
|
+
d3("decompressing sysroot");
|
|
993
|
+
await (0, import_cross_spawn_promise.spawn)("tar", ["-xf", tmpTarFile, "-C", sysrootDir], { stdio: "ignore" });
|
|
994
|
+
return sysrootDir;
|
|
995
|
+
}
|
|
996
|
+
var import_debug3, import_cross_spawn_promise, d3, sysrootArchAliases, SYSROOT_BASE_URL;
|
|
997
|
+
var init_sysroot_fetcher = __esm({
|
|
998
|
+
"../../node_modules/@electron/rebuild/lib/sysroot-fetcher.js"() {
|
|
999
|
+
"use strict";
|
|
1000
|
+
import_debug3 = __toESM(require_src(), 1);
|
|
1001
|
+
init_constants();
|
|
1002
|
+
init_fetcher();
|
|
1003
|
+
import_cross_spawn_promise = __toESM(require_src2(), 1);
|
|
1004
|
+
d3 = (0, import_debug3.default)("electron-rebuild");
|
|
1005
|
+
sysrootArchAliases = {
|
|
1006
|
+
x64: "amd64",
|
|
1007
|
+
ia32: "i386"
|
|
1008
|
+
};
|
|
1009
|
+
SYSROOT_BASE_URL = "https://dev-cdn.electronjs.org/linux-sysroots";
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
// ../../node_modules/@electron/rebuild/lib/clang-fetcher.js
|
|
1014
|
+
import cp from "child_process";
|
|
1015
|
+
import fs4 from "fs";
|
|
1016
|
+
import path5 from "path";
|
|
1017
|
+
function getPlatformUrlPrefix(hostOS, hostArch) {
|
|
1018
|
+
const prefixMap = {
|
|
1019
|
+
linux: "Linux_x64",
|
|
1020
|
+
darwin: "Mac",
|
|
1021
|
+
win32: "Win"
|
|
1022
|
+
};
|
|
1023
|
+
let prefix = prefixMap[hostOS];
|
|
1024
|
+
if (prefix === "Mac" && hostArch === "arm64") {
|
|
1025
|
+
prefix = "Mac_arm64";
|
|
1026
|
+
}
|
|
1027
|
+
return CDS_URL + "/" + prefix + "/";
|
|
1028
|
+
}
|
|
1029
|
+
function getClangDownloadURL(packageFile, packageVersion, hostOS, hostArch) {
|
|
1030
|
+
const cdsFile = `${packageFile}-${packageVersion}.tgz`;
|
|
1031
|
+
return getPlatformUrlPrefix(hostOS, hostArch) + cdsFile;
|
|
1032
|
+
}
|
|
1033
|
+
function getSDKRoot() {
|
|
1034
|
+
if (process.env.SDKROOT)
|
|
1035
|
+
return process.env.SDKROOT;
|
|
1036
|
+
const output = cp.execFileSync("xcrun", ["--sdk", "macosx", "--show-sdk-path"]);
|
|
1037
|
+
return output.toString().trim();
|
|
1038
|
+
}
|
|
1039
|
+
async function getClangEnvironmentVars(electronVersion, targetArch) {
|
|
1040
|
+
const clangDownloadDir = await downloadClangVersion(electronVersion);
|
|
1041
|
+
const clangDir = path5.resolve(clangDownloadDir, "bin");
|
|
1042
|
+
const clangArgs = [];
|
|
1043
|
+
if (process.platform === "darwin") {
|
|
1044
|
+
clangArgs.push("-isysroot", getSDKRoot());
|
|
1045
|
+
}
|
|
1046
|
+
const gypArgs = [];
|
|
1047
|
+
if (process.platform === "win32") {
|
|
1048
|
+
console.log(await fs4.promises.readdir(clangDir));
|
|
1049
|
+
gypArgs.push(`/p:CLToolExe=clang-cl.exe`, `/p:CLToolPath=${clangDir}`);
|
|
1050
|
+
}
|
|
1051
|
+
if (process.platform === "linux") {
|
|
1052
|
+
const sysrootPath = await downloadLinuxSysroot(electronVersion, targetArch);
|
|
1053
|
+
clangArgs.push("--sysroot", sysrootPath);
|
|
1054
|
+
}
|
|
1055
|
+
return {
|
|
1056
|
+
env: {
|
|
1057
|
+
CC: `"${path5.resolve(clangDir, "clang")}" ${clangArgs.join(" ")}`,
|
|
1058
|
+
CXX: `"${path5.resolve(clangDir, "clang++")}" ${clangArgs.join(" ")}`
|
|
1059
|
+
},
|
|
1060
|
+
args: gypArgs
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
function clangVersionFromRevision(update) {
|
|
1064
|
+
const regex = /CLANG_REVISION = '([^']+)'\nCLANG_SUB_REVISION = (\d+)\n/g;
|
|
1065
|
+
const clangVersionMatch = regex.exec(update);
|
|
1066
|
+
if (!clangVersionMatch)
|
|
1067
|
+
return null;
|
|
1068
|
+
const [, clangVersion, clangSubRevision] = clangVersionMatch;
|
|
1069
|
+
return `${clangVersion}-${clangSubRevision}`;
|
|
1070
|
+
}
|
|
1071
|
+
function clangVersionFromSVN(update) {
|
|
1072
|
+
const regex = /CLANG_REVISION = '([^']+)'\nCLANG_SVN_REVISION = '([^']+)'\nCLANG_SUB_REVISION = (\d+)\n/g;
|
|
1073
|
+
const clangVersionMatch = regex.exec(update);
|
|
1074
|
+
if (!clangVersionMatch)
|
|
1075
|
+
return null;
|
|
1076
|
+
const [, clangVersion, clangSvn, clangSubRevision] = clangVersionMatch;
|
|
1077
|
+
return `${clangSvn}-${clangVersion.substr(0, 8)}-${clangSubRevision}`;
|
|
1078
|
+
}
|
|
1079
|
+
async function downloadClangVersion(electronVersion) {
|
|
1080
|
+
d4("fetching clang for Electron:", electronVersion);
|
|
1081
|
+
const clangDirPath = path5.resolve(ELECTRON_GYP_DIR, `${electronVersion}-clang`);
|
|
1082
|
+
if (fs4.existsSync(path5.resolve(clangDirPath, "bin", "clang")))
|
|
1083
|
+
return clangDirPath;
|
|
1084
|
+
await fs4.promises.mkdir(ELECTRON_GYP_DIR, { recursive: true });
|
|
1085
|
+
const electronDeps = await fetchUrl(`https://raw.githubusercontent.com/electron/electron/v${electronVersion}/DEPS`, "text");
|
|
1086
|
+
const chromiumRevisionExtractor = /'chromium_version':\n\s+'([^']+)/g;
|
|
1087
|
+
const chromiumRevisionMatch = chromiumRevisionExtractor.exec(electronDeps);
|
|
1088
|
+
if (!chromiumRevisionMatch)
|
|
1089
|
+
throw new Error("Failed to determine Chromium revision for given Electron version");
|
|
1090
|
+
const chromiumRevision = chromiumRevisionMatch[1];
|
|
1091
|
+
d4("fetching clang for Chromium:", chromiumRevision);
|
|
1092
|
+
const base64ClangUpdate = await fetchUrl(`https://chromium.googlesource.com/chromium/src.git/+/${chromiumRevision}/tools/clang/scripts/update.py?format=TEXT`, "text");
|
|
1093
|
+
const clangUpdate = Buffer.from(base64ClangUpdate, "base64").toString("utf8");
|
|
1094
|
+
const clangVersionString = clangVersionFromRevision(clangUpdate) || clangVersionFromSVN(clangUpdate);
|
|
1095
|
+
if (!clangVersionString)
|
|
1096
|
+
throw new Error("Failed to determine Clang revision from Electron version");
|
|
1097
|
+
d4("fetching clang:", clangVersionString);
|
|
1098
|
+
const clangDownloadURL = getClangDownloadURL("clang", clangVersionString, process.platform, process.arch);
|
|
1099
|
+
const contents = await fetchUrl(clangDownloadURL, "buffer");
|
|
1100
|
+
const tarPath = path5.resolve(ELECTRON_GYP_DIR, `${electronVersion}-clang.tgz`);
|
|
1101
|
+
if (fs4.existsSync(tarPath))
|
|
1102
|
+
await fs4.promises.rm(tarPath, { recursive: true, force: true });
|
|
1103
|
+
await fs4.promises.writeFile(tarPath, contents);
|
|
1104
|
+
await fs4.promises.mkdir(clangDirPath, { recursive: true });
|
|
1105
|
+
d4("extracting clang");
|
|
1106
|
+
await (0, import_cross_spawn_promise2.spawn)("tar", ["-xf", tarPath, "-C", clangDirPath], { stdio: "ignore" });
|
|
1107
|
+
await fs4.promises.rm(tarPath, { recursive: true, force: true });
|
|
1108
|
+
d4("cleaning up clang tar file");
|
|
1109
|
+
return clangDirPath;
|
|
1110
|
+
}
|
|
1111
|
+
var import_debug4, import_cross_spawn_promise2, d4, CDS_URL;
|
|
1112
|
+
var init_clang_fetcher = __esm({
|
|
1113
|
+
"../../node_modules/@electron/rebuild/lib/clang-fetcher.js"() {
|
|
1114
|
+
"use strict";
|
|
1115
|
+
import_debug4 = __toESM(require_src(), 1);
|
|
1116
|
+
init_constants();
|
|
1117
|
+
init_fetcher();
|
|
1118
|
+
init_sysroot_fetcher();
|
|
1119
|
+
import_cross_spawn_promise2 = __toESM(require_src2(), 1);
|
|
1120
|
+
d4 = (0, import_debug4.default)("electron-rebuild");
|
|
1121
|
+
CDS_URL = "https://commondatastorage.googleapis.com/chromium-browser-clang";
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
// ../../node_modules/node-api-version/index.js
|
|
1126
|
+
var require_node_api_version = __commonJS({
|
|
1127
|
+
"../../node_modules/node-api-version/index.js"(exports) {
|
|
1128
|
+
"use strict";
|
|
1129
|
+
var semver3 = require_semver();
|
|
1130
|
+
var nodeApiVersionRanges = [
|
|
1131
|
+
[">=24 || ^22.14 || ^23.6", 10],
|
|
1132
|
+
[">=21 || ^18.17 || ^20.3", 9],
|
|
1133
|
+
[">=16 || ^15.12 || ^12.22", 8],
|
|
1134
|
+
[">=15 || ^14.12 || ^12.19 || ^10.23", 7],
|
|
1135
|
+
[">=14 || ^12.17 || ^10.20", 6],
|
|
1136
|
+
[">=13 || ^12.11 || ^10.17", 5],
|
|
1137
|
+
[">=12 || ^11.8 || ^10.16", 4],
|
|
1138
|
+
[">=10", 3]
|
|
1139
|
+
];
|
|
1140
|
+
function fromNodeVersion(nodeVersion) {
|
|
1141
|
+
for (const [range, version] of nodeApiVersionRanges) {
|
|
1142
|
+
if (semver3.satisfies(nodeVersion, range)) {
|
|
1143
|
+
return version;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return void 0;
|
|
1147
|
+
}
|
|
1148
|
+
exports.fromNodeVersion = fromNodeVersion;
|
|
1149
|
+
var electronNapiVersions = (
|
|
1150
|
+
// replace-start
|
|
1151
|
+
[
|
|
1152
|
+
["35.0.0-beta.8", 10],
|
|
1153
|
+
["35.0.0-alpha.1", 8],
|
|
1154
|
+
["27.0.0-alpha.1", 9],
|
|
1155
|
+
["15.0.0-alpha.1", 8],
|
|
1156
|
+
["12.0.0-beta.1", 7],
|
|
1157
|
+
["11.0.0-beta.1", 6],
|
|
1158
|
+
["8.0.0-beta.1", 5],
|
|
1159
|
+
["5.0.0-beta.1", 4],
|
|
1160
|
+
["3.0.0-beta.1", 3]
|
|
1161
|
+
]
|
|
1162
|
+
);
|
|
1163
|
+
function fromElectronVersion(electronVersion) {
|
|
1164
|
+
for (const [change, version] of electronNapiVersions) {
|
|
1165
|
+
if (semver3.gte(electronVersion, change)) {
|
|
1166
|
+
return version;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return void 0;
|
|
1170
|
+
}
|
|
1171
|
+
exports.fromElectronVersion = fromElectronVersion;
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
// ../../node_modules/@electron/rebuild/lib/node-api.js
|
|
1176
|
+
var import_node_api_version, NodeAPI;
|
|
1177
|
+
var init_node_api = __esm({
|
|
1178
|
+
"../../node_modules/@electron/rebuild/lib/node-api.js"() {
|
|
1179
|
+
"use strict";
|
|
1180
|
+
import_node_api_version = __toESM(require_node_api_version(), 1);
|
|
1181
|
+
NodeAPI = class {
|
|
1182
|
+
moduleName;
|
|
1183
|
+
electronVersion;
|
|
1184
|
+
constructor(moduleName, electronVersion) {
|
|
1185
|
+
this.moduleName = moduleName;
|
|
1186
|
+
this.electronVersion = electronVersion;
|
|
1187
|
+
}
|
|
1188
|
+
ensureElectronSupport() {
|
|
1189
|
+
this.getVersionForElectron();
|
|
1190
|
+
}
|
|
1191
|
+
getVersionForElectron() {
|
|
1192
|
+
const electronNapiVersion = (0, import_node_api_version.fromElectronVersion)(this.electronVersion);
|
|
1193
|
+
if (!electronNapiVersion) {
|
|
1194
|
+
throw new Error(`Native module '${this.moduleName}' requires Node-API but Electron v${this.electronVersion} does not support Node-API`);
|
|
1195
|
+
}
|
|
1196
|
+
return electronNapiVersion;
|
|
1197
|
+
}
|
|
1198
|
+
getNapiVersion(moduleNapiVersions) {
|
|
1199
|
+
const electronNapiVersion = this.getVersionForElectron();
|
|
1200
|
+
const filteredVersions = moduleNapiVersions.filter((v) => v <= electronNapiVersion);
|
|
1201
|
+
if (filteredVersions.length === 0) {
|
|
1202
|
+
throw new Error(`Native module '${this.moduleName}' supports Node-API versions ${moduleNapiVersions.join(", ")} but Electron v${this.electronVersion} only supports Node-API v${electronNapiVersion}`);
|
|
1203
|
+
}
|
|
1204
|
+
return Math.max(...filteredVersions);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
// ../../node_modules/@electron/rebuild/lib/read-package-json.js
|
|
1211
|
+
import fs5 from "fs/promises";
|
|
1212
|
+
import path6 from "path";
|
|
1213
|
+
async function readPackageJson(dir, safe = false) {
|
|
1214
|
+
try {
|
|
1215
|
+
return JSON.parse(await fs5.readFile(path6.resolve(dir, "package.json"), {
|
|
1216
|
+
encoding: "utf-8"
|
|
1217
|
+
}));
|
|
1218
|
+
} catch (err) {
|
|
1219
|
+
if (safe) {
|
|
1220
|
+
return {};
|
|
1221
|
+
} else {
|
|
1222
|
+
throw err;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
var init_read_package_json = __esm({
|
|
1227
|
+
"../../node_modules/@electron/rebuild/lib/read-package-json.js"() {
|
|
1228
|
+
"use strict";
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
// ../../node_modules/@electron/rebuild/lib/module-type/index.js
|
|
1233
|
+
import fs6 from "fs";
|
|
1234
|
+
import path7 from "path";
|
|
1235
|
+
async function locateBinary(basePath, suffix) {
|
|
1236
|
+
let parentPath = basePath;
|
|
1237
|
+
let testPath;
|
|
1238
|
+
while (testPath !== parentPath) {
|
|
1239
|
+
testPath = parentPath;
|
|
1240
|
+
const checkPath = path7.resolve(testPath, suffix);
|
|
1241
|
+
if (fs6.existsSync(checkPath)) {
|
|
1242
|
+
return checkPath;
|
|
1243
|
+
}
|
|
1244
|
+
parentPath = path7.resolve(testPath, "..");
|
|
1245
|
+
}
|
|
1246
|
+
return null;
|
|
1247
|
+
}
|
|
1248
|
+
var NativeModule;
|
|
1249
|
+
var init_module_type = __esm({
|
|
1250
|
+
"../../node_modules/@electron/rebuild/lib/module-type/index.js"() {
|
|
1251
|
+
"use strict";
|
|
1252
|
+
init_node_api();
|
|
1253
|
+
init_read_package_json();
|
|
1254
|
+
NativeModule = class {
|
|
1255
|
+
rebuilder;
|
|
1256
|
+
_moduleName;
|
|
1257
|
+
modulePath;
|
|
1258
|
+
nodeAPI;
|
|
1259
|
+
packageJSON;
|
|
1260
|
+
constructor(rebuilder, modulePath) {
|
|
1261
|
+
this.rebuilder = rebuilder;
|
|
1262
|
+
this.modulePath = modulePath;
|
|
1263
|
+
this.nodeAPI = new NodeAPI(this.moduleName, this.rebuilder.electronVersion);
|
|
1264
|
+
}
|
|
1265
|
+
get moduleName() {
|
|
1266
|
+
if (!this._moduleName) {
|
|
1267
|
+
const basename = path7.basename(this.modulePath);
|
|
1268
|
+
const parentDir = path7.basename(path7.dirname(this.modulePath));
|
|
1269
|
+
if (parentDir.startsWith("@")) {
|
|
1270
|
+
this._moduleName = `${parentDir}/${basename}`;
|
|
1271
|
+
}
|
|
1272
|
+
this._moduleName = basename;
|
|
1273
|
+
}
|
|
1274
|
+
return this._moduleName;
|
|
1275
|
+
}
|
|
1276
|
+
async packageJSONFieldWithDefault(key, defaultValue) {
|
|
1277
|
+
const result = await this.packageJSONField(key);
|
|
1278
|
+
return result === void 0 ? defaultValue : result;
|
|
1279
|
+
}
|
|
1280
|
+
async packageJSONField(key) {
|
|
1281
|
+
this.packageJSON ||= await readPackageJson(this.modulePath);
|
|
1282
|
+
return this.packageJSON[key];
|
|
1283
|
+
}
|
|
1284
|
+
async getSupportedNapiVersions() {
|
|
1285
|
+
const binary = await this.packageJSONFieldWithDefault("binary", {});
|
|
1286
|
+
return binary?.napi_versions;
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Search dependencies for package using either `packageName` or
|
|
1290
|
+
* `@namespace/packageName` in the case of forks.
|
|
1291
|
+
*/
|
|
1292
|
+
async findPackageInDependencies(packageName, packageProperty = "dependencies") {
|
|
1293
|
+
const dependencies = await this.packageJSONFieldWithDefault(packageProperty, {});
|
|
1294
|
+
if (typeof dependencies !== "object")
|
|
1295
|
+
return null;
|
|
1296
|
+
if (dependencies.hasOwnProperty(packageName))
|
|
1297
|
+
return packageName;
|
|
1298
|
+
const forkedPackage = Object.keys(dependencies).find((dependency) => dependency.startsWith("@") && dependency.endsWith(`/${packageName}`));
|
|
1299
|
+
return forkedPackage || null;
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
// ../../node_modules/@electron/rebuild/lib/detect-libc.js
|
|
1306
|
+
function detectLibcFamily() {
|
|
1307
|
+
if (cached !== void 0)
|
|
1308
|
+
return cached;
|
|
1309
|
+
if (process.platform !== "linux")
|
|
1310
|
+
return cached = null;
|
|
1311
|
+
const report = process.report?.getReport();
|
|
1312
|
+
if (report?.header?.glibcVersionRuntime)
|
|
1313
|
+
return cached = "glibc";
|
|
1314
|
+
if (Array.isArray(report?.sharedObjects) && report.sharedObjects.some((s) => s.includes("libc.musl") || s.includes("ld-musl"))) {
|
|
1315
|
+
return cached = "musl";
|
|
1316
|
+
}
|
|
1317
|
+
return cached = null;
|
|
1318
|
+
}
|
|
1319
|
+
var cached;
|
|
1320
|
+
var init_detect_libc = __esm({
|
|
1321
|
+
"../../node_modules/@electron/rebuild/lib/detect-libc.js"() {
|
|
1322
|
+
"use strict";
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
|
|
1326
|
+
// ../../node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js
|
|
1327
|
+
import { fork } from "child_process";
|
|
1328
|
+
import path8 from "path";
|
|
1329
|
+
var import_debug5, d5, NodeGyp;
|
|
1330
|
+
var init_node_gyp = __esm({
|
|
1331
|
+
"../../node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js"() {
|
|
1332
|
+
"use strict";
|
|
1333
|
+
import_debug5 = __toESM(require_src(), 1);
|
|
1334
|
+
init_constants();
|
|
1335
|
+
init_clang_fetcher();
|
|
1336
|
+
init_module_type();
|
|
1337
|
+
init_detect_libc();
|
|
1338
|
+
d5 = (0, import_debug5.default)("electron-rebuild");
|
|
1339
|
+
NodeGyp = class extends NativeModule {
|
|
1340
|
+
async buildArgs(prefixedArgs) {
|
|
1341
|
+
const args = [
|
|
1342
|
+
"node",
|
|
1343
|
+
"node-gyp",
|
|
1344
|
+
"rebuild",
|
|
1345
|
+
...prefixedArgs,
|
|
1346
|
+
`--runtime=electron`,
|
|
1347
|
+
`--target=${this.rebuilder.electronVersion}`,
|
|
1348
|
+
`--arch=${this.rebuilder.arch}`,
|
|
1349
|
+
`--dist-url=${this.rebuilder.headerURL}`,
|
|
1350
|
+
"--build-from-source"
|
|
1351
|
+
];
|
|
1352
|
+
args.push(d5.enabled ? "--verbose" : "--silent");
|
|
1353
|
+
if (this.rebuilder.debug) {
|
|
1354
|
+
args.push("--debug");
|
|
1355
|
+
}
|
|
1356
|
+
args.push(...await this.buildArgsFromBinaryField());
|
|
1357
|
+
if (this.rebuilder.msvsVersion) {
|
|
1358
|
+
args.push(`--msvs_version=${this.rebuilder.msvsVersion}`);
|
|
1359
|
+
}
|
|
1360
|
+
if (this.rebuilder.jobs) {
|
|
1361
|
+
args.push(`--jobs=${this.rebuilder.jobs}`);
|
|
1362
|
+
}
|
|
1363
|
+
const [maj, min] = this.rebuilder.electronVersion.split(".").map(Number);
|
|
1364
|
+
if (maj < 14 || maj === 14 && min < 2 || maj === 15 && min < 3) {
|
|
1365
|
+
args.push("--force-process-config");
|
|
1366
|
+
}
|
|
1367
|
+
return args;
|
|
1368
|
+
}
|
|
1369
|
+
async buildArgsFromBinaryField() {
|
|
1370
|
+
const binary = await this.packageJSONFieldWithDefault("binary", {});
|
|
1371
|
+
let napiBuildVersion = void 0;
|
|
1372
|
+
if (Array.isArray(binary.napi_versions)) {
|
|
1373
|
+
napiBuildVersion = this.nodeAPI.getNapiVersion(binary.napi_versions.map((str) => Number(str)));
|
|
1374
|
+
}
|
|
1375
|
+
const flags = await Promise.all(Object.entries(binary).map(async ([binaryKey, binaryValue]) => {
|
|
1376
|
+
if (binaryKey === "napi_versions") {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
let value = binaryValue;
|
|
1380
|
+
if (binaryKey === "module_path") {
|
|
1381
|
+
value = path8.resolve(this.modulePath, value);
|
|
1382
|
+
}
|
|
1383
|
+
value = value.replace("{configuration}", this.rebuilder.buildType).replace("{node_abi}", `electron-v${this.rebuilder.electronVersion.split(".").slice(0, 2).join(".")}`).replace("{platform}", this.rebuilder.platform).replace("{arch}", this.rebuilder.arch).replace("{version}", await this.packageJSONField("version")).replace("{libc}", detectLibcFamily() || "unknown");
|
|
1384
|
+
if (napiBuildVersion !== void 0) {
|
|
1385
|
+
value = value.replace("{napi_build_version}", napiBuildVersion.toString());
|
|
1386
|
+
}
|
|
1387
|
+
for (const [replaceKey, replaceValue] of Object.entries(binary)) {
|
|
1388
|
+
value = value.replace(`{${replaceKey}}`, replaceValue);
|
|
1389
|
+
}
|
|
1390
|
+
return `--${binaryKey}=${value}`;
|
|
1391
|
+
}));
|
|
1392
|
+
return flags.filter((value) => value);
|
|
1393
|
+
}
|
|
1394
|
+
async rebuildModule() {
|
|
1395
|
+
if (this.rebuilder.platform !== process.platform) {
|
|
1396
|
+
throw new Error("node-gyp does not support cross-compiling native modules from source.");
|
|
1397
|
+
}
|
|
1398
|
+
if (this.modulePath.includes(" ")) {
|
|
1399
|
+
console.error("Attempting to build a module with a space in the path");
|
|
1400
|
+
console.error("See https://github.com/nodejs/node-gyp/issues/65#issuecomment-368820565 for reasons why this may not work");
|
|
1401
|
+
}
|
|
1402
|
+
const env = {
|
|
1403
|
+
...process.env
|
|
1404
|
+
};
|
|
1405
|
+
const extraNodeGypArgs = [];
|
|
1406
|
+
if (this.rebuilder.useElectronClang) {
|
|
1407
|
+
const { env: clangEnv, args: clangArgs } = await getClangEnvironmentVars(this.rebuilder.electronVersion, this.rebuilder.arch);
|
|
1408
|
+
Object.assign(env, clangEnv);
|
|
1409
|
+
extraNodeGypArgs.push(...clangArgs);
|
|
1410
|
+
}
|
|
1411
|
+
const nodeGypArgs = await this.buildArgs(extraNodeGypArgs);
|
|
1412
|
+
d5("rebuilding", this.moduleName, "with args", nodeGypArgs);
|
|
1413
|
+
const forkedChild = fork(path8.resolve(import.meta.dirname, "worker.js"), {
|
|
1414
|
+
env,
|
|
1415
|
+
cwd: this.modulePath,
|
|
1416
|
+
stdio: "pipe"
|
|
1417
|
+
});
|
|
1418
|
+
const outputBuffers = [];
|
|
1419
|
+
forkedChild.stdout?.on("data", (chunk) => {
|
|
1420
|
+
outputBuffers.push(chunk);
|
|
1421
|
+
});
|
|
1422
|
+
forkedChild.stderr?.on("data", (chunk) => {
|
|
1423
|
+
outputBuffers.push(chunk);
|
|
1424
|
+
});
|
|
1425
|
+
forkedChild.send({
|
|
1426
|
+
moduleName: this.moduleName,
|
|
1427
|
+
nodeGypArgs,
|
|
1428
|
+
extraNodeGypArgs,
|
|
1429
|
+
devDir: this.rebuilder.mode === "sequential" ? ELECTRON_GYP_DIR : path8.resolve(ELECTRON_GYP_DIR, "_p", this.moduleName)
|
|
1430
|
+
});
|
|
1431
|
+
await new Promise((resolve, reject) => {
|
|
1432
|
+
forkedChild.on("exit", (code) => {
|
|
1433
|
+
if (code === 0)
|
|
1434
|
+
return resolve();
|
|
1435
|
+
console.error(Buffer.concat(outputBuffers).toString());
|
|
1436
|
+
reject(new Error(`node-gyp failed to rebuild '${this.modulePath}'`));
|
|
1437
|
+
});
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
|
|
1444
|
+
// ../../node_modules/@electron/rebuild/lib/arch.js
|
|
1445
|
+
import { execSync } from "child_process";
|
|
1446
|
+
function uname() {
|
|
1447
|
+
return execSync("uname -m").toString().trim();
|
|
1448
|
+
}
|
|
1449
|
+
function getNodeArch(arch, configVariables) {
|
|
1450
|
+
if (arch === "arm") {
|
|
1451
|
+
switch (configVariables.arm_version) {
|
|
1452
|
+
case "6":
|
|
1453
|
+
return uname();
|
|
1454
|
+
case "7":
|
|
1455
|
+
default:
|
|
1456
|
+
return "armv7l";
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
return arch;
|
|
1460
|
+
}
|
|
1461
|
+
var init_arch = __esm({
|
|
1462
|
+
"../../node_modules/@electron/rebuild/lib/arch.js"() {
|
|
1463
|
+
"use strict";
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// ../../node_modules/@electron/rebuild/lib/module-type/prebuildify.js
|
|
1468
|
+
import fs7 from "fs";
|
|
1469
|
+
import path9 from "path";
|
|
1470
|
+
function determineNativePrebuildArch(arch) {
|
|
1471
|
+
if (arch === "armv7l") {
|
|
1472
|
+
return "arm";
|
|
1473
|
+
}
|
|
1474
|
+
return arch;
|
|
1475
|
+
}
|
|
1476
|
+
function determineNativePrebuildExtension(arch) {
|
|
1477
|
+
switch (arch) {
|
|
1478
|
+
case "arm64":
|
|
1479
|
+
return "armv8.node";
|
|
1480
|
+
case "armv7l":
|
|
1481
|
+
return "armv7.node";
|
|
1482
|
+
}
|
|
1483
|
+
return "node";
|
|
1484
|
+
}
|
|
1485
|
+
var import_debug6, d6, Prebuildify;
|
|
1486
|
+
var init_prebuildify = __esm({
|
|
1487
|
+
"../../node_modules/@electron/rebuild/lib/module-type/prebuildify.js"() {
|
|
1488
|
+
"use strict";
|
|
1489
|
+
import_debug6 = __toESM(require_src(), 1);
|
|
1490
|
+
init_arch();
|
|
1491
|
+
init_module_type();
|
|
1492
|
+
d6 = (0, import_debug6.default)("electron-rebuild");
|
|
1493
|
+
Prebuildify = class extends NativeModule {
|
|
1494
|
+
async usesTool() {
|
|
1495
|
+
const packageName = await this.findPackageInDependencies("prebuildify", "devDependencies");
|
|
1496
|
+
return !!packageName;
|
|
1497
|
+
}
|
|
1498
|
+
async findPrebuiltModule() {
|
|
1499
|
+
d6(`Checking for prebuilds for "${this.moduleName}"`);
|
|
1500
|
+
const prebuildsDir = path9.join(this.modulePath, "prebuilds");
|
|
1501
|
+
if (!fs7.existsSync(prebuildsDir)) {
|
|
1502
|
+
d6(`Could not find the prebuilds directory at "${prebuildsDir}"`);
|
|
1503
|
+
return false;
|
|
1504
|
+
}
|
|
1505
|
+
const nodeArch = getNodeArch(this.rebuilder.arch, process.config.variables);
|
|
1506
|
+
const prebuiltModuleDir = path9.join(prebuildsDir, `${this.rebuilder.platform}-${determineNativePrebuildArch(nodeArch)}`);
|
|
1507
|
+
const nativeExt = determineNativePrebuildExtension(nodeArch);
|
|
1508
|
+
const electronNapiModuleFilename = path9.join(prebuiltModuleDir, `electron.napi.${nativeExt}`);
|
|
1509
|
+
const nodejsNapiModuleFilename = path9.join(prebuiltModuleDir, `node.napi.${nativeExt}`);
|
|
1510
|
+
const abiModuleFilename = path9.join(prebuiltModuleDir, `electron.abi${this.rebuilder.ABI}.${nativeExt}`);
|
|
1511
|
+
if (fs7.existsSync(electronNapiModuleFilename) || fs7.existsSync(nodejsNapiModuleFilename)) {
|
|
1512
|
+
this.nodeAPI.ensureElectronSupport();
|
|
1513
|
+
d6(`Found prebuilt Node-API module in ${prebuiltModuleDir}"`);
|
|
1514
|
+
} else if (fs7.existsSync(abiModuleFilename)) {
|
|
1515
|
+
d6(`Found prebuilt module: "${abiModuleFilename}"`);
|
|
1516
|
+
} else {
|
|
1517
|
+
d6(`Could not locate "${electronNapiModuleFilename}", "${nodejsNapiModuleFilename}", or "${abiModuleFilename}"`);
|
|
1518
|
+
return false;
|
|
1519
|
+
}
|
|
1520
|
+
return true;
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1526
|
+
// ../../node_modules/@electron/rebuild/lib/module-type/prebuild-install.js
|
|
1527
|
+
import fs8 from "fs";
|
|
1528
|
+
import path10 from "path";
|
|
1529
|
+
var import_debug7, import_cross_spawn_promise3, d7, PrebuildInstall;
|
|
1530
|
+
var init_prebuild_install = __esm({
|
|
1531
|
+
"../../node_modules/@electron/rebuild/lib/module-type/prebuild-install.js"() {
|
|
1532
|
+
"use strict";
|
|
1533
|
+
import_debug7 = __toESM(require_src(), 1);
|
|
1534
|
+
init_module_type();
|
|
1535
|
+
import_cross_spawn_promise3 = __toESM(require_src2(), 1);
|
|
1536
|
+
d7 = (0, import_debug7.default)("electron-rebuild");
|
|
1537
|
+
PrebuildInstall = class extends NativeModule {
|
|
1538
|
+
async usesTool() {
|
|
1539
|
+
const packageName = await this.findPackageInDependencies("prebuild-install");
|
|
1540
|
+
return !!packageName;
|
|
1541
|
+
}
|
|
1542
|
+
async locateBinary() {
|
|
1543
|
+
const packageName = await this.findPackageInDependencies("prebuild-install");
|
|
1544
|
+
if (!packageName)
|
|
1545
|
+
return null;
|
|
1546
|
+
return locateBinary(this.modulePath, `node_modules/${packageName}/bin.js`);
|
|
1547
|
+
}
|
|
1548
|
+
async run(prebuildInstallPath) {
|
|
1549
|
+
await (0, import_cross_spawn_promise3.spawn)(process.execPath, [
|
|
1550
|
+
path10.resolve(import.meta.dirname, "..", `prebuild-shim.js`),
|
|
1551
|
+
prebuildInstallPath,
|
|
1552
|
+
`--arch=${this.rebuilder.arch}`,
|
|
1553
|
+
`--platform=${this.rebuilder.platform}`,
|
|
1554
|
+
`--tag-prefix=${this.rebuilder.prebuildTagPrefix}`,
|
|
1555
|
+
...await this.getPrebuildInstallRuntimeArgs()
|
|
1556
|
+
], {
|
|
1557
|
+
cwd: this.modulePath
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
async findPrebuiltModule() {
|
|
1561
|
+
const prebuildInstallPath = await this.locateBinary();
|
|
1562
|
+
if (prebuildInstallPath) {
|
|
1563
|
+
d7(`triggering prebuild download step: ${this.moduleName}`);
|
|
1564
|
+
try {
|
|
1565
|
+
await this.run(prebuildInstallPath);
|
|
1566
|
+
return true;
|
|
1567
|
+
} catch (err) {
|
|
1568
|
+
d7("failed to use prebuild-install:", err);
|
|
1569
|
+
if (err?.message?.includes("requires Node-API but Electron")) {
|
|
1570
|
+
throw err;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
} else {
|
|
1574
|
+
d7(`could not find prebuild-install relative to: ${this.modulePath}`);
|
|
1575
|
+
}
|
|
1576
|
+
return false;
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Whether a prebuild-install-based native module exists.
|
|
1580
|
+
*/
|
|
1581
|
+
async prebuiltModuleExists() {
|
|
1582
|
+
return fs8.existsSync(path10.resolve(this.modulePath, "prebuilds", `${this.rebuilder.platform}-${this.rebuilder.arch}`, `electron-${this.rebuilder.ABI}.node`));
|
|
1583
|
+
}
|
|
1584
|
+
async getPrebuildInstallRuntimeArgs() {
|
|
1585
|
+
const moduleNapiVersions = await this.getSupportedNapiVersions();
|
|
1586
|
+
if (moduleNapiVersions) {
|
|
1587
|
+
const napiVersion = this.nodeAPI.getNapiVersion(moduleNapiVersions);
|
|
1588
|
+
return ["--runtime=napi", `--target=${napiVersion}`];
|
|
1589
|
+
} else {
|
|
1590
|
+
return ["--runtime=electron", `--target=${this.rebuilder.electronVersion}`];
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
|
|
1597
|
+
// ../../node_modules/read-binary-file-arch/index.js
|
|
1598
|
+
var require_read_binary_file_arch = __commonJS({
|
|
1599
|
+
"../../node_modules/read-binary-file-arch/index.js"(exports, module) {
|
|
1600
|
+
"use strict";
|
|
1601
|
+
var { promisify } = __require("util");
|
|
1602
|
+
var { exec } = __require("child_process");
|
|
1603
|
+
var { promises: fs13 } = __require("fs");
|
|
1604
|
+
var execAsync = promisify(exec);
|
|
1605
|
+
var debug12 = require_src()("read-binary-file-arch");
|
|
1606
|
+
var SUPPORTED_ARCH = [
|
|
1607
|
+
"arm",
|
|
1608
|
+
"arm64",
|
|
1609
|
+
"ia32",
|
|
1610
|
+
"loong64",
|
|
1611
|
+
"mips",
|
|
1612
|
+
"mipsel",
|
|
1613
|
+
"ppc",
|
|
1614
|
+
"ppc64",
|
|
1615
|
+
"riscv64",
|
|
1616
|
+
"s390",
|
|
1617
|
+
"s390x",
|
|
1618
|
+
"x64"
|
|
1619
|
+
];
|
|
1620
|
+
async function readPEArch(filePath) {
|
|
1621
|
+
const DOS_HEADER_PE_OFFSET = 60;
|
|
1622
|
+
const COFF_HEADER_MACHINE_OFFSET = 4;
|
|
1623
|
+
const BUFFER_SIZE = 1024;
|
|
1624
|
+
const buffer = Buffer.alloc(BUFFER_SIZE);
|
|
1625
|
+
const fileHandle = await fs13.open(filePath, "r");
|
|
1626
|
+
await fileHandle.read(buffer, 0, BUFFER_SIZE, 0);
|
|
1627
|
+
const peOffset = buffer.readUInt32LE(DOS_HEADER_PE_OFFSET);
|
|
1628
|
+
let machineType;
|
|
1629
|
+
try {
|
|
1630
|
+
machineType = buffer.readUInt16LE(
|
|
1631
|
+
peOffset + COFF_HEADER_MACHINE_OFFSET
|
|
1632
|
+
);
|
|
1633
|
+
} catch (error) {
|
|
1634
|
+
debug12("read error:", error.message);
|
|
1635
|
+
throw new Error("Invalid PE file");
|
|
1636
|
+
}
|
|
1637
|
+
const MACHINE_TYPES = {
|
|
1638
|
+
332: "ia32",
|
|
1639
|
+
34404: "x64",
|
|
1640
|
+
448: "arm",
|
|
1641
|
+
452: "arm",
|
|
1642
|
+
// ARMv7 Thumb-2 LE
|
|
1643
|
+
43620: "arm64"
|
|
1644
|
+
};
|
|
1645
|
+
const arch = MACHINE_TYPES[machineType];
|
|
1646
|
+
debug12("win32 arch:", arch);
|
|
1647
|
+
await fileHandle.close();
|
|
1648
|
+
return arch;
|
|
1649
|
+
}
|
|
1650
|
+
async function getArchUsingFileCommand(filePath) {
|
|
1651
|
+
const { stdout } = await execAsync(`file "${filePath}"`);
|
|
1652
|
+
const output = stdout.trim();
|
|
1653
|
+
debug12("file command output:", output);
|
|
1654
|
+
const resultStart = filePath.length + 1;
|
|
1655
|
+
const result = output.substring(resultStart).trim();
|
|
1656
|
+
debug12("result:", result);
|
|
1657
|
+
const FILE_ARCH = {
|
|
1658
|
+
x64: "x64",
|
|
1659
|
+
"x86-64": "x64",
|
|
1660
|
+
x86_64: "x64",
|
|
1661
|
+
x86: "ia32",
|
|
1662
|
+
i386: "ia32",
|
|
1663
|
+
arm64: "arm64",
|
|
1664
|
+
arm: "arm",
|
|
1665
|
+
aarch64: "arm64",
|
|
1666
|
+
ARMv7: "arm",
|
|
1667
|
+
ppc_7400: "ppc",
|
|
1668
|
+
// PE32 executable (console) Intel 80386, for MS Windows
|
|
1669
|
+
"Intel 80386": "ia32",
|
|
1670
|
+
// ELF 64-bit LSB executable, IA-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-ia64.so.2, for GNU/Linux 2.6.16
|
|
1671
|
+
"IA-64": "x64",
|
|
1672
|
+
// ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, for GNU/Linux 2.6.32
|
|
1673
|
+
PowerPC: "ppc",
|
|
1674
|
+
// ELF 32-bit MSB executable, MIPS, MIPS-IV version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, for GNU/Linux 2.4.1
|
|
1675
|
+
MIPS: "mips"
|
|
1676
|
+
};
|
|
1677
|
+
const fileArchRegexStr = Object.keys(FILE_ARCH).map((arch2) => `(?:${arch2})`).join("|");
|
|
1678
|
+
const fileArchRegex = new RegExp(fileArchRegexStr);
|
|
1679
|
+
const fileArchMatch = result.match(fileArchRegex);
|
|
1680
|
+
debug12("archMatch:", fileArchMatch && fileArchMatch[0]);
|
|
1681
|
+
const fileArch = fileArchMatch ? fileArchMatch[0] : null;
|
|
1682
|
+
const arch = FILE_ARCH[fileArch];
|
|
1683
|
+
return arch;
|
|
1684
|
+
}
|
|
1685
|
+
async function readBinaryFileArch2(filePath) {
|
|
1686
|
+
const stat = await fs13.stat(filePath);
|
|
1687
|
+
if (!stat.isFile()) {
|
|
1688
|
+
throw new Error(`${filePath} is not a file.`);
|
|
1689
|
+
}
|
|
1690
|
+
let arch;
|
|
1691
|
+
if (process.platform === "win32") {
|
|
1692
|
+
arch = await readPEArch(filePath);
|
|
1693
|
+
} else {
|
|
1694
|
+
arch = await getArchUsingFileCommand(filePath);
|
|
1695
|
+
}
|
|
1696
|
+
return SUPPORTED_ARCH.includes(arch) ? arch : null;
|
|
1697
|
+
}
|
|
1698
|
+
module.exports = { readBinaryFileArch: readBinaryFileArch2 };
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
|
|
1702
|
+
// ../../node_modules/@electron/rebuild/lib/module-type/node-pre-gyp.js
|
|
1703
|
+
var import_debug8, import_read_binary_file_arch, import_cross_spawn_promise4, d8, NodePreGyp;
|
|
1704
|
+
var init_node_pre_gyp = __esm({
|
|
1705
|
+
"../../node_modules/@electron/rebuild/lib/module-type/node-pre-gyp.js"() {
|
|
1706
|
+
"use strict";
|
|
1707
|
+
import_debug8 = __toESM(require_src(), 1);
|
|
1708
|
+
import_read_binary_file_arch = __toESM(require_read_binary_file_arch(), 1);
|
|
1709
|
+
init_module_type();
|
|
1710
|
+
import_cross_spawn_promise4 = __toESM(require_src2(), 1);
|
|
1711
|
+
d8 = (0, import_debug8.default)("electron-rebuild");
|
|
1712
|
+
NodePreGyp = class extends NativeModule {
|
|
1713
|
+
async usesTool() {
|
|
1714
|
+
const packageName = await this.findPackageInDependencies("node-pre-gyp");
|
|
1715
|
+
return !!packageName;
|
|
1716
|
+
}
|
|
1717
|
+
async locateBinary() {
|
|
1718
|
+
const packageName = await this.findPackageInDependencies("node-pre-gyp");
|
|
1719
|
+
if (!packageName)
|
|
1720
|
+
return null;
|
|
1721
|
+
return locateBinary(this.modulePath, `node_modules/${packageName}/bin/node-pre-gyp`);
|
|
1722
|
+
}
|
|
1723
|
+
async run(nodePreGypPath) {
|
|
1724
|
+
const redownloadBinary = await this.shouldUpdateBinary(nodePreGypPath);
|
|
1725
|
+
await (0, import_cross_spawn_promise4.spawn)(process.execPath, [
|
|
1726
|
+
nodePreGypPath,
|
|
1727
|
+
"reinstall",
|
|
1728
|
+
"--fallback-to-build",
|
|
1729
|
+
...redownloadBinary ? ["--update-binary"] : [],
|
|
1730
|
+
`--arch=${this.rebuilder.arch}`,
|
|
1731
|
+
// fallback build arch
|
|
1732
|
+
`--target_arch=${this.rebuilder.arch}`,
|
|
1733
|
+
// prebuild arch
|
|
1734
|
+
`--target_platform=${this.rebuilder.platform}`,
|
|
1735
|
+
...await this.getNodePreGypRuntimeArgs()
|
|
1736
|
+
], {
|
|
1737
|
+
cwd: this.modulePath
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
async findPrebuiltModule() {
|
|
1741
|
+
const nodePreGypPath = await this.locateBinary();
|
|
1742
|
+
if (nodePreGypPath) {
|
|
1743
|
+
d8(`triggering prebuild download step: ${this.moduleName}`);
|
|
1744
|
+
try {
|
|
1745
|
+
await this.run(nodePreGypPath);
|
|
1746
|
+
return true;
|
|
1747
|
+
} catch (err) {
|
|
1748
|
+
d8("failed to use node-pre-gyp:", err);
|
|
1749
|
+
if (err?.message?.includes("requires Node-API but Electron")) {
|
|
1750
|
+
throw err;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
} else {
|
|
1754
|
+
d8(`could not find node-pre-gyp relative to: ${this.modulePath}`);
|
|
1755
|
+
}
|
|
1756
|
+
return false;
|
|
1757
|
+
}
|
|
1758
|
+
async getNodePreGypRuntimeArgs() {
|
|
1759
|
+
const moduleNapiVersions = await this.getSupportedNapiVersions();
|
|
1760
|
+
if (moduleNapiVersions) {
|
|
1761
|
+
return [];
|
|
1762
|
+
} else {
|
|
1763
|
+
return [
|
|
1764
|
+
"--runtime=electron",
|
|
1765
|
+
`--target=${this.rebuilder.electronVersion}`,
|
|
1766
|
+
`--dist-url=${this.rebuilder.headerURL}`
|
|
1767
|
+
];
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
async shouldUpdateBinary(nodePreGypPath) {
|
|
1771
|
+
let shouldUpdate = false;
|
|
1772
|
+
try {
|
|
1773
|
+
const modulePaths = await this.getModulePaths(nodePreGypPath);
|
|
1774
|
+
d8("module paths:", modulePaths);
|
|
1775
|
+
for (const modulePath of modulePaths) {
|
|
1776
|
+
let moduleArch;
|
|
1777
|
+
try {
|
|
1778
|
+
moduleArch = await (0, import_read_binary_file_arch.readBinaryFileArch)(modulePath);
|
|
1779
|
+
d8("module arch:", moduleArch);
|
|
1780
|
+
} catch (error) {
|
|
1781
|
+
d8("failed to read module arch:", error.message);
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
1784
|
+
if (moduleArch && moduleArch !== this.rebuilder.arch) {
|
|
1785
|
+
shouldUpdate = true;
|
|
1786
|
+
d8("module architecture differs:", `${moduleArch} !== ${this.rebuilder.arch}`);
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
} catch (error) {
|
|
1791
|
+
d8("failed to get existing binary arch:", error.message);
|
|
1792
|
+
shouldUpdate = true;
|
|
1793
|
+
}
|
|
1794
|
+
return shouldUpdate;
|
|
1795
|
+
}
|
|
1796
|
+
async getModulePaths(nodePreGypPath) {
|
|
1797
|
+
const results = await (0, import_cross_spawn_promise4.spawn)(process.execPath, [
|
|
1798
|
+
nodePreGypPath,
|
|
1799
|
+
"reveal",
|
|
1800
|
+
"module",
|
|
1801
|
+
// pick property with module path
|
|
1802
|
+
`--target_arch=${this.rebuilder.arch}`,
|
|
1803
|
+
`--target_platform=${this.rebuilder.platform}`
|
|
1804
|
+
], {
|
|
1805
|
+
cwd: this.modulePath
|
|
1806
|
+
});
|
|
1807
|
+
return results.split("\n").filter(Boolean);
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1812
|
+
|
|
1813
|
+
// ../../node_modules/@electron/rebuild/lib/module-rebuilder.js
|
|
1814
|
+
import fs9 from "fs";
|
|
1815
|
+
import path11 from "path";
|
|
1816
|
+
var import_debug9, d9, ModuleRebuilder;
|
|
1817
|
+
var init_module_rebuilder = __esm({
|
|
1818
|
+
"../../node_modules/@electron/rebuild/lib/module-rebuilder.js"() {
|
|
1819
|
+
"use strict";
|
|
1820
|
+
import_debug9 = __toESM(require_src(), 1);
|
|
1821
|
+
init_cache();
|
|
1822
|
+
init_node_gyp();
|
|
1823
|
+
init_prebuildify();
|
|
1824
|
+
init_prebuild_install();
|
|
1825
|
+
init_node_pre_gyp();
|
|
1826
|
+
d9 = (0, import_debug9.default)("electron-rebuild");
|
|
1827
|
+
ModuleRebuilder = class {
|
|
1828
|
+
modulePath;
|
|
1829
|
+
nodeGyp;
|
|
1830
|
+
rebuilder;
|
|
1831
|
+
prebuildify;
|
|
1832
|
+
prebuildInstall;
|
|
1833
|
+
nodePreGyp;
|
|
1834
|
+
constructor(rebuilder, modulePath) {
|
|
1835
|
+
this.modulePath = modulePath;
|
|
1836
|
+
this.rebuilder = rebuilder;
|
|
1837
|
+
this.nodeGyp = new NodeGyp(rebuilder, modulePath);
|
|
1838
|
+
this.prebuildify = new Prebuildify(rebuilder, modulePath);
|
|
1839
|
+
this.prebuildInstall = new PrebuildInstall(rebuilder, modulePath);
|
|
1840
|
+
this.nodePreGyp = new NodePreGyp(rebuilder, modulePath);
|
|
1841
|
+
}
|
|
1842
|
+
get metaPath() {
|
|
1843
|
+
return path11.resolve(this.modulePath, "build", this.rebuilder.buildType, ".forge-meta");
|
|
1844
|
+
}
|
|
1845
|
+
get metaData() {
|
|
1846
|
+
return `${this.rebuilder.arch}--${this.rebuilder.ABI}`;
|
|
1847
|
+
}
|
|
1848
|
+
async alreadyBuiltByRebuild() {
|
|
1849
|
+
if (fs9.existsSync(this.metaPath)) {
|
|
1850
|
+
const meta = await fs9.promises.readFile(this.metaPath, "utf8");
|
|
1851
|
+
return meta === this.metaData;
|
|
1852
|
+
}
|
|
1853
|
+
return false;
|
|
1854
|
+
}
|
|
1855
|
+
async cacheModuleState(cacheKey) {
|
|
1856
|
+
if (this.rebuilder.useCache) {
|
|
1857
|
+
await cacheModuleState(this.modulePath, this.rebuilder.cachePath, cacheKey);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Whether a prebuild-install-generated native module exists.
|
|
1862
|
+
*/
|
|
1863
|
+
async prebuildInstallNativeModuleExists() {
|
|
1864
|
+
return this.prebuildInstall.prebuiltModuleExists();
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* If the native module uses prebuildify, check to see if it comes with a prebuilt module for
|
|
1868
|
+
* the given platform and arch.
|
|
1869
|
+
*/
|
|
1870
|
+
async findPrebuildifyModule(cacheKey) {
|
|
1871
|
+
if (await this.prebuildify.usesTool()) {
|
|
1872
|
+
d9(`assuming is prebuildify powered: ${this.prebuildify.moduleName}`);
|
|
1873
|
+
if (await this.prebuildify.findPrebuiltModule()) {
|
|
1874
|
+
await this.writeMetadata();
|
|
1875
|
+
await this.cacheModuleState(cacheKey);
|
|
1876
|
+
return true;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
return false;
|
|
1880
|
+
}
|
|
1881
|
+
async findPrebuildInstallModule(cacheKey) {
|
|
1882
|
+
if (await this.prebuildInstall.usesTool()) {
|
|
1883
|
+
d9(`assuming is prebuild-install powered: ${this.prebuildInstall.moduleName}`);
|
|
1884
|
+
if (await this.prebuildInstall.findPrebuiltModule()) {
|
|
1885
|
+
d9("installed prebuilt module:", this.prebuildInstall.moduleName);
|
|
1886
|
+
await this.writeMetadata();
|
|
1887
|
+
await this.cacheModuleState(cacheKey);
|
|
1888
|
+
return true;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
return false;
|
|
1892
|
+
}
|
|
1893
|
+
async findNodePreGypInstallModule(cacheKey) {
|
|
1894
|
+
if (await this.nodePreGyp.usesTool()) {
|
|
1895
|
+
d9(`assuming is node-pre-gyp powered: ${this.nodePreGyp.moduleName}`);
|
|
1896
|
+
if (await this.nodePreGyp.findPrebuiltModule()) {
|
|
1897
|
+
d9("installed prebuilt module:", this.nodePreGyp.moduleName);
|
|
1898
|
+
await this.writeMetadata();
|
|
1899
|
+
await this.cacheModuleState(cacheKey);
|
|
1900
|
+
return true;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
async rebuildNodeGypModule(cacheKey) {
|
|
1906
|
+
await this.nodeGyp.rebuildModule();
|
|
1907
|
+
d9("built via node-gyp:", this.nodeGyp.moduleName);
|
|
1908
|
+
await this.writeMetadata();
|
|
1909
|
+
await this.replaceExistingNativeModule();
|
|
1910
|
+
await this.cacheModuleState(cacheKey);
|
|
1911
|
+
return true;
|
|
1912
|
+
}
|
|
1913
|
+
async replaceExistingNativeModule() {
|
|
1914
|
+
const buildLocation = path11.resolve(this.modulePath, "build", this.rebuilder.buildType);
|
|
1915
|
+
d9("searching for .node file", buildLocation);
|
|
1916
|
+
const buildLocationFiles = await fs9.promises.readdir(buildLocation);
|
|
1917
|
+
d9("testing files", buildLocationFiles);
|
|
1918
|
+
const nodeFile = buildLocationFiles.find((file) => file !== ".node" && file.endsWith(".node"));
|
|
1919
|
+
const nodePath = nodeFile ? path11.resolve(buildLocation, nodeFile) : void 0;
|
|
1920
|
+
if (nodePath && fs9.existsSync(nodePath)) {
|
|
1921
|
+
d9("found .node file", nodePath);
|
|
1922
|
+
if (!this.rebuilder.disablePreGypCopy) {
|
|
1923
|
+
const abiPath = path11.resolve(this.modulePath, `bin/${this.rebuilder.platform}-${this.rebuilder.arch}-${this.rebuilder.ABI}`);
|
|
1924
|
+
d9("copying to prebuilt place:", abiPath);
|
|
1925
|
+
await fs9.promises.mkdir(abiPath, { recursive: true });
|
|
1926
|
+
await fs9.promises.copyFile(nodePath, path11.join(abiPath, `${this.nodeGyp.moduleName}.node`));
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
async writeMetadata() {
|
|
1931
|
+
await fs9.promises.mkdir(path11.dirname(this.metaPath), { recursive: true });
|
|
1932
|
+
await fs9.promises.writeFile(this.metaPath, this.metaData);
|
|
1933
|
+
}
|
|
1934
|
+
async rebuild(cacheKey) {
|
|
1935
|
+
if (!this.rebuilder.buildFromSource && (await this.findPrebuildifyModule(cacheKey) || await this.findPrebuildInstallModule(cacheKey) || await this.findNodePreGypInstallModule(cacheKey))) {
|
|
1936
|
+
return true;
|
|
1937
|
+
}
|
|
1938
|
+
return await this.rebuildNodeGypModule(cacheKey);
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
|
|
1944
|
+
// ../../node_modules/@electron/rebuild/lib/search-module.js
|
|
1945
|
+
import fs10 from "fs";
|
|
1946
|
+
import path12 from "path";
|
|
1947
|
+
async function shouldContinueSearch(traversedPath, rootPath, stopAtPackageJSON) {
|
|
1948
|
+
if (rootPath) {
|
|
1949
|
+
return Promise.resolve(traversedPath !== path12.dirname(rootPath));
|
|
1950
|
+
} else if (stopAtPackageJSON) {
|
|
1951
|
+
return fs10.existsSync(path12.join(traversedPath, "package.json"));
|
|
1952
|
+
} else {
|
|
1953
|
+
return true;
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
async function traverseAncestorDirectories(cwd, pathGenerator, rootPath, maxItems, stopAtPackageJSON) {
|
|
1957
|
+
const paths = [];
|
|
1958
|
+
let traversedPath = path12.resolve(cwd);
|
|
1959
|
+
while (await shouldContinueSearch(traversedPath, rootPath, stopAtPackageJSON)) {
|
|
1960
|
+
const generatedPath = pathGenerator(traversedPath);
|
|
1961
|
+
if (fs10.existsSync(generatedPath)) {
|
|
1962
|
+
paths.push(generatedPath);
|
|
1963
|
+
}
|
|
1964
|
+
const parentPath = path12.dirname(traversedPath);
|
|
1965
|
+
if (parentPath === traversedPath || maxItems && paths.length >= maxItems) {
|
|
1966
|
+
break;
|
|
1967
|
+
}
|
|
1968
|
+
traversedPath = parentPath;
|
|
1969
|
+
}
|
|
1970
|
+
return paths;
|
|
1971
|
+
}
|
|
1972
|
+
async function searchForModule(cwd, moduleName, rootPath) {
|
|
1973
|
+
const pathGenerator = (traversedPath) => path12.join(traversedPath, "node_modules", moduleName);
|
|
1974
|
+
return traverseAncestorDirectories(cwd, pathGenerator, rootPath, void 0, true);
|
|
1975
|
+
}
|
|
1976
|
+
async function searchForNodeModules(cwd, rootPath) {
|
|
1977
|
+
const pathGenerator = (traversedPath) => path12.join(traversedPath, "node_modules");
|
|
1978
|
+
return traverseAncestorDirectories(cwd, pathGenerator, rootPath, void 0, true);
|
|
1979
|
+
}
|
|
1980
|
+
var init_search_module = __esm({
|
|
1981
|
+
"../../node_modules/@electron/rebuild/lib/search-module.js"() {
|
|
1982
|
+
"use strict";
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
|
|
1986
|
+
// ../../node_modules/@electron/rebuild/lib/module-walker.js
|
|
1987
|
+
import fs11 from "fs";
|
|
1988
|
+
import path13 from "path";
|
|
1989
|
+
var import_debug10, d10, ModuleWalker;
|
|
1990
|
+
var init_module_walker = __esm({
|
|
1991
|
+
"../../node_modules/@electron/rebuild/lib/module-walker.js"() {
|
|
1992
|
+
"use strict";
|
|
1993
|
+
import_debug10 = __toESM(require_src(), 1);
|
|
1994
|
+
init_read_package_json();
|
|
1995
|
+
init_search_module();
|
|
1996
|
+
d10 = (0, import_debug10.default)("electron-rebuild");
|
|
1997
|
+
ModuleWalker = class {
|
|
1998
|
+
buildPath;
|
|
1999
|
+
modulesToRebuild;
|
|
2000
|
+
onlyModules;
|
|
2001
|
+
prodDeps;
|
|
2002
|
+
projectRootPath;
|
|
2003
|
+
realModulePaths;
|
|
2004
|
+
realNodeModulesPaths;
|
|
2005
|
+
types;
|
|
2006
|
+
constructor(buildPath, projectRootPath, types, prodDeps, onlyModules) {
|
|
2007
|
+
this.buildPath = buildPath;
|
|
2008
|
+
this.modulesToRebuild = [];
|
|
2009
|
+
this.projectRootPath = projectRootPath;
|
|
2010
|
+
this.types = types;
|
|
2011
|
+
this.prodDeps = prodDeps;
|
|
2012
|
+
this.onlyModules = onlyModules;
|
|
2013
|
+
this.realModulePaths = /* @__PURE__ */ new Set();
|
|
2014
|
+
this.realNodeModulesPaths = /* @__PURE__ */ new Set();
|
|
2015
|
+
}
|
|
2016
|
+
get nodeModulesPaths() {
|
|
2017
|
+
return searchForNodeModules(this.buildPath, this.projectRootPath);
|
|
2018
|
+
}
|
|
2019
|
+
async walkModules() {
|
|
2020
|
+
const rootPackageJson = await readPackageJson(this.buildPath);
|
|
2021
|
+
const markWaiters = [];
|
|
2022
|
+
const depKeys = [];
|
|
2023
|
+
if (this.types.includes("prod") || this.onlyModules) {
|
|
2024
|
+
depKeys.push(...Object.keys(rootPackageJson.dependencies || {}));
|
|
2025
|
+
}
|
|
2026
|
+
if (this.types.includes("optional") || this.onlyModules) {
|
|
2027
|
+
depKeys.push(...Object.keys(rootPackageJson.optionalDependencies || {}));
|
|
2028
|
+
}
|
|
2029
|
+
if (this.types.includes("dev") || this.onlyModules) {
|
|
2030
|
+
depKeys.push(...Object.keys(rootPackageJson.devDependencies || {}));
|
|
2031
|
+
}
|
|
2032
|
+
for (const key of depKeys) {
|
|
2033
|
+
this.prodDeps.add(key);
|
|
2034
|
+
const modulePaths = await searchForModule(this.buildPath, key, this.projectRootPath);
|
|
2035
|
+
for (const modulePath of modulePaths) {
|
|
2036
|
+
markWaiters.push(this.markChildrenAsProdDeps(modulePath));
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
await Promise.all(markWaiters);
|
|
2040
|
+
d10("identified prod deps:", this.prodDeps);
|
|
2041
|
+
}
|
|
2042
|
+
async findModule(moduleName, fromDir, foundFn) {
|
|
2043
|
+
const testPaths = await searchForModule(fromDir, moduleName, this.projectRootPath);
|
|
2044
|
+
const foundFns = testPaths.map((testPath) => foundFn(testPath));
|
|
2045
|
+
return Promise.all(foundFns);
|
|
2046
|
+
}
|
|
2047
|
+
async markChildrenAsProdDeps(modulePath) {
|
|
2048
|
+
if (!fs11.existsSync(modulePath)) {
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
d10("exploring", modulePath);
|
|
2052
|
+
let childPackageJson;
|
|
2053
|
+
try {
|
|
2054
|
+
childPackageJson = await readPackageJson(modulePath, true);
|
|
2055
|
+
} catch {
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
const moduleWait = [];
|
|
2059
|
+
const callback = this.markChildrenAsProdDeps.bind(this);
|
|
2060
|
+
for (const key of Object.keys(childPackageJson.dependencies || {}).concat(Object.keys(childPackageJson.optionalDependencies || {}))) {
|
|
2061
|
+
if (this.prodDeps.has(key)) {
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
this.prodDeps.add(key);
|
|
2065
|
+
moduleWait.push(this.findModule(key, modulePath, callback));
|
|
2066
|
+
}
|
|
2067
|
+
await Promise.all(moduleWait);
|
|
2068
|
+
}
|
|
2069
|
+
async findAllModulesIn(nodeModulesPath, prefix = "") {
|
|
2070
|
+
const realNodeModulesPath = await fs11.promises.realpath(nodeModulesPath);
|
|
2071
|
+
if (this.realNodeModulesPaths.has(realNodeModulesPath)) {
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
this.realNodeModulesPaths.add(realNodeModulesPath);
|
|
2075
|
+
d10("scanning:", realNodeModulesPath);
|
|
2076
|
+
for (const modulePath of await fs11.promises.readdir(realNodeModulesPath)) {
|
|
2077
|
+
if (modulePath === ".bin")
|
|
2078
|
+
continue;
|
|
2079
|
+
const subPath = path13.resolve(nodeModulesPath, modulePath);
|
|
2080
|
+
let realPath;
|
|
2081
|
+
try {
|
|
2082
|
+
realPath = await fs11.promises.realpath(subPath);
|
|
2083
|
+
} catch (error) {
|
|
2084
|
+
if (error.code === "ENOENT") {
|
|
2085
|
+
const stat = await fs11.promises.lstat(subPath);
|
|
2086
|
+
if (stat.isSymbolicLink()) {
|
|
2087
|
+
continue;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
throw error;
|
|
2091
|
+
}
|
|
2092
|
+
if (this.realModulePaths.has(realPath)) {
|
|
2093
|
+
continue;
|
|
2094
|
+
}
|
|
2095
|
+
this.realModulePaths.add(realPath);
|
|
2096
|
+
const moduleName = `${prefix}${modulePath}`;
|
|
2097
|
+
if (this.prodDeps.has(moduleName) && (!this.onlyModules || this.onlyModules.includes(moduleName))) {
|
|
2098
|
+
this.modulesToRebuild.push(realPath);
|
|
2099
|
+
}
|
|
2100
|
+
if (modulePath.startsWith("@")) {
|
|
2101
|
+
await this.findAllModulesIn(realPath, `${modulePath}/`);
|
|
2102
|
+
}
|
|
2103
|
+
if (fs11.existsSync(path13.resolve(nodeModulesPath, modulePath, "node_modules"))) {
|
|
2104
|
+
await this.findAllModulesIn(path13.resolve(realPath, "node_modules"));
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
});
|
|
2111
|
+
|
|
2112
|
+
// ../../node_modules/@electron/rebuild/lib/rebuild.js
|
|
2113
|
+
import { EventEmitter } from "events";
|
|
2114
|
+
import fs12 from "fs";
|
|
2115
|
+
import os2 from "os";
|
|
2116
|
+
import path14 from "path";
|
|
2117
|
+
function rebuild(options) {
|
|
2118
|
+
d11("rebuilding with args:", arguments);
|
|
2119
|
+
const lifecycle = new EventEmitter();
|
|
2120
|
+
const rebuilderOptions = { ...options, lifecycle };
|
|
2121
|
+
const rebuilder = new Rebuilder(rebuilderOptions);
|
|
2122
|
+
const ret = rebuilder.rebuild();
|
|
2123
|
+
ret.lifecycle = lifecycle;
|
|
2124
|
+
return ret;
|
|
2125
|
+
}
|
|
2126
|
+
var import_debug11, d11, defaultMode, defaultTypes, Rebuilder;
|
|
2127
|
+
var init_rebuild = __esm({
|
|
2128
|
+
"../../node_modules/@electron/rebuild/lib/rebuild.js"() {
|
|
2129
|
+
"use strict";
|
|
2130
|
+
import_debug11 = __toESM(require_src(), 1);
|
|
2131
|
+
init_node_abi();
|
|
2132
|
+
init_cache();
|
|
2133
|
+
init_types();
|
|
2134
|
+
init_module_rebuilder();
|
|
2135
|
+
init_module_walker();
|
|
2136
|
+
d11 = (0, import_debug11.default)("electron-rebuild");
|
|
2137
|
+
defaultMode = "sequential";
|
|
2138
|
+
defaultTypes = ["prod", "optional"];
|
|
2139
|
+
Rebuilder = class {
|
|
2140
|
+
ABIVersion;
|
|
2141
|
+
moduleWalker;
|
|
2142
|
+
rebuilds;
|
|
2143
|
+
lifecycle;
|
|
2144
|
+
buildPath;
|
|
2145
|
+
electronVersion;
|
|
2146
|
+
platform;
|
|
2147
|
+
arch;
|
|
2148
|
+
force;
|
|
2149
|
+
headerURL;
|
|
2150
|
+
mode;
|
|
2151
|
+
debug;
|
|
2152
|
+
useCache;
|
|
2153
|
+
cachePath;
|
|
2154
|
+
prebuildTagPrefix;
|
|
2155
|
+
msvsVersion;
|
|
2156
|
+
useElectronClang;
|
|
2157
|
+
disablePreGypCopy;
|
|
2158
|
+
buildFromSource;
|
|
2159
|
+
ignoreModules;
|
|
2160
|
+
jobs;
|
|
2161
|
+
constructor(options) {
|
|
2162
|
+
this.lifecycle = options.lifecycle;
|
|
2163
|
+
this.buildPath = options.buildPath;
|
|
2164
|
+
this.electronVersion = options.electronVersion;
|
|
2165
|
+
this.platform = options.platform || process.platform;
|
|
2166
|
+
this.arch = options.arch || process.arch;
|
|
2167
|
+
this.force = options.force || false;
|
|
2168
|
+
this.headerURL = options.headerURL || "https://www.electronjs.org/headers";
|
|
2169
|
+
this.mode = options.mode || defaultMode;
|
|
2170
|
+
this.debug = options.debug || false;
|
|
2171
|
+
this.useCache = options.useCache || false;
|
|
2172
|
+
this.useElectronClang = options.useElectronClang || false;
|
|
2173
|
+
this.cachePath = options.cachePath || path14.resolve(os2.homedir(), ".electron-rebuild-cache");
|
|
2174
|
+
this.prebuildTagPrefix = options.prebuildTagPrefix ?? "v";
|
|
2175
|
+
this.msvsVersion = process.env.GYP_MSVS_VERSION;
|
|
2176
|
+
this.disablePreGypCopy = options.disablePreGypCopy || false;
|
|
2177
|
+
this.buildFromSource = options.buildFromSource || false;
|
|
2178
|
+
this.ignoreModules = options.ignoreModules || [];
|
|
2179
|
+
this.jobs = options.jobs;
|
|
2180
|
+
d11("ignoreModules", this.ignoreModules);
|
|
2181
|
+
if (this.useCache && this.force) {
|
|
2182
|
+
console.warn("[WARNING]: Electron Rebuild has force enabled and cache enabled, force take precedence and the cache will not be used.");
|
|
2183
|
+
this.useCache = false;
|
|
2184
|
+
}
|
|
2185
|
+
if (typeof this.electronVersion === "number") {
|
|
2186
|
+
if (`${this.electronVersion}`.split(".").length === 1) {
|
|
2187
|
+
this.electronVersion = `${this.electronVersion}.0.0`;
|
|
2188
|
+
} else {
|
|
2189
|
+
this.electronVersion = `${this.electronVersion}.0`;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
if (typeof this.electronVersion !== "string") {
|
|
2193
|
+
throw new Error(`Expected a string version for electron version, got a "${typeof this.electronVersion}"`);
|
|
2194
|
+
}
|
|
2195
|
+
this.ABIVersion = options.forceABI?.toString();
|
|
2196
|
+
const onlyModules = options.onlyModules || null;
|
|
2197
|
+
const extraModules = new Set(options.extraModules);
|
|
2198
|
+
const types = options.types || defaultTypes;
|
|
2199
|
+
this.moduleWalker = new ModuleWalker(this.buildPath, options.projectRootPath, types, extraModules, onlyModules);
|
|
2200
|
+
this.rebuilds = [];
|
|
2201
|
+
d11("rebuilding with args:", this.buildPath, this.electronVersion, this.platform, this.arch, extraModules, this.force, this.headerURL, types, this.debug);
|
|
2202
|
+
}
|
|
2203
|
+
get ABI() {
|
|
2204
|
+
if (this.ABIVersion === void 0) {
|
|
2205
|
+
this.ABIVersion = getAbi(this.electronVersion, "electron");
|
|
2206
|
+
}
|
|
2207
|
+
return this.ABIVersion;
|
|
2208
|
+
}
|
|
2209
|
+
get buildType() {
|
|
2210
|
+
return this.debug ? BuildType.Debug : BuildType.Release;
|
|
2211
|
+
}
|
|
2212
|
+
async rebuild() {
|
|
2213
|
+
if (!path14.isAbsolute(this.buildPath)) {
|
|
2214
|
+
throw new Error("Expected buildPath to be an absolute path");
|
|
2215
|
+
}
|
|
2216
|
+
this.lifecycle.emit("start");
|
|
2217
|
+
const candidatePaths = [...await this.modulesToRebuild(), this.buildPath];
|
|
2218
|
+
const nativeModulePaths = candidatePaths.filter((p) => fs12.existsSync(path14.resolve(p, "binding.gyp")));
|
|
2219
|
+
this.lifecycle.emit("modules-found", nativeModulePaths.map((p) => {
|
|
2220
|
+
const name = path14.basename(p);
|
|
2221
|
+
const parent = path14.basename(path14.dirname(p));
|
|
2222
|
+
return parent !== "node_modules" ? `${parent}/${name}` : name;
|
|
2223
|
+
}));
|
|
2224
|
+
for (const modulePath of nativeModulePaths) {
|
|
2225
|
+
this.rebuilds.push(() => this.rebuildModuleAt(modulePath));
|
|
2226
|
+
}
|
|
2227
|
+
if (this.mode !== "sequential") {
|
|
2228
|
+
await Promise.all(this.rebuilds.map((fn) => fn()));
|
|
2229
|
+
} else {
|
|
2230
|
+
for (const rebuildFn of this.rebuilds) {
|
|
2231
|
+
await rebuildFn();
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
async modulesToRebuild() {
|
|
2236
|
+
await this.moduleWalker.walkModules();
|
|
2237
|
+
for (const nodeModulesPath of await this.moduleWalker.nodeModulesPaths) {
|
|
2238
|
+
await this.moduleWalker.findAllModulesIn(nodeModulesPath);
|
|
2239
|
+
}
|
|
2240
|
+
return this.moduleWalker.modulesToRebuild;
|
|
2241
|
+
}
|
|
2242
|
+
async rebuildModuleAt(modulePath) {
|
|
2243
|
+
const moduleRebuilder = new ModuleRebuilder(this, modulePath);
|
|
2244
|
+
let moduleName = path14.basename(modulePath);
|
|
2245
|
+
const parentName = path14.basename(path14.dirname(modulePath));
|
|
2246
|
+
if (parentName !== "node_modules") {
|
|
2247
|
+
moduleName = `${parentName}/${moduleName}`;
|
|
2248
|
+
}
|
|
2249
|
+
this.lifecycle.emit("module-found", moduleName);
|
|
2250
|
+
if (!this.force && await moduleRebuilder.alreadyBuiltByRebuild()) {
|
|
2251
|
+
d11(`skipping: ${moduleName} as it is already built`);
|
|
2252
|
+
this.lifecycle.emit("module-done", moduleName);
|
|
2253
|
+
this.lifecycle.emit("module-skip", moduleName);
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
d11("checking", moduleName, "against", this.ignoreModules);
|
|
2257
|
+
if (this.ignoreModules.includes(moduleName)) {
|
|
2258
|
+
d11(`skipping: ${moduleName} as it is in the ignoreModules array`);
|
|
2259
|
+
this.lifecycle.emit("module-done", moduleName);
|
|
2260
|
+
this.lifecycle.emit("module-skip", moduleName);
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
if (await moduleRebuilder.prebuildInstallNativeModuleExists()) {
|
|
2264
|
+
d11(`skipping: ${moduleName} as it was prebuilt`);
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
let cacheKey;
|
|
2268
|
+
if (this.useCache) {
|
|
2269
|
+
cacheKey = await generateCacheKey({
|
|
2270
|
+
ABI: this.ABI,
|
|
2271
|
+
arch: this.arch,
|
|
2272
|
+
platform: this.platform,
|
|
2273
|
+
debug: this.debug,
|
|
2274
|
+
electronVersion: this.electronVersion,
|
|
2275
|
+
headerURL: this.headerURL,
|
|
2276
|
+
modulePath
|
|
2277
|
+
});
|
|
2278
|
+
const applyDiffFn = await lookupModuleState(this.cachePath, cacheKey);
|
|
2279
|
+
if (typeof applyDiffFn === "function") {
|
|
2280
|
+
await applyDiffFn(modulePath);
|
|
2281
|
+
this.lifecycle.emit("module-done", moduleName);
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
if (await moduleRebuilder.rebuild(cacheKey)) {
|
|
2286
|
+
this.lifecycle.emit("module-done", moduleName);
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
|
|
2293
|
+
// ../../node_modules/@electron/rebuild/lib/main.js
|
|
2294
|
+
var init_main = __esm({
|
|
2295
|
+
"../../node_modules/@electron/rebuild/lib/main.js"() {
|
|
2296
|
+
init_rebuild();
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
init_main();
|
|
2300
|
+
export {
|
|
2301
|
+
rebuild
|
|
2302
|
+
};
|