diff --git a/Cargo.lock b/Cargo.lock index 1d566a6..5186b44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -735,9 +735,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" dependencies = [ "jobserver", "libc", @@ -4140,6 +4140,21 @@ dependencies = [ "serde_json", "tempfile", "thiserror", + "tree-sitter-bash", + "tree-sitter-c", + "tree-sitter-css", + "tree-sitter-go", + "tree-sitter-highlight", + "tree-sitter-html", + "tree-sitter-javascript", + "tree-sitter-json", + "tree-sitter-md", + "tree-sitter-python", + "tree-sitter-ruby", + "tree-sitter-rust", + "tree-sitter-svelte-ng", + "tree-sitter-toml-ng", + "tree-sitter-typescript", "ts-rs", ] @@ -5087,6 +5102,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" + [[package]] name = "string_cache" version = "0.8.7" @@ -6044,6 +6065,178 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "tree-sitter" +version = "0.24.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67baf55e7e1b6806063b1e51041069c90afff16afcbbccd278d899f9d84bca4" +dependencies = [ + "cc", + "regex", + "regex-syntax", + "streaming-iterator", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-bash" +version = "0.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "329a4d48623ac337d42b1df84e81a1c9dbb2946907c102ca72db158c1964a52e" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-c" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db56fadd8c3c6bc880dffcf1177c9d1c54a71a5207716db8660189082e63b587" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-css" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25435a275adb3226b6fddab891bbc50d1a500774a44ceb97022a39666ccda75d" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-go" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b13d476345220dbe600147dd444165c5791bf85ef53e28acbedd46112ee18431" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-highlight" +version = "0.24.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f0f856de10d70a6d14d66db3648f7410c131cd49e989a863f15dda9acae6044" +dependencies = [ + "lazy_static", + "regex", + "streaming-iterator", + "thiserror", + "tree-sitter", +] + +[[package]] +name = "tree-sitter-html" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261b708e5d92061ede329babaaa427b819329a9d427a1d710abb0f67bbef63ee" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-javascript" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf40bf599e0416c16c125c3cec10ee5ddc7d1bb8b0c60fa5c4de249ad34dc1b1" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-json" +version = "0.24.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d727acca406c0020cffc6cf35516764f36c8e3dc4408e5ebe2cb35a947ec471" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-language" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ddffe35a0e5eeeadf13ff7350af564c6e73993a24db62caee1822b185c2600" + +[[package]] +name = "tree-sitter-md" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f968c22a01010b83fc960455ae729db08dbeb6388617d9113897cb9204b030" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-python" +version = "0.23.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70beaa47e19e1529e8787fc0a80ebbae5a9fdaefc5fcc8972c885c9abf6ab0f0" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-ruby" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0484ea4ef6bb9c575b4fdabde7e31340a8d2dbc7d52b321ac83da703249f95" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-rust" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4d64d449ca63e683c562c7743946a646671ca23947b9c925c0cfbe65051a4af" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-svelte-ng" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef0a71f9cf5e94373cc86c64893630c8a29bb25d3390a248268d08af2165fa37" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-toml-ng" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9adc2c898ae49730e857d75be403da3f92bb81d8e37a2f918a08dd10de5ebb1" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-typescript" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5f76ed8d947a75cc446d5fccd8b602ebf0cde64ccf2ffa434d873d7a575eff" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "triomphe" version = "0.1.13" diff --git a/crates/radicle-tauri/src/commands/diff.rs b/crates/radicle-tauri/src/commands/diff.rs index 6028cc1..6e4c344 100644 --- a/crates/radicle-tauri/src/commands/diff.rs +++ b/crates/radicle-tauri/src/commands/diff.rs @@ -1,6 +1,5 @@ -use radicle_surf as surf; - use radicle::identity; +use radicle_types as types; use radicle_types::error::Error; use radicle_types::traits::repo::Repo; @@ -11,6 +10,6 @@ pub async fn get_diff( ctx: tauri::State<'_, AppState>, rid: identity::RepoId, options: radicle_types::cobs::diff::Options, -) -> Result { +) -> Result { ctx.get_diff(rid, options) } diff --git a/crates/radicle-types/Cargo.toml b/crates/radicle-types/Cargo.toml index 32c9d6d..b5223df 100644 --- a/crates/radicle-types/Cargo.toml +++ b/crates/radicle-types/Cargo.toml @@ -15,3 +15,18 @@ thiserror = { version = "1.0.65" } ts-rs = { version = "10.0.0", features = ["serde-json-impl", "no-serde-warnings", "format"] } localtime = { version = "1.3.1" } tempfile = { version = "3.14.0" } +tree-sitter-bash = { version = "0.23.3" } +tree-sitter-c = { version = "0.23.2" } +tree-sitter-css = { version = "0.23.1" } +tree-sitter-go = { version = "0.23.4" } +tree-sitter-highlight = { version = "0.24.4" } +tree-sitter-html = { version = "0.23.2" } +tree-sitter-javascript = { version = "0.23.1" } +tree-sitter-json = { version = "0.24.8" } +tree-sitter-md = { version = "0.3.2" } +tree-sitter-python = { version = "0.23.4" } +tree-sitter-ruby = { version = "0.23.1" } +tree-sitter-rust = { version = "0.23.2" } +tree-sitter-svelte-ng = { version = "1.0.2" } +tree-sitter-toml-ng = { version = "0.7.0" } +tree-sitter-typescript = { version = "0.23.2" } diff --git a/crates/radicle-types/bindings/diff/Added.ts b/crates/radicle-types/bindings/diff/Added.ts new file mode 100644 index 0000000..82dc536 --- /dev/null +++ b/crates/radicle-types/bindings/diff/Added.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DiffContent } from "./DiffContent"; +import type { DiffFile } from "./DiffFile"; + +export type Added = { path: string; diff: DiffContent; new: DiffFile }; diff --git a/crates/radicle-types/bindings/diff/Addition.ts b/crates/radicle-types/bindings/diff/Addition.ts new file mode 100644 index 0000000..98bfe1e --- /dev/null +++ b/crates/radicle-types/bindings/diff/Addition.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Line } from "../syntax/Line"; + +export type Addition = { line: string; lineNo: number; highlight: Line | null }; diff --git a/crates/radicle-types/bindings/diff/Copied.ts b/crates/radicle-types/bindings/diff/Copied.ts new file mode 100644 index 0000000..d69dc7e --- /dev/null +++ b/crates/radicle-types/bindings/diff/Copied.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DiffContent } from "./DiffContent"; +import type { DiffFile } from "./DiffFile"; + +export type Copied = { + oldPath: string; + newPath: string; + old: DiffFile; + new: DiffFile; + diff: DiffContent; +}; diff --git a/crates/radicle-types/bindings/diff/Deleted.ts b/crates/radicle-types/bindings/diff/Deleted.ts new file mode 100644 index 0000000..052ba33 --- /dev/null +++ b/crates/radicle-types/bindings/diff/Deleted.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DiffContent } from "./DiffContent"; +import type { DiffFile } from "./DiffFile"; + +export type Deleted = { path: string; diff: DiffContent; old: DiffFile }; diff --git a/crates/radicle-types/bindings/diff/Deletion.ts b/crates/radicle-types/bindings/diff/Deletion.ts new file mode 100644 index 0000000..90ef5df --- /dev/null +++ b/crates/radicle-types/bindings/diff/Deletion.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Line } from "../syntax/Line"; + +export type Deletion = { line: string; lineNo: number; highlight: Line | null }; diff --git a/crates/radicle-types/bindings/diff/Diff.ts b/crates/radicle-types/bindings/diff/Diff.ts new file mode 100644 index 0000000..6744e8e --- /dev/null +++ b/crates/radicle-types/bindings/diff/Diff.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { FileDiff } from "./FileDiff"; +import type { Stats } from "./Stats"; + +export type Diff = { files: Array; stats: Stats }; diff --git a/crates/radicle-types/bindings/diff/DiffContent.ts b/crates/radicle-types/bindings/diff/DiffContent.ts new file mode 100644 index 0000000..6a470f4 --- /dev/null +++ b/crates/radicle-types/bindings/diff/DiffContent.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EofNewLine } from "./EofNewLine"; +import type { FileStats } from "./FileStats"; +import type { Hunks } from "./Hunks"; + +export type DiffContent = { "type": "binary" } | { + "type": "plain"; + hunks: Hunks; + stats: FileStats; + eof: EofNewLine; +} | { "type": "empty" }; diff --git a/crates/radicle-types/bindings/diff/DiffFile.ts b/crates/radicle-types/bindings/diff/DiffFile.ts new file mode 100644 index 0000000..2a1d63e --- /dev/null +++ b/crates/radicle-types/bindings/diff/DiffFile.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { FileMode } from "./FileMode"; + +export type DiffFile = { oid: string; mode: FileMode }; diff --git a/crates/radicle-types/bindings/diff/EofNewLine.ts b/crates/radicle-types/bindings/diff/EofNewLine.ts new file mode 100644 index 0000000..38b8064 --- /dev/null +++ b/crates/radicle-types/bindings/diff/EofNewLine.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type EofNewLine = + | "oldMissing" + | "newMissing" + | "bothMissing" + | "noneMissing"; diff --git a/crates/radicle-types/bindings/diff/FileDiff.ts b/crates/radicle-types/bindings/diff/FileDiff.ts new file mode 100644 index 0000000..db94592 --- /dev/null +++ b/crates/radicle-types/bindings/diff/FileDiff.ts @@ -0,0 +1,13 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Added } from "./Added"; +import type { Copied } from "./Copied"; +import type { Deleted } from "./Deleted"; +import type { Modified } from "./Modified"; +import type { Moved } from "./Moved"; + +export type FileDiff = + | { "status": "added" } & Added + | { "status": "deleted" } & Deleted + | { "status": "modified" } & Modified + | { "status": "moved" } & Moved + | { "status": "copied" } & Copied; diff --git a/crates/radicle-types/bindings/diff/FileMode.ts b/crates/radicle-types/bindings/diff/FileMode.ts new file mode 100644 index 0000000..12d5442 --- /dev/null +++ b/crates/radicle-types/bindings/diff/FileMode.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type FileMode = "blob" | "blobExecutable" | "tree" | "link" | "commit"; diff --git a/crates/radicle-types/bindings/diff/FileStats.ts b/crates/radicle-types/bindings/diff/FileStats.ts new file mode 100644 index 0000000..5892c45 --- /dev/null +++ b/crates/radicle-types/bindings/diff/FileStats.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type FileStats = { additions: number; deletions: number }; diff --git a/crates/radicle-types/bindings/diff/Hunk.ts b/crates/radicle-types/bindings/diff/Hunk.ts new file mode 100644 index 0000000..363f52f --- /dev/null +++ b/crates/radicle-types/bindings/diff/Hunk.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Modification } from "./Modification"; + +export type Hunk = { + header: string; + lines: Array; + old: { start: number; end: number }; + new: { start: number; end: number }; +}; diff --git a/crates/radicle-types/bindings/diff/Hunks.ts b/crates/radicle-types/bindings/diff/Hunks.ts new file mode 100644 index 0000000..ebcfbb1 --- /dev/null +++ b/crates/radicle-types/bindings/diff/Hunks.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Hunk } from "./Hunk"; + +export type Hunks = Array; diff --git a/crates/radicle-types/bindings/diff/Line.ts b/crates/radicle-types/bindings/diff/Line.ts new file mode 100644 index 0000000..07d22d8 --- /dev/null +++ b/crates/radicle-types/bindings/diff/Line.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Line = Array; diff --git a/crates/radicle-types/bindings/diff/Modification.ts b/crates/radicle-types/bindings/diff/Modification.ts new file mode 100644 index 0000000..878d590 --- /dev/null +++ b/crates/radicle-types/bindings/diff/Modification.ts @@ -0,0 +1,15 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Addition } from "./Addition"; +import type { Deletion } from "./Deletion"; +import type { Line } from "../syntax/Line"; + +export type Modification = + | { "type": "addition" } & Addition + | { "type": "deletion" } & Deletion + | { + "type": "context"; + line: string; + lineNoOld: number; + lineNoNew: number; + highlight: Line | null; + }; diff --git a/crates/radicle-types/bindings/diff/Modified.ts b/crates/radicle-types/bindings/diff/Modified.ts new file mode 100644 index 0000000..ba5743e --- /dev/null +++ b/crates/radicle-types/bindings/diff/Modified.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DiffContent } from "./DiffContent"; +import type { DiffFile } from "./DiffFile"; + +export type Modified = { + path: string; + diff: DiffContent; + old: DiffFile; + new: DiffFile; +}; diff --git a/crates/radicle-types/bindings/diff/Moved.ts b/crates/radicle-types/bindings/diff/Moved.ts new file mode 100644 index 0000000..637d18b --- /dev/null +++ b/crates/radicle-types/bindings/diff/Moved.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DiffContent } from "./DiffContent"; +import type { DiffFile } from "./DiffFile"; + +export type Moved = { + oldPath: string; + old: DiffFile; + newPath: string; + new: DiffFile; + diff: DiffContent; +}; diff --git a/crates/radicle-types/bindings/diff/Stats.ts b/crates/radicle-types/bindings/diff/Stats.ts new file mode 100644 index 0000000..2612086 --- /dev/null +++ b/crates/radicle-types/bindings/diff/Stats.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Stats = { + filesChanged: number; + insertions: number; + deletions: number; +}; diff --git a/crates/radicle-types/bindings/syntax/Label.ts b/crates/radicle-types/bindings/syntax/Label.ts new file mode 100644 index 0000000..9cc1fdd --- /dev/null +++ b/crates/radicle-types/bindings/syntax/Label.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Paint } from "./Paint"; + +/** + * A styled string that does not contain any `'\n'`. + */ +export type Label = Paint; diff --git a/crates/radicle-types/bindings/syntax/Line.ts b/crates/radicle-types/bindings/syntax/Line.ts new file mode 100644 index 0000000..9c955d3 --- /dev/null +++ b/crates/radicle-types/bindings/syntax/Line.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Label } from "./Label"; + +/** + * A line of text that has styling and can be displayed. + */ +export type Line = { items: Array