@pluv/crdt-yjs 0.15.0 → 0.16.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.
Files changed (47) hide show
  1. package/.eslintrc.js +2 -2
  2. package/.turbo/turbo-build.log +9 -9
  3. package/CHANGELOG.md +45 -37
  4. package/README.md +13 -29
  5. package/dist/index.d.mts +152 -55
  6. package/dist/index.d.ts +152 -55
  7. package/dist/index.js +433 -107
  8. package/dist/index.mjs +445 -101
  9. package/package.json +9 -8
  10. package/src/array/CrdtYjsArray.ts +55 -0
  11. package/src/array/array.ts +7 -0
  12. package/src/array/index.ts +2 -0
  13. package/src/doc/CrdtYjsDoc.ts +274 -0
  14. package/src/doc/CrdtYjsDocFactory.ts +83 -0
  15. package/src/doc/doc.ts +10 -0
  16. package/src/doc/index.ts +3 -0
  17. package/src/index.ts +1 -20
  18. package/src/map/CrdtYjsMap.ts +43 -0
  19. package/src/map/index.ts +2 -0
  20. package/src/{map.ts → map/map.ts} +3 -3
  21. package/src/object/CrdtYjsObject.ts +32 -0
  22. package/src/object/index.ts +2 -0
  23. package/src/object/object.ts +7 -0
  24. package/src/shared/index.ts +2 -0
  25. package/src/shared/isWrapper.ts +25 -0
  26. package/src/shared/toYjsValue.ts +5 -0
  27. package/src/text/CrdtYjsText.ts +34 -0
  28. package/src/text/index.ts +2 -0
  29. package/src/text/text.ts +5 -0
  30. package/src/types.ts +54 -35
  31. package/src/xmlElement/CrdtYjsXmlElement.ts +60 -0
  32. package/src/xmlElement/index.ts +2 -0
  33. package/src/xmlElement/xmlElement.ts +9 -0
  34. package/src/xmlFragment/CrdtYjsXmlFragment.ts +56 -0
  35. package/src/xmlFragment/index.ts +2 -0
  36. package/src/xmlFragment/xmlFragment.ts +9 -0
  37. package/src/xmlText/CrdtYjsXmlText.ts +38 -0
  38. package/src/xmlText/index.ts +2 -0
  39. package/src/xmlText/xmlText.ts +5 -0
  40. package/src/yjs.ts +9 -0
  41. package/src/array.ts +0 -11
  42. package/src/doc.ts +0 -160
  43. package/src/object.ts +0 -16
  44. package/src/text.ts +0 -5
  45. package/src/xmlElement.ts +0 -19
  46. package/src/xmlFragment.ts +0 -16
  47. package/src/xmlText.ts +0 -5
package/.eslintrc.js CHANGED
@@ -1,4 +1,4 @@
1
1
  module.exports = {
2
- root: true,
3
- extends: ["pluv"],
2
+ root: true,
3
+ extends: ["pluv"],
4
4
  };
@@ -1,18 +1,18 @@
1
1
 
2
- > @pluv/crdt-yjs@0.15.0 build /home/runner/work/pluv/pluv/packages/crdt-yjs
2
+ > @pluv/crdt-yjs@0.16.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
6
6
  CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.0.1
7
+ CLI tsup v8.0.2
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 5.88 KB
12
- CJS ⚡️ Build success in 32ms
13
- ESM dist/index.mjs 4.70 KB
14
- ESM ⚡️ Build success in 32ms
11
+ ESM dist/index.mjs 14.79 KB
12
+ ESM ⚡️ Build success in 166ms
13
+ CJS dist/index.js 15.50 KB
14
+ CJS ⚡️ Build success in 167ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 812ms
17
- DTS dist/index.d.mts 3.46 KB
18
- DTS dist/index.d.ts 3.46 KB
16
+ DTS ⚡️ Build success in 2551ms
17
+ DTS dist/index.d.mts 8.40 KB
18
+ DTS dist/index.d.ts 8.40 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @pluv/crdt-yjs
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@0.16.1
8
+ - @pluv/types@0.16.1
9
+
10
+ ## 0.16.0
11
+
12
+ ### Patch Changes
13
+
14
+ - @pluv/crdt@0.16.0
15
+ - @pluv/types@0.16.0
16
+
3
17
  ## 0.15.0
