@liveblocks/server 1.4.0 → 1.4.2-pre1
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 +103 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -19
- package/dist/index.d.ts +64 -19
- package/dist/index.js +77 -58
- package/dist/index.js.map +1 -1
- package/package.json +10 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Json, asPos, IUserInfo, SerializedCrdt, JsonObject, DistributiveOmit, SetParentKeyOp, DeleteCrdtOp, ClientMsg as ClientMsg$1, Brand, SerializedRootObject, SerializedChild, StorageNode, Awaitable, CompactNode, PlainLsonObject, NodeMap as NodeMap$1, NodeStream as NodeStream$1, ClientWireOp, ServerMsg as ServerMsg$1, BaseUserMeta, IgnoredOp } from '@liveblocks/core';
|
|
2
2
|
export { BroadcastEventClientMsg, ClientMsg, ClientWireOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, DeleteCrdtOp, DeleteObjectKeyOp, FetchStorageClientMsg, FetchYDocClientMsg, HasOpId, IgnoredOp, Op, RoomStateServerMsg, ServerMsg, ServerWireOp, SetParentKeyOp, UpdateObjectOp, UpdatePresenceClientMsg, UpdateStorageClientMsg, UpdateYDocClientMsg } from '@liveblocks/core';
|
|
3
3
|
import * as decoders from 'decoders';
|
|
4
4
|
import { Decoder } from 'decoders';
|
|
@@ -23,6 +23,37 @@ import * as Y from 'yjs';
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
type Pos = ReturnType<typeof asPos>;
|
|
26
|
+
declare const fromType: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* A string known to be a valid JSON-encoded value. Use this whenever a
|
|
29
|
+
* `string` already carries JSON, to keep that fact visible in the type system
|
|
30
|
+
* (instead of letting it look like a freeform `string`).
|
|
31
|
+
*
|
|
32
|
+
* Optionally parameterised by the *parsed* shape: `jstring<CompactNode>`
|
|
33
|
+
* means "a string whose `JSON.parse` result is a `CompactNode`". Without
|
|
34
|
+
* a type argument, defaults to `jstring<Json>` (any JSON value).
|
|
35
|
+
*
|
|
36
|
+
* At storage boundaries (e.g. reading `jdata` from SQLite), `as jstring`
|
|
37
|
+
* is acceptable — we trust the bytes are valid JSON because we wrote them as
|
|
38
|
+
* JSON ourselves.
|
|
39
|
+
*
|
|
40
|
+
* For example, these are valid JSON strings:
|
|
41
|
+
* - '0', '1', '2', '3', '3.14', etc.
|
|
42
|
+
* - 'null', 'true', 'false'
|
|
43
|
+
* - '{"foo":1}', '{ "foo": 1 }' (spaces are fine)
|
|
44
|
+
* - '[]', '[1,2, 3]', '[[]]', etc.
|
|
45
|
+
* - '["hi",{}]'
|
|
46
|
+
* - '"foo"'
|
|
47
|
+
*
|
|
48
|
+
* But these are not:
|
|
49
|
+
* - 'foo'
|
|
50
|
+
* - '1,2,3'
|
|
51
|
+
* - '{'
|
|
52
|
+
* - '[1,2,3,]' or '{"foo":1},' (trailing commas are not valid)
|
|
53
|
+
*/
|
|
54
|
+
type jstring<J = Json> = string & {
|
|
55
|
+
readonly [fromType]: J;
|
|
56
|
+
};
|
|
26
57
|
type NodeTuple<T extends SerializedCrdt = SerializedCrdt> = [
|
|
27
58
|
id: string,
|
|
28
59
|
value: T
|
|
@@ -683,6 +714,27 @@ interface IStorageDriverNodeAPI {
|
|
|
683
714
|
* Yield all nodes as [id, node] pairs. Must always include the root node.
|
|
684
715
|
*/
|
|
685
716
|
iter_nodes(): Iterable<StorageNode>;
|
|
717
|
+
/**
|
|
718
|
+
* Yield each node as a pre-built `CompactNode` JSON tuple string, ready to
|
|
719
|
+
* be emitted directly into a STORAGE_CHUNK wire frame without JSON.parse()
|
|
720
|
+
* or JSON.stringify()'ing overhead. Implementations MUST produce text whose
|
|
721
|
+
* parsed shape exactly matches the `CompactNode` union type from
|
|
722
|
+
* @liveblocks/core. The emitted shapes are:
|
|
723
|
+
*
|
|
724
|
+
* - Root node: '["root",<data>]'
|
|
725
|
+
* - OBJECT / REGISTER: '["0:1",0,"root","a",<data>]'
|
|
726
|
+
* - LIST / MAP: '["0:2",1,"0:1","b"]'
|
|
727
|
+
*
|
|
728
|
+
* Invariant (implementations MUST uphold; asserted by `_generateFullTestSuite`):
|
|
729
|
+
*
|
|
730
|
+
* iter_nodes_optimized().map(JSON.parse)
|
|
731
|
+
* ≡ nodeStreamToCompactNodes(iter_nodes())
|
|
732
|
+
*
|
|
733
|
+
* i.e. parsing each yielded string yields the same sequence of CompactNodes
|
|
734
|
+
* that the canonical `iter_nodes()` + `nodeStreamToCompactNodes()` path
|
|
735
|
+
* would produce.
|
|
736
|
+
*/
|
|
737
|
+
iter_nodes_optimized(): Iterable<jstring<CompactNode>>;
|
|
686
738
|
/**
|
|
687
739
|
* Return true iff a node with the given id exists. Must return true for "root".
|
|
688
740
|
*/
|
|
@@ -1158,7 +1210,7 @@ declare class YjsStorage {
|
|
|
1158
1210
|
private readonly initPromisesById;
|
|
1159
1211
|
private readonly storedKeysById;
|
|
1160
1212
|
constructor(driver: IStorageDriver, updateCountThreshold?: number);
|
|
1161
|
-
getYDoc(docId: YDocId): Promise<Y.Doc>;
|
|
1213
|
+
getYDoc(logger: Logger, docId: YDocId): Promise<Y.Doc>;
|
|
1162
1214
|
/**
|
|
1163
1215
|
* If passed a state vector, an update with diff will be returned, if not the entire doc is returned.
|
|
1164
1216
|
*
|
|
@@ -1167,8 +1219,8 @@ declare class YjsStorage {
|
|
|
1167
1219
|
*/
|
|
1168
1220
|
getYDocUpdate(logger: Logger, stateVector?: string, guid?: Guid, isV2?: boolean): Promise<string | null>;
|
|
1169
1221
|
getYDocUpdateBinary(logger: Logger, stateVector?: string, guid?: Guid, isV2?: boolean): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
1170
|
-
getYStateVector(guid?: Guid): Promise<string | null>;
|
|
1171
|
-
getSnapshotHash(options: {
|
|
1222
|
+
getYStateVector(logger: Logger, guid?: Guid): Promise<string | null>;
|
|
1223
|
+
getSnapshotHash(logger: Logger, options: {
|
|
1172
1224
|
guid?: Guid;
|
|
1173
1225
|
isV2?: boolean;
|
|
1174
1226
|
}): Promise<string | null>;
|
|
@@ -1182,8 +1234,8 @@ declare class YjsStorage {
|
|
|
1182
1234
|
isUpdated: boolean;
|
|
1183
1235
|
snapshotHash: string;
|
|
1184
1236
|
}>;
|
|
1185
|
-
loadDocByIdIfNotAlreadyLoaded(docId: YDocId): Promise<Y.Doc>;
|
|
1186
|
-
load(
|
|
1237
|
+
loadDocByIdIfNotAlreadyLoaded(logger: Logger, docId: YDocId): Promise<Y.Doc>;
|
|
1238
|
+
load(logger: Logger): Promise<void>;
|
|
1187
1239
|
/**
|
|
1188
1240
|
* Unloads the Yjs documents from memory.
|
|
1189
1241
|
*/
|
|
@@ -1196,7 +1248,8 @@ declare class YjsStorage {
|
|
|
1196
1248
|
private calculateSnapshotHash;
|
|
1197
1249
|
private getYSubdoc;
|
|
1198
1250
|
private handleYDocUpdate;
|
|
1199
|
-
private
|
|
1251
|
+
private shouldCompactBySize;
|
|
1252
|
+
private shouldCompactByKeyCount;
|
|
1200
1253
|
}
|
|
1201
1254
|
|
|
1202
1255
|
/**
|
|
@@ -1227,10 +1280,9 @@ type Millis = Brand<number, "Millis">;
|
|
|
1227
1280
|
* receives it as part of its ROOM_STATE message.
|
|
1228
1281
|
*/
|
|
1229
1282
|
type SessionKey = Brand<string, "SessionKey">;
|
|
1230
|
-
type PreSerializedServerMsg = Brand<string, "PreSerializedServerMsg">;
|
|
1231
1283
|
type ClientMsg = ClientMsg$1<JsonObject, Json> | FetchFeedsClientMsg | FetchFeedMessagesClientMsg | AddFeedClientMsg | UpdateFeedClientMsg | DeleteFeedClientMsg | AddFeedMessageClientMsg | UpdateFeedMessageClientMsg | DeleteFeedMessageClientMsg;
|
|
1232
1284
|
type ServerMsg = ServerMsg$1<JsonObject, BaseUserMeta, Json> | FeedMessagesServerMsg | FeedsServerMsg;
|
|
1233
|
-
declare function serialize(msgs: ServerMsg | readonly ServerMsg[]):
|
|
1285
|
+
declare function serialize(msgs: ServerMsg | readonly ServerMsg[]): jstring<ServerMsg>;
|
|
1234
1286
|
declare function ackIgnoredOp(opId: string): IgnoredOp;
|
|
1235
1287
|
/**
|
|
1236
1288
|
* A known or anonymous user.
|
|
@@ -1277,7 +1329,7 @@ declare class BrowserSession<SM, CM extends JsonObject> {
|
|
|
1277
1329
|
get hasNotifiedClientStorageUpdateError(): boolean;
|
|
1278
1330
|
setHasNotifiedClientStorageUpdateError(): void;
|
|
1279
1331
|
sendPong(): number;
|
|
1280
|
-
send(serverMsg: ServerMsg | ServerMsg[] |
|
|
1332
|
+
send(serverMsg: ServerMsg | ServerMsg[] | jstring<ServerMsg>): number;
|
|
1281
1333
|
}
|
|
1282
1334
|
declare class BackendSession extends BrowserSession<never, never> {
|
|
1283
1335
|
}
|
|
@@ -1316,13 +1368,6 @@ type RoomOptions<SM, CM extends JsonObject, C> = {
|
|
|
1316
1368
|
*/
|
|
1317
1369
|
storage?: IStorageDriver;
|
|
1318
1370
|
logger?: Logger;
|
|
1319
|
-
/**
|
|
1320
|
-
* Whether to allow streaming storage responses. Only safe with drivers
|
|
1321
|
-
* that can guarantee that no Ops from other clients can get interleaved
|
|
1322
|
-
* between the chunk generation until the last chunk has been sent.
|
|
1323
|
-
* Defaults to true, but is notably NOT safe to use from DOS-KV backends.
|
|
1324
|
-
*/
|
|
1325
|
-
allowStreaming?: boolean;
|
|
1326
1371
|
hooks?: {
|
|
1327
1372
|
/** Customize which incoming messages from a client are allowed or disallowed. */
|
|
1328
1373
|
isClientMsgAllowed?: (msg: ClientMsg, session: BrowserSession<SM, CM>) => {
|
|
@@ -1435,7 +1480,7 @@ declare class Room<RM, SM, CM extends JsonObject, C = undefined> {
|
|
|
1435
1480
|
createTicket(options?: CreateTicketOptions<SM, CM>): Promise<Ticket<SM, CM>>;
|
|
1436
1481
|
createBackendSession_experimental(): Promise<[
|
|
1437
1482
|
session: BackendSession,
|
|
1438
|
-
outgoingMessages:
|
|
1483
|
+
outgoingMessages: jstring<ServerMsg>[]
|
|
1439
1484
|
]>;
|
|
1440
1485
|
/**
|
|
1441
1486
|
* Restores the given sessions as the Room server's session list. Can only be
|
|
@@ -1894,4 +1939,4 @@ declare class InMemoryDriver implements IStorageDriver {
|
|
|
1894
1939
|
load_nodes_api(): IStorageDriverNodeAPI;
|
|
1895
1940
|
}
|
|
1896
1941
|
|
|
1897
|
-
export { type ActorID, type AddFeedClientMsg, type AddFeedMessageClientMsg, BackendSession, BrowserSession, ConsoleTarget, type CreateTicketOptions, DefaultMap, type DeleteFeedClientMsg, type DeleteFeedMessageClientMsg, type Feed, type FeedDeletedServerMsg, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesServerMsg, type FeedMessagesUpdatedServerMsg, FeedMsgCode, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedsAddedServerMsg, type FeedsListServerMsg, type FeedsServerMsg, type FeedsUpdatedServerMsg, type FetchFeedMessagesClientMsg, type FetchFeedsClientMsg, type FixOp, type Guid, type IReadableSnapshot, type IServerWebSocket, type IStorageDriver, type IStorageDriverNodeAPI, type IUserData, InMemoryDriver, type LeasedSession, type ListFeedMessagesOptions, type ListFeedMessagesResult, type ListFeedsOptions, type ListFeedsResult, type LoadingState, LogLevel, LogTarget, Logger, type MetadataDB, type Millis, NestedMap, type NodeMap, type NodeStream, type NodeTuple, type Pos,
|
|
1942
|
+
export { type ActorID, type AddFeedClientMsg, type AddFeedMessageClientMsg, BackendSession, BrowserSession, ConsoleTarget, type CreateTicketOptions, DefaultMap, type DeleteFeedClientMsg, type DeleteFeedMessageClientMsg, type Feed, type FeedDeletedServerMsg, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesServerMsg, type FeedMessagesUpdatedServerMsg, FeedMsgCode, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedsAddedServerMsg, type FeedsListServerMsg, type FeedsServerMsg, type FeedsUpdatedServerMsg, type FetchFeedMessagesClientMsg, type FetchFeedsClientMsg, type FixOp, type Guid, type IReadableSnapshot, type IServerWebSocket, type IStorageDriver, type IStorageDriverNodeAPI, type IUserData, InMemoryDriver, type LeasedSession, type ListFeedMessagesOptions, type ListFeedMessagesResult, type ListFeedsOptions, type ListFeedsResult, type LoadingState, LogLevel, LogTarget, Logger, type MetadataDB, type Millis, NestedMap, type NodeMap, type NodeStream, type NodeTuple, type Pos, ProtocolVersion, ROOT_YDOC_ID, Room, type SessionKey, type Ticket, UniqueMap, type UpdateFeedClientMsg, type UpdateFeedMessageClientMsg, type YDocId, type YUpdate, type YVector, ackIgnoredOp, clientMsgDecoder, concatUint8Arrays, feedFailureServerMsg, feedMetadataIdDecoder, feedMetadataUpdateDecoder, feedRequestFailed, fetchFeedsMetadataFilterDecoder, guidDecoder, isLeasedSessionExpired, jsonObjectYolo, jsonYolo, type jstring, makeInMemorySnapshot, makeMetadataDB, mapFeedError, optionalFeedMetadataDecoder, plainLsonToNodeStream, protocolVersionDecoder, quote, serialize as serializeServerMsg, snapshotToLossyJson_eager, snapshotToLossyJson_lazy, snapshotToNodeStream, snapshotToPlainLson_eager, snapshotToPlainLson_lazy, Storage as test_only__Storage, YjsStorage as test_only__YjsStorage, transientClientMsgDecoder, tryCatch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Json, asPos, IUserInfo, SerializedCrdt, JsonObject, DistributiveOmit, SetParentKeyOp, DeleteCrdtOp, ClientMsg as ClientMsg$1, Brand, SerializedRootObject, SerializedChild, StorageNode, Awaitable, CompactNode, PlainLsonObject, NodeMap as NodeMap$1, NodeStream as NodeStream$1, ClientWireOp, ServerMsg as ServerMsg$1, BaseUserMeta, IgnoredOp } from '@liveblocks/core';
|
|
2
2
|
export { BroadcastEventClientMsg, ClientMsg, ClientWireOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, DeleteCrdtOp, DeleteObjectKeyOp, FetchStorageClientMsg, FetchYDocClientMsg, HasOpId, IgnoredOp, Op, RoomStateServerMsg, ServerMsg, ServerWireOp, SetParentKeyOp, UpdateObjectOp, UpdatePresenceClientMsg, UpdateStorageClientMsg, UpdateYDocClientMsg } from '@liveblocks/core';
|
|
3
3
|
import * as decoders from 'decoders';
|
|
4
4
|
import { Decoder } from 'decoders';
|
|
@@ -23,6 +23,37 @@ import * as Y from 'yjs';
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
type Pos = ReturnType<typeof asPos>;
|
|
26
|
+
declare const fromType: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* A string known to be a valid JSON-encoded value. Use this whenever a
|
|
29
|
+
* `string` already carries JSON, to keep that fact visible in the type system
|
|
30
|
+
* (instead of letting it look like a freeform `string`).
|
|
31
|
+
*
|
|
32
|
+
* Optionally parameterised by the *parsed* shape: `jstring<CompactNode>`
|
|
33
|
+
* means "a string whose `JSON.parse` result is a `CompactNode`". Without
|
|
34
|
+
* a type argument, defaults to `jstring<Json>` (any JSON value).
|
|
35
|
+
*
|
|
36
|
+
* At storage boundaries (e.g. reading `jdata` from SQLite), `as jstring`
|
|
37
|
+
* is acceptable — we trust the bytes are valid JSON because we wrote them as
|
|
38
|
+
* JSON ourselves.
|
|
39
|
+
*
|
|
40
|
+
* For example, these are valid JSON strings:
|
|
41
|
+
* - '0', '1', '2', '3', '3.14', etc.
|
|
42
|
+
* - 'null', 'true', 'false'
|
|
43
|
+
* - '{"foo":1}', '{ "foo": 1 }' (spaces are fine)
|
|
44
|
+
* - '[]', '[1,2, 3]', '[[]]', etc.
|
|
45
|
+
* - '["hi",{}]'
|
|
46
|
+
* - '"foo"'
|
|
47
|
+
*
|
|
48
|
+
* But these are not:
|
|
49
|
+
* - 'foo'
|
|
50
|
+
* - '1,2,3'
|
|
51
|
+
* - '{'
|
|
52
|
+
* - '[1,2,3,]' or '{"foo":1},' (trailing commas are not valid)
|
|
53
|
+
*/
|
|
54
|
+
type jstring<J = Json> = string & {
|
|
55
|
+
readonly [fromType]: J;
|
|
56
|
+
};
|
|
26
57
|
type NodeTuple<T extends SerializedCrdt = SerializedCrdt> = [
|
|
27
58
|
id: string,
|
|
28
59
|
value: T
|
|
@@ -683,6 +714,27 @@ interface IStorageDriverNodeAPI {
|
|
|
683
714
|
* Yield all nodes as [id, node] pairs. Must always include the root node.
|
|
684
715
|
*/
|
|
685
716
|
iter_nodes(): Iterable<StorageNode>;
|
|
717
|
+
/**
|
|
718
|
+
* Yield each node as a pre-built `CompactNode` JSON tuple string, ready to
|
|
719
|
+
* be emitted directly into a STORAGE_CHUNK wire frame without JSON.parse()
|
|
720
|
+
* or JSON.stringify()'ing overhead. Implementations MUST produce text whose
|
|
721
|
+
* parsed shape exactly matches the `CompactNode` union type from
|
|
722
|
+
* @liveblocks/core. The emitted shapes are:
|
|
723
|
+
*
|
|
724
|
+
* - Root node: '["root",<data>]'
|
|
725
|
+
* - OBJECT / REGISTER: '["0:1",0,"root","a",<data>]'
|
|
726
|
+
* - LIST / MAP: '["0:2",1,"0:1","b"]'
|
|
727
|
+
*
|
|
728
|
+
* Invariant (implementations MUST uphold; asserted by `_generateFullTestSuite`):
|
|
729
|
+
*
|
|
730
|
+
* iter_nodes_optimized().map(JSON.parse)
|
|
731
|
+
* ≡ nodeStreamToCompactNodes(iter_nodes())
|
|
732
|
+
*
|
|
733
|
+
* i.e. parsing each yielded string yields the same sequence of CompactNodes
|
|
734
|
+
* that the canonical `iter_nodes()` + `nodeStreamToCompactNodes()` path
|
|
735
|
+
* would produce.
|
|
736
|
+
*/
|
|
737
|
+
iter_nodes_optimized(): Iterable<jstring<CompactNode>>;
|
|
686
738
|
/**
|
|
687
739
|
* Return true iff a node with the given id exists. Must return true for "root".
|
|
688
740
|
*/
|
|
@@ -1158,7 +1210,7 @@ declare class YjsStorage {
|
|
|
1158
1210
|
private readonly initPromisesById;
|
|
1159
1211
|
private readonly storedKeysById;
|
|
1160
1212
|
constructor(driver: IStorageDriver, updateCountThreshold?: number);
|
|
1161
|
-
getYDoc(docId: YDocId): Promise<Y.Doc>;
|
|
1213
|
+
getYDoc(logger: Logger, docId: YDocId): Promise<Y.Doc>;
|
|
1162
1214
|
/**
|
|
1163
1215
|
* If passed a state vector, an update with diff will be returned, if not the entire doc is returned.
|
|
1164
1216
|
*
|
|
@@ -1167,8 +1219,8 @@ declare class YjsStorage {
|
|
|
1167
1219
|
*/
|
|
1168
1220
|
getYDocUpdate(logger: Logger, stateVector?: string, guid?: Guid, isV2?: boolean): Promise<string | null>;
|
|
1169
1221
|
getYDocUpdateBinary(logger: Logger, stateVector?: string, guid?: Guid, isV2?: boolean): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
1170
|
-
getYStateVector(guid?: Guid): Promise<string | null>;
|
|
1171
|
-
getSnapshotHash(options: {
|
|
1222
|
+
getYStateVector(logger: Logger, guid?: Guid): Promise<string | null>;
|
|
1223
|
+
getSnapshotHash(logger: Logger, options: {
|
|
1172
1224
|
guid?: Guid;
|
|
1173
1225
|
isV2?: boolean;
|
|
1174
1226
|
}): Promise<string | null>;
|
|
@@ -1182,8 +1234,8 @@ declare class YjsStorage {
|
|
|
1182
1234
|
isUpdated: boolean;
|
|
1183
1235
|
snapshotHash: string;
|
|
1184
1236
|
}>;
|
|
1185
|
-
loadDocByIdIfNotAlreadyLoaded(docId: YDocId): Promise<Y.Doc>;
|
|
1186
|
-
load(
|
|
1237
|
+
loadDocByIdIfNotAlreadyLoaded(logger: Logger, docId: YDocId): Promise<Y.Doc>;
|
|
1238
|
+
load(logger: Logger): Promise<void>;
|
|
1187
1239
|
/**
|
|
1188
1240
|
* Unloads the Yjs documents from memory.
|
|
1189
1241
|
*/
|
|
@@ -1196,7 +1248,8 @@ declare class YjsStorage {
|
|
|
1196
1248
|
private calculateSnapshotHash;
|
|
1197
1249
|
private getYSubdoc;
|
|
1198
1250
|
private handleYDocUpdate;
|
|
1199
|
-
private
|
|
1251
|
+
private shouldCompactBySize;
|
|
1252
|
+
private shouldCompactByKeyCount;
|
|
1200
1253
|
}
|
|
1201
1254
|
|
|
1202
1255
|
/**
|
|
@@ -1227,10 +1280,9 @@ type Millis = Brand<number, "Millis">;
|
|
|
1227
1280
|
* receives it as part of its ROOM_STATE message.
|
|
1228
1281
|
*/
|
|
1229
1282
|
type SessionKey = Brand<string, "SessionKey">;
|
|
1230
|
-
type PreSerializedServerMsg = Brand<string, "PreSerializedServerMsg">;
|
|
1231
1283
|
type ClientMsg = ClientMsg$1<JsonObject, Json> | FetchFeedsClientMsg | FetchFeedMessagesClientMsg | AddFeedClientMsg | UpdateFeedClientMsg | DeleteFeedClientMsg | AddFeedMessageClientMsg | UpdateFeedMessageClientMsg | DeleteFeedMessageClientMsg;
|
|
1232
1284
|
type ServerMsg = ServerMsg$1<JsonObject, BaseUserMeta, Json> | FeedMessagesServerMsg | FeedsServerMsg;
|
|
1233
|
-
declare function serialize(msgs: ServerMsg | readonly ServerMsg[]):
|
|
1285
|
+
declare function serialize(msgs: ServerMsg | readonly ServerMsg[]): jstring<ServerMsg>;
|
|
1234
1286
|
declare function ackIgnoredOp(opId: string): IgnoredOp;
|
|
1235
1287
|
/**
|
|
1236
1288
|
* A known or anonymous user.
|
|
@@ -1277,7 +1329,7 @@ declare class BrowserSession<SM, CM extends JsonObject> {
|
|
|
1277
1329
|
get hasNotifiedClientStorageUpdateError(): boolean;
|
|
1278
1330
|
setHasNotifiedClientStorageUpdateError(): void;
|
|
1279
1331
|
sendPong(): number;
|
|
1280
|
-
send(serverMsg: ServerMsg | ServerMsg[] |
|
|
1332
|
+
send(serverMsg: ServerMsg | ServerMsg[] | jstring<ServerMsg>): number;
|
|
1281
1333
|
}
|
|
1282
1334
|
declare class BackendSession extends BrowserSession<never, never> {
|
|
1283
1335
|
}
|
|
@@ -1316,13 +1368,6 @@ type RoomOptions<SM, CM extends JsonObject, C> = {
|
|
|
1316
1368
|
*/
|
|
1317
1369
|
storage?: IStorageDriver;
|
|
1318
1370
|
logger?: Logger;
|
|
1319
|
-
/**
|
|
1320
|
-
* Whether to allow streaming storage responses. Only safe with drivers
|
|
1321
|
-
* that can guarantee that no Ops from other clients can get interleaved
|
|
1322
|
-
* between the chunk generation until the last chunk has been sent.
|
|
1323
|
-
* Defaults to true, but is notably NOT safe to use from DOS-KV backends.
|
|
1324
|
-
*/
|
|
1325
|
-
allowStreaming?: boolean;
|
|
1326
1371
|
hooks?: {
|
|
1327
1372
|
/** Customize which incoming messages from a client are allowed or disallowed. */
|
|
1328
1373
|
isClientMsgAllowed?: (msg: ClientMsg, session: BrowserSession<SM, CM>) => {
|
|
@@ -1435,7 +1480,7 @@ declare class Room<RM, SM, CM extends JsonObject, C = undefined> {
|
|
|
1435
1480
|
createTicket(options?: CreateTicketOptions<SM, CM>): Promise<Ticket<SM, CM>>;
|
|
1436
1481
|
createBackendSession_experimental(): Promise<[
|
|
1437
1482
|
session: BackendSession,
|
|
1438
|
-
outgoingMessages:
|
|
1483
|
+
outgoingMessages: jstring<ServerMsg>[]
|
|
1439
1484
|
]>;
|
|
1440
1485
|
/**
|
|
1441
1486
|
* Restores the given sessions as the Room server's session list. Can only be
|
|
@@ -1894,4 +1939,4 @@ declare class InMemoryDriver implements IStorageDriver {
|
|
|
1894
1939
|
load_nodes_api(): IStorageDriverNodeAPI;
|
|
1895
1940
|
}
|
|
1896
1941
|
|
|
1897
|
-
export { type ActorID, type AddFeedClientMsg, type AddFeedMessageClientMsg, BackendSession, BrowserSession, ConsoleTarget, type CreateTicketOptions, DefaultMap, type DeleteFeedClientMsg, type DeleteFeedMessageClientMsg, type Feed, type FeedDeletedServerMsg, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesServerMsg, type FeedMessagesUpdatedServerMsg, FeedMsgCode, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedsAddedServerMsg, type FeedsListServerMsg, type FeedsServerMsg, type FeedsUpdatedServerMsg, type FetchFeedMessagesClientMsg, type FetchFeedsClientMsg, type FixOp, type Guid, type IReadableSnapshot, type IServerWebSocket, type IStorageDriver, type IStorageDriverNodeAPI, type IUserData, InMemoryDriver, type LeasedSession, type ListFeedMessagesOptions, type ListFeedMessagesResult, type ListFeedsOptions, type ListFeedsResult, type LoadingState, LogLevel, LogTarget, Logger, type MetadataDB, type Millis, NestedMap, type NodeMap, type NodeStream, type NodeTuple, type Pos,
|
|
1942
|
+
export { type ActorID, type AddFeedClientMsg, type AddFeedMessageClientMsg, BackendSession, BrowserSession, ConsoleTarget, type CreateTicketOptions, DefaultMap, type DeleteFeedClientMsg, type DeleteFeedMessageClientMsg, type Feed, type FeedDeletedServerMsg, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesServerMsg, type FeedMessagesUpdatedServerMsg, FeedMsgCode, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedsAddedServerMsg, type FeedsListServerMsg, type FeedsServerMsg, type FeedsUpdatedServerMsg, type FetchFeedMessagesClientMsg, type FetchFeedsClientMsg, type FixOp, type Guid, type IReadableSnapshot, type IServerWebSocket, type IStorageDriver, type IStorageDriverNodeAPI, type IUserData, InMemoryDriver, type LeasedSession, type ListFeedMessagesOptions, type ListFeedMessagesResult, type ListFeedsOptions, type ListFeedsResult, type LoadingState, LogLevel, LogTarget, Logger, type MetadataDB, type Millis, NestedMap, type NodeMap, type NodeStream, type NodeTuple, type Pos, ProtocolVersion, ROOT_YDOC_ID, Room, type SessionKey, type Ticket, UniqueMap, type UpdateFeedClientMsg, type UpdateFeedMessageClientMsg, type YDocId, type YUpdate, type YVector, ackIgnoredOp, clientMsgDecoder, concatUint8Arrays, feedFailureServerMsg, feedMetadataIdDecoder, feedMetadataUpdateDecoder, feedRequestFailed, fetchFeedsMetadataFilterDecoder, guidDecoder, isLeasedSessionExpired, jsonObjectYolo, jsonYolo, type jstring, makeInMemorySnapshot, makeMetadataDB, mapFeedError, optionalFeedMetadataDecoder, plainLsonToNodeStream, protocolVersionDecoder, quote, serialize as serializeServerMsg, snapshotToLossyJson_eager, snapshotToLossyJson_lazy, snapshotToNodeStream, snapshotToPlainLson_eager, snapshotToPlainLson_lazy, Storage as test_only__Storage, YjsStorage as test_only__YjsStorage, transientClientMsgDecoder, tryCatch };
|