@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.
@@ -1,18 +1,18 @@
1
1
 
2
- > @pluv/crdt-yjs@2.2.0 build /home/runner/work/pluv/pluv/packages/crdt-yjs
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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.4.0
7
+ CLI tsup v8.5.0
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 22.21 KB
12
- ESM ⚡️ Build success in 109ms
13
- CJS dist/index.js 23.15 KB
14
- CJS ⚡️ Build success in 122ms
11
+ CJS dist/index.js 23.19 KB
12
+ CJS ⚡️ Build success in 123ms
13
+ ESM dist/index.mjs 22.25 KB
14
+ ESM ⚡️ Build success in 124ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 4999ms
17
- DTS dist/index.d.mts 10.93 KB
18
- DTS dist/index.d.ts 10.93 KB
16
+ DTS ⚡️ Build success in 4915ms
17
+ DTS dist/index.d.mts 10.95 KB
18
+ DTS dist/index.d.ts 10.95 KB
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
- ```ts
10
- import { createClient } from "@pluv/client";
11
- import { yjs } from "@pluv/crdt-yjs";
24
+ ```ts
25
+ import { createClient } from "@pluv/client";
26
+ import { yjs } from "@pluv/crdt-yjs";
12
27
 
13
- const client = createClient({
14
- /* ... */
15
- });
16
- const room = client.createRoom("example-room");
28
+ const client = createClient({
29
+ /* ... */
30
+ });
31
+ const room = client.createRoom("example-room");
17
32
 
