@pluv/client 2.2.1 → 2.2.2
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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +997 -996
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @pluv/client
|
|
2
2
|
|
|
3
|
+
## 2.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/crdt@2.2.2
|
|
8
|
+
- @pluv/types@2.2.2
|
|
9
|
+
|
|
3
10
|
## 2.2.1
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -13,43 +20,43 @@
|
|
|
13
20
|
|
|
14
21
|
- 3ce1547: Updated typings for `PluvRoom.getDoc` to be narrower to get the native doc type.
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import { createClient } from "@pluv/client";
|
|
25
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
26
|
+
import type { Doc as YDoc } from "yjs";
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const client = createClient({
|
|
29
|
+
// ...
|
|
30
|
+
crdt: yjs,
|
|
31
|
+
});
|
|
32
|
+
const room = client.createRoom("example-room");
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
const doc = room.getDoc();
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
// This is now typed as the native YDoc
|
|
37
|
+
doc.value;
|
|
38
|
+
// ^? const value: YDoc
|
|
39
|
+
```
|
|
33
40
|
|
|
34
41
|
- fd3bfe2: Added the ability to listen to the room's underlying websocket's event listeners.
|
|
35
42
|
- aee40cb: Updated `presence` types to be more lenient (i.e. no-longer extends `JsonObject`). This is to enable types like `.passthrough` with zod, which can be useful for integrating `yjs.awareness` with libraries such as [lexical](https://lexical.dev/).
|
|
36
43
|
- edd1789: **DEPRECATED** `PluvRoom.storageLoaded` will be removed in v3. Added `PluvRoom.getStorageLoaded` with improved detection of when the storage was synced.
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
```ts
|
|
46
|
+
const room = client.createRoom("example-room");
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
// Before
|
|
49
|
+
room.storageLoaded;
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
// After
|
|
52
|
+
room.getStorageLoaded();
|
|
53
|
+
```
|
|
47
54
|
|
|
48
55
|
### Patch Changes
|
|
49
56
|
|
|
50
57
|
- 48191fa: Fixed `PluvRoom.getDoc` not returning a stable doc reference for a single connection.
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
- @pluv/crdt@2.2.0
|
|
59
|
+
- @pluv/types@2.2.0
|
|
53
60
|
|
|
54
61
|
## 2.1.0
|
|
55
62
|
|
|
@@ -57,96 +64,96 @@
|
|
|
57
64
|
|
|
58
65
|
- e8d8fbc: **DEPRECATED** Subscribing to data via string parameters on `PluvRoom.subscribe` is deprecated, to be removed in v3. To subscribe to things such as `myself`, `my-presence` and `others`, you must now do so via nested properties on the `subscribe` object (see example below).
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
```ts
|
|
68
|
+
const room = client.createRoom("example-room");
|
|
69
|
+
|
|
70
|
+
// Before (now deprecated)
|
|
71
|
+
room.subscribe("connection", (state) => {});
|
|
72
|
+
room.subscribe("my-presence", (myPresence) => {});
|
|
73
|
+
room.subscribe("myself", (myself) => {});
|
|
74
|
+
room.subscribe("others", (others) => {});
|
|
75
|
+
room.subscribe("storage-loaded", (storageLoaded) => {});
|
|
76
|
+
|
|
77
|
+
// After
|
|
78
|
+
room.subscribe.connection((state) => {});
|
|
79
|
+
room.subscribe.myPresence((myPresence) => {});
|
|
80
|
+
room.subscribe.myself((myself) => {});
|
|
81
|
+
room.subscribe.others((others) => {});
|
|
82
|
+
room.subscribe.storageLoaded((storageLoaded) => {});
|
|
83
|
+
```
|
|
77
84
|
|
|
78
85
|
- d5ac29e: **DEPRECATED** `PluvRoom.event`, `PluvRoom.storage`, `PluvRoom.storageRoot` and `PluvRoom.other` have all been deprecated, to be removed in v3. These now exist under `PluvRoom.subscribe` instead.
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
```ts
|
|
88
|
+
const room = client.createRoom("example-room");
|
|
89
|
+
|
|
90
|
+
// Before (now deprecated)
|
|
91
|
+
room.event.receiveMessage((event) => {});
|
|
92
|
+
room.storage.messages((messages) => {});
|
|
93
|
+
room.storageRoot((storage) => {});
|
|
94
|
+
room.other(("id_...", other) => {});
|
|
95
|
+
|
|
96
|
+
// After
|
|
97
|
+
room.subscribe.event.receiveMessage((event) => {});
|
|
98
|
+
room.subscribe.storage.messages((messages) => {});
|
|
99
|
+
room.subscribe.storageRoot((storage) => {});
|
|
100
|
+
room.subscribe.other(("id_...", other) => {});
|
|
101
|
+
```
|
|
95
102
|
|
|
96
103
|
- 5ca5cb6: Updated `PluvRoom.storage` to also allow subscribing to storage fields as nested properties.
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
```ts
|
|
106
|
+
const client = createClient({
|
|
107
|
+
// ...
|
|
108
|
+
initialStorage: yjs.doc((t) => ({
|
|
109
|
+
messages: yjs.array<string>(),
|
|
110
|
+
})),
|
|
111
|
+
});
|
|
105
112
|
|
|
106
|
-
|
|
113
|
+
const room = client.createRoom("example-room");
|
|
107
114
|
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
// The two statements below are equivalent.
|
|
116
|
+
room.storage("messages", (value) => {});
|
|
110
117
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
// You can now subscribe to storage fields as nested properties like so
|
|
119
|
+
room.storage.messages((value) => {});
|
|
120
|
+
```
|
|
114
121
|
|
|
115
122
|
- 4acbe1e: Updated `PluvRoom.storage` to also allow subscribing to the root storage when no field is provided.
|
|
116
123
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
```ts
|
|
125
|
+
const client = createClient({
|
|
126
|
+
// ...
|
|
127
|
+
initialStorage: yjs.doc((t) => ({
|
|
128
|
+
messages: yjs.array<string>(),
|
|
129
|
+
})),
|
|
130
|
+
});
|
|
124
131
|
|
|
125
|
-
|
|
132
|
+
const room = client.createRoom("example-room");
|
|
126
133
|
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
room.storage("messages", (value) => {});
|
|
135
|
+
// ^? const value: string[];
|
|
129
136
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
// You can now subscribe to the storage root when no key is provided
|
|
138
|
+
room.storage((value) => {});
|
|
139
|
+
// ^? const value: { messages: string[] };
|
|
140
|
+
```
|
|
134
141
|
|
|
135
142
|
- e8d8fbc: Updated `PluvRoom.subscribe` so that `PluvRoom.event` and `PluvRoom.storage` can be accessed as properties under `PluvRoom.subscribe`.
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
```ts
|
|
145
|
+
const room = client.createRoom("example-room");
|
|
139
146
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
// These are now available under the subscribe object
|
|
148
|
+
room.subscribe.event.receiveEvent((event) => {});
|
|
149
|
+
room.subscribe.storage.messages((data) => {});
|
|
150
|
+
```
|
|
144
151
|
|
|
145
152
|
### Patch Changes
|
|
146
153
|
|
|
147
154
|
- a86ff5e: Updated internal types to simplify the type for `PluvRoom.broadcast` and `PluvRoom.event`.
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
- @pluv/crdt@2.1.0
|
|
156
|
+
- @pluv/types@2.1.0
|
|
150
157
|
|
|
151
158
|
## 2.0.2
|
|
152
159
|
|
|
@@ -160,8 +167,8 @@
|
|
|
160
167
|
### Patch Changes
|
|
161
168
|
|
|
162
169
|
- 1b93b18: Fixed `ConnectionState` not being exported.
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
- @pluv/crdt@2.0.1
|
|
171
|
+
- @pluv/types@2.0.1
|
|
165
172
|
|
|
166
173
|
## 2.0.0
|
|
167
174
|
|
|
@@ -171,24 +178,24 @@
|
|
|
171
178
|
- 0806212: Fix the room's id not being defined during the initialization of addons.
|
|
172
179
|
- 3a34dbb: Fixed `initialStorage` on `PluvClient.createRoom` not overwriting the `initialStorage` from the `PluvClient` constructor.
|
|
173
180
|
- Updated dependencies [047a1d8]
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
- @pluv/types@2.0.0
|
|
182
|
+
- @pluv/crdt@2.0.0
|
|
176
183
|
|
|
177
184
|
## 1.0.2
|
|
178
185
|
|
|
179
186
|
### Patch Changes
|
|
180
187
|
|
|
181
188
|
- d87159c: Restored `@pluv/addon-indexeddb` functionality, and fixed `@pluv/addon-indexeddb` sometimes duplicating storage operations based on `initialStorage` values.
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
- @pluv/crdt@1.0.2
|
|
190
|
+
- @pluv/types@1.0.2
|
|
184
191
|
|
|
185
192
|
## 1.0.1
|
|
186
193
|
|
|
187
194
|
### Patch Changes
|
|
188
195
|
|
|
189
196
|
- c583be9: Fixed storage race condition that occurred when 2 users joined a room near simultaneously that would cause users to have mismatched storage states from the server (and thereby preventing updates from properly registering) until the user reconnected.
|
|
190
|
-
|
|
191
|
-
|
|
197
|
+
- @pluv/crdt@1.0.1
|
|
198
|
+
- @pluv/types@1.0.1
|
|
192
199
|
|
|
193
200
|
## 1.0.0
|
|
194
201
|
|
|
@@ -196,31 +203,31 @@
|
|
|
196
203
|
|
|
197
204
|
- af94706: pluv.io is now stable and production ready!
|
|
198
205
|
|
|
199
|
-
|
|
206
|
+
With this v1 release, pluv.io will now follow [semantic versioning](https://semver.org/) with more comprehensive release notes for future changes to the library.
|
|
200
207
|
|
|
201
|
-
|
|
208
|
+
Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
|
|
202
209
|
|
|
203
210
|
### Patch Changes
|
|
204
211
|
|
|
205
212
|
- Updated dependencies [af94706]
|
|
206
|
-
|
|
207
|
-
|
|
213
|
+
- @pluv/crdt@1.0.0
|
|
214
|
+
- @pluv/types@1.0.0
|
|
208
215
|
|
|
209
216
|
## 0.44.2
|
|
210
217
|
|
|
211
218
|
### Patch Changes
|
|
212
219
|
|
|
213
220
|
- 6cfd36f: Update `PluvRoom` to attempt to reconnect if currently disconnected when the window is re-focused.
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
- @pluv/crdt@0.44.2
|
|
222
|
+
- @pluv/types@0.44.2
|
|
216
223
|
|
|
217
224
|
## 0.44.1
|
|
218
225
|
|
|
219
226
|
### Patch Changes
|
|
220
227
|
|
|
221
228
|
- 67c081d: Fix `PluvRoom._reconnect` not being called with the last used metadata (from `PluvRoom.connect`).
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
- @pluv/crdt@0.44.1
|
|
230
|
+
- @pluv/types@0.44.1
|
|
224
231
|
|
|
225
232
|
## 0.44.0
|
|
226
233
|
|
|
@@ -232,8 +239,8 @@
|
|
|
232
239
|
|
|
233
240
|
- fba9354: Fix potential edge case where event handlers may be called redundantly.
|
|
234
241
|
- bc2d684: Fix `PluvRoom` not properly reconnecting when connections are unavailable.
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
- @pluv/crdt@0.44.0
|
|
243
|
+
- @pluv/types@0.44.0
|
|
237
244
|
|
|
238
245
|
## 0.43.0
|
|
239
246
|
|
|
@@ -241,25 +248,25 @@
|
|
|
241
248
|
|
|
242
249
|
- 65d9172: Added configurable limits for client-side validation. These should only be updated if you control the server and the server limits have been changed.
|
|
243
250
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
```ts
|
|
252
|
+
// defaults
|
|
253
|
+
createClient({
|
|
254
|
+
limits: {
|
|
255
|
+
presenceMaxSize: 512,
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
```
|
|
252
259
|
|
|
253
|
-
|
|
254
|
-
|
|
260
|
+
- @pluv/crdt@0.43.0
|
|
261
|
+
- @pluv/types@0.43.0
|
|
255
262
|
|
|
256
263
|
## 0.42.0
|
|
257
264
|
|
|
258
265
|
### Patch Changes
|
|
259
266
|
|
|
260
267
|
- 7ae56bf: Periodically sync connection ids with the server to clear stale connections.
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
- @pluv/crdt@0.42.0
|
|
269
|
+
- @pluv/types@0.42.0
|
|
263
270
|
|
|
264
271
|
## 0.41.7
|
|
265
272
|
|
|
@@ -273,16 +280,16 @@
|
|
|
273
280
|
### Patch Changes
|
|
274
281
|
|
|
275
282
|
- 71642fa: Fix error about missing wsEndpoint.
|
|
276
|
-
|
|
277
|
-
|
|
283
|
+
- @pluv/crdt@0.41.6
|
|
284
|
+
- @pluv/types@0.41.6
|
|
278
285
|
|
|
279
286
|
## 0.41.5
|
|
280
287
|
|
|
281
288
|
### Patch Changes
|
|
282
289
|
|
|
283
290
|
- b3b7b30: Fix error being thrown about missing wsEndpoint when a public key is provided.
|
|
284
|
-
|
|
285
|
-
|
|
291
|
+
- @pluv/crdt@0.41.5
|
|
292
|
+
- @pluv/types@0.41.5
|
|
286
293
|
|
|
287
294
|
## 0.41.4
|
|
288
295
|
|
|
@@ -296,16 +303,16 @@
|
|
|
296
303
|
### Patch Changes
|
|
297
304
|
|
|
298
305
|
- 49051c0: Fix presence keys becoming lost, causing presence objects to be partial and failing schema validation.
|
|
299
|
-
|
|
300
|
-
|
|
306
|
+
- @pluv/crdt@0.41.3
|
|
307
|
+
- @pluv/types@0.41.3
|
|
301
308
|
|
|
302
309
|
## 0.41.2
|
|
303
310
|
|
|
304
311
|
### Patch Changes
|
|
305
312
|
|
|
306
313
|
- 37956d3: When presence is received for a user that is not currently being tracked, `PluvRoom` now automatically updates `others` to include the connection of the received presence.
|
|
307
|
-
|
|
308
|
-
|
|
314
|
+
- @pluv/crdt@0.41.2
|
|
315
|
+
- @pluv/types@0.41.2
|
|
309
316
|
|
|
310
317
|
## 0.41.1
|
|
311
318
|
|
|
@@ -321,22 +328,22 @@
|
|
|
321
328
|
- 41aa439: **BREAKING** User's presence is now limited to be at most 512 bytes. If the presence is any larger, the `PluvRoom` will now throw an error.
|
|
322
329
|
- 555b88d: Users can now have multiple simultaneous connections. Previously, if a user tried to open a connection to a room while already being connected to the room, the new connection would be blocked. Now, when the user opens another connection, the new connection will be opened and initialized with their latest presence.
|
|
323
330
|
|
|
324
|
-
|
|
331
|
+
Users can only have 1 identity and 1 presence, which means that all presence updates will sync across all of that user's connections. This means that even when a user opens multiple connections, they will only appear once in `others`.
|
|
325
332
|
|
|
326
333
|
### Patch Changes
|
|
327
334
|
|
|
328
335
|
- eb2d903: `PluvRoom` attempts to reconnect immediately after receiving a `close` event, instead of waiting for the reconnect timer. After failing the initial reconnect will the reconnects poll on the timer.
|
|
329
336
|
- 555b88d: Fixed the `presence` type of `other` and `others` to equal the inferred presence type.
|
|
330
|
-
|
|
331
|
-
|
|
337
|
+
- @pluv/crdt@0.41.0
|
|
338
|
+
- @pluv/types@0.41.0
|
|
332
339
|
|
|
333
340
|
## 0.40.2
|
|
334
341
|
|
|
335
342
|
### Patch Changes
|
|
336
343
|
|
|
337
344
|
- 6fbc2fe: Update `PluvClient.createRoom` so that the 2nd parameter is optional.
|
|
338
|
-
|
|
339
|
-
|
|
345
|
+
- @pluv/crdt@0.40.2
|
|
346
|
+
- @pluv/types@0.40.2
|
|
340
347
|
|
|
341
348
|
## 0.40.1
|
|
342
349
|
|
|
@@ -365,75 +372,75 @@
|
|
|
365
372
|
|
|
366
373
|
- e6ddddc: **BREAKING** Moved the `metadata` parameter from the constructor of `PluvRoom` to `PluvClient.connect`. The `metadata` parameter from the constructor of `PluvRoom` is now the validation schema for `metadata` passed through from `PluvClient`.
|
|
367
374
|
|
|
368
|
-
|
|
375
|
+
This should not be breaking for most users, as the recommended way to enter a room has always been via `PluvClient.enter(room)` (i.e. these are mostly internal-only changes).
|
|
369
376
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
```ts
|
|
378
|
+
// Before
|
|
379
|
+
const room = new Room("my-room", { metadata: { hello: "world" } });
|
|
373
380
|
|
|
374
|
-
|
|
381
|
+
await room.connect();
|
|
375
382
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
383
|
+
// After
|
|
384
|
+
const room = new Room("my-room", {
|
|
385
|
+
metadata: z.object({ hello: z.string() }),
|
|
386
|
+
});
|
|
380
387
|
|
|
381
|
-
|
|
382
|
-
|
|
388
|
+
await room.connect({ metadata: { hello: "world" } });
|
|
389
|
+
```
|
|
383
390
|
|
|
384
391
|
- e6ddddc: **BREAKING** Moved the `metadata` parameter from `PluvClient.createRoom` to `PluvClient.enter`.
|
|
385
392
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
+
```ts
|
|
394
|
+
// Before
|
|
395
|
+
const room = client.createRoom({
|
|
396
|
+
// ...
|
|
397
|
+
metadata: { hello: "world" },
|
|
398
|
+
// ...
|
|
399
|
+
});
|
|
393
400
|
|
|
394
|
-
|
|
401
|
+
client.enter(room);
|
|
395
402
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
403
|
+
// After
|
|
404
|
+
const room = client.createRoom({
|
|
405
|
+
// ...
|
|
406
|
+
});
|
|
400
407
|
|
|
401
|
-
|
|
402
|
-
|
|
408
|
+
client.enter(room, { metadata });
|
|
409
|
+
```
|
|
403
410
|
|
|
404
411
|
### Patch Changes
|
|
405
412
|
|
|
406
413
|
- e6ddddc: Improved handling of polling-reconnects to `PluvRoom` after the websocket closes (depending on the close event's code).
|
|
407
414
|
- 2cfb68d: Add the ability to configure the reconnect timeout (in milliseconds) for a `PluvRoom`, and lowered the default reconnect timeout from 30s to 5s. Values will be automatically clamped to between 1s and 60s.
|
|
408
415
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
416
|
+
```ts
|
|
417
|
+
// Both of these are valid
|
|
418
|
+
const room = client.createRoom("my-room", {
|
|
419
|
+
// Set timeout to a fixed 10s
|
|
420
|
+
reconnectTimeoutMs: 10_000,
|
|
421
|
+
});
|
|
415
422
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
const room = client.createRoom("my-room", {
|
|
424
|
+
/**
|
|
425
|
+
* `attempts` is the count of failed reconnect attempts, starting from 0 on the first attempt.
|
|
426
|
+
* The returned value will be how long until the next attempt.
|
|
427
|
+
*/
|
|
428
|
+
reconnectTimeoutMs: ({ attempts }) => {
|
|
429
|
+
return 10_000 + 1_000 * Math.pow(2, attempts);
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
```
|
|
426
433
|
|
|
427
|
-
|
|
428
|
-
|
|
434
|
+
- @pluv/crdt@0.39.0
|
|
435
|
+
- @pluv/types@0.39.0
|
|
429
436
|
|
|
430
437
|
## 0.38.14
|
|
431
438
|
|
|
432
439
|
### Patch Changes
|
|
433
440
|
|
|
434
441
|
- 886a1f9: Fix cases where the user's own presence was getting updated excessively, and without re-triggering subscriptions.
|
|
435
|
-
|
|
436
|
-
|
|
442
|
+
- @pluv/crdt@0.38.14
|
|
443
|
+
- @pluv/types@0.38.14
|
|
437
444
|
|
|
438
445
|
## 0.38.13
|
|
439
446
|
|
|
@@ -447,24 +454,24 @@
|
|
|
447
454
|
### Patch Changes
|
|
448
455
|
|
|
449
456
|
- b617726: Fix broken type narrowing for `PluvRoom.event` and `PluvRoom.broadcast`.
|
|
450
|
-
|
|
451
|
-
|
|
457
|
+
- @pluv/crdt@0.38.12
|
|
458
|
+
- @pluv/types@0.38.12
|
|
452
459
|
|
|
453
460
|
## 0.38.11
|
|
454
461
|
|
|
455
462
|
### Patch Changes
|
|
456
463
|
|
|
457
464
|
- 5ac1aba: Fix the default `wsEndpoint` parameter (for when `@pluv/platform-pluv` is being used).
|
|
458
|
-
|
|
459
|
-
|
|
465
|
+
- @pluv/crdt@0.38.11
|
|
466
|
+
- @pluv/types@0.38.11
|
|
460
467
|
|
|
461
468
|
## 0.38.10
|
|
462
469
|
|
|
463
470
|
### Patch Changes
|
|
464
471
|
|
|
465
472
|
- cadd963: Update the user's presence locally only via `PluvRoom.updateMyPresence` (i.e. do not update the user's own presence from WebSocket messages) to avoid update delays. This should fix some cases of "jitter" depending on network latecy.
|
|
466
|
-
|
|
467
|
-
|
|
473
|
+
- @pluv/crdt@0.38.10
|
|
474
|
+
- @pluv/types@0.38.10
|
|
468
475
|
|
|
469
476
|
## 0.38.9
|
|
470
477
|
|
|
@@ -513,16 +520,16 @@
|
|
|
513
520
|
### Patch Changes
|
|
514
521
|
|
|
515
522
|
- 8346273: Disallow the `# @pluv/client character in router event names.
|
|
516
|
-
|
|
517
|
-
|
|
523
|
+
- @pluv/crdt@0.38.3
|
|
524
|
+
- @pluv/types@0.38.3
|
|
518
525
|
|
|
519
526
|
## 0.38.2
|
|
520
527
|
|
|
521
528
|
### Patch Changes
|
|
522
529
|
|
|
523
530
|
- de35f0b: Require `PluvRouter` event names to be formatted as valid JavaScript variable names.
|
|
524
|
-
|
|
525
|
-
|
|
531
|
+
- @pluv/crdt@0.38.2
|
|
532
|
+
- @pluv/types@0.38.2
|
|
526
533
|
|
|
527
534
|
## 0.38.1
|
|
528
535
|
|
|
@@ -540,8 +547,8 @@
|
|
|
540
547
|
### Patch Changes
|
|
541
548
|
|
|
542
549
|
- Updated dependencies [f4ceca3]
|
|
543
|
-
|
|
544
|
-
|
|
550
|
+
- @pluv/types@0.38.0
|
|
551
|
+
- @pluv/crdt@0.38.0
|
|
545
552
|
|
|
546
553
|
## 0.37.7
|
|
547
554
|
|
|
@@ -569,24 +576,24 @@
|
|
|
569
576
|
### Patch Changes
|
|
570
577
|
|
|
571
578
|
- a9c3d17: Fix `publicKey` not being properly set on `PluvClient` when `publicKey` is a function.
|
|
572
|
-
|
|
573
|
-
|
|
579
|
+
- @pluv/crdt@0.37.4
|
|
580
|
+
- @pluv/types@0.37.4
|
|
574
581
|
|
|
575
582
|
## 0.37.3
|
|
576
583
|
|
|
577
584
|
### Patch Changes
|
|
578
585
|
|
|
579
586
|
- 9ae837b: Add missing schema validation for room metadata.
|
|
580
|
-
|
|
581
|
-
|
|
587
|
+
- @pluv/crdt@0.37.3
|
|
588
|
+
- @pluv/types@0.37.3
|
|
582
589
|
|
|
583
590
|
## 0.37.2
|
|
584
591
|
|
|
585
592
|
### Patch Changes
|
|
586
593
|
|
|
587
594
|
- 11920af: Updated the default `wsEndpoint` for `PluvClient` when `publicKey` is provided to be correct.
|
|
588
|
-
|
|
589
|
-
|
|
595
|
+
- @pluv/crdt@0.37.2
|
|
596
|
+
- @pluv/types@0.37.2
|
|
590
597
|
|
|
591
598
|
## 0.37.1
|
|
592
599
|
|
|
@@ -594,24 +601,24 @@
|
|
|
594
601
|
|
|
595
602
|
- e923a8d: Added support for specifying the `publicKey` param for `createClient` as a function with metadata. This is particularly useful for non-static Next.js applications built with Cloudflare Pages.
|
|
596
603
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
604
|
+
```ts
|
|
605
|
+
import { createClient } from "@pluv/client";
|
|
606
|
+
import { z } from "zod";
|
|
600
607
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
608
|
+
export const client = createClient({
|
|
609
|
+
// Can be a string
|
|
610
|
+
publicKey: "pk_abc123...",
|
|
604
611
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
+
// Or can be a function
|
|
613
|
+
metadata: z.object({
|
|
614
|
+
publicKey: z.string().min(1, "Required"),
|
|
615
|
+
}),
|
|
616
|
+
publicKey: ({ metadata }) => metadata.publicKey,
|
|
617
|
+
});
|
|
618
|
+
```
|
|
612
619
|
|
|
613
|
-
|
|
614
|
-
|
|
620
|
+
- @pluv/crdt@0.37.1
|
|
621
|
+
- @pluv/types@0.37.1
|
|
615
622
|
|
|
616
623
|
## 0.37.0
|
|
617
624
|
|
|
@@ -627,35 +634,35 @@
|
|
|
627
634
|
- 4518b6d: **BREAKING**
|
|
628
635
|
Updated how `createClient` infers the `PluvServer` type (again 🙁). The property to specify the type-inferred `PluvServer` type has been renamed to `types` from `infer`. `@pluv/client` now exports a function called `infer` that must now be used to construct the inferred `types` property. `infer` must be called before, and outside of `createClient` due to TypeScript inferrence limitations. See examples below:
|
|
629
636
|
|
|
630
|
-
|
|
631
|
-
|
|
637
|
+
```ts
|
|
638
|
+
// Before
|
|
632
639
|
|
|
633
|
-
|
|
634
|
-
|
|
640
|
+
import { createClient } from "@pluv/client";
|
|
641
|
+
import type { ioServer } from "../server/pluv";
|
|
635
642
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
643
|
+
const client = createClient({
|
|
644
|
+
// ...
|
|
645
|
+
infer: (i) => ({ io: i<typeof ioServer> }),
|
|
646
|
+
// ...
|
|
647
|
+
});
|
|
641
648
|
|
|
642
|
-
|
|
649
|
+
// After
|
|
643
650
|
|
|
644
|
-
|
|
645
|
-
|
|
651
|
+
import { createClient, infer } from "@pluv/client";
|
|
652
|
+
import type { ioServer } from "../server/pluv";
|
|
646
653
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
654
|
+
// Observe that `types` is initialized outside of `createClient`, instead of
|
|
655
|
+
// inline within the `createClient` function.`
|
|
656
|
+
const types = infer((i) => ({ io: i<typeof ioServer> }));
|
|
657
|
+
const client = createClient({
|
|
658
|
+
// ...
|
|
659
|
+
// Avoid calling `infer` inline within this function like in the commented
|
|
660
|
+
// example below:
|
|
661
|
+
// types: infer((i) => ({ io: i<typeof ioServer> })),
|
|
662
|
+
types,
|
|
663
|
+
// ...
|
|
664
|
+
});
|
|
665
|
+
```
|
|
659
666
|
|
|
660
667
|
### Patch Changes
|
|
661
668
|
|
|
@@ -681,8 +688,8 @@
|
|
|
681
688
|
### Patch Changes
|
|
682
689
|
|
|
683
690
|
- Updated dependencies [81cb692]
|
|
684
|
-
|
|
685
|
-
|
|
691
|
+
- @pluv/types@0.35.2
|
|
692
|
+
- @pluv/crdt@0.35.2
|
|
686
693
|
|
|
687
694
|
## 0.35.1
|
|
688
695
|
|
|
@@ -767,24 +774,23 @@
|
|
|
767
774
|
|
|
768
775
|
- b18230f: Add `register` helper to improve client initialization when hosted on pluv.io.
|
|
769
776
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
})
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
- @pluv/types@0.32.3
|
|
777
|
+
```ts
|
|
778
|
+
import { createClient, register } from "@pluv/client";
|
|
779
|
+
import type { ioServer } from "./server";
|
|
780
|
+
|
|
781
|
+
const client = createClient({
|
|
782
|
+
infer: (i) => ({ io: i<typeof ioServer> }),
|
|
783
|
+
// This includes `wsEndpoint` and therefore should no-longer be manually provided
|
|
784
|
+
...register({
|
|
785
|
+
// `authEndpoint` and `publicKey` are now required
|
|
786
|
+
authEndpoint: ({ room }) => `${process.env.API_URL}/api/room?room=${room}`,
|
|
787
|
+
publicKey: "pk_...",
|
|
788
|
+
}),
|
|
789
|
+
});
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
- @pluv/crdt@0.32.3
|
|
793
|
+
- @pluv/types@0.32.3
|
|
788
794
|
|
|
789
795
|
## 0.32.2
|
|
790
796
|
|
|
@@ -833,8 +839,8 @@
|
|
|
833
839
|
### Patch Changes
|
|
834
840
|
|
|
835
841
|
- cff933a: Add `publicKey` property to `createClient` for later usage ;)
|
|
836
|
-
|
|
837
|
-
|
|
842
|
+
- @pluv/crdt@0.30.0
|
|
843
|
+
- @pluv/types@0.30.0
|
|
838
844
|
|
|
839
845
|
## 0.29.0
|
|
840
846
|
|
|
@@ -856,124 +862,122 @@
|
|
|
856
862
|
|
|
857
863
|
- 19ed36c: **BREAKNG**
|
|
858
864
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
```ts
|
|
862
|
-
// Before
|
|
863
|
-
import { createClient } from "@pluv/client";
|
|
864
|
-
import { yjs } from "@pluv/crdt-yjs";
|
|
865
|
-
import { z } from "zod";
|
|
866
|
-
import type { ioServer } from "./server/ioServer";
|
|
867
|
-
|
|
868
|
-
const client = createClient<typeof ioServer>({
|
|
869
|
-
authEndpoint: ({ room }) => "MY_AUTH_URL",
|
|
870
|
-
wsEndpoint: ({ room }) => "MY_WEBSOCKET_URL",
|
|
871
|
-
});
|
|
872
|
-
|
|
873
|
-
client.createRoom("my-example-room", {
|
|
874
|
-
presence: z.object({
|
|
875
|
-
selectionId: z.string().nullish(),
|
|
876
|
-
}),
|
|
877
|
-
initialPresence: {
|
|
878
|
-
selectionId: null,
|
|
879
|
-
},
|
|
880
|
-
initialStorage: yjs.doc(() => ({
|
|
881
|
-
messages: yjs.array<string>([]),
|
|
882
|
-
})),
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
// After
|
|
886
|
-
const client = createClient({
|
|
887
|
-
authEndpoint: ({ room }) => "MY_AUTH_URL",
|
|
888
|
-
wsEndpoint: ({ room }) => "MY_WEBSOCKET_URL",
|
|
889
|
-
/**
|
|
890
|
-
* @description The ioServer type now needs to be inferred on this property
|
|
891
|
-
* instead of within the generic on `createClient`. This is because of
|
|
892
|
-
* limitations with TypeScript not yet supporting partial type-inference
|
|
893
|
-
* for generics. Ensure to no-loonger include any generics on `createClient`
|
|
894
|
-
*/
|
|
895
|
-
infer: (i) => ({ io: i<typeof ioServer> }),
|
|
896
|
-
// Now moved to `createClient` from `PluvClient.createRoom`
|
|
897
|
-
presence: z.object({
|
|
898
|
-
selectionId: z.string().nullish(),
|
|
899
|
-
}),
|
|
900
|
-
/**
|
|
901
|
-
* @description Now added to `createClient` to specify defaults for all
|
|
902
|
-
* rooms, and to infer types for storage. This value will be overwritten by
|
|
903
|
-
* `PluvClient.createRoom`.
|
|
904
|
-
*/
|
|
905
|
-
initialStorage: yjs.doc(() => ({
|
|
906
|
-
messages: yjs.array<string>([]),
|
|
907
|
-
})),
|
|
908
|
-
});
|
|
909
|
-
|
|
910
|
-
const room = client.createRoom("my-example-room", {
|
|
911
|
-
initialPresence: {
|
|
912
|
-
selectionId: null,
|
|
913
|
-
},
|
|
914
|
-
initialStorage: yjs.doc(() => ({
|
|
915
|
-
messages: yjs.array<string>([]),
|
|
916
|
-
})),
|
|
917
|
-
});
|
|
918
|
-
```
|
|
865
|
+
Updated `createClient` and `PluvClient.createRoom` object params to better support automatic type inference.
|
|
919
866
|
|
|
920
|
-
|
|
867
|
+
```ts
|
|
868
|
+
// Before
|
|
869
|
+
import { createClient } from "@pluv/client";
|
|
870
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
871
|
+
import { z } from "zod";
|
|
872
|
+
import type { ioServer } from "./server/ioServer";
|
|
921
873
|
|
|
922
|
-
|
|
874
|
+
const client = createClient<typeof ioServer>({
|
|
875
|
+
authEndpoint: ({ room }) => "MY_AUTH_URL",
|
|
876
|
+
wsEndpoint: ({ room }) => "MY_WEBSOCKET_URL",
|
|
877
|
+
});
|
|
923
878
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
multiply2: io.procedure
|
|
934
|
-
.input(z.object({ value: z.number() }))
|
|
935
|
-
.broadcast(({ value }) => ({
|
|
936
|
-
multiplied2: { value: value * 2 },
|
|
879
|
+
client.createRoom("my-example-room", {
|
|
880
|
+
presence: z.object({
|
|
881
|
+
selectionId: z.string().nullish(),
|
|
882
|
+
}),
|
|
883
|
+
initialPresence: {
|
|
884
|
+
selectionId: null,
|
|
885
|
+
},
|
|
886
|
+
initialStorage: yjs.doc(() => ({
|
|
887
|
+
messages: yjs.array<string>([]),
|
|
937
888
|
})),
|
|
938
|
-
})
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
// After
|
|
892
|
+
const client = createClient({
|
|
893
|
+
authEndpoint: ({ room }) => "MY_AUTH_URL",
|
|
894
|
+
wsEndpoint: ({ room }) => "MY_WEBSOCKET_URL",
|
|
895
|
+
/**
|
|
896
|
+
* @description The ioServer type now needs to be inferred on this property
|
|
897
|
+
* instead of within the generic on `createClient`. This is because of
|
|
898
|
+
* limitations with TypeScript not yet supporting partial type-inference
|
|
899
|
+
* for generics. Ensure to no-loonger include any generics on `createClient`
|
|
900
|
+
*/
|
|
901
|
+
infer: (i) => ({ io: i<typeof ioServer> }),
|
|
902
|
+
// Now moved to `createClient` from `PluvClient.createRoom`
|
|
903
|
+
presence: z.object({
|
|
904
|
+
selectionId: z.string().nullish(),
|
|
905
|
+
}),
|
|
906
|
+
/**
|
|
907
|
+
* @description Now added to `createClient` to specify defaults for all
|
|
908
|
+
* rooms, and to infer types for storage. This value will be overwritten by
|
|
909
|
+
* `PluvClient.createRoom`.
|
|
910
|
+
*/
|
|
911
|
+
initialStorage: yjs.doc(() => ({
|
|
912
|
+
messages: yjs.array<string>([]),
|
|
959
913
|
})),
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
.broadcast(({ value }) => ({
|
|
969
|
-
multiply2: { value: value - 5 },
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
const room = client.createRoom("my-example-room", {
|
|
917
|
+
initialPresence: {
|
|
918
|
+
selectionId: null,
|
|
919
|
+
},
|
|
920
|
+
initialStorage: yjs.doc(() => ({
|
|
921
|
+
messages: yjs.array<string>([]),
|
|
970
922
|
})),
|
|
971
|
-
})
|
|
972
|
-
|
|
973
|
-
```
|
|
923
|
+
});
|
|
924
|
+
```
|
|
974
925
|
|
|
975
|
-
|
|
976
|
-
|
|
926
|
+
### Patch Changes
|
|
927
|
+
|
|
928
|
+
- 19ed36c: Added client-side event router. This more-or-less mirrors the server-side event router. You can use both the server-side and client-side router simultaneously, but you should generally prefer only using one or the other.
|
|
929
|
+
|
|
930
|
+
```ts
|
|
931
|
+
// Backend Server
|
|
932
|
+
import { createIO } from "@pluv/io";
|
|
933
|
+
|
|
934
|
+
const io = createIO({
|
|
935
|
+
/* ... */
|
|
936
|
+
});
|
|
937
|
+
const ioServer = io.server({
|
|
938
|
+
router: io.router({
|
|
939
|
+
multiply2: io.procedure
|
|
940
|
+
.input(z.object({ value: z.number() }))
|
|
941
|
+
.broadcast(({ value }) => ({
|
|
942
|
+
multiplied2: { value: value * 2 },
|
|
943
|
+
})),
|
|
944
|
+
}),
|
|
945
|
+
});
|
|
946
|
+
|
|
947
|
+
// Frontend Client
|
|
948
|
+
import { createClient } from "@pluv/client";
|
|
949
|
+
|
|
950
|
+
const io = createClient({
|
|
951
|
+
/* ... */
|
|
952
|
+
});
|
|
953
|
+
|
|
954
|
+
const room = io.createRoom("my-example-room", {
|
|
955
|
+
// ...
|
|
956
|
+
router: io.router({
|
|
957
|
+
add5: io.procedure.input(z.object({ value: z.number() })).broadcast(({ value }) => ({
|
|
958
|
+
/**
|
|
959
|
+
* @description Because `ioServer` does not specify `added5`,
|
|
960
|
+
* this will be forwarded to connected peers.
|
|
961
|
+
*/
|
|
962
|
+
added5: { value: value + 5 },
|
|
963
|
+
})),
|
|
964
|
+
/**
|
|
965
|
+
* @description This is possible, but not recommended to do. Because
|
|
966
|
+
* `multiply2` is a procedure on `ioServer`, this will trigger the
|
|
967
|
+
* `multiply2` procedure on `ioServer`. Connected peers will not
|
|
968
|
+
* receive `multiply2`, but rather `multipled2`.
|
|
969
|
+
*/
|
|
970
|
+
subtract5Multiply2: io.procedure
|
|
971
|
+
.input(z.object({ value: z.number() }))
|
|
972
|
+
.broadcast(({ value }) => ({
|
|
973
|
+
multiply2: { value: value - 5 },
|
|
974
|
+
})),
|
|
975
|
+
}),
|
|
976
|
+
});
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
- @pluv/crdt@0.27.0
|
|
980
|
+
- @pluv/types@0.27.0
|
|
977
981
|
|
|
978
982
|
## 0.26.0
|
|
979
983
|
|
|
@@ -982,47 +986,47 @@
|
|
|
982
986
|
- 19e5dda: **BREAKING**
|
|
983
987
|
Update `authEndpoint` and `wsEndpoint` to now use a parameterized object that passes through additional data via a `metadata` property.
|
|
984
988
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
989
|
+
```tsx
|
|
990
|
+
// Before
|
|
991
|
+
|
|
992
|
+
import { env } from "./env";
|
|
993
|
+
import type { ioServer } from "./server";
|
|
994
|
+
|
|
995
|
+
const client = createClient<typeof ioServer>({
|
|
996
|
+
authEndpoint: (room: string) => `${env.API_URL}}/room/${room}`,
|
|
997
|
+
wsEndpoint: (room: string) => `${env.WS_URL}/room/${room}`,
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
// After
|
|
1001
|
+
|
|
1002
|
+
const client = createClient<
|
|
1003
|
+
typeof ioServer,
|
|
1004
|
+
// Optional: You can specify types for metadata here. This is useful for Cloudflare Pages
|
|
1005
|
+
{ apiUrl: string; wsUrl: string }
|
|
1006
|
+
>({
|
|
1007
|
+
authEndpoint: ({ metadata, room }) => `${metadata.apiUrl}}/room/${room}`,
|
|
1008
|
+
wsEndpoint: ({ metadata, room }) => `${{ metadata.wsUrl }}/room/${room}`,
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
client.createRoom("my-room", {
|
|
1012
|
+
// This property exists when the `metadata` generic type is defined above
|
|
1013
|
+
metadata: {
|
|
1014
|
+
apiUrl: "https://example.com/api",
|
|
1015
|
+
wsUrl: "wss://example.com/api",
|
|
1016
|
+
},
|
|
1017
|
+
// ...
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
<PluvRoomProvider
|
|
1021
|
+
// This property exists when the `metadata` generic type is defined above
|
|
1022
|
+
metadata={{
|
|
1023
|
+
apiUrl: "https://example.com/api",
|
|
1024
|
+
wsUrl: "wss://example.com/api",
|
|
1025
|
+
}}
|
|
1026
|
+
>
|
|
1027
|
+
{/* ... */}
|
|
1028
|
+
</PluvRoomProvider>
|
|
1029
|
+
```
|
|
1026
1030
|
|
|
1027
1031
|
### Patch Changes
|
|
1028
1032
|
|
|
@@ -1069,8 +1073,8 @@
|
|
|
1069
1073
|
### Patch Changes
|
|
1070
1074
|
|
|
1071
1075
|
- ba299e2: Fixed "others" state in the PluvClient not getting cleared when the user's websocket connection is closed, creating "ghost users" during some reconnects.
|
|
1072
|
-
|
|
1073
|
-
|
|
1076
|
+
- @pluv/crdt@0.24.1
|
|
1077
|
+
- @pluv/types@0.24.1
|
|
1074
1078
|
|
|
1075
1079
|
## 0.24.0
|
|
1076
1080
|
|
|
@@ -1117,76 +1121,76 @@
|
|
|
1117
1121
|
|
|
1118
1122
|
- 9492085: **BREAKING**: `@pluv/crdt-yjs` and `@pluv/crdt-loro` have been updated so that the utilities to create shared-types/containers no-longer return a wrapper around the underlying shared-types and containers, but rather return the shared-types/containers directly.
|
|
1119
1123
|
|
|
1120
|
-
|
|
1124
|
+
This means that for methods such as `getStorage` from `@pluv/client` and `useStorage` from `@pluv/react`, the shared-types/containers are also returned instead of the wrapper types.
|
|
1121
1125
|
|
|
1122
|
-
|
|
1126
|
+
The motivation for these changes are so that pluv.io is supplementary to `yjs` and `loro-crdt`, instead of having these libraries be an internal implementation of pluv.io.
|
|
1123
1127
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1128
|
+
```ts
|
|
1129
|
+
// Before
|
|
1126
1130
|
|
|
1127
|
-
|
|
1131
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
1128
1132
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1133
|
+
yjs.array([]); // Returns CrdtYjsArray
|
|
1134
|
+
yjs.object([]); // Returns CrdtYjsObject
|
|
1131
1135
|
|
|
1132
|
-
|
|
1136
|
+
const room: PluvRoom = /* ... */;
|
|
1133
1137
|
|
|
1134
|
-
|
|
1138
|
+
room.getStorage("messages"); // Returns AbstractCrdtType
|
|
1135
1139
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1140
|
+
const [, sharedType] = useStorage("messages"); // sharedType is an AbstractCrdtType
|
|
1141
|
+
```
|
|
1138
1142
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1143
|
+
```ts
|
|
1144
|
+
// Now
|
|
1141
1145
|
|
|
1142
|
-
|
|
1146
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
1143
1147
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1148
|
+
yjs.array([]); // Returns yjs.Array
|
|
1149
|
+
yjs.object([]); // Returns yjs.Map
|
|
1146
1150
|
|
|
1147
|
-
|
|
1151
|
+
const room: PluvRoom = /* ... */;
|
|
1148
1152
|
|
|
1149
|
-
|
|
1153
|
+
room.getStorage("messages"); // Returns yjs.AbstractType
|
|
1150
1154
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1155
|
+
const [, sharedType] = useStorage("messages"); // sharedType is a yjs.AbstractType
|
|
1156
|
+
```
|
|
1153
1157
|
|
|
1154
|
-
|
|
1158
|
+
For `@pluv/crdt-loro` specifically, `@pluv/client` relies on [loro events and subscriptions](https://www.loro.dev/docs/tutorial/get_started#event) to detect changes. The `AbstractLoroCrdt` types previously called `Loro.commit` after each change as an abstraction, but now this no-longer happens. To ensure that changes to loro containers are properly handled in `@pluv/react`, make sure to commit your changes whenever possible:
|
|
1155
1159
|
|
|
1156
|
-
|
|
1157
|
-
|
|
1160
|
+
```ts
|
|
1161
|
+
// Before
|
|
1158
1162
|
|
|
1159
|
-
|
|
1163
|
+
const [data, container] = useStorage("messages");
|
|
1160
1164
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1165
|
+
// This automatically called Loro.commit under the hood and rerendered the page with updated data.
|
|
1166
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
1167
|
+
```
|
|
1164
1168
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1169
|
+
```ts
|
|
1170
|
+
// Now
|
|
1167
1171
|
|
|
1168
|
-
|
|
1172
|
+
const [data, container] = useStorage("messages");
|
|
1169
1173
|
|
|
1170
|
-
|
|
1171
|
-
|
|
1174
|
+
const doc = useDoc();
|
|
1175
|
+
const transact = useTransact();
|
|
1172
1176
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1177
|
+
// Updates need to be committed back to the doc whenever the changes need to be emitted to other users
|
|
1178
|
+
// The returned data also will not update until the changes are commited
|
|
1175
1179
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
+
// The two operations below are functionally equivalent
|
|
1181
|
+
transact(() => {
|
|
1182
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
1183
|
+
});
|
|
1180
1184
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1185
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
1186
|
+
doc.value.commit();
|
|
1187
|
+
```
|
|
1184
1188
|
|
|
1185
1189
|
### Patch Changes
|
|
1186
1190
|
|
|
1187
1191
|
- Updated dependencies [9492085]
|
|
1188
|
-
|
|
1189
|
-
|
|
1192
|
+
- @pluv/crdt@0.20.0
|
|
1193
|
+
- @pluv/types@0.20.0
|
|
1190
1194
|
|
|
1191
1195
|
## 0.19.0
|
|
1192
1196
|
|
|
@@ -1194,23 +1198,23 @@
|
|
|
1194
1198
|
|
|
1195
1199
|
- 137444b: Updated PluvRoom.updateMyPresence to allow passing in a callback function that exposes the previous presence value and returns a presence update.
|
|
1196
1200
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
+
```ts
|
|
1202
|
+
type Presence = {
|
|
1203
|
+
selectionId: string | null;
|
|
1204
|
+
};
|
|
1201
1205
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1206
|
+
const room: PluvRoom = /* ... */;
|
|
1207
|
+
const newSelectionId: string | null = /* ... */;
|
|
1204
1208
|
|
|
1205
|
-
|
|
1209
|
+
room.updateMyPresence({ selectionId: newSelection });
|
|
1206
1210
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1211
|
+
// You can reference the previous presence and return a new presence based on it
|
|
1212
|
+
room.updateMyPresence((previousPresence) => ({ selectionId: newSelection ?? previousPresence.selectionId }));
|
|
1213
|
+
```
|
|
1210
1214
|
|
|
1211
1215
|
- f5e4370: Fix others' presence not getting tracked in PluvRoom when the user is unauthorized.
|
|
1212
|
-
|
|
1213
|
-
|
|
1216
|
+
- @pluv/crdt@0.19.0
|
|
1217
|
+
- @pluv/types@0.19.0
|
|
1214
1218
|
|
|
1215
1219
|
## 0.18.0
|
|
1216
1220
|
|
|
@@ -1218,151 +1222,151 @@
|
|
|
1218
1222
|
|
|
1219
1223
|
- 99b5ca9: ## Breaking Changes
|
|
1220
1224
|
|
|
1221
|
-
|
|
1225
|
+
- `@pluv/io` has been updated to introduce `PluvProcedure`, `PluvRouter` and `PluvServer`. This change is intended to improve the ergonomics of declaring events and simplifying inferences of event types.
|
|
1222
1226
|
|
|
1223
|
-
|
|
1227
|
+
### Before:
|
|
1224
1228
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1229
|
+
```ts
|
|
1230
|
+
// backend/io.ts
|
|
1227
1231
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1232
|
+
import { createIO } from "@pluv/io";
|
|
1233
|
+
import { createPluvHandler, platformNode } from "@pluv/platform-node";
|
|
1234
|
+
import { z } from "zod";
|
|
1231
1235
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
})
|
|
1235
|
-
.event("SEND_MESSAGE", {
|
|
1236
|
-
input: z.object({ message: z.string() }),
|
|
1237
|
-
resolver: ({ message }) => ({ RECEIVE_MESSAGE: { message } }),
|
|
1236
|
+
export const io = createIO({
|
|
1237
|
+
platform: platformNode(),
|
|
1238
1238
|
})
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1239
|
+
.event("SEND_MESSAGE", {
|
|
1240
|
+
input: z.object({ message: z.string() }),
|
|
1241
|
+
resolver: ({ message }) => ({ RECEIVE_MESSAGE: { message } }),
|
|
1242
|
+
})
|
|
1243
|
+
.event("DOUBLE_VALUE", {
|
|
1244
|
+
input: z.object({ value: z.number() }),
|
|
1245
|
+
resolver: ({ value }) => ({ VALUE_DOUBLED: { value: value * 2 } }),
|
|
1246
|
+
});
|
|
1247
|
+
|
|
1248
|
+
const Pluv = createPluvHandler({
|
|
1249
|
+
io,
|
|
1250
|
+
/* ... */
|
|
1242
1251
|
});
|
|
1252
|
+
```
|
|
1243
1253
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
/* ... */
|
|
1247
|
-
});
|
|
1248
|
-
```
|
|
1249
|
-
|
|
1250
|
-
```ts
|
|
1251
|
-
// frontend/pluv.ts
|
|
1254
|
+
```ts
|
|
1255
|
+
// frontend/pluv.ts
|
|
1252
1256
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1257
|
+
import { createClient } from "@pluv/react";
|
|
1258
|
+
import type { io } from "../backend/io";
|
|
1255
1259
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
+
const client = createClient<typeof io>({
|
|
1261
|
+
/* ... */
|
|
1262
|
+
});
|
|
1263
|
+
```
|
|
1260
1264
|
|
|
1261
|
-
|
|
1265
|
+
### Now:
|
|
1262
1266
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
+
```ts
|
|
1268
|
+
import { createIO } from "@pluv/io";
|
|
1269
|
+
import { createPluvHandler, platformNode } from "@pluv/platform-node";
|
|
1270
|
+
import { z } from "zod";
|
|
1267
1271
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1272
|
+
const io = createIO({
|
|
1273
|
+
platform: platformNode(),
|
|
1274
|
+
});
|
|
1271
1275
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1276
|
+
const router = io.router({
|
|
1277
|
+
SEND_MESSAGE: io.procedure
|
|
1278
|
+
.input(z.object({ message: z.string() }))
|
|
1279
|
+
.broadcast(({ message }) => ({
|
|
1280
|
+
RECEIVE_MESSAGE: { message },
|
|
1281
|
+
})),
|
|
1282
|
+
DOUBLE_VALUE: io.procedure
|
|
1283
|
+
.input(z.object({ value: z.number() }))
|
|
1284
|
+
.broadcast(({ value }) => ({
|
|
1285
|
+
VALUE_DOUBLED: { value: value * 2 },
|
|
1286
|
+
})),
|
|
1287
|
+
});
|
|
1284
1288
|
|
|
1285
|
-
|
|
1289
|
+
export const ioServer = io.server({ router });
|
|
1286
1290
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1291
|
+
const Pluv = createPluvHandler({
|
|
1292
|
+
io: ioServer, // <- This uses the PluvServer now
|
|
1293
|
+
/* ... */
|
|
1294
|
+
});
|
|
1295
|
+
```
|
|
1292
1296
|
|
|
1293
|
-
|
|
1294
|
-
|
|
1297
|
+
```ts
|
|
1298
|
+
// frontend/pluv.ts
|
|
1295
1299
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1300
|
+
import { createClient } from "@pluv/react";
|
|
1301
|
+
import type { ioServer } from "../backend/io";
|
|
1298
1302
|
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1303
|
+
// This users the PluvServer type now
|
|
1304
|
+
const client = createClient<typeof ioServer>({
|
|
1305
|
+
/* ... */
|
|
1306
|
+
});
|
|
1307
|
+
```
|
|
1304
1308
|
|
|
1305
|
-
|
|
1309
|
+
- `PluvRouter` instances can also be merged via the `mergeRouters` method, which effectively performs an `Object.assign` of the events object and returns a new `PluvRouter` with the correct types:
|
|
1306
1310
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1311
|
+
```ts
|
|
1312
|
+
const router = io.mergeRouters(router1, router2);
|
|
1313
|
+
```
|
|
1310
1314
|
|
|
1311
1315
|
### Patch Changes
|
|
1312
1316
|
|
|
1313
1317
|
- 06c67be: Added broadcast proxy as a new way to broadcast events.
|
|
1314
1318
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1319
|
+
```ts
|
|
1320
|
+
// backend
|
|
1317
1321
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1322
|
+
const router = io.router({
|
|
1323
|
+
SEND_MESSAGE: io.procedure
|
|
1324
|
+
.input(z.object({ message: z.string() }))
|
|
1325
|
+
.broadcast(({ message }) => ({ RECEIVE_MESSAGE: { message } })),
|
|
1326
|
+
});
|
|
1323
1327
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1328
|
+
// frontend
|
|
1329
|
+
const client = createClient(/* ... */);
|
|
1326
1330
|
|
|
1327
|
-
|
|
1331
|
+
// Both of the examples below are equivalent.
|
|
1328
1332
|
|
|
1329
|
-
|
|
1333
|
+
client.broadcast("SEND_MESSAGE", { message: "Hello world~!" });
|
|
1330
1334
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1335
|
+
client.broadcast.SEND_MESSAGE({ message: "Hello world~!" });
|
|
1336
|
+
```
|
|
1333
1337
|
|
|
1334
1338
|
- df1342c: Added event proxy as a new way to listen to events.
|
|
1335
1339
|
|
|
1336
|
-
|
|
1337
|
-
|
|
1340
|
+
```ts
|
|
1341
|
+
// backend
|
|
1338
1342
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1343
|
+
const router = io.router({
|
|
1344
|
+
SEND_MESSAGE: io.procedure
|
|
1345
|
+
.input(z.object({ message: z.string() }))
|
|
1346
|
+
.broadcast(({ message }) => ({ RECEIVE_MESSAGE: { message } })),
|
|
1347
|
+
});
|
|
1344
1348
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1349
|
+
// frontend
|
|
1350
|
+
const client = createClient(/* ... */);
|
|
1347
1351
|
|
|
1348
|
-
|
|
1352
|
+
// Both of the examples below are equivalent.
|
|
1349
1353
|
|
|
1350
|
-
|
|
1351
|
-
|
|
1354
|
+
client.event("RECEIVE_MESSAGE", ({ data }) => {
|
|
1355
|
+
const { message } = data;
|
|
1352
1356
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1357
|
+
console.log(message);
|
|
1358
|
+
});
|
|
1355
1359
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1360
|
+
client.event.RECEIVE_MESSAGE(({ data }) => {
|
|
1361
|
+
const { message } = data;
|
|
1358
1362
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1363
|
+
console.log(message);
|
|
1364
|
+
});
|
|
1365
|
+
```
|
|
1362
1366
|
|
|
1363
1367
|
- Updated dependencies [99b5ca9]
|
|
1364
|
-
|
|
1365
|
-
|
|
1368
|
+
- @pluv/types@0.18.0
|
|
1369
|
+
- @pluv/crdt@0.18.0
|
|
1366
1370
|
|
|
1367
1371
|
## 0.17.3
|
|
1368
1372
|
|
|
@@ -1390,8 +1394,8 @@
|
|
|
1390
1394
|
### Patch Changes
|
|
1391
1395
|
|
|
1392
1396
|
- Updated dependencies [507bc00]
|
|
1393
|
-
|
|
1394
|
-
|
|
1397
|
+
- @pluv/types@0.17.0
|
|
1398
|
+
- @pluv/crdt@0.17.0
|
|
1395
1399
|
|
|
1396
1400
|
## 0.16.3
|
|
1397
1401
|
|
|
@@ -1420,145 +1424,143 @@
|
|
|
1420
1424
|
|
|
1421
1425
|
- 4280220: ## Breaking Changes
|
|
1422
1426
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1427
|
+
- Storage types are now kept on the root of the document.
|
|
1428
|
+
- Previously, `@pluv/crdt-yjs` kept all shared-types on a hidden Yjs Map called `storage` on the root of the Yjs Doc. Now all shared-types are kept on the root of the Yjs Doc instead. This behavior should be more in-line with how shared-types are documented to be used from Yjs.
|
|
1429
|
+
- `@pluv/client` and `@pluv/react` no-longer re-export `@pluv/crdt-yjs`. This package will now need to be installed separately.
|
|
1430
|
+
|
|
1431
|
+
```bash
|
|
1432
|
+
# if installing @pluv/client
|
|
1433
|
+
npm install @pluv/client @pluv/crdt-yjs
|
|
1434
|
+
# if installing @pluv/react
|
|
1435
|
+
npm install @pluv/react @pluv/crdt-yjs
|
|
1436
|
+
```
|
|
1437
|
+
|
|
1438
|
+
```ts
|
|
1439
|
+
// Before:
|
|
1440
|
+
import { createClient, y } from "@pluv/client";
|
|
1441
|
+
// After:
|
|
1442
|
+
import { createClient } from "@pluv/client";
|
|
1443
|
+
import { yjs } from "@pluv/crdt-yjs"; // y renamed to yjs
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
- The `y` import has been renamed to `yjs`.
|
|
1447
|
+
```ts
|
|
1448
|
+
// Before:
|
|
1449
|
+
import { y } from "@pluv/crdt-yjs";
|
|
1450
|
+
// After:
|
|
1451
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
1452
|
+
```
|
|
1453
|
+
- `@pluv/crdt-yjs` functions no-longer return Yjs shared-types directly, but instead return an `AbstractCrdtType` from `@pluv/crdt` (new package). This also affects methods that return storage shared types in both `@pluv/client` and `@pluv/react` from functions like `PluvRoom.getStorage` and `PluvRoom.useStorage`.
|
|
1454
|
+
|
|
1455
|
+
```ts
|
|
1456
|
+
// Before:
|
|
1457
|
+
import { y } from "@pluv/crdt-yjs";
|
|
1458
|
+
import type { Array as YArray, Map as YMap } from "yjs";
|
|
1459
|
+
|
|
1460
|
+
const array: YArray<YMap<{ message: string }>> = y.array([y.object({ message: "Hello" })]);
|
|
1461
|
+
|
|
1462
|
+
array.push([y.object({ message: "World!" })]);
|
|
1463
|
+
|
|
1464
|
+
// After:
|
|
1465
|
+
import type { CrdtYjsArray, CrdtYjsObject } from "@pluv/crdt-yjs";
|
|
1466
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
1467
|
+
import type { Array as YArray } from "yjs";
|
|
1468
|
+
|
|
1469
|
+
const array: CrdtYjsArray<CrdtYjsObject<{ message: string }>> = yjs.array([
|
|
1470
|
+
yjs.object({ message: "Hello" }),
|
|
1471
|
+
]);
|
|
1472
|
+
|
|
1473
|
+
array.push(yjs.object({ message: "World!" }));
|
|
1474
|
+
|
|
1475
|
+
// use .value to get the underlying yjs type
|
|
1476
|
+
const yarray: YArray<YMap<{ message: string }>> = array.value;
|
|
1477
|
+
```
|
|
1478
|
+
|
|
1479
|
+
- `initialStorage` must now use the `doc` function from `@pluv/crdt-yjs` to be defined. This also affects `@pluv/react`.
|
|
1480
|
+
|
|
1481
|
+
```ts
|
|
1482
|
+
// Before:
|
|
1483
|
+
import { createClient, y } from "@pluv/client";
|
|
1484
|
+
|
|
1485
|
+
const client = createClient({
|
|
1486
|
+
/* ... */
|
|
1487
|
+
});
|
|
1488
|
+
|
|
1489
|
+
client.createRoom({
|
|
1490
|
+
// ...
|
|
1491
|
+
initialStorage: () => ({
|
|
1492
|
+
messages: y.array([y.object({ message: "Hello world!" })]),
|
|
1493
|
+
}),
|
|
1494
|
+
});
|
|
1495
|
+
|
|
1496
|
+
// After:
|
|
1497
|
+
import { createClient } from "@pluv/client";
|
|
1498
|
+
// This is now imported separately
|
|
1499
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
1500
|
+
|
|
1501
|
+
const client = createClient({
|
|
1502
|
+
/* ... */
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1505
|
+
client.createRoom({
|
|
1506
|
+
// ...
|
|
1507
|
+
initialStorage: yjs.doc(() => ({
|
|
1508
|
+
messages: yjs.array([yjs.object({ message: "Hello world!" })]),
|
|
1509
|
+
})),
|
|
1510
|
+
});
|
|
1511
|
+
```
|
|
1512
|
+
|
|
1513
|
+
- `@pluv/client` can now instead use [loro](https://github.com/loro-dev/loro) instead of [yjs](https://github.com/yjs/yjs).
|
|
1514
|
+
```bash
|
|
1515
|
+
npm install @pluv/client @pluv/crdt-loro loro-crdt
|
|
1516
|
+
```
|
|
1517
|
+
- If you are using storage features with pluv, `@pluv/io` must now specify which crdt library (i.e. `@pluv/crdt-yjs` or `@pluv/crdt-loro`) it is meant to use.
|
|
1518
|
+
|
|
1519
|
+
```ts
|
|
1520
|
+
import { loro } from "@pluv/crdt-loro";
|
|
1521
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
1522
|
+
import { createIO } from "@pluv/io";
|
|
1523
|
+
|
|
1524
|
+
const io = createIO({
|
|
1525
|
+
// ...
|
|
1526
|
+
// If using loro
|
|
1527
|
+
crdt: loro,
|
|
1528
|
+
// If using yjs
|
|
1529
|
+
crdt: yjs,
|
|
1530
|
+
});
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
- `PluvRoom.getDoc()` from `@pluv/client` no-longer returns the Yjs Doc instance, but rather a `AbstractCrdtDoc` instance from `@pluv/crdt`. This also affects the hook from `@pluv/react`.
|
|
1534
|
+
|
|
1535
|
+
```ts
|
|
1536
|
+
// Before:
|
|
1537
|
+
import { Doc as YDoc } from "yjs";
|
|
1538
|
+
|
|
1539
|
+
const room: PluvRoom = client.createRoom({
|
|
1540
|
+
/* ... */
|
|
1541
|
+
});
|
|
1478
1542
|
|
|
1479
|
-
|
|
1480
|
-
// Before:
|
|
1481
|
-
import { createClient, y } from "@pluv/client";
|
|
1543
|
+
const doc: YDoc = room.getDoc();
|
|
1482
1544
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
client.createRoom({
|
|
1488
|
-
// ...
|
|
1489
|
-
initialStorage: () => ({
|
|
1490
|
-
messages: y.array([y.object({ message: "Hello world!" })]),
|
|
1491
|
-
}),
|
|
1492
|
-
});
|
|
1493
|
-
|
|
1494
|
-
// After:
|
|
1495
|
-
import { createClient } from "@pluv/client";
|
|
1496
|
-
// This is now imported separately
|
|
1497
|
-
import { yjs } from "@pluv/crdt-yjs";
|
|
1545
|
+
// After:
|
|
1546
|
+
import { CrdtYjsDoc } from "@pluv/crdt-yjs";
|
|
1547
|
+
import { Doc as YDoc } from "yjs";
|
|
1498
1548
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1549
|
+
const room: PluvRoom = client.createRoom({
|
|
1550
|
+
/* ... */
|
|
1551
|
+
});
|
|
1502
1552
|
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
messages: yjs.array([yjs.object({ message: "Hello world!" })]),
|
|
1507
|
-
})),
|
|
1508
|
-
});
|
|
1509
|
-
```
|
|
1553
|
+
const doc: CrdtYjsDoc<any> = room.getDoc();
|
|
1554
|
+
const ydoc: YDoc = doc.value;
|
|
1555
|
+
```
|
|
1510
1556
|
|
|
1511
|
-
|
|
1512
|
-
```bash
|
|
1513
|
-
npm install @pluv/client @pluv/crdt-loro loro-crdt
|
|
1514
|
-
```
|
|
1515
|
-
- If you are using storage features with pluv, `@pluv/io` must now specify which crdt library (i.e. `@pluv/crdt-yjs` or `@pluv/crdt-loro`) it is meant to use.
|
|
1557
|
+
- `@pluv/client` and `@pluv/react` now may return `null` when retrieving storage while storage is being initialized.
|
|
1516
1558
|
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
import { yjs } from "@pluv/crdt-yjs";
|
|
1520
|
-
import { createIO } from "@pluv/io";
|
|
1559
|
+
```ts
|
|
1560
|
+
const sharedType = room.getStorage("messages"); // This may be null
|
|
1521
1561
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
// If using loro
|
|
1525
|
-
crdt: loro,
|
|
1526
|
-
// If using yjs
|
|
1527
|
-
crdt: yjs,
|
|
1528
|
-
});
|
|
1529
|
-
```
|
|
1530
|
-
|
|
1531
|
-
- `PluvRoom.getDoc()` from `@pluv/client` no-longer returns the Yjs Doc instance, but rather a `AbstractCrdtDoc` instance from `@pluv/crdt`. This also affects the hook from `@pluv/react`.
|
|
1532
|
-
|
|
1533
|
-
```ts
|
|
1534
|
-
// Before:
|
|
1535
|
-
import { Doc as YDoc } from "yjs";
|
|
1536
|
-
|
|
1537
|
-
const room: PluvRoom = client.createRoom({
|
|
1538
|
-
/* ... */
|
|
1539
|
-
});
|
|
1540
|
-
|
|
1541
|
-
const doc: YDoc = room.getDoc();
|
|
1542
|
-
|
|
1543
|
-
// After:
|
|
1544
|
-
import { CrdtYjsDoc } from "@pluv/crdt-yjs";
|
|
1545
|
-
import { Doc as YDoc } from "yjs";
|
|
1546
|
-
|
|
1547
|
-
const room: PluvRoom = client.createRoom({
|
|
1548
|
-
/* ... */
|
|
1549
|
-
});
|
|
1550
|
-
|
|
1551
|
-
const doc: CrdtYjsDoc<any> = room.getDoc();
|
|
1552
|
-
const ydoc: YDoc = doc.value;
|
|
1553
|
-
```
|
|
1554
|
-
|
|
1555
|
-
- `@pluv/client` and `@pluv/react` now may return `null` when retrieving storage while storage is being initialized.
|
|
1556
|
-
|
|
1557
|
-
```ts
|
|
1558
|
-
const sharedType = room.getStorage("messages"); // This may be null
|
|
1559
|
-
|
|
1560
|
-
const [data, sharedType] = useStorage("messages"); // data and sharedType may both be null
|
|
1561
|
-
```
|
|
1562
|
+
const [data, sharedType] = useStorage("messages"); // data and sharedType may both be null
|
|
1563
|
+
```
|
|
1562
1564
|
|
|
1563
1565
|
### Patch Changes
|
|
1564
1566
|
|
|
@@ -1592,15 +1594,15 @@
|
|
|
1592
1594
|
|
|
1593
1595
|
- 1126215: Added `getDoc` on `PluvRoom` to access the root Yjs doc.
|
|
1594
1596
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1597
|
+
```ts
|
|
1598
|
+
import { createClient } from "@pluv/client";
|
|
1599
|
+
import type { Doc } from "yjs";
|
|
1598
1600
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
+
const client = createClient(/* ... */);
|
|
1602
|
+
const room = client.createRoom(/* ... */);
|
|
1601
1603
|
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
+
const doc: Doc = room.getDoc();
|
|
1605
|
+
```
|
|
1604
1606
|
|
|
1605
1607
|
### Patch Changes
|
|
1606
1608
|
|
|
@@ -1613,8 +1615,8 @@
|
|
|
1613
1615
|
|
|
1614
1616
|
- da9f600: Upgraded dependencies
|
|
1615
1617
|
- Updated dependencies [da9f600]
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
+
- @pluv/crdt-yjs@0.12.3
|
|
1619
|
+
- @pluv/types@0.12.3
|
|
1618
1620
|
|
|
1619
1621
|
## 0.12.2
|
|
1620
1622
|
|
|
@@ -1627,8 +1629,8 @@
|
|
|
1627
1629
|
### Patch Changes
|
|
1628
1630
|
|
|
1629
1631
|
- cae08aa: Updated storage from `getStorage` to never return null
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
+
- @pluv/crdt-yjs@0.12.1
|
|
1633
|
+
- @pluv/types@0.12.1
|
|
1632
1634
|
|
|
1633
1635
|
## 0.12.0
|
|
1634
1636
|
|
|
@@ -1636,239 +1638,238 @@
|
|
|
1636
1638
|
|
|
1637
1639
|
- 436040b: Added ability to undo and redo changes to storage.
|
|
1638
1640
|
|
|
1639
|
-
|
|
1641
|
+
## @pluv/crdt-yjs
|
|
1640
1642
|
|
|
1641
|
-
|
|
1643
|
+
`@pluv/crdt-yjs` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `trackOrigins`.
|
|
1642
1644
|
|
|
1643
|
-
|
|
1645
|
+
Refer to the code-example below to better understand how to undo and redo with your doc.
|
|
1644
1646
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1647
|
+
```ts
|
|
1648
|
+
// Example
|
|
1649
|
+
import { array, doc } from "@pluv/crdt-yjs";
|
|
1650
|
+
|
|
1651
|
+
// Create your doc with your shared-types
|
|
1652
|
+
const myDoc = doc({
|
|
1653
|
+
messages: array<string>([]),
|
|
1654
|
+
});
|
|
1648
1655
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1656
|
+
/**
|
|
1657
|
+
* @description Track origins to enable undos and redos for your document.
|
|
1658
|
+
* trackOrigins must be called before any storage mutations, to enable those
|
|
1659
|
+
* mutations to be undone/redone.
|
|
1660
|
+
*/
|
|
1661
|
+
myDoc.trackOrigins({
|
|
1662
|
+
/**
|
|
1663
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1664
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
1665
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
1666
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1667
|
+
* @default 500
|
|
1668
|
+
*/
|
|
1669
|
+
captureTimeout: 500,
|
|
1670
|
+
/**
|
|
1671
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1672
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
1673
|
+
* can be undone.
|
|
1674
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1675
|
+
* @default undefined
|
|
1676
|
+
*/
|
|
1677
|
+
trackedOrigins: ["user-123"],
|
|
1678
|
+
});
|
|
1653
1679
|
|
|
1654
|
-
/**
|
|
1655
|
-
* @description Track origins to enable undos and redos for your document.
|
|
1656
|
-
* trackOrigins must be called before any storage mutations, to enable those
|
|
1657
|
-
* mutations to be undone/redone.
|
|
1658
|
-
*/
|
|
1659
|
-
myDoc.trackOrigins({
|
|
1660
1680
|
/**
|
|
1661
|
-
* @description
|
|
1662
|
-
*
|
|
1663
|
-
* undone together. Set this to 0, to track each transacted change individually.
|
|
1664
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1665
|
-
* @default 500
|
|
1681
|
+
* @description Check whether calling undo will mutate storage
|
|
1682
|
+
* @returns boolean
|
|
1666
1683
|
*/
|
|
1667
|
-
|
|
1684
|
+
myDoc.canUndo();
|
|
1668
1685
|
/**
|
|
1669
|
-
* @
|
|
1670
|
-
*
|
|
1671
|
-
* can be undone.
|
|
1672
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1673
|
-
* @default undefined
|
|
1686
|
+
* @description Check whether calling redo will mutate storage
|
|
1687
|
+
* @returns boolean
|
|
1674
1688
|
*/
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
/**
|
|
1684
|
-
* @description Check whether calling redo will mutate storage
|
|
1685
|
-
* @returns boolean
|
|
1686
|
-
*/
|
|
1687
|
-
myDoc.canRedo();
|
|
1688
|
-
|
|
1689
|
-
// Perform a storage mutation within a transaction so that it can be affected
|
|
1690
|
-
// by undo/redo operations.
|
|
1691
|
-
myDoc.transact(() => {
|
|
1692
|
-
myDoc.get("messages").push(["hello world!"]);
|
|
1693
|
-
}, "user-123");
|
|
1694
|
-
|
|
1695
|
-
/**
|
|
1696
|
-
* @description Undoes the last valid mutation to storage
|
|
1697
|
-
*/
|
|
1698
|
-
myDoc.undo();
|
|
1699
|
-
|
|
1700
|
-
/**
|
|
1701
|
-
* @description Re-applies the last undone mutation to storage
|
|
1702
|
-
*/
|
|
1703
|
-
myDoc.redo();
|
|
1704
|
-
```
|
|
1705
|
-
|
|
1706
|
-
## @pluv/client
|
|
1707
|
-
|
|
1708
|
-
`@pluv/client`'s `PluvRoom` and `MockedRoom` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `transact`.
|
|
1709
|
-
|
|
1710
|
-
Refer to the code-example below to better understand how to undo and redo with your `PluvRoom`.
|
|
1711
|
-
|
|
1712
|
-
```ts
|
|
1713
|
-
import { createClient, y } from "@pluv/client";
|
|
1714
|
-
|
|
1715
|
-
const client = createClient({});
|
|
1716
|
-
|
|
1717
|
-
/**
|
|
1718
|
-
* @description When a room is created, undo/redo will automatically
|
|
1719
|
-
* be configured to filter for changes made by the connected user
|
|
1720
|
-
* (so that users only undo/redo their changes).
|
|
1721
|
-
*/
|
|
1722
|
-
const room = client.createRoom("my-room", {
|
|
1723
|
-
initialStorage: () => ({
|
|
1724
|
-
messages: y.array<string>([]),
|
|
1725
|
-
}),
|
|
1689
|
+
myDoc.canRedo();
|
|
1690
|
+
|
|
1691
|
+
// Perform a storage mutation within a transaction so that it can be affected
|
|
1692
|
+
// by undo/redo operations.
|
|
1693
|
+
myDoc.transact(() => {
|
|
1694
|
+
myDoc.get("messages").push(["hello world!"]);
|
|
1695
|
+
}, "user-123");
|
|
1696
|
+
|
|
1726
1697
|
/**
|
|
1727
|
-
* @description
|
|
1728
|
-
* This specifies a number in ms, during which edits are merged together to be
|
|
1729
|
-
* undone together. Set this to 0, to track each transacted change individually.
|
|
1730
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1731
|
-
* @default 500
|
|
1698
|
+
* @description Undoes the last valid mutation to storage
|
|
1732
1699
|
*/
|
|
1733
|
-
|
|
1700
|
+
myDoc.undo();
|
|
1701
|
+
|
|
1734
1702
|
/**
|
|
1735
|
-
* @
|
|
1736
|
-
* This specifies transaction origins (strings only) to filter which transactions
|
|
1737
|
-
* can be undone.
|
|
1738
|
-
* When omitted, the user's connection id will be tracked. When provided,
|
|
1739
|
-
* specifies additional tracked origins besides the user's connection id.
|
|
1740
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1741
|
-
* @default undefined
|
|
1703
|
+
* @description Re-applies the last undone mutation to storage
|
|
1742
1704
|
*/
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
## @pluv/react
|
|
1785
|
-
|
|
1786
|
-
`@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `useCanRedo`, `useCanUndo`, `useRedo`, `useUndo` and `useTransact`.
|
|
1787
|
-
|
|
1788
|
-
Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
|
|
1789
|
-
|
|
1790
|
-
```tsx
|
|
1791
|
-
import { createBundle, createClient, y } from "@pluv/react";
|
|
1792
|
-
import { type io } from "./io";
|
|
1793
|
-
|
|
1794
|
-
const client = createClient<typeof io>();
|
|
1795
|
-
|
|
1796
|
-
const { createRoomBundle } = createBundle(client);
|
|
1797
|
-
|
|
1798
|
-
const { useCanRedo, useCanUndo, useRedo, useStorage, useTransact, useUndo } =
|
|
1799
|
-
createRoomBundle({
|
|
1800
|
-
initialStorage: () => ({
|
|
1801
|
-
messages: y.array<string>([]),
|
|
1802
|
-
}),
|
|
1803
|
-
/**
|
|
1804
|
-
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1805
|
-
* This specifies a number in ms, during which edits are merged together to be
|
|
1806
|
-
* undone together. Set this to 0, to track each transacted change individually.
|
|
1807
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1808
|
-
* @default 500
|
|
1809
|
-
*/
|
|
1810
|
-
captureTimeout: 500,
|
|
1811
|
-
/**
|
|
1812
|
-
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1813
|
-
* This specifies transaction origins (strings only) to filter which transactions
|
|
1814
|
-
* can be undone.
|
|
1815
|
-
* When omitted, the user's connection id will be tracked. When provided,
|
|
1816
|
-
* specifies additional tracked origins besides the user's connection id.
|
|
1817
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1818
|
-
* @default undefined
|
|
1819
|
-
*/
|
|
1820
|
-
trackedOrigins: ["user-123"],
|
|
1705
|
+
myDoc.redo();
|
|
1706
|
+
```
|
|
1707
|
+
|
|
1708
|
+
## @pluv/client
|
|
1709
|
+
|
|
1710
|
+
`@pluv/client`'s `PluvRoom` and `MockedRoom` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `transact`.
|
|
1711
|
+
|
|
1712
|
+
Refer to the code-example below to better understand how to undo and redo with your `PluvRoom`.
|
|
1713
|
+
|
|
1714
|
+
```ts
|
|
1715
|
+
import { createClient, y } from "@pluv/client";
|
|
1716
|
+
|
|
1717
|
+
const client = createClient({});
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* @description When a room is created, undo/redo will automatically
|
|
1721
|
+
* be configured to filter for changes made by the connected user
|
|
1722
|
+
* (so that users only undo/redo their changes).
|
|
1723
|
+
*/
|
|
1724
|
+
const room = client.createRoom("my-room", {
|
|
1725
|
+
initialStorage: () => ({
|
|
1726
|
+
messages: y.array<string>([]),
|
|
1727
|
+
}),
|
|
1728
|
+
/**
|
|
1729
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1730
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
1731
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
1732
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1733
|
+
* @default 500
|
|
1734
|
+
*/
|
|
1735
|
+
captureTimeout: 500,
|
|
1736
|
+
/**
|
|
1737
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1738
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
1739
|
+
* can be undone.
|
|
1740
|
+
* When omitted, the user's connection id will be tracked. When provided,
|
|
1741
|
+
* specifies additional tracked origins besides the user's connection id.
|
|
1742
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1743
|
+
* @default undefined
|
|
1744
|
+
*/
|
|
1745
|
+
trackedOrigins: ["user-123"],
|
|
1821
1746
|
});
|
|
1822
1747
|
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1748
|
+
/**
|
|
1749
|
+
* @description Check whether calling undo will mutate storage
|
|
1750
|
+
* @returns boolean
|
|
1751
|
+
*/
|
|
1752
|
+
room.canUndo();
|
|
1753
|
+
/**
|
|
1754
|
+
* @description Check whether calling redo will mutate storage
|
|
1755
|
+
* @returns boolean
|
|
1756
|
+
*/
|
|
1757
|
+
room.canRedo();
|
|
1831
1758
|
|
|
1832
|
-
|
|
1759
|
+
/**
|
|
1760
|
+
* @description Calling transact will enable a storage mutation to be undone/redone.
|
|
1761
|
+
* When called without an origin, the origin will default to the user's connection
|
|
1762
|
+
* id.
|
|
1763
|
+
*
|
|
1764
|
+
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1765
|
+
*/
|
|
1766
|
+
room.transact(() => {
|
|
1767
|
+
room.get("messages").push(["hello world!"]);
|
|
1768
|
+
});
|
|
1833
1769
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
*
|
|
1839
|
-
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1840
|
-
*/
|
|
1841
|
-
const transact = useTransact();
|
|
1770
|
+
// This will also be undoable because `"user-123"` is a tracked origin.
|
|
1771
|
+
room.transact(() => {
|
|
1772
|
+
room.get("messages").push(["hello world!"]);
|
|
1773
|
+
}, "user-123");
|
|
1842
1774
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1775
|
+
/**
|
|
1776
|
+
* @description Undoes the last valid mutation to storage
|
|
1777
|
+
*/
|
|
1778
|
+
room.undo();
|
|
1846
1779
|
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1780
|
+
/**
|
|
1781
|
+
* @description Re-applies the last undone mutation to storage
|
|
1782
|
+
*/
|
|
1783
|
+
room.redo();
|
|
1784
|
+
```
|
|
1785
|
+
|
|
1786
|
+
## @pluv/react
|
|
1787
|
+
|
|
1788
|
+
`@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `useCanRedo`, `useCanUndo`, `useRedo`, `useUndo` and `useTransact`.
|
|
1789
|
+
|
|
1790
|
+
Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
|
|
1791
|
+
|
|
1792
|
+
```tsx
|
|
1793
|
+
import { createBundle, createClient, y } from "@pluv/react";
|
|
1794
|
+
import { type io } from "./io";
|
|
1795
|
+
|
|
1796
|
+
const client = createClient<typeof io>();
|
|
1797
|
+
|
|
1798
|
+
const { createRoomBundle } = createBundle(client);
|
|
1799
|
+
|
|
1800
|
+
const { useCanRedo, useCanUndo, useRedo, useStorage, useTransact, useUndo } = createRoomBundle({
|
|
1801
|
+
initialStorage: () => ({
|
|
1802
|
+
messages: y.array<string>([]),
|
|
1803
|
+
}),
|
|
1804
|
+
/**
|
|
1805
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1806
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
1807
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
1808
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1809
|
+
* @default 500
|
|
1810
|
+
*/
|
|
1811
|
+
captureTimeout: 500,
|
|
1812
|
+
/**
|
|
1813
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1814
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
1815
|
+
* can be undone.
|
|
1816
|
+
* When omitted, the user's connection id will be tracked. When provided,
|
|
1817
|
+
* specifies additional tracked origins besides the user's connection id.
|
|
1818
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1819
|
+
* @default undefined
|
|
1820
|
+
*/
|
|
1821
|
+
trackedOrigins: ["user-123"],
|
|
1822
|
+
});
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* @description Check whether calling undo will mutate storage
|
|
1826
|
+
*/
|
|
1827
|
+
const canUndo: boolean = useCanUndo();
|
|
1828
|
+
/**
|
|
1829
|
+
* @description Check whether calling redo will mutate storage
|
|
1830
|
+
*/
|
|
1831
|
+
const canRedo: boolean = useCanRedo();
|
|
1851
1832
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1833
|
+
const [messages, sharedType] = useStorage("messages");
|
|
1834
|
+
|
|
1835
|
+
/**
|
|
1836
|
+
* @description Calling transact will enable a storage mutation to be undone/redone.
|
|
1837
|
+
* When called without an origin, the origin will default to the user's connection
|
|
1838
|
+
* id.
|
|
1839
|
+
*
|
|
1840
|
+
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1841
|
+
*/
|
|
1842
|
+
const transact = useTransact();
|
|
1843
|
+
|
|
1844
|
+
transact(() => {
|
|
1845
|
+
sharedType.push(["hello world!"]);
|
|
1846
|
+
});
|
|
1847
|
+
|
|
1848
|
+
// This will also be undoable because `"user-123"` is a tracked origin.
|
|
1849
|
+
transact(() => {
|
|
1850
|
+
sharedType.push(["hello world!"]);
|
|
1851
|
+
}, "user-123");
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* @description Undoes the last valid mutation to storage
|
|
1855
|
+
*/
|
|
1856
|
+
const undo = useUndo();
|
|
1856
1857
|
|
|
1857
|
-
|
|
1858
|
+
undo();
|
|
1858
1859
|
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1860
|
+
/**
|
|
1861
|
+
* @description Re-applies the last undone mutation to storage
|
|
1862
|
+
*/
|
|
1863
|
+
const redo = useRedo();
|
|
1863
1864
|
|
|
1864
|
-
|
|
1865
|
-
|
|
1865
|
+
redo();
|
|
1866
|
+
```
|
|
1866
1867
|
|
|
1867
1868
|
### Patch Changes
|
|
1868
1869
|
|
|
1869
1870
|
- Updated dependencies [436040b]
|
|
1870
|
-
|
|
1871
|
-
|
|
1871
|
+
- @pluv/crdt-yjs@0.12.0
|
|
1872
|
+
- @pluv/types@0.12.0
|
|
1872
1873
|
|
|
1873
1874
|
## 0.11.1
|
|
1874
1875
|
|
|
@@ -1876,8 +1877,8 @@
|
|
|
1876
1877
|
|
|
1877
1878
|
- 74b3061: Bumped minor and patch dependencies.
|
|
1878
1879
|
- Updated dependencies [74b3061]
|
|
1879
|
-
|
|
1880
|
-
|
|
1880
|
+
- @pluv/crdt-yjs@0.11.1
|
|
1881
|
+
- @pluv/types@0.11.1
|
|
1881
1882
|
|
|
1882
1883
|
## 0.11.0
|
|
1883
1884
|
|
|
@@ -1906,8 +1907,8 @@
|
|
|
1906
1907
|
|
|
1907
1908
|
- 885835d: remove unnecessary dependency
|
|
1908
1909
|
- Updated dependencies [885835d]
|
|
1909
|
-
|
|
1910
|
-
|
|
1910
|
+
- @pluv/crdt-yjs@0.10.1
|
|
1911
|
+
- @pluv/types@0.10.1
|
|
1911
1912
|
|
|
1912
1913
|
## 0.10.0
|
|
1913
1914
|
|
|
@@ -1918,8 +1919,8 @@
|
|
|
1918
1919
|
### Patch Changes
|
|
1919
1920
|
|
|
1920
1921
|
- Updated dependencies [f43f1cc]
|
|
1921
|
-
|
|
1922
|
-
|
|
1922
|
+
- @pluv/crdt-yjs@0.10.0
|
|
1923
|
+
- @pluv/types@0.10.0
|
|
1923
1924
|
|
|
1924
1925
|
## 0.9.2
|
|
1925
1926
|
|
|
@@ -1927,21 +1928,21 @@
|
|
|
1927
1928
|
|
|
1928
1929
|
- f4317ba: \* Renamed type `unstable_YObjectValue` to `YObjectValue`;
|
|
1929
1930
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1931
|
+
- Renamed type `unstable_YObject` to `YObject`.
|
|
1932
|
+
- Re-exported `xmlElement`, `xmlFragment` and `xmlText` from `@pluv/client`.
|
|
1932
1933
|
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1934
|
+
```ts
|
|
1935
|
+
import { y } from "@pluv/client";
|
|
1936
|
+
// or
|
|
1937
|
+
import { y } from "@pluv/react";
|
|
1937
1938
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1939
|
+
y.xmlElement("MyElement", {});
|
|
1940
|
+
y.xmlFragment({});
|
|
1941
|
+
y.xmlText("hello world");
|
|
1942
|
+
```
|
|
1942
1943
|
|
|
1943
1944
|
- Updated dependencies [f4317ba]
|
|
1944
|
-
|
|
1945
|
+
- @pluv/crdt-yjs@0.4.2
|
|
1945
1946
|
|
|
1946
1947
|
## 0.9.1
|
|
1947
1948
|
|
|
@@ -1951,8 +1952,8 @@
|
|
|
1951
1952
|
- 8997c65: bumped dependencies
|
|
1952
1953
|
- Updated dependencies [8fba48b]
|
|
1953
1954
|
- Updated dependencies [8997c65]
|
|
1954
|
-
|
|
1955
|
-
|
|
1955
|
+
- @pluv/crdt-yjs@0.4.1
|
|
1956
|
+
- @pluv/types@0.2.2
|
|
1956
1957
|
|
|
1957
1958
|
## 0.9.0
|
|
1958
1959
|
|
|
@@ -1960,49 +1961,49 @@
|
|
|
1960
1961
|
|
|
1961
1962
|
- 829d31b: Added support for defining persistant frontend storage for rooms via a new `addons` option on rooms.
|
|
1962
1963
|
|
|
1963
|
-
|
|
1964
|
+
This also introduces the first new addon `@pluv/addon-indexeddb`, which is more-or-less the equivalent to `y-indexeddb` which you can install like so:
|
|
1964
1965
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1966
|
+
```
|
|
1967
|
+
npm install @pluv/addon-indexeddb
|
|
1968
|
+
```
|
|
1968
1969
|
|
|
1969
|
-
|
|
1970
|
+
To use this new addon, simply pass it to options when creating a room:
|
|
1970
1971
|
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1972
|
+
```ts
|
|
1973
|
+
import { addonIndexedDB } from "@pluv/addon-indexeddb";
|
|
1974
|
+
import { createClient } from "@pluv/client";
|
|
1974
1975
|
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1976
|
+
const client = createClient({
|
|
1977
|
+
// ...
|
|
1978
|
+
});
|
|
1978
1979
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1980
|
+
const room = client.createRoom("my-new-room", {
|
|
1981
|
+
addons: [
|
|
1982
|
+
// Define your addons in an array like so
|
|
1983
|
+
addonIndexedDB(),
|
|
1984
|
+
],
|
|
1985
|
+
});
|
|
1986
|
+
```
|
|
1986
1987
|
|
|
1987
|
-
|
|
1988
|
+
Or when using `@pluv/react`:
|
|
1988
1989
|
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1990
|
+
```ts
|
|
1991
|
+
const PluvRoom = createRoomBundle({
|
|
1992
|
+
// ...
|
|
1993
|
+
addons: [
|
|
1994
|
+
// Define your addons in an array like so
|
|
1995
|
+
addonIndexedDB(),
|
|
1996
|
+
],
|
|
1997
|
+
});
|
|
1998
|
+
```
|
|
1998
1999
|
|
|
1999
2000
|
### Patch Changes
|
|
2000
2001
|
|
|
2001
2002
|
- 8d11672: bumped dependencies to latest
|
|
2002
2003
|
- Updated dependencies [8d11672]
|
|
2003
2004
|
- Updated dependencies [829d31b]
|
|
2004
|
-
|
|
2005
|
-
|
|
2005
|
+
- @pluv/crdt-yjs@0.4.0
|
|
2006
|
+
- @pluv/types@0.2.1
|
|
2006
2007
|
|
|
2007
2008
|
## 0.8.1
|
|
2008
2009
|
|
|
@@ -2021,8 +2022,8 @@
|
|
|
2021
2022
|
- 5bbfb98: fix not properly handling unauthorized checks
|
|
2022
2023
|
- b85a232: bumped dependencies
|
|
2023
2024
|
- Updated dependencies [b85a232]
|
|
2024
|
-
|
|
2025
|
-
|
|
2025
|
+
- @pluv/crdt-yjs@0.3.8
|
|
2026
|
+
- @pluv/types@0.2.0
|
|
2026
2027
|
|
|
2027
2028
|
## 0.7.0
|
|
2028
2029
|
|
|
@@ -2039,8 +2040,8 @@
|
|
|
2039
2040
|
- Updated dependencies [bb2886b]
|
|
2040
2041
|
- Updated dependencies [ae679a8]
|
|
2041
2042
|
- Updated dependencies [3518a83]
|
|
2042
|
-
|
|
2043
|
-
|
|
2043
|
+
- @pluv/crdt-yjs@0.3.7
|
|
2044
|
+
- @pluv/types@0.2.0
|
|
2044
2045
|
|
|
2045
2046
|
## 0.6.5
|
|
2046
2047
|
|
|
@@ -2048,8 +2049,8 @@
|
|
|
2048
2049
|
|
|
2049
2050
|
- 7ad4967: fixed user's presence not updating locally while offline
|
|
2050
2051
|
- 4535687: fix local yjs doc not updating while disconnected
|
|
2051
|
-
|
|
2052
|
-
|
|
2052
|
+
- @pluv/crdt-yjs@0.3.6
|
|
2053
|
+
- @pluv/types@0.1.6
|
|
2053
2054
|
|
|
2054
2055
|
## 0.6.4
|
|
2055
2056
|
|
|
@@ -2057,7 +2058,7 @@
|
|
|
2057
2058
|
|
|
2058
2059
|
- 78fd644: updated readmes with links to the documentation website
|
|
2059
2060
|
- Updated dependencies [78fd644]
|
|
2060
|
-
|
|
2061
|
+
- @pluv/crdt-yjs@0.3.6
|
|
2061
2062
|
|
|
2062
2063
|
## 0.6.3
|
|
2063
2064
|
|
|
@@ -2065,8 +2066,8 @@
|
|
|
2065
2066
|
|
|
2066
2067
|
- 850626e: bumped dependencies
|
|
2067
2068
|
- Updated dependencies [850626e]
|
|
2068
|
-
|
|
2069
|
-
|
|
2069
|
+
- @pluv/crdt-yjs@0.3.5
|
|
2070
|
+
- @pluv/types@0.1.6
|
|
2070
2071
|
|
|
2071
2072
|
## 0.6.2
|
|
2072
2073
|
|
|
@@ -2074,7 +2075,7 @@
|
|
|
2074
2075
|
|
|
2075
2076
|
- 9ae251d: bumped dependencies
|
|
2076
2077
|
- Updated dependencies [9ae251d]
|
|
2077
|
-
|
|
2078
|
+
- @pluv/crdt-yjs@0.3.4
|
|
2078
2079
|
|
|
2079
2080
|
## 0.6.1
|
|
2080
2081
|
|
|
@@ -2083,8 +2084,8 @@
|
|
|
2083
2084
|
- 19433af: updated MockedRoomProvider events to allow partial events
|
|
2084
2085
|
- 74870ee: bumped dependencies
|
|
2085
2086
|
- Updated dependencies [74870ee]
|
|
2086
|
-
|
|
2087
|
-
|
|
2087
|
+
- @pluv/crdt-yjs@0.3.3
|
|
2088
|
+
- @pluv/types@0.1.5
|
|
2088
2089
|
|
|
2089
2090
|
## 0.6.0
|
|
2090
2091
|
|
|
@@ -2103,8 +2104,8 @@
|
|
|
2103
2104
|
- Updated dependencies [7b6da1c]
|
|
2104
2105
|
- Updated dependencies [e9c1514]
|
|
2105
2106
|
- Updated dependencies [9d1829c]
|
|
2106
|
-
|
|
2107
|
-
|
|
2107
|
+
- @pluv/crdt-yjs@0.3.2
|
|
2108
|
+
- @pluv/types@0.1.4
|
|
2108
2109
|
|
|
2109
2110
|
## 0.5.1
|
|
2110
2111
|
|
|
@@ -2114,8 +2115,8 @@
|
|
|
2114
2115
|
- f6c0e65: bumped dependencies
|
|
2115
2116
|
- Updated dependencies [161e00e]
|
|
2116
2117
|
- Updated dependencies [f6c0e65]
|
|
2117
|
-
|
|
2118
|
-
|
|
2118
|
+
- @pluv/crdt-yjs@0.3.1
|
|
2119
|
+
- @pluv/types@0.1.3
|
|
2119
2120
|
|
|
2120
2121
|
## 0.5.0
|
|
2121
2122
|
|
|
@@ -2135,8 +2136,8 @@
|
|
|
2135
2136
|
- Updated dependencies [b1cb325]
|
|
2136
2137
|
- Updated dependencies [327a6ef]
|
|
2137
2138
|
- Updated dependencies [8e97fb2]
|
|
2138
|
-
|
|
2139
|
-
|
|
2139
|
+
- @pluv/crdt-yjs@0.3.0
|
|
2140
|
+
- @pluv/types@0.1.3
|
|
2140
2141
|
|
|
2141
2142
|
## 0.4.0
|
|
2142
2143
|
|
|
@@ -2159,8 +2160,8 @@
|
|
|
2159
2160
|
### Patch Changes
|
|
2160
2161
|
|
|
2161
2162
|
- Updated dependencies [6858682]
|
|
2162
|
-
|
|
2163
|
-
|
|
2163
|
+
- @pluv/crdt-yjs@0.2.0
|
|
2164
|
+
- @pluv/types@0.1.2
|
|
2164
2165
|
|
|
2165
2166
|
## 0.1.3
|
|
2166
2167
|
|
|
@@ -2168,15 +2169,15 @@
|
|
|
2168
2169
|
|
|
2169
2170
|
- fe80d7b: added preview disclaimer about breaking changes in the readme
|
|
2170
2171
|
- Updated dependencies [fe80d7b]
|
|
2171
|
-
|
|
2172
|
-
|
|
2172
|
+
- @pluv/crdt-yjs@0.1.3
|
|
2173
|
+
- @pluv/types@0.1.2
|
|
2173
2174
|
|
|
2174
2175
|
## 0.1.2
|
|
2175
2176
|
|
|
2176
2177
|
### Patch Changes
|
|
2177
2178
|
|
|
2178
2179
|
- Updated dependencies [b45d642]
|
|
2179
|
-
|
|
2180
|
+
- @pluv/crdt-yjs@0.1.2
|
|
2180
2181
|
|
|
2181
2182
|
## 0.1.1
|
|
2182
2183
|
|
|
@@ -2185,8 +2186,8 @@
|
|
|
2185
2186
|
- 23a7382: Omitted unused `encodedState` param from PluvRoom.
|
|
2186
2187
|
- 24016e6: Updated dependencies
|
|
2187
2188
|
- Updated dependencies [24016e6]
|
|
2188
|
-
|
|
2189
|
-
|
|
2189
|
+
- @pluv/crdt-yjs@0.1.1
|
|
2190
|
+
- @pluv/types@0.1.1
|
|
2190
2191
|
|
|
2191
2192
|
## 0.1.0
|
|
2192
2193
|
|
|
@@ -2197,5 +2198,5 @@
|
|
|
2197
2198
|
### Patch Changes
|
|
2198
2199
|
|
|
2199
2200
|
- Updated dependencies [a22f525]
|
|
2200
|
-
|
|
2201
|
-
|
|
2201
|
+
- @pluv/crdt-yjs@0.1.0
|
|
2202
|
+
- @pluv/types@0.1.0
|