diff --git a/01_basic.test.ts b/01_basic.test.ts index ce797ed..0e9d68c 100644 --- a/01_basic.test.ts +++ b/01_basic.test.ts @@ -1,4 +1,4 @@ -import { Loro, LoroList, LoroMap } from "npm:loro-crdt@0.5.0" +import { Loro, LoroList, LoroMap } from "npm:loro-crdt@0.6.3" import { expect } from "npm:expect@29.7.0" Deno.test("Basic usage", () => { diff --git a/02_text.test.ts b/02_text.test.ts index 25f90cd..a814885 100644 --- a/02_text.test.ts +++ b/02_text.test.ts @@ -1,4 +1,4 @@ -import { Delta, Loro } from "npm:loro-crdt@0.5.0"; +import { Delta, Loro } from "npm:loro-crdt@0.6.3"; import { expect } from "npm:expect@29.7.0"; Deno.test("Text", () => { @@ -71,7 +71,7 @@ Deno.test("Rich text custom expand behavior - Link", () => { }] as Delta[]); }) -Deno.test("Rich text event", () => { +Deno.test("Rich text event", async () => { /** * Loro text will receive rich text event in Quill Delta format */ @@ -91,5 +91,6 @@ Deno.test("Rich text event", () => { }); text.mark({ start: 0, end: 5 }, "bold", true); doc.commit(); + await new Promise((resolve) => setTimeout(resolve, 0)); expect(ran).toBeTruthy(); }); diff --git a/03_version.test.ts b/03_version.test.ts index d6f2325..bd72203 100644 --- a/03_version.test.ts +++ b/03_version.test.ts @@ -1,4 +1,4 @@ -import { Loro, OpId } from "npm:loro-crdt@0.5.0"; +import { Loro, OpId } from "npm:loro-crdt@0.6.3"; import { expect } from "npm:expect@29.7.0"; diff --git a/04_time_travel.test.ts b/04_time_travel.test.ts index 13b5099..51a0cd8 100644 --- a/04_time_travel.test.ts +++ b/04_time_travel.test.ts @@ -1,4 +1,4 @@ -import { Loro } from "npm:loro-crdt@0.5.0"; +import { Loro } from "npm:loro-crdt@0.6.3"; import { expect } from "npm:expect@29.7.0"; Deno.test("Time Travel", () => { diff --git a/05_save_and_load.test.ts b/05_save_and_load.test.ts index 62f60e0..ff57d1d 100644 --- a/05_save_and_load.test.ts +++ b/05_save_and_load.test.ts @@ -1,4 +1,4 @@ -import { Loro } from "npm:loro-crdt@0.5.0"; +import { Loro } from "npm:loro-crdt@0.6.3"; import { expect } from "npm:expect@29.7.0"; Deno.test("Save and load", () => { diff --git a/06_event.test.ts b/06_event.test.ts new file mode 100644 index 0000000..5b992ff --- /dev/null +++ b/06_event.test.ts @@ -0,0 +1,28 @@ +import { Loro, LoroText, getType } from "npm:loro-crdt@0.6.3"; +import { expect } from "npm:expect@29.7.0"; + +Deno.test("Event have delta that contains Container", async () => { + const doc = new Loro(); + const list = doc.getList("list"); + let ran = false; + doc.subscribe(event => { + if (event.diff.type === "list") { + for (const item of event.diff.diff) { + expect(item.insert?.length).toBe(2); + expect(getType(item.insert![0])).toBe("Text") + expect(getType(item.insert![1])).toBe("Map") + const t = item.insert![0] as LoroText; + expect(t.toString()).toBe("Hello") + } + ran = true; + } + }) + + list.insertContainer(0, "Map"); + const t = list.insertContainer(0, "Text"); + t.insert(0, "He"); + t.insert(2, "llo"); + doc.commit(); + await new Promise(resolve => setTimeout(resolve, 1)); + expect(ran).toBeTruthy() +}) diff --git a/benches/text.bench.ts b/benches/text.bench.ts index 7e8a96f..503ade7 100644 --- a/benches/text.bench.ts +++ b/benches/text.bench.ts @@ -1,4 +1,4 @@ -import { Loro } from "npm:loro-crdt@0.4.0" +import { Loro } from "npm:loro-crdt@0.6.3" /** cpu: Apple M1 diff --git a/deno.lock b/deno.lock index b22412b..f132ac0 100644 --- a/deno.lock +++ b/deno.lock @@ -3,14 +3,14 @@ "packages": { "specifiers": { "npm:expect@29.7.0": "npm:expect@29.7.0", - "npm:loro-crdt@0.4.0": "npm:loro-crdt@0.4.0", - "npm:loro-crdt@0.5.0": "npm:loro-crdt@0.5.0" + "npm:loro-crdt@0.6.2": "npm:loro-crdt@0.6.2", + "npm:loro-crdt@0.6.3": "npm:loro-crdt@0.6.3" }, "npm": { - "@babel/code-frame@7.22.13": { - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "@babel/code-frame@7.23.5": { + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", "dependencies": { - "@babel/highlight": "@babel/highlight@7.22.20", + "@babel/highlight": "@babel/highlight@7.23.4", "chalk": "chalk@2.4.2" } }, @@ -18,8 +18,8 @@ "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dependencies": {} }, - "@babel/highlight@7.22.20": { - "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", + "@babel/highlight@7.23.4": { + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", "dependencies": { "@babel/helper-validator-identifier": "@babel/helper-validator-identifier@7.22.20", "chalk": "chalk@2.4.2", @@ -45,7 +45,7 @@ "@types/istanbul-lib-coverage": "@types/istanbul-lib-coverage@2.0.6", "@types/istanbul-reports": "@types/istanbul-reports@3.0.4", "@types/node": "@types/node@18.16.19", - "@types/yargs": "@types/yargs@17.0.31", + "@types/yargs": "@types/yargs@17.0.32", "chalk": "chalk@4.1.2" } }, @@ -81,8 +81,8 @@ "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", "dependencies": {} }, - "@types/yargs@17.0.31": { - "integrity": "sha512-bocYSx4DI8TmdlvxqGpVNXOgCNR1Jj0gNPhhAY+iz1rgKDAaYrAYdFYnhDV1IFuiuVc9HkOwyDcFxaTElF3/wg==", + "@types/yargs@17.0.32": { + "integrity": "sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==", "dependencies": { "@types/yargs-parser": "@types/yargs-parser@21.0.3" } @@ -217,7 +217,7 @@ "jest-message-util@29.7.0": { "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", "dependencies": { - "@babel/code-frame": "@babel/code-frame@7.22.13", + "@babel/code-frame": "@babel/code-frame@7.23.5", "@jest/types": "@jest/types@29.6.3", "@types/stack-utils": "@types/stack-utils@2.0.3", "chalk": "chalk@4.1.2", @@ -243,24 +243,20 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dependencies": {} }, - "loro-crdt@0.4.0": { - "integrity": "sha512-e9nO3EqCul2KsKfYR3Y30QfLzupDHF9bKUOPq6CzC3e4LrGGJ1QcOqt8hKMttxH7Su+9w7sF9vxyC6KXHhrn0g==", + "loro-crdt@0.6.2": { + "integrity": "sha512-OsNnZbtWhRMItGKJcpxC+NAXVhXiRrbSh7D07oiAyPUkH2sEXwgRXmS0JN7Qt8JU9BsreOUgsthpyesX95OGXg==", "dependencies": { - "loro-wasm": "loro-wasm@0.4.0" + "loro-wasm": "loro-wasm@0.6.1" } }, - "loro-crdt@0.5.0": { - "integrity": "sha512-O7vBYOI1bGQZKlF2UabGVMbIqNtyHKsFUfz3gAy65EzNhFdxFV5BMlm5ViUMd2RAjKHQ8VKuTabV7zeim18cOw==", + "loro-crdt@0.6.3": { + "integrity": "sha512-dK4zDbklR4q4iQDNxoLTMOWtpp26cI4nTedp+agkjxbP6nwQXeRnCSz8UE+3m2ezrndCwbVCaFNg5Q6tfubb5g==", "dependencies": { - "loro-wasm": "loro-wasm@0.5.0" + "loro-wasm": "loro-wasm@0.6.1" } }, - "loro-wasm@0.4.0": { - "integrity": "sha512-vPk//ZpQmQfNsDqKnuEQQANtJDKZQTTgkyNa/EySLfskLStxJIYeua7PsCA5A0oB2Y9deMuOpD7YeMWo8vq5Yw==", - "dependencies": {} - }, - "loro-wasm@0.5.0": { - "integrity": "sha512-IvKvlo7cGJo/sR8loy45fugYko3rCGtanphT7dHD9cYJLiOHeKQqTlXYVPmLmfED6ALqfNxpvRWQvLglMW6EtQ==", + "loro-wasm@0.6.1": { + "integrity": "sha512-rpkUMmbHdoDoWGE28p40Q1fxzWSxdefpqirKglHqEqlkmcU5e5aSarLltklPbf1jtT8E988v8Qx0aA98Z47emw==", "dependencies": {} }, "micromatch@4.0.5": { @@ -316,82 +312,5 @@ } } }, - "redirects": { - "https://deno.land/std/fmt/printf.ts": "https://deno.land/std@0.105.0/fmt/printf.ts", - "https://deno.land/std/path/mod.ts": "https://deno.land/std@0.105.0/path/mod.ts", - "https://deno.land/std/testing/asserts.ts": "https://deno.land/std@0.105.0/testing/asserts.ts" - }, - "remote": { - "https://deno.land/std@0.105.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", - "https://deno.land/std@0.105.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", - "https://deno.land/std@0.105.0/fmt/colors.ts": "d2f8355f00a74404668fc5a1e4a92983ce1a9b0a6ac1d40efbd681cb8f519586", - "https://deno.land/std@0.105.0/fmt/printf.ts": "7ec612e9b89958b8f7710129f74f502327aad285a9e48ee5297f5882fbc3a078", - "https://deno.land/std@0.105.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", - "https://deno.land/std@0.105.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", - "https://deno.land/std@0.105.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", - "https://deno.land/std@0.105.0/path/common.ts": "eaf03d08b569e8a87e674e4e265e099f237472b6fd135b3cbeae5827035ea14a", - "https://deno.land/std@0.105.0/path/glob.ts": "3b84af55c53febacf6afe214c095624b22a56b6f57d7312157479cc783a0de65", - "https://deno.land/std@0.105.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", - "https://deno.land/std@0.105.0/path/posix.ts": "b81974c768d298f8dcd2c720229639b3803ca4a241fa9a355c762fa2bc5ef0c1", - "https://deno.land/std@0.105.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", - "https://deno.land/std@0.105.0/path/win32.ts": "f4a3d4a3f2c9fe894da046d5eac48b5e789a0ebec5152b2c0985efe96a9f7ae1", - "https://deno.land/std@0.105.0/testing/_diff.ts": "5d3693155f561d1a5443ac751ac70aab9f5d67b4819a621d4b96b8a1a1c89620", - "https://deno.land/std@0.105.0/testing/asserts.ts": "e4311d45d956459d4423bc267208fe154b5294989da2ed93257b6a85cae0427e", - "https://deno.land/std@0.106.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", - "https://deno.land/std@0.106.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", - "https://deno.land/std@0.106.0/fs/_util.ts": "f2ce811350236ea8c28450ed822a5f42a0892316515b1cd61321dec13569c56b", - "https://deno.land/std@0.106.0/fs/copy.ts": "631bbafbfe6cba282158abc8aeb7e8251cc69a7ec28ce12878ea1b75fec2add4", - "https://deno.land/std@0.106.0/fs/empty_dir.ts": "5f08b263dd064dc7917c4bbeb13de0f5505a664b9cdfe312fa86e7518cfaeb84", - "https://deno.land/std@0.106.0/fs/ensure_dir.ts": "b7c103dc41a3d1dbbb522bf183c519c37065fdc234831a4a0f7d671b1ed5fea7", - "https://deno.land/std@0.106.0/fs/ensure_file.ts": "c06031af24368e80c330897e4b8e9109efc8602ffabc8f3e2306be07529e1d13", - "https://deno.land/std@0.106.0/fs/ensure_link.ts": "26e54363508b822afd87a3f6e873bbbcd6b5993dd638f8170758c16262a75065", - "https://deno.land/std@0.106.0/fs/ensure_symlink.ts": "c07b6d19ef58b6f5c671ffa942e7f9be50315f4f78e2f9f511626fd2e13beccc", - "https://deno.land/std@0.106.0/fs/eol.ts": "afaebaaac36f48c423b920c836551997715672b80a0fee9aa7667c181a94f2df", - "https://deno.land/std@0.106.0/fs/exists.ts": "b0d2e31654819cc2a8d37df45d6b14686c0cc1d802e9ff09e902a63e98b85a00", - "https://deno.land/std@0.106.0/fs/expand_glob.ts": "73e7b13f01097b04ed782b3d63863379b718417417758ba622e282b1e5300b91", - "https://deno.land/std@0.106.0/fs/mod.ts": "26eee4b52a8c516e37d464094b080ff6822883e7f01ff0ba0a72b8dcd54b9927", - "https://deno.land/std@0.106.0/fs/move.ts": "4623058e39bbbeb3ad30aeff9c974c55d2d574ad7c480295c12b04c244686a99", - "https://deno.land/std@0.106.0/fs/walk.ts": "b91c655c60d048035f9cae0e6177991ab3245e786e3ab7d20a5b60012edf2126", - "https://deno.land/std@0.106.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", - "https://deno.land/std@0.106.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", - "https://deno.land/std@0.106.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", - "https://deno.land/std@0.106.0/path/common.ts": "eaf03d08b569e8a87e674e4e265e099f237472b6fd135b3cbeae5827035ea14a", - "https://deno.land/std@0.106.0/path/glob.ts": "3b84af55c53febacf6afe214c095624b22a56b6f57d7312157479cc783a0de65", - "https://deno.land/std@0.106.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", - "https://deno.land/std@0.106.0/path/posix.ts": "b81974c768d298f8dcd2c720229639b3803ca4a241fa9a355c762fa2bc5ef0c1", - "https://deno.land/std@0.106.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", - "https://deno.land/std@0.106.0/path/win32.ts": "f4a3d4a3f2c9fe894da046d5eac48b5e789a0ebec5152b2c0985efe96a9f7ae1", - "https://deno.land/x/cliui@v7.0.4-deno/build/lib/index.js": "fb6030c7b12602a4fca4d81de3ddafa301ba84fd9df73c53de6f3bdda7b482d5", - "https://deno.land/x/cliui@v7.0.4-deno/build/lib/string-utils.js": "b3eb9d2e054a43a3064af17332fb1839a7dadb205c5371af4789616afb1a117f", - "https://deno.land/x/cliui@v7.0.4-deno/deno.ts": "d07bc3338661f8011e3a5fd215061d17a52107a5383c29f40ce0c1ecb8bb8cc3", - "https://deno.land/x/escalade@v3.0.3/sync.ts": "493bc66563292c5c10c4a75a467a5933f24dad67d74b0f5a87e7b988fe97c104", - "https://deno.land/x/y18n@v5.0.0-deno/build/lib/index.js": "92c4624714aa508d33c6d21c0b0ffa072369a8b306e5f8c7727662f570bbd026", - "https://deno.land/x/y18n@v5.0.0-deno/deno.ts": "80997f0709a0b43d29931e2b33946f2bbc32b13fd82f80a5409628455427e28d", - "https://deno.land/x/y18n@v5.0.0-deno/lib/platform-shims/deno.ts": "8fa2c96ac03734966260cfd2c5bc240e41725c913e5b64a0297aede09f52b39d", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/argsert.js": "eb085555452eac3ff300935994a42f35d16e04cf698cb775cb5ad4f5653c0627", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/command.js": "499c95cecd5e93f627e0b5ce66a193c9a595adc10fbafe0581a9725e38324dee", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/completion-templates.js": "f84823b1daa0ed0189e4f823f6a4fd29ad58de6a05771004918368fd62bb2b3f", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/completion.js": "c91772b89907ebf1a462804305d12d3b9deade75cd1b319c06831ac0bf5abd27", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/middleware.js": "cef3f017d5ff61c340c65b8422f5ab9600ba381aa656df634d1a3edf0f967527", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/parse-command.js": "327242c0afae207b7aefa13133439e3b321d7db4229febc5b7bd5285770ac7f7", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/typings/common-types.js": "9618b81a86acb88a61fd9988e9bc3ec21c5250d94fc2231ba7d898e71500789d", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/usage.js": "61071feb99ac220f1b27036406ae8e4f9ee606b373a5f3bcb60042c7bcfbd0d8", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/apply-extends.js": "64640dce92669705abead3bdbe2c46c8318c8623843a55e4726fb3c55ff9dd1d", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/is-promise.js": "be45baa3090c5106dd4e442cceef6b357a268783a2ee28ec10fe131a8cd8db72", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/levenshtein.js": "d8638efc3376b5f794b1c8df6ef4f3d484b29d919127c7fdc242400e3cfded91", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/maybe-async-result.js": "31cf4026279e14c87d16faa14ac758f35c8cc5795d29393c5ce07120f5a3caf6", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/obj-filter.js": "5523fb2288d1e86ed48c460e176770b49587554df4ae2405b468c093786b040b", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/set-blocking.js": "6fa8ffc3299f456e42902736bae35fbc1f2dc96b3905a02ba9629f5bd9f80af1", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/utils/which-module.js": "9267633b2c9f8990b2c699101b641e59ae59932e0dee5270613c0508bfa13c5d", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/validation.js": "3dc366de2eb23bc9457ed3e120b69db9d801251bef3dc19f93e4c0380ac0198c", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/yargs-factory.js": "a3e629d7d063b5ac007b18a0d8e9ad2ca72ca4d702c5c46822fbbdfdd6c512df", - "https://deno.land/x/yargs@v17.1.1-deno/build/lib/yerror.js": "1d9dead374fe06c8f13f2e4adafc002b8a15682b7185abf29638f1be96fd9dfc", - "https://deno.land/x/yargs@v17.1.1-deno/deno-types.ts": "62f5c61899c6da491890c8c84fd9580cfbfa2a83f5a70f6dc74727bbfb148623", - "https://deno.land/x/yargs@v17.1.1-deno/deno.ts": "f3df0bfd08ba367ec36dc59ef6cab1a391ace49ad44387ec5fe5d76289af08af", - "https://deno.land/x/yargs@v17.1.1-deno/lib/platform-shims/deno.ts": "b5a48b40d5c64fe66f5a77f87ebaf4413eea828ccd8159feeac370b3eef9a356", - "https://deno.land/x/yargs_parser@v20.2.4-deno/build/lib/string-utils.js": "12fc056b23703bc370aae5b179dc5abee53fca277abc30eaf76f78d2546d6413", - "https://deno.land/x/yargs_parser@v20.2.4-deno/build/lib/tokenize-arg-string.js": "7e0875b11795b8e217386e45f14b24a6e501ebbc62e15aa469aa8829d4d0ee61", - "https://deno.land/x/yargs_parser@v20.2.4-deno/build/lib/yargs-parser.js": "453200a7dfbb002e605d8009b7dad30f2b1d93665e046ab89c073a4fe63dfd48", - "https://deno.land/x/yargs_parser@v20.2.4-deno/deno.ts": "ad53c0c82c3982c4fc5be9472384b259e0a32ce1f7ae0f68de7b2445df5642fc" - } + "remote": {} }