@cbxss/eoka 0.0.0-stage → 0.1.0-beta.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/README.md +577 -2
- package/dist/LICENSE +21 -0
- package/dist/browser-install-diagnostics.d.ts +1 -0
- package/dist/browser-install-diagnostics.js +21 -0
- package/dist/browser-install-engine.d.ts +10 -0
- package/dist/browser-install-engine.js +286 -0
- package/dist/browser-install-inventory.d.ts +34 -0
- package/dist/browser-install-inventory.js +107 -0
- package/dist/browser-install-worker.d.ts +21 -0
- package/dist/browser-install-worker.js +65 -0
- package/dist/browser-install.d.ts +22 -0
- package/dist/browser-install.js +7 -0
- package/dist/browser.d.ts +59 -0
- package/dist/browser.js +445 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.js +1 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +44 -0
- package/dist/generated/protocol.d.ts +3929 -0
- package/dist/generated/protocol.js +2 -0
- package/dist/generated/schema-bundle.json +18964 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +11 -0
- package/dist/install-errors.d.ts +4 -0
- package/dist/install-errors.js +6 -0
- package/dist/operations.d.ts +22 -0
- package/dist/operations.js +87 -0
- package/dist/page.d.ts +77 -0
- package/dist/page.js +250 -0
- package/dist/platform.d.ts +4 -0
- package/dist/platform.js +27 -0
- package/dist/recording.d.ts +27 -0
- package/dist/recording.js +124 -0
- package/dist/release-manifest.json +101 -0
- package/dist/release.d.ts +36 -0
- package/dist/release.js +76 -0
- package/dist/server-binary.d.ts +11 -0
- package/dist/server-binary.js +107 -0
- package/dist/transport.d.ts +89 -0
- package/dist/transport.js +737 -0
- package/examples/capture.mjs +36 -0
- package/examples/consume-schema.mjs +7 -0
- package/examples/explicit-paths.mjs +42 -0
- package/examples/install-browser.mjs +20 -0
- package/examples/offline.mjs +20 -0
- package/package.json +70 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { setTimeout } from 'node:timers/promises';
|
|
4
|
+
import { Browser, RecordingError } from '@cbxss/eoka';
|
|
5
|
+
|
|
6
|
+
if (process.argv[2] === undefined) throw new Error('Usage: node capture.mjs OUTPUT_DIRECTORY [BROWSER_CACHE_DIRECTORY]');
|
|
7
|
+
const directory = resolve(process.argv[2]);
|
|
8
|
+
await mkdir(directory, { recursive: true });
|
|
9
|
+
const browser = await Browser.launch({
|
|
10
|
+
...(process.argv[3] === undefined ? {} : { browserCacheDir: process.argv[3] }),
|
|
11
|
+
download: 'never',
|
|
12
|
+
headless: true,
|
|
13
|
+
sandbox: true,
|
|
14
|
+
viewport: { width: 800, height: 600, deviceScaleFactor: 1 },
|
|
15
|
+
timeoutMs: 30000,
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
const scene = '<!doctype html><title>Native capture</title><style>body{margin:0;background:#123;color:white;height:1200px}h1{padding:24px}.box{width:100px;height:100px;background:orange;animation:move 1s alternate infinite linear}@keyframes move{from{transform:translateX(0)}to{transform:translateX(600px)}}</style><h1>Native animated capture</h1><div class="box"></div>';
|
|
19
|
+
const page = await browser.newPage(`data:text/html,${encodeURIComponent(scene)}`);
|
|
20
|
+
const image = await page.screenshot({ format: 'png', clip: { x: 0, y: 0, width: 400, height: 300 } });
|
|
21
|
+
const screenshots = [];
|
|
22
|
+
for (const format of ['png', 'jpeg', 'webp']) {
|
|
23
|
+
screenshots.push(await page.screenshotToFile({ path: join(directory, `page.${format}`), format, fullPage: true }));
|
|
24
|
+
}
|
|
25
|
+
const recording = await page.record({ path: join(directory, 'animation.mp4'), maxWidth: 800, maxHeight: 600, fps: 30 });
|
|
26
|
+
await setTimeout(2000);
|
|
27
|
+
const artifact = await recording.stop({ timeoutMs: 60000 });
|
|
28
|
+
console.log(JSON.stringify({ imageBytes: image.length, screenshots, recordingId: recording.id, artifact }, null, 2));
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error instanceof RecordingError) {
|
|
31
|
+
console.error(JSON.stringify({ recordingId: error.recordingId, code: error.code, path: error.path, record: error.record, failure: error.failure, partialPath: error.partialPath, cleanupUncertain: error.cleanupUncertain }, null, 2));
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
} finally {
|
|
35
|
+
await browser.close();
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { decodeMethodResult } from "../scripts/schema-consumer.mjs";
|
|
3
|
+
|
|
4
|
+
const bundle = JSON.parse(await readFile(new URL("../src/generated/schema-bundle.json", import.meta.url), "utf8"));
|
|
5
|
+
const operations = decodeMethodResult(bundle, "operations.list", await readFile(new URL("../fixtures/wire/operations-list.json", import.meta.url), "utf8"));
|
|
6
|
+
const evaluation = decodeMethodResult(bundle, "page.evaluate", await readFile(new URL("../fixtures/wire/evaluation.json", import.meta.url), "utf8"));
|
|
7
|
+
console.log(JSON.stringify({ operations: operations.map((record) => record.id), evaluation: evaluation.result }, null, 2));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { Browser, EokaError } from "@cbxss/eoka";
|
|
3
|
+
|
|
4
|
+
const serverPath = process.argv[2] ?? process.env.EOKA_SERVER_BIN;
|
|
5
|
+
const executablePath = process.argv[3] ?? process.env.EOKA_CHROME_PATH;
|
|
6
|
+
if (!serverPath || !executablePath) {
|
|
7
|
+
throw new Error("Supply both server and Chrome paths as arguments or EOKA_SERVER_BIN/EOKA_CHROME_PATH");
|
|
8
|
+
}
|
|
9
|
+
const browser = await Browser.launch({
|
|
10
|
+
serverPath,
|
|
11
|
+
executablePath,
|
|
12
|
+
headless: true,
|
|
13
|
+
sandbox: true,
|
|
14
|
+
timeoutMs: 15000,
|
|
15
|
+
});
|
|
16
|
+
const operationId = randomUUID();
|
|
17
|
+
try {
|
|
18
|
+
const html = '<!doctype html><title>eoka SDK example</title><label>Name <input id="name"></label>';
|
|
19
|
+
const page = await browser.newPage(`data:text/html,${encodeURIComponent(html)}`, { timeoutMs: 15000 });
|
|
20
|
+
const target = { query: { kind: "css", selector: "#name" } };
|
|
21
|
+
const receipt = await page.fill(target, "Ada", {
|
|
22
|
+
operationId,
|
|
23
|
+
timeoutMs: 10000,
|
|
24
|
+
actionOptions: { expect: { kind: "value", target, value: "Ada" }, timeout_ms: 5000 },
|
|
25
|
+
});
|
|
26
|
+
console.log(JSON.stringify({ ownership: browser.ownership, browserVersion: browser.browserVersion, operationId, receipt }, null, 2));
|
|
27
|
+
console.log(JSON.stringify(await page.invoke("page.evaluate", { pageId: page.id, js: '({name: document.querySelector("#name").value})' })));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
const primary = error instanceof AggregateError ? error.cause : error;
|
|
30
|
+
if (primary instanceof EokaError && primary.operationId) {
|
|
31
|
+
console.error(JSON.stringify({ code: primary.code, operationId: primary.operationId, requestState: primary.requestState, receipt: primary.receipt }));
|
|
32
|
+
try {
|
|
33
|
+
const record = await browser.operation(primary.operationId).get({ timeoutMs: 5000 });
|
|
34
|
+
console.error(JSON.stringify({ recovered: record }));
|
|
35
|
+
} catch (recoveryError) {
|
|
36
|
+
console.error("Operation recovery failed:", recoveryError);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
} finally {
|
|
41
|
+
await browser.close();
|
|
42
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { installBrowser } from "@cbxss/eoka";
|
|
2
|
+
|
|
3
|
+
const controller = new AbortController();
|
|
4
|
+
const abort = () => controller.abort();
|
|
5
|
+
process.once("SIGINT", abort);
|
|
6
|
+
process.once("SIGTERM", abort);
|
|
7
|
+
try {
|
|
8
|
+
const installation = await installBrowser({
|
|
9
|
+
...(process.argv[2] === undefined ? {} : { browserCacheDir: process.argv[2] }),
|
|
10
|
+
signal: controller.signal,
|
|
11
|
+
timeoutMs: 300000,
|
|
12
|
+
onProgress: ({ downloadedBytes, totalBytes, buildId }) => {
|
|
13
|
+
process.stderr.write(`Chrome ${buildId}: ${downloadedBytes}/${totalBytes} bytes\n`);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
console.log(JSON.stringify(installation, null, 2));
|
|
17
|
+
} finally {
|
|
18
|
+
process.removeListener("SIGINT", abort);
|
|
19
|
+
process.removeListener("SIGTERM", abort);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Browser } from "@cbxss/eoka";
|
|
2
|
+
|
|
3
|
+
const browser = await Browser.launch({
|
|
4
|
+
...(process.argv[2] === undefined ? {} : { browserCacheDir: process.argv[2] }),
|
|
5
|
+
download: "never",
|
|
6
|
+
headless: true,
|
|
7
|
+
sandbox: true,
|
|
8
|
+
timeoutMs: 30000,
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
const page = await browser.newPage("data:text/html,%3Ctitle%3Eeoka%20offline%3C/title%3E");
|
|
12
|
+
const result = await page.invoke("page.evaluate", { pageId: page.id, js: "document.title" });
|
|
13
|
+
console.log(JSON.stringify({
|
|
14
|
+
title: result.result,
|
|
15
|
+
ownership: browser.ownership,
|
|
16
|
+
browserVersion: browser.browserVersion,
|
|
17
|
+
}, null, 2));
|
|
18
|
+
} finally {
|
|
19
|
+
await browser.close();
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cbxss/eoka",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Node.js SDK with pinned Chrome installation and verified eoka sidecar resolution",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./protocol": {
|
|
16
|
+
"types": "./dist/generated/protocol.d.ts",
|
|
17
|
+
"import": "./dist/generated/protocol.js"
|
|
18
|
+
},
|
|
19
|
+
"./release-manifest.json": "./dist/release-manifest.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/**/*.js",
|
|
23
|
+
"dist/**/*.d.ts",
|
|
24
|
+
"dist/generated/schema-bundle.json",
|
|
25
|
+
"dist/release-manifest.json",
|
|
26
|
+
"dist/LICENSE",
|
|
27
|
+
"README.md",
|
|
28
|
+
"examples/*.mjs"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": "^24.21.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"generate": "node scripts/generate-protocol.mjs",
|
|
36
|
+
"generate:check": "node scripts/generate-protocol.mjs --check",
|
|
37
|
+
"build": "node scripts/build.mjs",
|
|
38
|
+
"check": "npm run generate:check && npm run build && node scripts/typecheck.mjs && node --test tests/*.test.mjs",
|
|
39
|
+
"typecheck": "npm run build && node scripts/typecheck.mjs",
|
|
40
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
41
|
+
"test:consumer": "npm run build && node --test tests/package-consumer.test.mjs",
|
|
42
|
+
"stage:release": "node scripts/stage-release.mjs",
|
|
43
|
+
"example": "node examples/explicit-paths.mjs",
|
|
44
|
+
"example:install": "node examples/install-browser.mjs",
|
|
45
|
+
"example:offline": "node examples/offline.mjs",
|
|
46
|
+
"example:schema": "node examples/consume-schema.mjs",
|
|
47
|
+
"example:capture": "node examples/capture.mjs"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@puppeteer/browsers": "3.2.4",
|
|
51
|
+
"ajv": "8.17.1",
|
|
52
|
+
"proxy-agent": "8.0.1",
|
|
53
|
+
"yauzl": "3.4.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "24.19.2",
|
|
57
|
+
"sigstore": "4.1.1",
|
|
58
|
+
"typescript": "5.9.3"
|
|
59
|
+
},
|
|
60
|
+
"optionalDependencies": {
|
|
61
|
+
"@cbxss/eoka-server-linux-x64-gnu": "0.1.0-beta.2",
|
|
62
|
+
"@cbxss/eoka-server-linux-arm64-gnu": "0.1.0-beta.2",
|
|
63
|
+
"@cbxss/eoka-server-darwin-x64": "0.1.0-beta.2",
|
|
64
|
+
"@cbxss/eoka-server-darwin-arm64": "0.1.0-beta.2",
|
|
65
|
+
"@cbxss/eoka-server-win32-x64": "0.1.0-beta.2"
|
|
66
|
+
},
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "git+https://github.com/shrimp-software/eoka-tools.git",
|
|
70
|
+
"directory": "clients/node"
|
|
71
|
+
}
|
|
72
|
+
}
|