camoufox-js 0.9.1 → 0.9.2
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/pkgman.js +27 -18
- package/package.json +6 -5
package/dist/pkgman.js
CHANGED
|
@@ -5,7 +5,8 @@ import * as path from "node:path";
|
|
|
5
5
|
import { setTimeout } from "node:timers/promises";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import AdmZip from "adm-zip";
|
|
8
|
-
import
|
|
8
|
+
import cliProgress from "cli-progress";
|
|
9
|
+
import prettyBytes from "pretty-bytes";
|
|
9
10
|
import { CONSTRAINTS } from "./__version__.js";
|
|
10
11
|
import { CamoufoxNotInstalled, FileNotFoundError, MissingRelease, UnsupportedArchitecture, UnsupportedOS, UnsupportedVersion, } from "./exceptions.js";
|
|
11
12
|
const ARCH_MAP = {
|
|
@@ -25,6 +26,7 @@ if (!(process.platform in OS_MAP)) {
|
|
|
25
26
|
export const OS_NAME = OS_MAP[process.platform];
|
|
26
27
|
const currentDir = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
|
|
27
28
|
export const INSTALL_DIR = userCacheDir("camoufox");
|
|
29
|
+
const formatBytes = (v, _, type) => type === "total" || type === "value" ? prettyBytes(v) : String(v);
|
|
28
30
|
export const LOCAL_DATA = path.join(currentDir, "data-files");
|
|
29
31
|
export const OS_ARCH_MATRIX = {
|
|
30
32
|
win: ["x86_64", "i686"],
|
|
@@ -310,26 +312,33 @@ export async function webdl(url, desc = "", bar = true, buffer = null, { retries
|
|
|
310
312
|
throw new Error(`Failed to download from ${url} after ${retries} attempts`);
|
|
311
313
|
}
|
|
312
314
|
const totalSize = parseInt(response.headers.get("content-length") || "0", 10);
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
315
|
+
let progressBar = null;
|
|
316
|
+
if (bar && totalSize > 0) {
|
|
317
|
+
progressBar = new cliProgress.SingleBar({
|
|
318
|
+
format: `${desc} [{bar}] {percentage}% | ETA: {eta_formatted} | {value}/{total}`,
|
|
319
|
+
formatValue: formatBytes,
|
|
320
|
+
noTTYOutput: true,
|
|
321
|
+
}, cliProgress.Presets.shades_classic);
|
|
322
|
+
progressBar.start(totalSize, 0);
|
|
323
|
+
}
|
|
319
324
|
const chunks = [];
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
buffer
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
progressBar
|
|
325
|
+
try {
|
|
326
|
+
for await (const chunk of response.body) {
|
|
327
|
+
if (buffer) {
|
|
328
|
+
buffer.write(chunk);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
chunks.push(chunk);
|
|
332
|
+
}
|
|
333
|
+
if (progressBar) {
|
|
334
|
+
progressBar.increment(chunk.length);
|
|
335
|
+
}
|
|
329
336
|
}
|
|
330
337
|
}
|
|
331
|
-
|
|
332
|
-
|
|
338
|
+
finally {
|
|
339
|
+
progressBar?.stop();
|
|
340
|
+
}
|
|
341
|
+
return Buffer.concat(chunks);
|
|
333
342
|
}
|
|
334
343
|
export async function unzip(zipFile, extractPath, desc, bar = true) {
|
|
335
344
|
const zip = new AdmZip(zipFile);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camoufox-js",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -32,23 +32,24 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"adm-zip": "^0.5.16",
|
|
34
34
|
"better-sqlite3": "^12.2.0",
|
|
35
|
+
"cli-progress": "^3.12.0",
|
|
35
36
|
"commander": "^14.0.0",
|
|
36
37
|
"fingerprint-generator": "^2.1.66",
|
|
37
38
|
"glob": "^13.0.0",
|
|
38
|
-
"impit": "^0.
|
|
39
|
+
"impit": "^0.11.0",
|
|
39
40
|
"language-tags": "^2.0.1",
|
|
40
41
|
"maxmind": "^5.0.0",
|
|
41
|
-
"
|
|
42
|
+
"pretty-bytes": "^7.1.0",
|
|
42
43
|
"ua-parser-js": "^2.0.2",
|
|
43
44
|
"xml2js": "^0.6.2"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@biomejs/biome": "2.4.
|
|
47
|
+
"@biomejs/biome": "2.4.7",
|
|
47
48
|
"@types/adm-zip": "^0.5.7",
|
|
48
49
|
"@types/better-sqlite3": "^7.6.13",
|
|
50
|
+
"@types/cli-progress": "^3.11.6",
|
|
49
51
|
"@types/language-tags": "^1.0.4",
|
|
50
52
|
"@types/node": "^24.0.0",
|
|
51
|
-
"@types/progress": "^2.0.7",
|
|
52
53
|
"@types/xml2js": "^0.4.14",
|
|
53
54
|
"playwright-core": "^1.53.1",
|
|
54
55
|
"rimraf": "^6.0.1",
|