@pluv/client 0.11.0 → 0.12.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/client@0.11.0 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@0.12.0 build /home/runner/work/pluv/pluv/packages/client
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 40.42 KB
12
- CJS ⚡️ Build success in 115ms
13
- ESM dist/index.mjs 39.21 KB
14
- ESM ⚡️ Build success in 116ms
11
+ ESM dist/index.mjs 42.91 KB
12
+ ESM ⚡️ Build success in 113ms
13
+ CJS dist/index.js 44.16 KB
14
+ CJS ⚡️ Build success in 113ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5950ms
17
- DTS dist/index.d.mts 13.18 KB
18
- DTS dist/index.d.ts 13.18 KB
16
+ DTS ⚡️ Build success in 4686ms
17
+ DTS dist/index.d.mts 14.25 KB
18
+ DTS dist/index.d.ts 14.25 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,260 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 436040b: Added ability to undo and redo changes to storage.
8
+
9
+ ## @pluv/crdt-yjs
10
+
11
+ `@pluv/crdt-yjs` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `trackOrigins`.
12
+
13
+ Refer to the code-example below to better understand how to undo and redo with your doc.
14
+
15
+ ```ts
16
+ // Example
17
+ import { array, doc } from "@pluv/crdt-yjs";
18
+
19
+ // Create your doc with your shared-types
20
+ const myDoc = doc({
21
+ messages: array<string>([]),
22
+ });
23
+
24
+ /**
25
+ * @description Track origins to enable undos and redos for your document.
26
+ * trackOrigins must be called before any storage mutations, to enable those
27
+ * mutations to be undone/redone.
28
+ */
29
+ myDoc.trackOrigins({
30
+ /**
31
+ * @description This is the same `captureTimeout` option from yjs's UndoManager.
32
+ * This specifies a number in ms, during which edits are merged together to be
33
+ * undone together. Set this to 0, to track each transacted change individually.
34
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
35
+ * @default 500
36
+ */
37
+ captureTimeout: 500,
38
+ /**
39
+ * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
40
+ * This specifies transaction origins (strings only) to filter which transactions
41
+ * can be undone.
42
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
43
+ * @default undefined
44
+ */
45
+ trackedOrigins: ["user-123"],
46
+ });
47
+
48
+ /**
49
+ * @description Check whether calling undo will mutate storage
50
+ * @returns boolean
51
+ */
52
+ myDoc.canUndo();
53
+ /**
54
+ * @description Check whether calling redo will mutate storage
55
+ * @returns boolean
56
+ */
57
+ myDoc.canRedo();
58
+
59
+ // Perform a storage mutation within a transaction so that it can be affected
60
+ // by undo/redo operations.
61
+ myDoc.transact(() => {
62
+ myDoc.get("messages").push(["hello world!"]);
63
+ }, "user-123");
64
+
65
+ /**
66
+ * @description Undoes the last valid mutation to storage
67
+ */
68
+ myDoc.undo();
69
+
70
+ /**
71
+ * @description Re-applies the last undone mutation to storage
72
+ */
73
+ myDoc.redo();
74
+ ```
75
+
76
+ ## @pluv/client
77
+
78
+ `@pluv/client`'s `PluvRoom` and `MockedRoom` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `transact`.
79
+
80
+ Refer to the code-example below to better understand how to undo and redo with your `PluvRoom`.
81
+
82
+ ```ts
83
+ import { createClient, y } from "@pluv/client";
84
+
85
+ const client = createClient({});
86
+
87
+ /**
88
+ * @description When a room is created, undo/redo will automatically
89
+ * be configured to filter for changes made by the connected user
90
+ * (so that users only undo/redo their changes).
91
+ */
92
+ const room = client.createRoom("my-room", {
93
+ initialStorage: () => ({
94
+ messages: y.array<string>([]),
95
+ }),
96
+ /**
97
+ * @description This is the same `captureTimeout` option from yjs's UndoManager.
98
+ * This specifies a number in ms, during which edits are merged together to be
99
+ * undone together. Set this to 0, to track each transacted change individually.
100
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
101
+ * @default 500
102
+ */
103
+ captureTimeout: 500,
104
+ /**
105
+ * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
106
+ * This specifies transaction origins (strings only) to filter which transactions
107
+ * can be undone.
108
+ * When omitted, the user's connection id will be tracked. When provided,
109
+ * specifies additional tracked origins besides the user's connection id.
110
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
111
+ * @default undefined
112
+ */
113
+ trackedOrigins: ["user-123"],
114
+ });
115
+
116
+ /**
117
+ * @description Check whether calling undo will mutate storage
118
+ * @returns boolean
119
+ */
120
+ room.canUndo();
121
+ /**
122
+ * @description Check whether calling redo will mutate storage
123
+ * @returns boolean
124
+ */
125
+ room.canRedo();
126
+
127
+ /**
128
+ * @description Calling transact will enable a storage mutation to be undone/redone.
129
+ * When called without an origin, the origin will default to the user's connection
130
+ * id.
131
+ *
132
+ * You can specify a 2nd parameter to transact with a different transaction origin.
133
+ */
134
+ room.transact(() => {
135
+ room.get("messages").push(["hello world!"]);
136
+ });
137
+
138
+ // This will also be undoable because `"user-123"` is a tracked origin.
139
+ room.transact(() => {
140
+ room.get("messages").push(["hello world!"]);
141
+ }, "user-123");
142
+
143
+ /**
144
+ * @description Undoes the last valid mutation to storage
145
+ */
146
+ room.undo();
147
+
148
+ /**
149
+ * @description Re-applies the last undone mutation to storage
150
+ */
151
+ room.redo();
152
+ ```
153
+
154
+ ## @pluv/react
155
+
156
+ `@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `usePluvCanRedo`, `usePluvCanUndo`, `usePluvRedo`, `usePluvUndo` and `usePluvTransact`.
157
+
158
+ Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
159
+
160
+ ```tsx
161
+ import { createBundle, createClient, y } from "@pluv/react";
162
+ import { type io } from "./io";
163
+
164
+ const client = createClient<typeof io>();
165
+
166
+ const { createRoomBundle } = createBundle(client);
167
+
168
+ const {
169
+ usePluvCanRedo,
170
+ usePluvCanUndo,
171
+ usePluvRedo,
172
+ usePluvStorage,
173
+ usePluvTransact,
174
+ usePluvUndo,
175
+ } = createRoomBundle({
176
+ initialStorage: () => ({
177
+ messages: y.array<string>([]),
178
+ }),
179
+ /**
180
+ * @description This is the same `captureTimeout` option from yjs's UndoManager.
181
+ * This specifies a number in ms, during which edits are merged together to be
182
+ * undone together. Set this to 0, to track each transacted change individually.
183
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
184
+ * @default 500
185
+ */
186
+ captureTimeout: 500,
187
+ /**
188
+ * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
189
+ * This specifies transaction origins (strings only) to filter which transactions
190
+ * can be undone.
191
+ * When omitted, the user's connection id will be tracked. When provided,
192
+ * specifies additional tracked origins besides the user's connection id.
193
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
194
+ * @default undefined
195
+ */
196
+ trackedOrigins: ["user-123"],
197
+ });
198
+
199
+ /**
200
+ * @description Check whether calling undo will mutate storage
201
+ */
202
+ const canUndo: boolean = usePluvCanUndo();
203
+ /**
204
+ * @description Check whether calling redo will mutate storage
205
+ */
206
+ const canRedo: boolean = usePluvCanRedo();
207
+
208
+ const [messages, sharedType] = usePluvStorage("messages");
209
+
210
+ /**
211
+ * @description Calling transact will enable a storage mutation to be undone/redone.
212
+ * When called without an origin, the origin will default to the user's connection
213
+ * id.
214
+ *
215
+ * You can specify a 2nd parameter to transact with a different transaction origin.
216
+ */
217
+ const transact = usePluvTransact();
218
+
219
+ transact(() => {
220
+ sharedType?.push(["hello world!"]);
221
+ });
222
+
223
+ // This will also be undoable because `"user-123"` is a tracked origin.
224
+ transact(() => {
225
+ sharedType?.push(["hello world!"]);
226
+ }, "user-123");
227
+
228
+ /**
229
+ * @description Undoes the last valid mutation to storage
230
+ */
231
+ const undo = usePluvUndo();
232
+
233
+ undo();
234
+
235
+ /**
236
+ * @description Re-applies the last undone mutation to storage
237
+ */
238
+ const redo = usePluvRedo();
239
+
240
+ redo();
241
+ ```
242
+
243
+ ### Patch Changes
244
+
245
+ - Updated dependencies [436040b]
246
+ - @pluv/crdt-yjs@0.12.0
247
+ - @pluv/types@0.12.0
248
+
249
+ ## 0.11.1
250
+
251
+ ### Patch Changes
252
+
253
+ - 74b3061: Bumped minor and patch dependencies.
254
+ - Updated dependencies [74b3061]
255
+ - @pluv/crdt-yjs@0.11.1
256
+ - @pluv/types@0.11.1
257
+
3
258
  ## 0.11.0
4
259
 
5
260
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { InferYjsSharedTypeJson, array, map, object, text, xmlElement, xmlFragment, xmlText } from '@pluv/crdt-yjs';
2
- export { InferYjsSharedTypeJson } from '@pluv/crdt-yjs';
1
+ import { InferYjsSharedTypeJson, TrackOriginOptions, array, map, object, text, xmlElement, xmlFragment, xmlText } from '@pluv/crdt-yjs';
2
+ export { InferYjsSharedTypeJson, TrackOriginOptions } from '@pluv/crdt-yjs';
3
3
  import * as _pluv_types from '@pluv/types';
4
4
  import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, InferIOAuthorizeUser, InferIOAuthorize, InferIOInput, InputZodLike, InferIOAuthorizeRequired } from '@pluv/types';
5
5
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
@@ -51,6 +51,8 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
51
51
  readonly id: string;
52
52
  constructor(room: string);
53
53
  abstract broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
54
+ abstract canRedo(): boolean;
55
+ abstract canUndo(): boolean;
54
56
  abstract event<TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>): () => void;
55
57
  abstract getConnection(): WebSocketConnection;
56
58
  abstract getMyPresence(): TPresence;
@@ -59,8 +61,14 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
59
61
  abstract getOthers(): readonly Id<UserInfo<TIO, TPresence>>[];
60
62
  abstract getStorage<TKey extends keyof TStorage>(key: TKey): TStorage[TKey] | null;
61
63
  abstract other(connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>): () => void;
64
+ abstract redo(): void;
62
65
  abstract storage<TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void): () => void;
66
+ abstract storageRoot(fn: (value: {
67
+ [P in keyof TStorage]: InferYjsSharedTypeJson<TStorage[P]>;
68
+ }) => void): () => void;
63
69
  abstract subscribe<TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>): () => void;
70
+ abstract transact(fn: (storage: TStorage) => void, origin?: string): void;
71
+ abstract undo(): void;
64
72
  abstract updateMyPresence(presence: Partial<TPresence>): void;
65
73
  }
66
74
 
@@ -75,10 +83,10 @@ declare abstract class AbstractStorageStore {
75
83
  abstract initialize(): Promise<void>;
76
84
  }
77
85
 
78
- interface CrdtManagerOptions<TStorage extends Record<string, AbstractType<any>> = {}> {
86
+ type CrdtManagerOptions<TStorage extends Record<string, AbstractType<any>> = {}> = {
79
87
  encodedState?: string | Uint8Array | null;
80
88
  initialStorage?: () => TStorage;
81
- }
89
+ } & TrackOriginOptions;
82
90
 
83
91
  type UsersManagerConfig<TPresence extends JsonObject = {}> = {
84
92
  initialPresence?: TPresence;
@@ -121,9 +129,10 @@ type PluvRoomOptions<TIO extends IOLike, TPresence extends JsonObject = {}, TSto
121
129
  debug?: boolean | PluvRoomDebug<TIO>;
122
130
  onAuthorizationFail?: (error: Error) => void;
123
131
  } & Omit<CrdtManagerOptions<TStorage>, "encodedState"> & UsersManagerConfig<TPresence>;
124
- type RoomConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> = RoomEndpoints<TIO> & PluvRoomOptions<TIO, TPresence, TStorage>;
132
+ type RoomConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> = RoomEndpoints<TIO> & PluvRoomOptions<TIO, TPresence, TStorage> & TrackOriginOptions;
125
133
  declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> extends AbstractRoom<TIO, TPresence, TStorage> {
126
134
  readonly _endpoints: RoomEndpoints<TIO>;
135
+ private _captureTimeout;
127
136
  private _crdtManager;
128
137
  private _crdtNotifier;
129
138
  private _debug;
@@ -136,12 +145,15 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
136
145
  private _storageStore;
137
146
  private _subscriptions;
138
147
  private _timeouts;
148
+ private _trackedOrigins;
139
149
  private _windowListeners;
140
150
  private _wsListeners;
141
151
  private _usersManager;
142
152
  constructor(room: string, options: RoomConfig<TIO, TPresence, TStorage>);
143
153
  get webSocket(): WebSocket | null;
144
154
  broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
155
+ canRedo: () => boolean;
156
+ canUndo: () => boolean;
145
157
  connect(): Promise<void>;
146
158
  disconnect(): Promise<void>;
147
159
  event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
@@ -152,8 +164,12 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
152
164
  getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
153
165
  getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey] | null;
154
166
  other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
167
+ redo: () => void;
155
168
  storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
169
+ storageRoot: (fn: (value: { [P in keyof TStorage]: InferYjsSharedTypeJson<TStorage[P]>; }) => void) => (() => void);
156
170
  subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
171
+ transact: (fn: (storage: TStorage) => void, origin?: string) => void;
172
+ undo: () => void;
157
173
  updateMyPresence: (presence: Partial<TPresence>) => void;
158
174
  private _addToStorageStore;
159
175
  private _applyStorageStore;
@@ -169,6 +185,7 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
169
185
  private _getAddon;
170
186
  private _getAuthFetchOptions;
171
187
  private _getAuthorization;
188
+ private _getTrackedOrigins;
172
189
  private _getWsEndpoint;
173
190
  private _handleExit;
174
191
  private _handlePresenceUpdatedMessage;
@@ -243,6 +260,8 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
243
260
  private _usersManager;
244
261
  constructor(room: string, options: MockedRoomConfig<TIO, TPresence, TStorage>);
245
262
  broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
263
+ canRedo: () => boolean;
264
+ canUndo: () => boolean;
246
265
  event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
247
266
  getConnection(): WebSocketConnection;
248
267
  getMyPresence: () => TPresence;
@@ -251,8 +270,12 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
251
270
  getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
252
271
  getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey] | null;
253
272
  other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
273
+ redo: () => void;
254
274
  storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
275
+ storageRoot: (fn: (value: { [P in keyof TStorage]: InferYjsSharedTypeJson<TStorage[P]>; }) => void) => (() => void);
255
276
  subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
277
+ transact: (fn: (storage: TStorage) => void, origin?: string) => void;
278
+ undo: () => void;
256
279
  updateMyPresence: (presence: Partial<TPresence>) => void;
257
280
  private _observeCrdt;
258
281
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { InferYjsSharedTypeJson, array, map, object, text, xmlElement, xmlFragment, xmlText } from '@pluv/crdt-yjs';
2
- export { InferYjsSharedTypeJson } from '@pluv/crdt-yjs';
1
+ import { InferYjsSharedTypeJson, TrackOriginOptions, array, map, object, text, xmlElement, xmlFragment, xmlText } from '@pluv/crdt-yjs';
2
+ export { InferYjsSharedTypeJson, TrackOriginOptions } from '@pluv/crdt-yjs';
3
3
  import * as _pluv_types from '@pluv/types';
4
4
  import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, InferIOAuthorizeUser, InferIOAuthorize, InferIOInput, InputZodLike, InferIOAuthorizeRequired } from '@pluv/types';
5
5
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
@@ -51,6 +51,8 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
51
51
  readonly id: string;
52
52
  constructor(room: string);
53
53
  abstract broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
54
+ abstract canRedo(): boolean;
55
+ abstract canUndo(): boolean;
54
56
  abstract event<TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>): () => void;
55
57
  abstract getConnection(): WebSocketConnection;
56
58
  abstract getMyPresence(): TPresence;
@@ -59,8 +61,14 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
59
61
  abstract getOthers(): readonly Id<UserInfo<TIO, TPresence>>[];
60
62
  abstract getStorage<TKey extends keyof TStorage>(key: TKey): TStorage[TKey] | null;
61
63
  abstract other(connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>): () => void;
64
+ abstract redo(): void;
62
65
  abstract storage<TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void): () => void;
66
+ abstract storageRoot(fn: (value: {
67
+ [P in keyof TStorage]: InferYjsSharedTypeJson<TStorage[P]>;
68
+ }) => void): () => void;
63
69
  abstract subscribe<TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>): () => void;
70
+ abstract transact(fn: (storage: TStorage) => void, origin?: string): void;
71
+ abstract undo(): void;
64
72
  abstract updateMyPresence(presence: Partial<TPresence>): void;
65
73
  }
66
74
 
@@ -75,10 +83,10 @@ declare abstract class AbstractStorageStore {
75
83
  abstract initialize(): Promise<void>;
76
84
  }
77
85
 
78
- interface CrdtManagerOptions<TStorage extends Record<string, AbstractType<any>> = {}> {
86
+ type CrdtManagerOptions<TStorage extends Record<string, AbstractType<any>> = {}> = {
79
87
  encodedState?: string | Uint8Array | null;
80
88
  initialStorage?: () => TStorage;
81
- }
89
+ } & TrackOriginOptions;
82
90
 
83
91
  type UsersManagerConfig<TPresence extends JsonObject = {}> = {
84
92
  initialPresence?: TPresence;
@@ -121,9 +129,10 @@ type PluvRoomOptions<TIO extends IOLike, TPresence extends JsonObject = {}, TSto
121
129
  debug?: boolean | PluvRoomDebug<TIO>;
122
130
  onAuthorizationFail?: (error: Error) => void;
123
131
  } & Omit<CrdtManagerOptions<TStorage>, "encodedState"> & UsersManagerConfig<TPresence>;
124
- type RoomConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> = RoomEndpoints<TIO> & PluvRoomOptions<TIO, TPresence, TStorage>;
132
+ type RoomConfig<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> = RoomEndpoints<TIO> & PluvRoomOptions<TIO, TPresence, TStorage> & TrackOriginOptions;
125
133
  declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> extends AbstractRoom<TIO, TPresence, TStorage> {
126
134
  readonly _endpoints: RoomEndpoints<TIO>;
135
+ private _captureTimeout;
127
136
  private _crdtManager;
128
137
  private _crdtNotifier;
129
138
  private _debug;
@@ -136,12 +145,15 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
136
145
  private _storageStore;
137
146
  private _subscriptions;
138
147
  private _timeouts;
148
+ private _trackedOrigins;
139
149
  private _windowListeners;
140
150
  private _wsListeners;
141
151
  private _usersManager;
142
152
  constructor(room: string, options: RoomConfig<TIO, TPresence, TStorage>);
143
153
  get webSocket(): WebSocket | null;
144
154
  broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
155
+ canRedo: () => boolean;
156
+ canUndo: () => boolean;
145
157
  connect(): Promise<void>;
146
158
  disconnect(): Promise<void>;
147
159
  event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
@@ -152,8 +164,12 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
152
164
  getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
153
165
  getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey] | null;
154
166
  other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
167
+ redo: () => void;
155
168
  storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
169
+ storageRoot: (fn: (value: { [P in keyof TStorage]: InferYjsSharedTypeJson<TStorage[P]>; }) => void) => (() => void);
156
170
  subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
171
+ transact: (fn: (storage: TStorage) => void, origin?: string) => void;
172
+ undo: () => void;
157
173
  updateMyPresence: (presence: Partial<TPresence>) => void;
158
174
  private _addToStorageStore;
159
175
  private _applyStorageStore;
@@ -169,6 +185,7 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
169
185
  private _getAddon;
170
186
  private _getAuthFetchOptions;
171
187
  private _getAuthorization;
188
+ private _getTrackedOrigins;
172
189
  private _getWsEndpoint;
173
190
  private _handleExit;
174
191
  private _handlePresenceUpdatedMessage;
@@ -243,6 +260,8 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
243
260
  private _usersManager;
244
261
  constructor(room: string, options: MockedRoomConfig<TIO, TPresence, TStorage>);
245
262
  broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
263
+ canRedo: () => boolean;
264
+ canUndo: () => boolean;
246
265
  event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
247
266
  getConnection(): WebSocketConnection;
248
267
  getMyPresence: () => TPresence;
@@ -251,8 +270,12 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
251
270
  getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
252
271
  getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey] | null;
253
272
  other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
273
+ redo: () => void;
254
274
  storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
275
+ storageRoot: (fn: (value: { [P in keyof TStorage]: InferYjsSharedTypeJson<TStorage[P]>; }) => void) => (() => void);
255
276
  subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
277
+ transact: (fn: (storage: TStorage) => void, origin?: string) => void;
278
+ undo: () => void;
256
279
  updateMyPresence: (presence: Partial<TPresence>) => void;
257
280
  private _observeCrdt;
258
281
  }