@sandvichxyz/teamtype-wasm 0.9.2-dev

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/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@sandvichxyz/teamtype-wasm",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Moritz Neeb <nt4u@kpvn.de>",
6
+ "blinry <mail@blinry.org>",
7
+ "Caleb Maclennan <caleb@alerque.com>",
8
+ "HumanoidSandvichDispenser <humanoidsandvichdispenser@gmail.com>"
9
+ ],
10
+ "description": "Browser/wasm peer for Teamtype, exposing the sync core over a JavaScript API.",
11
+ "version": "0.9.2-dev",
12
+ "license": "AGPL-3.0-or-later",
13
+ "files": [
14
+ "teamtype_wasm_bg.wasm",
15
+ "teamtype_wasm.js",
16
+ "teamtype_wasm.d.ts"
17
+ ],
18
+ "main": "teamtype_wasm.js",
19
+ "types": "teamtype_wasm.d.ts",
20
+ "sideEffects": [
21
+ "./snippets/*"
22
+ ]
23
+ }
@@ -0,0 +1,217 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * The `ReadableStreamType` enum.
5
+ *
6
+ * *This API requires the following crate features to be activated: `ReadableStreamType`*
7
+ */
8
+
9
+ export type ReadableStreamType = "bytes";
10
+ /**
11
+ * Info about our own node, surfaced to JS via `nodeInfo()`.
12
+ */
13
+ export interface NodeInfo {
14
+ node_id: string;
15
+ passphrase: string;
16
+ }
17
+
18
+ export interface CursorState {
19
+ name: string | undefined;
20
+ file_path: string;
21
+ ranges: Range[];
22
+ }
23
+
24
+ export interface EphemeralMessage {
25
+ cursor_id: string;
26
+ sequence_number: number;
27
+ cursor_state: CursorState;
28
+ }
29
+
30
+ export interface Position {
31
+ line: number;
32
+ character: number;
33
+ }
34
+
35
+ export interface Range {
36
+ start: Position;
37
+ end: Position;
38
+ }
39
+
40
+ export type DisconnectReason = { kind: "PeerDisconnected" } | { kind: "ReceiveError"; error: string } | { kind: "HandlerError"; error: string };
41
+
42
+ export type WireDelta = WireOp[];
43
+
44
+ export type WireOp = { Retain: number } | { Insert: string } | { Delete: number };
45
+
46
+
47
+ export class IntoUnderlyingByteSource {
48
+ private constructor();
49
+ free(): void;
50
+ [Symbol.dispose](): void;
51
+ cancel(): void;
52
+ pull(controller: ReadableByteStreamController): Promise<any>;
53
+ start(controller: ReadableByteStreamController): void;
54
+ readonly autoAllocateChunkSize: number;
55
+ readonly type: ReadableStreamType;
56
+ }
57
+
58
+ export class IntoUnderlyingSink {
59
+ private constructor();
60
+ free(): void;
61
+ [Symbol.dispose](): void;
62
+ abort(reason: any): Promise<any>;
63
+ close(): Promise<any>;
64
+ write(chunk: any): Promise<any>;
65
+ }
66
+
67
+ export class IntoUnderlyingSource {
68
+ private constructor();
69
+ free(): void;
70
+ [Symbol.dispose](): void;
71
+ cancel(): void;
72
+ pull(controller: ReadableStreamDefaultController): Promise<any>;
73
+ }
74
+
75
+ /**
76
+ * Browser-side Teamtype peer. Owns the command channels and spawns the three
77
+ * services (node, connection, document) on construction.
78
+ */
79
+ export class TeamtypeClient {
80
+ free(): void;
81
+ [Symbol.dispose](): void;
82
+ /**
83
+ * Apply an edit to a file.
84
+ */
85
+ applyEdit(file_name: string, delta: any): void;
86
+ /**
87
+ * Connect to a peer using a wormhole join code.
88
+ */
89
+ connectByJoinCode(join_code: string): void;
90
+ /**
91
+ * Bind an iroh endpoint and start the service tasks.
92
+ */
93
+ constructor();
94
+ /**
95
+ * Gets our own node info (`{ nodeId, passphrase }`), or `null` until ready.
96
+ */
97
+ nodeInfo(): any;
98
+ /**
99
+ * Register `disconnect(reason: DisconnectReason)`.
100
+ */
101
+ onDisconnect(callback: Function): void;
102
+ /**
103
+ * Register `onEdit(fileName: string, delta)`.
104
+ */
105
+ onEdit(callback: Function): void;
106
+ /**
107
+ * Register `onEphemeral(message: EphemeralMessage)`.
108
+ */
109
+ onEphemeral(callback: Function): void;
110
+ /**
111
+ * Register `onEphemeralRemoved(cursorId: string)`.
112
+ */
113
+ onEphemeralRemoved(callback: Function): void;
114
+ /**
115
+ * Register `onFileContent(fileName: string, content: string)`.
116
+ */
117
+ onFileContent(callback: Function): void;
118
+ /**
119
+ * Register `onFiles(files: string[])`.
120
+ */
121
+ onFiles(callback: Function): void;
122
+ /**
123
+ * Register `onLog(message: string)`.
124
+ */
125
+ onLog(callback: Function): void;
126
+ /**
127
+ * Register `onPeers(peers: string[])`.
128
+ */
129
+ onPeers(callback: Function): void;
130
+ /**
131
+ * Request the content of a file. The result will be returned asynchronously through
132
+ * `onFileContent` callback.
133
+ */
134
+ selectFile(file_name: string): void;
135
+ /**
136
+ * Broadcast cursor.
137
+ */
138
+ setCursor(file_name: string, ranges: any): void;
139
+ /**
140
+ * Set our display name.
141
+ */
142
+ setName(name: string): void;
143
+ }
144
+
145
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
146
+
147
+ export interface InitOutput {
148
+ readonly memory: WebAssembly.Memory;
149
+ readonly __wbg_teamtypeclient_free: (a: number, b: number) => void;
150
+ readonly teamtypeclient_applyEdit: (a: number, b: number, c: number, d: any) => void;
151
+ readonly teamtypeclient_connectByJoinCode: (a: number, b: number, c: number) => void;
152
+ readonly teamtypeclient_new: () => number;
153
+ readonly teamtypeclient_nodeInfo: (a: number) => any;
154
+ readonly teamtypeclient_onDisconnect: (a: number, b: any) => void;
155
+ readonly teamtypeclient_onEdit: (a: number, b: any) => void;
156
+ readonly teamtypeclient_onEphemeral: (a: number, b: any) => void;
157
+ readonly teamtypeclient_onEphemeralRemoved: (a: number, b: any) => void;
158
+ readonly teamtypeclient_onFileContent: (a: number, b: any) => void;
159
+ readonly teamtypeclient_onFiles: (a: number, b: any) => void;
160
+ readonly teamtypeclient_onLog: (a: number, b: any) => void;
161
+ readonly teamtypeclient_onPeers: (a: number, b: any) => void;
162
+ readonly teamtypeclient_selectFile: (a: number, b: number, c: number) => void;
163
+ readonly teamtypeclient_setCursor: (a: number, b: number, c: number, d: any) => void;
164
+ readonly teamtypeclient_setName: (a: number, b: number, c: number) => void;
165
+ readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
166
+ readonly intounderlyingsource_cancel: (a: number) => void;
167
+ readonly intounderlyingsource_pull: (a: number, b: any) => any;
168
+ readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
169
+ readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
170
+ readonly intounderlyingbytesource_cancel: (a: number) => void;
171
+ readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
172
+ readonly intounderlyingbytesource_start: (a: number, b: any) => void;
173
+ readonly intounderlyingbytesource_type: (a: number) => number;
174
+ readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
175
+ readonly intounderlyingsink_abort: (a: number, b: any) => any;
176
+ readonly intounderlyingsink_close: (a: number) => any;
177
+ readonly intounderlyingsink_write: (a: number, b: any) => any;
178
+ readonly ring_core_0_17_14__bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
179
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke___wasm_bindgen_a1427d1cfc54b76a___JsValue__core_c09542a5c46f04b6___result__Result_____wasm_bindgen_a1427d1cfc54b76a___JsError___true_: (a: number, b: number, c: any) => [number, number];
180
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke___js_sys_bee433b15c647e3e___Function_fn_wasm_bindgen_a1427d1cfc54b76a___JsValue_____wasm_bindgen_a1427d1cfc54b76a___sys__Undefined___js_sys_bee433b15c647e3e___Function_fn_wasm_bindgen_a1427d1cfc54b76a___JsValue_____wasm_bindgen_a1427d1cfc54b76a___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
181
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke___wasm_bindgen_a1427d1cfc54b76a___JsValue______true_: (a: number, b: number, c: any) => void;
182
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke___web_sys_9299a82c88baa8d___features__gen_CloseEvent__CloseEvent______true_: (a: number, b: number, c: any) => void;
183
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke___web_sys_9299a82c88baa8d___features__gen_MessageEvent__MessageEvent______true_: (a: number, b: number, c: any) => void;
184
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke_______true_: (a: number, b: number) => void;
185
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke_______true__1_: (a: number, b: number) => void;
186
+ readonly wasm_bindgen_a1427d1cfc54b76a___convert__closures_____invoke_______true__2_: (a: number, b: number) => void;
187
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
188
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
189
+ readonly __wbindgen_exn_store: (a: number) => void;
190
+ readonly __externref_table_alloc: () => number;
191
+ readonly __wbindgen_externrefs: WebAssembly.Table;
192
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
193
+ readonly __externref_table_dealloc: (a: number) => void;
194
+ readonly __wbindgen_start: () => void;
195
+ }
196
+
197
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
198
+
199
+ /**
200
+ * Instantiates the given `module`, which can either be bytes or
201
+ * a precompiled `WebAssembly.Module`.
202
+ *
203
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
204
+ *
205
+ * @returns {InitOutput}
206
+ */
207
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
208
+
209
+ /**
210
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
211
+ * for everything else, calls `WebAssembly.instantiate` directly.
212
+ *
213
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
214
+ *
215
+ * @returns {Promise<InitOutput>}
216
+ */
217
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;