@pi-oxide/extension-js 0.12.0 → 0.12.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.
@@ -0,0 +1,451 @@
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: CommandParams;
20
+ run_id: string | null;
21
+ }
22
+
23
+ /**
24
+ * Consumer-facing result of running a single cell.
25
+ * Either success with an optional result string, or an error.
26
+ */
27
+ export type CellResult = { status: "ok"; stdout: string[]; stderr: string[]; result: string | null; execution_count: number } | { status: "err"; stdout: string[]; stderr: string[]; error: WasmCellError; execution_count: number };
28
+
29
+ /**
30
+ * Error details inside an async response.
31
+ */
32
+ export interface WasmAsyncError {
33
+ message: string;
34
+ code: string;
35
+ category?: string;
36
+ hint?: string;
37
+ recovery?: string[];
38
+ details?: Value;
39
+ }
40
+
41
+ /**
42
+ * Response passed to `resume_cell` to resolve an async yield.
43
+ */
44
+ export interface WasmAsyncResponse {
45
+ ok: boolean;
46
+ value: Value | null;
47
+ error: WasmAsyncError | null;
48
+ }
49
+
50
+ /**
51
+ * Result of running a single cell, including async-loop state.
52
+ * Either still pending (waiting for async resolution) or done.
53
+ */
54
+ export type WasmRunResult = { status: "pending"; stdout: string[]; stderr: string[]; commands: CommandParams[]; fuel_exhausted: boolean; execution_count: number; pending_commands: WasmAsyncCommand[] } | { status: "ok"; stdout: string[]; stderr: string[]; result: string | null; execution_count: number } | { status: "err"; stdout: string[]; stderr: string[]; error: WasmCellError; execution_count: number };
55
+
56
+ /**
57
+ * Snapshot of all JS globals.
58
+ */
59
+ export interface WasmGlobalsSnapshot {
60
+ variables: WasmGlobalVariable[];
61
+ execution_count: number;
62
+ }
63
+
64
+ /**
65
+ * Status of a cell execution.
66
+ */
67
+ export type WasmCellStatus = "done" | "async_pending";
68
+
69
+ /**
70
+ * Structured error from running a cell.
71
+ */
72
+ export type WasmCellError = { kind: "compile"; name: string | null; message: string; line: number | null } | { kind: "runtime"; name: string | null; message: string; line: number | null; action: string | null; code: string | null; stack: string | null } | { kind: "fuel_exhausted" } | { kind: "internal"; message: string };
73
+
74
+ export interface CollectOptions {
75
+ includeHidden?: boolean;
76
+ includeNonInteractive?: boolean;
77
+ includeGeometry?: boolean;
78
+ includePath?: boolean;
79
+ maxTextLength?: number;
80
+ maxNodes?: number;
81
+ interactiveOnly?: boolean;
82
+ format?: SnapshotFormat;
83
+ }
84
+
85
+ export interface FsBoolResult {
86
+ ok: boolean;
87
+ }
88
+
89
+ export interface FsCopyParams {
90
+ from: string;
91
+ to: string;
92
+ }
93
+
94
+ export interface FsExistsResult {
95
+ exists: boolean;
96
+ }
97
+
98
+ export interface FsHashParams {
99
+ path: string;
100
+ algo: string;
101
+ }
102
+
103
+ export interface FsHashResult {
104
+ hash: string;
105
+ }
106
+
107
+ export interface FsListEntry {
108
+ name: string;
109
+ kind: string;
110
+ }
111
+
112
+ export interface FsListResult {
113
+ entries: FsListEntry[];
114
+ }
115
+
116
+ export interface FsPathParams {
117
+ path: string;
118
+ }
119
+
120
+ export interface FsReadRangeDataParams {
121
+ path: string;
122
+ offset: number;
123
+ data: string;
124
+ }
125
+
126
+ export interface FsReadRangeParams {
127
+ path: string;
128
+ offset: number;
129
+ len: number;
130
+ }
131
+
132
+ export interface FsStatResult {
133
+ path: string;
134
+ name: string;
135
+ kind: string;
136
+ size: number;
137
+ mime: string | null;
138
+ created_at: number | null;
139
+ modified_at: number | null;
140
+ }
141
+
142
+ export interface FsStringResult {
143
+ data: string;
144
+ }
145
+
146
+ export interface FsWriteParams {
147
+ path: string;
148
+ data: string;
149
+ }
150
+
151
+ export interface FsWriteResult {
152
+ path: string;
153
+ bytes_written: number;
154
+ }
155
+
156
+ export interface JsApiAlias {
157
+ namespace: string;
158
+ name: string;
159
+ fields: string[] | null;
160
+ }
161
+
162
+ export interface JsManifestEntry {
163
+ action: string;
164
+ namespace: string;
165
+ name: string;
166
+ publicName: string;
167
+ description: string;
168
+ fields: string[] | null;
169
+ aliases: JsApiAlias[];
170
+ paramsDoc: JsParamDoc[];
171
+ returnsDoc: JsReturnDoc;
172
+ errorCode: string;
173
+ errorCategory: string | null;
174
+ permission: string | null;
175
+ example: string | null;
176
+ prerequisites?: string[] | null;
177
+ notes?: string[] | null;
178
+ tags?: string[] | null;
179
+ relatedApis?: string[] | null;
180
+ }
181
+
182
+ export interface JsParamDoc {
183
+ name: string;
184
+ type: string;
185
+ required: boolean;
186
+ description: string;
187
+ }
188
+
189
+ export interface JsReturnDoc {
190
+ type: string;
191
+ description: string;
192
+ }
193
+
194
+ export interface OutlineNode {
195
+ role: string;
196
+ name: string;
197
+ ref_id: string;
198
+ }
199
+
200
+ export interface Rect {
201
+ x: number;
202
+ y: number;
203
+ width: number;
204
+ height: number;
205
+ top: number;
206
+ right: number;
207
+ bottom: number;
208
+ left: number;
209
+ }
210
+
211
+ export interface SemanticNode {
212
+ refId: string;
213
+ role: string;
214
+ name?: string;
215
+ description?: string;
216
+ tag: string;
217
+ id?: string;
218
+ classes?: string[];
219
+ value?: string;
220
+ placeholder?: string;
221
+ href?: string;
222
+ states: States;
223
+ inputType?: string;
224
+ rect?: Rect;
225
+ inViewport: boolean;
226
+ visible: boolean;
227
+ path?: string;
228
+ }
229
+
230
+ export interface States {
231
+ disabled?: boolean;
232
+ checked?: boolean;
233
+ selected?: boolean;
234
+ expanded?: boolean;
235
+ pressed?: boolean;
236
+ required?: boolean;
237
+ readonly?: boolean;
238
+ invalid?: boolean;
239
+ hidden?: boolean;
240
+ focusable?: boolean;
241
+ interactive?: boolean;
242
+ current?: boolean;
243
+ }
244
+
245
+ export interface TreeSnapshot {
246
+ version: string;
247
+ url: string | null;
248
+ title: string | null;
249
+ viewport: Viewport | null;
250
+ nodes: SemanticNode[];
251
+ outline?: OutlineNode[];
252
+ }
253
+
254
+ export interface Viewport {
255
+ width: number;
256
+ height: number;
257
+ scrollX: number;
258
+ scrollY: number;
259
+ }
260
+
261
+ export type SnapshotFormat = "compact-text" | "json" | "json-pretty";
262
+
263
+
264
+ /**
265
+ * ExtensionSession wraps BaseSession for the Chrome Extension environment.
266
+ * WASM runs inside a Web Worker; all browser side-effects are dispatched
267
+ * through the unified executable handler registry (Rust-local handlers or JS-registered callbacks).
268
+ */
269
+ export class ExtensionSession {
270
+ free(): void;
271
+ [Symbol.dispose](): void;
272
+ /**
273
+ * Generate API documentation for every registered public API.
274
+ */
275
+ apiDocs(format: string): string;
276
+ fsAppend(params: FsWriteParams): Promise<FsWriteResult>;
277
+ fsAppendBase64(params: FsWriteParams): Promise<FsWriteResult>;
278
+ fsAppendText(params: FsWriteParams): Promise<FsWriteResult>;
279
+ fsCopy(params: FsCopyParams): Promise<FsBoolResult>;
280
+ fsDelete(params: FsPathParams): Promise<FsBoolResult>;
281
+ fsExists(params: FsPathParams): Promise<FsExistsResult>;
282
+ fsHash(params: FsHashParams): Promise<FsHashResult>;
283
+ fsList(params: FsPathParams): Promise<FsListResult>;
284
+ fsMkdir(params: FsPathParams): Promise<FsBoolResult>;
285
+ fsMove(params: FsCopyParams): Promise<FsBoolResult>;
286
+ fsRead(params: FsPathParams): Promise<FsStringResult>;
287
+ fsReadBase64(params: FsPathParams): Promise<FsStringResult>;
288
+ fsReadRange(params: FsReadRangeParams): Promise<FsStringResult>;
289
+ fsReadText(params: FsPathParams): Promise<FsStringResult>;
290
+ fsStat(params: FsPathParams): Promise<FsStatResult>;
291
+ fsUpdate(params: FsReadRangeDataParams): Promise<FsBoolResult>;
292
+ fsWrite(params: FsWriteParams): Promise<FsWriteResult>;
293
+ fsWriteBase64(params: FsWriteParams): Promise<FsWriteResult>;
294
+ fsWriteText(params: FsWriteParams): Promise<FsWriteResult>;
295
+ /**
296
+ * Inject async and sync API bindings from the doc registry into the JS environment.
297
+ * Must be called after all manifest entries are registered.
298
+ */
299
+ injectRegistryBindings(): void;
300
+ /**
301
+ * Inspect all global variables in the current JS state.
302
+ */
303
+ inspect_globals(): WasmGlobalsSnapshot;
304
+ /**
305
+ * Load a JS library by executing its source code.
306
+ */
307
+ load_library(source: string): CellResult;
308
+ /**
309
+ * Create a new extension session.
310
+ */
311
+ constructor();
312
+ /**
313
+ * Reset the session, clearing all JS state.
314
+ */
315
+ reset(): void;
316
+ /**
317
+ * Run a cell, automatically resolving all async calls through the
318
+ * unified handler registry.
319
+ */
320
+ runCellAsync(code: string, stdin: string, run_id: string): Promise<CellResult>;
321
+ /**
322
+ * Signal the async execution loop to abort between command batches.
323
+ */
324
+ setAborted(value: boolean): void;
325
+ /**
326
+ * Set the fuel limit for execution.
327
+ */
328
+ set_fuel_limit(limit: number): void;
329
+ /**
330
+ * Clean up the session and release resources.
331
+ */
332
+ stopWith(): void;
333
+ }
334
+
335
+ export function clearVfsWriteCache(): void;
336
+
337
+ export function collect_document(options: CollectOptions): TreeSnapshot;
338
+
339
+ export function collect_element(root: Element, options: CollectOptions): TreeSnapshot;
340
+
341
+ export function format_snapshot_js(snapshot: TreeSnapshot, format?: SnapshotFormat | null): string;
342
+
343
+ export function freezeManifest(): void;
344
+
345
+ export function importManifestEntries(entries: Array<any>): void;
346
+
347
+ export function main(): void;
348
+
349
+ export function registerJsCall(entry: JsManifestEntry, callback: Function): void;
350
+
351
+ export function registerJsCallBatch(items: Array<any>): void;
352
+
353
+ export function registerSharedDispatch(callback: Function): void;
354
+
355
+ /**
356
+ * 0=trace, 1=debug, 2=info, 3=warn, 4=error, 5=none
357
+ */
358
+ export function setLogLevel(level: number): void;
359
+
360
+ export function takeCachedVfsWriteBase64(path: string): string | undefined;
361
+
362
+ /**
363
+ * Borrow-free OPFS read for use from inside runCellAsync (e.g. setFiles path resolver).
364
+ * fsReadBase64 is an impl ExtensionSession method and re-enters the wasm-bindgen borrow
365
+ * held by runCellAsync; this free function reads OPFS without touching any session object.
366
+ */
367
+ export function webFsReadBase64(path: string): Promise<string>;
368
+
369
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
370
+
371
+ export interface InitOutput {
372
+ readonly memory: WebAssembly.Memory;
373
+ readonly setLogLevel: (a: number) => void;
374
+ readonly clearVfsWriteCache: () => void;
375
+ readonly freezeManifest: () => [number, number];
376
+ readonly importManifestEntries: (a: any) => [number, number];
377
+ readonly main: () => void;
378
+ readonly registerJsCall: (a: any, b: any) => [number, number];
379
+ readonly registerJsCallBatch: (a: any) => [number, number];
380
+ readonly registerSharedDispatch: (a: any) => [number, number];
381
+ readonly takeCachedVfsWriteBase64: (a: number, b: number) => [number, number];
382
+ readonly webFsReadBase64: (a: number, b: number) => any;
383
+ readonly __wbg_extensionsession_free: (a: number, b: number) => void;
384
+ readonly extensionsession_apiDocs: (a: number, b: number, c: number) => [number, number, number, number];
385
+ readonly extensionsession_fsAppend: (a: number, b: any) => any;
386
+ readonly extensionsession_fsAppendBase64: (a: number, b: any) => any;
387
+ readonly extensionsession_fsAppendText: (a: number, b: any) => any;
388
+ readonly extensionsession_fsCopy: (a: number, b: any) => any;
389
+ readonly extensionsession_fsDelete: (a: number, b: any) => any;
390
+ readonly extensionsession_fsExists: (a: number, b: any) => any;
391
+ readonly extensionsession_fsHash: (a: number, b: any) => any;
392
+ readonly extensionsession_fsList: (a: number, b: any) => any;
393
+ readonly extensionsession_fsMkdir: (a: number, b: any) => any;
394
+ readonly extensionsession_fsMove: (a: number, b: any) => any;
395
+ readonly extensionsession_fsRead: (a: number, b: any) => any;
396
+ readonly extensionsession_fsReadBase64: (a: number, b: any) => any;
397
+ readonly extensionsession_fsReadRange: (a: number, b: any) => any;
398
+ readonly extensionsession_fsReadText: (a: number, b: any) => any;
399
+ readonly extensionsession_fsStat: (a: number, b: any) => any;
400
+ readonly extensionsession_fsUpdate: (a: number, b: any) => any;
401
+ readonly extensionsession_fsWrite: (a: number, b: any) => any;
402
+ readonly extensionsession_fsWriteBase64: (a: number, b: any) => any;
403
+ readonly extensionsession_fsWriteText: (a: number, b: any) => any;
404
+ readonly extensionsession_injectRegistryBindings: (a: number) => void;
405
+ readonly extensionsession_inspect_globals: (a: number) => any;
406
+ readonly extensionsession_load_library: (a: number, b: number, c: number) => any;
407
+ readonly extensionsession_new: () => number;
408
+ readonly extensionsession_reset: (a: number) => void;
409
+ readonly extensionsession_runCellAsync: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
410
+ readonly extensionsession_setAborted: (a: number, b: number) => void;
411
+ readonly extensionsession_set_fuel_limit: (a: number, b: number) => void;
412
+ readonly extensionsession_stopWith: (a: number) => void;
413
+ readonly collect_document: (a: any) => any;
414
+ readonly collect_element: (a: any, b: any) => any;
415
+ readonly format_snapshot_js: (a: any, b: number) => [number, number];
416
+ readonly wasm_bindgen__convert__closures_____invoke__h98d1e2b6e52d4bb6: (a: number, b: number, c: any) => [number, number];
417
+ readonly wasm_bindgen__convert__closures_____invoke__h8b86fd99daba3694: (a: number, b: number, c: any, d: any) => void;
418
+ readonly wasm_bindgen__convert__closures_____invoke__h27811ca8d75e2bba: (a: number, b: number) => number;
419
+ readonly wasm_bindgen__convert__closures_____invoke__h6d8d5445a5fade3d: (a: number, b: number) => void;
420
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
421
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
422
+ readonly __wbindgen_exn_store: (a: number) => void;
423
+ readonly __externref_table_alloc: () => number;
424
+ readonly __wbindgen_externrefs: WebAssembly.Table;
425
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
426
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
427
+ readonly __externref_table_dealloc: (a: number) => void;
428
+ readonly __wbindgen_start: () => void;
429
+ }
430
+
431
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
432
+
433
+ /**
434
+ * Instantiates the given `module`, which can either be bytes or
435
+ * a precompiled `WebAssembly.Module`.
436
+ *
437
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
438
+ *
439
+ * @returns {InitOutput}
440
+ */
441
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
442
+
443
+ /**
444
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
445
+ * for everything else, calls `WebAssembly.instantiate` directly.
446
+ *
447
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
448
+ *
449
+ * @returns {Promise<InitOutput>}
450
+ */
451
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;