capiumbrowser 1.0.4 → 1.0.5
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/lib/channels.json +4 -4
- package/lib/download.js +46 -8
- package/package.json +1 -1
- package/playwright.js +13 -2
- package/puppeteer.js +13 -2
package/lib/channels.json
CHANGED
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
"stable": {
|
|
7
7
|
"windows-x64": {
|
|
8
8
|
"version": "152.0.7977.82",
|
|
9
|
-
"revision":
|
|
9
|
+
"revision": 4,
|
|
10
10
|
"sha256": "7172b2fdd62cbbfa2619428eca44a2c2fc614b859ce3e51bafef95ad759d4ef0",
|
|
11
11
|
"published": true
|
|
12
12
|
},
|
|
13
13
|
"macos-arm64": {
|
|
14
14
|
"version": "152.0.7977.82",
|
|
15
|
-
"revision":
|
|
15
|
+
"revision": 4,
|
|
16
16
|
"sha256": "4196dcc7687f11390a095b5f3c5aae091a7480306f63cdd9df86ad1267b421d8",
|
|
17
17
|
"published": true
|
|
18
18
|
},
|
|
19
19
|
"linux-x64": {
|
|
20
20
|
"version": "152.0.7977.82",
|
|
21
|
-
"revision":
|
|
22
|
-
"sha256": "
|
|
21
|
+
"revision": 4,
|
|
22
|
+
"sha256": "e4e052da580e300b0097c057445fff3ae865339dd93fd71ec96092dcfb1e7218",
|
|
23
23
|
"published": true
|
|
24
24
|
},
|
|
25
25
|
"linux-arm64": {
|
package/lib/download.js
CHANGED
|
@@ -192,6 +192,38 @@ function stampVersion(binPath, version) {
|
|
|
192
192
|
} catch {}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* The buildId (`<version>` or `<version>-r<N>`) this host SHOULD run, honoring CAPIUM_* env, or
|
|
197
|
+
* null if it can't be determined (CAPIUM_BINARY override / unsupported platform / bad manifest).
|
|
198
|
+
* Lets the launch path detect+reject a stale binary from an earlier install instead of running it.
|
|
199
|
+
*/
|
|
200
|
+
function expectedBuildId() {
|
|
201
|
+
if (process.env.CAPIUM_BINARY) return null;
|
|
202
|
+
try {
|
|
203
|
+
const tag = downloadTag();
|
|
204
|
+
const envVer = process.env.CAPIUM_VERSION;
|
|
205
|
+
const version = envVer || binaryVersionFor(tag);
|
|
206
|
+
let revision;
|
|
207
|
+
if (process.env.CAPIUM_REVISION) revision = parseInt(process.env.CAPIUM_REVISION, 10);
|
|
208
|
+
else if (envVer) revision = 1;
|
|
209
|
+
else revision = binaryRevisionFor(tag);
|
|
210
|
+
return buildId(version, revision);
|
|
211
|
+
} catch {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The launch wrapper inside a just-extracted distro dir, or null (scoped, never a global search). */
|
|
217
|
+
function wrapperIn(distroDir) {
|
|
218
|
+
for (const nm of config._wrapperNames()) {
|
|
219
|
+
const p = path.join(distroDir, nm);
|
|
220
|
+
try {
|
|
221
|
+
if (fs.statSync(p).isFile()) return p;
|
|
222
|
+
} catch {}
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
195
227
|
/**
|
|
196
228
|
* Delete previously-extracted capium distros under `root`. A host only ever holds its own
|
|
197
229
|
* platform's build, so on a version change we drop the stale one before installing the new
|
|
@@ -328,12 +360,13 @@ async function ensureBinary({ version = null, licenseKey = null, server = null }
|
|
|
328
360
|
const subdir = `capium-${String(version).split('.')[0]}-${tag}`; // FLAT-archive wrapper name
|
|
329
361
|
const tmp = path.join(os.tmpdir(),
|
|
330
362
|
`capium-dl-${crypto.randomBytes(6).toString('hex')}.tar.gz`);
|
|
363
|
+
let distroDir = null;
|
|
331
364
|
try {
|
|
332
365
|
await download(url, headers, tmp, version, tag);
|
|
333
366
|
// Only drop the stale install once the new bytes are in hand (a failed download must
|
|
334
367
|
// never leave the host with no binary), then extract the new version.
|
|
335
368
|
removeInstalls(root);
|
|
336
|
-
|
|
369
|
+
distroDir = await extract(tmp, root, subdir);
|
|
337
370
|
// Stamp the version marker BEFORE discovery: the FLAT Windows tar carries no capium
|
|
338
371
|
// marker files, and findBinary only accepts a bare chrome.exe next to one -- the
|
|
339
372
|
// downloader vouches for the directory it just extracted.
|
|
@@ -346,13 +379,17 @@ async function ensureBinary({ version = null, licenseKey = null, server = null }
|
|
|
346
379
|
} catch {}
|
|
347
380
|
}
|
|
348
381
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
382
|
+
// Return the binary we JUST extracted (scoped to distroDir), never a global findBinary here --
|
|
383
|
+
// a stale binary in another base could otherwise be returned instead of the fresh build.
|
|
384
|
+
let binPath = wrapperIn(distroDir);
|
|
385
|
+
if (!binPath) {
|
|
386
|
+
try {
|
|
387
|
+
binPath = config.findBinary();
|
|
388
|
+
} catch {
|
|
389
|
+
throw new CapiumError(
|
|
390
|
+
`downloaded and extracted the ${tag} build but no launch target was found afterwards ` +
|
|
391
|
+
`(unexpected archive layout under ${root}).`);
|
|
392
|
+
}
|
|
356
393
|
}
|
|
357
394
|
stampVersion(binPath, bid); // so a later version/revision bump knows to re-download
|
|
358
395
|
// Re-apply exec bits the wrapper + engine binaries need (zip drops unix perms).
|
|
@@ -372,6 +409,7 @@ module.exports = {
|
|
|
372
409
|
destRoot,
|
|
373
410
|
ensureBinary,
|
|
374
411
|
installedVersion,
|
|
412
|
+
expectedBuildId,
|
|
375
413
|
_SUPPORTED: SUPPORTED,
|
|
376
414
|
_normOs: normOs,
|
|
377
415
|
_normArch: normArch,
|
package/package.json
CHANGED
package/playwright.js
CHANGED
|
@@ -42,12 +42,23 @@ function requireDriver() {
|
|
|
42
42
|
|
|
43
43
|
/** Find the capium wrapper; if absent, try to download it (see lib/download). */
|
|
44
44
|
async function resolveBinary(binary, licenseKey) {
|
|
45
|
+
// Explicit override (arg or CAPIUM_BINARY) wins with no version check -- the caller's choice.
|
|
46
|
+
if (binary || process.env.CAPIUM_BINARY) return config.findBinary(binary);
|
|
47
|
+
// Otherwise the discovered binary must be the CURRENT target build. A stale binary left by an
|
|
48
|
+
// earlier install (older revision -> older device pool / pre-fix fingerprint) must never be
|
|
49
|
+
// launched silently even after `npm i -U` -- it still trips detection. Re-fetch on a mismatch.
|
|
50
|
+
const want = download.expectedBuildId();
|
|
45
51
|
try {
|
|
46
|
-
|
|
52
|
+
const found = config.findBinary();
|
|
53
|
+
const have = download.installedVersion(found);
|
|
54
|
+
if (want === null || have === want) return found;
|
|
55
|
+
process.stderr.write(
|
|
56
|
+
`capium: ignoring stale binary at ${found} (build ${have}; current target ${want}) and ` +
|
|
57
|
+
`fetching the current build. Delete it or set CAPIUM_BINARY to silence this.\n`);
|
|
47
58
|
} catch (e) {
|
|
48
59
|
if (e.code !== 'ENOENT') throw e;
|
|
49
|
-
return download.ensureBinary({ licenseKey });
|
|
50
60
|
}
|
|
61
|
+
return download.ensureBinary({ licenseKey });
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
/**
|
package/puppeteer.js
CHANGED
|
@@ -45,12 +45,23 @@ function requireDriver() {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async function resolveBinary(binary, licenseKey) {
|
|
48
|
+
// Explicit override (arg or CAPIUM_BINARY) wins with no version check -- the caller's choice.
|
|
49
|
+
if (binary || process.env.CAPIUM_BINARY) return config.findBinary(binary);
|
|
50
|
+
// Otherwise the discovered binary must be the CURRENT target build. A stale binary left by an
|
|
51
|
+
// earlier install (older revision -> older device pool / pre-fix fingerprint) must never be
|
|
52
|
+
// launched silently even after `npm i -U` -- it still trips detection. Re-fetch on a mismatch.
|
|
53
|
+
const want = download.expectedBuildId();
|
|
48
54
|
try {
|
|
49
|
-
|
|
55
|
+
const found = config.findBinary();
|
|
56
|
+
const have = download.installedVersion(found);
|
|
57
|
+
if (want === null || have === want) return found;
|
|
58
|
+
process.stderr.write(
|
|
59
|
+
`capium: ignoring stale binary at ${found} (build ${have}; current target ${want}) and ` +
|
|
60
|
+
`fetching the current build. Delete it or set CAPIUM_BINARY to silence this.\n`);
|
|
50
61
|
} catch (e) {
|
|
51
62
|
if (e.code !== 'ENOENT') throw e;
|
|
52
|
-
return download.ensureBinary({ licenseKey });
|
|
53
63
|
}
|
|
64
|
+
return download.ensureBinary({ licenseKey });
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
async function prepare(opts) {
|