diff --git a/frontend/obsidian-plugin/manifest.json b/frontend/obsidian-plugin/manifest.json index a15afeab..c4464e91 100644 --- a/frontend/obsidian-plugin/manifest.json +++ b/frontend/obsidian-plugin/manifest.json @@ -1,7 +1,7 @@ { "id": "vault-link", "name": "VaultLink", - "version": "0.6.1", + "version": "0.6.0", "minAppVersion": "0.0.0", "description": "Self-hosted synchronization and collaboration for your Vault.", "author": "Andras Schmelczer", diff --git a/frontend/obsidian-plugin/package.json b/frontend/obsidian-plugin/package.json index ce8f8b1a..18159d4b 100644 --- a/frontend/obsidian-plugin/package.json +++ b/frontend/obsidian-plugin/package.json @@ -1,6 +1,6 @@ { "name": "vault-link-obsidian-plugin", - "version": "0.6.1", + "version": "0.6.0", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { @@ -23,7 +23,7 @@ "mini-css-extract-plugin": "^2.9.2", "obsidian": "1.8.7", "resolve-url-loader": "^5.0.0", - "sass": "^1.89.1", + "sass": "^1.91.0", "sass-loader": "^16.0.5", "sync-client": "file:../sync-client", "terser-webpack-plugin": "^5.3.14", diff --git a/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts b/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts index 8801ecda..5dff2c59 100644 --- a/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts +++ b/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts @@ -18,6 +18,25 @@ import { getRandomColor } from "src/utils/get-random-color"; import type { SpanWithHistory } from "reconcile-text"; import { reconcileWithHistory } from "reconcile-text"; +function findWhereToMoveCursor( + cursor: number, + spans: SpanWithHistory[] +): number | null { + let position = 0; + for (const span of spans) { + // left and origin are the same + if (position === cursor && span.history === "AddedFromRight") { + return position + span.text.length; + } + position += span.text.length; + if (position === cursor && span.history === "RemovedFromRight") { + return position - span.text.length; + } + } + + return null; +} + const forceUpdate = StateEffect.define(); export class RemoteCursorsPluginValue implements PluginValue { @@ -79,16 +98,9 @@ export class RemoteCursorsPluginValue implements PluginValue { }); } - private static interpolateRemoteCursorPositions( - original: string, - edited: string - ): void { - if ( - original === edited || - RemoteCursorsPluginValue.cursors.length === 0 - ) { - return; - } + public update(update: ViewUpdate): void { + const original = update.startState.doc.toString(); + const edited = update.state.doc.toString(); const updatedPositions: number[] = []; const reconciled = reconcileWithHistory( @@ -102,11 +114,12 @@ export class RemoteCursorsPluginValue implements PluginValue { ] ) }, - edited + edited, + "Character" ); reconciled.cursors.forEach(({ id, position }) => { - const whereToJump = RemoteCursorsPluginValue.findWhereToMoveCursor( + const whereToJump = findWhereToMoveCursor( position, reconciled.history ); @@ -121,35 +134,6 @@ export class RemoteCursorsPluginValue implements PluginValue { span.start = updatedPositions[i * 2]; span.end = updatedPositions[i * 2 + 1]; }); - } - - private static findWhereToMoveCursor( - cursor: number, - spans: SpanWithHistory[] - ): number | null { - let position = 0; - for (const span of spans) { - // left and origin are the same - if (position === cursor && span.history === "AddedFromRight") { - return position + span.text.length; - } - position += span.text.length; - if (position === cursor && span.history === "RemovedFromRight") { - return position - span.text.length; - } - } - - return null; - } - - public update(update: ViewUpdate): void { - const original = update.startState.doc.toString(); - const edited = update.state.doc.toString(); - - RemoteCursorsPluginValue.interpolateRemoteCursorPositions( - original, - edited - ); const decorations: Range[] = []; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 73309f06..4d8daf6f 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -5190,7 +5190,9 @@ "license": "MIT" }, "node_modules/sass": { - "version": "1.89.1", + "version": "1.91.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.91.0.tgz", + "integrity": "sha512-aFOZHGf+ur+bp1bCHZ+u8otKGh77ZtmFyXDo4tlYvT7PWql41Kwd8wdkPqhhT+h2879IVblcHFglIMofsFd1EA==", "dev": true, "license": "MIT", "dependencies": { @@ -6361,7 +6363,7 @@ }, "obsidian-plugin": { "name": "vault-link-obsidian-plugin", - "version": "0.6.1", + "version": "0.6.0", "license": "MIT", "devDependencies": { "@types/jest": "^29.5.14", @@ -6375,7 +6377,7 @@ "obsidian": "1.8.7", "reconcile-text": "^0.5.0", "resolve-url-loader": "^5.0.0", - "sass": "^1.89.1", + "sass": "^1.91.0", "sass-loader": "^16.0.5", "sync-client": "file:../sync-client", "terser-webpack-plugin": "^5.3.14", @@ -6390,7 +6392,7 @@ } }, "sync-client": { - "version": "0.6.1", + "version": "0.6.0", "dependencies": { "byte-base64": "^1.1.0", "minimatch": "^10.0.1", @@ -6433,7 +6435,7 @@ } }, "test-client": { - "version": "0.6.1", + "version": "0.6.0", "bin": { "test-client": "dist/cli.js" }, diff --git a/frontend/sync-client/package.json b/frontend/sync-client/package.json index b44ac8cc..1d32c118 100644 --- a/frontend/sync-client/package.json +++ b/frontend/sync-client/package.json @@ -1,6 +1,6 @@ { "name": "sync-client", - "version": "0.6.1", + "version": "0.6.0", "main": "dist/sync-client.node.js", "browser": "dist/sync-client.web.js", "types": "dist/types/index.d.ts", diff --git a/frontend/test-client/package.json b/frontend/test-client/package.json index dc5d2d44..0c8e69ea 100644 --- a/frontend/test-client/package.json +++ b/frontend/test-client/package.json @@ -1,6 +1,6 @@ { "name": "test-client", - "version": "0.6.1", + "version": "0.6.0", "private": true, "bin": { "test-client": "./dist/cli.js" diff --git a/manifest.json b/manifest.json index a15afeab..c4464e91 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "vault-link", "name": "VaultLink", - "version": "0.6.1", + "version": "0.6.0", "minAppVersion": "0.0.0", "description": "Self-hosted synchronization and collaboration for your Vault.", "author": "Andras Schmelczer", diff --git a/scripts/check.sh b/scripts/check.sh index f807d2c8..750831ed 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -9,6 +9,8 @@ cargo fmt --all -- --check cargo machete cargo test --verbose +scripts/update-api-types.sh + echo "Running checks in frontend" cd ../frontend npm ci diff --git a/scripts/e2e.sh b/scripts/e2e.sh index 952e1855..55cb1ac8 100755 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -3,12 +3,6 @@ set -e set -o pipefail -node_version=$(node -v | sed 's/^v\([0-9]*\).*/\1/') -if [ "$node_version" != "22" ]; then - echo "Error: This script requires Node.js version 22, found: $node_version" - exit 1 -fi - # Check if the argument is provided if [ $# -eq 0 ]; then echo "Usage: $0 " @@ -26,22 +20,13 @@ npm run build ../scripts/utils/wait-for-server.sh -cd .. -scripts/update-api-types.sh -if [[ $(git status --porcelain) ]]; then - git status --porcelain - echo "Failing CI because the working directory is not clean after generating api types" - exit 1 -fi -cd frontend - pids=() for i in $(seq 1 $process_count); do node test-client/dist/cli.js > "../logs/log_${i}.log" 2>&1 & pids+=($!) done -cd .. +cd - print_failed_log() { for i in $(seq 1 $process_count); do diff --git a/sync-server/Cargo.lock b/sync-server/Cargo.lock index 7bcdcb6b..9e9574d7 100644 --- a/sync-server/Cargo.lock +++ b/sync-server/Cargo.lock @@ -2205,7 +2205,7 @@ dependencies = [ [[package]] name = "sync_server" -version = "0.6.1" +version = "0.6.0" dependencies = [ "anyhow", "axum", diff --git a/sync-server/Cargo.toml b/sync-server/Cargo.toml index 7565adde..b4e5b1f8 100644 --- a/sync-server/Cargo.toml +++ b/sync-server/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Andras Schmelczer "] edition = "2024" license = "MIT" repository = "https://github.com/schmelczer/vault-link" -version = "0.6.1" +version = "0.6.0" [dependencies] serde = { version = "1.0.219", default-features = false, features = ["derive"] }