@pluv/crdt 0.19.0 → 0.21.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/.turbo/turbo-build.log +15 -15
- package/CHANGELOG.md +81 -0
- package/dist/index.d.mts +12 -13
- package/dist/index.d.ts +12 -13
- package/dist/index.js +0 -6
- package/dist/index.mjs +0 -5
- package/package.json +6 -6
- package/src/AbstractCrdtDoc.ts +5 -5
- package/src/AbstractCrdtDocFactory.ts +3 -3
- package/src/index.ts +1 -2
- package/src/types.ts +12 -9
- package/src/AbstractCrdtType.ts +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt@0.
|
|
2
|
+
> @pluv/crdt@0.21.0 build /home/runner/work/pluv/pluv/packages/crdt
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.2.4
|
|
8
|
+
[34mCLI[39m Target: es6
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[34mCJS[39m Build start
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m1.26 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 25ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m2.42 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 24ms
|
|
15
|
+
[34mDTS[39m Build start
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 512ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.22 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.22 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @pluv/crdt
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/types@0.21.0
|
|
8
|
+
|
|
9
|
+
## 0.20.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 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.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// Before
|
|
21
|
+
|
|
22
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
23
|
+
|
|
24
|
+
yjs.array([]); // Returns CrdtYjsArray
|
|
25
|
+
yjs.object([]); // Returns CrdtYjsObject
|
|
26
|
+
|
|
27
|
+
const room: PluvRoom = /* ... */;
|
|
28
|
+
|
|
29
|
+
room.getStorage("messages"); // Returns AbstractCrdtType
|
|
30
|
+
|
|
31
|
+
const [, sharedType] = useStorage("messages"); // sharedType is an AbstractCrdtType
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
// Now
|
|
36
|
+
|
|
37
|
+
import { yjs } from "@pluv/crdt-yjs";
|
|
38
|
+
|
|
39
|
+
yjs.array([]); // Returns yjs.Array
|
|
40
|
+
yjs.object([]); // Returns yjs.Map
|
|
41
|
+
|
|
42
|
+
const room: PluvRoom = /* ... */;
|
|
43
|
+
|
|
44
|
+
room.getStorage("messages"); // Returns yjs.AbstractType
|
|
45
|
+
|
|
46
|
+
const [, sharedType] = useStorage("messages"); // sharedType is a yjs.AbstractType
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
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:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Before
|
|
53
|
+
|
|
54
|
+
const [data, container] = useStorage("messages");
|
|
55
|
+
|
|
56
|
+
// This automatically called Loro.commit under the hood and rerendered the page with updated data.
|
|
57
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// Now
|
|
62
|
+
|
|
63
|
+
const [data, container] = useStorage("messages");
|
|
64
|
+
|
|
65
|
+
const doc = useDoc();
|
|
66
|
+
const transact = useTransact();
|
|
67
|
+
|
|
68
|
+
// Updates need to be committed back to the doc whenever the changes need to be emitted to other users
|
|
69
|
+
// The returned data also will not update until the changes are commited
|
|
70
|
+
|
|
71
|
+
// The two operations below are functionally equivalent
|
|
72
|
+
transact(() => {
|
|
73
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
container.push(loro.object({ name: "John Doe", age: 35 }));
|
|
77
|
+
doc.value.commit();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- @pluv/types@0.20.0
|
|
83
|
+
|
|
3
84
|
## 0.19.0
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { Json } from '@pluv/types';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
abstract toJson(): InferCrdtStorageJson<TJson>;
|
|
10
|
-
}
|
|
3
|
+
type CrdtType<TValue extends unknown, TJson extends unknown = any> = Omit<TValue, "__pluvType"> & {
|
|
4
|
+
__pluvType: () => TJson;
|
|
5
|
+
};
|
|
6
|
+
type InferCrdtJson<T extends unknown> = T extends CrdtType<any, infer IJson> ? InferCrdtJson<IJson> : T extends Record<string, any> ? {
|
|
7
|
+
[P in keyof T]: InferCrdtJson<T[P]>;
|
|
8
|
+
} : T extends (infer IJson)[] ? InferCrdtJson<IJson>[] : T extends readonly (infer IJson)[] ? readonly InferCrdtJson<IJson>[] : T extends Json ? T : string;
|
|
11
9
|
|
|
12
10
|
interface DocApplyEncodedStateParams {
|
|
13
11
|
origin?: string;
|
|
14
12
|
update?: string | Uint8Array;
|
|
15
13
|
}
|
|
16
|
-
interface DocSubscribeCallbackParams<T extends Record<string,
|
|
14
|
+
interface DocSubscribeCallbackParams<T extends Record<string, CrdtType<any, any>>> {
|
|
17
15
|
doc: AbstractCrdtDoc<T>;
|
|
18
16
|
local: boolean;
|
|
19
17
|
origin?: string | null;
|
|
20
18
|
update: string;
|
|
21
19
|
}
|
|
22
|
-
declare abstract class AbstractCrdtDoc<T extends Record<string,
|
|
20
|
+
declare abstract class AbstractCrdtDoc<T extends Record<string, CrdtType<any, any>>> {
|
|
23
21
|
abstract applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
24
22
|
abstract batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
|
|
25
23
|
abstract canRedo(): boolean;
|
|
@@ -31,13 +29,14 @@ declare abstract class AbstractCrdtDoc<T extends Record<string, AbstractCrdtType
|
|
|
31
29
|
abstract isEmpty(): boolean;
|
|
32
30
|
abstract redo(): this;
|
|
33
31
|
abstract subscribe(listener: (params: DocSubscribeCallbackParams<T>) => void): () => void;
|
|
34
|
-
abstract toJson():
|
|
32
|
+
abstract toJson(): InferCrdtJson<T>;
|
|
33
|
+
abstract toJson<TKey extends keyof T>(type: TKey): InferCrdtJson<T[TKey]>;
|
|
35
34
|
abstract track(): this;
|
|
36
35
|
abstract transact(fn: () => void, origin?: string): this;
|
|
37
36
|
abstract undo(): this;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
declare abstract class AbstractCrdtDocFactory<TStorage extends Record<string,
|
|
39
|
+
declare abstract class AbstractCrdtDocFactory<TStorage extends Record<string, CrdtType<any, any>>> {
|
|
41
40
|
abstract getEmpty(): AbstractCrdtDoc<TStorage>;
|
|
42
41
|
abstract getFactory(initialStorage?: () => TStorage): AbstractCrdtDocFactory<TStorage>;
|
|
43
42
|
abstract getFresh(): AbstractCrdtDoc<TStorage>;
|
|
@@ -73,4 +72,4 @@ declare const noop: {
|
|
|
73
72
|
doc: (args?: any) => NoopCrdtDocFactory;
|
|
74
73
|
};
|
|
75
74
|
|
|
76
|
-
export { AbstractCrdtDoc, AbstractCrdtDocFactory,
|
|
75
|
+
export { AbstractCrdtDoc, AbstractCrdtDocFactory, type CrdtType, type DocApplyEncodedStateParams, type DocSubscribeCallbackParams, type InferCrdtJson, NoopCrdtDoc, NoopCrdtDocFactory, noop };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { Json } from '@pluv/types';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
abstract toJson(): InferCrdtStorageJson<TJson>;
|
|
10
|
-
}
|
|
3
|
+
type CrdtType<TValue extends unknown, TJson extends unknown = any> = Omit<TValue, "__pluvType"> & {
|
|
4
|
+
__pluvType: () => TJson;
|
|
5
|
+
};
|
|
6
|
+
type InferCrdtJson<T extends unknown> = T extends CrdtType<any, infer IJson> ? InferCrdtJson<IJson> : T extends Record<string, any> ? {
|
|
7
|
+
[P in keyof T]: InferCrdtJson<T[P]>;
|
|
8
|
+
} : T extends (infer IJson)[] ? InferCrdtJson<IJson>[] : T extends readonly (infer IJson)[] ? readonly InferCrdtJson<IJson>[] : T extends Json ? T : string;
|
|
11
9
|
|
|
12
10
|
interface DocApplyEncodedStateParams {
|
|
13
11
|
origin?: string;
|
|
14
12
|
update?: string | Uint8Array;
|
|
15
13
|
}
|
|
16
|
-
interface DocSubscribeCallbackParams<T extends Record<string,
|
|
14
|
+
interface DocSubscribeCallbackParams<T extends Record<string, CrdtType<any, any>>> {
|
|
17
15
|
doc: AbstractCrdtDoc<T>;
|
|
18
16
|
local: boolean;
|
|
19
17
|
origin?: string | null;
|
|
20
18
|
update: string;
|
|
21
19
|
}
|
|
22
|
-
declare abstract class AbstractCrdtDoc<T extends Record<string,
|
|
20
|
+
declare abstract class AbstractCrdtDoc<T extends Record<string, CrdtType<any, any>>> {
|
|
23
21
|
abstract applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
24
22
|
abstract batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
|
|
25
23
|
abstract canRedo(): boolean;
|
|
@@ -31,13 +29,14 @@ declare abstract class AbstractCrdtDoc<T extends Record<string, AbstractCrdtType
|
|
|
31
29
|
abstract isEmpty(): boolean;
|
|
32
30
|
abstract redo(): this;
|
|
33
31
|
abstract subscribe(listener: (params: DocSubscribeCallbackParams<T>) => void): () => void;
|
|
34
|
-
abstract toJson():
|
|
32
|
+
abstract toJson(): InferCrdtJson<T>;
|
|
33
|
+
abstract toJson<TKey extends keyof T>(type: TKey): InferCrdtJson<T[TKey]>;
|
|
35
34
|
abstract track(): this;
|
|
36
35
|
abstract transact(fn: () => void, origin?: string): this;
|
|
37
36
|
abstract undo(): this;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
declare abstract class AbstractCrdtDocFactory<TStorage extends Record<string,
|
|
39
|
+
declare abstract class AbstractCrdtDocFactory<TStorage extends Record<string, CrdtType<any, any>>> {
|
|
41
40
|
abstract getEmpty(): AbstractCrdtDoc<TStorage>;
|
|
42
41
|
abstract getFactory(initialStorage?: () => TStorage): AbstractCrdtDocFactory<TStorage>;
|
|
43
42
|
abstract getFresh(): AbstractCrdtDoc<TStorage>;
|
|
@@ -73,4 +72,4 @@ declare const noop: {
|
|
|
73
72
|
doc: (args?: any) => NoopCrdtDocFactory;
|
|
74
73
|
};
|
|
75
74
|
|
|
76
|
-
export { AbstractCrdtDoc, AbstractCrdtDocFactory,
|
|
75
|
+
export { AbstractCrdtDoc, AbstractCrdtDocFactory, type CrdtType, type DocApplyEncodedStateParams, type DocSubscribeCallbackParams, type InferCrdtJson, NoopCrdtDoc, NoopCrdtDocFactory, noop };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
AbstractCrdtDoc: () => AbstractCrdtDoc,
|
|
24
24
|
AbstractCrdtDocFactory: () => AbstractCrdtDocFactory,
|
|
25
|
-
AbstractCrdtType: () => AbstractCrdtType,
|
|
26
25
|
NoopCrdtDoc: () => NoopCrdtDoc,
|
|
27
26
|
NoopCrdtDocFactory: () => NoopCrdtDocFactory,
|
|
28
27
|
noop: () => noop
|
|
@@ -37,10 +36,6 @@ var AbstractCrdtDoc = class {
|
|
|
37
36
|
var AbstractCrdtDocFactory = class {
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
// src/AbstractCrdtType.ts
|
|
41
|
-
var AbstractCrdtType = class {
|
|
42
|
-
};
|
|
43
|
-
|
|
44
39
|
// src/NoopCrdtDoc.ts
|
|
45
40
|
var NoopCrdtDoc = class extends AbstractCrdtDoc {
|
|
46
41
|
applyEncodedState(params) {
|
|
@@ -112,7 +107,6 @@ var noop = {
|
|
|
112
107
|
0 && (module.exports = {
|
|
113
108
|
AbstractCrdtDoc,
|
|
114
109
|
AbstractCrdtDocFactory,
|
|
115
|
-
AbstractCrdtType,
|
|
116
110
|
NoopCrdtDoc,
|
|
117
111
|
NoopCrdtDocFactory,
|
|
118
112
|
noop
|
package/dist/index.mjs
CHANGED
|
@@ -6,10 +6,6 @@ var AbstractCrdtDoc = class {
|
|
|
6
6
|
var AbstractCrdtDocFactory = class {
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
// src/AbstractCrdtType.ts
|
|
10
|
-
var AbstractCrdtType = class {
|
|
11
|
-
};
|
|
12
|
-
|
|
13
9
|
// src/NoopCrdtDoc.ts
|
|
14
10
|
var NoopCrdtDoc = class extends AbstractCrdtDoc {
|
|
15
11
|
applyEncodedState(params) {
|
|
@@ -80,7 +76,6 @@ var noop = {
|
|
|
80
76
|
export {
|
|
81
77
|
AbstractCrdtDoc,
|
|
82
78
|
AbstractCrdtDocFactory,
|
|
83
|
-
AbstractCrdtType,
|
|
84
79
|
NoopCrdtDoc,
|
|
85
80
|
NoopCrdtDocFactory,
|
|
86
81
|
noop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "crdt base for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@pluv/types": "^0.
|
|
20
|
+
"@pluv/types": "^0.21.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"eslint": "^8.57.0",
|
|
24
|
-
"tsup": "^8.
|
|
25
|
-
"typescript": "^5.4
|
|
26
|
-
"@pluv/tsconfig": "^0.
|
|
27
|
-
"eslint-config-pluv": "^0.
|
|
24
|
+
"tsup": "^8.2.4",
|
|
25
|
+
"typescript": "^5.5.4",
|
|
26
|
+
"@pluv/tsconfig": "^0.21.0",
|
|
27
|
+
"eslint-config-pluv": "^0.21.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/AbstractCrdtDoc.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { InferCrdtStorageJson } from "./types";
|
|
1
|
+
import type { CrdtType, InferCrdtJson } from "./types";
|
|
3
2
|
|
|
4
3
|
export interface DocApplyEncodedStateParams {
|
|
5
4
|
origin?: string;
|
|
6
5
|
update?: string | Uint8Array;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
export interface DocSubscribeCallbackParams<T extends Record<string,
|
|
8
|
+
export interface DocSubscribeCallbackParams<T extends Record<string, CrdtType<any, any>>> {
|
|
10
9
|
doc: AbstractCrdtDoc<T>;
|
|
11
10
|
local: boolean;
|
|
12
11
|
origin?: string | null;
|
|
13
12
|
update: string;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export abstract class AbstractCrdtDoc<T extends Record<string,
|
|
15
|
+
export abstract class AbstractCrdtDoc<T extends Record<string, CrdtType<any, any>>> {
|
|
17
16
|
public abstract applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
18
17
|
public abstract batchApplyEncodedState(
|
|
19
18
|
updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[],
|
|
@@ -27,7 +26,8 @@ export abstract class AbstractCrdtDoc<T extends Record<string, AbstractCrdtType<
|
|
|
27
26
|
public abstract isEmpty(): boolean;
|
|
28
27
|
public abstract redo(): this;
|
|
29
28
|
public abstract subscribe(listener: (params: DocSubscribeCallbackParams<T>) => void): () => void;
|
|
30
|
-
public abstract toJson():
|
|
29
|
+
public abstract toJson(): InferCrdtJson<T>;
|
|
30
|
+
public abstract toJson<TKey extends keyof T>(type: TKey): InferCrdtJson<T[TKey]>;
|
|
31
31
|
public abstract track(): this;
|
|
32
32
|
public abstract transact(fn: () => void, origin?: string): this;
|
|
33
33
|
public abstract undo(): this;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AbstractCrdtDoc } from "./AbstractCrdtDoc";
|
|
2
|
-
import type {
|
|
1
|
+
import type { AbstractCrdtDoc } from "./AbstractCrdtDoc";
|
|
2
|
+
import type { CrdtType } from "./types";
|
|
3
3
|
|
|
4
|
-
export abstract class AbstractCrdtDocFactory<TStorage extends Record<string,
|
|
4
|
+
export abstract class AbstractCrdtDocFactory<TStorage extends Record<string, CrdtType<any, any>>> {
|
|
5
5
|
public abstract getEmpty(): AbstractCrdtDoc<TStorage>;
|
|
6
6
|
public abstract getFactory(initialStorage?: () => TStorage): AbstractCrdtDocFactory<TStorage>;
|
|
7
7
|
public abstract getFresh(): AbstractCrdtDoc<TStorage>;
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { AbstractCrdtDoc } from "./AbstractCrdtDoc";
|
|
2
2
|
export type { DocApplyEncodedStateParams, DocSubscribeCallbackParams } from "./AbstractCrdtDoc";
|
|
3
3
|
export { AbstractCrdtDocFactory } from "./AbstractCrdtDocFactory";
|
|
4
|
-
export { AbstractCrdtType } from "./AbstractCrdtType";
|
|
5
4
|
export { NoopCrdtDoc } from "./NoopCrdtDoc";
|
|
6
5
|
export { NoopCrdtDocFactory } from "./NoopCrdtDocFactory";
|
|
7
6
|
export { noop } from "./noop";
|
|
8
|
-
export type {
|
|
7
|
+
export type { CrdtType, InferCrdtJson } from "./types";
|
package/src/types.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { Json } from "@pluv/types";
|
|
2
|
-
import type { AbstractCrdtType } from "./AbstractCrdtType";
|
|
3
2
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export type CrdtType<TValue extends unknown, TJson extends unknown = any> = Omit<TValue, "__pluvType"> & {
|
|
4
|
+
__pluvType: () => TJson;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type InferCrdtJson<T extends unknown> =
|
|
8
|
+
T extends CrdtType<any, infer IJson>
|
|
9
|
+
? InferCrdtJson<IJson>
|
|
7
10
|
: T extends Record<string, any>
|
|
8
|
-
? { [P in keyof T]:
|
|
9
|
-
: T extends (infer
|
|
10
|
-
?
|
|
11
|
-
: T extends readonly (infer
|
|
12
|
-
?
|
|
11
|
+
? { [P in keyof T]: InferCrdtJson<T[P]> }
|
|
12
|
+
: T extends (infer IJson)[]
|
|
13
|
+
? InferCrdtJson<IJson>[]
|
|
14
|
+
: T extends readonly (infer IJson)[]
|
|
15
|
+
? readonly InferCrdtJson<IJson>[]
|
|
13
16
|
: T extends Json
|
|
14
17
|
? T
|
|
15
18
|
: string;
|
package/src/AbstractCrdtType.ts
DELETED