@liveblocks/core 3.20.0-pre1 → 3.20.0
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 +994 -423
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +228 -126
- package/dist/index.d.ts +228 -126
- package/dist/index.js +891 -320
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,83 @@ type DistributiveRelax<T, Ks extends string | number | symbol> = T extends any ?
|
|
|
64
64
|
[K in Exclude<Ks, keyof T>]?: never;
|
|
65
65
|
}> : never;
|
|
66
66
|
|
|
67
|
+
declare const Permission: {
|
|
68
|
+
/**
|
|
69
|
+
* Default permission for a room.
|
|
70
|
+
*/
|
|
71
|
+
readonly Read: "*:read";
|
|
72
|
+
readonly Write: "*:write";
|
|
73
|
+
/**
|
|
74
|
+
* Legacy aliases for default room permissions.
|
|
75
|
+
*/
|
|
76
|
+
readonly RoomWrite: "room:write";
|
|
77
|
+
readonly RoomRead: "room:read";
|
|
78
|
+
/**
|
|
79
|
+
* Storage
|
|
80
|
+
*/
|
|
81
|
+
readonly StorageRead: "storage:read";
|
|
82
|
+
readonly StorageWrite: "storage:write";
|
|
83
|
+
readonly StorageNone: "storage:none";
|
|
84
|
+
/**
|
|
85
|
+
* Comments
|
|
86
|
+
*/
|
|
87
|
+
readonly CommentsWrite: "comments:write";
|
|
88
|
+
readonly CommentsRead: "comments:read";
|
|
89
|
+
readonly CommentsNone: "comments:none";
|
|
90
|
+
/**
|
|
91
|
+
* Feeds
|
|
92
|
+
*/
|
|
93
|
+
readonly FeedsRead: "feeds:read";
|
|
94
|
+
readonly FeedsWrite: "feeds:write";
|
|
95
|
+
readonly FeedsNone: "feeds:none";
|
|
96
|
+
/**
|
|
97
|
+
* Legacy
|
|
98
|
+
*/
|
|
99
|
+
readonly LegacyRoomPresenceWrite: "room:presence:write";
|
|
100
|
+
};
|
|
101
|
+
type Permission = (typeof Permission)[keyof typeof Permission];
|
|
102
|
+
declare const ACCESS_LEVELS: readonly ["none", "read", "write"];
|
|
103
|
+
type AccessLevel = (typeof ACCESS_LEVELS)[number];
|
|
104
|
+
type RequiredAccessLevel = "read" | "write";
|
|
105
|
+
type PermissionMatrix = {
|
|
106
|
+
room: AccessLevel;
|
|
107
|
+
storage: AccessLevel;
|
|
108
|
+
comments: AccessLevel;
|
|
109
|
+
feeds: AccessLevel;
|
|
110
|
+
personal: AccessLevel;
|
|
111
|
+
};
|
|
112
|
+
type PermissionResources = keyof PermissionMatrix;
|
|
113
|
+
type RoomPermissions = Permission[];
|
|
114
|
+
type RoomAccesses = Record<string, RoomPermissions>;
|
|
115
|
+
type UpdateRoomAccesses = Record<string, RoomPermissions | null>;
|
|
116
|
+
declare function permissionMatrixFromScopes(scopes: RoomPermissions): PermissionMatrix;
|
|
117
|
+
declare function hasPermissionAccess(matrix: Partial<PermissionMatrix>, resource: PermissionResources, requiredAccess: RequiredAccessLevel): boolean;
|
|
118
|
+
declare function normalizeRoomPermissions(permissions: string[] | readonly string[]): RoomPermissions;
|
|
119
|
+
declare function normalizeRoomAccesses(accesses: RoomAccesses | undefined): RoomAccesses | undefined;
|
|
120
|
+
declare function normalizeUpdateRoomAccesses(accesses: UpdateRoomAccesses | undefined): UpdateRoomAccesses | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Merges permission scopes from multiple sources, by priority: explicit user
|
|
123
|
+
* accesses override group accesses, which override the room defaults. Groups
|
|
124
|
+
* all share the same priority, so they are first merged together by taking
|
|
125
|
+
* the highest access level per feature (and base).
|
|
126
|
+
*/
|
|
127
|
+
declare function mergeRoomPermissionScopes({ defaultAccesses, groupsAccesses, userAccesses, }: {
|
|
128
|
+
defaultAccesses: RoomPermissions;
|
|
129
|
+
groupsAccesses: RoomPermissions[];
|
|
130
|
+
userAccesses: RoomPermissions;
|
|
131
|
+
}): RoomPermissions;
|
|
132
|
+
/**
|
|
133
|
+
* Validates a set of permissions:
|
|
134
|
+
* - every scope must be a known permission scope,
|
|
135
|
+
* - exactly one base permission is required (*:read, *:write, or the legacy
|
|
136
|
+
* aliases room:read, room:write),
|
|
137
|
+
* - at most one scope per feature (storage, comments, feeds, ...),
|
|
138
|
+
* - room:presence:write is accepted as an extra legacy scope.
|
|
139
|
+
*
|
|
140
|
+
* Returns `true` when the set is valid, or an error message otherwise.
|
|
141
|
+
*/
|
|
142
|
+
declare function validatePermissionsSet(scopes: readonly string[]): true | string;
|
|
143
|
+
|
|
67
144
|
type CustomAuthenticationResult = Relax<{
|
|
68
145
|
token: string;
|
|
69
146
|
} | {
|
|
@@ -132,15 +209,6 @@ type BaseUserMeta = {
|
|
|
132
209
|
info?: IUserInfo;
|
|
133
210
|
};
|
|
134
211
|
|
|
135
|
-
declare enum Permission {
|
|
136
|
-
Read = "room:read",
|
|
137
|
-
Write = "room:write",
|
|
138
|
-
PresenceWrite = "room:presence:write",
|
|
139
|
-
CommentsWrite = "comments:write",
|
|
140
|
-
CommentsRead = "comments:read",
|
|
141
|
-
FeedsWrite = "feeds:write"
|
|
142
|
-
}
|
|
143
|
-
|
|
144
212
|
type RenameDataField<T, TFieldName extends string> = T extends any ? {
|
|
145
213
|
[K in keyof T as K extends "data" ? TFieldName : K]: T[K];
|
|
146
214
|
} : never;
|
|
@@ -242,90 +310,6 @@ type BatchStore<O, I> = {
|
|
|
242
310
|
invalidate: (inputs?: I[]) => void;
|
|
243
311
|
};
|
|
244
312
|
|
|
245
|
-
declare const kTrigger: unique symbol;
|
|
246
|
-
/**
|
|
247
|
-
* Runs a callback function that is allowed to change multiple signals. At the
|
|
248
|
-
* end of the batch, all changed signals will be notified (at most once).
|
|
249
|
-
*
|
|
250
|
-
* Nesting batches is supported.
|
|
251
|
-
*/
|
|
252
|
-
declare function batch(callback: Callback<void>): void;
|
|
253
|
-
type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
|
|
254
|
-
interface ISignal<T> {
|
|
255
|
-
get(): T;
|
|
256
|
-
subscribe(callback: Callback<void>): UnsubscribeCallback;
|
|
257
|
-
addSink(sink: DerivedSignal<unknown>): void;
|
|
258
|
-
removeSink(sink: DerivedSignal<unknown>): void;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Base functionality every Signal implementation needs.
|
|
262
|
-
*/
|
|
263
|
-
declare abstract class AbstractSignal<T> implements ISignal<T>, Observable<void> {
|
|
264
|
-
#private;
|
|
265
|
-
constructor(equals?: (a: T, b: T) => boolean);
|
|
266
|
-
dispose(): void;
|
|
267
|
-
abstract get(): T;
|
|
268
|
-
get hasWatchers(): boolean;
|
|
269
|
-
[kTrigger](): void;
|
|
270
|
-
subscribe(callback: Callback<void>): UnsubscribeCallback;
|
|
271
|
-
subscribeOnce(callback: Callback<void>): UnsubscribeCallback;
|
|
272
|
-
waitUntil(): never;
|
|
273
|
-
markSinksDirty(): void;
|
|
274
|
-
addSink(sink: DerivedSignal<unknown>): void;
|
|
275
|
-
removeSink(sink: DerivedSignal<unknown>): void;
|
|
276
|
-
asReadonly(): ISignal<T>;
|
|
277
|
-
}
|
|
278
|
-
declare class Signal<T> extends AbstractSignal<T> {
|
|
279
|
-
#private;
|
|
280
|
-
constructor(value: T, equals?: (a: T, b: T) => boolean);
|
|
281
|
-
dispose(): void;
|
|
282
|
-
get(): T;
|
|
283
|
-
set(newValue: T | ((oldValue: T) => T)): void;
|
|
284
|
-
}
|
|
285
|
-
declare class DerivedSignal<T> extends AbstractSignal<T> {
|
|
286
|
-
#private;
|
|
287
|
-
static from<Ts extends unknown[], V>(...args: [...signals: {
|
|
288
|
-
[K in keyof Ts]: ISignal<Ts[K]>;
|
|
289
|
-
}, transform: (...values: Ts) => V]): DerivedSignal<V>;
|
|
290
|
-
static from<Ts extends unknown[], V>(...args: [...signals: {
|
|
291
|
-
[K in keyof Ts]: ISignal<Ts[K]>;
|
|
292
|
-
}, transform: (...values: Ts) => V, equals: (a: V, b: V) => boolean]): DerivedSignal<V>;
|
|
293
|
-
private constructor();
|
|
294
|
-
dispose(): void;
|
|
295
|
-
get isDirty(): boolean;
|
|
296
|
-
markDirty(): void;
|
|
297
|
-
get(): T;
|
|
298
|
-
/**
|
|
299
|
-
* Called by the Signal system if one or more of the dependent signals have
|
|
300
|
-
* changed. In the case of a DerivedSignal, we'll only want to re-evaluate
|
|
301
|
-
* the actual value if it's being watched, or any of their sinks are being
|
|
302
|
-
* watched actively.
|
|
303
|
-
*/
|
|
304
|
-
[kTrigger](): void;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* A MutableSignal is a bit like Signal, except its state is managed by
|
|
308
|
-
* a single value whose reference does not change but is mutated.
|
|
309
|
-
*
|
|
310
|
-
* Similar to how useSyncExternalState() works in React, there is a way to read
|
|
311
|
-
* the current state at any point in time synchronously, and a way to update
|
|
312
|
-
* its reference.
|
|
313
|
-
*/
|
|
314
|
-
declare class MutableSignal<T extends object> extends AbstractSignal<T> {
|
|
315
|
-
#private;
|
|
316
|
-
constructor(initialState: T);
|
|
317
|
-
dispose(): void;
|
|
318
|
-
get(): T;
|
|
319
|
-
/**
|
|
320
|
-
* Invokes a callback function that is allowed to mutate the given state
|
|
321
|
-
* value. Do not change the value outside of the callback.
|
|
322
|
-
*
|
|
323
|
-
* If the callback explicitly returns `false`, it's assumed that the state
|
|
324
|
-
* was not changed.
|
|
325
|
-
*/
|
|
326
|
-
mutate(callback?: (state: T) => void | boolean): void;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
313
|
type ContextualPromptResponse = Relax<{
|
|
330
314
|
type: "insert";
|
|
331
315
|
text: string;
|
|
@@ -519,6 +503,7 @@ type HasOpId = {
|
|
|
519
503
|
* acknowledge the receipt.
|
|
520
504
|
*/
|
|
521
505
|
type ClientWireOp = Op & HasOpId;
|
|
506
|
+
type ClientWireCreateOp = CreateOp & HasOpId;
|
|
522
507
|
/**
|
|
523
508
|
* ServerWireOp: Ops sent from server → client. Three variants:
|
|
524
509
|
* 1. ClientWireOp — Full echo back of our own op, confirming it was applied
|
|
@@ -744,6 +729,14 @@ type SyncMode = boolean | "atomic" | SyncConfig;
|
|
|
744
729
|
type SyncConfig = {
|
|
745
730
|
[key: string]: SyncMode | undefined;
|
|
746
731
|
};
|
|
732
|
+
/**
|
|
733
|
+
* Deeply converts all nested lists to LiveLists, and all nested objects to
|
|
734
|
+
* LiveObjects.
|
|
735
|
+
*
|
|
736
|
+
* As such, the returned result will not contain any Json arrays or Json
|
|
737
|
+
* objects anymore.
|
|
738
|
+
*/
|
|
739
|
+
declare function deepLiveify(value: Json, config?: SyncMode): Lson;
|
|
747
740
|
|
|
748
741
|
/**
|
|
749
742
|
* Optional keys of O whose non-undefined type is plain Json (not a
|
|
@@ -864,6 +857,30 @@ type LiveListUpdate = LiveListUpdates<Lson>;
|
|
|
864
857
|
*/
|
|
865
858
|
type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
|
|
866
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
|
|
862
|
+
* they can look up their own still-pending Create ops without being able to
|
|
863
|
+
* mutate the set (only the room adds/acks).
|
|
864
|
+
*/
|
|
865
|
+
interface ReadonlyUnacknowledgedOps {
|
|
866
|
+
/** Still-unacknowledged Create ops whose `parentId` is the given one. */
|
|
867
|
+
getByParentId(parentId: string): Iterable<ClientWireCreateOp>;
|
|
868
|
+
/**
|
|
869
|
+
* Still-unacknowledged Create ops whose `parentId` and `parentKey` are both
|
|
870
|
+
* the given ones (i.e. targeting one exact position).
|
|
871
|
+
*/
|
|
872
|
+
getByParentIdAndKey(parentId: string, parentKey: string): Iterable<ClientWireCreateOp>;
|
|
873
|
+
/**
|
|
874
|
+
* Whether the given pending op may already have been processed by the
|
|
875
|
+
* server. True for ops that were in flight when a connection died: the
|
|
876
|
+
* server may have stored them with the ack getting lost in the disconnect,
|
|
877
|
+
* or may never have received them. Until the (re-sent) op's ack arrives,
|
|
878
|
+
* the client cannot know which, so optimistic predictions that assume the
|
|
879
|
+
* op has not been processed yet are unsound for these ops.
|
|
880
|
+
*/
|
|
881
|
+
isPossiblyStored(opId: string): boolean;
|
|
882
|
+
}
|
|
883
|
+
|
|
867
884
|
/**
|
|
868
885
|
* The managed pool is a namespace registry (i.e. a context) that "owns" all
|
|
869
886
|
* the individual live nodes, ensuring each one has a unique ID, and holding on
|
|
@@ -892,6 +909,11 @@ interface ManagedPool {
|
|
|
892
909
|
* @returns {void}
|
|
893
910
|
*/
|
|
894
911
|
assertStorageIsWritable: () => void;
|
|
912
|
+
/**
|
|
913
|
+
* Read-only view of the client's still-unacknowledged ops (sent or
|
|
914
|
+
* pending-send, not yet confirmed by the server).
|
|
915
|
+
*/
|
|
916
|
+
readonly unacknowledgedOps: ReadonlyUnacknowledgedOps;
|
|
895
917
|
}
|
|
896
918
|
type CreateManagedPoolOptions = {
|
|
897
919
|
/**
|
|
@@ -911,6 +933,13 @@ type CreateManagedPoolOptions = {
|
|
|
911
933
|
* have an effect upstream.
|
|
912
934
|
*/
|
|
913
935
|
isStorageWritable?: () => boolean;
|
|
936
|
+
/**
|
|
937
|
+
* Read-only view of the client's still-unacknowledged ops. Used by CRDTs
|
|
938
|
+
* (e.g. LiveList) to know which of their optimistic mutations the server
|
|
939
|
+
* hasn't confirmed yet. Defaults to an empty view (e.g. server-side pools
|
|
940
|
+
* that dispatch-and-flush have no optimistic state to track).
|
|
941
|
+
*/
|
|
942
|
+
unacknowledgedOps?: ReadonlyUnacknowledgedOps;
|
|
914
943
|
};
|
|
915
944
|
/**
|
|
916
945
|
* @private Private API, never use this API directly.
|
|
@@ -1649,7 +1678,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1649
1678
|
subscriptions: SubscriptionData[];
|
|
1650
1679
|
requestedAt: Date;
|
|
1651
1680
|
nextCursor: string | null;
|
|
1652
|
-
permissionHints: Record<string,
|
|
1681
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1653
1682
|
}>;
|
|
1654
1683
|
getThreadsSince(options: {
|
|
1655
1684
|
roomId: string;
|
|
@@ -1669,7 +1698,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1669
1698
|
deleted: SubscriptionDeleteInfo[];
|
|
1670
1699
|
};
|
|
1671
1700
|
requestedAt: Date;
|
|
1672
|
-
permissionHints: Record<string,
|
|
1701
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1673
1702
|
}>;
|
|
1674
1703
|
searchComments(options: {
|
|
1675
1704
|
roomId: string;
|
|
@@ -1788,18 +1817,6 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1788
1817
|
signal?: AbortSignal;
|
|
1789
1818
|
}): Promise<CommentAttachment>;
|
|
1790
1819
|
getOrCreateAttachmentUrlsStore(roomId: string): BatchStore<string, string>;
|
|
1791
|
-
uploadChatAttachment({ chatId, attachment, signal, }: {
|
|
1792
|
-
chatId: string;
|
|
1793
|
-
attachment: {
|
|
1794
|
-
id: string;
|
|
1795
|
-
file: File;
|
|
1796
|
-
};
|
|
1797
|
-
signal?: AbortSignal;
|
|
1798
|
-
}): Promise<void>;
|
|
1799
|
-
getOrCreateChatAttachmentUrlsStore(chatId: string): BatchStore<string, string>;
|
|
1800
|
-
getChatAttachmentUrl(options: {
|
|
1801
|
-
attachmentId: string;
|
|
1802
|
-
}): Promise<string>;
|
|
1803
1820
|
createTextMention({ roomId, mentionId, mention, }: {
|
|
1804
1821
|
roomId: string;
|
|
1805
1822
|
mentionId: string;
|
|
@@ -1931,7 +1948,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
1931
1948
|
subscriptions: SubscriptionData[];
|
|
1932
1949
|
nextCursor: string | null;
|
|
1933
1950
|
requestedAt: Date;
|
|
1934
|
-
permissionHints: Record<string,
|
|
1951
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1935
1952
|
}>;
|
|
1936
1953
|
getUserThreadsSince_experimental(options: {
|
|
1937
1954
|
since: Date;
|
|
@@ -1950,7 +1967,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
1950
1967
|
deleted: SubscriptionDeleteInfo[];
|
|
1951
1968
|
};
|
|
1952
1969
|
requestedAt: Date;
|
|
1953
|
-
permissionHints: Record<string,
|
|
1970
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1954
1971
|
}>;
|
|
1955
1972
|
groupsStore: BatchStore<GroupData | undefined, string>;
|
|
1956
1973
|
getGroup(groupId: string): Promise<GroupData | undefined>;
|
|
@@ -1981,6 +1998,90 @@ declare const kInternal: unique symbol;
|
|
|
1981
1998
|
*/
|
|
1982
1999
|
type NoInfr<A> = [A][A extends any ? 0 : never];
|
|
1983
2000
|
|
|
2001
|
+
declare const kTrigger: unique symbol;
|
|
2002
|
+
/**
|
|
2003
|
+
* Runs a callback function that is allowed to change multiple signals. At the
|
|
2004
|
+
* end of the batch, all changed signals will be notified (at most once).
|
|
2005
|
+
*
|
|
2006
|
+
* Nesting batches is supported.
|
|
2007
|
+
*/
|
|
2008
|
+
declare function batch(callback: Callback<void>): void;
|
|
2009
|
+
type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
|
|
2010
|
+
interface ISignal<T> {
|
|
2011
|
+
get(): T;
|
|
2012
|
+
subscribe(callback: Callback<void>): UnsubscribeCallback;
|
|
2013
|
+
addSink(sink: DerivedSignal<unknown>): void;
|
|
2014
|
+
removeSink(sink: DerivedSignal<unknown>): void;
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Base functionality every Signal implementation needs.
|
|
2018
|
+
*/
|
|
2019
|
+
declare abstract class AbstractSignal<T> implements ISignal<T>, Observable<void> {
|
|
2020
|
+
#private;
|
|
2021
|
+
constructor(equals?: (a: T, b: T) => boolean);
|
|
2022
|
+
dispose(): void;
|
|
2023
|
+
abstract get(): T;
|
|
2024
|
+
get hasWatchers(): boolean;
|
|
2025
|
+
[kTrigger](): void;
|
|
2026
|
+
subscribe(callback: Callback<void>): UnsubscribeCallback;
|
|
2027
|
+
subscribeOnce(callback: Callback<void>): UnsubscribeCallback;
|
|
2028
|
+
waitUntil(): never;
|
|
2029
|
+
markSinksDirty(): void;
|
|
2030
|
+
addSink(sink: DerivedSignal<unknown>): void;
|
|
2031
|
+
removeSink(sink: DerivedSignal<unknown>): void;
|
|
2032
|
+
asReadonly(): ISignal<T>;
|
|
2033
|
+
}
|
|
2034
|
+
declare class Signal<T> extends AbstractSignal<T> {
|
|
2035
|
+
#private;
|
|
2036
|
+
constructor(value: T, equals?: (a: T, b: T) => boolean);
|
|
2037
|
+
dispose(): void;
|
|
2038
|
+
get(): T;
|
|
2039
|
+
set(newValue: T | ((oldValue: T) => T)): void;
|
|
2040
|
+
}
|
|
2041
|
+
declare class DerivedSignal<T> extends AbstractSignal<T> {
|
|
2042
|
+
#private;
|
|
2043
|
+
static from<Ts extends unknown[], V>(...args: [...signals: {
|
|
2044
|
+
[K in keyof Ts]: ISignal<Ts[K]>;
|
|
2045
|
+
}, transform: (...values: Ts) => V]): DerivedSignal<V>;
|
|
2046
|
+
static from<Ts extends unknown[], V>(...args: [...signals: {
|
|
2047
|
+
[K in keyof Ts]: ISignal<Ts[K]>;
|
|
2048
|
+
}, transform: (...values: Ts) => V, equals: (a: V, b: V) => boolean]): DerivedSignal<V>;
|
|
2049
|
+
private constructor();
|
|
2050
|
+
dispose(): void;
|
|
2051
|
+
get isDirty(): boolean;
|
|
2052
|
+
markDirty(): void;
|
|
2053
|
+
get(): T;
|
|
2054
|
+
/**
|
|
2055
|
+
* Called by the Signal system if one or more of the dependent signals have
|
|
2056
|
+
* changed. In the case of a DerivedSignal, we'll only want to re-evaluate
|
|
2057
|
+
* the actual value if it's being watched, or any of their sinks are being
|
|
2058
|
+
* watched actively.
|
|
2059
|
+
*/
|
|
2060
|
+
[kTrigger](): void;
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* A MutableSignal is a bit like Signal, except its state is managed by
|
|
2064
|
+
* a single value whose reference does not change but is mutated.
|
|
2065
|
+
*
|
|
2066
|
+
* Similar to how useSyncExternalState() works in React, there is a way to read
|
|
2067
|
+
* the current state at any point in time synchronously, and a way to update
|
|
2068
|
+
* its reference.
|
|
2069
|
+
*/
|
|
2070
|
+
declare class MutableSignal<T extends object> extends AbstractSignal<T> {
|
|
2071
|
+
#private;
|
|
2072
|
+
constructor(initialState: T);
|
|
2073
|
+
dispose(): void;
|
|
2074
|
+
get(): T;
|
|
2075
|
+
/**
|
|
2076
|
+
* Invokes a callback function that is allowed to mutate the given state
|
|
2077
|
+
* value. Do not change the value outside of the callback.
|
|
2078
|
+
*
|
|
2079
|
+
* If the callback explicitly returns `false`, it's assumed that the state
|
|
2080
|
+
* was not changed.
|
|
2081
|
+
*/
|
|
2082
|
+
mutate(callback?: (state: T) => void | boolean): void;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
1984
2085
|
type Awaitable<T> = T | PromiseLike<T>;
|
|
1985
2086
|
|
|
1986
2087
|
type AiConnectionErrorContext = {
|
|
@@ -2112,11 +2213,6 @@ type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolv
|
|
|
2112
2213
|
* the authentication endpoint or connect via WebSocket.
|
|
2113
2214
|
*/
|
|
2114
2215
|
autoConnect?: boolean;
|
|
2115
|
-
/**
|
|
2116
|
-
* @deprecated This flag no longer has any effect and will be removed in
|
|
2117
|
-
* a future version. All rooms now use the v2 storage engine by default.
|
|
2118
|
-
*/
|
|
2119
|
-
engine?: 1 | 2;
|
|
2120
2216
|
} & PartialUnless<P, {
|
|
2121
2217
|
/**
|
|
2122
2218
|
* The initial Presence to use and announce when you enter the Room. The
|
|
@@ -2424,12 +2520,6 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
2424
2520
|
lostConnectionTimeout?: number;
|
|
2425
2521
|
backgroundKeepAliveTimeout?: number;
|
|
2426
2522
|
polyfills?: Polyfills;
|
|
2427
|
-
/**
|
|
2428
|
-
* @deprecated All rooms will be migrated to the v2 storage engine in the
|
|
2429
|
-
* future, which has native support for streaming. After that migration, this
|
|
2430
|
-
* flag will no longer have any effect and will be removed in a future version.
|
|
2431
|
-
*/
|
|
2432
|
-
unstable_streamData?: boolean;
|
|
2433
2523
|
/**
|
|
2434
2524
|
* A function that returns a list of mention suggestions matching a string.
|
|
2435
2525
|
*/
|
|
@@ -3639,10 +3729,15 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3639
3729
|
}>;
|
|
3640
3730
|
/**
|
|
3641
3731
|
* Get the room's storage synchronously.
|
|
3642
|
-
* The storage's root is a
|
|
3732
|
+
* The storage's root is a LiveObject.
|
|
3643
3733
|
*
|
|
3644
3734
|
* @example
|
|
3645
|
-
* const root = room.
|
|
3735
|
+
* const root = room.getStorageOrNull();
|
|
3736
|
+
*/
|
|
3737
|
+
getStorageOrNull(): LiveObject<S> | null;
|
|
3738
|
+
/**
|
|
3739
|
+
* @deprecated Renamed to `Room.getStorageOrNull`. This alias will be
|
|
3740
|
+
* removed in the future.
|
|
3646
3741
|
*/
|
|
3647
3742
|
getStorageSnapshot(): LiveObject<S> | null;
|
|
3648
3743
|
/**
|
|
@@ -3759,7 +3854,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3759
3854
|
subscriptions: SubscriptionData[];
|
|
3760
3855
|
requestedAt: Date;
|
|
3761
3856
|
nextCursor: string | null;
|
|
3762
|
-
permissionHints: Record<string,
|
|
3857
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
3763
3858
|
}>;
|
|
3764
3859
|
/**
|
|
3765
3860
|
* Returns the updated and deleted threads and their associated inbox notifications and subscriptions since the requested date.
|
|
@@ -3783,7 +3878,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3783
3878
|
deleted: SubscriptionDeleteInfo[];
|
|
3784
3879
|
};
|
|
3785
3880
|
requestedAt: Date;
|
|
3786
|
-
permissionHints: Record<string,
|
|
3881
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
3787
3882
|
}>;
|
|
3788
3883
|
/**
|
|
3789
3884
|
* Returns a thread and the associated inbox notification and subscription if it exists.
|
|
@@ -4075,7 +4170,7 @@ type StaticSessionInfo = {
|
|
|
4075
4170
|
type DynamicSessionInfo = {
|
|
4076
4171
|
readonly actor: number;
|
|
4077
4172
|
readonly nonce: string;
|
|
4078
|
-
readonly
|
|
4173
|
+
readonly permissionMatrix: PermissionMatrix;
|
|
4079
4174
|
readonly meta: JsonObject;
|
|
4080
4175
|
};
|
|
4081
4176
|
type Polyfills = {
|
|
@@ -5457,6 +5552,13 @@ declare class SortedList<T> {
|
|
|
5457
5552
|
reposition(value: T): number;
|
|
5458
5553
|
at(index: number): T | undefined;
|
|
5459
5554
|
get length(): number;
|
|
5555
|
+
/**
|
|
5556
|
+
* Whether the given value is present, by identity. O(log n) plus the length
|
|
5557
|
+
* of any run of items that share its sort key (normally 1). Bisects on the
|
|
5558
|
+
* value's own key, so it only finds values sitting at their sorted position,
|
|
5559
|
+
* which is true for any item currently in the list.
|
|
5560
|
+
*/
|
|
5561
|
+
includes(value: T): boolean;
|
|
5460
5562
|
filter(predicate: (value: T) => boolean): IterableIterator<T>;
|
|
5461
5563
|
findAllRight(predicate: (value: T, index: number) => unknown): IterableIterator<T>;
|
|
5462
5564
|
[Symbol.iterator](): IterableIterator<T>;
|
|
@@ -5669,4 +5771,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5669
5771
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5670
5772
|
};
|
|
5671
5773
|
|
|
5672
|
-
export { 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 ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, 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 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, 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 PlainLson, type PlainLsonFields, 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 Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, 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 ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, 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, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, nodeStreamToCompactNodes, objectToQuery, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
|
5774
|
+
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 ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, 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 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, 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 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 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 ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, 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, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, 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 };
|