18
- // Yjs Provider
19
- yjs.provider({ room });
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
- ```ts
25
- createClient({
26
- presence: z.object({
27
- topField: z.number(),
28
- forAwareness: z.object({
29
- nestedField: z.number(),
30
- }),
31
- }),
32
- });
33
-
34
- yjs.provider({
35
- // ...
36
- // Optional field to use a nested field, instead of the presence root
37
- field: "forAwareness",
38
- });
39
-
40
- yjs.awareness({
41
- // ...
42
- // Optional field to use a nested field, instead of the presence root
43
- field: "forAwareness",
44
- });
45
- ```
46
-
47
- This allows better integrations with [lexical](https://lexical.dev), since they have their own presence types.
48
-
49
- ```tsx
50
- createClient({
51
- presence: z.object({
52
- topField: z.number(),
53
- lexical: z.any(),
54
- }),
55
- });
56
-
57
- yjs.provider({ field: "lexical" /* ... */ });
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
- ```ts
63
- import { createClient } from "@pluv/client";
64
- import { yjs } from "@pluv/crdt-yjs";
77
+ ```ts
78
+ import { createClient } from "@pluv/client";
79
+ import { yjs } from "@pluv/crdt-yjs";
65
80
 
66
- const client = createClient({
67
- /* ... */
68
- });
69
- const room = client.createRoom("example-room");
81
+ const client = createClient({
82
+ /* ... */
83
+ });
84
+ const room = client.createRoom("example-room");
70
85
 
71
- // Yjs Awareness
72
- yjs.awareness({ room /* ... */ });
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
- 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.
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
- - @pluv/crdt@2.0.2
96
- - @pluv/types@2.0.2
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
- ```ts
112
- import { yjs } from "@pluv/crdt-yjs";
113
-
114
- // Before
115
- yjs.doc(() => ({
116
- // Using the `yjs` utility (in this case `yjs.map`) when declaring
117
- // top-level types is now deprecated
118
- topType: yjs.map([
119
- ["key1", yjs.text("")],
120
- ["key2", yjs.text("")],
121
- ]),
122
- }));
123
-
124
- // After
125
- yjs.doc((t) => ({
126
- // Top-level properties must now use the builder (in this case `t`).
127
- // This effectively calls `yjs.getMap("topType")` to instantiate the type on
128
- // the root document.
129
- // This simply returns the native Yjs shared-types (e.g. Y.Map), which
130
- // allows you operate on your yjs shared-typess in a more native way.
131
- topType: t.map("topType", [
132
- // Declaring nested types should continue to use the `yjs` utilities
133
- // you've used before
134
- ["key1", yjs.text("")],
135
- ["key2", yjs.text("")],
136
- ]),
137
- }));
138
- ```
139
-
140
- 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.
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
- - @pluv/types@2.0.0
147
- - @pluv/crdt@2.0.0
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
- 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.
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
- Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
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
- - @pluv/crdt@1.0.0
177
- - @pluv/types@1.0.0
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
- - @pluv/crdt@0.44.0
199
- - @pluv/types@0.44.0
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
- - @pluv/types@0.38.0
410
- - @pluv/crdt@0.38.0
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
- - @pluv/types@0.35.2
495
- - @pluv/crdt@0.35.2
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
- - @pluv/crdt@0.35.1
503
- - @pluv/types@0.35.1
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
- - @pluv/crdt@0.30.0
630
- - @pluv/types@0.30.0
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
- 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.
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
- 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.
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
- ```ts
748
- // Before
762
+ ```ts
763
+ // Before
749
764
 
750
- import { yjs } from "@pluv/crdt-yjs";
765
+ import { yjs } from "@pluv/crdt-yjs";
751
766
 
752
- yjs.array([]); // Returns CrdtYjsArray
753
- yjs.object([]); // Returns CrdtYjsObject
767
+ yjs.array([]); // Returns CrdtYjsArray
768
+ yjs.object([]); // Returns CrdtYjsObject
754
769
 
755
- const room: PluvRoom = /* ... */;
770
+ const room: PluvRoom = /* ... */;
756
771
 
757
- room.getStorage("messages"); // Returns AbstractCrdtType
772
+ room.getStorage("messages"); // Returns AbstractCrdtType
758
773
 
759
- const [, sharedType] = useStorage("messages"); // sharedType is an AbstractCrdtType
760
- ```
774
+ const [, sharedType] = useStorage("messages"); // sharedType is an AbstractCrdtType
775
+ ```
761
776
 
762
- ```ts
763
- // Now
777
+ ```ts
778
+ // Now
764
779
 
765
- import { yjs } from "@pluv/crdt-yjs";
780
+ import { yjs } from "@pluv/crdt-yjs";
766
781
 
767
- yjs.array([]); // Returns yjs.Array
768
- yjs.object([]); // Returns yjs.Map
782
+ yjs.array([]); // Returns yjs.Array
783
+ yjs.object([]); // Returns yjs.Map
769
784
 
770
- const room: PluvRoom = /* ... */;
785
+ const room: PluvRoom = /* ... */;
771
786
 
772
- room.getStorage("messages"); // Returns yjs.AbstractType
787
+ room.getStorage("messages"); // Returns yjs.AbstractType
773
788
 
774
- const [, sharedType] = useStorage("messages"); // sharedType is a yjs.AbstractType
775
- ```
789
+ const [, sharedType] = useStorage("messages"); // sharedType is a yjs.AbstractType
790
+ ```
776
791
 
777
- 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:
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
- ```ts
780
- // Before
794
+ ```ts
795
+ // Before
781
796
 
782
- const [data, container] = useStorage("messages");
797
+ const [data, container] = useStorage("messages");
783
798
 
784
- // This automatically called Loro.commit under the hood and rerendered the page with updated data.
785
- container.push(loro.object({ name: "John Doe", age: 35 }));
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
- ```ts
789
- // Now
803
+ ```ts
804
+ // Now
790
805
 
791
- const [data, container] = useStorage("messages");
806
+ const [data, container] = useStorage("messages");
792
807
 
793
- const doc = useDoc();
794
- const transact = useTransact();
808
+ const doc = useDoc();
809
+ const transact = useTransact();
795
810
 
796
- // Updates need to be committed back to the doc whenever the changes need to be emitted to other users
797
- // The returned data also will not update until the changes are commited
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
- // The two operations below are functionally equivalent
800
- transact(() => {
801
- container.push(loro.object({ name: "John Doe", age: 35 }));
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
- container.push(loro.object({ name: "John Doe", age: 35 }));
805
- doc.value.commit();
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
- - @pluv/crdt@0.20.0
812
- - @pluv/types@0.20.0
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
- - @pluv/types@0.18.0
827
- - @pluv/crdt@0.18.0
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
- - @pluv/types@0.17.0
856
- - @pluv/crdt@0.17.0
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
- - @pluv/types@0.12.3
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
- ## @pluv/crdt-yjs
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
- `@pluv/crdt-yjs` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `trackOrigins`.
1019
+ `@pluv/client`'s `PluvRoom` and `MockedRoom` now exposes 5 new methods: `canRedo`, `canUndo`, `redo`, `undo` and `transact`.
938
1020
 
939
- Refer to the code-example below to better understand how to undo and redo with your doc.
1021
+ Refer to the code-example below to better understand how to undo and redo with your `PluvRoom`.
940
1022
 
941
- ```ts
942
- // Example
943
- import { array, doc } from "@pluv/crdt-yjs";
1023
+ ```ts
1024
+ import { createClient, y } from "@pluv/client";
944
1025
 
945
- // Create your doc with your shared-types
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 This is the same `captureTimeout` option from yjs's UndoManager.
958
- * This specifies a number in ms, during which edits are merged together to be
959
- * undone together. Set this to 0, to track each transacted change individually.
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
- captureTimeout: 500,
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
- * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
966
- * This specifies transaction origins (strings only) to filter which transactions
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
- trackedOrigins: ["user-123"],
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 This is the same `captureTimeout` option from yjs's UndoManager.
1024
- * This specifies a number in ms, during which edits are merged together to be
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
- captureTimeout: 500,
1066
+ room.canRedo();
1067
+
1030
1068
  /**
1031
- * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
1032
- * This specifies transaction origins (strings only) to filter which transactions
1033
- * can be undone.
1034
- * When omitted, the user's connection id will be tracked. When provided,
1035
- * specifies additional tracked origins besides the user's connection id.
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
- trackedOrigins: ["user-123"],
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
- * @description Check whether calling undo will mutate storage
1121
- */
1122
- const canUndo: boolean = useCanUndo();
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
- const [messages, sharedType] = useStorage("messages");
1084
+ /**
1085
+ * @description Undoes the last valid mutation to storage
1086
+ */
1087
+ room.undo();
1129
1088
 
1130
- /**
1131
- * @description Calling transact will enable a storage mutation to be undone/redone.
1132
- * When called without an origin, the origin will default to the user's connection
1133
- * id.
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
- transact(() => {
1140
- sharedType.push(["hello world!"]);
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
- // This will also be undoable because `"user-123"` is a tracked origin.
1144
- transact(() => {
1145
- sharedType.push(["hello world!"]);
1146
- }, "user-123");
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
- undo();
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
- * @description Re-applies the last undone mutation to storage
1157
- */
1158
- const redo = useRedo();
1153
+ transact(() => {
1154
+ sharedType.push(["hello world!"]);
1155
+ });
1159
1156
 
1160
- redo();
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
- - @pluv/types@0.11.1
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
- - @pluv/types@0.10.1
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
- - @pluv/types@0.10.0
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
- - Renamed type `unstable_YObject` to `YObject`.
1218
- - Re-exported `xmlElement`, `xmlFragment` and `xmlText` from `@pluv/client`.
1231
+ - Renamed type `unstable_YObject` to `YObject`.
1232
+ - Re-exported `xmlElement`, `xmlFragment` and `xmlText` from `@pluv/client`.
1219
1233
 
1220
- ```ts
1221
- import { y } from "@pluv/client";
1222
- // or
1223
- import { y } from "@pluv/react";
1234
+ ```ts
1235
+ import { y } from "@pluv/client";
1236
+ // or
1237
+ import { y } from "@pluv/react";
1224
1238
 
1225
- y.xmlElement("MyElement", {});
1226
- y.xmlFragment({});
1227
- y.xmlText("hello world");
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
- - @pluv/types@0.2.2
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
- 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:
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
- npm install @pluv/addon-indexeddb
1250
- ```
1262
+ ```
1263
+ npm install @pluv/addon-indexeddb
1264
+ ```
1251
1265
 
1252
- To use this new addon, simply pass it to options when creating a room:
1266
+ To use this new addon, simply pass it to options when creating a room:
1253
1267
 
1254
- ```ts
1255
- import { addonIndexedDB } from "@pluv/addon-indexeddb";
1256
- import { createClient } from "@pluv/client";
1268
+ ```ts
1269
+ import { addonIndexedDB } from "@pluv/addon-indexeddb";
1270
+ import { createClient } from "@pluv/client";
1257
1271
 
1258
- const client = createClient({
1259
- // ...
1260
- });
1272
+ const client = createClient({
1273
+ // ...
1274
+ });
1261
1275
 
1262
- const room = client.createRoom("my-new-room", {
1263
- addons: [
1264
- // Define your addons in an array like so
1265
- addonIndexedDB(),
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
- Or when using `@pluv/react`:
1284
+ Or when using `@pluv/react`:
1271
1285
 
1272
- ```ts
1273
- const PluvRoom = createRoomBundle({
1274
- // ...
1275
- addons: [
1276
- // Define your addons in an array like so
1277
- addonIndexedDB(),
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
- - @pluv/types@0.2.1
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
- - @pluv/types@0.2.0
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
- - @pluv/types@0.2.0
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
- - @pluv/types@0.1.6
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
- - @pluv/types@0.1.5
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
- - @pluv/types@0.1.4
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
- - @pluv/types@0.1.3
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
- - @pluv/types@0.1.3
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
- - @pluv/types@0.1.2
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
- - @pluv/types@0.1.1
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
- - @pluv/types@0.1.0
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
- field?: TField;
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
- field?: TField;
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
- field?: TField;
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
- field?: TField;
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 { field, room } = params;
100
+ const { presenceField, room } = params;
101
101
  this.doc = room.getDoc().value;
102
102
  this._room = room;
103
- if (!!field) this._field = field;
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 { field, room } = params;
613
- this.awareness = awareness({ field, room });
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 { field, room } = params;
81
+ const { presenceField, room } = params;
82
82
  this.doc = room.getDoc().value;
83
83
  this._room = room;
84
- if (!!field) this._field = field;
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 { field, room } = params;
608
- this.awareness = awareness({ field, room });
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.0",
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.0",
24
- "@pluv/types": "^2.2.0"
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.26.0",
31
- "tsup": "^8.4.0",
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.0",
35
- "eslint-config-pluv": "^2.2.0"
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
- field?: TField;
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 { field, room } = params;
54
+ const { presenceField, room } = params;
55
55
 
56
56
  this.doc = room.getDoc().value;
57
57
  this._room = room;
58
58
 
59
- if (!!field) this._field = field;
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
- field?: TField;
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 { field, room } = params;
56
+ const { presenceField, room } = params;
57
57
 
58
- this.awareness = awareness({ field, room });
58
+ this.awareness = awareness({ presenceField, room });
59
59
  this.doc = room.getDoc().value;
60
60
 
61
61
  this._room = room;