@liveblocks/core 3.23.0-exp2 → 3.23.0-file2
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/dist/index.cjs +7331 -8346
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +420 -660
- package/dist/index.d.ts +420 -660
- package/dist/index.js +7208 -8223
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -217,143 +217,6 @@ type BaseUserMeta = {
|
|
|
217
217
|
info?: IUserInfo;
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
-
type RenameDataField<T, TFieldName extends string> = T extends any ? {
|
|
221
|
-
[K in keyof T as K extends "data" ? TFieldName : K]: T[K];
|
|
222
|
-
} : never;
|
|
223
|
-
type AsyncLoading<F extends string = "data"> = RenameDataField<{
|
|
224
|
-
readonly isLoading: true;
|
|
225
|
-
readonly data?: never;
|
|
226
|
-
readonly error?: never;
|
|
227
|
-
}, F>;
|
|
228
|
-
type AsyncSuccess<T, F extends string = "data"> = RenameDataField<{
|
|
229
|
-
readonly isLoading: false;
|
|
230
|
-
readonly data: T;
|
|
231
|
-
readonly error?: never;
|
|
232
|
-
}, F>;
|
|
233
|
-
type AsyncError<F extends string = "data"> = RenameDataField<{
|
|
234
|
-
readonly isLoading: false;
|
|
235
|
-
readonly data?: never;
|
|
236
|
-
readonly error: Error;
|
|
237
|
-
}, F>;
|
|
238
|
-
type AsyncResult<T, F extends string = "data"> = AsyncLoading<F> | AsyncSuccess<T, F> | AsyncError<F>;
|
|
239
|
-
|
|
240
|
-
type Callback<T> = (event: T) => void;
|
|
241
|
-
type UnsubscribeCallback = () => void;
|
|
242
|
-
type Observable<T> = {
|
|
243
|
-
/**
|
|
244
|
-
* Register a callback function to be called whenever the event source emits
|
|
245
|
-
* an event.
|
|
246
|
-
*/
|
|
247
|
-
subscribe(callback: Callback<T>): UnsubscribeCallback;
|
|
248
|
-
/**
|
|
249
|
-
* Register a one-time callback function to be called whenever the event
|
|
250
|
-
* source emits an event. After the event fires, the callback is
|
|
251
|
-
* auto-unsubscribed.
|
|
252
|
-
*/
|
|
253
|
-
subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
|
|
254
|
-
/**
|
|
255
|
-
* Returns a promise that will resolve when an event is emitted by this
|
|
256
|
-
* event source. Optionally, specify a predicate that has to match. The first
|
|
257
|
-
* event matching that predicate will then resolve the promise.
|
|
258
|
-
*/
|
|
259
|
-
waitUntil(predicate?: (event: T) => boolean): Promise<T>;
|
|
260
|
-
};
|
|
261
|
-
type EventSource<T> = Observable<T> & {
|
|
262
|
-
/**
|
|
263
|
-
* Notify all subscribers about the event. Will return `false` if there
|
|
264
|
-
* weren't any subscribers at the time the .notify() was called, or `true` if
|
|
265
|
-
* there was at least one subscriber.
|
|
266
|
-
*/
|
|
267
|
-
notify(event: T): boolean;
|
|
268
|
-
/**
|
|
269
|
-
* Returns the number of active subscribers.
|
|
270
|
-
*/
|
|
271
|
-
count(): number;
|
|
272
|
-
/**
|
|
273
|
-
* Observable instance, which can be used to subscribe to this event source
|
|
274
|
-
* in a readonly fashion. Safe to publicly expose.
|
|
275
|
-
*/
|
|
276
|
-
observable: Observable<T>;
|
|
277
|
-
/**
|
|
278
|
-
* Disposes of this event source.
|
|
279
|
-
*
|
|
280
|
-
* Will clears all registered event listeners. None of the registered
|
|
281
|
-
* functions will ever get called again.
|
|
282
|
-
*
|
|
283
|
-
* WARNING!
|
|
284
|
-
* Be careful when using this API, because the subscribers may not have any
|
|
285
|
-
* idea they won't be notified anymore.
|
|
286
|
-
*/
|
|
287
|
-
dispose(): void;
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* makeEventSource allows you to generate a subscribe/notify pair of functions
|
|
291
|
-
* to make subscribing easy and to get notified about events.
|
|
292
|
-
*
|
|
293
|
-
* The events are anonymous, so you can use it to define events, like so:
|
|
294
|
-
*
|
|
295
|
-
* const event1 = makeEventSource();
|
|
296
|
-
* const event2 = makeEventSource();
|
|
297
|
-
*
|
|
298
|
-
* event1.subscribe(foo);
|
|
299
|
-
* event1.subscribe(bar);
|
|
300
|
-
* event2.subscribe(qux);
|
|
301
|
-
*
|
|
302
|
-
* // Unsubscription is pretty standard
|
|
303
|
-
* const unsub = event2.subscribe(foo);
|
|
304
|
-
* unsub();
|
|
305
|
-
*
|
|
306
|
-
* event1.notify(); // Now foo and bar will get called
|
|
307
|
-
* event2.notify(); // Now qux will get called (but foo will not, since it's unsubscribed)
|
|
308
|
-
*
|
|
309
|
-
*/
|
|
310
|
-
declare function makeEventSource<T>(): EventSource<T>;
|
|
311
|
-
|
|
312
|
-
type BatchStore<O, I> = {
|
|
313
|
-
subscribe: (callback: Callback<void>) => UnsubscribeCallback;
|
|
314
|
-
enqueue: (input: I) => Promise<void>;
|
|
315
|
-
setData: (entries: [I, O][]) => void;
|
|
316
|
-
getItemState: (input: I) => AsyncResult<O> | undefined;
|
|
317
|
-
getData: (input: I) => O | undefined;
|
|
318
|
-
invalidate: (inputs?: I[]) => void;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
type ContextualPromptResponse = Relax<{
|
|
322
|
-
type: "insert";
|
|
323
|
-
text: string;
|
|
324
|
-
} | {
|
|
325
|
-
type: "replace";
|
|
326
|
-
text: string;
|
|
327
|
-
} | {
|
|
328
|
-
type: "other";
|
|
329
|
-
text: string;
|
|
330
|
-
}>;
|
|
331
|
-
type ContextualPromptContext = {
|
|
332
|
-
beforeSelection: string;
|
|
333
|
-
selection: string;
|
|
334
|
-
afterSelection: string;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Use this symbol to brand an object property as internal.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* Object.defineProperty(
|
|
342
|
-
* {
|
|
343
|
-
* public,
|
|
344
|
-
* [kInternal]: {
|
|
345
|
-
* private
|
|
346
|
-
* },
|
|
347
|
-
* },
|
|
348
|
-
* kInternal,
|
|
349
|
-
* {
|
|
350
|
-
* enumerable: false,
|
|
351
|
-
* }
|
|
352
|
-
* );
|
|
353
|
-
*/
|
|
354
|
-
declare const kInternal: unique symbol;
|
|
355
|
-
declare const kStorageUpdateSource: unique symbol;
|
|
356
|
-
|
|
357
220
|
declare const brand: unique symbol;
|
|
358
221
|
type Brand<T, TBrand extends string> = T & {
|
|
359
222
|
[brand]: TBrand;
|
|
@@ -439,8 +302,7 @@ declare const OpCode: Readonly<{
|
|
|
439
302
|
DELETE_OBJECT_KEY: 6;
|
|
440
303
|
CREATE_MAP: 7;
|
|
441
304
|
CREATE_REGISTER: 8;
|
|
442
|
-
|
|
443
|
-
UPDATE_TEXT: 10;
|
|
305
|
+
CREATE_FILE: 11;
|
|
444
306
|
}>;
|
|
445
307
|
declare namespace OpCode {
|
|
446
308
|
type INIT = typeof OpCode.INIT;
|
|
@@ -452,48 +314,14 @@ declare namespace OpCode {
|
|
|
452
314
|
type DELETE_OBJECT_KEY = typeof OpCode.DELETE_OBJECT_KEY;
|
|
453
315
|
type CREATE_MAP = typeof OpCode.CREATE_MAP;
|
|
454
316
|
type CREATE_REGISTER = typeof OpCode.CREATE_REGISTER;
|
|
455
|
-
type
|
|
456
|
-
type UPDATE_TEXT = typeof OpCode.UPDATE_TEXT;
|
|
317
|
+
type CREATE_FILE = typeof OpCode.CREATE_FILE;
|
|
457
318
|
}
|
|
458
|
-
type TextAttributes = JsonObject;
|
|
459
|
-
/**
|
|
460
|
-
* A single segment in a {@link LiveTextData} document.
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* ["Hello world"]
|
|
464
|
-
* ["Hello ", { bold: true }]
|
|
465
|
-
*/
|
|
466
|
-
type LiveTextSegment = [text: string] | [text: string, attributes: TextAttributes];
|
|
467
|
-
/**
|
|
468
|
-
* Serialized form of a {@link LiveText} document: an ordered list of text
|
|
469
|
-
* segments with optional inline attributes.
|
|
470
|
-
*
|
|
471
|
-
* @example
|
|
472
|
-
* [["Hello world"]]
|
|
473
|
-
* [["Hello ", { bold: true }], ["world"]]
|
|
474
|
-
*/
|
|
475
|
-
type LiveTextData = LiveTextSegment[];
|
|
476
|
-
type TextOperation = {
|
|
477
|
-
type: "insert";
|
|
478
|
-
index: number;
|
|
479
|
-
text: string;
|
|
480
|
-
attributes?: TextAttributes;
|
|
481
|
-
} | {
|
|
482
|
-
type: "delete";
|
|
483
|
-
index: number;
|
|
484
|
-
length: number;
|
|
485
|
-
} | {
|
|
486
|
-
type: "format";
|
|
487
|
-
index: number;
|
|
488
|
-
length: number;
|
|
489
|
-
attributes: JsonObject;
|
|
490
|
-
};
|
|
491
319
|
/**
|
|
492
320
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
493
321
|
* only.
|
|
494
322
|
*/
|
|
495
|
-
type Op = CreateOp | UpdateObjectOp |
|
|
496
|
-
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp |
|
|
323
|
+
type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
|
|
324
|
+
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp | CreateFileOp;
|
|
497
325
|
type UpdateObjectOp = {
|
|
498
326
|
readonly opId?: string;
|
|
499
327
|
readonly id: string;
|
|
@@ -538,26 +366,16 @@ type CreateRegisterOp = {
|
|
|
538
366
|
readonly intent?: "set" | "push";
|
|
539
367
|
readonly deletedId?: string;
|
|
540
368
|
};
|
|
541
|
-
type
|
|
369
|
+
type CreateFileOp = {
|
|
542
370
|
readonly opId?: string;
|
|
543
371
|
readonly id: string;
|
|
544
|
-
readonly type: OpCode.
|
|
372
|
+
readonly type: OpCode.CREATE_FILE;
|
|
545
373
|
readonly parentId: string;
|
|
546
374
|
readonly parentKey: string;
|
|
547
|
-
readonly data:
|
|
548
|
-
readonly version: number;
|
|
375
|
+
readonly data: LiveFileData;
|
|
549
376
|
readonly intent?: "set" | "push";
|
|
550
377
|
readonly deletedId?: string;
|
|
551
378
|
};
|
|
552
|
-
type UpdateTextOp = {
|
|
553
|
-
readonly opId?: string;
|
|
554
|
-
readonly id: string;
|
|
555
|
-
readonly type: OpCode.UPDATE_TEXT;
|
|
556
|
-
readonly baseVersion: number;
|
|
557
|
-
readonly version?: number;
|
|
558
|
-
readonly ops: TextOperation[];
|
|
559
|
-
readonly metadata?: JsonObject;
|
|
560
|
-
};
|
|
561
379
|
type DeleteCrdtOp = {
|
|
562
380
|
readonly opId?: string;
|
|
563
381
|
readonly id: string;
|
|
@@ -600,6 +418,133 @@ type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
|
600
418
|
opId?: undefined;
|
|
601
419
|
};
|
|
602
420
|
|
|
421
|
+
type LiveListUpdateDelta = {
|
|
422
|
+
type: "insert";
|
|
423
|
+
index: number;
|
|
424
|
+
item: Lson;
|
|
425
|
+
} | {
|
|
426
|
+
type: "delete";
|
|
427
|
+
index: number;
|
|
428
|
+
deletedItem: Lson;
|
|
429
|
+
} | {
|
|
430
|
+
type: "move";
|
|
431
|
+
index: number;
|
|
432
|
+
previousIndex: number;
|
|
433
|
+
item: Lson;
|
|
434
|
+
} | {
|
|
435
|
+
type: "set";
|
|
436
|
+
index: number;
|
|
437
|
+
item: Lson;
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* A LiveList notification that is sent in-client to any subscribers whenever
|
|
441
|
+
* one or more of the items inside the LiveList instance have changed.
|
|
442
|
+
*/
|
|
443
|
+
type LiveListUpdates<TItem extends Lson> = {
|
|
444
|
+
type: "LiveList";
|
|
445
|
+
node: LiveList<TItem>;
|
|
446
|
+
updates: LiveListUpdateDelta[];
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* The LiveList class represents an ordered collection of items that is synchronized across clients.
|
|
450
|
+
*/
|
|
451
|
+
declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
452
|
+
#private;
|
|
453
|
+
constructor(items: TItem[]);
|
|
454
|
+
/**
|
|
455
|
+
* Returns the number of elements.
|
|
456
|
+
*/
|
|
457
|
+
get length(): number;
|
|
458
|
+
/**
|
|
459
|
+
* Adds one element to the end of the LiveList.
|
|
460
|
+
* @param element The element to add to the end of the LiveList.
|
|
461
|
+
*/
|
|
462
|
+
push(element: TItem): void;
|
|
463
|
+
/**
|
|
464
|
+
* Inserts one element at a specified index.
|
|
465
|
+
* @param element The element to insert.
|
|
466
|
+
* @param index The index at which you want to insert the element.
|
|
467
|
+
*/
|
|
468
|
+
insert(element: TItem, index: number): void;
|
|
469
|
+
/**
|
|
470
|
+
* Move one element from one index to another.
|
|
471
|
+
* @param index The index of the element to move
|
|
472
|
+
* @param targetIndex The index where the element should be after moving.
|
|
473
|
+
*/
|
|
474
|
+
move(index: number, targetIndex: number): void;
|
|
475
|
+
/**
|
|
476
|
+
* Deletes an element at the specified index
|
|
477
|
+
* @param index The index of the element to delete
|
|
478
|
+
*/
|
|
479
|
+
delete(index: number): void;
|
|
480
|
+
clear(): void;
|
|
481
|
+
set(index: number, item: TItem): void;
|
|
482
|
+
/**
|
|
483
|
+
* Tests whether all elements pass the test implemented by the provided function.
|
|
484
|
+
* @param predicate Function to test for each element, taking two arguments (the element and its index).
|
|
485
|
+
* @returns true if the predicate function returns a truthy value for every element. Otherwise, false.
|
|
486
|
+
*/
|
|
487
|
+
every(predicate: (value: TItem, index: number) => unknown): boolean;
|
|
488
|
+
/**
|
|
489
|
+
* Creates an array with all elements that pass the test implemented by the provided function.
|
|
490
|
+
* @param predicate Function to test each element of the LiveList. Return a value that coerces to true to keep the element, or to false otherwise.
|
|
491
|
+
* @returns An array with the elements that pass the test.
|
|
492
|
+
*/
|
|
493
|
+
filter(predicate: (value: TItem, index: number) => unknown): TItem[];
|
|
494
|
+
/**
|
|
495
|
+
* Returns the first element that satisfies the provided testing function.
|
|
496
|
+
* @param predicate Function to execute on each value.
|
|
497
|
+
* @returns The value of the first element in the LiveList that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
498
|
+
*/
|
|
499
|
+
find(predicate: (value: TItem, index: number) => unknown): TItem | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* Returns the index of the first element in the LiveList that satisfies the provided testing function.
|
|
502
|
+
* @param predicate Function to execute on each value until the function returns true, indicating that the satisfying element was found.
|
|
503
|
+
* @returns The index of the first element in the LiveList that passes the test. Otherwise, -1.
|
|
504
|
+
*/
|
|
505
|
+
findIndex(predicate: (value: TItem, index: number) => unknown): number;
|
|
506
|
+
/**
|
|
507
|
+
* Executes a provided function once for each element.
|
|
508
|
+
* @param callbackfn Function to execute on each element.
|
|
509
|
+
*/
|
|
510
|
+
forEach(callbackfn: (value: TItem, index: number) => void): void;
|
|
511
|
+
/**
|
|
512
|
+
* Get the element at the specified index.
|
|
513
|
+
* @param index The index on the element to get.
|
|
514
|
+
* @returns The element at the specified index or undefined.
|
|
515
|
+
*/
|
|
516
|
+
get(index: number): TItem | undefined;
|
|
517
|
+
/**
|
|
518
|
+
* Returns the first index at which a given element can be found in the LiveList, or -1 if it is not present.
|
|
519
|
+
* @param searchElement Element to locate.
|
|
520
|
+
* @param fromIndex The index to start the search at.
|
|
521
|
+
* @returns The first index of the element in the LiveList; -1 if not found.
|
|
522
|
+
*/
|
|
523
|
+
indexOf(searchElement: TItem, fromIndex?: number): number;
|
|
524
|
+
/**
|
|
525
|
+
* Returns the last index at which a given element can be found in the LiveList, or -1 if it is not present. The LiveList is searched backwards, starting at fromIndex.
|
|
526
|
+
* @param searchElement Element to locate.
|
|
527
|
+
* @param fromIndex The index at which to start searching backwards.
|
|
528
|
+
* @returns The last index of the element in the LiveList; -1 if not found.
|
|
529
|
+
*/
|
|
530
|
+
lastIndexOf(searchElement: TItem, fromIndex?: number): number;
|
|
531
|
+
/**
|
|
532
|
+
* Creates an array populated with the results of calling a provided function on every element.
|
|
533
|
+
* @param callback Function that is called for every element.
|
|
534
|
+
* @returns An array with each element being the result of the callback function.
|
|
535
|
+
*/
|
|
536
|
+
map<U>(callback: (value: TItem, index: number) => U): U[];
|
|
537
|
+
/**
|
|
538
|
+
* Tests whether at least one element in the LiveList passes the test implemented by the provided function.
|
|
539
|
+
* @param predicate Function to test for each element.
|
|
540
|
+
* @returns true if the callback function returns a truthy value for at least one element. Otherwise, false.
|
|
541
|
+
*/
|
|
542
|
+
some(predicate: (value: TItem, index: number) => unknown): boolean;
|
|
543
|
+
[Symbol.iterator](): IterableIterator<TItem>;
|
|
544
|
+
toJSON(): readonly ToJson<TItem>[];
|
|
545
|
+
clone(): LiveList<TItem>;
|
|
546
|
+
}
|
|
547
|
+
|
|
603
548
|
type UpdateDelta = {
|
|
604
549
|
type: "update";
|
|
605
550
|
} | {
|
|
@@ -686,17 +631,17 @@ declare const CrdtType: Readonly<{
|
|
|
686
631
|
LIST: 1;
|
|
687
632
|
MAP: 2;
|
|
688
633
|
REGISTER: 3;
|
|
689
|
-
|
|
634
|
+
FILE: 5;
|
|
690
635
|
}>;
|
|
691
636
|
declare namespace CrdtType {
|
|
692
637
|
type OBJECT = typeof CrdtType.OBJECT;
|
|
693
638
|
type LIST = typeof CrdtType.LIST;
|
|
694
639
|
type MAP = typeof CrdtType.MAP;
|
|
695
640
|
type REGISTER = typeof CrdtType.REGISTER;
|
|
696
|
-
type
|
|
641
|
+
type FILE = typeof CrdtType.FILE;
|
|
697
642
|
}
|
|
698
643
|
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
699
|
-
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister |
|
|
644
|
+
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister | SerializedFile;
|
|
700
645
|
type SerializedRootObject = {
|
|
701
646
|
readonly type: CrdtType.OBJECT;
|
|
702
647
|
readonly data: JsonObject;
|
|
@@ -725,21 +670,20 @@ type SerializedRegister = {
|
|
|
725
670
|
readonly parentKey: string;
|
|
726
671
|
readonly data: Json;
|
|
727
672
|
};
|
|
728
|
-
type
|
|
729
|
-
readonly type: CrdtType.
|
|
673
|
+
type SerializedFile = {
|
|
674
|
+
readonly type: CrdtType.FILE;
|
|
730
675
|
readonly parentId: string;
|
|
731
676
|
readonly parentKey: string;
|
|
732
|
-
readonly data:
|
|
733
|
-
readonly version: number;
|
|
677
|
+
readonly data: LiveFileData;
|
|
734
678
|
};
|
|
735
679
|
type StorageNode = RootStorageNode | ChildStorageNode;
|
|
736
|
-
type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode |
|
|
680
|
+
type ChildStorageNode = ObjectStorageNode | ListStorageNode | MapStorageNode | RegisterStorageNode | FileStorageNode;
|
|
737
681
|
type RootStorageNode = [id: "root", value: SerializedRootObject];
|
|
738
682
|
type ObjectStorageNode = [id: string, value: SerializedObject];
|
|
739
683
|
type ListStorageNode = [id: string, value: SerializedList];
|
|
740
684
|
type MapStorageNode = [id: string, value: SerializedMap];
|
|
741
685
|
type RegisterStorageNode = [id: string, value: SerializedRegister];
|
|
742
|
-
type
|
|
686
|
+
type FileStorageNode = [id: string, value: SerializedFile];
|
|
743
687
|
type NodeMap = Map<string, SerializedCrdt>;
|
|
744
688
|
type NodeStream = Iterable<StorageNode>;
|
|
745
689
|
declare function isRootStorageNode(node: StorageNode): node is RootStorageNode;
|
|
@@ -747,9 +691,9 @@ declare function isObjectStorageNode(node: StorageNode): node is RootStorageNode
|
|
|
747
691
|
declare function isListStorageNode(node: StorageNode): node is ListStorageNode;
|
|
748
692
|
declare function isMapStorageNode(node: StorageNode): node is MapStorageNode;
|
|
749
693
|
declare function isRegisterStorageNode(node: StorageNode): node is RegisterStorageNode;
|
|
750
|
-
declare function
|
|
694
|
+
declare function isFileStorageNode(node: StorageNode): node is FileStorageNode;
|
|
751
695
|
type CompactNode = CompactRootNode | CompactChildNode;
|
|
752
|
-
type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode |
|
|
696
|
+
type CompactChildNode = CompactObjectNode | CompactListNode | CompactMapNode | CompactRegisterNode | CompactFileNode;
|
|
753
697
|
type CompactRootNode = readonly [id: "root", data: JsonObject];
|
|
754
698
|
type CompactObjectNode = readonly [
|
|
755
699
|
id: string,
|
|
@@ -777,13 +721,12 @@ type CompactRegisterNode = readonly [
|
|
|
777
721
|
parentKey: string,
|
|
778
722
|
data: Json
|
|
779
723
|
];
|
|
780
|
-
type
|
|
724
|
+
type CompactFileNode = readonly [
|
|
781
725
|
id: string,
|
|
782
|
-
type: CrdtType.
|
|
726
|
+
type: CrdtType.FILE,
|
|
783
727
|
parentId: string,
|
|
784
728
|
parentKey: string,
|
|
785
|
-
data:
|
|
786
|
-
version: number
|
|
729
|
+
data: LiveFileData
|
|
787
730
|
];
|
|
788
731
|
declare function compactNodesToNodeStream(compactNodes: CompactNode[]): NodeStream;
|
|
789
732
|
declare function nodeStreamToCompactNodes(nodes: NodeStream): Iterable<CompactNode>;
|
|
@@ -951,223 +894,65 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
951
894
|
}
|
|
952
895
|
|
|
953
896
|
/**
|
|
954
|
-
*
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
* - "before": the transformed ops were ordered before the `over` ops. Used
|
|
963
|
-
* when applying an accepted remote op on top of locally-pending ops. On
|
|
964
|
-
* same-index insert ties, the transformed op stays left, and conflicting
|
|
965
|
-
* format attributes are dropped on overlapping ranges (the later `over` op
|
|
966
|
-
* wins).
|
|
967
|
-
*/
|
|
968
|
-
type TransformOrder = "before" | "after";
|
|
969
|
-
/**
|
|
970
|
-
* Transform `ops` over `over` (see {@link transformTextOperationsX}),
|
|
971
|
-
* returning only the transformed `ops`.
|
|
972
|
-
*/
|
|
973
|
-
declare function transformTextOperations(ops: readonly TextOperation[], over: readonly TextOperation[], order: TransformOrder): TextOperation[];
|
|
974
|
-
declare function applyLiveTextOperations(data: LiveTextData, ops: readonly TextOperation[]): LiveTextData;
|
|
975
|
-
|
|
976
|
-
type LiveTextAttributes = TextAttributes;
|
|
977
|
-
type LiveTextAttributesPatch = JsonObject;
|
|
897
|
+
* INTERNAL
|
|
898
|
+
*/
|
|
899
|
+
declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
|
|
900
|
+
#private;
|
|
901
|
+
constructor(data: TValue);
|
|
902
|
+
get data(): TValue;
|
|
903
|
+
clone(): TValue;
|
|
904
|
+
}
|
|
978
905
|
|
|
979
|
-
type
|
|
980
|
-
/** Text was inserted at {@link LiveTextChange.index}. */
|
|
981
|
-
readonly type: "insert";
|
|
982
|
-
readonly index: number;
|
|
983
|
-
readonly text: string;
|
|
984
|
-
readonly attributes?: TextAttributes;
|
|
985
|
-
} | {
|
|
986
|
-
/** Text was deleted starting at {@link LiveTextChange.index}. */
|
|
987
|
-
readonly type: "delete";
|
|
988
|
-
readonly index: number;
|
|
989
|
-
readonly length: number;
|
|
990
|
-
readonly deletedText: string;
|
|
991
|
-
} | {
|
|
992
|
-
/** Inline attributes were updated on a range of text. */
|
|
993
|
-
readonly type: "format";
|
|
994
|
-
readonly index: number;
|
|
995
|
-
readonly length: number;
|
|
996
|
-
readonly attributes: LiveTextAttributesPatch;
|
|
997
|
-
};
|
|
998
|
-
/** Notification payload when a {@link LiveText} node changes. */
|
|
999
|
-
type LiveTextUpdates = {
|
|
1000
|
-
type: "LiveText";
|
|
1001
|
-
node: LiveText;
|
|
1002
|
-
version: number;
|
|
1003
|
-
updates: LiveTextChange[];
|
|
1004
|
-
};
|
|
906
|
+
type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson> | LiveFile;
|
|
1005
907
|
/**
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
* Private methods on a LiveText node. As a user of Liveblocks, NEVER USE ANY
|
|
1009
|
-
* OF THESE DIRECTLY, because bad things will probably happen if you do.
|
|
908
|
+
* Think of Lson as a sibling of the Json data tree, except that the nested
|
|
909
|
+
* data structure can contain a mix of Json values and LiveStructure instances.
|
|
1010
910
|
*/
|
|
1011
|
-
type
|
|
1012
|
-
/**
|
|
1013
|
-
* Encode a local-document index into server-confirmed coordinates suitable
|
|
1014
|
-
* for broadcasting to peers via presence or any other side channel. Pair
|
|
1015
|
-
* the result with {@link LiveText.version} at the same instant when
|
|
1016
|
-
* sending.
|
|
1017
|
-
*/
|
|
1018
|
-
encodeIndex(localIndex: number): number;
|
|
1019
|
-
/**
|
|
1020
|
-
* Decode an `(index, fromVersion)` pair from a peer into an offset in this
|
|
1021
|
-
* LiveText's current local document.
|
|
1022
|
-
*/
|
|
1023
|
-
decodeIndex(index: number, fromVersion: number): number | null;
|
|
1024
|
-
};
|
|
1025
|
-
|
|
911
|
+
type Lson = Json | LiveStructure;
|
|
1026
912
|
/**
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
*
|
|
1039
|
-
* ops the client hadn't seen — never over the client's own pending ops.
|
|
1040
|
-
*
|
|
1041
|
-
* Inbound model: accepted remote ops are transformed over the local pending
|
|
1042
|
-
* ops before being applied ("before" order: the accepted op wins ties), and
|
|
1043
|
-
* the pending ops are re-expressed over the remote op in turn ("after"
|
|
1044
|
-
* order), keeping them in server coordinates at all times.
|
|
1045
|
-
*
|
|
1046
|
-
* @example
|
|
1047
|
-
* const text = new LiveText("Hello");
|
|
1048
|
-
* text.insert(5, " world");
|
|
1049
|
-
* text.format(0, 5, { bold: true });
|
|
1050
|
-
*
|
|
1051
|
-
* // [["Hello", { bold: true }], [" world"]]
|
|
1052
|
-
* text.toJSON();
|
|
913
|
+
* LiveNode is the internal tree for managing Live data structures. The key
|
|
914
|
+
* difference with Lson is that all the Json values get represented in
|
|
915
|
+
* a LiveRegister node.
|
|
916
|
+
*/
|
|
917
|
+
type LiveNode = LiveStructure | LiveRegister<Json>;
|
|
918
|
+
/**
|
|
919
|
+
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
920
|
+
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
921
|
+
*/
|
|
922
|
+
type LsonObject = Record<string, Lson | undefined>;
|
|
923
|
+
/**
|
|
924
|
+
* Helper type to convert any valid Lson type to the equivalent Json type.
|
|
1053
925
|
*
|
|
1054
|
-
*
|
|
1055
|
-
* // Use in Storage
|
|
1056
|
-
* declare global {
|
|
1057
|
-
* interface Liveblocks {
|
|
1058
|
-
* Storage: { document: LiveText };
|
|
1059
|
-
* }
|
|
1060
|
-
* }
|
|
926
|
+
* Examples:
|
|
1061
927
|
*
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
928
|
+
* ToJson<42> // 42
|
|
929
|
+
* ToJson<'hi'> // 'hi'
|
|
930
|
+
* ToJson<number> // number
|
|
931
|
+
* ToJson<string> // string
|
|
932
|
+
* ToJson<string | LiveList<number>> // string | readonly number[]
|
|
933
|
+
* ToJson<LiveMap<string, LiveList<number>>>
|
|
934
|
+
* // { readonly [key: string]: readonly number[] }
|
|
935
|
+
* ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
936
|
+
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
1064
937
|
*/
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
* will probably happen if you do.
|
|
1073
|
-
*/
|
|
1074
|
-
readonly [kInternal]: PrivateLiveTextApi;
|
|
1075
|
-
/**
|
|
1076
|
-
* Creates a new LiveText document.
|
|
1077
|
-
*
|
|
1078
|
-
* @param textOrData Initial plain text, or an array of `[text]` /
|
|
1079
|
-
* `[text, attributes]` segments. Defaults to an empty document.
|
|
1080
|
-
*
|
|
1081
|
-
* @example
|
|
1082
|
-
* new LiveText();
|
|
1083
|
-
* new LiveText("Hello world");
|
|
1084
|
-
* new LiveText([["Hello ", { bold: true }], ["world"]]);
|
|
1085
|
-
*/
|
|
1086
|
-
constructor(textOrData?: string | LiveTextData, version?: number);
|
|
1087
|
-
get version(): number;
|
|
1088
|
-
get length(): number;
|
|
1089
|
-
/**
|
|
1090
|
-
* Inserts text at the given index.
|
|
1091
|
-
*
|
|
1092
|
-
* @param index Character index at which to insert. Values outside the
|
|
1093
|
-
* document range are clipped.
|
|
1094
|
-
* @param text Text to insert.
|
|
1095
|
-
* @param attributes Optional inline attributes for the inserted text.
|
|
1096
|
-
*
|
|
1097
|
-
* @example
|
|
1098
|
-
* const text = new LiveText("Hello");
|
|
1099
|
-
* text.insert(5, " world");
|
|
1100
|
-
* text.insert(0, "Say: ", { italic: true });
|
|
1101
|
-
*/
|
|
1102
|
-
insert(index: number, text: string, attributes?: TextAttributes): void;
|
|
1103
|
-
/**
|
|
1104
|
-
* Deletes `length` characters starting at `index`.
|
|
1105
|
-
*
|
|
1106
|
-
* @example
|
|
1107
|
-
* const text = new LiveText("Hello world");
|
|
1108
|
-
* text.delete(5, 6); // "Hello"
|
|
1109
|
-
*/
|
|
1110
|
-
delete(index: number, length: number): void;
|
|
1111
|
-
/**
|
|
1112
|
-
* Replaces a range of text with new text.
|
|
1113
|
-
*
|
|
1114
|
-
* @example
|
|
1115
|
-
* const text = new LiveText("Hello world");
|
|
1116
|
-
* text.replace(0, 5, "Hi"); // "Hi world"
|
|
1117
|
-
*/
|
|
1118
|
-
replace(index: number, length: number, text: string, attributes?: TextAttributes): void;
|
|
1119
|
-
/**
|
|
1120
|
-
* Applies or removes inline attributes on a range of text.
|
|
1121
|
-
*
|
|
1122
|
-
* Set an attribute to `null` to remove it from the range.
|
|
1123
|
-
*
|
|
1124
|
-
* @example
|
|
1125
|
-
* const text = new LiveText("Hello world");
|
|
1126
|
-
* text.format(0, 5, { bold: true });
|
|
1127
|
-
* text.format(0, 5, { bold: null });
|
|
1128
|
-
*/
|
|
1129
|
-
format(index: number, length: number, attributes: LiveTextAttributesPatch): void;
|
|
1130
|
-
/** Returns the plain text content without attributes. Equivalent to joining the text from each segment in {@link LiveText.toJSON}. */
|
|
1131
|
-
toString(): string;
|
|
1132
|
-
/**
|
|
1133
|
-
* Returns a JSON-compatible snapshot of the document as a {@link LiveTextData}
|
|
1134
|
-
* array.
|
|
1135
|
-
*
|
|
1136
|
-
* @example
|
|
1137
|
-
* new LiveText([["Hello ", { bold: true }], ["world"]]).toJSON();
|
|
1138
|
-
* // [["Hello ", { bold: true }], ["world"]]
|
|
1139
|
-
*/
|
|
1140
|
-
toJSON(): LiveTextData;
|
|
1141
|
-
clone(): LiveText;
|
|
1142
|
-
}
|
|
938
|
+
type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? LsonObject extends O ? ReadonlyJsonObject : {
|
|
939
|
+
readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
|
|
940
|
+
} : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
|
|
941
|
+
readonly [K in KS]: ToJson<V>;
|
|
942
|
+
} : L extends LiveFile ? LiveFileData : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
|
|
943
|
+
readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
944
|
+
} : L extends Json ? L : never;
|
|
1143
945
|
|
|
1144
946
|
type StorageCallback = (updates: StorageUpdate[]) => void;
|
|
1145
947
|
type LiveMapUpdate = LiveMapUpdates<string, Lson>;
|
|
1146
948
|
type LiveObjectUpdate = LiveObjectUpdates<LsonObject>;
|
|
1147
949
|
type LiveListUpdate = LiveListUpdates<Lson>;
|
|
1148
|
-
type LiveTextUpdate = LiveTextUpdates;
|
|
1149
|
-
type StorageUpdateSource = {
|
|
1150
|
-
origin: "remote";
|
|
1151
|
-
} | {
|
|
1152
|
-
origin: "local";
|
|
1153
|
-
via: "mutation";
|
|
1154
|
-
} | {
|
|
1155
|
-
origin: "local";
|
|
1156
|
-
via: "history";
|
|
1157
|
-
action: "undo" | "redo";
|
|
1158
|
-
};
|
|
1159
950
|
/**
|
|
1160
951
|
* The payload of notifications sent (in-client) when LiveStructures change.
|
|
1161
952
|
* Messages of this kind are not originating from the network, but are 100%
|
|
1162
953
|
* in-client.
|
|
1163
|
-
*
|
|
1164
|
-
* Updates delivered through `room.subscribe` may carry
|
|
1165
|
-
* `[kStorageUpdateSource]` to distinguish where a mutation came from.
|
|
1166
|
-
* Undo/redo replays use `via: "history"` with `action: "undo" | "redo"`.
|
|
1167
954
|
*/
|
|
1168
|
-
type StorageUpdate =
|
|
1169
|
-
[kStorageUpdateSource]?: StorageUpdateSource;
|
|
1170
|
-
};
|
|
955
|
+
type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
|
|
1171
956
|
|
|
1172
957
|
/**
|
|
1173
958
|
* Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
|
|
@@ -1193,27 +978,6 @@ interface ReadonlyUnacknowledgedOps {
|
|
|
1193
978
|
isPossiblyStored(opId: string): boolean;
|
|
1194
979
|
}
|
|
1195
980
|
|
|
1196
|
-
type DispatchOptions = {
|
|
1197
|
-
/**
|
|
1198
|
-
* Whether this dispatch should clear the redo stack. Defaults to true when
|
|
1199
|
-
* any forward ops are included (a fresh local mutation), false otherwise.
|
|
1200
|
-
* LiveText uses this to dispatch queued ops after an acknowledgement
|
|
1201
|
-
* (which should not clear redo), and to register fresh local edits that
|
|
1202
|
-
* don't carry wire ops yet (which should).
|
|
1203
|
-
*/
|
|
1204
|
-
clearRedoStack?: boolean;
|
|
1205
|
-
};
|
|
1206
|
-
/**
|
|
1207
|
-
* Private methods on any Liveblocks CRDT node. As a user of Liveblocks, NEVER
|
|
1208
|
-
* USE ANY OF THESE DIRECTLY, because bad things will probably happen if you do.
|
|
1209
|
-
*/
|
|
1210
|
-
type PrivateLiveNodeApi = {
|
|
1211
|
-
/**
|
|
1212
|
-
* Returns the CRDT node id once attached to the room pool. Detached nodes
|
|
1213
|
-
* that have not entered storage yet return `undefined`.
|
|
1214
|
-
*/
|
|
1215
|
-
getId(): string | undefined;
|
|
1216
|
-
};
|
|
1217
981
|
/**
|
|
1218
982
|
* The managed pool is a namespace registry (i.e. a context) that "owns" all
|
|
1219
983
|
* the individual live nodes, ensuring each one has a unique ID, and holding on
|
|
@@ -1232,7 +996,7 @@ interface ManagedPool {
|
|
|
1232
996
|
* - Add reverse operations to the undo/redo stack
|
|
1233
997
|
* - Notify room subscribers with updates (in-client, no networking)
|
|
1234
998
|
*/
|
|
1235
|
-
dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate
|
|
999
|
+
dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
1236
1000
|
/**
|
|
1237
1001
|
* Ensures storage can be written to else throws an error.
|
|
1238
1002
|
* This is used to prevent writing to storage when the user does not have
|
|
@@ -1250,233 +1014,194 @@ interface ManagedPool {
|
|
|
1250
1014
|
type CreateManagedPoolOptions = {
|
|
1251
1015
|
/**
|
|
1252
1016
|
* Returns the current connection ID. This is used to generate unique
|
|
1253
|
-
* prefixes for nodes created by this client. This number is allowed to
|
|
1254
|
-
* change over time (for example, when the client reconnects).
|
|
1255
|
-
*/
|
|
1256
|
-
getCurrentConnectionId(): number;
|
|
1257
|
-
/**
|
|
1258
|
-
* Will get invoked when any Live structure calls .dispatch() on the pool.
|
|
1259
|
-
*/
|
|
1260
|
-
onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>, options?: DispatchOptions) => void;
|
|
1261
|
-
/**
|
|
1262
|
-
* Will get invoked when any Live structure calls .assertStorageIsWritable()
|
|
1263
|
-
* on the pool. Defaults to true when not provided. Return false if you want
|
|
1264
|
-
* to prevent writes to the pool locally early, because you know they won't
|
|
1265
|
-
* have an effect upstream.
|
|
1266
|
-
*/
|
|
1267
|
-
isStorageWritable?: () => boolean;
|
|
1268
|
-
/**
|
|
1269
|
-
* Read-only view of the client's still-unacknowledged ops. Used by CRDTs
|
|
1270
|
-
* (e.g. LiveList) to know which of their optimistic mutations the server
|
|
1271
|
-
* hasn't confirmed yet. Defaults to an empty view (e.g. server-side pools
|
|
1272
|
-
* that dispatch-and-flush have no optimistic state to track).
|
|
1273
|
-
*/
|
|
1274
|
-
unacknowledgedOps?: ReadonlyUnacknowledgedOps;
|
|
1275
|
-
};
|
|
1276
|
-
/**
|
|
1277
|
-
* @private Private API, never use this API directly.
|
|
1278
|
-
*/
|
|
1279
|
-
declare function createManagedPool(options: CreateManagedPoolOptions): ManagedPool;
|
|
1280
|
-
declare abstract class AbstractCrdt {
|
|
1281
|
-
#private;
|
|
1282
|
-
readonly [kInternal]: PrivateLiveNodeApi;
|
|
1283
|
-
constructor();
|
|
1284
|
-
/**
|
|
1285
|
-
* @private
|
|
1286
|
-
* Returns true if the cached JSON snapshot exists and is reference-equal
|
|
1287
|
-
* to the given value. Does not trigger a recompute.
|
|
1288
|
-
*/
|
|
1289
|
-
hasCache(value: unknown): boolean;
|
|
1290
|
-
/**
|
|
1291
|
-
* Return a JSON-compatible snapshot of this Live node and its children.
|
|
1292
|
-
* LiveObject values become plain objects, LiveList values become arrays,
|
|
1293
|
-
* and LiveMap values also become plain objects (not Map instances).
|
|
1294
|
-
* The result is cached and only recomputed when the contents change.
|
|
1295
|
-
*/
|
|
1296
|
-
toJSON(): ReadonlyJson;
|
|
1297
|
-
/**
|
|
1298
|
-
* Returns a deep clone of the current LiveStructure, suitable for insertion
|
|
1299
|
-
* in the tree elsewhere.
|
|
1300
|
-
*/
|
|
1301
|
-
abstract clone(): Lson;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
type LiveListUpdateDelta = {
|
|
1305
|
-
type: "insert";
|
|
1306
|
-
index: number;
|
|
1307
|
-
item: Lson;
|
|
1308
|
-
} | {
|
|
1309
|
-
type: "delete";
|
|
1310
|
-
index: number;
|
|
1311
|
-
deletedItem: Lson;
|
|
1312
|
-
} | {
|
|
1313
|
-
type: "move";
|
|
1314
|
-
index: number;
|
|
1315
|
-
previousIndex: number;
|
|
1316
|
-
item: Lson;
|
|
1317
|
-
} | {
|
|
1318
|
-
type: "set";
|
|
1319
|
-
index: number;
|
|
1320
|
-
item: Lson;
|
|
1321
|
-
};
|
|
1322
|
-
/**
|
|
1323
|
-
* A LiveList notification that is sent in-client to any subscribers whenever
|
|
1324
|
-
* one or more of the items inside the LiveList instance have changed.
|
|
1325
|
-
*/
|
|
1326
|
-
type LiveListUpdates<TItem extends Lson> = {
|
|
1327
|
-
type: "LiveList";
|
|
1328
|
-
node: LiveList<TItem>;
|
|
1329
|
-
updates: LiveListUpdateDelta[];
|
|
1330
|
-
};
|
|
1331
|
-
/**
|
|
1332
|
-
* The LiveList class represents an ordered collection of items that is synchronized across clients.
|
|
1333
|
-
*/
|
|
1334
|
-
declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
1335
|
-
#private;
|
|
1336
|
-
constructor(items: TItem[]);
|
|
1337
|
-
/**
|
|
1338
|
-
* Returns the number of elements.
|
|
1339
|
-
*/
|
|
1340
|
-
get length(): number;
|
|
1341
|
-
/**
|
|
1342
|
-
* Adds one element to the end of the LiveList.
|
|
1343
|
-
* @param element The element to add to the end of the LiveList.
|
|
1344
|
-
*/
|
|
1345
|
-
push(element: TItem): void;
|
|
1346
|
-
/**
|
|
1347
|
-
* Inserts one element at a specified index.
|
|
1348
|
-
* @param element The element to insert.
|
|
1349
|
-
* @param index The index at which you want to insert the element.
|
|
1350
|
-
*/
|
|
1351
|
-
insert(element: TItem, index: number): void;
|
|
1352
|
-
/**
|
|
1353
|
-
* Move one element from one index to another.
|
|
1354
|
-
* @param index The index of the element to move
|
|
1355
|
-
* @param targetIndex The index where the element should be after moving.
|
|
1356
|
-
*/
|
|
1357
|
-
move(index: number, targetIndex: number): void;
|
|
1358
|
-
/**
|
|
1359
|
-
* Deletes an element at the specified index
|
|
1360
|
-
* @param index The index of the element to delete
|
|
1361
|
-
*/
|
|
1362
|
-
delete(index: number): void;
|
|
1363
|
-
clear(): void;
|
|
1364
|
-
set(index: number, item: TItem): void;
|
|
1365
|
-
/**
|
|
1366
|
-
* Tests whether all elements pass the test implemented by the provided function.
|
|
1367
|
-
* @param predicate Function to test for each element, taking two arguments (the element and its index).
|
|
1368
|
-
* @returns true if the predicate function returns a truthy value for every element. Otherwise, false.
|
|
1369
|
-
*/
|
|
1370
|
-
every(predicate: (value: TItem, index: number) => unknown): boolean;
|
|
1371
|
-
/**
|
|
1372
|
-
* Creates an array with all elements that pass the test implemented by the provided function.
|
|
1373
|
-
* @param predicate Function to test each element of the LiveList. Return a value that coerces to true to keep the element, or to false otherwise.
|
|
1374
|
-
* @returns An array with the elements that pass the test.
|
|
1375
|
-
*/
|
|
1376
|
-
filter(predicate: (value: TItem, index: number) => unknown): TItem[];
|
|
1377
|
-
/**
|
|
1378
|
-
* Returns the first element that satisfies the provided testing function.
|
|
1379
|
-
* @param predicate Function to execute on each value.
|
|
1380
|
-
* @returns The value of the first element in the LiveList that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
1381
|
-
*/
|
|
1382
|
-
find(predicate: (value: TItem, index: number) => unknown): TItem | undefined;
|
|
1383
|
-
/**
|
|
1384
|
-
* Returns the index of the first element in the LiveList that satisfies the provided testing function.
|
|
1385
|
-
* @param predicate Function to execute on each value until the function returns true, indicating that the satisfying element was found.
|
|
1386
|
-
* @returns The index of the first element in the LiveList that passes the test. Otherwise, -1.
|
|
1017
|
+
* prefixes for nodes created by this client. This number is allowed to
|
|
1018
|
+
* change over time (for example, when the client reconnects).
|
|
1387
1019
|
*/
|
|
1388
|
-
|
|
1020
|
+
getCurrentConnectionId(): number;
|
|
1389
1021
|
/**
|
|
1390
|
-
*
|
|
1391
|
-
* @param callbackfn Function to execute on each element.
|
|
1022
|
+
* Will get invoked when any Live structure calls .dispatch() on the pool.
|
|
1392
1023
|
*/
|
|
1393
|
-
|
|
1024
|
+
onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
|
|
1394
1025
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1397
|
-
*
|
|
1026
|
+
* Will get invoked when any Live structure calls .assertStorageIsWritable()
|
|
1027
|
+
* on the pool. Defaults to true when not provided. Return false if you want
|
|
1028
|
+
* to prevent writes to the pool locally early, because you know they won't
|
|
1029
|
+
* have an effect upstream.
|
|
1398
1030
|
*/
|
|
1399
|
-
|
|
1031
|
+
isStorageWritable?: () => boolean;
|
|
1400
1032
|
/**
|
|
1401
|
-
*
|
|
1402
|
-
*
|
|
1403
|
-
*
|
|
1404
|
-
*
|
|
1033
|
+
* Read-only view of the client's still-unacknowledged ops. Used by CRDTs
|
|
1034
|
+
* (e.g. LiveList) to know which of their optimistic mutations the server
|
|
1035
|
+
* hasn't confirmed yet. Defaults to an empty view (e.g. server-side pools
|
|
1036
|
+
* that dispatch-and-flush have no optimistic state to track).
|
|
1405
1037
|
*/
|
|
1406
|
-
|
|
1038
|
+
unacknowledgedOps?: ReadonlyUnacknowledgedOps;
|
|
1039
|
+
};
|
|
1040
|
+
/**
|
|
1041
|
+
* @private Private API, never use this API directly.
|
|
1042
|
+
*/
|
|
1043
|
+
declare function createManagedPool(options: CreateManagedPoolOptions): ManagedPool;
|
|
1044
|
+
declare abstract class AbstractCrdt {
|
|
1045
|
+
#private;
|
|
1407
1046
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
* @returns The last index of the element in the LiveList; -1 if not found.
|
|
1047
|
+
* @private
|
|
1048
|
+
* Returns true if the cached JSON snapshot exists and is reference-equal
|
|
1049
|
+
* to the given value. Does not trigger a recompute.
|
|
1412
1050
|
*/
|
|
1413
|
-
|
|
1051
|
+
hasCache(value: unknown): boolean;
|
|
1414
1052
|
/**
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1053
|
+
* Return a JSON-compatible snapshot of this Live node and its children.
|
|
1054
|
+
* LiveObject values become plain objects, LiveList values become arrays,
|
|
1055
|
+
* and LiveMap values also become plain objects (not Map instances).
|
|
1056
|
+
* The result is cached and only recomputed when the contents change.
|
|
1418
1057
|
*/
|
|
1419
|
-
|
|
1058
|
+
toJSON(): ReadonlyJson;
|
|
1420
1059
|
/**
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
* @returns true if the callback function returns a truthy value for at least one element. Otherwise, false.
|
|
1060
|
+
* Returns a deep clone of the current LiveStructure, suitable for insertion
|
|
1061
|
+
* in the tree elsewhere.
|
|
1424
1062
|
*/
|
|
1425
|
-
|
|
1426
|
-
[Symbol.iterator](): IterableIterator<TItem>;
|
|
1427
|
-
toJSON(): readonly ToJson<TItem>[];
|
|
1428
|
-
clone(): LiveList<TItem>;
|
|
1063
|
+
abstract clone(): Lson;
|
|
1429
1064
|
}
|
|
1430
1065
|
|
|
1066
|
+
type LiveFileData = {
|
|
1067
|
+
readonly id: string;
|
|
1068
|
+
readonly name: string;
|
|
1069
|
+
readonly size: number;
|
|
1070
|
+
readonly mimeType: string;
|
|
1071
|
+
};
|
|
1072
|
+
type LiveFileReference = LiveFile | LiveFileData | string;
|
|
1073
|
+
declare function getLiveFileId(file: LiveFileReference): string;
|
|
1431
1074
|
/**
|
|
1432
|
-
*
|
|
1075
|
+
* A LiveFile is an immutable Storage leaf that references file bytes stored
|
|
1076
|
+
* outside the realtime Storage tree.
|
|
1433
1077
|
*/
|
|
1434
|
-
declare class
|
|
1078
|
+
declare class LiveFile extends AbstractCrdt {
|
|
1435
1079
|
#private;
|
|
1436
|
-
constructor(data:
|
|
1437
|
-
get data():
|
|
1438
|
-
|
|
1080
|
+
constructor(data: LiveFileData);
|
|
1081
|
+
get data(): Readonly<LiveFileData>;
|
|
1082
|
+
get id(): string;
|
|
1083
|
+
get name(): string;
|
|
1084
|
+
get size(): number;
|
|
1085
|
+
get mimeType(): string;
|
|
1086
|
+
clone(): LiveFile;
|
|
1439
1087
|
}
|
|
1440
1088
|
|
|
1441
|
-
type
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1089
|
+
type RenameDataField<T, TFieldName extends string> = T extends any ? {
|
|
1090
|
+
[K in keyof T as K extends "data" ? TFieldName : K]: T[K];
|
|
1091
|
+
} : never;
|
|
1092
|
+
type AsyncLoading<F extends string = "data"> = RenameDataField<{
|
|
1093
|
+
readonly isLoading: true;
|
|
1094
|
+
readonly data?: never;
|
|
1095
|
+
readonly error?: never;
|
|
1096
|
+
}, F>;
|
|
1097
|
+
type AsyncSuccess<T, F extends string = "data"> = RenameDataField<{
|
|
1098
|
+
readonly isLoading: false;
|
|
1099
|
+
readonly data: T;
|
|
1100
|
+
readonly error?: never;
|
|
1101
|
+
}, F>;
|
|
1102
|
+
type AsyncError<F extends string = "data"> = RenameDataField<{
|
|
1103
|
+
readonly isLoading: false;
|
|
1104
|
+
readonly data?: never;
|
|
1105
|
+
readonly error: Error;
|
|
1106
|
+
}, F>;
|
|
1107
|
+
type AsyncResult<T, F extends string = "data"> = AsyncLoading<F> | AsyncSuccess<T, F> | AsyncError<F>;
|
|
1108
|
+
|
|
1109
|
+
type Callback<T> = (event: T) => void;
|
|
1110
|
+
type UnsubscribeCallback = () => void;
|
|
1111
|
+
type Observable<T> = {
|
|
1112
|
+
/**
|
|
1113
|
+
* Register a callback function to be called whenever the event source emits
|
|
1114
|
+
* an event.
|
|
1115
|
+
*/
|
|
1116
|
+
subscribe(callback: Callback<T>): UnsubscribeCallback;
|
|
1117
|
+
/**
|
|
1118
|
+
* Register a one-time callback function to be called whenever the event
|
|
1119
|
+
* source emits an event. After the event fires, the callback is
|
|
1120
|
+
* auto-unsubscribed.
|
|
1121
|
+
*/
|
|
1122
|
+
subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
|
|
1123
|
+
/**
|
|
1124
|
+
* Returns a promise that will resolve when an event is emitted by this
|
|
1125
|
+
* event source. Optionally, specify a predicate that has to match. The first
|
|
1126
|
+
* event matching that predicate will then resolve the promise.
|
|
1127
|
+
*/
|
|
1128
|
+
waitUntil(predicate?: (event: T) => boolean): Promise<T>;
|
|
1129
|
+
};
|
|
1130
|
+
type EventSource<T> = Observable<T> & {
|
|
1131
|
+
/**
|
|
1132
|
+
* Notify all subscribers about the event. Will return `false` if there
|
|
1133
|
+
* weren't any subscribers at the time the .notify() was called, or `true` if
|
|
1134
|
+
* there was at least one subscriber.
|
|
1135
|
+
*/
|
|
1136
|
+
notify(event: T): boolean;
|
|
1137
|
+
/**
|
|
1138
|
+
* Returns the number of active subscribers.
|
|
1139
|
+
*/
|
|
1140
|
+
count(): number;
|
|
1141
|
+
/**
|
|
1142
|
+
* Observable instance, which can be used to subscribe to this event source
|
|
1143
|
+
* in a readonly fashion. Safe to publicly expose.
|
|
1144
|
+
*/
|
|
1145
|
+
observable: Observable<T>;
|
|
1146
|
+
/**
|
|
1147
|
+
* Disposes of this event source.
|
|
1148
|
+
*
|
|
1149
|
+
* Will clears all registered event listeners. None of the registered
|
|
1150
|
+
* functions will ever get called again.
|
|
1151
|
+
*
|
|
1152
|
+
* WARNING!
|
|
1153
|
+
* Be careful when using this API, because the subscribers may not have any
|
|
1154
|
+
* idea they won't be notified anymore.
|
|
1155
|
+
*/
|
|
1156
|
+
dispose(): void;
|
|
1157
|
+
};
|
|
1458
1158
|
/**
|
|
1459
|
-
*
|
|
1159
|
+
* makeEventSource allows you to generate a subscribe/notify pair of functions
|
|
1160
|
+
* to make subscribing easy and to get notified about events.
|
|
1460
1161
|
*
|
|
1461
|
-
*
|
|
1162
|
+
* The events are anonymous, so you can use it to define events, like so:
|
|
1163
|
+
*
|
|
1164
|
+
* const event1 = makeEventSource();
|
|
1165
|
+
* const event2 = makeEventSource();
|
|
1166
|
+
*
|
|
1167
|
+
* event1.subscribe(foo);
|
|
1168
|
+
* event1.subscribe(bar);
|
|
1169
|
+
* event2.subscribe(qux);
|
|
1170
|
+
*
|
|
1171
|
+
* // Unsubscription is pretty standard
|
|
1172
|
+
* const unsub = event2.subscribe(foo);
|
|
1173
|
+
* unsub();
|
|
1174
|
+
*
|
|
1175
|
+
* event1.notify(); // Now foo and bar will get called
|
|
1176
|
+
* event2.notify(); // Now qux will get called (but foo will not, since it's unsubscribed)
|
|
1462
1177
|
*
|
|
1463
|
-
* ToJson<42> // 42
|
|
1464
|
-
* ToJson<'hi'> // 'hi'
|
|
1465
|
-
* ToJson<number> // number
|
|
1466
|
-
* ToJson<string> // string
|
|
1467
|
-
* ToJson<string | LiveList<number>> // string | readonly number[]
|
|
1468
|
-
* ToJson<LiveMap<string, LiveList<number>>>
|
|
1469
|
-
* // { readonly [key: string]: readonly number[] }
|
|
1470
|
-
* ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
1471
|
-
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
1472
1178
|
*/
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1179
|
+
declare function makeEventSource<T>(): EventSource<T>;
|
|
1180
|
+
|
|
1181
|
+
type BatchStore<O, I> = {
|
|
1182
|
+
subscribe: (callback: Callback<void>) => UnsubscribeCallback;
|
|
1183
|
+
enqueue: (input: I) => Promise<void>;
|
|
1184
|
+
setData: (entries: [I, O][]) => void;
|
|
1185
|
+
getItemState: (input: I) => AsyncResult<O> | undefined;
|
|
1186
|
+
getData: (input: I) => O | undefined;
|
|
1187
|
+
invalidate: (inputs?: I[]) => void;
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
type ContextualPromptResponse = Relax<{
|
|
1191
|
+
type: "insert";
|
|
1192
|
+
text: string;
|
|
1193
|
+
} | {
|
|
1194
|
+
type: "replace";
|
|
1195
|
+
text: string;
|
|
1196
|
+
} | {
|
|
1197
|
+
type: "other";
|
|
1198
|
+
text: string;
|
|
1199
|
+
}>;
|
|
1200
|
+
type ContextualPromptContext = {
|
|
1201
|
+
beforeSelection: string;
|
|
1202
|
+
selection: string;
|
|
1203
|
+
afterSelection: string;
|
|
1204
|
+
};
|
|
1480
1205
|
|
|
1481
1206
|
type DateToString<T> = {
|
|
1482
1207
|
[P in keyof T]: T[P] extends Date ? string : T[P] extends Date | null ? string | null : T[P] extends Date | undefined ? string | undefined : T[P];
|
|
@@ -2172,6 +1897,16 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
2172
1897
|
signal?: AbortSignal;
|
|
2173
1898
|
}): Promise<CommentAttachment>;
|
|
2174
1899
|
getOrCreateAttachmentUrlsStore(roomId: string): BatchStore<string, string>;
|
|
1900
|
+
getFileUrl(options: {
|
|
1901
|
+
roomId: string;
|
|
1902
|
+
fileId: string;
|
|
1903
|
+
}): Promise<string>;
|
|
1904
|
+
uploadFile({ roomId, file, signal, }: {
|
|
1905
|
+
roomId: string;
|
|
1906
|
+
file: File;
|
|
1907
|
+
signal?: AbortSignal;
|
|
1908
|
+
}): Promise<LiveFile>;
|
|
1909
|
+
getOrCreateFileUrlsStore(roomId: string): BatchStore<string, string>;
|
|
2175
1910
|
createTextMention({ roomId, mentionId, mention, }: {
|
|
2176
1911
|
roomId: string;
|
|
2177
1912
|
mentionId: string;
|
|
@@ -2321,6 +2056,25 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
2321
2056
|
getGroup(groupId: string): Promise<GroupData | undefined>;
|
|
2322
2057
|
}
|
|
2323
2058
|
|
|
2059
|
+
/**
|
|
2060
|
+
* Use this symbol to brand an object property as internal.
|
|
2061
|
+
*
|
|
2062
|
+
* @example
|
|
2063
|
+
* Object.defineProperty(
|
|
2064
|
+
* {
|
|
2065
|
+
* public,
|
|
2066
|
+
* [kInternal]: {
|
|
2067
|
+
* private
|
|
2068
|
+
* },
|
|
2069
|
+
* },
|
|
2070
|
+
* kInternal,
|
|
2071
|
+
* {
|
|
2072
|
+
* enumerable: false,
|
|
2073
|
+
* }
|
|
2074
|
+
* );
|
|
2075
|
+
*/
|
|
2076
|
+
declare const kInternal: unique symbol;
|
|
2077
|
+
|
|
2324
2078
|
/**
|
|
2325
2079
|
* Back-port of TypeScript 5.4's built-in NoInfer utility type.
|
|
2326
2080
|
* See https://stackoverflow.com/a/56688073/148872
|
|
@@ -3560,7 +3314,13 @@ type LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = {
|
|
|
3560
3314
|
readonly key: string;
|
|
3561
3315
|
readonly payload: LsonTreeNode[];
|
|
3562
3316
|
};
|
|
3563
|
-
type
|
|
3317
|
+
type LiveFileTreeNode = {
|
|
3318
|
+
readonly type: "LiveFile";
|
|
3319
|
+
readonly id: string;
|
|
3320
|
+
readonly key: string;
|
|
3321
|
+
readonly payload: LiveFileData;
|
|
3322
|
+
};
|
|
3323
|
+
type LsonTreeNode = LiveTreeNode | LiveFileTreeNode | JsonTreeNode;
|
|
3564
3324
|
type UserTreeNode = {
|
|
3565
3325
|
readonly type: "User";
|
|
3566
3326
|
readonly id: string;
|
|
@@ -3584,12 +3344,13 @@ type TreeNode = LsonTreeNode | UserTreeNode | CustomEventTreeNode;
|
|
|
3584
3344
|
|
|
3585
3345
|
type DevToolsTreeNode_CustomEventTreeNode = CustomEventTreeNode;
|
|
3586
3346
|
type DevToolsTreeNode_JsonTreeNode = JsonTreeNode;
|
|
3347
|
+
type DevToolsTreeNode_LiveFileTreeNode = LiveFileTreeNode;
|
|
3587
3348
|
type DevToolsTreeNode_LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = LiveTreeNode<TName>;
|
|
3588
3349
|
type DevToolsTreeNode_LsonTreeNode = LsonTreeNode;
|
|
3589
3350
|
type DevToolsTreeNode_TreeNode = TreeNode;
|
|
3590
3351
|
type DevToolsTreeNode_UserTreeNode = UserTreeNode;
|
|
3591
3352
|
declare namespace DevToolsTreeNode {
|
|
3592
|
-
export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
|
|
3353
|
+
export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveFileTreeNode as LiveFileTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
|
|
3593
3354
|
}
|
|
3594
3355
|
|
|
3595
3356
|
type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
|
|
@@ -3879,6 +3640,9 @@ type GetThreadsSinceOptions = {
|
|
|
3879
3640
|
type UploadAttachmentOptions = {
|
|
3880
3641
|
signal?: AbortSignal;
|
|
3881
3642
|
};
|
|
3643
|
+
type UploadFileOptions = {
|
|
3644
|
+
signal?: AbortSignal;
|
|
3645
|
+
};
|
|
3882
3646
|
type ListTextVersionsSinceOptions = {
|
|
3883
3647
|
since: Date;
|
|
3884
3648
|
signal?: AbortSignal;
|
|
@@ -4387,6 +4151,23 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
4387
4151
|
* await room.getAttachmentUrl("at_xxx");
|
|
4388
4152
|
*/
|
|
4389
4153
|
getAttachmentUrl(attachmentId: string): Promise<string>;
|
|
4154
|
+
/**
|
|
4155
|
+
* Uploads a file for a `LiveFile`.
|
|
4156
|
+
*
|
|
4157
|
+
* @example
|
|
4158
|
+
* const liveFile = await room.uploadFile(file);
|
|
4159
|
+
*/
|
|
4160
|
+
uploadFile(file: File, options?: UploadFileOptions): Promise<LiveFile>;
|
|
4161
|
+
/**
|
|
4162
|
+
* Returns a presigned URL for a `LiveFile`.
|
|
4163
|
+
*
|
|
4164
|
+
* @example
|
|
4165
|
+
* await getFileUrl("fl_xxx");
|
|
4166
|
+
*
|
|
4167
|
+
* @example
|
|
4168
|
+
* await getFileUrl(liveFile);
|
|
4169
|
+
*/
|
|
4170
|
+
getFileUrl(file: LiveFileReference): Promise<string>;
|
|
4390
4171
|
/**
|
|
4391
4172
|
* Gets the user's subscription settings for the current room.
|
|
4392
4173
|
*
|
|
@@ -4444,14 +4225,7 @@ interface SyncSource {
|
|
|
4444
4225
|
*/
|
|
4445
4226
|
type PrivateRoomApi = {
|
|
4446
4227
|
presenceBuffer: Json | undefined;
|
|
4447
|
-
undoStack: readonly
|
|
4448
|
-
readonly id: number;
|
|
4449
|
-
readonly frames: readonly Readonly<Stackframe<JsonObject>>[];
|
|
4450
|
-
}[];
|
|
4451
|
-
redoStack: readonly {
|
|
4452
|
-
readonly id: number;
|
|
4453
|
-
readonly frames: readonly Readonly<Stackframe<JsonObject>>[];
|
|
4454
|
-
}[];
|
|
4228
|
+
undoStack: readonly (readonly Readonly<Stackframe<JsonObject>>[])[];
|
|
4455
4229
|
nodeCount: number;
|
|
4456
4230
|
getYjsProvider(): IYjsProvider | undefined;
|
|
4457
4231
|
setYjsProvider(provider: IYjsProvider | undefined): void;
|
|
@@ -4491,21 +4265,7 @@ type PrivateRoomApi = {
|
|
|
4491
4265
|
incomingMessage(data: string): void;
|
|
4492
4266
|
};
|
|
4493
4267
|
attachmentUrlsStore: BatchStore<string, string>;
|
|
4494
|
-
|
|
4495
|
-
action: "push";
|
|
4496
|
-
id: number;
|
|
4497
|
-
} | {
|
|
4498
|
-
action: "undo";
|
|
4499
|
-
id: number;
|
|
4500
|
-
} | {
|
|
4501
|
-
action: "redo";
|
|
4502
|
-
id: number;
|
|
4503
|
-
} | {
|
|
4504
|
-
action: "clear";
|
|
4505
|
-
} | {
|
|
4506
|
-
action: "discard";
|
|
4507
|
-
ids: number[];
|
|
4508
|
-
}>;
|
|
4268
|
+
fileUrlsStore: BatchStore<string, string>;
|
|
4509
4269
|
};
|
|
4510
4270
|
type Stackframe<P extends JsonObject> = Op | PresenceStackframe<P>;
|
|
4511
4271
|
type PresenceStackframe<P extends JsonObject> = {
|
|
@@ -5405,12 +5165,11 @@ type PlainLsonList = {
|
|
|
5405
5165
|
liveblocksType: "LiveList";
|
|
5406
5166
|
data: PlainLson[];
|
|
5407
5167
|
};
|
|
5408
|
-
type
|
|
5409
|
-
liveblocksType: "
|
|
5410
|
-
data:
|
|
5411
|
-
version?: number;
|
|
5168
|
+
type PlainLsonFile = {
|
|
5169
|
+
liveblocksType: "LiveFile";
|
|
5170
|
+
data: LiveFileData;
|
|
5412
5171
|
};
|
|
5413
|
-
type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList |
|
|
5172
|
+
type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | PlainLsonFile | Json;
|
|
5414
5173
|
|
|
5415
5174
|
/**
|
|
5416
5175
|
* Returns PlainLson for a given Json or LiveStructure, suitable for calling the storage init api
|
|
@@ -5518,6 +5277,7 @@ declare function Promise_withResolvers<T>(): ControlledPromise<T>;
|
|
|
5518
5277
|
declare function createThreadId(): string;
|
|
5519
5278
|
declare function createCommentId(): string;
|
|
5520
5279
|
declare function createCommentAttachmentId(): string;
|
|
5280
|
+
declare function createStorageFileId(): string;
|
|
5521
5281
|
declare function createInboxNotificationId(): string;
|
|
5522
5282
|
|
|
5523
5283
|
/**
|
|
@@ -6125,4 +5885,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
6125
5885
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
6126
5886
|
};
|
|
6127
5887
|
|
|
6128
|
-
export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type
|
|
5888
|
+
export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };
|