@pluv/crdt-yjs 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -7
- package/CHANGELOG.md +29 -0
- package/dist/index.d.mts +56 -0
- package/dist/index.d.ts +6 -6
- package/package.json +8 -9
- package/src/array.ts +1 -1
- package/src/doc.ts +7 -7
- package/src/index.ts +7 -7
- package/src/map.ts +1 -1
- package/src/object.ts +6 -8
- package/src/types.ts +6 -4
- package/src/xmlElement.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-yjs@0.4.
|
|
2
|
+
> @pluv/crdt-yjs@0.4.2 build /home/runner/work/pluv/pluv/packages/crdt-yjs
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v7.
|
|
7
|
+
[34mCLI[39m tsup v7.1.0
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m3.68 KB[39m
|
|
12
|
-
[32mESM[39m ⚡️ Build success in 95ms
|
|
13
11
|
[32mCJS[39m [1mdist/index.js [22m[32m4.87 KB[39m
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 73ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m3.68 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 74ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1374ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.11 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.11 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @pluv/crdt-yjs
|
|
2
2
|
|
|
3
|
+
## 0.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f4317ba: \* Renamed type `unstable_YObjectValue` to `YObjectValue`;
|
|
8
|
+
|
|
9
|
+
- Renamed type `unstable_YObject` to `YObject`.
|
|
10
|
+
- Re-exported `xmlElement`, `xmlFragment` and `xmlText` from `@pluv/client`.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { y } from "@pluv/client";
|
|
14
|
+
// or
|
|
15
|
+
import { y } from "@pluv/react";
|
|
16
|
+
|
|
17
|
+
y.xmlElement("MyElement", {});
|
|
18
|
+
y.xmlFragment({});
|
|
19
|
+
y.xmlText("hello world");
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 0.4.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 8fba48b: fix including incorrect dependency
|
|
27
|
+
- 8997c65: bumped dependencies
|
|
28
|
+
- Updated dependencies [8fba48b]
|
|
29
|
+
- Updated dependencies [8997c65]
|
|
30
|
+
- @pluv/types@0.2.2
|
|
31
|
+
|
|
3
32
|
## 0.4.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
declare class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
24
|
+
value: Doc;
|
|
25
|
+
private get _storage();
|
|
26
|
+
constructor(value?: T);
|
|
27
|
+
applyUpdate(update?: string | Uint8Array | null, origin?: string): this;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
encodeStateAsUpdate(): string;
|
|
30
|
+
get<TKey extends keyof T>(key: TKey): T[TKey];
|
|
31
|
+
getSharedTypes(): T;
|
|
32
|
+
subscribe(fn: (update: string, origin: any, doc: Doc, transaction: Transaction) => void): () => void;
|
|
33
|
+
toJSON(): InferYjsDocJson<this>;
|
|
34
|
+
transact(fn: (transaction: Transaction) => void, origin?: any): void;
|
|
35
|
+
static fromUint8Array(u8a: Uint8Array): string;
|
|
36
|
+
static toUint8Array(str: string): Uint8Array;
|
|
37
|
+
}
|
|
38
|
+
declare const doc: <T extends Record<string, AbstractType<any>> = {}>(value?: T | undefined) => YjsDoc<T>;
|
|
39
|
+
|
|
40
|
+
declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => Map<T>;
|
|
41
|
+
|
|
42
|
+
declare const text: (value?: string) => Text;
|
|
43
|
+
|
|
44
|
+
interface XmlElementParams {
|
|
45
|
+
children?: readonly (XmlElement | XmlText)[];
|
|
46
|
+
}
|
|
47
|
+
declare const xmlElement: (name: string, params?: XmlElementParams) => XmlElement;
|
|
48
|
+
|
|
49
|
+
interface XmlFragmentParams {
|
|
50
|
+
children?: readonly (XmlElement | XmlText)[];
|
|
51
|
+
}
|
|
52
|
+
declare const xmlFragment: (params?: XmlFragmentParams) => XmlFragment;
|
|
53
|
+
|
|
54
|
+
declare const xmlText: (value?: string) => XmlText;
|
|
55
|
+
|
|
56
|
+
export { InferYjsDocJson, InferYjsDocSharedType, InferYjsDocSharedTypeJson, InferYjsDocSharedTypes, InferYjsSharedTypeJson, XmlElementParams, XmlFragmentParams, YObject, YObjectValue, YjsDoc, array, doc, map, object, text, xmlElement, xmlFragment, xmlText };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Array,
|
|
1
|
+
import { Array, AbstractType, Map, Text, XmlElement, XmlFragment, XmlText, Doc, Transaction } from 'yjs';
|
|
2
2
|
export { AbstractType, Array, Map, Text } from 'yjs';
|
|
3
3
|
import { JsonPrimitive } from '@pluv/types';
|
|
4
4
|
|
|
5
5
|
declare const array: <T extends unknown>(value?: readonly T[]) => Array<T>;
|
|
6
6
|
|
|
7
|
-
type
|
|
8
|
-
type
|
|
7
|
+
type YObjectValue = Record<string, NonNullable<JsonPrimitive> | AbstractType<any>>;
|
|
8
|
+
type YObject<T extends YObjectValue> = Map<T[keyof T]> & {
|
|
9
9
|
__$type: T;
|
|
10
10
|
};
|
|
11
|
-
declare const object: <T extends
|
|
11
|
+
declare const object: <T extends YObjectValue = {}>(value: T) => YObject<T>;
|
|
12
12
|
|
|
13
13
|
type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? {
|
|
14
14
|
[P in keyof ITypes]: InferYjsSharedTypeJson<ITypes[P]>;
|
|
@@ -16,7 +16,7 @@ type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer IType
|
|
|
16
16
|
type InferYjsDocSharedType<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsDocSharedTypes<TDoc>[TKey];
|
|
17
17
|
type InferYjsDocSharedTypeJson<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsSharedTypeJson<InferYjsDocSharedTypes<TDoc>[TKey]>;
|
|
18
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
|
|
19
|
+
type InferYjsSharedTypeJson<TShared extends unknown> = TShared extends AbstractType<any> ? TShared extends Array<infer IItem> ? readonly InferYjsSharedTypeJson<IItem>[] : TShared extends YObject<infer IObject> ? {
|
|
20
20
|
[P in keyof IObject]: InferYjsSharedTypeJson<IObject[P]>;
|
|
21
21
|
} : TShared extends Map<infer IItem> ? Record<string, InferYjsSharedTypeJson<IItem>> : TShared extends Text | XmlElement | XmlFragment | XmlText ? string : never : TShared;
|
|
22
22
|
|
|
@@ -53,4 +53,4 @@ declare const xmlFragment: (params?: XmlFragmentParams) => XmlFragment;
|
|
|
53
53
|
|
|
54
54
|
declare const xmlText: (value?: string) => XmlText;
|
|
55
55
|
|
|
56
|
-
export { InferYjsDocJson, InferYjsDocSharedType, InferYjsDocSharedTypeJson, InferYjsDocSharedTypes, InferYjsSharedTypeJson, XmlElementParams, XmlFragmentParams, YjsDoc, array, doc, map, object, text,
|
|
56
|
+
export { InferYjsDocJson, InferYjsDocSharedType, InferYjsDocSharedTypeJson, InferYjsDocSharedTypes, InferYjsSharedTypeJson, XmlElementParams, XmlFragmentParams, YObject, YObjectValue, YjsDoc, array, doc, map, object, text, xmlElement, xmlFragment, xmlText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-yjs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "yjs for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,20 +17,19 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@types/react": "^18.2.13",
|
|
20
|
+
"@types/react": "^18.2.15",
|
|
22
21
|
"js-base64": "^3.7.5",
|
|
23
|
-
"@pluv/types": "^0.2.
|
|
22
|
+
"@pluv/types": "^0.2.2"
|
|
24
23
|
},
|
|
25
24
|
"peerDependencies": {
|
|
26
25
|
"yjs": "^13.0.0"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
|
-
"tsup": "^7.
|
|
30
|
-
"typescript": "^5.1.
|
|
31
|
-
"yjs": "^13.6.
|
|
32
|
-
"@pluv/tsconfig": "^0.
|
|
33
|
-
"eslint-config-pluv": "^0.1.
|
|
28
|
+
"tsup": "^7.1.0",
|
|
29
|
+
"typescript": "^5.1.6",
|
|
30
|
+
"yjs": "^13.6.7",
|
|
31
|
+
"@pluv/tsconfig": "^0.2.0",
|
|
32
|
+
"eslint-config-pluv": "^0.1.14"
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
36
35
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/array.ts
CHANGED
package/src/doc.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
28
28
|
|
|
29
29
|
public applyUpdate(
|
|
30
30
|
update?: string | Uint8Array | null,
|
|
31
|
-
origin?: string
|
|
31
|
+
origin?: string,
|
|
32
32
|
): this {
|
|
33
33
|
if (update === null || typeof update === "undefined") return this;
|
|
34
34
|
|
|
@@ -55,7 +55,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
55
55
|
public getSharedTypes(): T {
|
|
56
56
|
return Array.from(this._storage.keys()).reduce(
|
|
57
57
|
(acc, key) => ({ ...acc, [key]: this._storage.get(key) }),
|
|
58
|
-
{} as T
|
|
58
|
+
{} as T,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -64,14 +64,14 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
64
64
|
update: string,
|
|
65
65
|
origin: any,
|
|
66
66
|
doc: YDoc,
|
|
67
|
-
transaction: Transaction
|
|
68
|
-
) => void
|
|
67
|
+
transaction: Transaction,
|
|
68
|
+
) => void,
|
|
69
69
|
): () => void {
|
|
70
70
|
const _fn = (
|
|
71
71
|
update: Uint8Array,
|
|
72
72
|
origin: any,
|
|
73
73
|
doc: YDoc,
|
|
74
|
-
transaction: Transaction
|
|
74
|
+
transaction: Transaction,
|
|
75
75
|
) => fn(YjsDoc.fromUint8Array(update), origin, doc, transaction);
|
|
76
76
|
|
|
77
77
|
this.value.on("update", _fn);
|
|
@@ -87,7 +87,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
87
87
|
|
|
88
88
|
public transact(
|
|
89
89
|
fn: (transaction: Transaction) => void,
|
|
90
|
-
origin?: any
|
|
90
|
+
origin?: any,
|
|
91
91
|
): void {
|
|
92
92
|
this.value.transact((tx) => {
|
|
93
93
|
fn(tx);
|
|
@@ -104,7 +104,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export const doc = <T extends Record<string, AbstractType<any>> = {}>(
|
|
107
|
-
value?: T
|
|
107
|
+
value?: T,
|
|
108
108
|
): YjsDoc<T> => {
|
|
109
109
|
return new YjsDoc(value);
|
|
110
110
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
export type { AbstractType, Array, Map, Text } from "yjs";
|
|
2
2
|
export { array } from "./array";
|
|
3
|
-
export {
|
|
3
|
+
export { YjsDoc, doc } from "./doc";
|
|
4
4
|
export { map } from "./map";
|
|
5
|
-
export type { unstable__YObject } from "./object";
|
|
6
5
|
export { object } from "./object";
|
|
6
|
+
export type { YObject, YObjectValue } from "./object";
|
|
7
7
|
export { text } from "./text";
|
|
8
|
-
export type { XmlElementParams } from "./xmlElement";
|
|
9
|
-
export { xmlElement } from "./xmlElement";
|
|
10
|
-
export type { XmlFragmentParams } from "./xmlFragment";
|
|
11
|
-
export { xmlFragment } from "./xmlFragment";
|
|
12
|
-
export { xmlText } from "./xmlText";
|
|
13
8
|
export type {
|
|
14
9
|
InferYjsDocJson,
|
|
15
10
|
InferYjsDocSharedType,
|
|
@@ -17,3 +12,8 @@ export type {
|
|
|
17
12
|
InferYjsDocSharedTypes,
|
|
18
13
|
InferYjsSharedTypeJson,
|
|
19
14
|
} from "./types";
|
|
15
|
+
export { xmlElement } from "./xmlElement";
|
|
16
|
+
export type { XmlElementParams } from "./xmlElement";
|
|
17
|
+
export { xmlFragment } from "./xmlFragment";
|
|
18
|
+
export type { XmlFragmentParams } from "./xmlFragment";
|
|
19
|
+
export { xmlText } from "./xmlText";
|
package/src/map.ts
CHANGED
package/src/object.ts
CHANGED
|
@@ -2,17 +2,15 @@ import type { JsonPrimitive } from "@pluv/types";
|
|
|
2
2
|
import type { AbstractType } from "yjs";
|
|
3
3
|
import { Map as YMap } from "yjs";
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type YObjectValue = Record<
|
|
6
6
|
string,
|
|
7
7
|
NonNullable<JsonPrimitive> | AbstractType<any>
|
|
8
8
|
>;
|
|
9
9
|
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export type YObject<T extends YObjectValue> = YMap<T[keyof T]> & {
|
|
11
|
+
__$type: T;
|
|
12
|
+
};
|
|
13
13
|
|
|
14
|
-
export const object = <T extends
|
|
15
|
-
value
|
|
16
|
-
): unstable__YObject<T> => {
|
|
17
|
-
return new YMap(Object.entries(value)) as unstable__YObject<T>;
|
|
14
|
+
export const object = <T extends YObjectValue = {}>(value: T): YObject<T> => {
|
|
15
|
+
return new YMap(Object.entries(value)) as YObject<T>;
|
|
18
16
|
};
|
package/src/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
XmlText as YXmlText,
|
|
9
9
|
} from "yjs";
|
|
10
10
|
import type { YjsDoc } from "./doc";
|
|
11
|
-
import type {
|
|
11
|
+
import type { YObject } from "./object";
|
|
12
12
|
|
|
13
13
|
export type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<
|
|
14
14
|
infer ITypes
|
|
@@ -18,12 +18,14 @@ export type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<
|
|
|
18
18
|
|
|
19
19
|
export type InferYjsDocSharedType<
|
|
20
20
|
TDoc extends YjsDoc<any>,
|
|
21
|
-
TKey extends
|
|
21
|
+
TKey extends
|
|
22
|
+
keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>,
|
|
22
23
|
> = InferYjsDocSharedTypes<TDoc>[TKey];
|
|
23
24
|
|
|
24
25
|
export type InferYjsDocSharedTypeJson<
|
|
25
26
|
TDoc extends YjsDoc<any>,
|
|
26
|
-
TKey extends
|
|
27
|
+
TKey extends
|
|
28
|
+
keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>,
|
|
27
29
|
> = InferYjsSharedTypeJson<InferYjsDocSharedTypes<TDoc>[TKey]>;
|
|
28
30
|
|
|
29
31
|
export type InferYjsDocSharedTypes<TDoc extends YjsDoc<any>> =
|
|
@@ -33,7 +35,7 @@ export type InferYjsSharedTypeJson<TShared extends unknown> =
|
|
|
33
35
|
TShared extends AbstractType<any>
|
|
34
36
|
? TShared extends YArray<infer IItem>
|
|
35
37
|
? readonly InferYjsSharedTypeJson<IItem>[]
|
|
36
|
-
: TShared extends
|
|
38
|
+
: TShared extends YObject<infer IObject>
|
|
37
39
|
? { [P in keyof IObject]: InferYjsSharedTypeJson<IObject[P]> }
|
|
38
40
|
: TShared extends YMap<infer IItem>
|
|
39
41
|
? Record<string, InferYjsSharedTypeJson<IItem>>
|