@howaboua/pi-durable-browser 0.0.0-stage → 0.9.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/LICENSE +21 -0
- package/NOTICE +52 -0
- package/README.md +86 -2
- package/dist/browser/artifact-store.d.ts +16 -0
- package/dist/browser/artifacts.d.ts +20 -0
- package/dist/browser/bounds.d.ts +4 -0
- package/dist/browser/config-store.d.ts +11 -0
- package/dist/browser/config.d.ts +7 -0
- package/dist/browser/help.d.ts +1 -0
- package/dist/browser/launcher.d.ts +1 -0
- package/dist/browser/operation-executor.d.ts +12 -0
- package/dist/browser/operation-input.d.ts +10 -0
- package/dist/browser/operation.d.ts +115 -0
- package/dist/browser/parse-operation.d.ts +6 -0
- package/dist/browser/parse-tab-operation.d.ts +3 -0
- package/dist/browser/remote-helper.d.ts +3 -0
- package/dist/browser/remote-process.d.ts +6 -0
- package/dist/browser/remote.d.ts +4 -0
- package/dist/browser/request.d.ts +8 -0
- package/dist/browser/routes.d.ts +15 -0
- package/dist/browser/runtime.d.ts +35 -0
- package/dist/browser/voice-start.d.ts +17 -0
- package/dist/browser/worker-client.d.ts +1 -0
- package/dist/browser/worker-server.d.ts +1 -0
- package/dist/browser/worker-socket.d.ts +11 -0
- package/dist/cdp/accessibility-snapshot.d.ts +11 -0
- package/dist/cdp/actions/click.d.ts +6 -0
- package/dist/cdp/actions/element.d.ts +22 -0
- package/dist/cdp/actions/fill.d.ts +8 -0
- package/dist/cdp/actions/key.d.ts +20 -0
- package/dist/cdp/actions/page.d.ts +7 -0
- package/dist/cdp/actions/screenshot.d.ts +14 -0
- package/dist/cdp/actions/selector.d.ts +2 -0
- package/dist/cdp/actions/type.d.ts +3 -0
- package/dist/cdp/actions/wait.d.ts +9 -0
- package/dist/cdp/client.d.ts +20 -0
- package/dist/cdp/discovery.d.ts +7 -0
- package/dist/cdp/evaluate.d.ts +3 -0
- package/dist/cdp/pages.d.ts +4 -0
- package/dist/cdp/serial.d.ts +1 -0
- package/dist/cdp/session.d.ts +27 -0
- package/dist/cdp/snapshot-contract.d.ts +38 -0
- package/dist/cdp/snapshot.d.ts +3 -0
- package/dist/cdp/tab-bridge.d.ts +26 -0
- package/dist/cdp/tabs.d.ts +32 -0
- package/dist/cdp/types.d.ts +22 -0
- package/dist/cdp/url.d.ts +1 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +3951 -0
- package/dist/presentation.d.ts +43 -0
- package/dist/presentation.js +82 -0
- package/dist/remote-worker.d.ts +2 -0
- package/dist/remote-worker.js +3850 -0
- package/package.json +43 -5
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BrowserRuntime } from "./browser/runtime.ts";
|
|
2
|
+
export type BrowserResult = Awaited<ReturnType<BrowserRuntime["execute"]>>;
|
|
3
|
+
export interface BrowserPresentationState {
|
|
4
|
+
host: string | null;
|
|
5
|
+
operationCount: number;
|
|
6
|
+
screenshots: string[];
|
|
7
|
+
continuations: Array<{
|
|
8
|
+
handle: string;
|
|
9
|
+
nextOffset: number;
|
|
10
|
+
}>;
|
|
11
|
+
detail: BrowserResult | null;
|
|
12
|
+
}
|
|
13
|
+
/** Project actual completed output. A thrown batch failure is not a success receipt. */
|
|
14
|
+
export declare function createBrowserPresentationState(output: BrowserResult): BrowserPresentationState;
|
|
15
|
+
declare function parseState(value: unknown): BrowserPresentationState;
|
|
16
|
+
/** Readonly receipts. The host owns binding, acquisition and ordinary tool invocation. */
|
|
17
|
+
export declare const browserCapability: {
|
|
18
|
+
id: string;
|
|
19
|
+
version: number;
|
|
20
|
+
parseState: typeof parseState;
|
|
21
|
+
actions: readonly string[];
|
|
22
|
+
streams: readonly string[];
|
|
23
|
+
presentations: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export declare const browserSummary: {
|
|
26
|
+
id: string;
|
|
27
|
+
select: (state: BrowserPresentationState) => {
|
|
28
|
+
host: string | null;
|
|
29
|
+
operationCount: number;
|
|
30
|
+
screenshots: string[];
|
|
31
|
+
continuations: {
|
|
32
|
+
handle: string;
|
|
33
|
+
nextOffset: number;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
requests: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
export declare const browserDetail: {
|
|
39
|
+
id: string;
|
|
40
|
+
select: (state: BrowserPresentationState) => Record<string, unknown> | null;
|
|
41
|
+
requests: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// packages/browser/src/presentation.ts
|
|
2
|
+
function createBrowserPresentationState(output) {
|
|
3
|
+
const results = Array.isArray(output["results"]) ? output["results"].map(record) : [output];
|
|
4
|
+
const continuations = results.flatMap((result) => {
|
|
5
|
+
const handle = result["result_handle"] ?? result["handle"];
|
|
6
|
+
const offset = result["next_offset"];
|
|
7
|
+
return handle === undefined || offset === undefined ? [] : [{ handle: string(handle), nextOffset: count(offset) }];
|
|
8
|
+
});
|
|
9
|
+
const screenshots = results.flatMap((result) => result["file"] === undefined ? [] : [string(result["file"])]);
|
|
10
|
+
return parseState({
|
|
11
|
+
host: output["host"] ?? null,
|
|
12
|
+
operationCount: results.length,
|
|
13
|
+
screenshots,
|
|
14
|
+
continuations,
|
|
15
|
+
detail: null
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function parseState(value) {
|
|
19
|
+
const state = record(value);
|
|
20
|
+
const host = state["host"] === null ? null : string(state["host"]);
|
|
21
|
+
const operationCount = count(state["operationCount"]);
|
|
22
|
+
if (!Array.isArray(state["screenshots"]))
|
|
23
|
+
throw new TypeError("Missing screenshot metadata");
|
|
24
|
+
const screenshots = state["screenshots"].map(string);
|
|
25
|
+
if (!Array.isArray(state["continuations"]))
|
|
26
|
+
throw new TypeError("Missing continuations");
|
|
27
|
+
const continuations = state["continuations"].map((value) => {
|
|
28
|
+
const cursor = record(value);
|
|
29
|
+
return {
|
|
30
|
+
handle: string(cursor["handle"]),
|
|
31
|
+
nextOffset: count(cursor["nextOffset"])
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const detail = state["detail"] === null ? null : record(state["detail"]);
|
|
35
|
+
if (detail && (Array.isArray(detail["results"]) ? detail["results"].length : 1) !== operationCount)
|
|
36
|
+
throw new TypeError("Browser operation count mismatch");
|
|
37
|
+
return { host, operationCount, screenshots, continuations, detail };
|
|
38
|
+
}
|
|
39
|
+
var browserCapability = {
|
|
40
|
+
id: "browser",
|
|
41
|
+
version: 1,
|
|
42
|
+
parseState,
|
|
43
|
+
actions: [],
|
|
44
|
+
streams: [],
|
|
45
|
+
presentations: ["summary", "detail"]
|
|
46
|
+
};
|
|
47
|
+
var browserSummary = {
|
|
48
|
+
id: "summary",
|
|
49
|
+
select: (state) => ({
|
|
50
|
+
host: state.host,
|
|
51
|
+
operationCount: state.operationCount,
|
|
52
|
+
screenshots: state.screenshots,
|
|
53
|
+
continuations: state.continuations
|
|
54
|
+
}),
|
|
55
|
+
requests: ["detail"]
|
|
56
|
+
};
|
|
57
|
+
var browserDetail = {
|
|
58
|
+
id: "detail",
|
|
59
|
+
select: (state) => state.detail,
|
|
60
|
+
requests: []
|
|
61
|
+
};
|
|
62
|
+
function record(value) {
|
|
63
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
64
|
+
throw new TypeError("Expected a receipt object");
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
function string(value) {
|
|
68
|
+
if (typeof value !== "string")
|
|
69
|
+
throw new TypeError("Expected a string");
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function count(value) {
|
|
73
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
|
|
74
|
+
throw new TypeError("Expected a nonnegative integer");
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
browserCapability,
|
|
79
|
+
browserDetail,
|
|
80
|
+
browserSummary,
|
|
81
|
+
createBrowserPresentationState
|
|
82
|
+
};
|