loro-crdt
Advanced tools
Comparing version 0.4.3 to 0.5.0
@@ -5,2 +5,18 @@ # Changelog | ||
## [0.5.0](https://github.com/loro-dev/loro/compare/v0.4.3...v0.5.0) (2023-11-27) | ||
### ⚠ BREAKING CHANGES | ||
* encoding schema is changed | ||
### Bug Fixes | ||
* [#181](https://github.com/loro-dev/loro/issues/181) importing should use inherent arena ([8e901cf](https://github.com/loro-dev/loro/commit/8e901cf00cc8469da136f18f13d2affc78e08e64)) | ||
* deno dirname in windows ([#183](https://github.com/loro-dev/loro/issues/183)) ([c04dc34](https://github.com/loro-dev/loro/commit/c04dc344f5413b5135354c9652a70b5d698f04ac)) | ||
* from snapshot should enable auto commit ([b940214](https://github.com/loro-dev/loro/commit/b94021498571cf7ac42f2896ca0abc82f15d823a)) | ||
* keep strong ref to doc in handlers [#190](https://github.com/loro-dev/loro/issues/190) ([#191](https://github.com/loro-dev/loro/issues/191)) ([e23ef43](https://github.com/loro-dev/loro/commit/e23ef4362d69430601728f40b730e72a183ac4ea)) | ||
* remove compress feature ([#184](https://github.com/loro-dev/loro/issues/184)) ([899270c](https://github.com/loro-dev/loro/commit/899270c6de065852d6e26a07b94b3d923cb83459)) | ||
* typo in lib.rs ([#176](https://github.com/loro-dev/loro/issues/176)) ([83b0e8c](https://github.com/loro-dev/loro/commit/83b0e8cc7f8bccd9d7c152c0e5a59437bebe6c87)) | ||
### [0.4.3](https://github.com/loro-dev/loro/compare/v0.4.2...v0.4.3) (2023-11-16) | ||
@@ -7,0 +23,0 @@ |
@@ -1,13 +0,7 @@ | ||
import { LoroTree, ContainerID, LoroList, LoroMap, LoroText, PrelimList, PrelimMap, PrelimText, Delta, TreeID } from 'loro-wasm'; | ||
import { Value, Container, PrelimList, PrelimMap, PrelimText, OpId, ContainerID, Delta, TreeID, ContainerType } from 'loro-wasm'; | ||
export * from 'loro-wasm'; | ||
export { Loro } from 'loro-wasm'; | ||
/** | ||
* Data types supported by loro | ||
*/ | ||
type Value = ContainerID | string | number | boolean | null | { | ||
[key: string]: Value; | ||
} | Uint8Array | Value[]; | ||
type Container = LoroList | LoroMap | LoroText | LoroTree; | ||
type Prelim = PrelimList | PrelimMap | PrelimText; | ||
type Frontiers = OpId[]; | ||
/** | ||
@@ -76,2 +70,4 @@ * Represents a path to identify the exact location of an event's target. | ||
declare function isContainer(value: any): value is Container; | ||
declare function valueType(value: any): "Json" | ContainerType; | ||
declare module "loro-wasm" { | ||
@@ -118,2 +114,2 @@ interface Loro { | ||
export { Container, Diff, ListDiff, LoroEvent, MapDiff, Path, Prelim, TextDiff, TreeDiff, Value, isContainerId }; | ||
export { Diff, Frontiers, ListDiff, LoroEvent, MapDiff, Path, Prelim, TextDiff, TreeDiff, isContainer, isContainerId, valueType }; |
@@ -33,5 +33,19 @@ 'use strict'; | ||
}; | ||
const CONTAINER_TYPES = ["Map", "Text", "List", "Tree"]; | ||
function isContainerId(s) { | ||
return s.startsWith("cid:"); | ||
} | ||
function isContainer(value) { | ||
if (typeof value !== "object" || value == null) { | ||
return false; | ||
} | ||
const p = value.__proto__; | ||
return p.hasOwnProperty("kind") && CONTAINER_TYPES.includes(value.kind()); | ||
} | ||
function valueType(value) { | ||
if (isContainer(value)) { | ||
return value.kind(); | ||
} | ||
return "Json"; | ||
} | ||
@@ -42,3 +56,5 @@ Object.defineProperty(exports, 'Loro', { | ||
}); | ||
exports.isContainer = isContainer; | ||
exports.isContainerId = isContainerId; | ||
exports.valueType = valueType; | ||
Object.keys(loroWasm).forEach(function (k) { | ||
@@ -45,0 +61,0 @@ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { |
{ | ||
"name": "loro-crdt", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.", | ||
@@ -20,3 +20,3 @@ "keywords": [ | ||
"dependencies": { | ||
"loro-wasm": "0.4.3" | ||
"loro-wasm": "0.5.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
export * from "loro-wasm"; | ||
import { Delta } from "loro-wasm"; | ||
import { Container, ContainerType, Delta, OpId, Value } from "loro-wasm"; | ||
import { PrelimText, PrelimList, PrelimMap } from "loro-wasm"; | ||
@@ -9,4 +9,2 @@ import { | ||
LoroMap, | ||
LoroText, | ||
LoroTree, | ||
TreeID, | ||
@@ -44,17 +42,4 @@ } from "loro-wasm"; | ||
/** | ||
* Data types supported by loro | ||
*/ | ||
export type Value = | ||
| ContainerID | ||
| string | ||
| number | ||
| boolean | ||
| null | ||
| { [key: string]: Value } | ||
| Uint8Array | ||
| Value[]; | ||
export type Container = LoroList | LoroMap | LoroText | LoroTree; | ||
export type Prelim = PrelimList | PrelimMap | PrelimText; | ||
export type Frontiers = OpId[]; | ||
@@ -115,4 +100,4 @@ /** | ||
diff: | ||
| { target: TreeID; action: "create" | "delete" } | ||
| { target: TreeID; action: "move"; parent: TreeID }; | ||
| { target: TreeID; action: "create" | "delete" } | ||
| { target: TreeID; action: "move"; parent: TreeID }; | ||
}; | ||
@@ -134,2 +119,19 @@ | ||
export function isContainer(value: any): value is Container { | ||
if (typeof value !== "object" || value == null) { | ||
return false; | ||
} | ||
const p = value.__proto__; | ||
return p.hasOwnProperty("kind") && CONTAINER_TYPES.includes(value.kind()); | ||
} | ||
export function valueType(value: any): "Json" | ContainerType { | ||
if (isContainer(value)) { | ||
return value.kind(); | ||
} | ||
return "Json"; | ||
} | ||
declare module "loro-wasm" { | ||
@@ -136,0 +138,0 @@ interface Loro { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102025
521
+ Addedloro-wasm@0.5.0(transitive)
- Removedloro-wasm@0.4.3(transitive)
Updatedloro-wasm@0.5.0