@pluv/crdt-yjs 2.2.0 → 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 +9 -9
- package/CHANGELOG.md +423 -409
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +7 -7
- package/src/awareness/PluvYjsAwareness.ts +3 -3
- package/src/provider/PluvYjsProvider.ts +3 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-yjs@2.2.
|
|
2
|
+
> @pluv/crdt-yjs@2.2.2 build /home/runner/work/pluv/pluv/packages/crdt-yjs
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.
|
|
7
|
+
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m23.19 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 123ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m22.25 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 124ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m10.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4915ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m10.95 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.95 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,76 +1,91 @@
|
|
|
1
1
|
# @pluv/crdt-yjs
|
|
2
2
|
|
|
3
|
+
## 2.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 289d71d: Updated `yjs.provider` field to `presenceField`.
|
|
8
|
+
- @pluv/crdt@2.2.2
|
|
9
|
+
- @pluv/types@2.2.2
|
|
10
|
+
|
|
11
|
+
## 2.2.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @pluv/crdt@2.2.1
|
|
16
|
+
- @pluv/types@2.2.1
|
|
17
|
+
|
|
3
18
|
## 2.2.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
6
21
|
|
|
7
22
|
- 745f6df: Added a `provider` function that satisfies Yjs's provider interface.
|
|
8
23
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
```ts
|
|
25
|
+
import { createClient } from "@pluv/client";
|
|
26
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
12
27
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
const client = createClient({
|
|
29
|
+
/* ... */
|
|
30
|
+
});
|
|
31
|
+
const room = client.createRoom("example-room");
|
|
17
32
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
// Yjs Provider
|
|
34
|
+
yjs.provider({ room });
|
|
35
|
+
```
|
|
21
36
|
|
|
22
37
|
- df4ceed: Update `yjs.awareness` and `yjs.provider` to allow for a `field` parameter to use awareness on a nested presence field.
|
|
23
38
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
```ts
|
|
40
|
+
createClient({
|
|
41
|
+
presence: z.object({
|
|
42
|
+
topField: z.number(),
|
|
43
|
+
forAwareness: z.object({
|
|
44
|
+
nestedField: z.number(),
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
yjs.provider({
|
|
50
|
+
// ...
|
|
51
|
+
// Optional field to use a nested field, instead of the presence root
|
|
52
|
+
field: "forAwareness",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
yjs.awareness({
|
|
56
|
+
// ...
|
|
57
|
+
// Optional field to use a nested field, instead of the presence root
|
|
58
|
+
field: "forAwareness",
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This allows better integrations with [lexical](https://lexical.dev), since they have their own presence types.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
createClient({
|
|
66
|
+
presence: z.object({
|
|
67
|
+
topField: z.number(),
|
|
68
|
+
lexical: z.any(),
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
yjs.provider({ field: "lexical" /* ... */ });
|
|
73
|
+
```
|
|
59
74
|
|
|
60
75
|
- 6323979: Added an `awareness` function that satisfies Yjs's [awareness interface](https://github.com/yjs/y-protocols/blob/master/awareness.js).
|
|
61
76
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
```ts
|
|
78
|
+
import { createClient } from "@pluv/client";
|
|
79
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
65
80
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
const client = createClient({
|
|
82
|
+
/* ... */
|
|
83
|
+
});
|
|
84
|
+
const room = client.createRoom("example-room");
|
|
70
85
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
// Yjs Awareness
|
|
87
|
+
yjs.awareness({ room /* ... */ });
|
|
88
|
+
```
|
|
74
89
|
|
|
75
90
|
### Patch Changes
|
|
76
91
|
|
|
@@ -90,10 +105,10 @@
|
|
|
90
105
|
|
|
91
106
|
- 945c47d: Updated deprecation warnings to read that features will be removed in v3 instead of v2.
|
|
92
107
|
|
|
93
|
-
|
|
108
|
+
Due to an [extremely unfortunate bug in changesets](https://github.com/changesets/changesets/issues/1011), minor and patch changes will create major releases. This caused an unintended v2 release that had no breaking changes. To avoid backtracking and deleting deprecated functionalities right away, the deprecation warnings have been updated so that those APIs will be removed in v3 instead of v2.
|
|
94
109
|
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
- @pluv/crdt@2.0.2
|
|
111
|
+
- @pluv/types@2.0.2
|
|
97
112
|
|
|
98
113
|
## 2.0.1
|
|
99
114
|
|
|
@@ -108,43 +123,43 @@
|
|
|
108
123
|
|
|
109
124
|
- 0b234d1: **Deprecated** Declaring top-level types on your CRDT storage via the `yjs` utility (e.g. `yjs.array`) is now deprecated, to be removed in the next major release (v2). Continuing to use the `yjs` utility to declare top-level types will log a warning to your console while in development mode (i.e. when `process.env.NODE_ENV === "development"`). To declare top-level types, you should now use the builder type exposed in the storage factory function. See the example below:
|
|
110
125
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
```ts
|
|
127
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
128
|
+
|
|
129
|
+
// Before
|
|
130
|
+
yjs.doc(() => ({
|
|
131
|
+
// Using the `yjs` utility (in this case `yjs.map`) when declaring
|
|
132
|
+
// top-level types is now deprecated
|
|
133
|
+
topType: yjs.map([
|
|
134
|
+
["key1", yjs.text("")],
|
|
135
|
+
["key2", yjs.text("")],
|
|
136
|
+
]),
|
|
137
|
+
}));
|
|
138
|
+
|
|
139
|
+
// After
|
|
140
|
+
yjs.doc((t) => ({
|
|
141
|
+
// Top-level properties must now use the builder (in this case `t`).
|
|
142
|
+
// This effectively calls `yjs.getMap("topType")` to instantiate the type on
|
|
143
|
+
// the root document.
|
|
144
|
+
// This simply returns the native Yjs shared-types (e.g. Y.Map), which
|
|
145
|
+
// allows you operate on your yjs shared-typess in a more native way.
|
|
146
|
+
topType: t.map("topType", [
|
|
147
|
+
// Declaring nested types should continue to use the `yjs` utilities
|
|
148
|
+
// you've used before
|
|
149
|
+
["key1", yjs.text("")],
|
|
150
|
+
["key2", yjs.text("")],
|
|
151
|
+
]),
|
|
152
|
+
}));
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The functions on the builder type calls the native yjs shared-type instantiating methods and returns the native types (e.g. `t.map("topType")` is simply just a `Y.Doc.getMap("topType")`) call under the hood. This allows you to declare your type in a more yjs-native and predictable way, and enables declaring more complex initial storage states if needed.
|
|
141
156
|
|
|
142
157
|
### Patch Changes
|
|
143
158
|
|
|
144
159
|
- 0b234d1: Fixed `Y.XmlText` types transforming into `Y.Text` types on the initial initializaion of storage states.
|
|
145
160
|
- Updated dependencies [047a1d8]
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
- @pluv/types@2.0.0
|
|
162
|
+
- @pluv/crdt@2.0.0
|
|
148
163
|
|
|
149
164
|
## 1.0.2
|
|
150
165
|
|
|
@@ -166,15 +181,15 @@
|
|
|
166
181
|
|
|
167
182
|
- af94706: pluv.io is now stable and production ready!
|
|
168
183
|
|
|
169
|
-
|
|
184
|
+
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.
|
|
170
185
|
|
|
171
|
-
|
|
186
|
+
Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
|
|
172
187
|
|
|
173
188
|
### Patch Changes
|
|
174
189
|
|
|
175
190
|
- Updated dependencies [af94706]
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
- @pluv/crdt@1.0.0
|
|
192
|
+
- @pluv/types@1.0.0
|
|
178
193
|
|
|
179
194
|
## 0.44.2
|
|
180
195
|
|
|
@@ -195,8 +210,8 @@
|
|
|
195
210
|
### Patch Changes
|
|
196
211
|
|
|
197
212
|
- 503c23b: Updated `batchApplyEncodedState` to use `Yjs.mergeUpdates` to more efficiently update the document under-the-hood, while also producing a smaller document.
|
|
198
|
-
|
|
199
|
-
|
|
213
|
+
- @pluv/crdt@0.44.0
|
|
214
|
+
- @pluv/types@0.44.0
|
|
200
215
|
|
|
201
216
|
## 0.43.0
|
|
202
217
|
|
|
@@ -406,8 +421,8 @@
|
|
|
406
421
|
### Patch Changes
|
|
407
422
|
|
|
408
423
|
- Updated dependencies [f4ceca3]
|
|
409
|
-
|
|
410
|
-
|
|
424
|
+
- @pluv/types@0.38.0
|
|
425
|
+
- @pluv/crdt@0.38.0
|
|
411
426
|
|
|
412
427
|
## 0.37.7
|
|
413
428
|
|
|
@@ -491,16 +506,16 @@
|
|
|
491
506
|
### Patch Changes
|
|
492
507
|
|
|
493
508
|
- Updated dependencies [81cb692]
|
|
494
|
-
|
|
495
|
-
|
|
509
|
+
- @pluv/types@0.35.2
|
|
510
|
+
- @pluv/crdt@0.35.2
|
|
496
511
|
|
|
497
512
|
## 0.35.1
|
|
498
513
|
|
|
499
514
|
### Patch Changes
|
|
500
515
|
|
|
501
516
|
- 820898c: Increase undo/redo merge interval from 0s to 1s.
|
|
502
|
-
|
|
503
|
-
|
|
517
|
+
- @pluv/crdt@0.35.1
|
|
518
|
+
- @pluv/types@0.35.1
|
|
504
519
|
|
|
505
520
|
## 0.35.0
|
|
506
521
|
|
|
@@ -626,8 +641,8 @@
|
|
|
626
641
|
### Patch Changes
|
|
627
642
|
|
|
628
643
|
- 7246a9e: Added `CrdtLibraryType` so that `@pluv/crdt-yjs` and `@pluv/crdt-loro` export a new property `kind` containing an identifier for the crdt.
|
|
629
|
-
|
|
630
|
-
|
|
644
|
+
- @pluv/crdt@0.30.0
|
|
645
|
+
- @pluv/types@0.30.0
|
|
631
646
|
|
|
632
647
|
## 0.29.0
|
|
633
648
|
|
|
@@ -740,76 +755,76 @@
|
|
|
740
755
|
|
|
741
756
|
- 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.
|
|
742
757
|
|
|
743
|
-
|
|
758
|
+
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.
|
|
744
759
|
|
|
745
|
-
|
|
760
|
+
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.
|
|
746
761
|
|
|
747
|
-
|
|
748
|
-
|
|
762
|
+
```ts
|
|
763
|
+
// Before
|
|
749
764
|
|
|
750
|
-
|
|
765
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
751
766
|
|
|
752
|
-
|
|
753
|
-
|
|
767
|
+
yjs.array([]); // Returns CrdtYjsArray
|
|
768
|
+
yjs.object([]); // Returns CrdtYjsObject
|
|
754
769
|
|
|
755
|
-
|
|
770
|
+
const room: PluvRoom = /* ... */;
|
|
756
771
|
|
|
757
|
-
|
|
772
|
+
room.getStorage("messages"); // Returns AbstractCrdtType
|
|
758
773
|
|
|
759
|
-
|
|
760
|
-
|
|
774
|
+
const [, sharedType] = useStorage("messages"); // sharedType is an AbstractCrdtType
|
|
775
|
+
```
|
|
761
776
|
|
|
762
|
-
|
|
763
|
-
|
|
777
|
+
```ts
|
|
778
|
+
// Now
|
|
764
779
|
|
|
765
|
-
|
|
780
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
766
781
|
|
|
767
|
-
|
|
768
|
-
|
|
782
|
+
yjs.array([]); // Returns yjs.Array
|
|
783
|
+
yjs.object([]); // Returns yjs.Map
|
|
769
784
|
|
|
770
|
-
|
|
785
|
+
const room: PluvRoom = /* ... */;
|
|
771
786
|
|
|
772
|
-
|
|
787
|
+
room.getStorage("messages"); // Returns yjs.AbstractType
|
|
773
788
|
|
|
774
|
-
|
|
775
|
-
|
|
789
|
+
const [, sharedType] = useStorage("messages"); // sharedType is a yjs.AbstractType
|
|
790
|
+
```
|
|
776
791
|
|
|
777
|
-
|
|
792
|
+
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:
|
|
778
793
|
|
|
779
|
-
|
|
780
|
-
|
|
794
|
+
```ts
|
|
795
|
+
// Before
|
|
781
796
|
|
|
782
|
-
|
|
797
|
+
const [data, container] = useStorage("messages");
|
|
783
798
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
799
|
+
// This automatically called Loro.commit under the hood and rerendered the page with updated data.
|
|
800
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
801
|
+
```
|
|
787
802
|
|
|
788
|
-
|
|
789
|
-
|
|
803
|
+
```ts
|
|
804
|
+
// Now
|
|
790
805
|
|
|
791
|
-
|
|
806
|
+
const [data, container] = useStorage("messages");
|
|
792
807
|
|
|
793
|
-
|
|
794
|
-
|
|
808
|
+
const doc = useDoc();
|
|
809
|
+
const transact = useTransact();
|
|
795
810
|
|
|
796
|
-
|
|
797
|
-
|
|
811
|
+
// Updates need to be committed back to the doc whenever the changes need to be emitted to other users
|
|
812
|
+
// The returned data also will not update until the changes are commited
|
|
798
813
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
814
|
+
// The two operations below are functionally equivalent
|
|
815
|
+
transact(() => {
|
|
816
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
817
|
+
});
|
|
803
818
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
819
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
820
|
+
doc.value.commit();
|
|
821
|
+
```
|
|
807
822
|
|
|
808
823
|
### Patch Changes
|
|
809
824
|
|
|
810
825
|
- Updated dependencies [9492085]
|
|
811
|
-
|
|
812
|
-
|
|
826
|
+
- @pluv/crdt@0.20.0
|
|
827
|
+
- @pluv/types@0.20.0
|
|
813
828
|
|
|
814
829
|
## 0.19.0
|
|
815
830
|
|
|
@@ -823,8 +838,8 @@
|
|
|
823
838
|
### Patch Changes
|
|
824
839
|
|
|
825
840
|
- Updated dependencies [99b5ca9]
|
|
826
|
-
|
|
827
|
-
|
|
841
|
+
- @pluv/types@0.18.0
|
|
842
|
+
- @pluv/crdt@0.18.0
|
|
828
843
|
|
|
829
844
|
## 0.17.3
|
|
830
845
|
|
|
@@ -852,8 +867,8 @@
|
|
|
852
867
|
### Patch Changes
|
|
853
868
|
|
|
854
869
|
- Updated dependencies [507bc00]
|
|
855
|
-
|
|
856
|
-
|
|
870
|
+
- @pluv/types@0.17.0
|
|
871
|
+
- @pluv/crdt@0.17.0
|
|
857
872
|
|
|
858
873
|
## 0.16.3
|
|
859
874
|
|
|
@@ -912,7 +927,7 @@
|
|
|
912
927
|
### Patch Changes
|
|
913
928
|
|
|
914
929
|
- da9f600: Upgraded dependencies
|
|
915
|
-
|
|
930
|
+
- @pluv/types@0.12.3
|
|
916
931
|
|
|
917
932
|
## 0.12.2
|
|
918
933
|
|
|
@@ -932,233 +947,232 @@
|
|
|
932
947
|
|
|
933
948
|
- 436040b: Added ability to undo and redo changes to storage.
|
|
934
949
|
|
|
935
|
-
|
|
950
|
+
## @pluv/crdt-yjs
|
|
951
|
+
|
|
952
|
+
`@pluv/crdt-yjs` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `trackOrigins`.
|
|
953
|
+
|
|
954
|
+
Refer to the code-example below to better understand how to undo and redo with your doc.
|
|
955
|
+
|
|
956
|
+
```ts
|
|
957
|
+
// Example
|
|
958
|
+
import { array, doc } from "@pluv/crdt-yjs";
|
|
959
|
+
|
|
960
|
+
// Create your doc with your shared-types
|
|
961
|
+
const myDoc = doc({
|
|
962
|
+
messages: array<string>([]),
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* @description Track origins to enable undos and redos for your document.
|
|
967
|
+
* trackOrigins must be called before any storage mutations, to enable those
|
|
968
|
+
* mutations to be undone/redone.
|
|
969
|
+
*/
|
|
970
|
+
myDoc.trackOrigins({
|
|
971
|
+
/**
|
|
972
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
973
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
974
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
975
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
976
|
+
* @default 500
|
|
977
|
+
*/
|
|
978
|
+
captureTimeout: 500,
|
|
979
|
+
/**
|
|
980
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
981
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
982
|
+
* can be undone.
|
|
983
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
984
|
+
* @default undefined
|
|
985
|
+
*/
|
|
986
|
+
trackedOrigins: ["user-123"],
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @description Check whether calling undo will mutate storage
|
|
991
|
+
* @returns boolean
|
|
992
|
+
*/
|
|
993
|
+
myDoc.canUndo();
|
|
994
|
+
/**
|
|
995
|
+
* @description Check whether calling redo will mutate storage
|
|
996
|
+
* @returns boolean
|
|
997
|
+
*/
|
|
998
|
+
myDoc.canRedo();
|
|
999
|
+
|
|
1000
|
+
// Perform a storage mutation within a transaction so that it can be affected
|
|
1001
|
+
// by undo/redo operations.
|
|
1002
|
+
myDoc.transact(() => {
|
|
1003
|
+
myDoc.get("messages").push(["hello world!"]);
|
|
1004
|
+
}, "user-123");
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* @description Undoes the last valid mutation to storage
|
|
1008
|
+
*/
|
|
1009
|
+
myDoc.undo();
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* @description Re-applies the last undone mutation to storage
|
|
1013
|
+
*/
|
|
1014
|
+
myDoc.redo();
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
## @pluv/client
|
|
936
1018
|
|
|
937
|
-
|
|
1019
|
+
`@pluv/client`'s `PluvRoom` and `MockedRoom` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `transact`.
|
|
938
1020
|
|
|
939
|
-
|
|
1021
|
+
Refer to the code-example below to better understand how to undo and redo with your `PluvRoom`.
|
|
940
1022
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
import { array, doc } from "@pluv/crdt-yjs";
|
|
1023
|
+
```ts
|
|
1024
|
+
import { createClient, y } from "@pluv/client";
|
|
944
1025
|
|
|
945
|
-
|
|
946
|
-
const myDoc = doc({
|
|
947
|
-
messages: array<string>([]),
|
|
948
|
-
});
|
|
1026
|
+
const client = createClient({});
|
|
949
1027
|
|
|
950
|
-
/**
|
|
951
|
-
* @description Track origins to enable undos and redos for your document.
|
|
952
|
-
* trackOrigins must be called before any storage mutations, to enable those
|
|
953
|
-
* mutations to be undone/redone.
|
|
954
|
-
*/
|
|
955
|
-
myDoc.trackOrigins({
|
|
956
1028
|
/**
|
|
957
|
-
* @description
|
|
958
|
-
*
|
|
959
|
-
*
|
|
960
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
961
|
-
* @default 500
|
|
1029
|
+
* @description When a room is created, undo/redo will automatically
|
|
1030
|
+
* be configured to filter for changes made by the connected user
|
|
1031
|
+
* (so that users only undo/redo their changes).
|
|
962
1032
|
*/
|
|
963
|
-
|
|
1033
|
+
const room = client.createRoom("my-room", {
|
|
1034
|
+
initialStorage: () => ({
|
|
1035
|
+
messages: y.array<string>([]),
|
|
1036
|
+
}),
|
|
1037
|
+
/**
|
|
1038
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1039
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
1040
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
1041
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1042
|
+
* @default 500
|
|
1043
|
+
*/
|
|
1044
|
+
captureTimeout: 500,
|
|
1045
|
+
/**
|
|
1046
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1047
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
1048
|
+
* can be undone.
|
|
1049
|
+
* When omitted, the user's connection id will be tracked. When provided,
|
|
1050
|
+
* specifies additional tracked origins besides the user's connection id.
|
|
1051
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1052
|
+
* @default undefined
|
|
1053
|
+
*/
|
|
1054
|
+
trackedOrigins: ["user-123"],
|
|
1055
|
+
});
|
|
1056
|
+
|
|
964
1057
|
/**
|
|
965
|
-
* @
|
|
966
|
-
*
|
|
967
|
-
* can be undone.
|
|
968
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
969
|
-
* @default undefined
|
|
1058
|
+
* @description Check whether calling undo will mutate storage
|
|
1059
|
+
* @returns boolean
|
|
970
1060
|
*/
|
|
971
|
-
|
|
972
|
-
});
|
|
973
|
-
|
|
974
|
-
/**
|
|
975
|
-
* @description Check whether calling undo will mutate storage
|
|
976
|
-
* @returns boolean
|
|
977
|
-
*/
|
|
978
|
-
myDoc.canUndo();
|
|
979
|
-
/**
|
|
980
|
-
* @description Check whether calling redo will mutate storage
|
|
981
|
-
* @returns boolean
|
|
982
|
-
*/
|
|
983
|
-
myDoc.canRedo();
|
|
984
|
-
|
|
985
|
-
// Perform a storage mutation within a transaction so that it can be affected
|
|
986
|
-
// by undo/redo operations.
|
|
987
|
-
myDoc.transact(() => {
|
|
988
|
-
myDoc.get("messages").push(["hello world!"]);
|
|
989
|
-
}, "user-123");
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
* @description Undoes the last valid mutation to storage
|
|
993
|
-
*/
|
|
994
|
-
myDoc.undo();
|
|
995
|
-
|
|
996
|
-
/**
|
|
997
|
-
* @description Re-applies the last undone mutation to storage
|
|
998
|
-
*/
|
|
999
|
-
myDoc.redo();
|
|
1000
|
-
```
|
|
1001
|
-
|
|
1002
|
-
## @pluv/client
|
|
1003
|
-
|
|
1004
|
-
`@pluv/client`'s `PluvRoom` and `MockedRoom` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `transact`.
|
|
1005
|
-
|
|
1006
|
-
Refer to the code-example below to better understand how to undo and redo with your `PluvRoom`.
|
|
1007
|
-
|
|
1008
|
-
```ts
|
|
1009
|
-
import { createClient, y } from "@pluv/client";
|
|
1010
|
-
|
|
1011
|
-
const client = createClient({});
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* @description When a room is created, undo/redo will automatically
|
|
1015
|
-
* be configured to filter for changes made by the connected user
|
|
1016
|
-
* (so that users only undo/redo their changes).
|
|
1017
|
-
*/
|
|
1018
|
-
const room = client.createRoom("my-room", {
|
|
1019
|
-
initialStorage: () => ({
|
|
1020
|
-
messages: y.array<string>([]),
|
|
1021
|
-
}),
|
|
1061
|
+
room.canUndo();
|
|
1022
1062
|
/**
|
|
1023
|
-
* @description
|
|
1024
|
-
*
|
|
1025
|
-
* undone together. Set this to 0, to track each transacted change individually.
|
|
1026
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1027
|
-
* @default 500
|
|
1063
|
+
* @description Check whether calling redo will mutate storage
|
|
1064
|
+
* @returns boolean
|
|
1028
1065
|
*/
|
|
1029
|
-
|
|
1066
|
+
room.canRedo();
|
|
1067
|
+
|
|
1030
1068
|
/**
|
|
1031
|
-
* @
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1037
|
-
* @default undefined
|
|
1069
|
+
* @description Calling transact will enable a storage mutation to be undone/redone.
|
|
1070
|
+
* When called without an origin, the origin will default to the user's connection
|
|
1071
|
+
* id.
|
|
1072
|
+
*
|
|
1073
|
+
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1038
1074
|
*/
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
/**
|
|
1043
|
-
* @description Check whether calling undo will mutate storage
|
|
1044
|
-
* @returns boolean
|
|
1045
|
-
*/
|
|
1046
|
-
room.canUndo();
|
|
1047
|
-
/**
|
|
1048
|
-
* @description Check whether calling redo will mutate storage
|
|
1049
|
-
* @returns boolean
|
|
1050
|
-
*/
|
|
1051
|
-
room.canRedo();
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* @description Calling transact will enable a storage mutation to be undone/redone.
|
|
1055
|
-
* When called without an origin, the origin will default to the user's connection
|
|
1056
|
-
* id.
|
|
1057
|
-
*
|
|
1058
|
-
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1059
|
-
*/
|
|
1060
|
-
room.transact(() => {
|
|
1061
|
-
room.get("messages").push(["hello world!"]);
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
// This will also be undoable because `"user-123"` is a tracked origin.
|
|
1065
|
-
room.transact(() => {
|
|
1066
|
-
room.get("messages").push(["hello world!"]);
|
|
1067
|
-
}, "user-123");
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* @description Undoes the last valid mutation to storage
|
|
1071
|
-
*/
|
|
1072
|
-
room.undo();
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* @description Re-applies the last undone mutation to storage
|
|
1076
|
-
*/
|
|
1077
|
-
room.redo();
|
|
1078
|
-
```
|
|
1079
|
-
|
|
1080
|
-
## @pluv/react
|
|
1081
|
-
|
|
1082
|
-
`@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `useCanRedo`, `useCanUndo`, `useRedo`, `useUndo` and `useTransact`.
|
|
1083
|
-
|
|
1084
|
-
Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
|
|
1085
|
-
|
|
1086
|
-
```tsx
|
|
1087
|
-
import { createBundle, createClient, y } from "@pluv/react";
|
|
1088
|
-
import { type io } from "./io";
|
|
1089
|
-
|
|
1090
|
-
const client = createClient<typeof io>();
|
|
1091
|
-
|
|
1092
|
-
const { createRoomBundle } = createBundle(client);
|
|
1093
|
-
|
|
1094
|
-
const { useCanRedo, useCanUndo, useRedo, useStorage, useTransact, useUndo } =
|
|
1095
|
-
createRoomBundle({
|
|
1096
|
-
initialStorage: () => ({
|
|
1097
|
-
messages: y.array<string>([]),
|
|
1098
|
-
}),
|
|
1099
|
-
/**
|
|
1100
|
-
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1101
|
-
* This specifies a number in ms, during which edits are merged together to be
|
|
1102
|
-
* undone together. Set this to 0, to track each transacted change individually.
|
|
1103
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1104
|
-
* @default 500
|
|
1105
|
-
*/
|
|
1106
|
-
captureTimeout: 500,
|
|
1107
|
-
/**
|
|
1108
|
-
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1109
|
-
* This specifies transaction origins (strings only) to filter which transactions
|
|
1110
|
-
* can be undone.
|
|
1111
|
-
* When omitted, the user's connection id will be tracked. When provided,
|
|
1112
|
-
* specifies additional tracked origins besides the user's connection id.
|
|
1113
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1114
|
-
* @default undefined
|
|
1115
|
-
*/
|
|
1116
|
-
trackedOrigins: ["user-123"],
|
|
1075
|
+
room.transact(() => {
|
|
1076
|
+
room.get("messages").push(["hello world!"]);
|
|
1117
1077
|
});
|
|
1118
1078
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
/**
|
|
1124
|
-
* @description Check whether calling redo will mutate storage
|
|
1125
|
-
*/
|
|
1126
|
-
const canRedo: boolean = useCanRedo();
|
|
1079
|
+
// This will also be undoable because `"user-123"` is a tracked origin.
|
|
1080
|
+
room.transact(() => {
|
|
1081
|
+
room.get("messages").push(["hello world!"]);
|
|
1082
|
+
}, "user-123");
|
|
1127
1083
|
|
|
1128
|
-
|
|
1084
|
+
/**
|
|
1085
|
+
* @description Undoes the last valid mutation to storage
|
|
1086
|
+
*/
|
|
1087
|
+
room.undo();
|
|
1129
1088
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1136
|
-
*/
|
|
1137
|
-
const transact = useTransact();
|
|
1089
|
+
/**
|
|
1090
|
+
* @description Re-applies the last undone mutation to storage
|
|
1091
|
+
*/
|
|
1092
|
+
room.redo();
|
|
1093
|
+
```
|
|
1138
1094
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1095
|
+
## @pluv/react
|
|
1096
|
+
|
|
1097
|
+
`@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `useCanRedo`, `useCanUndo`, `useRedo`, `useUndo` and `useTransact`.
|
|
1098
|
+
|
|
1099
|
+
Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
|
|
1100
|
+
|
|
1101
|
+
```tsx
|
|
1102
|
+
import { createBundle, createClient, y } from "@pluv/react";
|
|
1103
|
+
import { type io } from "./io";
|
|
1104
|
+
|
|
1105
|
+
const client = createClient<typeof io>();
|
|
1106
|
+
|
|
1107
|
+
const { createRoomBundle } = createBundle(client);
|
|
1108
|
+
|
|
1109
|
+
const { useCanRedo, useCanUndo, useRedo, useStorage, useTransact, useUndo } = createRoomBundle({
|
|
1110
|
+
initialStorage: () => ({
|
|
1111
|
+
messages: y.array<string>([]),
|
|
1112
|
+
}),
|
|
1113
|
+
/**
|
|
1114
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
1115
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
1116
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
1117
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1118
|
+
* @default 500
|
|
1119
|
+
*/
|
|
1120
|
+
captureTimeout: 500,
|
|
1121
|
+
/**
|
|
1122
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
1123
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
1124
|
+
* can be undone.
|
|
1125
|
+
* When omitted, the user's connection id will be tracked. When provided,
|
|
1126
|
+
* specifies additional tracked origins besides the user's connection id.
|
|
1127
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
1128
|
+
* @default undefined
|
|
1129
|
+
*/
|
|
1130
|
+
trackedOrigins: ["user-123"],
|
|
1131
|
+
});
|
|
1142
1132
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1133
|
+
/**
|
|
1134
|
+
* @description Check whether calling undo will mutate storage
|
|
1135
|
+
*/
|
|
1136
|
+
const canUndo: boolean = useCanUndo();
|
|
1137
|
+
/**
|
|
1138
|
+
* @description Check whether calling redo will mutate storage
|
|
1139
|
+
*/
|
|
1140
|
+
const canRedo: boolean = useCanRedo();
|
|
1147
1141
|
|
|
1148
|
-
|
|
1149
|
-
* @description Undoes the last valid mutation to storage
|
|
1150
|
-
*/
|
|
1151
|
-
const undo = useUndo();
|
|
1142
|
+
const [messages, sharedType] = useStorage("messages");
|
|
1152
1143
|
|
|
1153
|
-
|
|
1144
|
+
/**
|
|
1145
|
+
* @description Calling transact will enable a storage mutation to be undone/redone.
|
|
1146
|
+
* When called without an origin, the origin will default to the user's connection
|
|
1147
|
+
* id.
|
|
1148
|
+
*
|
|
1149
|
+
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
1150
|
+
*/
|
|
1151
|
+
const transact = useTransact();
|
|
1154
1152
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
const redo = useRedo();
|
|
1153
|
+
transact(() => {
|
|
1154
|
+
sharedType.push(["hello world!"]);
|
|
1155
|
+
});
|
|
1159
1156
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1157
|
+
// This will also be undoable because `"user-123"` is a tracked origin.
|
|
1158
|
+
transact(() => {
|
|
1159
|
+
sharedType.push(["hello world!"]);
|
|
1160
|
+
}, "user-123");
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* @description Undoes the last valid mutation to storage
|
|
1164
|
+
*/
|
|
1165
|
+
const undo = useUndo();
|
|
1166
|
+
|
|
1167
|
+
undo();
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* @description Re-applies the last undone mutation to storage
|
|
1171
|
+
*/
|
|
1172
|
+
const redo = useRedo();
|
|
1173
|
+
|
|
1174
|
+
redo();
|
|
1175
|
+
```
|
|
1162
1176
|
|
|
1163
1177
|
### Patch Changes
|
|
1164
1178
|
|
|
@@ -1169,7 +1183,7 @@
|
|
|
1169
1183
|
### Patch Changes
|
|
1170
1184
|
|
|
1171
1185
|
- 74b3061: Bumped minor and patch dependencies.
|
|
1172
|
-
|
|
1186
|
+
- @pluv/types@0.11.1
|
|
1173
1187
|
|
|
1174
1188
|
## 0.11.0
|
|
1175
1189
|
|
|
@@ -1195,7 +1209,7 @@
|
|
|
1195
1209
|
|
|
1196
1210
|
- 885835d: remove unnecessary dependency
|
|
1197
1211
|
- Updated dependencies [885835d]
|
|
1198
|
-
|
|
1212
|
+
- @pluv/types@0.10.1
|
|
1199
1213
|
|
|
1200
1214
|
## 0.10.0
|
|
1201
1215
|
|
|
@@ -1206,7 +1220,7 @@
|
|
|
1206
1220
|
### Patch Changes
|
|
1207
1221
|
|
|
1208
1222
|
- Updated dependencies [f43f1cc]
|
|
1209
|
-
|
|
1223
|
+
- @pluv/types@0.10.0
|
|
1210
1224
|
|
|
1211
1225
|
## 0.4.2
|
|
1212
1226
|
|
|
@@ -1214,18 +1228,18 @@
|
|
|
1214
1228
|
|
|
1215
1229
|
- f4317ba: \* Renamed type `unstable_YObjectValue` to `YObjectValue`;
|
|
1216
1230
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1231
|
+
- Renamed type `unstable_YObject` to `YObject`.
|
|
1232
|
+
- Re-exported `xmlElement`, `xmlFragment` and `xmlText` from `@pluv/client`.
|
|
1219
1233
|
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1234
|
+
```ts
|
|
1235
|
+
import { y } from "@pluv/client";
|
|
1236
|
+
// or
|
|
1237
|
+
import { y } from "@pluv/react";
|
|
1224
1238
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1239
|
+
y.xmlElement("MyElement", {});
|
|
1240
|
+
y.xmlFragment({});
|
|
1241
|
+
y.xmlText("hello world");
|
|
1242
|
+
```
|
|
1229
1243
|
|
|
1230
1244
|
## 0.4.1
|
|
1231
1245
|
|
|
@@ -1235,7 +1249,7 @@
|
|
|
1235
1249
|
- 8997c65: bumped dependencies
|
|
1236
1250
|
- Updated dependencies [8fba48b]
|
|
1237
1251
|
- Updated dependencies [8997c65]
|
|
1238
|
-
|
|
1252
|
+
- @pluv/types@0.2.2
|
|
1239
1253
|
|
|
1240
1254
|
## 0.4.0
|
|
1241
1255
|
|
|
@@ -1243,54 +1257,54 @@
|
|
|
1243
1257
|
|
|
1244
1258
|
- 829d31b: Added support for defining persistant frontend storage for rooms via a new `addons` option on rooms.
|
|
1245
1259
|
|
|
1246
|
-
|
|
1260
|
+
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:
|
|
1247
1261
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1262
|
+
```
|
|
1263
|
+
npm install @pluv/addon-indexeddb
|
|
1264
|
+
```
|
|
1251
1265
|
|
|
1252
|
-
|
|
1266
|
+
To use this new addon, simply pass it to options when creating a room:
|
|
1253
1267
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1268
|
+
```ts
|
|
1269
|
+
import { addonIndexedDB } from "@pluv/addon-indexeddb";
|
|
1270
|
+
import { createClient } from "@pluv/client";
|
|
1257
1271
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1272
|
+
const client = createClient({
|
|
1273
|
+
// ...
|
|
1274
|
+
});
|
|
1261
1275
|
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1276
|
+
const room = client.createRoom("my-new-room", {
|
|
1277
|
+
addons: [
|
|
1278
|
+
// Define your addons in an array like so
|
|
1279
|
+
addonIndexedDB(),
|
|
1280
|
+
],
|
|
1281
|
+
});
|
|
1282
|
+
```
|
|
1269
1283
|
|
|
1270
|
-
|
|
1284
|
+
Or when using `@pluv/react`:
|
|
1271
1285
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1286
|
+
```ts
|
|
1287
|
+
const PluvRoom = createRoomBundle({
|
|
1288
|
+
// ...
|
|
1289
|
+
addons: [
|
|
1290
|
+
// Define your addons in an array like so
|
|
1291
|
+
addonIndexedDB(),
|
|
1292
|
+
],
|
|
1293
|
+
});
|
|
1294
|
+
```
|
|
1281
1295
|
|
|
1282
1296
|
### Patch Changes
|
|
1283
1297
|
|
|
1284
1298
|
- 8d11672: bumped dependencies to latest
|
|
1285
1299
|
- Updated dependencies [8d11672]
|
|
1286
|
-
|
|
1300
|
+
- @pluv/types@0.2.1
|
|
1287
1301
|
|
|
1288
1302
|
## 0.3.8
|
|
1289
1303
|
|
|
1290
1304
|
### Patch Changes
|
|
1291
1305
|
|
|
1292
1306
|
- b85a232: bumped dependencies
|
|
1293
|
-
|
|
1307
|
+
- @pluv/types@0.2.0
|
|
1294
1308
|
|
|
1295
1309
|
## 0.3.7
|
|
1296
1310
|
|
|
@@ -1301,7 +1315,7 @@
|
|
|
1301
1315
|
- Updated dependencies [0dd847e]
|
|
1302
1316
|
- Updated dependencies [bb2886b]
|
|
1303
1317
|
- Updated dependencies [ae679a8]
|
|
1304
|
-
|
|
1318
|
+
- @pluv/types@0.2.0
|
|
1305
1319
|
|
|
1306
1320
|
## 0.3.6
|
|
1307
1321
|
|
|
@@ -1315,7 +1329,7 @@
|
|
|
1315
1329
|
|
|
1316
1330
|
- 850626e: bumped dependencies
|
|
1317
1331
|
- Updated dependencies [850626e]
|
|
1318
|
-
|
|
1332
|
+
- @pluv/types@0.1.6
|
|
1319
1333
|
|
|
1320
1334
|
## 0.3.4
|
|
1321
1335
|
|
|
@@ -1329,7 +1343,7 @@
|
|
|
1329
1343
|
|
|
1330
1344
|
- 74870ee: bumped dependencies
|
|
1331
1345
|
- Updated dependencies [74870ee]
|
|
1332
|
-
|
|
1346
|
+
- @pluv/types@0.1.5
|
|
1333
1347
|
|
|
1334
1348
|
## 0.3.2
|
|
1335
1349
|
|
|
@@ -1342,7 +1356,7 @@
|
|
|
1342
1356
|
- Updated dependencies [9516a4e]
|
|
1343
1357
|
- Updated dependencies [7b6da1c]
|
|
1344
1358
|
- Updated dependencies [e9c1514]
|
|
1345
|
-
|
|
1359
|
+
- @pluv/types@0.1.4
|
|
1346
1360
|
|
|
1347
1361
|
## 0.3.1
|
|
1348
1362
|
|
|
@@ -1350,7 +1364,7 @@
|
|
|
1350
1364
|
|
|
1351
1365
|
- 161e00e: fixed links to other pluv packages in readmes
|
|
1352
1366
|
- f6c0e65: bumped dependencies
|
|
1353
|
-
|
|
1367
|
+
- @pluv/types@0.1.3
|
|
1354
1368
|
|
|
1355
1369
|
## 0.3.0
|
|
1356
1370
|
|
|
@@ -1367,7 +1381,7 @@
|
|
|
1367
1381
|
- Updated dependencies [8bf62cb]
|
|
1368
1382
|
- Updated dependencies [7e52685]
|
|
1369
1383
|
- Updated dependencies [8e97fb2]
|
|
1370
|
-
|
|
1384
|
+
- @pluv/types@0.1.3
|
|
1371
1385
|
|
|
1372
1386
|
## 0.2.0
|
|
1373
1387
|
|
|
@@ -1385,7 +1399,7 @@
|
|
|
1385
1399
|
|
|
1386
1400
|
- fe80d7b: added preview disclaimer about breaking changes in the readme
|
|
1387
1401
|
- Updated dependencies [fe80d7b]
|
|
1388
|
-
|
|
1402
|
+
- @pluv/types@0.1.2
|
|
1389
1403
|
|
|
1390
1404
|
## 0.1.2
|
|
1391
1405
|
|
|
@@ -1399,7 +1413,7 @@
|
|
|
1399
1413
|
|
|
1400
1414
|
- 24016e6: Updated dependencies
|
|
1401
1415
|
- Updated dependencies [24016e6]
|
|
1402
|
-
|
|
1416
|
+
- @pluv/types@0.1.1
|
|
1403
1417
|
|
|
1404
1418
|
## 0.1.0
|
|
1405
1419
|
|
|
@@ -1410,4 +1424,4 @@
|
|
|
1410
1424
|
### Patch Changes
|
|
1411
1425
|
|
|
1412
1426
|
- Updated dependencies [a22f525]
|
|
1413
|
-
|
|
1427
|
+
- @pluv/types@0.1.0
|
package/dist/index.d.mts
CHANGED
|
@@ -30,7 +30,7 @@ type AwarenessPresence<TPresence extends Record<string, any>, TField extends key
|
|
|
30
30
|
declare const array: <T extends unknown>(value?: T[] | readonly T[]) => YjsType<Array<T>, T[]>;
|
|
31
31
|
|
|
32
32
|
interface PluvYjsAwarenessParams<TIO extends IOLike<any>, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType$1<any, any>>, TEvents extends PluvRouterEventConfig, TField extends keyof TPresence | null = null> {
|
|
33
|
-
|
|
33
|
+
presenceField?: TField;
|
|
34
34
|
room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
|
|
35
35
|
}
|
|
36
36
|
declare class PluvYjsAwareness<TIO extends IOLike, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType$1<any, any>>, TEvents extends PluvRouterEventConfig, TField extends keyof TPresence | null = null> extends ObservableV2<{
|
|
@@ -130,7 +130,7 @@ declare const map: <T extends unknown>(value?: readonly (readonly [key: string,
|
|
|
130
130
|
declare const object: <T extends Record<string, any>>(value?: T) => YjsType<Map$1<T[keyof T]>, T>;
|
|
131
131
|
|
|
132
132
|
interface PluvYjsProviderParams<TIO extends IOLike<any>, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType$1<any, any>>, TEvents extends PluvRouterEventConfig, TField extends keyof TPresence | null = null> {
|
|
133
|
-
|
|
133
|
+
presenceField?: TField;
|
|
134
134
|
room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
|
|
135
135
|
}
|
|
136
136
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ type AwarenessPresence<TPresence extends Record<string, any>, TField extends key
|
|
|
30
30
|
declare const array: <T extends unknown>(value?: T[] | readonly T[]) => YjsType<Array<T>, T[]>;
|
|
31
31
|
|
|
32
32
|
interface PluvYjsAwarenessParams<TIO extends IOLike<any>, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType$1<any, any>>, TEvents extends PluvRouterEventConfig, TField extends keyof TPresence | null = null> {
|
|
33
|
-
|
|
33
|
+
presenceField?: TField;
|
|
34
34
|
room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
|
|
35
35
|
}
|
|
36
36
|
declare class PluvYjsAwareness<TIO extends IOLike, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType$1<any, any>>, TEvents extends PluvRouterEventConfig, TField extends keyof TPresence | null = null> extends ObservableV2<{
|
|
@@ -130,7 +130,7 @@ declare const map: <T extends unknown>(value?: readonly (readonly [key: string,
|
|
|
130
130
|
declare const object: <T extends Record<string, any>>(value?: T) => YjsType<Map$1<T[keyof T]>, T>;
|
|
131
131
|
|
|
132
132
|
interface PluvYjsProviderParams<TIO extends IOLike<any>, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType$1<any, any>>, TEvents extends PluvRouterEventConfig, TField extends keyof TPresence | null = null> {
|
|
133
|
-
|
|
133
|
+
presenceField?: TField;
|
|
134
134
|
room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
|
|
135
135
|
}
|
|
136
136
|
/**
|
package/dist/index.js
CHANGED
|
@@ -97,10 +97,10 @@ var PluvYjsAwareness = class extends import_observable.ObservableV2 {
|
|
|
97
97
|
*/
|
|
98
98
|
this.meta = /* @__PURE__ */ new Map();
|
|
99
99
|
this._checkInterval = 0;
|
|
100
|
-
const {
|
|
100
|
+
const { presenceField, room } = params;
|
|
101
101
|
this.doc = room.getDoc().value;
|
|
102
102
|
this._room = room;
|
|
103
|
-
if (!!
|
|
103
|
+
if (!!presenceField) this._field = presenceField;
|
|
104
104
|
const myPresence = this._room.getMyPresence();
|
|
105
105
|
const myMeta = (myPresence == null ? void 0 : myPresence[PLUV_PRESENCE_META_KEY]) || {};
|
|
106
106
|
this._room.updateMyPresence({
|
|
@@ -609,8 +609,8 @@ var PluvYjsProvider = class extends import_observable2.ObservableV2 {
|
|
|
609
609
|
constructor(params) {
|
|
610
610
|
super();
|
|
611
611
|
this._synced = false;
|
|
612
|
-
const {
|
|
613
|
-
this.awareness = awareness({
|
|
612
|
+
const { presenceField, room } = params;
|
|
613
|
+
this.awareness = awareness({ presenceField, room });
|
|
614
614
|
this.doc = room.getDoc().value;
|
|
615
615
|
this._room = room;
|
|
616
616
|
const subscriptions = [
|
package/dist/index.mjs
CHANGED
|
@@ -78,10 +78,10 @@ var PluvYjsAwareness = class extends ObservableV2 {
|
|
|
78
78
|
*/
|
|
79
79
|
this.meta = /* @__PURE__ */ new Map();
|
|
80
80
|
this._checkInterval = 0;
|
|
81
|
-
const {
|
|
81
|
+
const { presenceField, room } = params;
|
|
82
82
|
this.doc = room.getDoc().value;
|
|
83
83
|
this._room = room;
|
|
84
|
-
if (!!
|
|
84
|
+
if (!!presenceField) this._field = presenceField;
|
|
85
85
|
const myPresence = this._room.getMyPresence();
|
|
86
86
|
const myMeta = (myPresence == null ? void 0 : myPresence[PLUV_PRESENCE_META_KEY]) || {};
|
|
87
87
|
this._room.updateMyPresence({
|
|
@@ -604,8 +604,8 @@ var PluvYjsProvider = class extends ObservableV22 {
|
|
|
604
604
|
constructor(params) {
|
|
605
605
|
super();
|
|
606
606
|
this._synced = false;
|
|
607
|
-
const {
|
|
608
|
-
this.awareness = awareness({
|
|
607
|
+
const { presenceField, room } = params;
|
|
608
|
+
this.awareness = awareness({ presenceField, room });
|
|
609
609
|
this.doc = room.getDoc().value;
|
|
610
610
|
this._room = room;
|
|
611
611
|
const subscriptions = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-yjs",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "yjs for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"@types/node": "^22.15.18",
|
|
21
21
|
"js-base64": "^3.7.7",
|
|
22
22
|
"lib0": "^0.2.108",
|
|
23
|
-
"@pluv/crdt": "^2.2.
|
|
24
|
-
"@pluv/types": "^2.2.
|
|
23
|
+
"@pluv/crdt": "^2.2.2",
|
|
24
|
+
"@pluv/types": "^2.2.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"yjs": "^13.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"eslint": "^9.
|
|
31
|
-
"tsup": "^8.
|
|
30
|
+
"eslint": "^9.27.0",
|
|
31
|
+
"tsup": "^8.5.0",
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
33
|
"yjs": "^13.6.27",
|
|
34
|
-
"@pluv/tsconfig": "^2.2.
|
|
35
|
-
"eslint-config-pluv": "^2.2.
|
|
34
|
+
"@pluv/tsconfig": "^2.2.2",
|
|
35
|
+
"eslint-config-pluv": "^2.2.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
@@ -18,7 +18,7 @@ export interface PluvYjsAwarenessParams<
|
|
|
18
18
|
TEvents extends PluvRouterEventConfig,
|
|
19
19
|
TField extends keyof TPresence | null = null,
|
|
20
20
|
> {
|
|
21
|
-
|
|
21
|
+
presenceField?: TField;
|
|
22
22
|
room: RoomLike<TIO, YDoc, TPresence, TStorage, TEvents>;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -51,12 +51,12 @@ export class PluvYjsAwareness<
|
|
|
51
51
|
constructor(params: PluvYjsAwarenessParams<TIO, TPresence, TStorage, TEvents, TField>) {
|
|
52
52
|
super();
|
|
53
53
|
|
|
54
|
-
const {
|
|
54
|
+
const { presenceField, room } = params;
|
|
55
55
|
|
|
56
56
|
this.doc = room.getDoc().value;
|
|
57
57
|
this._room = room;
|
|
58
58
|
|
|
59
|
-
if (!!
|
|
59
|
+
if (!!presenceField) this._field = presenceField;
|
|
60
60
|
|
|
61
61
|
const myPresence: any = this._room.getMyPresence();
|
|
62
62
|
const myMeta = myPresence?.[PLUV_PRESENCE_META_KEY] || {};
|
|
@@ -13,7 +13,7 @@ export interface PluvYjsProviderParams<
|
|
|
13
13
|
TEvents extends PluvRouterEventConfig,
|
|
14
14
|
TField extends keyof TPresence | null = null,
|
|
15
15
|
> {
|
|
16
|
-
|
|
16
|
+
presenceField?: TField;
|
|
17
17
|
room: RoomLike<TIO, YDoc, TPresence, TStorage, TEvents>;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -53,9 +53,9 @@ export class PluvYjsProvider<
|
|
|
53
53
|
constructor(params: PluvYjsProviderParams<TIO, TPresence, TStorage, TEvents, TField>) {
|
|
54
54
|
super();
|
|
55
55
|
|
|
56
|
-
const {
|
|
56
|
+
const { presenceField, room } = params;
|
|
57
57
|
|
|
58
|
-
this.awareness = awareness({
|
|
58
|
+
this.awareness = awareness({ presenceField, room });
|
|
59
59
|
this.doc = room.getDoc().value;
|
|
60
60
|
|
|
61
61
|
this._room = room;
|