@pi-oxide/extension-js 0.1.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/extension_js.d.ts +338 -0
- package/extension_js.js +1367 -0
- package/extension_js_bg.wasm +0 -0
- package/package.json +16 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* A single global variable observed by `inspect_globals`.
|
|
5
|
+
*/
|
|
6
|
+
export interface WasmGlobalVariable {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
value: string | null;
|
|
10
|
+
keys: string[] | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An async command yielded from JS, waiting for external resolution.
|
|
15
|
+
*/
|
|
16
|
+
export interface WasmAsyncCommand {
|
|
17
|
+
call_id: number;
|
|
18
|
+
action: string;
|
|
19
|
+
params: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Consumer-facing result of running a single cell.
|
|
24
|
+
* Either success with an optional result string, or an error.
|
|
25
|
+
*/
|
|
26
|
+
export type CellResult =
|
|
27
|
+
| {
|
|
28
|
+
status: "ok";
|
|
29
|
+
stdout: string[];
|
|
30
|
+
stderr: string[];
|
|
31
|
+
result: string | null;
|
|
32
|
+
execution_count: number;
|
|
33
|
+
}
|
|
34
|
+
| {
|
|
35
|
+
status: "err";
|
|
36
|
+
stdout: string[];
|
|
37
|
+
stderr: string[];
|
|
38
|
+
error: WasmCellError;
|
|
39
|
+
execution_count: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Error details inside an async response.
|
|
44
|
+
*/
|
|
45
|
+
export interface WasmAsyncError {
|
|
46
|
+
message: string;
|
|
47
|
+
code: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Response passed to `resume_cell` to resolve an async yield.
|
|
52
|
+
*/
|
|
53
|
+
export interface WasmAsyncResponse {
|
|
54
|
+
ok: boolean;
|
|
55
|
+
value: unknown;
|
|
56
|
+
error: WasmAsyncError | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Result of running a single cell, including async-loop state.
|
|
61
|
+
* Either still pending (waiting for async resolution) or done.
|
|
62
|
+
*/
|
|
63
|
+
export type WasmRunResult =
|
|
64
|
+
| {
|
|
65
|
+
status: "pending";
|
|
66
|
+
stdout: string[];
|
|
67
|
+
stderr: string[];
|
|
68
|
+
commands: unknown[];
|
|
69
|
+
fuel_exhausted: boolean;
|
|
70
|
+
execution_count: number;
|
|
71
|
+
pending_commands: WasmAsyncCommand[];
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
status: "ok";
|
|
75
|
+
stdout: string[];
|
|
76
|
+
stderr: string[];
|
|
77
|
+
result: string | null;
|
|
78
|
+
execution_count: number;
|
|
79
|
+
}
|
|
80
|
+
| {
|
|
81
|
+
status: "err";
|
|
82
|
+
stdout: string[];
|
|
83
|
+
stderr: string[];
|
|
84
|
+
error: WasmCellError;
|
|
85
|
+
execution_count: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Snapshot of all JS globals.
|
|
90
|
+
*/
|
|
91
|
+
export interface WasmGlobalsSnapshot {
|
|
92
|
+
variables: WasmGlobalVariable[];
|
|
93
|
+
execution_count: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Status of a cell execution.
|
|
98
|
+
*/
|
|
99
|
+
export type WasmCellStatus = "done" | "async_pending";
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Structured error from running a cell.
|
|
103
|
+
*/
|
|
104
|
+
export type WasmCellError =
|
|
105
|
+
| { kind: "compile"; message: string; line: number | null }
|
|
106
|
+
| { kind: "runtime"; message: string; line: number | null }
|
|
107
|
+
| { kind: "fuel_exhausted" }
|
|
108
|
+
| { kind: "internal"; message: string };
|
|
109
|
+
|
|
110
|
+
export interface CollectOptions {
|
|
111
|
+
includeHidden?: boolean;
|
|
112
|
+
includeNonInteractive?: boolean;
|
|
113
|
+
includeGeometry?: boolean;
|
|
114
|
+
includePath?: boolean;
|
|
115
|
+
maxTextLength?: number;
|
|
116
|
+
maxNodes?: number;
|
|
117
|
+
interactiveOnly?: boolean;
|
|
118
|
+
format?: SnapshotFormat;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface OutlineNode {
|
|
122
|
+
role: string;
|
|
123
|
+
name: string;
|
|
124
|
+
ref_id: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface Rect {
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
width: number;
|
|
131
|
+
height: number;
|
|
132
|
+
top: number;
|
|
133
|
+
right: number;
|
|
134
|
+
bottom: number;
|
|
135
|
+
left: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface SemanticNode {
|
|
139
|
+
refId: string;
|
|
140
|
+
role: string;
|
|
141
|
+
name?: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
tag: string;
|
|
144
|
+
id?: string;
|
|
145
|
+
classes?: string[];
|
|
146
|
+
value?: string;
|
|
147
|
+
placeholder?: string;
|
|
148
|
+
href?: string;
|
|
149
|
+
states: States;
|
|
150
|
+
inputType?: string;
|
|
151
|
+
rect?: Rect;
|
|
152
|
+
inViewport: boolean;
|
|
153
|
+
visible: boolean;
|
|
154
|
+
path?: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface States {
|
|
158
|
+
disabled?: boolean;
|
|
159
|
+
checked?: boolean;
|
|
160
|
+
selected?: boolean;
|
|
161
|
+
expanded?: boolean;
|
|
162
|
+
pressed?: boolean;
|
|
163
|
+
required?: boolean;
|
|
164
|
+
readonly?: boolean;
|
|
165
|
+
invalid?: boolean;
|
|
166
|
+
hidden?: boolean;
|
|
167
|
+
focusable?: boolean;
|
|
168
|
+
interactive?: boolean;
|
|
169
|
+
current?: boolean;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface TreeSnapshot {
|
|
173
|
+
version: string;
|
|
174
|
+
url: string | null;
|
|
175
|
+
title: string | null;
|
|
176
|
+
viewport: Viewport | null;
|
|
177
|
+
nodes: SemanticNode[];
|
|
178
|
+
outline?: OutlineNode[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface Viewport {
|
|
182
|
+
width: number;
|
|
183
|
+
height: number;
|
|
184
|
+
scrollX: number;
|
|
185
|
+
scrollY: number;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export type SnapshotFormat = "compact-text" | "json" | "json-pretty";
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* ExtensionSession wraps BaseSession for the Chrome Extension environment.
|
|
192
|
+
* WASM runs inside a Web Worker; all browser side-effects are relayed
|
|
193
|
+
* to the main-thread runner via the `__extension_js_relay` global function.
|
|
194
|
+
*/
|
|
195
|
+
export class ExtensionSession {
|
|
196
|
+
free(): void;
|
|
197
|
+
[Symbol.dispose](): void;
|
|
198
|
+
/**
|
|
199
|
+
* Inspect all global variables in the current JS state.
|
|
200
|
+
*/
|
|
201
|
+
inspect_globals(): WasmGlobalsSnapshot;
|
|
202
|
+
/**
|
|
203
|
+
* Load a JS library by executing its source code.
|
|
204
|
+
*/
|
|
205
|
+
load_library(source: string): CellResult;
|
|
206
|
+
/**
|
|
207
|
+
* Create a new extension session.
|
|
208
|
+
*/
|
|
209
|
+
constructor();
|
|
210
|
+
/**
|
|
211
|
+
* Reset the session, clearing all JS state.
|
|
212
|
+
*/
|
|
213
|
+
reset(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Run a cell, automatically resolving all async calls by relaying
|
|
216
|
+
* them to the main-thread runner via `__extension_js_relay`.
|
|
217
|
+
*/
|
|
218
|
+
runCellAsync(code: string, stdin: string): Promise<CellResult>;
|
|
219
|
+
/**
|
|
220
|
+
* Set the fuel limit for execution.
|
|
221
|
+
*/
|
|
222
|
+
set_fuel_limit(limit: number): void;
|
|
223
|
+
/**
|
|
224
|
+
* Clean up the session and release resources.
|
|
225
|
+
*/
|
|
226
|
+
stopWith(): void;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function collect_document(options: CollectOptions): TreeSnapshot;
|
|
230
|
+
|
|
231
|
+
export function collect_element(
|
|
232
|
+
root: Element,
|
|
233
|
+
options: CollectOptions,
|
|
234
|
+
): TreeSnapshot;
|
|
235
|
+
|
|
236
|
+
export function format_snapshot_js(
|
|
237
|
+
snapshot: TreeSnapshot,
|
|
238
|
+
format?: SnapshotFormat | null,
|
|
239
|
+
): string;
|
|
240
|
+
|
|
241
|
+
export function generateApiDocs(format: string): string;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 0=debug, 1=info, 2=warn, 3=error, 4=none
|
|
245
|
+
*/
|
|
246
|
+
export function setLogLevel(level: number): void;
|
|
247
|
+
|
|
248
|
+
export type InitInput =
|
|
249
|
+
| RequestInfo
|
|
250
|
+
| URL
|
|
251
|
+
| Response
|
|
252
|
+
| BufferSource
|
|
253
|
+
| WebAssembly.Module;
|
|
254
|
+
|
|
255
|
+
export interface InitOutput {
|
|
256
|
+
readonly memory: WebAssembly.Memory;
|
|
257
|
+
readonly __wbg_extensionsession_free: (a: number, b: number) => void;
|
|
258
|
+
readonly extensionsession_inspect_globals: (a: number) => any;
|
|
259
|
+
readonly extensionsession_load_library: (
|
|
260
|
+
a: number,
|
|
261
|
+
b: number,
|
|
262
|
+
c: number,
|
|
263
|
+
) => any;
|
|
264
|
+
readonly extensionsession_new: () => number;
|
|
265
|
+
readonly extensionsession_reset: (a: number) => void;
|
|
266
|
+
readonly extensionsession_runCellAsync: (
|
|
267
|
+
a: number,
|
|
268
|
+
b: number,
|
|
269
|
+
c: number,
|
|
270
|
+
d: number,
|
|
271
|
+
e: number,
|
|
272
|
+
) => any;
|
|
273
|
+
readonly extensionsession_set_fuel_limit: (a: number, b: number) => void;
|
|
274
|
+
readonly extensionsession_stopWith: (a: number) => void;
|
|
275
|
+
readonly setLogLevel: (a: number) => void;
|
|
276
|
+
readonly generateApiDocs: (a: number, b: number) => [number, number];
|
|
277
|
+
readonly collect_document: (a: any) => any;
|
|
278
|
+
readonly collect_element: (a: any, b: any) => any;
|
|
279
|
+
readonly format_snapshot_js: (a: any, b: number) => [number, number];
|
|
280
|
+
readonly wasm_bindgen__convert__closures_____invoke__hbaf3bd60d2f803db: (
|
|
281
|
+
a: number,
|
|
282
|
+
b: number,
|
|
283
|
+
c: any,
|
|
284
|
+
) => [number, number];
|
|
285
|
+
readonly wasm_bindgen__convert__closures_____invoke__hf458ead16698aa30: (
|
|
286
|
+
a: number,
|
|
287
|
+
b: number,
|
|
288
|
+
c: any,
|
|
289
|
+
d: any,
|
|
290
|
+
) => void;
|
|
291
|
+
readonly wasm_bindgen__convert__closures_____invoke__hd488ef5680429ef6: (
|
|
292
|
+
a: number,
|
|
293
|
+
b: number,
|
|
294
|
+
) => number;
|
|
295
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
296
|
+
readonly __wbindgen_realloc: (
|
|
297
|
+
a: number,
|
|
298
|
+
b: number,
|
|
299
|
+
c: number,
|
|
300
|
+
d: number,
|
|
301
|
+
) => number;
|
|
302
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
303
|
+
readonly __externref_table_alloc: () => number;
|
|
304
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
305
|
+
readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
306
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
307
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
308
|
+
readonly __wbindgen_start: () => void;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
315
|
+
* a precompiled `WebAssembly.Module`.
|
|
316
|
+
*
|
|
317
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
318
|
+
*
|
|
319
|
+
* @returns {InitOutput}
|
|
320
|
+
*/
|
|
321
|
+
export function initSync(
|
|
322
|
+
module: { module: SyncInitInput } | SyncInitInput,
|
|
323
|
+
): InitOutput;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
327
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
328
|
+
*
|
|
329
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
330
|
+
*
|
|
331
|
+
* @returns {Promise<InitOutput>}
|
|
332
|
+
*/
|
|
333
|
+
export default function __wbg_init(
|
|
334
|
+
module_or_path?:
|
|
335
|
+
| { module_or_path: InitInput | Promise<InitInput> }
|
|
336
|
+
| InitInput
|
|
337
|
+
| Promise<InitInput>,
|
|
338
|
+
): Promise<InitOutput>;
|