@pluv/crdt-yjs 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/crdt-yjs@2.1.0 build /home/runner/work/pluv/pluv/packages/crdt-yjs
2
+ > @pluv/crdt-yjs@2.2.1 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
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 15.47 KB
12
- ESM ⚡️ Build success in 86ms
13
- CJS dist/index.js 16.33 KB
14
- CJS ⚡️ Build success in 88ms
11
+ CJS dist/index.js 23.15 KB
12
+ CJS ⚡️ Build success in 110ms
13
+ ESM dist/index.mjs 22.21 KB
14
+ ESM ⚡️ Build success in 110ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 4437ms
17
- DTS dist/index.d.mts 5.14 KB
18
- DTS dist/index.d.ts 5.14 KB
16
+ DTS ⚡️ Build success in 4831ms
17
+ DTS dist/index.d.mts 10.93 KB
18
+ DTS dist/index.d.ts 10.93 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # @pluv/crdt-yjs
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@2.2.1
8
+ - @pluv/types@2.2.1
9
+
10
+ ## 2.2.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 745f6df: Added a `provider` function that satisfies Yjs's provider interface.
15
+
16
+ ```ts
17
+ import { createClient } from "@pluv/client";
18
+ import { yjs } from "@pluv/crdt-yjs";
19
+
20
+ const client = createClient({
21
+ /* ... */
22
+ });
23
+ const room = client.createRoom("example-room");
24
+
25
+ // Yjs Provider
26
+ yjs.provider({ room });
27
+ ```
28
+
29
+ - df4ceed: Update `yjs.awareness` and `yjs.provider` to allow for a `field` parameter to use awareness on a nested presence field.
30
+
31
+ ```ts
32
+ createClient({
33
+ presence: z.object({
34
+ topField: z.number(),
35
+ forAwareness: z.object({
36
+ nestedField: z.number(),
37
+ }),
38
+ }),
39
+ });
40
+
41
+ yjs.provider({
42
+ // ...
43
+ // Optional field to use a nested field, instead of the presence root
44
+ field: "forAwareness",
45
+ });
46
+
47
+ yjs.awareness({
48
+ // ...
49
+ // Optional field to use a nested field, instead of the presence root
50
+ field: "forAwareness",
51
+ });
52
+ ```
53
+
54
+ This allows better integrations with [lexical](https://lexical.dev), since they have their own presence types.
55
+
56
+ ```tsx
57
+ createClient({
58
+ presence: z.object({
59
+ topField: z.number(),
60
+ lexical: z.any(),
61
+ }),
62
+ });
63
+
64
+ yjs.provider({ field: "lexical" /* ... */ });
65
+ ```
66
+
67
+ - 6323979: Added an `awareness` function that satisfies Yjs's [awareness interface](https://github.com/yjs/y-protocols/blob/master/awareness.js).
68
+
69
+ ```ts
70
+ import { createClient } from "@pluv/client";
71
+ import { yjs } from "@pluv/crdt-yjs";
72
+
73
+ const client = createClient({
74
+ /* ... */
75
+ });
76
+ const room = client.createRoom("example-room");
77
+
78
+ // Yjs Awareness
79
+ yjs.awareness({ room /* ... */ });
80
+ ```
81
+
82
+ ### Patch Changes
83
+
84
+ - @pluv/crdt@2.2.0
85
+ - @pluv/types@2.2.0
86
+
3
87
  ## 2.1.0
4
88
 
5
89
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,18 +1,83 @@
1
- import { Array, Doc, Map, Text, XmlElement, XmlText, XmlFragment } from 'yjs';
1
+ import { Array, Doc, Map as Map$1, Text, XmlElement, XmlText, XmlFragment } from 'yjs';
2
2
  import { CrdtType, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
3
- import { CrdtDocLike } from '@pluv/types';
3
+ import { IOLike, CrdtType as CrdtType$1, PluvRouterEventConfig, RoomLike, CrdtDocLike } from '@pluv/types';
4
+ import { ObservableV2 } from 'lib0/observable';
4
5
 
5
6
  type YjsType<TValue extends unknown, TJson extends unknown = any> = CrdtType<TValue, TJson> & {
6
7
  initialValue?: any;
7
8
  toJSON: () => any;
8
9
  };
10
+ /**
11
+ * @description Type internally defined by Yjs.Awareness
12
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
13
+ */
14
+ interface YjsAwarenessUpdate {
15
+ added: number[];
16
+ updated: number[];
17
+ removed: number[];
18
+ }
19
+ type YjsProviderStatus = "connecting" | "connected" | "disconnected";
20
+ /**
21
+ * @description Type internally defined by Yjs.Awareness
22
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
23
+ */
24
+ interface MetaClientState {
25
+ clock: number;
26
+ lastUpdated: number;
27
+ }
28
+ type AwarenessPresence<TPresence extends Record<string, any>, TField extends keyof TPresence | null> = TField extends null ? TPresence : TField extends keyof TPresence ? TPresence[TField] : never;
9
29
 
10
30
  declare const array: <T extends unknown>(value?: T[] | readonly T[]) => YjsType<Array<T>, T[]>;
11
31
 
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;
34
+ room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
35
+ }
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<{
37
+ change: (updates: YjsAwarenessUpdate, kind: "presence") => void;
38
+ destroy: (awareness: PluvYjsAwareness<TIO, TPresence, TStorage, TEvents, TField>) => void;
39
+ update: (updates: YjsAwarenessUpdate, kind: "local" | "presence") => void;
40
+ }> {
41
+ readonly doc: Doc;
42
+ private readonly _field;
43
+ private readonly _idMap;
44
+ private readonly _room;
45
+ private readonly _unsubscribe;
46
+ get clientID(): number;
47
+ get states(): Map<number, TPresence>;
48
+ constructor(params: PluvYjsAwarenessParams<TIO, TPresence, TStorage, TEvents, TField>);
49
+ destroy(): void;
50
+ getLocalState(): AwarenessPresence<TPresence, TField>;
51
+ setLocalState(state: AwarenessPresence<TPresence, TField>): void;
52
+ setLocalStateField<TLocalField extends keyof AwarenessPresence<TPresence, TField>>(field: TLocalField, value: AwarenessPresence<TPresence, TField>[TLocalField]): void;
53
+ /**
54
+ * !HACK
55
+ * @description We're building the awareness presences from the states stored on the room's
56
+ * presense instead of using the map defined in the awareness interface.
57
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
58
+ * @date May 13, 2025
59
+ */
60
+ getStates(): Map<number, AwarenessPresence<TPresence, TField>>;
61
+ private _adaptPresence;
62
+ private _deriveUpdates;
63
+ private _resetIdMap;
64
+ /**
65
+ * !HACK
66
+ * @description We dgaf about these. We're just mirroring the fields that exist in the
67
+ * og awareness to make sure everything aligns.
68
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
69
+ * @date May 13, 2025
70
+ */
71
+ readonly meta: Map<string, MetaClientState>;
72
+ readonly _checkInterval: number;
73
+ }
74
+
75
+ declare const awareness: <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>(params: PluvYjsAwarenessParams<TIO, TPresence, TStorage, TEvents, TField>) => PluvYjsAwareness<TIO, TPresence, TStorage, TEvents, TField>;
76
+
12
77
  type YjsBuilder = ReturnType<typeof builder>;
13
78
  declare const builder: (doc: Doc) => {
14
79
  array<T extends unknown>(name: string, value?: T[] | readonly T[]): YjsType<Array<T>, T[]>;
15
- map<T extends unknown>(name: string, value?: readonly (readonly [key: string, value: T])[]): YjsType<Map<T>, Record<string, T>>;
80
+ map<T extends unknown>(name: string, value?: readonly (readonly [key: string, value: T])[]): YjsType<Map$1<T>, Record<string, T>>;
16
81
  text(name: string, value?: string): YjsType<Text, string>;
17
82
  xmlElement(name: string, children?: (XmlElement | XmlText)[] | readonly (XmlElement | XmlText)[]): YjsType<XmlElement, string>;
18
83
  xmlFragment(name: string, children?: (XmlElement | XmlText)[] | readonly (XmlElement | XmlText)[]): YjsType<XmlFragment, string>;
@@ -20,7 +85,7 @@ declare const builder: (doc: Doc) => {
20
85
  };
21
86
 
22
87
  type CrdtYjsDocParams<TStorage extends Record<string, YjsType<any, any>>> = (builder: YjsBuilder) => TStorage;
23
- declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> implements CrdtDocLike<TStorage> {
88
+ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> implements CrdtDocLike<Doc, TStorage> {
24
89
  value: Doc;
25
90
  private _storage;
26
91
  private _undoManager;
@@ -36,7 +101,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> imp
36
101
  isEmpty(): boolean;
37
102
  rebuildStorage(reference: TStorage): this;
38
103
  redo(): this;
39
- subscribe(listener: (params: DocSubscribeCallbackParams<TStorage>) => void): () => void;
104
+ subscribe(listener: (params: DocSubscribeCallbackParams<Doc, TStorage>) => void): () => void;
40
105
  track(): this;
41
106
  transact(fn: () => void): this;
42
107
  toJson(): InferCrdtJson<TStorage>;
@@ -45,7 +110,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> imp
45
110
  private _warn;
46
111
  }
47
112
 
48
- declare class CrdtYjsDocFactory<TStorage extends Record<string, YjsType<any, any>> = {}> extends AbstractCrdtDocFactory<TStorage> {
113
+ declare class CrdtYjsDocFactory<TStorage extends Record<string, YjsType<any, any>> = {}> extends AbstractCrdtDocFactory<Doc, TStorage> {
49
114
  readonly _initialStorage: (builder: YjsBuilder) => TStorage;
50
115
  constructor(initialStorage?: (builder: YjsBuilder) => TStorage);
51
116
  getEmpty(): CrdtYjsDoc<TStorage>;
@@ -55,14 +120,56 @@ declare class CrdtYjsDocFactory<TStorage extends Record<string, YjsType<any, any
55
120
 
56
121
  declare const doc: <TStorage extends Record<string, YjsType<any, any>>>(value?: (buidler: YjsBuilder) => TStorage) => CrdtYjsDocFactory<TStorage>;
57
122
 
58
- declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => YjsType<Map<T>, Record<string, T>>;
123
+ declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => YjsType<Map$1<T>, Record<string, T>>;
59
124
 
60
125
  /**
61
126
  * @deprecated This will be removed in v3.0.0. Use yjs.map instead
62
127
  * @description Creates a Yjs map, but declare it like it's an object
63
128
  * @date May 8, 2025
64
129
  */
65
- declare const object: <T extends Record<string, any>>(value?: T) => YjsType<Map<T[keyof T]>, T>;
130
+ declare const object: <T extends Record<string, any>>(value?: T) => YjsType<Map$1<T[keyof T]>, T>;
131
+
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;
134
+ room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
135
+ }
136
+ /**
137
+ * !HACK
138
+ * @description This doesn't really do anything but emit states in a Yjs.Provider compatible way.
139
+ * Connections and document syncing are handled by the PluvRoom already.
140
+ * @date May 13, 2025
141
+ */
142
+ declare class PluvYjsProvider<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> extends ObservableV2<{
143
+ "connection-close": (event: CloseEvent | null, provider: PluvYjsProvider<TIO, TPresence, TStorage, TEvents, TField>) => void;
144
+ "connection-error": (event: Event, provider: PluvYjsProvider<TIO, TPresence, TStorage, TEvents, TField>) => void;
145
+ status: (event: {
146
+ status: YjsProviderStatus;
147
+ }) => void;
148
+ sync: (state: boolean) => void;
149
+ synced: (state: boolean) => void;
150
+ }> {
151
+ readonly awareness: PluvYjsAwareness<TIO, TPresence, TStorage, TEvents, TField>;
152
+ readonly doc: Doc;
153
+ private readonly _room;
154
+ private readonly _unsubscribe;
155
+ private _synced;
156
+ constructor(params: PluvYjsProviderParams<TIO, TPresence, TStorage, TEvents, TField>);
157
+ get synced(): boolean;
158
+ set synced(state: boolean);
159
+ destroy(): void;
160
+ private _toProviderStatus;
161
+ /**
162
+ * !HACK
163
+ * @description We dgaf about these, since the room manages these already. We're just mirroring
164
+ * the fields that exist in the og provider to make sure everything aligns.
165
+ * @see https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js
166
+ * @date May 13, 2025
167
+ */
168
+ connect(): void;
169
+ disconnect(): void;
170
+ }
171
+
172
+ declare const provider: <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>(params: PluvYjsProviderParams<TIO, TPresence, TStorage, TEvents, TField>) => PluvYjsProvider<TIO, TPresence, TStorage, TEvents, TField>;
66
173
 
67
174
  declare const text: (value?: string) => YjsType<Text, string>;
68
175
 
@@ -89,16 +196,18 @@ declare const kind: "yjs";
89
196
  type yjs_YjsBuilder = YjsBuilder;
90
197
  type yjs_YjsType<TValue extends unknown, TJson extends unknown = any> = YjsType<TValue, TJson>;
91
198
  declare const yjs_array: typeof array;
199
+ declare const yjs_awareness: typeof awareness;
92
200
  declare const yjs_doc: typeof doc;
93
201
  declare const yjs_kind: typeof kind;
94
202
  declare const yjs_map: typeof map;
95
203
  declare const yjs_object: typeof object;
204
+ declare const yjs_provider: typeof provider;
96
205
  declare const yjs_text: typeof text;
97
206
  declare const yjs_xmlElement: typeof xmlElement;
98
207
  declare const yjs_xmlFragment: typeof xmlFragment;
99
208
  declare const yjs_xmlText: typeof xmlText;
100
209
  declare namespace yjs {
101
- export { type yjs_YjsBuilder as YjsBuilder, type yjs_YjsType as YjsType, yjs_array as array, yjs_doc as doc, yjs_kind as kind, yjs_map as map, yjs_object as object, yjs_text as text, yjs_xmlElement as xmlElement, yjs_xmlFragment as xmlFragment, yjs_xmlText as xmlText };
210
+ export { type yjs_YjsBuilder as YjsBuilder, type yjs_YjsType as YjsType, yjs_array as array, yjs_awareness as awareness, yjs_doc as doc, yjs_kind as kind, yjs_map as map, yjs_object as object, yjs_provider as provider, yjs_text as text, yjs_xmlElement as xmlElement, yjs_xmlFragment as xmlFragment, yjs_xmlText as xmlText };
102
211
  }
103
212
 
104
213
  export { yjs };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,83 @@
1
- import { Array, Doc, Map, Text, XmlElement, XmlText, XmlFragment } from 'yjs';
1
+ import { Array, Doc, Map as Map$1, Text, XmlElement, XmlText, XmlFragment } from 'yjs';
2
2
  import { CrdtType, DocApplyEncodedStateParams, DocBatchApplyEncodedStateParams, DocSubscribeCallbackParams, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
3
- import { CrdtDocLike } from '@pluv/types';
3
+ import { IOLike, CrdtType as CrdtType$1, PluvRouterEventConfig, RoomLike, CrdtDocLike } from '@pluv/types';
4
+ import { ObservableV2 } from 'lib0/observable';
4
5
 
5
6
  type YjsType<TValue extends unknown, TJson extends unknown = any> = CrdtType<TValue, TJson> & {
6
7
  initialValue?: any;
7
8
  toJSON: () => any;
8
9
  };
10
+ /**
11
+ * @description Type internally defined by Yjs.Awareness
12
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
13
+ */
14
+ interface YjsAwarenessUpdate {
15
+ added: number[];
16
+ updated: number[];
17
+ removed: number[];
18
+ }
19
+ type YjsProviderStatus = "connecting" | "connected" | "disconnected";
20
+ /**
21
+ * @description Type internally defined by Yjs.Awareness
22
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
23
+ */
24
+ interface MetaClientState {
25
+ clock: number;
26
+ lastUpdated: number;
27
+ }
28
+ type AwarenessPresence<TPresence extends Record<string, any>, TField extends keyof TPresence | null> = TField extends null ? TPresence : TField extends keyof TPresence ? TPresence[TField] : never;
9
29
 
10
30
  declare const array: <T extends unknown>(value?: T[] | readonly T[]) => YjsType<Array<T>, T[]>;
11
31
 
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;
34
+ room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
35
+ }
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<{
37
+ change: (updates: YjsAwarenessUpdate, kind: "presence") => void;
38
+ destroy: (awareness: PluvYjsAwareness<TIO, TPresence, TStorage, TEvents, TField>) => void;
39
+ update: (updates: YjsAwarenessUpdate, kind: "local" | "presence") => void;
40
+ }> {
41
+ readonly doc: Doc;
42
+ private readonly _field;
43
+ private readonly _idMap;
44
+ private readonly _room;
45
+ private readonly _unsubscribe;
46
+ get clientID(): number;
47
+ get states(): Map<number, TPresence>;
48
+ constructor(params: PluvYjsAwarenessParams<TIO, TPresence, TStorage, TEvents, TField>);
49
+ destroy(): void;
50
+ getLocalState(): AwarenessPresence<TPresence, TField>;
51
+ setLocalState(state: AwarenessPresence<TPresence, TField>): void;
52
+ setLocalStateField<TLocalField extends keyof AwarenessPresence<TPresence, TField>>(field: TLocalField, value: AwarenessPresence<TPresence, TField>[TLocalField]): void;
53
+ /**
54
+ * !HACK
55
+ * @description We're building the awareness presences from the states stored on the room's
56
+ * presense instead of using the map defined in the awareness interface.
57
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
58
+ * @date May 13, 2025
59
+ */
60
+ getStates(): Map<number, AwarenessPresence<TPresence, TField>>;
61
+ private _adaptPresence;
62
+ private _deriveUpdates;
63
+ private _resetIdMap;
64
+ /**
65
+ * !HACK
66
+ * @description We dgaf about these. We're just mirroring the fields that exist in the
67
+ * og awareness to make sure everything aligns.
68
+ * @see https://github.com/yjs/y-protocols/blob/master/awareness.js
69
+ * @date May 13, 2025
70
+ */
71
+ readonly meta: Map<string, MetaClientState>;
72
+ readonly _checkInterval: number;
73
+ }
74
+
75
+ declare const awareness: <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>(params: PluvYjsAwarenessParams<TIO, TPresence, TStorage, TEvents, TField>) => PluvYjsAwareness<TIO, TPresence, TStorage, TEvents, TField>;
76
+
12
77
  type YjsBuilder = ReturnType<typeof builder>;
13
78
  declare const builder: (doc: Doc) => {
14
79
  array<T extends unknown>(name: string, value?: T[] | readonly T[]): YjsType<Array<T>, T[]>;
15
- map<T extends unknown>(name: string, value?: readonly (readonly [key: string, value: T])[]): YjsType<Map<T>, Record<string, T>>;
80
+ map<T extends unknown>(name: string, value?: readonly (readonly [key: string, value: T])[]): YjsType<Map$1<T>, Record<string, T>>;
16
81
  text(name: string, value?: string): YjsType<Text, string>;
17
82
  xmlElement(name: string, children?: (XmlElement | XmlText)[] | readonly (XmlElement | XmlText)[]): YjsType<XmlElement, string>;
18
83
  xmlFragment(name: string, children?: (XmlElement | XmlText)[] | readonly (XmlElement | XmlText)[]): YjsType<XmlFragment, string>;
@@ -20,7 +85,7 @@ declare const builder: (doc: Doc) => {
20
85
  };
21
86
 
22
87
  type CrdtYjsDocParams<TStorage extends Record<string, YjsType<any, any>>> = (builder: YjsBuilder) => TStorage;
23
- declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> implements CrdtDocLike<TStorage> {
88
+ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> implements CrdtDocLike<Doc, TStorage> {
24
89
  value: Doc;
25
90
  private _storage;
26
91
  private _undoManager;
@@ -36,7 +101,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> imp
36
101
  isEmpty(): boolean;
37
102
  rebuildStorage(reference: TStorage): this;
38
103
  redo(): this;
39
- subscribe(listener: (params: DocSubscribeCallbackParams<TStorage>) => void): () => void;
104
+ subscribe(listener: (params: DocSubscribeCallbackParams<Doc, TStorage>) => void): () => void;
40
105
  track(): this;
41
106
  transact(fn: () => void): this;
42
107
  toJson(): InferCrdtJson<TStorage>;
@@ -45,7 +110,7 @@ declare class CrdtYjsDoc<TStorage extends Record<string, YjsType<any, any>>> imp
45
110
  private _warn;
46
111
  }
47
112
 
48
- declare class CrdtYjsDocFactory<TStorage extends Record<string, YjsType<any, any>> = {}> extends AbstractCrdtDocFactory<TStorage> {
113
+ declare class CrdtYjsDocFactory<TStorage extends Record<string, YjsType<any, any>> = {}> extends AbstractCrdtDocFactory<Doc, TStorage> {
49
114
  readonly _initialStorage: (builder: YjsBuilder) => TStorage;
50
115
  constructor(initialStorage?: (builder: YjsBuilder) => TStorage);
51
116
  getEmpty(): CrdtYjsDoc<TStorage>;
@@ -55,14 +120,56 @@ declare class CrdtYjsDocFactory<TStorage extends Record<string, YjsType<any, any
55
120
 
56
121
  declare const doc: <TStorage extends Record<string, YjsType<any, any>>>(value?: (buidler: YjsBuilder) => TStorage) => CrdtYjsDocFactory<TStorage>;
57
122
 
58
- declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => YjsType<Map<T>, Record<string, T>>;
123
+ declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => YjsType<Map$1<T>, Record<string, T>>;
59
124
 
60
125
  /**
61
126
  * @deprecated This will be removed in v3.0.0. Use yjs.map instead
62
127
  * @description Creates a Yjs map, but declare it like it's an object
63
128
  * @date May 8, 2025
64
129
  */
65
- declare const object: <T extends Record<string, any>>(value?: T) => YjsType<Map<T[keyof T]>, T>;
130
+ declare const object: <T extends Record<string, any>>(value?: T) => YjsType<Map$1<T[keyof T]>, T>;
131
+
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;
134
+ room: RoomLike<TIO, Doc, TPresence, TStorage, TEvents>;
135
+ }
136
+ /**
137
+ * !HACK
138
+ * @description This doesn't really do anything but emit states in a Yjs.Provider compatible way.
139
+ * Connections and document syncing are handled by the PluvRoom already.
140
+ * @date May 13, 2025
141
+ */
142
+ declare class PluvYjsProvider<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> extends ObservableV2<{
143
+ "connection-close": (event: CloseEvent | null, provider: PluvYjsProvider<TIO, TPresence, TStorage, TEvents, TField>) => void;
144
+ "connection-error": (event: Event, provider: PluvYjsProvider<TIO, TPresence, TStorage, TEvents, TField>) => void;
145
+ status: (event: {
146
+ status: YjsProviderStatus;
147
+ }) => void;
148
+ sync: (state: boolean) => void;
149
+ synced: (state: boolean) => void;
150
+ }> {
151
+ readonly awareness: PluvYjsAwareness<TIO, TPresence, TStorage, TEvents, TField>;
152
+ readonly doc: Doc;
153
+ private readonly _room;
154
+ private readonly _unsubscribe;
155
+ private _synced;
156
+ constructor(params: PluvYjsProviderParams<TIO, TPresence, TStorage, TEvents, TField>);
157
+ get synced(): boolean;
158
+ set synced(state: boolean);
159
+ destroy(): void;
160
+ private _toProviderStatus;
161
+ /**
162
+ * !HACK
163
+ * @description We dgaf about these, since the room manages these already. We're just mirroring
164
+ * the fields that exist in the og provider to make sure everything aligns.
165
+ * @see https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js
166
+ * @date May 13, 2025
167
+ */
168
+ connect(): void;
169
+ disconnect(): void;
170
+ }
171
+
172
+ declare const provider: <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>(params: PluvYjsProviderParams<TIO, TPresence, TStorage, TEvents, TField>) => PluvYjsProvider<TIO, TPresence, TStorage, TEvents, TField>;
66
173
 
67
174
  declare const text: (value?: string) => YjsType<Text, string>;
68
175
 
@@ -89,16 +196,18 @@ declare const kind: "yjs";
89
196
  type yjs_YjsBuilder = YjsBuilder;
90
197
  type yjs_YjsType<TValue extends unknown, TJson extends unknown = any> = YjsType<TValue, TJson>;
91
198
  declare const yjs_array: typeof array;
199
+ declare const yjs_awareness: typeof awareness;
92
200
  declare const yjs_doc: typeof doc;
93
201
  declare const yjs_kind: typeof kind;
94
202
  declare const yjs_map: typeof map;
95
203
  declare const yjs_object: typeof object;
204
+ declare const yjs_provider: typeof provider;
96
205
  declare const yjs_text: typeof text;
97
206
  declare const yjs_xmlElement: typeof xmlElement;
98
207
  declare const yjs_xmlFragment: typeof xmlFragment;
99
208
  declare const yjs_xmlText: typeof xmlText;
100
209
  declare namespace yjs {
101
- export { type yjs_YjsBuilder as YjsBuilder, type yjs_YjsType as YjsType, yjs_array as array, yjs_doc as doc, yjs_kind as kind, yjs_map as map, yjs_object as object, yjs_text as text, yjs_xmlElement as xmlElement, yjs_xmlFragment as xmlFragment, yjs_xmlText as xmlText };
210
+ export { type yjs_YjsBuilder as YjsBuilder, type yjs_YjsType as YjsType, yjs_array as array, yjs_awareness as awareness, yjs_doc as doc, yjs_kind as kind, yjs_map as map, yjs_object as object, yjs_provider as provider, yjs_text as text, yjs_xmlElement as xmlElement, yjs_xmlFragment as xmlFragment, yjs_xmlText as xmlText };
102
211
  }
103
212
 
104
213
  export { yjs };