camoucore 0.2.0 → 0.6.0
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/LICENSE +4 -3
- package/dist/camoufox/__main__.d.ts +10 -0
- package/dist/camoufox/__main__.js +1175 -0
- package/dist/camoufox/__version__.d.ts +31 -0
- package/dist/camoufox/__version__.js +32 -0
- package/dist/camoufox/_humanize_playwright.d.ts +54 -0
- package/dist/camoufox/_humanize_playwright.js +429 -0
- package/dist/camoufox/addons.d.ts +21 -0
- package/dist/camoufox/addons.js +56 -0
- package/dist/camoufox/async_api.d.ts +9 -0
- package/dist/camoufox/async_api.js +9 -0
- package/dist/camoufox/browser-pin.d.ts +46 -0
- package/dist/camoufox/browser-pin.js +96 -0
- package/dist/camoufox/cli.d.ts +7 -0
- package/dist/camoufox/cli.js +20 -0
- package/dist/camoufox/coherence.d.ts +141 -0
- package/dist/camoufox/coherence.js +708 -0
- package/dist/camoufox/data-files/audio-output-latency.json +15 -0
- package/dist/camoufox/data-files/browser-pin.json +7 -0
- package/dist/camoufox/data-files/display-profiles.json +6 -0
- package/dist/camoufox/data-files/essential-fonts.json +5 -0
- package/dist/camoufox/data-files/fingerprint-presets-v150.json +14544 -0
- package/dist/camoufox/data-files/fingerprint-presets.json +5192 -0
- package/dist/camoufox/data-files/font-bases.json +1888 -0
- package/dist/camoufox/data-files/font-groups.json +716 -0
- package/dist/camoufox/data-files/font-prefs.json +1046 -0
- package/dist/camoufox/data-files/fonts.json +240 -0
- package/dist/camoufox/data-files/fpgen.yml +44 -0
- package/dist/camoufox/data-files/launcher-constants.json +136 -0
- package/dist/camoufox/data-files/media-devices.json +180 -0
- package/dist/camoufox/data-files/repos.yml +40 -0
- package/dist/camoufox/data-files/voice-manifests.json +1864 -0
- package/dist/camoufox/data-files/voice-uris.json +188 -0
- package/dist/camoufox/data-files/warnings.yml +146 -0
- package/dist/camoufox/display_profile.d.ts +21 -0
- package/dist/camoufox/display_profile.js +129 -0
- package/dist/camoufox/driver_defaults.d.ts +27 -0
- package/dist/camoufox/driver_defaults.js +119 -0
- package/dist/camoufox/exceptions.d.ts +68 -0
- package/dist/camoufox/exceptions.js +122 -0
- package/dist/camoufox/fingerprints.d.ts +434 -0
- package/dist/camoufox/fingerprints.js +1936 -0
- package/dist/camoufox/gpudisplay.d.ts +158 -0
- package/dist/camoufox/gpudisplay.js +695 -0
- package/dist/camoufox/host_rendering.d.ts +38 -0
- package/dist/camoufox/host_rendering.js +180 -0
- package/dist/camoufox/humanize.d.ts +89 -0
- package/dist/camoufox/humanize.js +143 -0
- package/dist/camoufox/index.d.ts +21 -0
- package/dist/camoufox/index.js +21 -0
- package/dist/camoufox/ip.d.ts +45 -0
- package/dist/camoufox/ip.js +114 -0
- package/dist/camoufox/multiversion.d.ts +131 -0
- package/dist/camoufox/multiversion.js +490 -0
- package/dist/camoufox/node-floor.d.ts +5 -0
- package/dist/camoufox/node-floor.js +17 -0
- package/dist/camoufox/paths.d.ts +45 -0
- package/dist/camoufox/paths.js +62 -0
- package/dist/camoufox/pkgman.d.ts +361 -0
- package/dist/camoufox/pkgman.js +1066 -0
- package/dist/camoufox/product.d.ts +8 -0
- package/dist/camoufox/product.js +8 -0
- package/dist/camoufox/pycompat.d.ts +97 -0
- package/dist/camoufox/pycompat.js +458 -0
- package/dist/camoufox/server.d.ts +36 -0
- package/dist/camoufox/server.js +82 -0
- package/dist/camoufox/sync_api.d.ts +77 -0
- package/dist/camoufox/sync_api.js +207 -0
- package/dist/camoufox/utils.d.ts +638 -0
- package/dist/camoufox/utils.js +2507 -0
- package/dist/camoufox/warnings.d.ts +16 -0
- package/dist/camoufox/warnings.js +65 -0
- package/dist/camoufox/webgl.d.ts +52 -0
- package/dist/camoufox/webgl.js +264 -0
- package/dist/camouwolf/__main__.d.ts +10 -0
- package/dist/camouwolf/__main__.js +1180 -0
- package/dist/camouwolf/__version__.d.ts +31 -0
- package/dist/camouwolf/__version__.js +32 -0
- package/dist/camouwolf/_humanize_playwright.d.ts +53 -0
- package/dist/camouwolf/_humanize_playwright.js +427 -0
- package/dist/camouwolf/addons.d.ts +42 -0
- package/dist/camouwolf/addons.js +113 -0
- package/dist/camouwolf/async_api.d.ts +9 -0
- package/dist/camouwolf/async_api.js +9 -0
- package/dist/camouwolf/browser-pin.d.ts +46 -0
- package/dist/camouwolf/browser-pin.js +96 -0
- package/dist/camouwolf/cli.d.ts +7 -0
- package/dist/camouwolf/cli.js +20 -0
- package/dist/camouwolf/clienthints.d.ts +61 -0
- package/dist/camouwolf/clienthints.js +176 -0
- package/dist/camouwolf/coherence.d.ts +152 -0
- package/dist/camouwolf/coherence.js +554 -0
- package/dist/camouwolf/data-files/browser-pin.json +7 -0
- package/dist/camouwolf/data-files/camouwolf.defaults.json +118 -0
- package/dist/camouwolf/data-files/data/bundle-fonts.json +1983 -0
- package/dist/camouwolf/data-files/data/chrome-languages.json +517 -0
- package/dist/camouwolf/data-files/data/properties.json +321 -0
- package/dist/camouwolf/data-files/data/system-colors.json +35 -0
- package/dist/camouwolf/data-files/data/ubo.json +6 -0
- package/dist/camouwolf/data-files/fpgen.yml +41 -0
- package/dist/camouwolf/data-files/launcher-constants.json +26 -0
- package/dist/camouwolf/data-files/repos.yml +23 -0
- package/dist/camouwolf/data-files/warnings.yml +96 -0
- package/dist/camouwolf/driver_defaults.d.ts +25 -0
- package/dist/camouwolf/driver_defaults.js +114 -0
- package/dist/camouwolf/exceptions.d.ts +95 -0
- package/dist/camouwolf/exceptions.js +150 -0
- package/dist/camouwolf/fingerprints.d.ts +227 -0
- package/dist/camouwolf/fingerprints.js +753 -0
- package/dist/camouwolf/gpudisplay.d.ts +171 -0
- package/dist/camouwolf/gpudisplay.js +711 -0
- package/dist/camouwolf/host_rendering.d.ts +18 -0
- package/dist/camouwolf/host_rendering.js +114 -0
- package/dist/camouwolf/humanize.d.ts +84 -0
- package/dist/camouwolf/humanize.js +128 -0
- package/dist/camouwolf/index.d.ts +22 -0
- package/dist/camouwolf/index.js +21 -0
- package/dist/camouwolf/multiversion.d.ts +131 -0
- package/dist/camouwolf/multiversion.js +491 -0
- package/dist/camouwolf/node-floor.d.ts +5 -0
- package/dist/camouwolf/node-floor.js +17 -0
- package/dist/camouwolf/paths.d.ts +34 -0
- package/dist/camouwolf/paths.js +58 -0
- package/dist/camouwolf/pkgman.d.ts +331 -0
- package/dist/camouwolf/pkgman.js +972 -0
- package/dist/camouwolf/product.d.ts +3 -0
- package/dist/camouwolf/product.js +3 -0
- package/dist/camouwolf/pycompat.d.ts +92 -0
- package/dist/camouwolf/pycompat.js +461 -0
- package/dist/camouwolf/server.d.ts +36 -0
- package/dist/camouwolf/server.js +81 -0
- package/dist/camouwolf/switches.d.ts +77 -0
- package/dist/camouwolf/switches.js +222 -0
- package/dist/camouwolf/sync_api.d.ts +84 -0
- package/dist/camouwolf/sync_api.js +173 -0
- package/dist/camouwolf/utils.d.ts +644 -0
- package/dist/camouwolf/utils.js +2057 -0
- package/dist/camouwolf/warnings.d.ts +14 -0
- package/dist/camouwolf/warnings.js +59 -0
- package/dist/camouwolf/webgl.d.ts +41 -0
- package/dist/camouwolf/webgl.js +198 -0
- package/dist/data-files/antibot-rules.json +146 -0
- package/dist/data.d.ts +1 -1
- package/dist/data.js +4 -3
- package/dist/download.js +1 -1
- package/dist/exceptions.d.ts +1 -1
- package/dist/exceptions.js +1 -1
- package/dist/geolocation.js +1 -1
- package/dist/host.d.ts +2 -0
- package/dist/host.js +17 -1
- package/dist/ip.js +1 -1
- package/dist/locales.js +1 -1
- package/dist/mcp/cli.d.ts +15 -0
- package/dist/mcp/cli.js +108 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/main.d.ts +2 -0
- package/dist/mcp/main.js +8 -0
- package/dist/mcp/secrets.d.ts +50 -0
- package/dist/mcp/secrets.js +193 -0
- package/dist/mcp/server.d.ts +48 -0
- package/dist/mcp/server.js +653 -0
- package/dist/mcp/tree.d.ts +10 -0
- package/dist/mcp/tree.js +36 -0
- package/dist/passthrough.d.ts +16 -0
- package/dist/passthrough.js +50 -0
- package/dist/product.js +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +95 -0
- package/dist/telemetry.d.ts +127 -0
- package/dist/telemetry.js +426 -0
- package/dist/virtdisplay.d.ts +1 -1
- package/dist/virtdisplay.js +1 -1
- package/dist/warnings.js +1 -1
- package/package.json +57 -13
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A GPU as WEBGL_debug_renderer_info reports it: [vendor, renderer]. */
|
|
2
|
+
export type Gpu = [string, string];
|
|
3
|
+
/**
|
|
4
|
+
* A display that accepts TCP but never completes the X handshake leaves the
|
|
5
|
+
* browser's launch waiting forever; the probe is given this long.
|
|
6
|
+
*/
|
|
7
|
+
export declare const HOST_GPU_PROBE_TIMEOUT_MS = 30000;
|
|
8
|
+
/**
|
|
9
|
+
* The [vendor, renderer] the browser reports on this machine with no identity
|
|
10
|
+
* applied, or null without WebGL.
|
|
11
|
+
*
|
|
12
|
+
* Read under the given display and switches: headless, Xvfb, a GPU display and
|
|
13
|
+
* a real display can each render on a different device, and so can a launch
|
|
14
|
+
* with gpudisplay.GPU_SWITCHES. The strings are ANGLE's.
|
|
15
|
+
*/
|
|
16
|
+
export declare function hostGpu(executablePath: string, headless: boolean, env: Record<string, string | number | boolean | undefined>, args?: readonly string[]): Promise<Gpu | null>;
|
|
17
|
+
/** Whether the host's canvas and WebGL come from a GPU, not a software rasterizer. */
|
|
18
|
+
export declare function rendersOnHardware(gpu: Gpu | null): gpu is Gpu;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this machine's own GPU reports through the browser.
|
|
3
|
+
*
|
|
4
|
+
* A library probe, not part of the launch: Camouwolf's identity names its GPU
|
|
5
|
+
* in webGl:vendor / webGl:renderer, which the browser reports whatever the
|
|
6
|
+
* host renders on, so a launch never needs to know the host's device. The
|
|
7
|
+
* probe answers the question a caller choosing between headless modes has:
|
|
8
|
+
* does this display render on hardware, or on SwiftShader?
|
|
9
|
+
*
|
|
10
|
+
* import { hostGpu, rendersOnHardware } from "camouwolf";
|
|
11
|
+
* const gpu = await hostGpu(executablePath, true, process.env, []);
|
|
12
|
+
*
|
|
13
|
+
* TypeScript twin of python/camoucore/src/camoucore/camouwolf/host_rendering.py. Python runs the
|
|
14
|
+
* probe in a child interpreter (its sync API cannot start inside a running
|
|
15
|
+
* loop); Node has no such limit, so the probe runs in-process under the same
|
|
16
|
+
* deadline.
|
|
17
|
+
*/
|
|
18
|
+
import { chromium } from "playwright-core";
|
|
19
|
+
import { isSoftwareRenderer } from "./fingerprints.js";
|
|
20
|
+
// What the launcher adds to the environment, which the probe leaves out: it
|
|
21
|
+
// reads the device, not an identity's claim about it.
|
|
22
|
+
const LAUNCHER_ENV = ["CAMOU_", "CAMOUWOLF_UCRT_MATH", "FONTCONFIG_FILE"];
|
|
23
|
+
/**
|
|
24
|
+
* A display that accepts TCP but never completes the X handshake leaves the
|
|
25
|
+
* browser's launch waiting forever; the probe is given this long.
|
|
26
|
+
*/
|
|
27
|
+
export const HOST_GPU_PROBE_TIMEOUT_MS = 30_000;
|
|
28
|
+
const HOST_GPU_CLOSE_TIMEOUT_MS = 1_000;
|
|
29
|
+
const probes = new Map();
|
|
30
|
+
function within(promise, timeoutMs, message) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
33
|
+
timer.unref();
|
|
34
|
+
promise.then((value) => {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
resolve(value);
|
|
37
|
+
}, (error) => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
reject(error);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The [vendor, renderer] the browser reports on this machine with no identity
|
|
45
|
+
* applied, or null without WebGL.
|
|
46
|
+
*
|
|
47
|
+
* Read under the given display and switches: headless, Xvfb, a GPU display and
|
|
48
|
+
* a real display can each render on a different device, and so can a launch
|
|
49
|
+
* with gpudisplay.GPU_SWITCHES. The strings are ANGLE's.
|
|
50
|
+
*/
|
|
51
|
+
export function hostGpu(executablePath, headless, env, args = []) {
|
|
52
|
+
const hostEnv = Object.entries(env)
|
|
53
|
+
.filter(([key, value]) => value !== undefined &&
|
|
54
|
+
!LAUNCHER_ENV.some((prefix) => key.startsWith(prefix)))
|
|
55
|
+
.map(([key, value]) => [key, String(value)])
|
|
56
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
57
|
+
const key = JSON.stringify([executablePath, headless, hostEnv, args]);
|
|
58
|
+
let gpu = probes.get(key);
|
|
59
|
+
if (!gpu) {
|
|
60
|
+
gpu = readHostGpu(executablePath, headless, Object.fromEntries(hostEnv), [
|
|
61
|
+
...args,
|
|
62
|
+
]);
|
|
63
|
+
// Remember a reading, not a failure: the next call tries again.
|
|
64
|
+
gpu.catch(() => probes.delete(key));
|
|
65
|
+
probes.set(key, gpu);
|
|
66
|
+
}
|
|
67
|
+
return gpu;
|
|
68
|
+
}
|
|
69
|
+
/** Launch the binary once and read its WebGL vendor and renderer. */
|
|
70
|
+
async function readHostGpu(executablePath, headless, env, args) {
|
|
71
|
+
const deadline = Date.now() + HOST_GPU_PROBE_TIMEOUT_MS;
|
|
72
|
+
const display = env.DISPLAY ? ` (DISPLAY=${env.DISPLAY})` : "";
|
|
73
|
+
const timeoutMessage = `Host GPU probe timed out after ${HOST_GPU_PROBE_TIMEOUT_MS / 1000} s ` +
|
|
74
|
+
`while launching ${executablePath}${display}. The browser did not ` +
|
|
75
|
+
"answer the WebGL probe; check that the display accepts X connections.";
|
|
76
|
+
const remaining = () => Math.max(1, deadline - Date.now());
|
|
77
|
+
let browser;
|
|
78
|
+
try {
|
|
79
|
+
browser = await within(chromium.launch({
|
|
80
|
+
executablePath,
|
|
81
|
+
headless,
|
|
82
|
+
env,
|
|
83
|
+
args,
|
|
84
|
+
timeout: remaining(),
|
|
85
|
+
}), remaining(), timeoutMessage);
|
|
86
|
+
const page = await within(browser.newPage(), remaining(), timeoutMessage);
|
|
87
|
+
return await within(page.evaluate(() => {
|
|
88
|
+
const gl = globalThis.document
|
|
89
|
+
.createElement("canvas")
|
|
90
|
+
.getContext("webgl");
|
|
91
|
+
const ext = gl?.getExtension("WEBGL_debug_renderer_info");
|
|
92
|
+
if (!ext)
|
|
93
|
+
return null;
|
|
94
|
+
return [
|
|
95
|
+
gl.getParameter(ext.UNMASKED_VENDOR_WEBGL),
|
|
96
|
+
gl.getParameter(ext.UNMASKED_RENDERER_WEBGL),
|
|
97
|
+
];
|
|
98
|
+
}), remaining(), timeoutMessage);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (error instanceof Error && error.message === timeoutMessage)
|
|
102
|
+
throw error;
|
|
103
|
+
throw new Error(`Host GPU probe failed while launching ${executablePath}:\n${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
if (browser) {
|
|
107
|
+
await within(browser.close(), HOST_GPU_CLOSE_TIMEOUT_MS, "close timed out").catch(() => { });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Whether the host's canvas and WebGL come from a GPU, not a software rasterizer. */
|
|
112
|
+
export function rendersOnHardware(gpu) {
|
|
113
|
+
return gpu !== null && !isSoftwareRenderer(gpu[1]);
|
|
114
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-channel humanized input, run by the driver, never by the browser.
|
|
3
|
+
* The TypeScript twin of python/camoucore/src/camoucore/camouwolf/humanize.py.
|
|
4
|
+
*
|
|
5
|
+
* import { Camouwolf, myuri, raw } from "camouwolf";
|
|
6
|
+
*
|
|
7
|
+
* await Camouwolf({ humanize: true }); // myuri on every channel
|
|
8
|
+
* await Camouwolf({
|
|
9
|
+
* humanize: {
|
|
10
|
+
* mouse: myuri({ move: myMove }),
|
|
11
|
+
* keyboard: myuri({ wpm: 70 }),
|
|
12
|
+
* scroll: raw(),
|
|
13
|
+
* seed: 1234,
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* The browser has no humanization of its own: each Playwright input call
|
|
18
|
+
* reaches the page as the one native-looking event it asks for, when it is
|
|
19
|
+
* sent (docs/input-dispatch.md). A channel (mouse, keyboard, scroll) is one of
|
|
20
|
+
*
|
|
21
|
+
* myuri() myuri's smart actions (https://github.com/JWriter20/Myuri):
|
|
22
|
+
* paths, clicks, typing and wheel turns as the people it was
|
|
23
|
+
* fitted to make them on the identity's OS, and the decisions
|
|
24
|
+
* around a click (scroll into view, the point, whether it lands)
|
|
25
|
+
* raw() Playwright's own calls, unchanged
|
|
26
|
+
*
|
|
27
|
+
* cursory() is another name for myuri(), which runs cursory's paths.
|
|
28
|
+
*
|
|
29
|
+
* `myuri(parts)` replaces any of myuri's parts on its channel with a function
|
|
30
|
+
* of yours; the rest stay myuri's (_humanize_playwright.ts). `humanize` may be
|
|
31
|
+
* null / false (every channel raw), true (every channel myuri), or an object
|
|
32
|
+
* per channel plus an optional `seed`; an omitted channel is myuri. Nothing
|
|
33
|
+
* about it reaches the browser's config.
|
|
34
|
+
*/
|
|
35
|
+
import type { BoundingBox, PartContext, Vector } from "@jwriter20/myuri";
|
|
36
|
+
export declare const CHANNELS: readonly ["mouse", "keyboard", "scroll"];
|
|
37
|
+
export type Channel = (typeof CHANNELS)[number];
|
|
38
|
+
/** The myuri parts each channel's myuri() may replace (myuri's PARTS). */
|
|
39
|
+
export declare const CHANNEL_PARTS: Record<Channel, readonly string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* What myuri() takes: functions that replace myuri's parts, each called with
|
|
42
|
+
* the page, the part's arguments and `{ default, rng, play }`, and `wpm` for
|
|
43
|
+
* the keyboard.
|
|
44
|
+
*/
|
|
45
|
+
export interface MyuriOptions {
|
|
46
|
+
move?: (page: any, x: number, y: number, ctx: PartContext<void>) => unknown;
|
|
47
|
+
press?: (page: any, button: "left" | "right" | "middle", clickCount: number, ctx: PartContext<void>) => unknown;
|
|
48
|
+
point?: (page: any, box: BoundingBox, attempt: number, ctx: PartContext<Vector>) => Vector | Promise<Vector>;
|
|
49
|
+
reaches?: (page: any, locator: any, x: number, y: number, pressing: boolean, ctx: PartContext<string | null>) => string | null | Promise<string | null>;
|
|
50
|
+
intoView?: (page: any, locator: any, ctx: PartContext<void>) => unknown;
|
|
51
|
+
wheel?: (page: any, dx: number, dy: number, ctx: PartContext<void>) => unknown;
|
|
52
|
+
type?: (page: any, text: string, ctx: PartContext<void>) => unknown;
|
|
53
|
+
key?: (page: any, key: string, ctx: PartContext<void>) => unknown;
|
|
54
|
+
wpm?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface Engine {
|
|
57
|
+
engine: "raw" | "myuri";
|
|
58
|
+
options: MyuriOptions;
|
|
59
|
+
}
|
|
60
|
+
export type HumanizeSetting = boolean | Record<string, unknown> | null | undefined;
|
|
61
|
+
/** Playwright's own dispatch, byte for byte. */
|
|
62
|
+
export declare function raw(): Engine;
|
|
63
|
+
/**
|
|
64
|
+
* myuri's smart actions on the channel. Each key names a part to replace with
|
|
65
|
+
* your function, called as `fn(page, ...args, { default, rng, play })`:
|
|
66
|
+
*
|
|
67
|
+
* mouse move(x, y) press(button, clickCount) point(box, attempt)
|
|
68
|
+
* reaches(locator, x, y, pressing)
|
|
69
|
+
* keyboard type(text) key(key)
|
|
70
|
+
* scroll intoView(locator) wheel(dx, dy)
|
|
71
|
+
*
|
|
72
|
+
* `default(...args)` runs myuri's part (with the same arguments when given
|
|
73
|
+
* none), `rng()` draws from the humanize seed's stream, and `play(steps)`
|
|
74
|
+
* plays a timeline of input. `wpm` (keyboard) sets myuri's typing speed.
|
|
75
|
+
*/
|
|
76
|
+
export declare function myuri(options?: MyuriOptions): Engine;
|
|
77
|
+
export declare const cursory: typeof myuri;
|
|
78
|
+
/** The engine per channel of a `humanize` setting, and the seed if given. */
|
|
79
|
+
export declare function normalize(humanize: unknown): {
|
|
80
|
+
engines: Record<Channel, Engine>;
|
|
81
|
+
seed?: number;
|
|
82
|
+
};
|
|
83
|
+
/** The channels of a `humanize` setting that an engine in this process drives. */
|
|
84
|
+
export declare function drivenChannels(humanize: unknown): Channel[];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-channel humanized input, run by the driver, never by the browser.
|
|
3
|
+
* The TypeScript twin of python/camoucore/src/camoucore/camouwolf/humanize.py.
|
|
4
|
+
*
|
|
5
|
+
* import { Camouwolf, myuri, raw } from "camouwolf";
|
|
6
|
+
*
|
|
7
|
+
* await Camouwolf({ humanize: true }); // myuri on every channel
|
|
8
|
+
* await Camouwolf({
|
|
9
|
+
* humanize: {
|
|
10
|
+
* mouse: myuri({ move: myMove }),
|
|
11
|
+
* keyboard: myuri({ wpm: 70 }),
|
|
12
|
+
* scroll: raw(),
|
|
13
|
+
* seed: 1234,
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* The browser has no humanization of its own: each Playwright input call
|
|
18
|
+
* reaches the page as the one native-looking event it asks for, when it is
|
|
19
|
+
* sent (docs/input-dispatch.md). A channel (mouse, keyboard, scroll) is one of
|
|
20
|
+
*
|
|
21
|
+
* myuri() myuri's smart actions (https://github.com/JWriter20/Myuri):
|
|
22
|
+
* paths, clicks, typing and wheel turns as the people it was
|
|
23
|
+
* fitted to make them on the identity's OS, and the decisions
|
|
24
|
+
* around a click (scroll into view, the point, whether it lands)
|
|
25
|
+
* raw() Playwright's own calls, unchanged
|
|
26
|
+
*
|
|
27
|
+
* cursory() is another name for myuri(), which runs cursory's paths.
|
|
28
|
+
*
|
|
29
|
+
* `myuri(parts)` replaces any of myuri's parts on its channel with a function
|
|
30
|
+
* of yours; the rest stay myuri's (_humanize_playwright.ts). `humanize` may be
|
|
31
|
+
* null / false (every channel raw), true (every channel myuri), or an object
|
|
32
|
+
* per channel plus an optional `seed`; an omitted channel is myuri. Nothing
|
|
33
|
+
* about it reaches the browser's config.
|
|
34
|
+
*/
|
|
35
|
+
import { pyRepr, ValueError } from "./pycompat.js";
|
|
36
|
+
export const CHANNELS = ["mouse", "keyboard", "scroll"];
|
|
37
|
+
/** The myuri parts each channel's myuri() may replace (myuri's PARTS). */
|
|
38
|
+
export const CHANNEL_PARTS = {
|
|
39
|
+
mouse: ["move", "press", "point", "reaches"],
|
|
40
|
+
keyboard: ["type", "key"],
|
|
41
|
+
scroll: ["intoView", "wheel"],
|
|
42
|
+
};
|
|
43
|
+
/** Playwright's own dispatch, byte for byte. */
|
|
44
|
+
export function raw() {
|
|
45
|
+
return { engine: "raw", options: {} };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* myuri's smart actions on the channel. Each key names a part to replace with
|
|
49
|
+
* your function, called as `fn(page, ...args, { default, rng, play })`:
|
|
50
|
+
*
|
|
51
|
+
* mouse move(x, y) press(button, clickCount) point(box, attempt)
|
|
52
|
+
* reaches(locator, x, y, pressing)
|
|
53
|
+
* keyboard type(text) key(key)
|
|
54
|
+
* scroll intoView(locator) wheel(dx, dy)
|
|
55
|
+
*
|
|
56
|
+
* `default(...args)` runs myuri's part (with the same arguments when given
|
|
57
|
+
* none), `rng()` draws from the humanize seed's stream, and `play(steps)`
|
|
58
|
+
* plays a timeline of input. `wpm` (keyboard) sets myuri's typing speed.
|
|
59
|
+
*/
|
|
60
|
+
export function myuri(options = {}) {
|
|
61
|
+
const parts = Object.values(CHANNEL_PARTS).flat();
|
|
62
|
+
const unknown = Object.keys(options)
|
|
63
|
+
.filter((key) => key !== "wpm" && !parts.includes(key))
|
|
64
|
+
.sort();
|
|
65
|
+
if (unknown.length)
|
|
66
|
+
throw new ValueError(`myuri() has no part '${unknown[0]}'; the parts are ${JSON.stringify(CHANNEL_PARTS)}, and wpm`);
|
|
67
|
+
for (const [name, fn] of Object.entries(options))
|
|
68
|
+
if (name !== "wpm" && typeof fn !== "function")
|
|
69
|
+
throw new ValueError(`myuri({ ${name} }) takes the function that replaces the part, got ${pyRepr(fn)}`);
|
|
70
|
+
return { engine: "myuri", options: { ...options } };
|
|
71
|
+
}
|
|
72
|
+
export const cursory = myuri;
|
|
73
|
+
const IN_BROWSER = "the browser does not humanize input: each Playwright call is one event. " +
|
|
74
|
+
"Pass True, or myuri() or raw() per channel (camouwolf.humanize)";
|
|
75
|
+
function asEngine(channel, value) {
|
|
76
|
+
const entry = value;
|
|
77
|
+
if (typeof entry !== "object" ||
|
|
78
|
+
!["myuri", "cursory", "raw"].includes(entry?.engine))
|
|
79
|
+
throw new ValueError(`humanize["${channel}"]=${pyRepr(value)} is not an engine; ${IN_BROWSER}`);
|
|
80
|
+
const options = entry?.options ?? {};
|
|
81
|
+
if (entry?.engine === "raw") {
|
|
82
|
+
if (Object.keys(options).length)
|
|
83
|
+
throw new ValueError(`humanize["${channel}"]: raw() takes no options`);
|
|
84
|
+
return raw();
|
|
85
|
+
}
|
|
86
|
+
const engine = myuri(options);
|
|
87
|
+
const allowed = [
|
|
88
|
+
...CHANNEL_PARTS[channel],
|
|
89
|
+
...(channel === "keyboard" ? ["wpm"] : []),
|
|
90
|
+
];
|
|
91
|
+
const misplaced = Object.keys(options)
|
|
92
|
+
.filter((key) => !allowed.includes(key))
|
|
93
|
+
.sort();
|
|
94
|
+
if (misplaced.length)
|
|
95
|
+
throw new ValueError(`humanize["${channel}"]: myuri({ ${misplaced[0]} }) is not a ${channel} part; ` +
|
|
96
|
+
`the ${channel} parts are ${allowed.join(", ")}`);
|
|
97
|
+
return engine;
|
|
98
|
+
}
|
|
99
|
+
/** The engine per channel of a `humanize` setting, and the seed if given. */
|
|
100
|
+
export function normalize(humanize) {
|
|
101
|
+
const every = (engine) => ({
|
|
102
|
+
engines: Object.fromEntries(CHANNELS.map((c) => [c, engine()])),
|
|
103
|
+
});
|
|
104
|
+
if (humanize === null || humanize === undefined || humanize === false)
|
|
105
|
+
return every(raw);
|
|
106
|
+
if (humanize === true)
|
|
107
|
+
return every(myuri);
|
|
108
|
+
if (typeof humanize !== "object" || Array.isArray(humanize))
|
|
109
|
+
throw new ValueError(`humanize=${pyRepr(humanize)}: ${IN_BROWSER}`);
|
|
110
|
+
const setting = humanize;
|
|
111
|
+
const unknown = Object.keys(setting).filter((key) => !CHANNELS.includes(key) && key !== "seed");
|
|
112
|
+
if (unknown.length)
|
|
113
|
+
throw new ValueError(`humanize has no channel ${JSON.stringify(unknown)}; the channels are ${CHANNELS.join(", ")} and "seed"`);
|
|
114
|
+
const seed = (setting.seed ?? undefined);
|
|
115
|
+
if (seed !== undefined &&
|
|
116
|
+
(!Number.isInteger(seed) || seed < 0 || seed >= 2 ** 32))
|
|
117
|
+
throw new ValueError(`humanize.seed must be an integer in [0, 2**32), got ${String(seed)}`);
|
|
118
|
+
const engines = Object.fromEntries(CHANNELS.map((c) => [
|
|
119
|
+
c,
|
|
120
|
+
asEngine(c, setting[c] === undefined ? myuri() : setting[c]),
|
|
121
|
+
]));
|
|
122
|
+
return { engines, seed };
|
|
123
|
+
}
|
|
124
|
+
/** The channels of a `humanize` setting that an engine in this process drives. */
|
|
125
|
+
export function drivenChannels(humanize) {
|
|
126
|
+
const { engines } = normalize(humanize);
|
|
127
|
+
return CHANNELS.filter((c) => engines[c].engine !== "raw");
|
|
128
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API. Mirrors python/camoucore/src/camoucore/camouwolf/__init__.py (Camouwolf, NewBrowser,
|
|
3
|
+
* NewContext, their Async* twins, DefaultAddons, launch_options), plus the
|
|
4
|
+
* package-management and server helpers the TS port has always exported.
|
|
5
|
+
*/
|
|
6
|
+
import "./node-floor.js";
|
|
7
|
+
export { VirtualDisplay } from "../virtdisplay.js";
|
|
8
|
+
export { attach } from "./_humanize_playwright.js";
|
|
9
|
+
export type { DefaultAddon } from "./addons.js";
|
|
10
|
+
export { DefaultAddons } from "./addons.js";
|
|
11
|
+
export { AsyncCamouwolf, AsyncNewBrowser, AsyncNewContext, } from "./async_api.js";
|
|
12
|
+
export * from "./exceptions.js";
|
|
13
|
+
export { Screen } from "./fingerprints.js";
|
|
14
|
+
export { cursory, type HumanizeSetting, type MyuriOptions, myuri, raw, } from "./humanize.js";
|
|
15
|
+
export { findInstalledVersion, listInstalled, printTree, } from "./multiversion.js";
|
|
16
|
+
export { INSTALL_DIR, OS_NAME } from "./paths.js";
|
|
17
|
+
export { CamouwolfFetcher, installedVerStr, RepoConfig } from "./pkgman.js";
|
|
18
|
+
export { PRODUCT } from "./product.js";
|
|
19
|
+
export { type LaunchServerOptions, launchServer } from "./server.js";
|
|
20
|
+
export { Camouwolf, type Headless, NewBrowser, type NewBrowserOptions, NewContext, type NewContextOptions, } from "./sync_api.js";
|
|
21
|
+
export { type LaunchOptions, launchOptions, launchOptions as launch_options, } from "./utils.js";
|
|
22
|
+
export { FallbackWarning, LeakWarning } from "./warnings.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API. Mirrors python/camoucore/src/camoucore/camouwolf/__init__.py (Camouwolf, NewBrowser,
|
|
3
|
+
* NewContext, their Async* twins, DefaultAddons, launch_options), plus the
|
|
4
|
+
* package-management and server helpers the TS port has always exported.
|
|
5
|
+
*/
|
|
6
|
+
import "./node-floor.js";
|
|
7
|
+
export { VirtualDisplay } from "../virtdisplay.js";
|
|
8
|
+
export { attach } from "./_humanize_playwright.js";
|
|
9
|
+
export { DefaultAddons } from "./addons.js";
|
|
10
|
+
export { AsyncCamouwolf, AsyncNewBrowser, AsyncNewContext, } from "./async_api.js";
|
|
11
|
+
export * from "./exceptions.js";
|
|
12
|
+
export { Screen } from "./fingerprints.js";
|
|
13
|
+
export { cursory, myuri, raw, } from "./humanize.js";
|
|
14
|
+
export { findInstalledVersion, listInstalled, printTree, } from "./multiversion.js";
|
|
15
|
+
export { INSTALL_DIR, OS_NAME } from "./paths.js";
|
|
16
|
+
export { CamouwolfFetcher, installedVerStr, RepoConfig } from "./pkgman.js";
|
|
17
|
+
export { PRODUCT } from "./product.js";
|
|
18
|
+
export { launchServer } from "./server.js";
|
|
19
|
+
export { Camouwolf, NewBrowser, NewContext, } from "./sync_api.js";
|
|
20
|
+
export { launchOptions, launchOptions as launch_options, } from "./utils.js";
|
|
21
|
+
export { FallbackWarning, LeakWarning } from "./warnings.js";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type AvailableVersion, type CamouwolfFetcher, Version } from "./pkgman.js";
|
|
2
|
+
export declare const BROWSERS_DIR: string;
|
|
3
|
+
export declare const CONFIG_FILE: string;
|
|
4
|
+
export declare const REPO_CACHE_FILE: string;
|
|
5
|
+
export declare const COMPAT_FLAG: string;
|
|
6
|
+
export interface CamouwolfConfig {
|
|
7
|
+
active_version?: string | null;
|
|
8
|
+
channel?: string;
|
|
9
|
+
pinned?: string;
|
|
10
|
+
pinned_sha?: string;
|
|
11
|
+
geoip?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load user config from disk, or return an empty object.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadConfig(): CamouwolfConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Get the default repo's stable channel string (like official/stable).
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDefaultChannel(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Save user config to disk.
|
|
24
|
+
*/
|
|
25
|
+
export declare function saveConfig(config: CamouwolfConfig): void;
|
|
26
|
+
export interface CachedVersion {
|
|
27
|
+
version: string;
|
|
28
|
+
build: string;
|
|
29
|
+
url: string;
|
|
30
|
+
is_prerelease?: boolean;
|
|
31
|
+
asset_id?: number;
|
|
32
|
+
asset_size?: number;
|
|
33
|
+
asset_updated_at?: string;
|
|
34
|
+
sha256?: string;
|
|
35
|
+
created_at?: string;
|
|
36
|
+
interface?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface RepoCache {
|
|
39
|
+
repos?: Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
versions?: CachedVersion[];
|
|
42
|
+
}>;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load cached repo data from disk.
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadRepoCache(): RepoCache;
|
|
49
|
+
/**
|
|
50
|
+
* Save repo cache to disk.
|
|
51
|
+
*/
|
|
52
|
+
export declare function saveRepoCache(cache: RepoCache): void;
|
|
53
|
+
/**
|
|
54
|
+
* Keep one cache entry per version-build, the newest by created_at.
|
|
55
|
+
*/
|
|
56
|
+
export declare function latestPerBuild(versions: CachedVersion[]): CachedVersion[];
|
|
57
|
+
/**
|
|
58
|
+
* Information about an installed Camouwolf version.
|
|
59
|
+
*/
|
|
60
|
+
export declare class InstalledVersion {
|
|
61
|
+
repoName: string;
|
|
62
|
+
version: Version;
|
|
63
|
+
path: string;
|
|
64
|
+
isActive: boolean;
|
|
65
|
+
isPrerelease: boolean;
|
|
66
|
+
assetId?: number;
|
|
67
|
+
assetSize?: number;
|
|
68
|
+
assetUpdatedAt?: string;
|
|
69
|
+
sha256?: string;
|
|
70
|
+
createdAt?: string;
|
|
71
|
+
constructor(init: {
|
|
72
|
+
repoName: string;
|
|
73
|
+
version: Version;
|
|
74
|
+
path: string;
|
|
75
|
+
isActive?: boolean;
|
|
76
|
+
isPrerelease?: boolean;
|
|
77
|
+
assetId?: number;
|
|
78
|
+
assetSize?: number;
|
|
79
|
+
assetUpdatedAt?: string;
|
|
80
|
+
sha256?: string;
|
|
81
|
+
createdAt?: string;
|
|
82
|
+
});
|
|
83
|
+
/** Folder name, e.g. 150.0.2-beta.25-8020db3b. */
|
|
84
|
+
get folderName(): string;
|
|
85
|
+
/** Path relative to INSTALL_DIR, e.g. browsers/official/150.0.2-beta.25. */
|
|
86
|
+
get relativePath(): string;
|
|
87
|
+
/** Channel display string (like official/stable/134.0.2-beta.20). */
|
|
88
|
+
get channelPath(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Compare with an available version and return change indicators.
|
|
91
|
+
*/
|
|
92
|
+
getChanges(available: AvailableVersion): string[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The install folder for a catalog item: version-build-sha8/, else a legacy
|
|
96
|
+
* version-build/ when its sha matches or `count` says the item is unambiguous.
|
|
97
|
+
*/
|
|
98
|
+
export declare function findInstall(versionBuild: string, sha256: string | undefined, installed: InstalledVersion[], count?: number): InstalledVersion | null;
|
|
99
|
+
/**
|
|
100
|
+
* Scan browsers/ for installed versions, sorted by repo then version descending.
|
|
101
|
+
*/
|
|
102
|
+
export declare function listInstalled(): InstalledVersion[];
|
|
103
|
+
/**
|
|
104
|
+
* Get the path to the active version, or null if no version is active.
|
|
105
|
+
*/
|
|
106
|
+
export declare function getActivePath(): string | null;
|
|
107
|
+
/**
|
|
108
|
+
* Set the active version by its relative path.
|
|
109
|
+
*/
|
|
110
|
+
export declare function setActive(relativePath: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Find an installed version by path, build, full version, or repo/build.
|
|
113
|
+
*/
|
|
114
|
+
export declare function findInstalledVersion(specifier: string): string | null;
|
|
115
|
+
/**
|
|
116
|
+
* Install to browsers/{repoName}/{version}-{build}-{sha8}; the suffix is
|
|
117
|
+
* omitted when the release carries no sha.
|
|
118
|
+
*/
|
|
119
|
+
export declare function installVersioned(fetcher: CamouwolfFetcher, replace?: boolean): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Remove a specific version installation.
|
|
122
|
+
*/
|
|
123
|
+
export declare function removeVersion(versionPath: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Short tag to tell coexisting installs apart: date, else sha8.
|
|
126
|
+
*/
|
|
127
|
+
export declare function installedLabel(iv: InstalledVersion): string;
|
|
128
|
+
/**
|
|
129
|
+
* Print installed versions as a tree.
|
|
130
|
+
*/
|
|
131
|
+
export declare function printTree(showHeader?: boolean, showPaths?: boolean): void;
|