4
18
 
5
19
  ### Patch Changes
@@ -196,7 +210,7 @@
196
210
 
197
211
  ## @pluv/react
198
212
 
199
- `@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `usePluvCanRedo`, `usePluvCanUndo`, `usePluvRedo`, `usePluvUndo` and `usePluvTransact`.
213
+ `@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `useCanRedo`, `useCanUndo`, `useRedo`, `useUndo` and `useTransact`.
200
214
 
201
215
  Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
202
216
 
@@ -208,47 +222,41 @@
208
222
 
209
223
  const { createRoomBundle } = createBundle(client);
210
224
 
211
- const {
212
- usePluvCanRedo,
213
- usePluvCanUndo,
214
- usePluvRedo,
215
- usePluvStorage,
216
- usePluvTransact,
217
- usePluvUndo,
218
- } = createRoomBundle({
219
- initialStorage: () => ({
220
- messages: y.array<string>([]),
221
- }),
222
- /**
223
- * @description This is the same `captureTimeout` option from yjs's UndoManager.
224
- * This specifies a number in ms, during which edits are merged together to be
225
- * undone together. Set this to 0, to track each transacted change individually.
226
- * @see (@link https://docs.yjs.dev/api/undo-manager)
227
- * @default 500
228
- */
229
- captureTimeout: 500,
230
- /**
231
- * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
232
- * This specifies transaction origins (strings only) to filter which transactions
233
- * can be undone.
234
- * When omitted, the user's connection id will be tracked. When provided,
235
- * specifies additional tracked origins besides the user's connection id.
236
- * @see (@link https://docs.yjs.dev/api/undo-manager)
237
- * @default undefined
238
- */
239
- trackedOrigins: ["user-123"],
240
- });
225
+ const { useCanRedo, useCanUndo, useRedo, useStorage, useTransact, useUndo } =
226
+ createRoomBundle({
227
+ initialStorage: () => ({
228
+ messages: y.array<string>([]),
229
+ }),
230
+ /**
231
+ * @description This is the same `captureTimeout` option from yjs's UndoManager.
232
+ * This specifies a number in ms, during which edits are merged together to be
233
+ * undone together. Set this to 0, to track each transacted change individually.
234
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
235
+ * @default 500
236
+ */
237
+ captureTimeout: 500,
238
+ /**
239
+ * @desription This is the same `trackedOrigins` option from yjs's UndoManager.
240
+ * This specifies transaction origins (strings only) to filter which transactions
241
+ * can be undone.
242
+ * When omitted, the user's connection id will be tracked. When provided,
243
+ * specifies additional tracked origins besides the user's connection id.
244
+ * @see (@link https://docs.yjs.dev/api/undo-manager)
245
+ * @default undefined
246
+ */
247
+ trackedOrigins: ["user-123"],
248
+ });
241
249
 
242
250
  /**
243
251
  * @description Check whether calling undo will mutate storage
244
252
  */
245
- const canUndo: boolean = usePluvCanUndo();
253
+ const canUndo: boolean = useCanUndo();
246
254
  /**
247
255
  * @description Check whether calling redo will mutate storage
248
256
  */
249
- const canRedo: boolean = usePluvCanRedo();
257
+ const canRedo: boolean = useCanRedo();
250
258
 
251
- const [messages, sharedType] = usePluvStorage("messages");
259
+ const [messages, sharedType] = useStorage("messages");
252
260
 
253
261
  /**
254
262
  * @description Calling transact will enable a storage mutation to be undone/redone.
@@ -257,7 +265,7 @@
257
265
  *
258
266
  * You can specify a 2nd parameter to transact with a different transaction origin.
259
267
  */
