@webpodjs/net-worker 0.0.0-stage → 0.1.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,134 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * One guest NIC's network: gateway stack, egress and inbound bridge.
6
+ */
7
+ export class NetPod {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Another pod on the page LAN: its guest is `hostname` at its LAN index's address.
12
+ */
13
+ add_peer(id: number, hostname: string, index: number): void;
14
+ /**
15
+ * Certificate and private key, for the Worker to persist (never handed to the page).
16
+ */
17
+ ca_bundle(): string;
18
+ /**
19
+ * The pod CA certificate (PEM) to install in the guest's trust stores.
20
+ */
21
+ ca_certificate(): string;
22
+ /**
23
+ * Milliseconds until the stack wants to be polled again (-1: no timer).
24
+ */
25
+ delay(now_ms: number): number;
26
+ /**
27
+ * `network`: `{ mode?: "browser" | "none", mtu?, corsProxy?: { url, token? }, relay?: { url,
28
+ * token? }, routes?: [{ host?, ports?: [lo, hi], protocol?, via, stripHeaders? }] }` (see
29
+ * packages/net-worker/README.md). `ca_bundle`: a previously exported CA (PEM, certificate and
30
+ * key) or empty to generate one. `get_token`: called for relay tokens when `relay.token` is
31
+ * absent (returns a string or a Promise). `unix_secs`: wall clock (wasm has none).
32
+ */
33
+ constructor(network: any, ca_bundle: string, get_token: Function | null | undefined, unix_secs: number);
34
+ /**
35
+ * A page connection (preview, pod.fetch, pod.net.connect).
36
+ */
37
+ open_inbound(port: MessagePort): void;
38
+ /**
39
+ * Run the stack; returns whether anything happened (frames in or out, completions, page
40
+ * commands), in which case the Worker should poll again right away.
41
+ */
42
+ poll(now_ms: number): boolean;
43
+ /**
44
+ * An Ethernet frame from the guest.
45
+ */
46
+ push(frame: Uint8Array | number[]): void;
47
+ /**
48
+ * A frame a peer forwarded for this guest.
49
+ */
50
+ push_forwarded(frame: Uint8Array | number[]): boolean;
51
+ remove_peer(id: number): void;
52
+ /**
53
+ * Called (at most once per batch) when egress completions or page commands arrive.
54
+ */
55
+ set_notify(f?: Function | null): void;
56
+ set_unix_time(secs: number): void;
57
+ /**
58
+ * Gauges for leak and load checks: the stack's, the egress's, page connections, queued
59
+ * frames and the wasm memory size (bytes).
60
+ */
61
+ stats(): any;
62
+ /**
63
+ * Frames for the guest produced by the last polls.
64
+ */
65
+ take(): Array<any>;
66
+ /**
67
+ * Guest frames for peers: `[[peerId, Uint8Array], ...]`, to post to their Workers.
68
+ */
69
+ take_forwarded(): Array<any>;
70
+ }
71
+
72
+ /**
73
+ * Sends log records at `level` (`"error"`, `"warn"`, `"info"`, `"debug"`; default warn) and
74
+ * above to `f(level, text)`.
75
+ */
76
+ export function set_logger(f: Function, level?: string | null): void;
77
+
78
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
79
+
80
+ export interface InitOutput {
81
+ readonly memory: WebAssembly.Memory;
82
+ readonly __wbg_netpod_free: (a: number, b: number) => void;
83
+ readonly netpod_add_peer: (a: number, b: number, c: number, d: number, e: number) => void;
84
+ readonly netpod_ca_bundle: (a: number) => [number, number];
85
+ readonly netpod_ca_certificate: (a: number) => [number, number];
86
+ readonly netpod_delay: (a: number, b: number) => number;
87
+ readonly netpod_new: (a: any, b: number, c: number, d: number, e: number) => [number, number, number];
88
+ readonly netpod_open_inbound: (a: number, b: any) => void;
89
+ readonly netpod_poll: (a: number, b: number) => number;
90
+ readonly netpod_push: (a: number, b: number, c: number) => void;
91
+ readonly netpod_push_forwarded: (a: number, b: number, c: number) => number;
92
+ readonly netpod_remove_peer: (a: number, b: number) => void;
93
+ readonly netpod_set_notify: (a: number, b: number) => void;
94
+ readonly netpod_set_unix_time: (a: number, b: number) => void;
95
+ readonly netpod_stats: (a: number) => any;
96
+ readonly netpod_take: (a: number) => any;
97
+ readonly netpod_take_forwarded: (a: number) => any;
98
+ readonly set_logger: (a: any, b: number, c: number) => void;
99
+ readonly ring_core_0_17_14__bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
100
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke___wasm_bindgen_5a2380350bab5903___JsValue__core_6a51abefd5362b2___result__Result_____wasm_bindgen_5a2380350bab5903___JsError___true_: (a: number, b: number, c: any) => [number, number];
101
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke___wasm_bindgen_5a2380350bab5903___JsValue______true_: (a: number, b: number, c: any) => void;
102
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke___wasm_bindgen_5a2380350bab5903___JsValue__true_: (a: number, b: number) => any;
103
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
104
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
105
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
106
+ readonly __wbindgen_exn_store: (a: number) => void;
107
+ readonly __externref_table_alloc: () => number;
108
+ readonly __wbindgen_externrefs: WebAssembly.Table;
109
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
110
+ readonly __externref_table_dealloc: (a: number) => void;
111
+ readonly __wbindgen_start: () => void;
112
+ }
113
+
114
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
115
+
116
+ /**
117
+ * Instantiates the given `module`, which can either be bytes or
118
+ * a precompiled `WebAssembly.Module`.
119
+ *
120
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
121
+ *
122
+ * @returns {InitOutput}
123
+ */
124
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
125
+
126
+ /**
127
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
128
+ * for everything else, calls `WebAssembly.instantiate` directly.
129
+ *
130
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
131
+ *
132
+ * @returns {Promise<InitOutput>}
133
+ */
134
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;