mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-02 11:06:14 +00:00
chore: rename wasm export from (#519)
* chore: rename wasm export from * fix: clippy
This commit is contained in:
parent
2110a4e33a
commit
dedc8e087e
5 changed files with 26 additions and 50 deletions
|
@ -3544,14 +3544,13 @@ impl MapHandler {
|
||||||
inner.with_state(|state| {
|
inner.with_state(|state| {
|
||||||
let a = state.as_map_state().unwrap();
|
let a = state.as_map_state().unwrap();
|
||||||
for (k, v) in a.iter() {
|
for (k, v) in a.iter() {
|
||||||
match &v.value {
|
if let Some(v) = &v.value {
|
||||||
Some(v) => match v {
|
match v {
|
||||||
LoroValue::Container(c) => {
|
LoroValue::Container(c) => {
|
||||||
f(k, ValueOrHandler::Handler(create_handler(inner, c.clone())))
|
f(k, ValueOrHandler::Handler(create_handler(inner, c.clone())))
|
||||||
}
|
}
|
||||||
value => f(k, ValueOrHandler::Value(value.clone())),
|
value => f(k, ValueOrHandler::Value(value.clone())),
|
||||||
},
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ impl LoroDoc {
|
||||||
///
|
///
|
||||||
/// @param mode - The export mode to use. Can be one of:
|
/// @param mode - The export mode to use. Can be one of:
|
||||||
/// - `{ mode: "snapshot" }`: Export a full snapshot of the document.
|
/// - `{ 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: "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.
|
/// - `{ 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
|
/// // Export updates from a specific version
|
||||||
/// const vv = doc.oplogVersion();
|
/// const vv = doc.oplogVersion();
|
||||||
/// doc.setText("text", "Hello Loro");
|
/// 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
|
/// // Export a garbage-collected snapshot
|
||||||
/// const gcBytes = doc.export({ mode: "shallow-snapshot", frontiers: doc.oplogFrontiers() });
|
/// 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() {
|
match mode.as_str() {
|
||||||
"update" => {
|
"update" => {
|
||||||
let start_vv = js_sys::Reflect::get(&js_value, &JsValue::from_str("start_vv"))?;
|
let from = js_sys::Reflect::get(&js_value, &JsValue::from_str("from"))?;
|
||||||
if start_vv.is_undefined() {
|
if from.is_undefined() {
|
||||||
Ok(ExportMode::all_updates())
|
Ok(ExportMode::all_updates())
|
||||||
} else {
|
} else {
|
||||||
let start_vv = js_to_version_vector(start_vv)?;
|
let from = js_to_version_vector(from)?;
|
||||||
// TODO: PERF: avoid this clone
|
// TODO: PERF: avoid this clone
|
||||||
Ok(ExportMode::updates_owned(start_vv.0.clone()))
|
Ok(ExportMode::updates_owned(from.0.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"snapshot" => Ok(ExportMode::Snapshot),
|
"snapshot" => Ok(ExportMode::Snapshot),
|
||||||
|
@ -4309,7 +4309,7 @@ interface LoroDoc {
|
||||||
/**
|
/**
|
||||||
* Export updates from the specific version to the current version
|
* 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
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
@ -4669,7 +4669,7 @@ export type JsonChange = {
|
||||||
|
|
||||||
export type ExportMode = {
|
export type ExportMode = {
|
||||||
mode: "update",
|
mode: "update",
|
||||||
start_vv?: VersionVector,
|
from?: VersionVector,
|
||||||
} | {
|
} | {
|
||||||
mode: "snapshot",
|
mode: "snapshot",
|
||||||
} | {
|
} | {
|
||||||
|
|
|
@ -497,7 +497,7 @@ describe("export", () => {
|
||||||
const doc = new LoroDoc();
|
const doc = new LoroDoc();
|
||||||
doc.getText("text").insert(0, "123");
|
doc.getText("text").insert(0, "123");
|
||||||
doc.commit();
|
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();
|
const doc2 = new LoroDoc();
|
||||||
doc2.import(updates);
|
doc2.import(updates);
|
||||||
expect(doc2.toJSON()).toStrictEqual({ text: "123" });
|
expect(doc2.toJSON()).toStrictEqual({ text: "123" });
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe("gc", () => {
|
||||||
doc.getList("list").delete(1, 1); // Delete "B"
|
doc.getList("list").delete(1, 1); // Delete "B"
|
||||||
doc.getMap("map").set("key", "value"); // Add a new key-value pair to a map
|
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);
|
newDoc.import(updatedBytes);
|
||||||
expect(newDoc.toJSON()).toEqual(doc.toJSON());
|
expect(newDoc.toJSON()).toEqual(doc.toJSON());
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ describe("gc", () => {
|
||||||
const docB = doc.fork();
|
const docB = doc.fork();
|
||||||
const v = docB.version();
|
const v = docB.version();
|
||||||
docB.getList("list").insert(1, "C");
|
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(1, "B");
|
||||||
doc.getList("list").insert(2, "C");
|
doc.getList("list").insert(2, "C");
|
||||||
|
|
|
@ -19,10 +19,10 @@ importers:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
vite-plugin-top-level-await:
|
vite-plugin-top-level-await:
|
||||||
specifier: ^1.2.2
|
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:
|
vite-plugin-wasm:
|
||||||
specifier: ^3.1.0
|
specifier: ^3.1.0
|
||||||
version: 3.3.0(vite@5.2.11)
|
version: 3.3.0(vite@4.5.3)
|
||||||
|
|
||||||
examples/loro-quill:
|
examples/loro-quill:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -44,7 +44,7 @@ importers:
|
||||||
version: 1.3.10
|
version: 1.3.10
|
||||||
'@vitejs/plugin-vue':
|
'@vitejs/plugin-vue':
|
||||||
specifier: ^4.1.0
|
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:
|
typescript:
|
||||||
specifier: ^5.2.0
|
specifier: ^5.2.0
|
||||||
version: 5.4.5
|
version: 5.4.5
|
||||||
|
@ -53,7 +53,7 @@ importers:
|
||||||
version: 4.5.3
|
version: 4.5.3
|
||||||
vite-plugin-top-level-await:
|
vite-plugin-top-level-await:
|
||||||
specifier: ^1.3.0
|
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:
|
vite-plugin-wasm:
|
||||||
specifier: ^3.2.2
|
specifier: ^3.2.2
|
||||||
version: 3.3.0(vite@4.5.3)
|
version: 3.3.0(vite@4.5.3)
|
||||||
|
@ -2905,19 +2905,15 @@ snapshots:
|
||||||
is-builtin-module: 3.2.1
|
is-builtin-module: 3.2.1
|
||||||
is-module: 1.0.0
|
is-module: 1.0.0
|
||||||
resolve: 1.22.8
|
resolve: 1.22.8
|
||||||
optionalDependencies:
|
|
||||||
rollup: 3.29.4
|
rollup: 3.29.4
|
||||||
|
|
||||||
'@rollup/plugin-virtual@3.0.2(rollup@4.17.2)':
|
'@rollup/plugin-virtual@3.0.2': {}
|
||||||
optionalDependencies:
|
|
||||||
rollup: 4.17.2
|
|
||||||
|
|
||||||
'@rollup/pluginutils@5.1.0(rollup@3.29.4)':
|
'@rollup/pluginutils@5.1.0(rollup@3.29.4)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/estree': 1.0.5
|
'@types/estree': 1.0.5
|
||||||
estree-walker: 2.0.2
|
estree-walker: 2.0.2
|
||||||
picomatch: 2.3.1
|
picomatch: 2.3.1
|
||||||
optionalDependencies:
|
|
||||||
rollup: 3.29.4
|
rollup: 3.29.4
|
||||||
|
|
||||||
'@rollup/rollup-android-arm-eabi@4.17.2':
|
'@rollup/rollup-android-arm-eabi@4.17.2':
|
||||||
|
@ -3046,7 +3042,6 @@ snapshots:
|
||||||
'@typescript-eslint/visitor-keys': 6.21.0
|
'@typescript-eslint/visitor-keys': 6.21.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
eslint: 8.57.0
|
eslint: 8.57.0
|
||||||
optionalDependencies:
|
|
||||||
typescript: 5.4.5
|
typescript: 5.4.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
@ -3068,7 +3063,6 @@ snapshots:
|
||||||
minimatch: 9.0.3
|
minimatch: 9.0.3
|
||||||
semver: 7.6.2
|
semver: 7.6.2
|
||||||
ts-api-utils: 1.3.0(typescript@5.4.5)
|
ts-api-utils: 1.3.0(typescript@5.4.5)
|
||||||
optionalDependencies:
|
|
||||||
typescript: 5.4.5
|
typescript: 5.4.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
@ -3080,7 +3074,7 @@ snapshots:
|
||||||
|
|
||||||
'@ungap/structured-clone@1.2.0': {}
|
'@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:
|
dependencies:
|
||||||
vite: 4.5.3
|
vite: 4.5.3
|
||||||
vue: 3.4.27(typescript@5.4.5)
|
vue: 3.4.27(typescript@5.4.5)
|
||||||
|
@ -3178,9 +3172,8 @@ snapshots:
|
||||||
minimatch: 9.0.4
|
minimatch: 9.0.4
|
||||||
muggle-string: 0.3.1
|
muggle-string: 0.3.1
|
||||||
path-browserify: 1.0.1
|
path-browserify: 1.0.1
|
||||||
vue-template-compiler: 2.7.16
|
|
||||||
optionalDependencies:
|
|
||||||
typescript: 5.4.5
|
typescript: 5.4.5
|
||||||
|
vue-template-compiler: 2.7.16
|
||||||
|
|
||||||
'@vue/reactivity@3.4.27':
|
'@vue/reactivity@3.4.27':
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -3197,7 +3190,7 @@ snapshots:
|
||||||
'@vue/shared': 3.4.27
|
'@vue/shared': 3.4.27
|
||||||
csstype: 3.1.3
|
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:
|
dependencies:
|
||||||
'@vue/compiler-ssr': 3.4.27
|
'@vue/compiler-ssr': 3.4.27
|
||||||
'@vue/shared': 3.4.27
|
'@vue/shared': 3.4.27
|
||||||
|
@ -4858,9 +4851,9 @@ snapshots:
|
||||||
- supports-color
|
- supports-color
|
||||||
- terser
|
- 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:
|
dependencies:
|
||||||
'@rollup/plugin-virtual': 3.0.2(rollup@4.17.2)
|
'@rollup/plugin-virtual': 3.0.2
|
||||||
'@swc/core': 1.5.5
|
'@swc/core': 1.5.5
|
||||||
uuid: 9.0.1
|
uuid: 9.0.1
|
||||||
vite: 4.5.3
|
vite: 4.5.3
|
||||||
|
@ -4868,24 +4861,10 @@ snapshots:
|
||||||
- '@swc/helpers'
|
- '@swc/helpers'
|
||||||
- rollup
|
- 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):
|
vite-plugin-wasm@3.3.0(vite@4.5.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
vite: 4.5.3
|
vite: 4.5.3
|
||||||
|
|
||||||
vite-plugin-wasm@3.3.0(vite@5.2.11):
|
|
||||||
dependencies:
|
|
||||||
vite: 5.2.11
|
|
||||||
|
|
||||||
vite@4.5.3:
|
vite@4.5.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild: 0.18.20
|
esbuild: 0.18.20
|
||||||
|
@ -4908,6 +4887,7 @@ snapshots:
|
||||||
'@vitest/runner': 1.6.0
|
'@vitest/runner': 1.6.0
|
||||||
'@vitest/snapshot': 1.6.0
|
'@vitest/snapshot': 1.6.0
|
||||||
'@vitest/spy': 1.6.0
|
'@vitest/spy': 1.6.0
|
||||||
|
'@vitest/ui': 1.6.0(vitest@1.6.0)
|
||||||
'@vitest/utils': 1.6.0
|
'@vitest/utils': 1.6.0
|
||||||
acorn-walk: 8.3.2
|
acorn-walk: 8.3.2
|
||||||
chai: 4.4.1
|
chai: 4.4.1
|
||||||
|
@ -4924,8 +4904,6 @@ snapshots:
|
||||||
vite: 5.2.11
|
vite: 5.2.11
|
||||||
vite-node: 1.6.0
|
vite-node: 1.6.0
|
||||||
why-is-node-running: 2.2.2
|
why-is-node-running: 2.2.2
|
||||||
optionalDependencies:
|
|
||||||
'@vitest/ui': 1.6.0(vitest@1.6.0)
|
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- less
|
- less
|
||||||
- lightningcss
|
- lightningcss
|
||||||
|
@ -4952,9 +4930,8 @@ snapshots:
|
||||||
'@vue/compiler-dom': 3.4.27
|
'@vue/compiler-dom': 3.4.27
|
||||||
'@vue/compiler-sfc': 3.4.27
|
'@vue/compiler-sfc': 3.4.27
|
||||||
'@vue/runtime-dom': 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
|
'@vue/shared': 3.4.27
|
||||||
optionalDependencies:
|
|
||||||
typescript: 5.4.5
|
typescript: 5.4.5
|
||||||
|
|
||||||
wcwidth@1.0.1:
|
wcwidth@1.0.1:
|
||||||
|
|
Loading…
Reference in a new issue