@meshagent/meshagent 0.29.4 → 0.30.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/CHANGELOG.md +9 -0
- package/dist/browser/agent-client.js +3 -28
- package/dist/browser/agent.js +6 -6
- package/dist/browser/containers-client.d.ts +125 -0
- package/dist/browser/containers-client.js +458 -0
- package/dist/browser/database-client.d.ts +42 -6
- package/dist/browser/database-client.js +610 -77
- package/dist/browser/developer-client.d.ts +2 -2
- package/dist/browser/developer-client.js +60 -15
- package/dist/browser/helpers.js +4 -3
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/lk-client.js +12 -3
- package/dist/browser/meshagent-client.d.ts +5 -0
- package/dist/browser/messaging-client.d.ts +1 -0
- package/dist/browser/messaging-client.js +52 -8
- package/dist/browser/queues-client.d.ts +2 -0
- package/dist/browser/queues-client.js +34 -7
- package/dist/browser/response.d.ts +28 -0
- package/dist/browser/response.js +76 -1
- package/dist/browser/room-client.d.ts +43 -1
- package/dist/browser/room-client.js +204 -0
- package/dist/browser/secrets-client.d.ts +1 -0
- package/dist/browser/secrets-client.js +32 -27
- package/dist/browser/storage-client.d.ts +22 -7
- package/dist/browser/storage-client.js +353 -15
- package/dist/browser/sync-client.d.ts +12 -13
- package/dist/browser/sync-client.js +263 -65
- package/dist/esm/agent-client.js +3 -28
- package/dist/esm/agent.js +6 -6
- package/dist/esm/containers-client.d.ts +125 -0
- package/dist/esm/containers-client.js +453 -0
- package/dist/esm/database-client.d.ts +42 -6
- package/dist/esm/database-client.js +611 -78
- package/dist/esm/developer-client.d.ts +2 -2
- package/dist/esm/developer-client.js +61 -16
- package/dist/esm/helpers.js +4 -3
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/lk-client.js +12 -3
- package/dist/esm/meshagent-client.d.ts +5 -0
- package/dist/esm/messaging-client.d.ts +1 -0
- package/dist/esm/messaging-client.js +52 -8
- package/dist/esm/queues-client.d.ts +2 -0
- package/dist/esm/queues-client.js +35 -8
- package/dist/esm/response.d.ts +28 -0
- package/dist/esm/response.js +73 -0
- package/dist/esm/room-client.d.ts +43 -1
- package/dist/esm/room-client.js +207 -3
- package/dist/esm/secrets-client.d.ts +1 -0
- package/dist/esm/secrets-client.js +33 -28
- package/dist/esm/storage-client.d.ts +22 -7
- package/dist/esm/storage-client.js +353 -15
- package/dist/esm/sync-client.d.ts +12 -13
- package/dist/esm/sync-client.js +263 -64
- package/dist/node/agent-client.js +3 -28
- package/dist/node/agent.js +6 -6
- package/dist/node/containers-client.d.ts +125 -0
- package/dist/node/containers-client.js +458 -0
- package/dist/node/database-client.d.ts +42 -6
- package/dist/node/database-client.js +610 -77
- package/dist/node/developer-client.d.ts +2 -2
- package/dist/node/developer-client.js +60 -15
- package/dist/node/helpers.js +4 -3
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/lk-client.js +12 -3
- package/dist/node/meshagent-client.d.ts +5 -0
- package/dist/node/messaging-client.d.ts +1 -0
- package/dist/node/messaging-client.js +52 -8
- package/dist/node/queues-client.d.ts +2 -0
- package/dist/node/queues-client.js +34 -7
- package/dist/node/response.d.ts +28 -0
- package/dist/node/response.js +76 -1
- package/dist/node/room-client.d.ts +43 -1
- package/dist/node/room-client.js +204 -0
- package/dist/node/secrets-client.d.ts +1 -0
- package/dist/node/secrets-client.js +32 -27
- package/dist/node/storage-client.d.ts +22 -7
- package/dist/node/storage-client.js +353 -15
- package/dist/node/sync-client.d.ts +12 -13
- package/dist/node/sync-client.js +263 -65
- package/package.json +1 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { FileDeletedEvent, FileUpdatedEvent } from "./room-event";
|
|
2
|
+
import { BinaryContent, ControlContent, ErrorContent, JsonContent, FileContent } from "./response";
|
|
2
3
|
import { unpackMessage } from "./utils";
|
|
3
4
|
import { EventEmitter } from "./event-emitter";
|
|
5
|
+
import { RoomServerException } from "./room-server-client";
|
|
4
6
|
export class FileHandle {
|
|
5
7
|
constructor({ id }) {
|
|
6
8
|
this.id = id;
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
11
|
class StorageEntry {
|
|
10
|
-
constructor({ name, isFolder }) {
|
|
12
|
+
constructor({ name, isFolder, size = null }) {
|
|
11
13
|
this.name = name;
|
|
12
14
|
this.isFolder = isFolder;
|
|
15
|
+
this.size = size;
|
|
13
16
|
}
|
|
14
17
|
nameWithoutExtension() {
|
|
15
18
|
const segments = this.name
|
|
@@ -39,41 +42,376 @@ export class StorageClient extends EventEmitter {
|
|
|
39
42
|
this.client.emit(event);
|
|
40
43
|
this.emit('file.deleted', event);
|
|
41
44
|
}
|
|
45
|
+
_unexpectedResponseError(operation) {
|
|
46
|
+
return new RoomServerException(`unexpected return type from storage.${operation}`);
|
|
47
|
+
}
|
|
48
|
+
async _invoke(operation, input, callerContext) {
|
|
49
|
+
return await this.client.invoke({
|
|
50
|
+
toolkit: "storage",
|
|
51
|
+
tool: operation,
|
|
52
|
+
input,
|
|
53
|
+
callerContext,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
42
56
|
async list(path) {
|
|
43
|
-
const response =
|
|
57
|
+
const response = await this._invoke("list", { path });
|
|
58
|
+
if (!(response instanceof JsonContent)) {
|
|
59
|
+
throw this._unexpectedResponseError("list");
|
|
60
|
+
}
|
|
44
61
|
const files = response.json["files"];
|
|
45
62
|
const entries = files.map((f) => {
|
|
46
63
|
return new StorageEntry({
|
|
47
64
|
name: f["name"],
|
|
48
65
|
isFolder: f["is_folder"],
|
|
66
|
+
size: typeof f["size"] === "number" ? f["size"] : null,
|
|
49
67
|
});
|
|
50
68
|
});
|
|
51
69
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
52
70
|
return entries;
|
|
53
71
|
}
|
|
54
72
|
async delete(path) {
|
|
55
|
-
await this.
|
|
56
|
-
}
|
|
57
|
-
async open(path, { overwrite = false }) {
|
|
58
|
-
const response = (await this.client.sendRequest("storage.open", { path, overwrite }));
|
|
59
|
-
return new FileHandle({ id: response.json["handle"] });
|
|
73
|
+
await this._invoke("delete", { path, recursive: null });
|
|
60
74
|
}
|
|
61
75
|
async exists(path) {
|
|
62
|
-
const result =
|
|
76
|
+
const result = await this._invoke("exists", { path });
|
|
77
|
+
if (!(result instanceof JsonContent)) {
|
|
78
|
+
throw this._unexpectedResponseError("exists");
|
|
79
|
+
}
|
|
63
80
|
return result.json["exists"];
|
|
64
81
|
}
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
_defaultUploadName(path, name) {
|
|
83
|
+
if (typeof name === "string" && name.length > 0) {
|
|
84
|
+
return name;
|
|
85
|
+
}
|
|
86
|
+
const segments = path.split("/").filter((segment) => segment.length > 0);
|
|
87
|
+
const lastSegment = segments.length > 0 ? segments[segments.length - 1] : undefined;
|
|
88
|
+
return lastSegment ?? path;
|
|
67
89
|
}
|
|
68
|
-
async
|
|
69
|
-
|
|
90
|
+
async upload(path, bytes, { overwrite = false, name, mimeType = null, } = {}) {
|
|
91
|
+
async function* singleChunk() {
|
|
92
|
+
yield bytes;
|
|
93
|
+
}
|
|
94
|
+
await this.uploadStream(path, singleChunk(), {
|
|
95
|
+
overwrite,
|
|
96
|
+
size: bytes.length,
|
|
97
|
+
name,
|
|
98
|
+
mimeType,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async uploadStream(path, chunks, { overwrite = false, chunkSize = 64 * 1024, size = null, name, mimeType = null, } = {}) {
|
|
102
|
+
const resolvedName = this._defaultUploadName(path, name);
|
|
103
|
+
const input = new _StorageUploadInputStream({
|
|
104
|
+
path,
|
|
105
|
+
overwrite,
|
|
106
|
+
chunks,
|
|
107
|
+
chunkSize,
|
|
108
|
+
size,
|
|
109
|
+
name: resolvedName,
|
|
110
|
+
mimeType,
|
|
111
|
+
});
|
|
112
|
+
const response = await this.client.invokeStream({
|
|
113
|
+
toolkit: "storage",
|
|
114
|
+
tool: "upload",
|
|
115
|
+
input: input.stream(),
|
|
116
|
+
});
|
|
117
|
+
try {
|
|
118
|
+
for await (const chunk of response) {
|
|
119
|
+
if (chunk instanceof ErrorContent) {
|
|
120
|
+
throw new RoomServerException(chunk.text, chunk.code);
|
|
121
|
+
}
|
|
122
|
+
if (chunk instanceof ControlContent) {
|
|
123
|
+
if (chunk.method === "close") {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
throw this._unexpectedResponseError("upload");
|
|
127
|
+
}
|
|
128
|
+
if (!(chunk instanceof BinaryContent)) {
|
|
129
|
+
throw this._unexpectedResponseError("upload");
|
|
130
|
+
}
|
|
131
|
+
if (chunk.headers["kind"] !== "pull") {
|
|
132
|
+
throw this._unexpectedResponseError("upload");
|
|
133
|
+
}
|
|
134
|
+
input.requestNext();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
input.close();
|
|
139
|
+
}
|
|
70
140
|
}
|
|
71
141
|
async download(path) {
|
|
72
|
-
const
|
|
73
|
-
|
|
142
|
+
const stream = await this.downloadStream(path);
|
|
143
|
+
let name = null;
|
|
144
|
+
let mimeType = null;
|
|
145
|
+
let expectedSize = null;
|
|
146
|
+
let bytesReceived = 0;
|
|
147
|
+
const parts = [];
|
|
148
|
+
for await (const chunk of stream) {
|
|
149
|
+
const kind = chunk.headers["kind"];
|
|
150
|
+
if (kind === "start") {
|
|
151
|
+
const chunkName = chunk.headers["name"];
|
|
152
|
+
const chunkMimeType = chunk.headers["mime_type"];
|
|
153
|
+
const chunkSizeValue = chunk.headers["size"];
|
|
154
|
+
if (typeof chunkName !== "string" ||
|
|
155
|
+
typeof chunkMimeType !== "string" ||
|
|
156
|
+
typeof chunkSizeValue !== "number" ||
|
|
157
|
+
chunkSizeValue < 0) {
|
|
158
|
+
throw this._unexpectedResponseError("download");
|
|
159
|
+
}
|
|
160
|
+
name = chunkName;
|
|
161
|
+
mimeType = chunkMimeType;
|
|
162
|
+
expectedSize = chunkSizeValue;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (kind !== "data") {
|
|
166
|
+
throw this._unexpectedResponseError("download");
|
|
167
|
+
}
|
|
168
|
+
parts.push(chunk.data);
|
|
169
|
+
bytesReceived += chunk.data.length;
|
|
170
|
+
}
|
|
171
|
+
if (name == null || mimeType == null || expectedSize == null || bytesReceived !== expectedSize) {
|
|
172
|
+
throw this._unexpectedResponseError("download");
|
|
173
|
+
}
|
|
174
|
+
const totalLength = parts.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
175
|
+
const data = new Uint8Array(totalLength);
|
|
176
|
+
let offset = 0;
|
|
177
|
+
for (const part of parts) {
|
|
178
|
+
data.set(part, offset);
|
|
179
|
+
offset += part.length;
|
|
180
|
+
}
|
|
181
|
+
return new FileContent({ data, name, mimeType });
|
|
182
|
+
}
|
|
183
|
+
async downloadStream(path, { chunkSize = 64 * 1024, } = {}) {
|
|
184
|
+
const input = new _StorageDownloadInputStream({ path, chunkSize });
|
|
185
|
+
const response = await this.client.invokeStream({
|
|
186
|
+
toolkit: "storage",
|
|
187
|
+
tool: "download",
|
|
188
|
+
input: input.stream(),
|
|
189
|
+
});
|
|
190
|
+
const self = this;
|
|
191
|
+
return {
|
|
192
|
+
async *[Symbol.asyncIterator]() {
|
|
193
|
+
let metadataReceived = false;
|
|
194
|
+
let expectedSize = null;
|
|
195
|
+
let bytesReceived = 0;
|
|
196
|
+
try {
|
|
197
|
+
for await (const chunk of response) {
|
|
198
|
+
if (chunk instanceof ErrorContent) {
|
|
199
|
+
throw new RoomServerException(chunk.text, chunk.code);
|
|
200
|
+
}
|
|
201
|
+
if (chunk instanceof ControlContent) {
|
|
202
|
+
if (chunk.method === "close") {
|
|
203
|
+
if (!metadataReceived || expectedSize == null || bytesReceived !== expectedSize) {
|
|
204
|
+
throw self._unexpectedResponseError("download");
|
|
205
|
+
}
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
throw self._unexpectedResponseError("download");
|
|
209
|
+
}
|
|
210
|
+
if (!(chunk instanceof BinaryContent)) {
|
|
211
|
+
throw self._unexpectedResponseError("download");
|
|
212
|
+
}
|
|
213
|
+
const kind = chunk.headers["kind"];
|
|
214
|
+
if (kind === "start") {
|
|
215
|
+
if (metadataReceived) {
|
|
216
|
+
throw self._unexpectedResponseError("download");
|
|
217
|
+
}
|
|
218
|
+
const chunkName = chunk.headers["name"];
|
|
219
|
+
const chunkMimeType = chunk.headers["mime_type"];
|
|
220
|
+
const chunkSizeValue = chunk.headers["size"];
|
|
221
|
+
if (typeof chunkName !== "string" ||
|
|
222
|
+
typeof chunkMimeType !== "string" ||
|
|
223
|
+
typeof chunkSizeValue !== "number" ||
|
|
224
|
+
chunkSizeValue < 0) {
|
|
225
|
+
throw self._unexpectedResponseError("download");
|
|
226
|
+
}
|
|
227
|
+
metadataReceived = true;
|
|
228
|
+
expectedSize = chunkSizeValue;
|
|
229
|
+
yield chunk;
|
|
230
|
+
if (expectedSize > 0) {
|
|
231
|
+
input.requestNext();
|
|
232
|
+
}
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (kind !== "data" || !metadataReceived || expectedSize == null) {
|
|
236
|
+
throw self._unexpectedResponseError("download");
|
|
237
|
+
}
|
|
238
|
+
bytesReceived += chunk.data.length;
|
|
239
|
+
if (bytesReceived > expectedSize) {
|
|
240
|
+
throw self._unexpectedResponseError("download");
|
|
241
|
+
}
|
|
242
|
+
yield chunk;
|
|
243
|
+
if (bytesReceived < expectedSize) {
|
|
244
|
+
input.requestNext();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
input.close();
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
};
|
|
74
253
|
}
|
|
75
254
|
async downloadUrl(path) {
|
|
76
|
-
const response =
|
|
255
|
+
const response = await this._invoke("download_url", { path });
|
|
256
|
+
if (!(response instanceof JsonContent)) {
|
|
257
|
+
throw this._unexpectedResponseError("download_url");
|
|
258
|
+
}
|
|
77
259
|
return response.json["url"];
|
|
78
260
|
}
|
|
79
261
|
}
|
|
262
|
+
class _StorageDownloadInputStream {
|
|
263
|
+
constructor({ path, chunkSize }) {
|
|
264
|
+
this.closed = false;
|
|
265
|
+
this.pendingPulls = 0;
|
|
266
|
+
this.waitingResolver = null;
|
|
267
|
+
this.path = path;
|
|
268
|
+
this.chunkSize = chunkSize;
|
|
269
|
+
}
|
|
270
|
+
requestNext() {
|
|
271
|
+
if (this.closed) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.pendingPulls += 1;
|
|
275
|
+
if (this.waitingResolver) {
|
|
276
|
+
const resolver = this.waitingResolver;
|
|
277
|
+
this.waitingResolver = null;
|
|
278
|
+
resolver();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
close() {
|
|
282
|
+
if (this.closed) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.closed = true;
|
|
286
|
+
if (this.waitingResolver) {
|
|
287
|
+
const resolver = this.waitingResolver;
|
|
288
|
+
this.waitingResolver = null;
|
|
289
|
+
resolver();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async *stream() {
|
|
293
|
+
yield new BinaryContent({
|
|
294
|
+
data: new Uint8Array(0),
|
|
295
|
+
headers: {
|
|
296
|
+
kind: "start",
|
|
297
|
+
path: this.path,
|
|
298
|
+
chunk_size: this.chunkSize,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
while (!this.closed) {
|
|
302
|
+
if (this.pendingPulls === 0) {
|
|
303
|
+
await new Promise((resolve) => {
|
|
304
|
+
this.waitingResolver = resolve;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (this.closed) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (this.pendingPulls === 0) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
this.pendingPulls -= 1;
|
|
314
|
+
yield new BinaryContent({
|
|
315
|
+
data: new Uint8Array(0),
|
|
316
|
+
headers: { kind: "pull" },
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
class _StorageUploadInputStream {
|
|
322
|
+
constructor({ path, overwrite, chunks, chunkSize, size, name, mimeType, }) {
|
|
323
|
+
this.closed = false;
|
|
324
|
+
this.pendingPulls = 0;
|
|
325
|
+
this.waitingResolver = null;
|
|
326
|
+
this.pendingChunk = new Uint8Array(0);
|
|
327
|
+
this.pendingOffset = 0;
|
|
328
|
+
this.sourceExhausted = false;
|
|
329
|
+
this.path = path;
|
|
330
|
+
this.overwrite = overwrite;
|
|
331
|
+
this.source = chunks[Symbol.asyncIterator]();
|
|
332
|
+
this.chunkSize = chunkSize;
|
|
333
|
+
this.size = size;
|
|
334
|
+
this.name = name;
|
|
335
|
+
this.mimeType = mimeType;
|
|
336
|
+
}
|
|
337
|
+
requestNext() {
|
|
338
|
+
if (this.closed) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
this.pendingPulls += 1;
|
|
342
|
+
if (this.waitingResolver) {
|
|
343
|
+
const resolver = this.waitingResolver;
|
|
344
|
+
this.waitingResolver = null;
|
|
345
|
+
resolver();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
close() {
|
|
349
|
+
if (this.closed) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this.closed = true;
|
|
353
|
+
if (this.waitingResolver) {
|
|
354
|
+
const resolver = this.waitingResolver;
|
|
355
|
+
this.waitingResolver = null;
|
|
356
|
+
resolver();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
async nextChunk() {
|
|
360
|
+
while (true) {
|
|
361
|
+
if (this.pendingOffset < this.pendingChunk.length) {
|
|
362
|
+
const start = this.pendingOffset;
|
|
363
|
+
const end = Math.min(start + this.chunkSize, this.pendingChunk.length);
|
|
364
|
+
this.pendingOffset = end;
|
|
365
|
+
return this.pendingChunk.slice(start, end);
|
|
366
|
+
}
|
|
367
|
+
if (this.sourceExhausted) {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
const next = await this.source.next();
|
|
371
|
+
if (next.done) {
|
|
372
|
+
this.sourceExhausted = true;
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
if (next.value.length === 0) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
this.pendingChunk = next.value;
|
|
379
|
+
this.pendingOffset = 0;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
async *stream() {
|
|
383
|
+
yield new BinaryContent({
|
|
384
|
+
data: new Uint8Array(0),
|
|
385
|
+
headers: {
|
|
386
|
+
kind: "start",
|
|
387
|
+
path: this.path,
|
|
388
|
+
overwrite: this.overwrite,
|
|
389
|
+
name: this.name,
|
|
390
|
+
mime_type: this.mimeType,
|
|
391
|
+
size: this.size,
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
while (!this.closed) {
|
|
395
|
+
if (this.pendingPulls === 0) {
|
|
396
|
+
await new Promise((resolve) => {
|
|
397
|
+
this.waitingResolver = resolve;
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (this.closed) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (this.pendingPulls === 0) {
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
this.pendingPulls -= 1;
|
|
407
|
+
const chunk = await this.nextChunk();
|
|
408
|
+
if (chunk == null) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
yield new BinaryContent({
|
|
412
|
+
data: chunk,
|
|
413
|
+
headers: { kind: "data" },
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { EventEmitter } from "./event-emitter";
|
|
2
2
|
import { RoomClient } from "./room-client";
|
|
3
|
+
import { MeshSchema } from "./schema";
|
|
3
4
|
import { MeshDocument } from "./room-server-client";
|
|
4
5
|
export interface SyncClientEvent {
|
|
5
6
|
type: string;
|
|
6
|
-
doc
|
|
7
|
-
|
|
8
|
-
export declare class QueuedSync {
|
|
9
|
-
path: string;
|
|
10
|
-
base64: string;
|
|
11
|
-
constructor({ path, base64 }: {
|
|
12
|
-
path: string;
|
|
13
|
-
base64: string;
|
|
14
|
-
});
|
|
7
|
+
doc?: MeshDocument;
|
|
8
|
+
status?: unknown;
|
|
15
9
|
}
|
|
16
10
|
export declare class SyncClient extends EventEmitter<SyncClientEvent> {
|
|
17
|
-
private client;
|
|
11
|
+
private readonly client;
|
|
18
12
|
private _connectingDocuments;
|
|
19
|
-
private _changesToSync;
|
|
20
13
|
private _connectedDocuments;
|
|
14
|
+
private _documentStreams;
|
|
21
15
|
constructor({ room }: {
|
|
22
16
|
room: RoomClient;
|
|
23
17
|
});
|
|
18
|
+
private _unexpectedResponseError;
|
|
19
|
+
private _invoke;
|
|
24
20
|
start({ onDone, onError }?: {
|
|
25
21
|
onDone?: () => void;
|
|
26
22
|
onError?: (error: Error) => void;
|
|
27
23
|
}): void;
|
|
28
24
|
dispose(): void;
|
|
29
|
-
private
|
|
25
|
+
private _applySyncPayload;
|
|
30
26
|
private _handleStatus;
|
|
31
27
|
create(path: string, json?: Record<string, any>): Promise<void>;
|
|
32
|
-
open(path: string, { create }?: {
|
|
28
|
+
open(path: string, { create, initialJson, schema, }?: {
|
|
33
29
|
create?: boolean;
|
|
30
|
+
initialJson?: Record<string, any>;
|
|
31
|
+
schema?: MeshSchema;
|
|
34
32
|
}): Promise<MeshDocument>;
|
|
35
33
|
close(path: string): Promise<void>;
|
|
36
34
|
sync(path: string, data: Uint8Array): Promise<void>;
|
|
35
|
+
private _consumeOpenStream;
|
|
37
36
|
}
|