From e386dd25d138886501e513d9e8ccd9ed7e021ae7 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 4 Dec 2024 21:15:20 +0100 Subject: [PATCH] Add syntax highlighting for diffs --- Cargo.lock | 643 +++++++++++++- crates/radicle-tauri/src/commands/diff.rs | 5 +- crates/radicle-types/Cargo.toml | 19 +- crates/radicle-types/bindings/diff/Added.ts | 5 + .../radicle-types/bindings/diff/Addition.ts | 4 + crates/radicle-types/bindings/diff/Copied.ts | 11 + crates/radicle-types/bindings/diff/Deleted.ts | 5 + .../radicle-types/bindings/diff/Deletion.ts | 4 + crates/radicle-types/bindings/diff/Diff.ts | 5 + .../bindings/diff/DiffContent.ts | 11 + .../radicle-types/bindings/diff/DiffFile.ts | 4 + .../radicle-types/bindings/diff/EofNewLine.ts | 7 + .../radicle-types/bindings/diff/FileDiff.ts | 13 + .../radicle-types/bindings/diff/FileMode.ts | 3 + .../radicle-types/bindings/diff/FileStats.ts | 3 + crates/radicle-types/bindings/diff/Hunk.ts | 9 + crates/radicle-types/bindings/diff/Hunks.ts | 4 + crates/radicle-types/bindings/diff/Line.ts | 3 + .../bindings/diff/Modification.ts | 15 + .../radicle-types/bindings/diff/Modified.ts | 10 + crates/radicle-types/bindings/diff/Moved.ts | 11 + crates/radicle-types/bindings/diff/Stats.ts | 7 + crates/radicle-types/bindings/syntax/Label.ts | 7 + crates/radicle-types/bindings/syntax/Line.ts | 7 + crates/radicle-types/bindings/syntax/Paint.ts | 6 + crates/radicle-types/src/cobs/diff.rs | 3 +- crates/radicle-types/src/diff.rs | 415 +++++++++ crates/radicle-types/src/lib.rs | 2 + crates/radicle-types/src/syntax.rs | 825 ++++++++++++++++++ crates/radicle-types/src/traits/repo.rs | 22 +- index.html | 1 + public/syntax.css | 60 ++ scripts/check-js | 2 +- src/components/Changeset.svelte | 29 + src/components/Changeset/FileDiff.svelte | 290 ++++++ src/components/File.svelte | 70 ++ src/views/repo/Patch.svelte | 17 + 37 files changed, 2537 insertions(+), 20 deletions(-) create mode 100644 crates/radicle-types/bindings/diff/Added.ts create mode 100644 crates/radicle-types/bindings/diff/Addition.ts create mode 100644 crates/radicle-types/bindings/diff/Copied.ts create mode 100644 crates/radicle-types/bindings/diff/Deleted.ts create mode 100644 crates/radicle-types/bindings/diff/Deletion.ts create mode 100644 crates/radicle-types/bindings/diff/Diff.ts create mode 100644 crates/radicle-types/bindings/diff/DiffContent.ts create mode 100644 crates/radicle-types/bindings/diff/DiffFile.ts create mode 100644 crates/radicle-types/bindings/diff/EofNewLine.ts create mode 100644 crates/radicle-types/bindings/diff/FileDiff.ts create mode 100644 crates/radicle-types/bindings/diff/FileMode.ts create mode 100644 crates/radicle-types/bindings/diff/FileStats.ts create mode 100644 crates/radicle-types/bindings/diff/Hunk.ts create mode 100644 crates/radicle-types/bindings/diff/Hunks.ts create mode 100644 crates/radicle-types/bindings/diff/Line.ts create mode 100644 crates/radicle-types/bindings/diff/Modification.ts create mode 100644 crates/radicle-types/bindings/diff/Modified.ts create mode 100644 crates/radicle-types/bindings/diff/Moved.ts create mode 100644 crates/radicle-types/bindings/diff/Stats.ts create mode 100644 crates/radicle-types/bindings/syntax/Label.ts create mode 100644 crates/radicle-types/bindings/syntax/Line.ts create mode 100644 crates/radicle-types/bindings/syntax/Paint.ts create mode 100644 crates/radicle-types/src/diff.rs create mode 100644 crates/radicle-types/src/syntax.rs create mode 100644 public/syntax.css create mode 100644 src/components/Changeset.svelte create mode 100644 src/components/Changeset/FileDiff.svelte create mode 100644 src/components/File.svelte diff --git a/Cargo.lock b/Cargo.lock index 489e8d5..e70dae6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.24.2" @@ -69,6 +79,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -99,6 +121,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "amplify" version = "4.7.0" @@ -228,6 +256,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" +[[package]] +name = "ast_node" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9184f2b369b3e8625712493c89b785881f27eedc6cde480a81883cef78868b2" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.81", +] + [[package]] name = "async-trait" version = "0.1.83" @@ -406,6 +446,15 @@ dependencies = [ "sha2", ] +[[package]] +name = "better_scoped_tls" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297b153aa5e573b5863108a6ddc9d5c968bd0b20e75cc614ee9821d2f45679c7" +dependencies = [ + "scoped-tls", +] + [[package]] name = "bit_field" version = "0.10.2" @@ -544,6 +593,9 @@ name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +dependencies = [ + "allocator-api2", +] [[package]] name = "byte-unit" @@ -683,9 +735,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "jobserver", "libc", @@ -1139,6 +1191,56 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "data-url" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" + +[[package]] +name = "deno_ast" +version = "0.38.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "584547d27786a734536fde7088f8429d355569c39410427be44695c300618408" +dependencies = [ + "deno_media_type", + "deno_terminal", + "dprint-swc-ext", + "once_cell", + "percent-encoding", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_eq_ignore_macros", + "text_lines", + "thiserror", + "unicode-width", + "url", +] + +[[package]] +name = "deno_media_type" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8978229b82552bf8457a0125aa20863f023619cfc21ebb007b1e571d68fd85b" +dependencies = [ + "data-url", + "serde", + "url", +] + +[[package]] +name = "deno_terminal" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6337d4e7f375f8b986409a76fbeecfa4bd8a1343e63355729ae4befa058eaf" +dependencies = [ + "once_cell", + "termcolor", +] + [[package]] name = "der" version = "0.7.9" @@ -1243,6 +1345,63 @@ dependencies = [ "serde", ] +[[package]] +name = "dprint-core" +version = "0.66.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ab0dd2bedc109d25f0d21afb09b7d329f6c6fa83b095daf31d2d967e091548" +dependencies = [ + "anyhow", + "bumpalo", + "hashbrown 0.14.5", + "indexmap 2.6.0", + "rustc-hash", + "serde", + "unicode-width", +] + +[[package]] +name = "dprint-core-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1675ad2b358481f3cc46202040d64ac7a36c4ade414a696df32e0e45421a6e9f" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dprint-plugin-typescript" +version = "0.90.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c3c339020ebbbbbe5fc049350935ee2ea2ba5a3fc01f753588639a30404cda" +dependencies = [ + "anyhow", + "deno_ast", + "dprint-core", + "dprint-core-macros", + "percent-encoding", + "rustc-hash", + "serde", +] + +[[package]] +name = "dprint-swc-ext" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "019d17f2c2457c5a70a7cf4505b1a562ca8ab168c0ac0c005744efbd29fcb8fe" +dependencies = [ + "allocator-api2", + "bumpalo", + "num-bigint", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "text_lines", +] + [[package]] name = "dtoa" version = "1.0.9" @@ -1542,6 +1701,17 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "from_variant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32016f1242eb82af5474752d00fd8ebcd9004bd69b462b1c91de833972d08ed4" +dependencies = [ + "proc-macro2", + "swc_macros_common", + "syn 2.0.81", +] + [[package]] name = "funty" version = "2.0.0" @@ -2027,7 +2197,17 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", ] [[package]] @@ -2069,6 +2249,20 @@ dependencies = [ "digest", ] +[[package]] +name = "hstr" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dae404c0c5d4e95d4858876ab02eecd6a196bb8caa42050dfa809938833fc412" +dependencies = [ + "hashbrown 0.14.5", + "new_debug_unreachable", + "once_cell", + "phf 0.11.2", + "rustc-hash", + "triomphe", +] + [[package]] name = "html5ever" version = "0.26.0" @@ -2332,6 +2526,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "is-macro" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.81", +] + [[package]] name = "is-wsl" version = "0.4.0" @@ -2858,6 +3064,7 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", + "serde", ] [[package]] @@ -3692,6 +3899,15 @@ dependencies = [ "syn 2.0.81", ] +[[package]] +name = "psm" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" +dependencies = [ + "cc", +] + [[package]] name = "ptr_meta" version = "0.1.4" @@ -3906,6 +4122,21 @@ dependencies = [ "serde", "serde_json", "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", ] @@ -4254,6 +4485,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.1" @@ -4324,6 +4561,12 @@ dependencies = [ "syn 2.0.81", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -4639,6 +4882,17 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + [[package]] name = "socket2" version = "0.5.7" @@ -4811,6 +5065,31 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "stacker" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799c883d55abdb5e98af1a7b3f23b9b6de8ecada0ecac058672d7635eb48ca7b" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.59.0", +] + +[[package]] +name = "static_assertions" +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" @@ -4837,6 +5116,18 @@ dependencies = [ "quote", ] +[[package]] +name = "string_enum" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e383308aebc257e7d7920224fa055c632478d92744eca77f99be8fa1545b90" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.81", +] + [[package]] name = "strsim" version = "0.11.1" @@ -4849,6 +5140,128 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "swc_atoms" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6567e4e67485b3e7662b486f1565bdae54bd5b9d6b16b2ba1a9babb1e42125" +dependencies = [ + "hstr", + "once_cell", + "rustc-hash", + "serde", +] + +[[package]] +name = "swc_common" +version = "0.33.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2f9706038906e66f3919028f9f7a37f3ed552f1b85578e93f4468742e2da438" +dependencies = [ + "ast_node", + "better_scoped_tls", + "cfg-if", + "either", + "from_variant", + "new_debug_unreachable", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "siphasher 0.3.11", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_visit", + "tracing", + "unicode-width", + "url", +] + +[[package]] +name = "swc_ecma_ast" +version = "0.113.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1690cc0c9ab60b44ac0225ba1e231ac532f7ba1d754df761c6ee607561afae" +dependencies = [ + "bitflags 2.6.0", + "is-macro", + "num-bigint", + "phf 0.11.2", + "scoped-tls", + "serde", + "string_enum", + "swc_atoms", + "swc_common", + "unicode-id-start", +] + +[[package]] +name = "swc_ecma_parser" +version = "0.144.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0499e69683ae5d67a20ff0279b94bc90f29df7922a46331b54d5dd367bf89570" +dependencies = [ + "either", + "new_debug_unreachable", + "num-bigint", + "num-traits", + "phf 0.11.2", + "serde", + "smallvec", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", + "typed-arena", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "695a1d8b461033d32429b5befbf0ad4d7a2c4d6ba9cd5ba4e0645c615839e8e4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.81", +] + +[[package]] +name = "swc_macros_common" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27e18fbfe83811ffae2bb23727e45829a0d19c6870bced7c0f545cc99ad248dd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.81", +] + +[[package]] +name = "swc_visit" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043d11fe683dcb934583ead49405c0896a5af5face522e4682c16971ef7871b9" +dependencies = [ + "either", + "swc_visit_macros", +] + +[[package]] +name = "swc_visit_macros" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92807d840959f39c60ce8a774a3f83e8193c658068e6d270dbe0a05e40e90b41" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.81", +] + [[package]] name = "swift-rs" version = "1.0.7" @@ -5346,6 +5759,15 @@ dependencies = [ "tower-http", ] +[[package]] +name = "text_lines" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd5828de7deaa782e1dd713006ae96b3bee32d3279b79eb67ecf8072c059bcf" +dependencies = [ + "serde", +] + [[package]] name = "thin-slice" version = "0.1.1" @@ -5580,9 +6002,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.81", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -5613,6 +6047,188 @@ 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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2416de7eea3f2e1bd53c250f2d3f3394fc77f78497680f37f4b87918b8d752e3" +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.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -5625,6 +6241,7 @@ version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a2f31991cee3dce1ca4f929a8a04fdd11fd8801aac0f2030b0fa8a0a3fef6b9" dependencies = [ + "dprint-plugin-typescript", "lazy_static", "serde_json", "thiserror", @@ -5643,6 +6260,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typeid" version = "1.0.2" @@ -5702,6 +6325,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +[[package]] +name = "unicode-id-start" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02aebfa694eccbbbffdd92922c7de136b9fe764396d2f10e21bce1681477cfc1" + [[package]] name = "unicode-ident" version = "1.0.13" @@ -5723,6 +6352,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "universal-hash" version = "0.5.1" @@ -6063,7 +6698,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] 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 10a5fb7..92ff9da 100644 --- a/crates/radicle-types/Cargo.toml +++ b/crates/radicle-types/Cargo.toml @@ -7,10 +7,25 @@ edition = "2021" anyhow = { version = "1.0.90" } axum = { version = "0.7.5", default-features = false, features = ["json"] } base64 = { version = "0.22.1" } +localtime = { version = "1.3.1" } radicle = { git = "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git" } radicle-surf = { version = "0.22.1", features = ["serde"] } serde = { version = "1.0.210", features = ["derive"] } serde_json = { version = "1.0.132" } thiserror = { version = "1.0.65" } -ts-rs = { version = "10.0.0", features = [ "serde-json-impl", "no-serde-warnings" ] } -localtime = { version = "1.3.1" } +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" } +ts-rs = { version = "10.0.0", features = [ "format", "serde-json-impl", "no-serde-warnings" ] } 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