chore: rename wasm export from (#519)

* chore: rename wasm export from

* fix: clippy
This commit is contained in:
Leon Zhao 2024-10-18 19:49:40 +08:00 committed by GitHub
parent 2110a4e33a
commit dedc8e087e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 26 additions and 50 deletions

View file

@ -3544,14 +3544,13 @@ impl MapHandler {
inner.with_state(|state| {
let a = state.as_map_state().unwrap();
for (k, v) in a.iter() {
match &v.value {
Some(v) => match v {
if let Some(v) = &v.value {
match v {
LoroValue::Container(c) => {
f(k, ValueOrHandler::Handler(create_handler(inner, c.clone())))
}
value => f(k, ValueOrHandler::Value(value.clone())),
},
None => {}
}
}
}
});

View file

@ -1051,7 +1051,7 @@ impl LoroDoc {
///
/// @param mode - The export mode to use. Can be one of:
/// - `{ mode: "snapshot" }`: Export a full snapshot of the document.
/// - `{ mode: "update", start_vv: VersionVector }`: Export updates from the given version vector.
/// - `{ mode: "update", from: VersionVector }`: Export updates from the given version vector.
/// - `{ mode: "updates-in-range", spans: { id: ID, len: number }[] }`: Export updates within the specified ID spans.
/// - `{ mode: "shallow-snapshot", frontiers: Frontiers }`: Export a garbage-collected snapshot up to the given frontiers.
///
@ -1070,7 +1070,7 @@ impl LoroDoc {
/// // Export updates from a specific version
/// const vv = doc.oplogVersion();
/// doc.setText("text", "Hello Loro");
/// const updateBytes = doc.export({ mode: "update", start_vv: vv });
/// const updateBytes = doc.export({ mode: "update", from: vv });
///
/// // Export a garbage-collected snapshot
/// const gcBytes = doc.export({ mode: "shallow-snapshot", frontiers: doc.oplogFrontiers() });
@ -4215,13 +4215,13 @@ fn js_to_export_mode(js_mode: JsExportMode) -> JsResult<ExportMode<'static>> {
match mode.as_str() {
"update" => {
let start_vv = js_sys::Reflect::get(&js_value, &JsValue::from_str("start_vv"))?;
if start_vv.is_undefined() {
let from = js_sys::Reflect::get(&js_value, &JsValue::from_str("from"))?;
if from.is_undefined() {
Ok(ExportMode::all_updates())
} else {
let start_vv = js_to_version_vector(start_vv)?;
let from = js_to_version_vector(from)?;
// TODO: PERF: avoid this clone
Ok(ExportMode::updates_owned(start_vv.0.clone()))
Ok(ExportMode::updates_owned(from.0.clone()))
}
}
"snapshot" => Ok(ExportMode::Snapshot),
@ -4309,7 +4309,7 @@ interface LoroDoc {
/**
* Export updates from the specific version to the current version
*
* @deprecated Use `export({mode: "update", start_vv: version})` instead
* @deprecated Use `export({mode: "update", from: version})` instead
*
* @example
* ```ts
@ -4669,7 +4669,7 @@ export type JsonChange = {
export type ExportMode = {
mode: "update",
start_vv?: VersionVector,
from?: VersionVector,
} | {
mode: "snapshot",
} | {

View file

@ -497,7 +497,7 @@ describe("export", () => {
const doc = new LoroDoc();
doc.getText("text").insert(0, "123");
doc.commit();
const updates = doc.export({ mode: "update", start_vv: new VersionVector(null) });
const updates = doc.export({ mode: "update", from: new VersionVector(null) });
const doc2 = new LoroDoc();
doc2.import(updates);
expect(doc2.toJSON()).toStrictEqual({ text: "123" });

View file

@ -25,7 +25,7 @@ describe("gc", () => {
doc.getList("list").delete(1, 1); // Delete "B"
doc.getMap("map").set("key", "value"); // Add a new key-value pair to a map
const updatedBytes = doc.export({ mode: "update", start_vv: newDoc.version() });
const updatedBytes = doc.export({ mode: "update", from: newDoc.version() });
newDoc.import(updatedBytes);
expect(newDoc.toJSON()).toEqual(doc.toJSON());
});
@ -38,7 +38,7 @@ describe("gc", () => {
const docB = doc.fork();
const v = docB.version();
docB.getList("list").insert(1, "C");
const updates = docB.export({ mode: "update", start_vv: v });
const updates = docB.export({ mode: "update", from: v });
doc.getList("list").insert(1, "B");
doc.getList("list").insert(2, "C");

View file

@ -19,10 +19,10 @@ importers:
devDependencies:
vite-plugin-top-level-await:
specifier: ^1.2.2
version: 1.4.1(rollup@4.17.2)(vite@5.2.11)
version: 1.4.1(vite@4.5.3)
vite-plugin-wasm:
specifier: ^3.1.0
version: 3.3.0(vite@5.2.11)
version: 3.3.0(vite@4.5.3)
examples/loro-quill:
dependencies:
@ -44,7 +44,7 @@ importers:
version: 1.3.10
'@vitejs/plugin-vue':
specifier: ^4.1.0
version: 4.6.2(vite@4.5.3)(vue@3.4.27(typescript@5.4.5))
version: 4.6.2(vite@4.5.3)(vue@3.4.27)
typescript:
specifier: ^5.2.0
version: 5.4.5
@ -53,7 +53,7 @@ importers:
version: 4.5.3
vite-plugin-top-level-await:
specifier: ^1.3.0
version: 1.4.1(rollup@4.17.2)(vite@4.5.3)
version: 1.4.1(vite@4.5.3)
vite-plugin-wasm:
specifier: ^3.2.2
version: 3.3.0(vite@4.5.3)
@ -2905,19 +2905,15 @@ snapshots:
is-builtin-module: 3.2.1
is-module: 1.0.0
resolve: 1.22.8
optionalDependencies:
rollup: 3.29.4
'@rollup/plugin-virtual@3.0.2(rollup@4.17.2)':
optionalDependencies:
rollup: 4.17.2
'@rollup/plugin-virtual@3.0.2': {}
'@rollup/pluginutils@5.1.0(rollup@3.29.4)':
dependencies:
'@types/estree': 1.0.5
estree-walker: 2.0.2
picomatch: 2.3.1
optionalDependencies:
rollup: 3.29.4
'@rollup/rollup-android-arm-eabi@4.17.2':
@ -3046,7 +3042,6 @@ snapshots:
'@typescript-eslint/visitor-keys': 6.21.0
debug: 4.3.4
eslint: 8.57.0
optionalDependencies:
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
@ -3068,7 +3063,6 @@ snapshots:
minimatch: 9.0.3
semver: 7.6.2
ts-api-utils: 1.3.0(typescript@5.4.5)
optionalDependencies:
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
@ -3080,7 +3074,7 @@ snapshots:
'@ungap/structured-clone@1.2.0': {}
'@vitejs/plugin-vue@4.6.2(vite@4.5.3)(vue@3.4.27(typescript@5.4.5))':
'@vitejs/plugin-vue@4.6.2(vite@4.5.3)(vue@3.4.27)':
dependencies:
vite: 4.5.3
vue: 3.4.27(typescript@5.4.5)
@ -3178,9 +3172,8 @@ snapshots:
minimatch: 9.0.4
muggle-string: 0.3.1
path-browserify: 1.0.1
vue-template-compiler: 2.7.16
optionalDependencies:
typescript: 5.4.5
vue-template-compiler: 2.7.16
'@vue/reactivity@3.4.27':
dependencies:
@ -3197,7 +3190,7 @@ snapshots:
'@vue/shared': 3.4.27
csstype: 3.1.3
'@vue/server-renderer@3.4.27(vue@3.4.27(typescript@5.4.5))':
'@vue/server-renderer@3.4.27(vue@3.4.27)':
dependencies:
'@vue/compiler-ssr': 3.4.27
'@vue/shared': 3.4.27
@ -4858,9 +4851,9 @@ snapshots:
- supports-color
- terser
vite-plugin-top-level-await@1.4.1(rollup@4.17.2)(vite@4.5.3):
vite-plugin-top-level-await@1.4.1(vite@4.5.3):
dependencies:
'@rollup/plugin-virtual': 3.0.2(rollup@4.17.2)
'@rollup/plugin-virtual': 3.0.2
'@swc/core': 1.5.5
uuid: 9.0.1
vite: 4.5.3
@ -4868,24 +4861,10 @@ snapshots:
- '@swc/helpers'
- rollup
vite-plugin-top-level-await@1.4.1(rollup@4.17.2)(vite@5.2.11):
dependencies:
'@rollup/plugin-virtual': 3.0.2(rollup@4.17.2)
'@swc/core': 1.5.5
uuid: 9.0.1
vite: 5.2.11
transitivePeerDependencies:
- '@swc/helpers'
- rollup
vite-plugin-wasm@3.3.0(vite@4.5.3):
dependencies:
vite: 4.5.3
vite-plugin-wasm@3.3.0(vite@5.2.11):
dependencies:
vite: 5.2.11
vite@4.5.3:
dependencies:
esbuild: 0.18.20
@ -4908,6 +4887,7 @@ snapshots:
'@vitest/runner': 1.6.0
'@vitest/snapshot': 1.6.0
'@vitest/spy': 1.6.0
'@vitest/ui': 1.6.0(vitest@1.6.0)
'@vitest/utils': 1.6.0
acorn-walk: 8.3.2
chai: 4.4.1
@ -4924,8 +4904,6 @@ snapshots:
vite: 5.2.11
vite-node: 1.6.0
why-is-node-running: 2.2.2
optionalDependencies:
'@vitest/ui': 1.6.0(vitest@1.6.0)
transitivePeerDependencies:
- less
- lightningcss
@ -4952,9 +4930,8 @@ snapshots:
'@vue/compiler-dom': 3.4.27
'@vue/compiler-sfc': 3.4.27
'@vue/runtime-dom': 3.4.27
'@vue/server-renderer': 3.4.27(vue@3.4.27(typescript@5.4.5))
'@vue/server-renderer': 3.4.27(vue@3.4.27)
'@vue/shared': 3.4.27
optionalDependencies:
typescript: 5.4.5
wcwidth@1.0.1: