@pluv/crdt-yjs 0.14.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -2
- package/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +44 -37
- package/README.md +13 -29
- package/dist/index.d.mts +152 -55
- package/dist/index.d.ts +152 -55
- package/dist/index.js +433 -107
- package/dist/index.mjs +445 -101
- package/package.json +9 -8
- package/src/array/CrdtYjsArray.ts +55 -0
- package/src/array/array.ts +7 -0
- package/src/array/index.ts +2 -0
- package/src/doc/CrdtYjsDoc.ts +274 -0
- package/src/doc/CrdtYjsDocFactory.ts +83 -0
- package/src/doc/doc.ts +10 -0
- package/src/doc/index.ts +3 -0
- package/src/index.ts +1 -20
- package/src/map/CrdtYjsMap.ts +43 -0
- package/src/map/index.ts +2 -0
- package/src/{map.ts → map/map.ts} +3 -3
- package/src/object/CrdtYjsObject.ts +32 -0
- package/src/object/index.ts +2 -0
- package/src/object/object.ts +7 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/isWrapper.ts +25 -0
- package/src/shared/toYjsValue.ts +5 -0
- package/src/text/CrdtYjsText.ts +34 -0
- package/src/text/index.ts +2 -0
- package/src/text/text.ts +5 -0
- package/src/types.ts +54 -35
- package/src/xmlElement/CrdtYjsXmlElement.ts +60 -0
- package/src/xmlElement/index.ts +2 -0
- package/src/xmlElement/xmlElement.ts +9 -0
- package/src/xmlFragment/CrdtYjsXmlFragment.ts +56 -0
- package/src/xmlFragment/index.ts +2 -0
- package/src/xmlFragment/xmlFragment.ts +9 -0
- package/src/xmlText/CrdtYjsXmlText.ts +38 -0
- package/src/xmlText/index.ts +2 -0
- package/src/xmlText/xmlText.ts +5 -0
- package/src/yjs.ts +9 -0
- package/src/array.ts +0 -11
- package/src/doc.ts +0 -160
- package/src/object.ts +0 -16
- package/src/text.ts +0 -5
- package/src/xmlElement.ts +0 -19
- package/src/xmlFragment.ts +0 -16
- package/src/xmlText.ts +0 -5
package/.eslintrc.js
CHANGED
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-yjs@0.
|
|
2
|
+
> @pluv/crdt-yjs@0.16.0 build /home/runner/work/pluv/pluv/packages/crdt-yjs
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.0.
|
|
7
|
+
[34mCLI[39m tsup v8.0.2
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m15.50 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 117ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m14.79 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 118ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 2707ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m8.40 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m8.40 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @pluv/crdt-yjs
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/crdt@0.16.0
|
|
8
|
+
- @pluv/types@0.16.0
|
|
9
|
+
|
|
10
|
+
## 0.15.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @pluv/types@0.15.0
|
|
15
|
+
|
|
3
16
|
## 0.14.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -190,7 +203,7 @@
|
|
|
190
203
|
|
|
191
204
|
## @pluv/react
|
|
192
205
|
|
|
193
|
-
`@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `
|
|
206
|
+
`@pluv/react`'s `createRoomBundle` now exposes 5 new react hooks: `useCanRedo`, `useCanUndo`, `useRedo`, `useUndo` and `useTransact`.
|
|
194
207
|
|
|
195
208
|
Refer to the code-example below to better understand how to undo and redo with your `createRoomBundle`.
|
|
196
209
|
|
|
@@ -202,47 +215,41 @@
|
|
|
202
215
|
|
|
203
216
|
const { createRoomBundle } = createBundle(client);
|
|
204
217
|
|
|
205
|
-
const {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
* specifies additional tracked origins besides the user's connection id.
|
|
230
|
-
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
231
|
-
* @default undefined
|
|
232
|
-
*/
|
|
233
|
-
trackedOrigins: ["user-123"],
|
|
234
|
-
});
|
|
218
|
+
const { useCanRedo, useCanUndo, useRedo, useStorage, useTransact, useUndo } =
|
|
219
|
+
createRoomBundle({
|
|
220
|
+
initialStorage: () => ({
|
|
221
|
+
messages: y.array<string>([]),
|
|
222
|
+
}),
|
|
223
|
+
/**
|
|
224
|
+
* @description This is the same `captureTimeout` option from yjs's UndoManager.
|
|
225
|
+
* This specifies a number in ms, during which edits are merged together to be
|
|
226
|
+
* undone together. Set this to 0, to track each transacted change individually.
|
|
227
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
228
|
+
* @default 500
|
|
229
|
+
*/
|
|
230
|
+
captureTimeout: 500,
|
|
231
|
+
/**
|
|
232
|
+
* @desription This is the same `trackedOrigins` option from yjs's UndoManager.
|
|
233
|
+
* This specifies transaction origins (strings only) to filter which transactions
|
|
234
|
+
* can be undone.
|
|
235
|
+
* When omitted, the user's connection id will be tracked. When provided,
|
|
236
|
+
* specifies additional tracked origins besides the user's connection id.
|
|
237
|
+
* @see (@link https://docs.yjs.dev/api/undo-manager)
|
|
238
|
+
* @default undefined
|
|
239
|
+
*/
|
|
240
|
+
trackedOrigins: ["user-123"],
|
|
241
|
+
});
|
|
235
242
|
|
|
236
243
|
/**
|
|
237
244
|
* @description Check whether calling undo will mutate storage
|
|
238
245
|
*/
|
|
239
|
-
const canUndo: boolean =
|
|
246
|
+
const canUndo: boolean = useCanUndo();
|
|
240
247
|
/**
|
|
241
248
|
* @description Check whether calling redo will mutate storage
|
|
242
249
|
*/
|
|
243
|
-
const canRedo: boolean =
|
|
250
|
+
const canRedo: boolean = useCanRedo();
|
|
244
251
|
|
|
245
|
-
const [messages, sharedType] =
|
|
252
|
+
const [messages, sharedType] = useStorage("messages");
|
|
246
253
|
|
|
247
254
|
/**
|
|
248
255
|
* @description Calling transact will enable a storage mutation to be undone/redone.
|
|
@@ -251,7 +258,7 @@
|
|
|
251
258
|
*
|
|
252
259
|
* You can specify a 2nd parameter to transact with a different transaction origin.
|
|
253
260
|
*/
|
|
254
|
-
const transact =
|
|
261
|
+
const transact = useTransact();
|
|
255
262
|
|
|
256
263
|
transact(() => {
|
|
257
264
|
sharedType.push(["hello world!"]);
|
|
@@ -265,14 +272,14 @@
|
|
|
265
272
|
/**
|
|
266
273
|
* @description Undoes the last valid mutation to storage
|
|
267
274
|
*/
|
|
268
|
-
const undo =
|
|
275
|
+
const undo = useUndo();
|
|
269
276
|
|
|
270
277
|
undo();
|
|
271
278
|
|
|
272
279
|
/**
|
|
273
280
|
* @description Re-applies the last undone mutation to storage
|
|
274
281
|
*/
|
|
275
|
-
const redo =
|
|
282
|
+
const redo = useRedo();
|
|
276
283
|
|
|
277
284
|
redo();
|
|
278
285
|
```
|
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> 💕
|
|
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
|
-
|
|
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
|
|
58
|
-
import
|
|
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
|
|
79
|
-
initialStorage: () => ({
|
|
80
|
-
editor:
|
|
62
|
+
const room = client.createRoom("my-room", {
|
|
63
|
+
initialStorage: yjs.doc(() => ({
|
|
64
|
+
editor: yjs.xmlFragment({
|
|
81
65
|
children: [
|
|
82
|
-
|
|
83
|
-
children: [
|
|
66
|
+
yjs.xmlElement("paragraph", {
|
|
67
|
+
children: [yjs.xmlText("Hello World!")],
|
|
84
68
|
}),
|
|
85
69
|
]
|
|
86
70
|
}),
|
|
87
|
-
groceryList:
|
|
71
|
+
groceryList: yjs.map([
|
|
88
72
|
["apricots", 2],
|
|
89
73
|
["bread", 3],
|
|
90
74
|
["cheese", 5],
|
|
91
75
|
]),
|
|
92
|
-
messages:
|
|
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 {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
38
|
-
get<TKey extends keyof
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
transact(fn: (
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
164
|
+
export { yjs };
|