260
- const transact = usePluvTransact();
268
+ const transact = useTransact();
261
269
 
262
270
  transact(() => {
263
271
  sharedType.push(["hello world!"]);
@@ -271,14 +279,14 @@
271
279
  /**
272
280
  * @description Undoes the last valid mutation to storage
273
281
  */
274
- const undo = usePluvUndo();
282
+ const undo = useUndo();
275
283
 
276
284
  undo();
277
285
 
278
286
  /**
279
287
  * @description Re-applies the last undone mutation to storage
280
288
  */
281
- const redo = usePluvRedo();
289
+ const redo = useRedo();
282
290
 
283
291
  redo();
284
292
  ```
package/README.md CHANGED
@@ -5,12 +5,12 @@
5
5
  <br />
6
6
  <img src="https://github.com/pluv-io/pluv/blob/master/assets/pluv-icon-192x192.png?raw=true" alt="Pluv.IO" width="180" style="border-radius:16px" />
7
7
  <br />
8
- Pluv.IO (preview)
8
+ <a href="https://pluv.io/docs/introduction">Pluv.IO (preview)</a>
9
9
  <br />
10
10
  </h1>
11
11
 
12
12
  <h3 align="center">Multi-platform, E2E type-safe realtime packages</h3>
13
- <h4 align="center">💕 Inspired by <a href="https://trpc.io">trpc</a> 💕 Built with <a href="https://docs.yjs.dev/">yjs</a> 💕</h4>
13
+ <h4 align="center">💕 Inspired by <a href="https://trpc.io">trpc</a> 💕 <a href="https://docs.yjs.dev/">yjs</a> 💕 and <a href="https://developers.cloudflare.com/">Cloudflare</a> 💕 </h4>
14
14
 
15
15
  <p align="center">
16
16
  <a href="https://www.npmjs.com/package/@pluv/crdt-yjs">
@@ -19,14 +19,10 @@
19
19
  <a href="https://github.com/pluv-io/pluv/blob/master/LICENSE">
20
20
  <img alt="GitHub" src="https://img.shields.io/github/license/pluv-io/pluv" alt="License MIT" />
21
21
  </a>
22
- <img src="https://badgen.net/badge/-/TypeScript?icon=typescript&label&labelColor=blue&color=555555" alt="TypeScript" />
23
22
  <a href="https://commitizen.github.io/cz-cli/">
24
23
  <img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" />
25
24
  </a>
26
- </p>
27
-
28
- <p align="center">
29
- <img src="https://github.com/pluv-io/pluv/blob/master/assets/demo-events.gif?raw=true" alt="Demo" />
25
+ <img src="https://badgen.net/badge/-/TypeScript?icon=typescript&label&labelColor=blue&color=555555" alt="TypeScript" />
30
26
  </p>
31
27
 
32
28
  ## `@pluv/crdt-yjs`
@@ -54,43 +50,31 @@ pnpm add @pluv/crdt-yjs yjs
54
50
  ## Basic Example
55
51
 
56
52
  ```ts
57
- import { createClient, y } from "@pluv/client";
58
- import type {
59
- Array as YArray,
60
- Map as YMap,
61
- XmlFragment as YXmlFragment,
62
- } from "yjs";
53
+ import { createClient } from "@pluv/client";
54
+ import { yjs } from "@pluv/crdt-yjs";
63
55
  import { z } from "zod";
64
56
  // Import the PluvIO instance as a type from your server file
65
57
  import { type io } from "./server";
66
58
 
67
59
  const client = createClient<typeof io>({ /* client config here */ });
68
60
 
69
- type Presence = {};
70
-
71
- interface Storage {
72
- editor: YXmlFragment;
73
- groceryList: YMap<string, number>;
74
- messages: YArray<{ name: string; message: string }>;
75
- }
76
-
77
61
  // Create a room to join
78
- const room = client.createRoom<Presence, Storage>("my-room", {
79
- initialStorage: () => ({
80
- editor: y.xmlFragment({
62
+ const room = client.createRoom("my-room", {
63
+ initialStorage: yjs.doc(() => ({
64
+ editor: yjs.xmlFragment({
81
65
  children: [
82
- y.xmlElement("paragraph", {
83
- children: [y.xmlText("Hello World!")],
66
+ yjs.xmlElement("paragraph", {
67
+ children: [yjs.xmlText("Hello World!")],
84
68
  }),
85
69
  ]
86
70
  }),
87
- groceryList: y.map([
71
+ groceryList: yjs.map([
88
72
  ["apricots", 2],
89
73
  ["bread", 3],
90
74
  ["cheese", 5],
91
75
  ]),
92
- messages: y.array([]),
93
- }),
76
+ messages: yjs.array([]),
77
+ })),
94
78
  presence: z.object({}),
95
79
  });
96
80
  ```
package/dist/index.d.mts CHANGED
@@ -1,67 +1,164 @@
1
- import { Array, AbstractType, Map, Text, XmlElement, XmlFragment, XmlText, Doc, Transaction } from 'yjs';
2
- export { AbstractType, Array, Map, Text } from 'yjs';
3
- import { JsonPrimitive } from '@pluv/types';
4
-
5
- declare const array: <T extends unknown>(value?: readonly T[]) => Array<T>;
6
-
7
- type YObjectValue = Record<string, NonNullable<JsonPrimitive> | AbstractType<any>>;
8
- type YObject<T extends YObjectValue> = Map<T[keyof T]> & {
9
- __$type: T;
10
- };
11
- declare const object: <T extends YObjectValue = {}>(value: T) => YObject<T>;
12
-
13
- type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? {
14
- [P in keyof ITypes]: InferYjsSharedTypeJson<ITypes[P]>;
15
- } : never;
16
- type InferYjsDocSharedType<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsDocSharedTypes<TDoc>[TKey];
17
- type InferYjsDocSharedTypeJson<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsSharedTypeJson<InferYjsDocSharedTypes<TDoc>[TKey]>;
18
- type InferYjsDocSharedTypes<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? ITypes : never;
19
- type InferYjsSharedTypeJson<TShared extends unknown> = TShared extends AbstractType<any> ? TShared extends Array<infer IItem> ? readonly InferYjsSharedTypeJson<IItem>[] : TShared extends YObject<infer IObject> ? {
20
- [P in keyof IObject]: InferYjsSharedTypeJson<IObject[P]>;
21
- } : TShared extends Map<infer IItem> ? Record<string, InferYjsSharedTypeJson<IItem>> : TShared extends Text | XmlElement | XmlFragment | XmlText ? string : never : TShared;
22
-
23
- interface TrackOriginOptions {
24
- captureTimeout?: number;
25
- trackedOrigins?: readonly string[];
1
+ import { AbstractCrdtType, InferCrdtStorageJson, AbstractCrdtDoc, DocApplyEncodedStateParams, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
2
+ import { Map, Text, XmlText, XmlElement, XmlFragment, Array, Doc } from 'yjs';
3
+ import { Json } from '@pluv/types';
4
+
5
+ declare class CrdtYjsMap<T extends unknown> extends AbstractCrdtType<Map<InferYjsType<T>>, Record<string, InferYjsJson<T>>> {
6
+ initialValue: readonly (readonly [
7
+ key: string,
8
+ value: InferYjsType<T>
9
+ ])[];
10
+ value: Map<InferYjsType<T>>;
11
+ constructor(value?: readonly (readonly [key: string, value: T])[]);
12
+ get size(): number;
13
+ delete(prop: string): this;
14
+ set(prop: string, value: T): this;
15
+ toJson(): InferCrdtStorageJson<Record<string, InferYjsJson<T>>>;
16
+ }
17
+
18
+ declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => CrdtYjsMap<T>;
19
+
20
+ declare class CrdtYjsObject<T extends Record<string, any>> extends AbstractCrdtType<Map<InferYjsType<T[keyof T]>>, InferYjsJson<T>> {
21
+ initialValue: readonly (readonly [key: string, value: T[keyof T]])[];
22
+ value: Map<InferYjsType<T[keyof T]>>;
23
+ constructor(value?: T);
24
+ set<TProp extends keyof T>(prop: TProp, value: T[TProp]): this;
25
+ toJson(): InferCrdtStorageJson<InferYjsJson<T>>;
26
+ }
27
+
28
+ declare const object: <T extends Record<string, any>>(value: T) => CrdtYjsObject<T>;
29
+
30
+ declare class CrdtYjsText extends AbstractCrdtType<Text, string> {
31
+ readonly initialValue: string;
32
+ value: Text;
33
+ constructor(value?: string);
34
+ get length(): number;
35
+ delete(index: number, length?: number): this;
36
+ insert(index: number, text: string): this;
37
+ toJson(): string;
38
+ }
39
+
40
+ declare class CrdtYjsXmlText extends AbstractCrdtType<XmlText, string> {
41
+ readonly initialValue: string;
42
+ value: XmlText;
43
+ constructor(value?: string);
44
+ get length(): number;
45
+ delete(index: number, length?: number): this;
46
+ insert(index: number, text: string, attributes?: Record<string, string>): this;
47
+ toJson(): string;
26
48
  }
27
- declare class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
49
+
50
+ declare class CrdtYjsXmlElement extends AbstractCrdtType<XmlElement, string> {
51
+ readonly initialValue: readonly (XmlElement | XmlText)[];
52
+ readonly name: string;
53
+ value: XmlElement;
54
+ constructor(name: string, children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]);
55
+ get length(): number;
56
+ delete(index: number, length?: number): this;
57
+ insert(index: number, ...children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]): this;
58
+ push(...children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]): this;
59
+ unshift(...children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]): this;
60
+ toJson(): string;
61
+ }
62
+
63
+ declare const xmlText: (value?: string) => CrdtYjsXmlText;
64
+
65
+ declare const xmlElement: (name: string, children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]) => CrdtYjsXmlElement;
66
+
67
+ declare class CrdtYjsXmlFragment extends AbstractCrdtType<XmlFragment, string> {
68
+ readonly initialValue: readonly (XmlElement | XmlText)[];
69
+ value: XmlFragment;
70
+ constructor(children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]);
71
+ get length(): number;
72
+ delete(index: number, length?: number): this;
73
+ insert(index: number, ...children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]): this;
74
+ push(...children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]): this;
75
+ unshift(...children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]): this;
76
+ toJson(): string;
77
+ }
78
+
79
+ declare const xmlFragment: (children: readonly (CrdtYjsXmlElement | CrdtYjsXmlText)[]) => CrdtYjsXmlFragment;
80
+
81
+ type InferYjsType<T extends unknown> = T extends CrdtYjsArray<infer IType> ? Array<IType> : T extends CrdtYjsMap<infer IType> ? Map<IType> : T extends CrdtYjsObject<infer IType> ? Map<IType[keyof IType]> : T extends CrdtYjsText ? Text : T extends CrdtYjsXmlElement ? XmlElement : T extends CrdtYjsXmlFragment ? XmlFragment : T extends CrdtYjsXmlText ? XmlText : T extends Json ? T : never;
82
+ type InferYjsJson<T extends unknown> = T extends CrdtYjsArray<infer IType> ? InferYjsJson<IType>[] : T extends CrdtYjsMap<infer IType> ? Record<string, InferYjsJson<IType>> : T extends CrdtYjsObject<infer IType> ? {
83
+ [P in keyof IType]: InferYjsJson<IType[P]>;
84
+ } : T extends CrdtYjsText | CrdtYjsXmlElement | CrdtYjsXmlFragment | CrdtYjsXmlText | Text | XmlElement | XmlFragment | XmlText ? string : T extends Array<infer IType> ? InferYjsJson<IType>[] : T extends Map<infer IType> ? Record<string, InferYjsJson<IType>> : T extends (infer IType)[] ? InferYjsJson<IType>[] : T extends Record<any, any> ? {
85
+ [P in keyof T]: InferYjsJson<T[P]>;
86
+ } : T extends Json ? T : never;
87
+
88
+ declare class CrdtYjsArray<T extends unknown> extends AbstractCrdtType<Array<InferYjsType<T>>, InferYjsJson<T>[]> {
89
+ readonly initialValue: InferYjsType<T>[] | readonly InferYjsType<T>[];
90
+ value: Array<InferYjsType<T>>;
91
+ constructor(value?: T[] | readonly T[]);
92
+ get length(): number;
93
+ delete(index: number, length?: number): this;
94
+ insert(index: number, ...items: T[]): this;
95
+ push(...items: T[]): this;
96
+ unshift(...items: T[]): this;
97
+ toJson(): InferCrdtStorageJson<InferYjsJson<T>>[];
98
+ }
99
+
100
+ declare const array: <T extends unknown>(value?: T[] | readonly T[]) => CrdtYjsArray<T>;
101
+
102
+ declare class CrdtYjsDoc<TStorage extends Record<string, AbstractCrdtType<any, any>>> extends AbstractCrdtDoc<TStorage> {
28
103
  value: Doc;
104
+ private _storage;
29
105
  private _undoManager;
30
- get storage(): T;
31
- private get _storage();
32
- constructor(value?: T);
33
- applyUpdate(update?: string | Uint8Array | null, origin?: string): this;
106
+ constructor(value?: TStorage);
107
+ applyEncodedState(params: DocApplyEncodedStateParams): this;
108
+ batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
34
109
  canRedo(): boolean;
35
110
  canUndo(): boolean;
36
111
  destroy(): void;
37
- encodeStateAsUpdate(): string;
38
- get<TKey extends keyof T>(key: TKey): T[TKey];
39
- getSharedTypes(): T;
40
- redo(): void;
41
- subscribe(fn: (update: string, origin: any, doc: Doc, transaction: Transaction) => void): () => void;
42
- toJSON(): InferYjsDocJson<this>;
43
- trackOrigins(options: TrackOriginOptions): void;
44
- transact(fn: (transaction: Transaction) => void, origin?: any): void;
45
- static fromUint8Array(u8a: Uint8Array): string;
46
- static toUint8Array(str: string): Uint8Array;
47
- undo(): void;
112
+ get(key?: undefined): TStorage;
113
+ get<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
114
+ getEncodedState(): string;
115
+ isEmpty(): boolean;
116
+ redo(): this;
117
+ subscribe(listener: (params: DocSubscribeCallbackParams<TStorage>) => void): () => void;
118
+ track(): this;
119
+ transact(fn: () => void): this;
120
+ toJson(): InferCrdtStorageJson<TStorage>;
121
+ undo(): this;
48
122
  }
49
- declare const doc: <T extends Record<string, AbstractType<any>> = {}>(value?: T | undefined) => YjsDoc<T>;
50
-
51
- declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => Map<T>;
52
123
 
53
- declare const text: (value?: string) => Text;
54
-
55
- interface XmlElementParams {
56
- children?: readonly (XmlElement | XmlText)[];
124
+ declare class CrdtYjsDocFactory<TStorage extends Record<string, AbstractCrdtType<any, any>>> extends AbstractCrdtDocFactory<TStorage> {
125
+ private _initialStorage;
126
+ constructor(initialStorage?: () => TStorage);
127
+ getEmpty(): CrdtYjsDoc<TStorage>;
128
+ getFactory(initialStorage?: (() => TStorage) | undefined): CrdtYjsDocFactory<TStorage>;
129
+ getFresh(): CrdtYjsDoc<TStorage>;
130
+ getInitialized(initialStorage?: () => TStorage): CrdtYjsDoc<TStorage>;
57
131
  }
58
- declare const xmlElement: (name: string, params?: XmlElementParams) => XmlElement;
59
132
 
60
- interface XmlFragmentParams {
61
- children?: readonly (XmlElement | XmlText)[];
62
- }
63
- declare const xmlFragment: (params?: XmlFragmentParams) => XmlFragment;
133
+ declare const doc: <TStorage extends Record<string, AbstractCrdtType<any, any>>>(value?: () => TStorage) => CrdtYjsDocFactory<TStorage>;
64
134
 
65
- declare const xmlText: (value?: string) => XmlText;
135
+ type yjs_CrdtYjsArray<T extends unknown> = CrdtYjsArray<T>;
136
+ declare const yjs_CrdtYjsArray: typeof CrdtYjsArray;
137
+ type yjs_CrdtYjsDoc<TStorage extends Record<string, AbstractCrdtType<any, any>>> = CrdtYjsDoc<TStorage>;
138
+ declare const yjs_CrdtYjsDoc: typeof CrdtYjsDoc;
139
+ type yjs_CrdtYjsMap<T extends unknown> = CrdtYjsMap<T>;
140
+ declare const yjs_CrdtYjsMap: typeof CrdtYjsMap;
141
+ type yjs_CrdtYjsObject<T extends Record<string, any>> = CrdtYjsObject<T>;
142
+ declare const yjs_CrdtYjsObject: typeof CrdtYjsObject;
143
+ type yjs_CrdtYjsText = CrdtYjsText;
144
+ declare const yjs_CrdtYjsText: typeof CrdtYjsText;
145
+ type yjs_CrdtYjsXmlElement = CrdtYjsXmlElement;
146
+ declare const yjs_CrdtYjsXmlElement: typeof CrdtYjsXmlElement;
147
+ type yjs_CrdtYjsXmlFragment = CrdtYjsXmlFragment;
148
+ declare const yjs_CrdtYjsXmlFragment: typeof CrdtYjsXmlFragment;
149
+ type yjs_CrdtYjsXmlText = CrdtYjsXmlText;
150
+ declare const yjs_CrdtYjsXmlText: typeof CrdtYjsXmlText;
151
+ type yjs_InferYjsJson<T extends unknown> = InferYjsJson<T>;
152
+ type yjs_InferYjsType<T extends unknown> = InferYjsType<T>;
153
+ declare const yjs_array: typeof array;
154
+ declare const yjs_doc: typeof doc;
155
+ declare const yjs_map: typeof map;
156
+ declare const yjs_object: typeof object;
157
+ declare const yjs_xmlElement: typeof xmlElement;
158
+ declare const yjs_xmlFragment: typeof xmlFragment;
159
+ declare const yjs_xmlText: typeof xmlText;
160
+ declare namespace yjs {
161
+ export { yjs_CrdtYjsArray as CrdtYjsArray, yjs_CrdtYjsDoc as CrdtYjsDoc, yjs_CrdtYjsMap as CrdtYjsMap, yjs_CrdtYjsObject as CrdtYjsObject, yjs_CrdtYjsText as CrdtYjsText, yjs_CrdtYjsXmlElement as CrdtYjsXmlElement, yjs_CrdtYjsXmlFragment as CrdtYjsXmlFragment, yjs_CrdtYjsXmlText as CrdtYjsXmlText, type yjs_InferYjsJson as InferYjsJson, type yjs_InferYjsType as InferYjsType, yjs_array as array, yjs_doc as doc, yjs_map as map, yjs_object as object, yjs_xmlElement as xmlElement, yjs_xmlFragment as xmlFragment, yjs_xmlText as xmlText };
162
+ }
66
163
 
67
- export { type InferYjsDocJson, type InferYjsDocSharedType, type InferYjsDocSharedTypeJson, type InferYjsDocSharedTypes, type InferYjsSharedTypeJson, type TrackOriginOptions, type XmlElementParams, type XmlFragmentParams, type YObject, type YObjectValue, YjsDoc, array, doc, map, object, text, xmlElement, xmlFragment, xmlText };
164
+ export { yjs };