camoufox-js 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/__main__.js CHANGED
@@ -5,6 +5,7 @@ import { INSTALL_DIR, CamoufoxFetcher, installedVerStr } from './pkgman.js';
5
5
  import { Command } from 'commander';
6
6
  import { Camoufox } from './sync_api.js';
7
7
  import { existsSync, rmSync } from 'fs';
8
+ import { getAsBooleanFromENV } from './utils.js';
8
9
  class CamoufoxUpdate extends CamoufoxFetcher {
9
10
  currentVerStr;
10
11
  constructor() {
@@ -28,13 +29,11 @@ class CamoufoxUpdate extends CamoufoxFetcher {
28
29
  return updater;
29
30
  }
30
31
  isUpdateNeeded() {
31
- if (this.currentVerStr === null) {
32
- return true;
33
- }
34
- if (this.currentVerStr !== this.verstr) {
35
- return true;
32
+ if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD', false)) {
33
+ console.log("Skipping browser download / update check due to PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD set!");
34
+ return false;
36
35
  }
37
- return false;
36
+ return this.currentVerStr === null || this.currentVerStr !== this.verstr;
38
37
  }
39
38
  async update() {
40
39
  if (!this.isUpdateNeeded()) {
package/dist/addons.js CHANGED
@@ -2,6 +2,7 @@ import { InvalidAddonPath } from './exceptions.js';
2
2
  import { getPath, unzip, webdl } from './pkgman.js';
3
3
  import fs from 'fs';
4
4
  import { join } from 'path';
5
+ import { getAsBooleanFromENV } from './utils.js';
5
6
  export const DefaultAddons = {
6
7
  /**
7
8
  * Default addons to be downloaded
@@ -47,6 +48,10 @@ function getAddonPath(addonName) {
47
48
  * Skips downloading if the addon is already downloaded
48
49
  */
49
50
  export function maybeDownloadAddons(addons, addonsList = []) {
51
+ if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD', false)) {
52
+ console.log("Skipping addon download due to PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD set!");
53
+ return;
54
+ }
50
55
  for (const addonName in addons) {
51
56
  const addonPath = getAddonPath(addonName);
52
57
  if (fs.existsSync(addonPath)) {
package/dist/locale.js CHANGED
@@ -7,6 +7,7 @@ import * as fs from 'fs';
7
7
  import * as path from 'path';
8
8
  import maxmind from 'maxmind';
9
9
  import xml2js from 'xml2js';
10
+ import { getAsBooleanFromENV } from './utils.js';
10
11
  export const ALLOW_GEOIP = true;
11
12
  class Locale {
12
13
  language;
@@ -145,6 +146,10 @@ export function geoipAllowed() {
145
146
  }
146
147
  export async function downloadMMDB() {
147
148
  geoipAllowed();
149
+ if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD', false)) {
150
+ console.log("Skipping GeoIP database download due to PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD set!");
151
+ return;
152
+ }
148
153
  const assetUrl = await (new MaxMindDownloader(MMDB_REPO).getAsset());
149
154
  const fileStream = fs.createWriteStream(MMDB_FILE);
150
155
  await webdl(assetUrl, 'Downloading GeoIP database', true, fileStream);
package/dist/utils.d.ts CHANGED
@@ -3,6 +3,7 @@ import { VirtualDisplay } from './virtdisplay.js';
3
3
  import { PathLike } from 'fs';
4
4
  import { Fingerprint, FingerprintGeneratorOptions } from 'fingerprint-generator';
5
5
  type Screen = FingerprintGeneratorOptions['screen'];
6
+ export declare function getAsBooleanFromENV(name: string, defaultValue?: boolean | undefined): boolean;
6
7
  export declare function syncAttachVD(browser: any, virtualDisplay?: VirtualDisplay | null): any;
7
8
  export interface LaunchOptions {
8
9
  /** Operating system to use for the fingerprint generation.
package/dist/utils.js CHANGED
@@ -50,6 +50,14 @@ function getEnvVars(configMap, userAgentOS) {
50
50
  }
51
51
  return envVars;
52
52
  }
53
+ export function getAsBooleanFromENV(name, defaultValue) {
54
+ const value = process.env[name];
55
+ if (value === 'false' || value === '0')
56
+ return false;
57
+ if (value)
58
+ return true;
59
+ return !!defaultValue;
60
+ }
53
61
  function loadProperties(filePath) {
54
62
  let propFile;
55
63
  filePath = filePath?.toString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camoufox-js",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {