loro-crdt 0.4.1 → 0.4.3
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/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/dist/loro.d.ts +9 -4
- package/dist/loro.js.map +1 -1
- package/dist/loro.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +22 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.4.3](https://github.com/loro-dev/loro/compare/v0.4.2...v0.4.3) (2023-11-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* avoid i32 overflow ([f799da9](https://github.com/loro-dev/loro/commit/f799da9abbdf369ea1f120c700078bb87f27212b))
|
|
11
|
+
|
|
12
|
+
### [0.4.2](https://github.com/loro-dev/loro/compare/v0.4.1...v0.4.2) (2023-11-16)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* get sub container directly when getting value ([#175](https://github.com/loro-dev/loro/issues/175)) ([1ff1505](https://github.com/loro-dev/loro/commit/1ff1505933198be8f3b7aefc32e1698007e21c25))
|
|
18
|
+
* **wasm:** add event id ([e54d2ac](https://github.com/loro-dev/loro/commit/e54d2ac21b02ad6b161336b0b9a99a0a85ca5a02))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* loro-wasm typo ([#171](https://github.com/loro-dev/loro/issues/171)) ([c4b9cb4](https://github.com/loro-dev/loro/commit/c4b9cb4b2b77c3c83b99b51153cd8dd19a948dc0))
|
|
24
|
+
|
|
5
25
|
### 0.4.1 (2023-11-12)
|
|
6
26
|
|
|
7
27
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Loro
|
|
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/loro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContainerID, PrelimList, PrelimMap, PrelimText, Delta, TreeID } from 'loro-wasm';
|
|
1
|
+
import { LoroTree, ContainerID, LoroList, LoroMap, LoroText, PrelimList, PrelimMap, PrelimText, Delta, TreeID } from 'loro-wasm';
|
|
2
2
|
export * from 'loro-wasm';
|
|
3
3
|
export { Loro } from 'loro-wasm';
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ export { Loro } from 'loro-wasm';
|
|
|
8
8
|
type Value = ContainerID | string | number | boolean | null | {
|
|
9
9
|
[key: string]: Value;
|
|
10
10
|
} | Uint8Array | Value[];
|
|
11
|
+
type Container = LoroList | LoroMap | LoroText | LoroTree;
|
|
11
12
|
type Prelim = PrelimList | PrelimMap | PrelimText;
|
|
12
13
|
/**
|
|
13
14
|
* Represents a path to identify the exact location of an event's target.
|
|
@@ -25,6 +26,10 @@ type Path = (number | string)[];
|
|
|
25
26
|
* @prop path - Specifies the absolute path of the event's emitter, which can be an index of a list container or a key of a map container.
|
|
26
27
|
*/
|
|
27
28
|
interface LoroEvent {
|
|
29
|
+
/**
|
|
30
|
+
* The unique ID of the event.
|
|
31
|
+
*/
|
|
32
|
+
id: bigint;
|
|
28
33
|
local: boolean;
|
|
29
34
|
origin?: string;
|
|
30
35
|
/**
|
|
@@ -82,7 +87,7 @@ declare module "loro-wasm" {
|
|
|
82
87
|
insertContainer(pos: number, container: "Text"): LoroText;
|
|
83
88
|
insertContainer(pos: number, container: "Tree"): LoroTree;
|
|
84
89
|
insertContainer(pos: number, container: string): never;
|
|
85
|
-
get(index: number): Value;
|
|
90
|
+
get(index: number): undefined | Value | Container;
|
|
86
91
|
getTyped<Key extends keyof T & number>(loro: Loro, index: Key): T[Key];
|
|
87
92
|
insertTyped<Key extends keyof T & number>(pos: Key, value: T[Key]): void;
|
|
88
93
|
insert(pos: number, value: Value | Prelim): void;
|
|
@@ -95,7 +100,7 @@ declare module "loro-wasm" {
|
|
|
95
100
|
setContainer(key: string, container_type: "Text"): LoroText;
|
|
96
101
|
setContainer(key: string, container_type: "Tree"): LoroTree;
|
|
97
102
|
setContainer(key: string, container_type: string): never;
|
|
98
|
-
get(key: string): Value;
|
|
103
|
+
get(key: string): undefined | Value | Container;
|
|
99
104
|
getTyped<Key extends keyof T & string>(txn: Loro, key: Key): T[Key];
|
|
100
105
|
set(key: string, value: Value | Prelim): void;
|
|
101
106
|
setTyped<Key extends keyof T & string>(key: Key, value: T[Key]): void;
|
|
@@ -109,4 +114,4 @@ declare module "loro-wasm" {
|
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
export { Diff, ListDiff, LoroEvent, MapDiff, Path, Prelim, TextDiff, TreeDiff, Value, isContainerId };
|
|
117
|
+
export { Container, Diff, ListDiff, LoroEvent, MapDiff, Path, Prelim, TextDiff, TreeDiff, Value, isContainerId };
|
package/dist/loro.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loro.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"loro-wasm\";\nimport { Delta } from \"loro-wasm\";\nimport { PrelimText,PrelimList,PrelimMap } from \"loro-wasm\";\nimport {
|
|
1
|
+
{"version":3,"file":"loro.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"loro-wasm\";\nimport { Delta } from \"loro-wasm\";\nimport { PrelimText, PrelimList, PrelimMap } from \"loro-wasm\";\nimport {\n ContainerID,\n Loro,\n LoroList,\n LoroMap,\n LoroText,\n LoroTree,\n TreeID,\n} from \"loro-wasm\";\n\nLoro.prototype.getTypedMap = function (...args) {\n return this.getMap(...args);\n};\nLoro.prototype.getTypedList = function (...args) {\n return this.getList(...args);\n};\nLoroList.prototype.getTyped = function (loro, index) {\n const value = this.get(index);\n if (typeof value === \"string\" && isContainerId(value)) {\n return loro.getContainerById(value);\n } else {\n return value;\n }\n};\nLoroList.prototype.insertTyped = function (...args) {\n return this.insert(...args);\n};\nLoroMap.prototype.getTyped = function (loro, key) {\n const value = this.get(key);\n if (typeof value === \"string\" && isContainerId(value)) {\n return loro.getContainerById(value);\n } else {\n return value;\n }\n};\nLoroMap.prototype.setTyped = function (...args) {\n return this.set(...args);\n};\n\n/**\n * Data types supported by loro\n */\nexport type Value =\n | ContainerID\n | string\n | number\n | boolean\n | null\n | { [key: string]: Value }\n | Uint8Array\n | Value[];\n\nexport type Container = LoroList | LoroMap | LoroText | LoroTree;\nexport type Prelim = PrelimList | PrelimMap | PrelimText;\n\n/**\n * Represents a path to identify the exact location of an event's target.\n * The path is composed of numbers (e.g., indices of a list container) and strings\n * (e.g., keys of a map container), indicating the absolute position of the event's source\n * within a loro document.\n */\nexport type Path = (number | string)[];\n\n/**\n * The event of Loro.\n * @prop local - Indicates whether the event is local.\n * @prop origin - (Optional) Provides information about the origin of the event.\n * @prop diff - Contains the differential information related to the event.\n * @prop target - Identifies the container ID of the event's target.\n * @prop path - Specifies the absolute path of the event's emitter, which can be an index of a list container or a key of a map container.\n */\nexport interface LoroEvent {\n /**\n * The unique ID of the event.\n */\n id: bigint;\n local: boolean;\n origin?: string;\n /**\n * If true, this event was triggered by a child container.\n */\n fromChildren: boolean;\n /**\n * If true, this event was triggered by a checkout.\n */\n fromCheckout: boolean;\n diff: Diff;\n target: ContainerID;\n path: Path;\n}\n\nexport type ListDiff = {\n type: \"list\";\n diff: Delta<Value[]>[];\n};\n\nexport type TextDiff = {\n type: \"text\";\n diff: Delta<string>[];\n};\n\nexport type MapDiff = {\n type: \"map\";\n updated: Record<string, Value | undefined>;\n};\n\nexport type TreeDiff = {\n type: \"tree\";\n diff:\n | { target: TreeID; action: \"create\" | \"delete\" }\n | { target: TreeID; action: \"move\"; parent: TreeID };\n};\n\nexport type Diff = ListDiff | TextDiff | MapDiff | TreeDiff;\n\ninterface Listener {\n (event: LoroEvent): void;\n}\n\nconst CONTAINER_TYPES = [\"Map\", \"Text\", \"List\", \"Tree\"];\n\nexport function isContainerId(s: string): s is ContainerID {\n return s.startsWith(\"cid:\");\n}\n\nexport { Loro };\n\ndeclare module \"loro-wasm\" {\n interface Loro {\n subscribe(listener: Listener): number;\n }\n\n interface Loro<T extends Record<string, any> = Record<string, any>> {\n getTypedMap<Key extends keyof T & string>(\n name: Key,\n ): T[Key] extends LoroMap ? T[Key] : never;\n getTypedList<Key extends keyof T & string>(\n name: Key,\n ): T[Key] extends LoroList ? T[Key] : never;\n }\n\n interface LoroList<T extends any[] = any[]> {\n insertContainer(pos: number, container: \"Map\"): LoroMap;\n insertContainer(pos: number, container: \"List\"): LoroList;\n insertContainer(pos: number, container: \"Text\"): LoroText;\n insertContainer(pos: number, container: \"Tree\"): LoroTree;\n insertContainer(pos: number, container: string): never;\n\n get(index: number): undefined | Value | Container;\n getTyped<Key extends keyof T & number>(loro: Loro, index: Key): T[Key];\n insertTyped<Key extends keyof T & number>(pos: Key, value: T[Key]): void;\n insert(pos: number, value: Value | Prelim): void;\n delete(pos: number, len: number): void;\n subscribe(txn: Loro, listener: Listener): number;\n }\n\n interface LoroMap<T extends Record<string, any> = Record<string, any>> {\n setContainer(key: string, container_type: \"Map\"): LoroMap;\n setContainer(key: string, container_type: \"List\"): LoroList;\n setContainer(key: string, container_type: \"Text\"): LoroText;\n setContainer(key: string, container_type: \"Tree\"): LoroTree;\n setContainer(key: string, container_type: string): never;\n\n get(key: string): undefined | Value | Container;\n getTyped<Key extends keyof T & string>(txn: Loro, key: Key): T[Key];\n set(key: string, value: Value | Prelim): void;\n setTyped<Key extends keyof T & string>(key: Key, value: T[Key]): void;\n delete(key: string): void;\n subscribe(txn: Loro, listener: Listener): number;\n }\n\n interface LoroText {\n insert(pos: number, text: string): void;\n delete(pos: number, len: number): void;\n subscribe(txn: Loro, listener: Listener): number;\n }\n}\n"],"names":["Loro","LoroList","LoroMap"],"mappings":";;;;AAaAA,aAAK,CAAA,SAAA,CAAU,WAAc,GAAA,SAAA,GAAa,IAAM,EAAA;AAC9C,EAAO,OAAA,IAAA,CAAK,MAAO,CAAA,GAAG,IAAI,CAAA,CAAA;AAC5B,CAAA,CAAA;AACAA,aAAK,CAAA,SAAA,CAAU,YAAe,GAAA,SAAA,GAAa,IAAM,EAAA;AAC/C,EAAO,OAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,IAAI,CAAA,CAAA;AAC7B,CAAA,CAAA;AACAC,iBAAA,CAAS,SAAU,CAAA,QAAA,GAAW,SAAU,IAAA,EAAM,KAAO,EAAA;AACnD,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAC5B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,aAAA,CAAc,KAAK,CAAG,EAAA;AACrD,IAAO,OAAA,IAAA,CAAK,iBAAiB,KAAK,CAAA,CAAA;AAAA,GAC7B,MAAA;AACL,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA,CAAA;AACAA,iBAAS,CAAA,SAAA,CAAU,WAAc,GAAA,SAAA,GAAa,IAAM,EAAA;AAClD,EAAO,OAAA,IAAA,CAAK,MAAO,CAAA,GAAG,IAAI,CAAA,CAAA;AAC5B,CAAA,CAAA;AACAC,gBAAA,CAAQ,SAAU,CAAA,QAAA,GAAW,SAAU,IAAA,EAAM,GAAK,EAAA;AAChD,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,GAAA,CAAI,GAAG,CAAA,CAAA;AAC1B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,aAAA,CAAc,KAAK,CAAG,EAAA;AACrD,IAAO,OAAA,IAAA,CAAK,iBAAiB,KAAK,CAAA,CAAA;AAAA,GAC7B,MAAA;AACL,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA,CAAA;AACAA,gBAAQ,CAAA,SAAA,CAAU,QAAW,GAAA,SAAA,GAAa,IAAM,EAAA;AAC9C,EAAO,OAAA,IAAA,CAAK,GAAI,CAAA,GAAG,IAAI,CAAA,CAAA;AACzB,CAAA,CAAA;AAoFO,SAAS,cAAc,CAA6B,EAAA;AACzD,EAAO,OAAA,CAAA,CAAE,WAAW,MAAM,CAAA,CAAA;AAC5B;;;;;;;;;;;;;;"}
|
package/dist/loro.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loro.mjs","sources":["../src/index.ts"],"sourcesContent":["export * from \"loro-wasm\";\nimport { Delta } from \"loro-wasm\";\nimport { PrelimText,PrelimList,PrelimMap } from \"loro-wasm\";\nimport {
|
|
1
|
+
{"version":3,"file":"loro.mjs","sources":["../src/index.ts"],"sourcesContent":["export * from \"loro-wasm\";\nimport { Delta } from \"loro-wasm\";\nimport { PrelimText, PrelimList, PrelimMap } from \"loro-wasm\";\nimport {\n ContainerID,\n Loro,\n LoroList,\n LoroMap,\n LoroText,\n LoroTree,\n TreeID,\n} from \"loro-wasm\";\n\nLoro.prototype.getTypedMap = function (...args) {\n return this.getMap(...args);\n};\nLoro.prototype.getTypedList = function (...args) {\n return this.getList(...args);\n};\nLoroList.prototype.getTyped = function (loro, index) {\n const value = this.get(index);\n if (typeof value === \"string\" && isContainerId(value)) {\n return loro.getContainerById(value);\n } else {\n return value;\n }\n};\nLoroList.prototype.insertTyped = function (...args) {\n return this.insert(...args);\n};\nLoroMap.prototype.getTyped = function (loro, key) {\n const value = this.get(key);\n if (typeof value === \"string\" && isContainerId(value)) {\n return loro.getContainerById(value);\n } else {\n return value;\n }\n};\nLoroMap.prototype.setTyped = function (...args) {\n return this.set(...args);\n};\n\n/**\n * Data types supported by loro\n */\nexport type Value =\n | ContainerID\n | string\n | number\n | boolean\n | null\n | { [key: string]: Value }\n | Uint8Array\n | Value[];\n\nexport type Container = LoroList | LoroMap | LoroText | LoroTree;\nexport type Prelim = PrelimList | PrelimMap | PrelimText;\n\n/**\n * Represents a path to identify the exact location of an event's target.\n * The path is composed of numbers (e.g., indices of a list container) and strings\n * (e.g., keys of a map container), indicating the absolute position of the event's source\n * within a loro document.\n */\nexport type Path = (number | string)[];\n\n/**\n * The event of Loro.\n * @prop local - Indicates whether the event is local.\n * @prop origin - (Optional) Provides information about the origin of the event.\n * @prop diff - Contains the differential information related to the event.\n * @prop target - Identifies the container ID of the event's target.\n * @prop path - Specifies the absolute path of the event's emitter, which can be an index of a list container or a key of a map container.\n */\nexport interface LoroEvent {\n /**\n * The unique ID of the event.\n */\n id: bigint;\n local: boolean;\n origin?: string;\n /**\n * If true, this event was triggered by a child container.\n */\n fromChildren: boolean;\n /**\n * If true, this event was triggered by a checkout.\n */\n fromCheckout: boolean;\n diff: Diff;\n target: ContainerID;\n path: Path;\n}\n\nexport type ListDiff = {\n type: \"list\";\n diff: Delta<Value[]>[];\n};\n\nexport type TextDiff = {\n type: \"text\";\n diff: Delta<string>[];\n};\n\nexport type MapDiff = {\n type: \"map\";\n updated: Record<string, Value | undefined>;\n};\n\nexport type TreeDiff = {\n type: \"tree\";\n diff:\n | { target: TreeID; action: \"create\" | \"delete\" }\n | { target: TreeID; action: \"move\"; parent: TreeID };\n};\n\nexport type Diff = ListDiff | TextDiff | MapDiff | TreeDiff;\n\ninterface Listener {\n (event: LoroEvent): void;\n}\n\nconst CONTAINER_TYPES = [\"Map\", \"Text\", \"List\", \"Tree\"];\n\nexport function isContainerId(s: string): s is ContainerID {\n return s.startsWith(\"cid:\");\n}\n\nexport { Loro };\n\ndeclare module \"loro-wasm\" {\n interface Loro {\n subscribe(listener: Listener): number;\n }\n\n interface Loro<T extends Record<string, any> = Record<string, any>> {\n getTypedMap<Key extends keyof T & string>(\n name: Key,\n ): T[Key] extends LoroMap ? T[Key] : never;\n getTypedList<Key extends keyof T & string>(\n name: Key,\n ): T[Key] extends LoroList ? T[Key] : never;\n }\n\n interface LoroList<T extends any[] = any[]> {\n insertContainer(pos: number, container: \"Map\"): LoroMap;\n insertContainer(pos: number, container: \"List\"): LoroList;\n insertContainer(pos: number, container: \"Text\"): LoroText;\n insertContainer(pos: number, container: \"Tree\"): LoroTree;\n insertContainer(pos: number, container: string): never;\n\n get(index: number): undefined | Value | Container;\n getTyped<Key extends keyof T & number>(loro: Loro, index: Key): T[Key];\n insertTyped<Key extends keyof T & number>(pos: Key, value: T[Key]): void;\n insert(pos: number, value: Value | Prelim): void;\n delete(pos: number, len: number): void;\n subscribe(txn: Loro, listener: Listener): number;\n }\n\n interface LoroMap<T extends Record<string, any> = Record<string, any>> {\n setContainer(key: string, container_type: \"Map\"): LoroMap;\n setContainer(key: string, container_type: \"List\"): LoroList;\n setContainer(key: string, container_type: \"Text\"): LoroText;\n setContainer(key: string, container_type: \"Tree\"): LoroTree;\n setContainer(key: string, container_type: string): never;\n\n get(key: string): undefined | Value | Container;\n getTyped<Key extends keyof T & string>(txn: Loro, key: Key): T[Key];\n set(key: string, value: Value | Prelim): void;\n setTyped<Key extends keyof T & string>(key: Key, value: T[Key]): void;\n delete(key: string): void;\n subscribe(txn: Loro, listener: Listener): number;\n }\n\n interface LoroText {\n insert(pos: number, text: string): void;\n delete(pos: number, len: number): void;\n subscribe(txn: Loro, listener: Listener): number;\n }\n}\n"],"names":[],"mappings":";;;;AAaA,IAAK,CAAA,SAAA,CAAU,WAAc,GAAA,SAAA,GAAa,IAAM,EAAA;AAC9C,EAAO,OAAA,IAAA,CAAK,MAAO,CAAA,GAAG,IAAI,CAAA,CAAA;AAC5B,CAAA,CAAA;AACA,IAAK,CAAA,SAAA,CAAU,YAAe,GAAA,SAAA,GAAa,IAAM,EAAA;AAC/C,EAAO,OAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,IAAI,CAAA,CAAA;AAC7B,CAAA,CAAA;AACA,QAAA,CAAS,SAAU,CAAA,QAAA,GAAW,SAAU,IAAA,EAAM,KAAO,EAAA;AACnD,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAC5B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,aAAA,CAAc,KAAK,CAAG,EAAA;AACrD,IAAO,OAAA,IAAA,CAAK,iBAAiB,KAAK,CAAA,CAAA;AAAA,GAC7B,MAAA;AACL,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA,CAAA;AACA,QAAS,CAAA,SAAA,CAAU,WAAc,GAAA,SAAA,GAAa,IAAM,EAAA;AAClD,EAAO,OAAA,IAAA,CAAK,MAAO,CAAA,GAAG,IAAI,CAAA,CAAA;AAC5B,CAAA,CAAA;AACA,OAAA,CAAQ,SAAU,CAAA,QAAA,GAAW,SAAU,IAAA,EAAM,GAAK,EAAA;AAChD,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,GAAA,CAAI,GAAG,CAAA,CAAA;AAC1B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,aAAA,CAAc,KAAK,CAAG,EAAA;AACrD,IAAO,OAAA,IAAA,CAAK,iBAAiB,KAAK,CAAA,CAAA;AAAA,GAC7B,MAAA;AACL,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA,CAAA;AACA,OAAQ,CAAA,SAAA,CAAU,QAAW,GAAA,SAAA,GAAa,IAAM,EAAA;AAC9C,EAAO,OAAA,IAAA,CAAK,GAAI,CAAA,GAAG,IAAI,CAAA,CAAA;AACzB,CAAA,CAAA;AAoFO,SAAS,cAAc,CAA6B,EAAA;AACzD,EAAO,OAAA,CAAA,CAAE,WAAW,MAAM,CAAA,CAAA;AAC5B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loro-crdt",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crdt",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"typings": "dist/loro.d.ts",
|
|
16
16
|
"author": "Loro",
|
|
17
17
|
"homepage": "https://loro.dev",
|
|
18
|
-
"license": "
|
|
18
|
+
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"loro-wasm": "0.4.
|
|
20
|
+
"loro-wasm": "0.4.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
export * from "loro-wasm";
|
|
2
2
|
import { Delta } from "loro-wasm";
|
|
3
|
-
import { PrelimText,PrelimList,PrelimMap } from "loro-wasm";
|
|
4
|
-
import {
|
|
3
|
+
import { PrelimText, PrelimList, PrelimMap } from "loro-wasm";
|
|
4
|
+
import {
|
|
5
|
+
ContainerID,
|
|
6
|
+
Loro,
|
|
7
|
+
LoroList,
|
|
8
|
+
LoroMap,
|
|
9
|
+
LoroText,
|
|
10
|
+
LoroTree,
|
|
11
|
+
TreeID,
|
|
12
|
+
} from "loro-wasm";
|
|
5
13
|
|
|
6
14
|
Loro.prototype.getTypedMap = function (...args) {
|
|
7
15
|
return this.getMap(...args);
|
|
@@ -45,12 +53,12 @@ export type Value =
|
|
|
45
53
|
| Uint8Array
|
|
46
54
|
| Value[];
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
export type Container = LoroList | LoroMap | LoroText | LoroTree;
|
|
49
57
|
export type Prelim = PrelimList | PrelimMap | PrelimText;
|
|
50
58
|
|
|
51
59
|
/**
|
|
52
60
|
* Represents a path to identify the exact location of an event's target.
|
|
53
|
-
* The path is composed of numbers (e.g., indices of a list container) and strings
|
|
61
|
+
* The path is composed of numbers (e.g., indices of a list container) and strings
|
|
54
62
|
* (e.g., keys of a map container), indicating the absolute position of the event's source
|
|
55
63
|
* within a loro document.
|
|
56
64
|
*/
|
|
@@ -65,6 +73,10 @@ export type Path = (number | string)[];
|
|
|
65
73
|
* @prop path - Specifies the absolute path of the event's emitter, which can be an index of a list container or a key of a map container.
|
|
66
74
|
*/
|
|
67
75
|
export interface LoroEvent {
|
|
76
|
+
/**
|
|
77
|
+
* The unique ID of the event.
|
|
78
|
+
*/
|
|
79
|
+
id: bigint;
|
|
68
80
|
local: boolean;
|
|
69
81
|
origin?: string;
|
|
70
82
|
/**
|
|
@@ -97,8 +109,10 @@ export type MapDiff = {
|
|
|
97
109
|
|
|
98
110
|
export type TreeDiff = {
|
|
99
111
|
type: "tree";
|
|
100
|
-
diff:
|
|
101
|
-
}
|
|
112
|
+
diff:
|
|
113
|
+
| { target: TreeID; action: "create" | "delete" }
|
|
114
|
+
| { target: TreeID; action: "move"; parent: TreeID };
|
|
115
|
+
};
|
|
102
116
|
|
|
103
117
|
export type Diff = ListDiff | TextDiff | MapDiff | TreeDiff;
|
|
104
118
|
|
|
@@ -135,7 +149,7 @@ declare module "loro-wasm" {
|
|
|
135
149
|
insertContainer(pos: number, container: "Tree"): LoroTree;
|
|
136
150
|
insertContainer(pos: number, container: string): never;
|
|
137
151
|
|
|
138
|
-
get(index: number): Value;
|
|
152
|
+
get(index: number): undefined | Value | Container;
|
|
139
153
|
getTyped<Key extends keyof T & number>(loro: Loro, index: Key): T[Key];
|
|
140
154
|
insertTyped<Key extends keyof T & number>(pos: Key, value: T[Key]): void;
|
|
141
155
|
insert(pos: number, value: Value | Prelim): void;
|
|
@@ -150,7 +164,7 @@ declare module "loro-wasm" {
|
|
|
150
164
|
setContainer(key: string, container_type: "Tree"): LoroTree;
|
|
151
165
|
setContainer(key: string, container_type: string): never;
|
|
152
166
|
|
|
153
|
-
get(key: string): Value;
|
|
167
|
+
get(key: string): undefined | Value | Container;
|
|
154
168
|
getTyped<Key extends keyof T & string>(txn: Loro, key: Key): T[Key];
|
|
155
169
|
set(key: string, value: Value | Prelim): void;
|
|
156
170
|
setTyped<Key extends keyof T & string>(key: Key, value: T[Key]): void;
|