@pluv/crdt-loro 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 +4 -0
- package/.turbo/turbo-build.log +18 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/dist/index.d.mts +164 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +701 -0
- package/dist/index.mjs +681 -0
- package/package.json +41 -0
- package/src/array/CrdtLoroArray.ts +102 -0
- package/src/array/array.ts +7 -0
- package/src/array/index.ts +2 -0
- package/src/doc/CrdtLoroDoc.ts +239 -0
- package/src/doc/CrdtLoroDocFactory.ts +65 -0
- package/src/doc/doc.ts +10 -0
- package/src/doc/index.ts +3 -0
- package/src/index.ts +1 -0
- package/src/loro.ts +6 -0
- package/src/map/CrdtLoroMap.ts +90 -0
- package/src/map/index.ts +2 -0
- package/src/map/map.ts +7 -0
- package/src/object/CrdtLoroObject.ts +79 -0
- package/src/object/index.ts +2 -0
- package/src/object/object.ts +7 -0
- package/src/shared/cloneType.ts +238 -0
- package/src/shared/getLoroContainerType.ts +22 -0
- package/src/shared/index.ts +5 -0
- package/src/shared/isWrapper.ts +19 -0
- package/src/shared/toLoroValue.ts +5 -0
- package/src/text/CrdtLoroText.ts +68 -0
- package/src/text/index.ts +2 -0
- package/src/text/text.ts +5 -0
- package/src/types.ts +40 -0
- package/tsconfig.json +8 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
> @pluv/crdt-loro@0.16.0 build /home/runner/work/pluv/pluv/packages/crdt-loro
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.0.2
|
|
8
|
+
[34mCLI[39m Target: es6
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[34mCJS[39m Build start
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m18.48 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 118ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m19.50 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 122ms
|
|
15
|
+
[34mDTS[39m Build start
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 2541ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.04 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.04 KB[39m
|
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Shoubhit Dash
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { AbstractCrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, InferCrdtStorageJson, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
2
|
+
import { Loro, LoroMap, LoroText, LoroList } from 'loro-crdt';
|
|
3
|
+
import { Json } from '@pluv/types';
|
|
4
|
+
|
|
5
|
+
declare class CrdtLoroDoc<TStorage extends Record<string, AbstractCrdtType<any, any>>> extends AbstractCrdtDoc<TStorage> {
|
|
6
|
+
value: Loro;
|
|
7
|
+
private _storage;
|
|
8
|
+
constructor(value?: TStorage);
|
|
9
|
+
applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
10
|
+
batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
|
|
11
|
+
/**
|
|
12
|
+
* TODO
|
|
13
|
+
* @description This method is not yet supported for loro
|
|
14
|
+
*/
|
|
15
|
+
canRedo(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* TODO
|
|
18
|
+
* @description This method is not yet supported for loro
|
|
19
|
+
*/
|
|
20
|
+
canUndo(): boolean;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
get(key?: undefined): TStorage;
|
|
23
|
+
get<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
|
|
24
|
+
getEncodedState(): string;
|
|
25
|
+
toJson(): InferCrdtStorageJson<TStorage>;
|
|
26
|
+
isEmpty(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* TODO
|
|
29
|
+
* @description This method is not yet supported for loro
|
|
30
|
+
*/
|
|
31
|
+
redo(): this;
|
|
32
|
+
subscribe(listener: (params: DocSubscribeCallbackParams<TStorage>) => void): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* TODO
|
|
35
|
+
* @description This method doesn't do anything yet.
|
|
36
|
+
*/
|
|
37
|
+
track(): this;
|
|
38
|
+
/**
|
|
39
|
+
* TODO
|
|
40
|
+
* @description This method doesn't do anything yet. The callback will still be executed.
|
|
41
|
+
*/
|
|
42
|
+
transact(fn: () => void): this;
|
|
43
|
+
/**
|
|
44
|
+
* TODO
|
|
45
|
+
* @description This method is not yet supported for loro
|
|
46
|
+
*/
|
|
47
|
+
undo(): this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class CrdtLoroMap<T extends unknown> extends AbstractCrdtType<LoroMap<Record<string, T>>, Record<string, InferLoroJson<T>>> {
|
|
51
|
+
readonly initialValue: readonly (readonly [key: string, value: T])[];
|
|
52
|
+
private _doc;
|
|
53
|
+
private _initialized;
|
|
54
|
+
private _value;
|
|
55
|
+
constructor(value?: readonly (readonly [key: string, value: T])[]);
|
|
56
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
57
|
+
get size(): number;
|
|
58
|
+
get value(): LoroMap<Record<string, T>>;
|
|
59
|
+
set value(value: LoroMap<Record<string, T>>);
|
|
60
|
+
delete(prop: string): this;
|
|
61
|
+
set(prop: string, value: T): this;
|
|
62
|
+
toJson(): InferCrdtStorageJson<Record<string, InferLoroJson<T>>>;
|
|
63
|
+
private _guardInitialized;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => CrdtLoroMap<T>;
|
|
67
|
+
|
|
68
|
+
declare class CrdtLoroObject<T extends Record<string, any>> extends AbstractCrdtType<LoroMap<T>, InferLoroJson<T>> {
|
|
69
|
+
readonly initialValue: readonly (readonly [key: string, value: T])[];
|
|
70
|
+
private _doc;
|
|
71
|
+
private _initialized;
|
|
72
|
+
private _value;
|
|
73
|
+
constructor(value: T);
|
|
74
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
75
|
+
get size(): number;
|
|
76
|
+
get value(): LoroMap<T>;
|
|
77
|
+
set value(value: LoroMap<T>);
|
|
78
|
+
set(prop: string, value: T): this;
|
|
79
|
+
toJson(): InferCrdtStorageJson<InferLoroJson<T>>;
|
|
80
|
+
private _guardInitialized;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare const object: <T extends Record<string, any>>(value: T) => CrdtLoroObject<T>;
|
|
84
|
+
|
|
85
|
+
declare class CrdtLoroText extends AbstractCrdtType<LoroText, string> {
|
|
86
|
+
initalValue: string;
|
|
87
|
+
private _doc;
|
|
88
|
+
private _initialized;
|
|
89
|
+
private _value;
|
|
90
|
+
constructor(value?: string);
|
|
91
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
92
|
+
get length(): number;
|
|
93
|
+
get value(): LoroText;
|
|
94
|
+
set value(value: LoroText);
|
|
95
|
+
delete(index: number, length?: number): this;
|
|
96
|
+
insert(index: number, text: string): this;
|
|
97
|
+
toJson(): string;
|
|
98
|
+
private _guardInitialized;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare const text: (value?: string) => CrdtLoroText;
|
|
102
|
+
|
|
103
|
+
type InferLoroType<T extends unknown> = T extends CrdtLoroArray<infer IType> ? LoroList<IType[]> : T extends CrdtLoroMap<infer IType> ? LoroMap<Record<string, IType>> : T extends CrdtLoroObject<infer IType> ? LoroMap<IType> : T extends CrdtLoroText ? LoroText : T extends Json ? T : never;
|
|
104
|
+
type InferLoroJson<T extends unknown> = T extends CrdtLoroArray<infer IType> ? InferLoroJson<IType>[] : T extends CrdtLoroMap<infer IType> ? Record<string, InferLoroJson<IType>> : T extends CrdtLoroObject<infer IType> ? {
|
|
105
|
+
[P in keyof IType]: InferLoroJson<IType[P]>;
|
|
106
|
+
} : T extends CrdtLoroText | LoroText ? string : T extends LoroList<infer IType> ? InferLoroJson<IType> : T extends LoroMap<infer IType> ? {
|
|
107
|
+
[P in keyof IType]: InferLoroJson<IType[P]>;
|
|
108
|
+
} : T extends (infer IType)[] ? InferLoroJson<IType>[] : T extends Record<any, any> ? {
|
|
109
|
+
[P in keyof T]: InferLoroJson<T[P]>;
|
|
110
|
+
} : T extends Json ? T : never;
|
|
111
|
+
|
|
112
|
+
declare class CrdtLoroArray<T extends unknown> extends AbstractCrdtType<LoroList<T[]>, InferLoroJson<T>[]> {
|
|
113
|
+
readonly initialValue: T[] | readonly T[];
|
|
114
|
+
private _doc;
|
|
115
|
+
private _initialized;
|
|
116
|
+
private _value;
|
|
117
|
+
constructor(value?: T[] | readonly T[]);
|
|
118
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
119
|
+
get length(): number;
|
|
120
|
+
get value(): LoroList<T[]>;
|
|
121
|
+
set value(value: LoroList<T[]>);
|
|
122
|
+
delete(index: number, length?: number): this;
|
|
123
|
+
insert(index: number, ...items: T[]): this;
|
|
124
|
+
push(...items: T[]): this;
|
|
125
|
+
unshift(...items: T[]): this;
|
|
126
|
+
toJson(): InferCrdtStorageJson<InferLoroJson<T>>[];
|
|
127
|
+
private _guardInitialized;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare const array: <T extends unknown>(value?: T[] | readonly T[]) => CrdtLoroArray<T>;
|
|
131
|
+
|
|
132
|
+
declare class CrdtLoroDocFactory<TStorage extends Record<string, AbstractCrdtType<any, any>>> extends AbstractCrdtDocFactory<TStorage> {
|
|
133
|
+
private _initialStorage;
|
|
134
|
+
constructor(initialStorage?: () => TStorage);
|
|
135
|
+
getEmpty(): CrdtLoroDoc<TStorage>;
|
|
136
|
+
getFactory(initialStorage?: (() => TStorage) | undefined): CrdtLoroDocFactory<TStorage>;
|
|
137
|
+
getFresh(): CrdtLoroDoc<TStorage>;
|
|
138
|
+
getInitialized(initialStorage?: () => TStorage): CrdtLoroDoc<TStorage>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare const doc: <TStorage extends Record<string, AbstractCrdtType<any, any>>>(value?: () => TStorage) => CrdtLoroDocFactory<TStorage>;
|
|
142
|
+
|
|
143
|
+
type loro_CrdtLoroArray<T extends unknown> = CrdtLoroArray<T>;
|
|
144
|
+
declare const loro_CrdtLoroArray: typeof CrdtLoroArray;
|
|
145
|
+
type loro_CrdtLoroDoc<TStorage extends Record<string, AbstractCrdtType<any, any>>> = CrdtLoroDoc<TStorage>;
|
|
146
|
+
declare const loro_CrdtLoroDoc: typeof CrdtLoroDoc;
|
|
147
|
+
type loro_CrdtLoroMap<T extends unknown> = CrdtLoroMap<T>;
|
|
148
|
+
declare const loro_CrdtLoroMap: typeof CrdtLoroMap;
|
|
149
|
+
type loro_CrdtLoroObject<T extends Record<string, any>> = CrdtLoroObject<T>;
|
|
150
|
+
declare const loro_CrdtLoroObject: typeof CrdtLoroObject;
|
|
151
|
+
type loro_CrdtLoroText = CrdtLoroText;
|
|
152
|
+
declare const loro_CrdtLoroText: typeof CrdtLoroText;
|
|
153
|
+
type loro_InferLoroJson<T extends unknown> = InferLoroJson<T>;
|
|
154
|
+
type loro_InferLoroType<T extends unknown> = InferLoroType<T>;
|
|
155
|
+
declare const loro_array: typeof array;
|
|
156
|
+
declare const loro_doc: typeof doc;
|
|
157
|
+
declare const loro_map: typeof map;
|
|
158
|
+
declare const loro_object: typeof object;
|
|
159
|
+
declare const loro_text: typeof text;
|
|
160
|
+
declare namespace loro {
|
|
161
|
+
export { loro_CrdtLoroArray as CrdtLoroArray, loro_CrdtLoroDoc as CrdtLoroDoc, loro_CrdtLoroMap as CrdtLoroMap, loro_CrdtLoroObject as CrdtLoroObject, loro_CrdtLoroText as CrdtLoroText, type loro_InferLoroJson as InferLoroJson, type loro_InferLoroType as InferLoroType, loro_array as array, loro_doc as doc, loro_map as map, loro_object as object, loro_text as text };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { loro };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { AbstractCrdtType, AbstractCrdtDoc, DocApplyEncodedStateParams, InferCrdtStorageJson, DocSubscribeCallbackParams, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
2
|
+
import { Loro, LoroMap, LoroText, LoroList } from 'loro-crdt';
|
|
3
|
+
import { Json } from '@pluv/types';
|
|
4
|
+
|
|
5
|
+
declare class CrdtLoroDoc<TStorage extends Record<string, AbstractCrdtType<any, any>>> extends AbstractCrdtDoc<TStorage> {
|
|
6
|
+
value: Loro;
|
|
7
|
+
private _storage;
|
|
8
|
+
constructor(value?: TStorage);
|
|
9
|
+
applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
10
|
+
batchApplyEncodedState(updates: readonly (DocApplyEncodedStateParams | string | null | undefined)[]): this;
|
|
11
|
+
/**
|
|
12
|
+
* TODO
|
|
13
|
+
* @description This method is not yet supported for loro
|
|
14
|
+
*/
|
|
15
|
+
canRedo(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* TODO
|
|
18
|
+
* @description This method is not yet supported for loro
|
|
19
|
+
*/
|
|
20
|
+
canUndo(): boolean;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
get(key?: undefined): TStorage;
|
|
23
|
+
get<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
|
|
24
|
+
getEncodedState(): string;
|
|
25
|
+
toJson(): InferCrdtStorageJson<TStorage>;
|
|
26
|
+
isEmpty(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* TODO
|
|
29
|
+
* @description This method is not yet supported for loro
|
|
30
|
+
*/
|
|
31
|
+
redo(): this;
|
|
32
|
+
subscribe(listener: (params: DocSubscribeCallbackParams<TStorage>) => void): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* TODO
|
|
35
|
+
* @description This method doesn't do anything yet.
|
|
36
|
+
*/
|
|
37
|
+
track(): this;
|
|
38
|
+
/**
|
|
39
|
+
* TODO
|
|
40
|
+
* @description This method doesn't do anything yet. The callback will still be executed.
|
|
41
|
+
*/
|
|
42
|
+
transact(fn: () => void): this;
|
|
43
|
+
/**
|
|
44
|
+
* TODO
|
|
45
|
+
* @description This method is not yet supported for loro
|
|
46
|
+
*/
|
|
47
|
+
undo(): this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class CrdtLoroMap<T extends unknown> extends AbstractCrdtType<LoroMap<Record<string, T>>, Record<string, InferLoroJson<T>>> {
|
|
51
|
+
readonly initialValue: readonly (readonly [key: string, value: T])[];
|
|
52
|
+
private _doc;
|
|
53
|
+
private _initialized;
|
|
54
|
+
private _value;
|
|
55
|
+
constructor(value?: readonly (readonly [key: string, value: T])[]);
|
|
56
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
57
|
+
get size(): number;
|
|
58
|
+
get value(): LoroMap<Record<string, T>>;
|
|
59
|
+
set value(value: LoroMap<Record<string, T>>);
|
|
60
|
+
delete(prop: string): this;
|
|
61
|
+
set(prop: string, value: T): this;
|
|
62
|
+
toJson(): InferCrdtStorageJson<Record<string, InferLoroJson<T>>>;
|
|
63
|
+
private _guardInitialized;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => CrdtLoroMap<T>;
|
|
67
|
+
|
|
68
|
+
declare class CrdtLoroObject<T extends Record<string, any>> extends AbstractCrdtType<LoroMap<T>, InferLoroJson<T>> {
|
|
69
|
+
readonly initialValue: readonly (readonly [key: string, value: T])[];
|
|
70
|
+
private _doc;
|
|
71
|
+
private _initialized;
|
|
72
|
+
private _value;
|
|
73
|
+
constructor(value: T);
|
|
74
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
75
|
+
get size(): number;
|
|
76
|
+
get value(): LoroMap<T>;
|
|
77
|
+
set value(value: LoroMap<T>);
|
|
78
|
+
set(prop: string, value: T): this;
|
|
79
|
+
toJson(): InferCrdtStorageJson<InferLoroJson<T>>;
|
|
80
|
+
private _guardInitialized;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare const object: <T extends Record<string, any>>(value: T) => CrdtLoroObject<T>;
|
|
84
|
+
|
|
85
|
+
declare class CrdtLoroText extends AbstractCrdtType<LoroText, string> {
|
|
86
|
+
initalValue: string;
|
|
87
|
+
private _doc;
|
|
88
|
+
private _initialized;
|
|
89
|
+
private _value;
|
|
90
|
+
constructor(value?: string);
|
|
91
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
92
|
+
get length(): number;
|
|
93
|
+
get value(): LoroText;
|
|
94
|
+
set value(value: LoroText);
|
|
95
|
+
delete(index: number, length?: number): this;
|
|
96
|
+
insert(index: number, text: string): this;
|
|
97
|
+
toJson(): string;
|
|
98
|
+
private _guardInitialized;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare const text: (value?: string) => CrdtLoroText;
|
|
102
|
+
|
|
103
|
+
type InferLoroType<T extends unknown> = T extends CrdtLoroArray<infer IType> ? LoroList<IType[]> : T extends CrdtLoroMap<infer IType> ? LoroMap<Record<string, IType>> : T extends CrdtLoroObject<infer IType> ? LoroMap<IType> : T extends CrdtLoroText ? LoroText : T extends Json ? T : never;
|
|
104
|
+
type InferLoroJson<T extends unknown> = T extends CrdtLoroArray<infer IType> ? InferLoroJson<IType>[] : T extends CrdtLoroMap<infer IType> ? Record<string, InferLoroJson<IType>> : T extends CrdtLoroObject<infer IType> ? {
|
|
105
|
+
[P in keyof IType]: InferLoroJson<IType[P]>;
|
|
106
|
+
} : T extends CrdtLoroText | LoroText ? string : T extends LoroList<infer IType> ? InferLoroJson<IType> : T extends LoroMap<infer IType> ? {
|
|
107
|
+
[P in keyof IType]: InferLoroJson<IType[P]>;
|
|
108
|
+
} : T extends (infer IType)[] ? InferLoroJson<IType>[] : T extends Record<any, any> ? {
|
|
109
|
+
[P in keyof T]: InferLoroJson<T[P]>;
|
|
110
|
+
} : T extends Json ? T : never;
|
|
111
|
+
|
|
112
|
+
declare class CrdtLoroArray<T extends unknown> extends AbstractCrdtType<LoroList<T[]>, InferLoroJson<T>[]> {
|
|
113
|
+
readonly initialValue: T[] | readonly T[];
|
|
114
|
+
private _doc;
|
|
115
|
+
private _initialized;
|
|
116
|
+
private _value;
|
|
117
|
+
constructor(value?: T[] | readonly T[]);
|
|
118
|
+
set doc(doc: CrdtLoroDoc<any>);
|
|
119
|
+
get length(): number;
|
|
120
|
+
get value(): LoroList<T[]>;
|
|
121
|
+
set value(value: LoroList<T[]>);
|
|
122
|
+
delete(index: number, length?: number): this;
|
|
123
|
+
insert(index: number, ...items: T[]): this;
|
|
124
|
+
push(...items: T[]): this;
|
|
125
|
+
unshift(...items: T[]): this;
|
|
126
|
+
toJson(): InferCrdtStorageJson<InferLoroJson<T>>[];
|
|
127
|
+
private _guardInitialized;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare const array: <T extends unknown>(value?: T[] | readonly T[]) => CrdtLoroArray<T>;
|
|
131
|
+
|
|
132
|
+
declare class CrdtLoroDocFactory<TStorage extends Record<string, AbstractCrdtType<any, any>>> extends AbstractCrdtDocFactory<TStorage> {
|
|
133
|
+
private _initialStorage;
|
|
134
|
+
constructor(initialStorage?: () => TStorage);
|
|
135
|
+
getEmpty(): CrdtLoroDoc<TStorage>;
|
|
136
|
+
getFactory(initialStorage?: (() => TStorage) | undefined): CrdtLoroDocFactory<TStorage>;
|
|
137
|
+
getFresh(): CrdtLoroDoc<TStorage>;
|
|
138
|
+
getInitialized(initialStorage?: () => TStorage): CrdtLoroDoc<TStorage>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare const doc: <TStorage extends Record<string, AbstractCrdtType<any, any>>>(value?: () => TStorage) => CrdtLoroDocFactory<TStorage>;
|
|
142
|
+
|
|
143
|
+
type loro_CrdtLoroArray<T extends unknown> = CrdtLoroArray<T>;
|
|
144
|
+
declare const loro_CrdtLoroArray: typeof CrdtLoroArray;
|
|
145
|
+
type loro_CrdtLoroDoc<TStorage extends Record<string, AbstractCrdtType<any, any>>> = CrdtLoroDoc<TStorage>;
|
|
146
|
+
declare const loro_CrdtLoroDoc: typeof CrdtLoroDoc;
|
|
147
|
+
type loro_CrdtLoroMap<T extends unknown> = CrdtLoroMap<T>;
|
|
148
|
+
declare const loro_CrdtLoroMap: typeof CrdtLoroMap;
|
|
149
|
+
type loro_CrdtLoroObject<T extends Record<string, any>> = CrdtLoroObject<T>;
|
|
150
|
+
declare const loro_CrdtLoroObject: typeof CrdtLoroObject;
|
|
151
|
+
type loro_CrdtLoroText = CrdtLoroText;
|
|
152
|
+
declare const loro_CrdtLoroText: typeof CrdtLoroText;
|
|
153
|
+
type loro_InferLoroJson<T extends unknown> = InferLoroJson<T>;
|
|
154
|
+
type loro_InferLoroType<T extends unknown> = InferLoroType<T>;
|
|
155
|
+
declare const loro_array: typeof array;
|
|
156
|
+
declare const loro_doc: typeof doc;
|
|
157
|
+
declare const loro_map: typeof map;
|
|
158
|
+
declare const loro_object: typeof object;
|
|
159
|
+
declare const loro_text: typeof text;
|
|
160
|
+
declare namespace loro {
|
|
161
|
+
export { loro_CrdtLoroArray as CrdtLoroArray, loro_CrdtLoroDoc as CrdtLoroDoc, loro_CrdtLoroMap as CrdtLoroMap, loro_CrdtLoroObject as CrdtLoroObject, loro_CrdtLoroText as CrdtLoroText, type loro_InferLoroJson as InferLoroJson, type loro_InferLoroType as InferLoroType, loro_array as array, loro_doc as doc, loro_map as map, loro_object as object, loro_text as text };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { loro };
|