diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 4660d0f..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,75 +0,0 @@ -# What software is installed by default: -# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources - -name: build - -on: - push: - pull_request: - -defaults: - run: - shell: bash - -jobs: - build: - strategy: - matrix: - os: - - ubuntu-22.04 - - windows-latest - - macos-latest - - macos-13 - runs-on: ${{ matrix.os }} - steps: - - name: Check out repo - uses: actions/checkout@v4 - - - name: Set up rust - run: rustup update - - - name: Build - run: cargo build --release - - - name: Test - run: cargo test --release - - - name: Record target triple - run: rustc -vV | awk '/^host/ { print $2 }' > target/release/host - - - name: Upload - uses: actions/upload-artifact@v4 - with: - name: cove-${{ matrix.os }} - path: | - target/release/cove - target/release/cove.exe - target/release/host - - release: - runs-on: ubuntu-latest - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - needs: - - build - permissions: - contents: write - steps: - - name: Download artifacts - uses: actions/download-artifact@v4 - - - name: Zip artifacts - run: | - chmod +x cove-ubuntu-22.04/cove - chmod +x cove-windows-latest/cove.exe - chmod +x cove-macos-latest/cove - chmod +x cove-macos-13/cove - zip -jr "cove-$(cat cove-ubuntu-22.04/host).zip" cove-ubuntu-22.04/cove - zip -jr "cove-$(cat cove-windows-latest/host).zip" cove-windows-latest/cove.exe - zip -jr "cove-$(cat cove-macos-latest/host).zip" cove-macos-latest/cove - zip -jr "cove-$(cat cove-macos-13/host).zip" cove-macos-13/cove - - - name: Create new release - uses: softprops/action-gh-release@v2 - with: - body: Automated release, see [CHANGELOG.md](CHANGELOG.md) for more details. - files: "*.zip" diff --git a/.vscode/settings.json b/.vscode/settings.json index 4e428aa..7a89179 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "files.insertFinalNewline": true, "rust-analyzer.cargo.features": "all", "rust-analyzer.imports.granularity.enforce": true, - "rust-analyzer.imports.granularity.group": "crate", + "rust-analyzer.imports.granularity.group": "module", "rust-analyzer.imports.group.enable": true, "evenBetterToml.formatter.columnWidth": 100, } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f9ce8c..d9f1927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,83 +4,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Procedure when bumping the version number: - -1. Update dependencies in a separate commit +1. Update dependencies and flake in a separate commit 2. Set version number in `Cargo.toml` 3. Add new section in this changelog 4. Run `cargo run help-config > CONFIG.md` 5. Commit with message `Bump version to X.Y.Z` 6. Create tag named `vX.Y.Z` -7. Push `master` and the new tag +7. Fast-forward branch `latest` +8. Push `master`, `latest` and the new tag ## Unreleased -### Changed - -- Display emoji user id hashes in the nick list -- Compile linux binary with older glibc version - -## v0.9.3 - 2025-05-31 - -### Added - -- Key bindings for emoji-based user id hashing - -### Fixed - -- `keys.rooms.action.connect_autojoin` connecting to non-autojoin rooms - -## v0.9.2 - 2025-03-14 - -### Added - -- `bell_on_mention` config option - -## v0.9.1 - 2025-03-01 - -### Fixed - -- Rendering glitches with unicode-based width estimation - -## v0.9.0 - 2025-02-23 - -### Added - -- Unicode-based grapheme width estimation method - - `width_estimation_method` config option - - `--width-estimation-method` option -- Room links are now included in the `I` message links list - -### Changed - -- Updated documentation for `time_zone` config option -- When connecting to a room using `n` in the room list, the cursor now moves to that room -- Updated list of emoji names - -### Removed - -- Special handling of &rl2dev - -### Fixed - -- Nick color in rare edge cases -- Message link list rendering bug - -## v0.8.3 - 2024-05-20 - -### Changed - -- Updated list of emoji names - ## v0.8.2 - 2024-04-25 ### Changed - - Renamed `json-stream` export format to `json-lines` (see ) - Changed `json-lines` file extension from `.json` to `.jsonl` ### Fixed - - Crash when window is too small while empty message editor is visible - Mistakes in output and docs - Cove not cleaning up terminal state properly @@ -88,19 +29,16 @@ Procedure when bumping the version number: ## v0.8.1 - 2024-01-11 ### Added - - Support for setting window title - More information to room list heading - Key bindings for live caesar cipher de- and encoding ### Removed - - Key binding to open present page ## v0.8.0 - 2024-01-04 ### Added - - Support for multiple euph server domains - Support for `TZ` environment variable - `time_zone` config option @@ -110,7 +48,6 @@ Procedure when bumping the version number: - Welcome info box next to room list ### Changed - - The default euph domain is now https://euphoria.leet.nu/ everywhere - The config file format was changed to support multiple euph servers with different domains. Options previously located at `euph.rooms.*` should be reviewed and moved to `euph.servers."euphoria.leet.nu".rooms.*`. @@ -119,20 +56,17 @@ Procedure when bumping the version number: - Reduced connection timeout from 30 seconds to 10 seconds ### Fixed - - Room deletion popup accepting any room name - Duplicated key presses on Windows ## v0.7.1 - 2023-08-31 ### Changed - - Updated dependencies ## v0.7.0 - 2023-05-14 ### Added - - Auto-generated config documentation - in [CONFIG.md](CONFIG.md) - via `help-config` CLI command @@ -140,7 +74,6 @@ Procedure when bumping the version number: - `measure_widths` config option ### Changed - - Overhauled widget system and extracted generic widgets to [toss](https://github.com/Garmelon/toss) - Overhauled config system to support auto-generating documentation - Overhauled key binding system to make key bindings configurable @@ -154,18 +87,15 @@ Procedure when bumping the version number: ## v0.6.1 - 2023-04-10 ### Changed - - Improved JSON export performance - Always show rooms from config file in room list ### Fixed - - Rooms reconnecting instead of showing error popups ## v0.6.0 - 2023-04-04 ### Added - - Emoji support - `flake.nix`, making cove available as a nix flake - `json-stream` room export format @@ -173,37 +103,31 @@ Procedure when bumping the version number: - `--verbose` flag ### Changed - - Non-export info is now printed to stderr instead of stdout - Recognizes links without scheme (e.g. `euphoria.io` instead of `https://euphoria.io`) - Rooms waiting for reconnect are no longer sorted to bottom in default sort order ### Fixed - - Mentions not being stopped by `>` ## v0.5.2 - 2023-01-14 ### Added - - Key binding to open present page ### Changed - - Always connect to &rl2dev in ephemeral mode - Reduce amount of messages per &rl2dev log request ## v0.5.1 - 2022-11-27 ### Changed - - Increase reconnect delay to one minute - Print errors that occurred while cove was running more compactly ## v0.5.0 - 2022-09-26 ### Added - - Key bindings to navigate nick list - Room deletion confirmation popup - Message inspection popup @@ -212,12 +136,10 @@ Procedure when bumping the version number: - `rooms_sort_order` config option ### Changed - - Use nick changes to detect sessions for nick list - Support Unicode 15 ### Fixed - - Cursor being visible through popups - Cursor in lists when highlighted item moves off-screen - User disappearing from nick list when only one of their sessions disconnects @@ -225,7 +147,6 @@ Procedure when bumping the version number: ## v0.4.0 - 2022-09-01 ### Added - - Config file and `--config` cli option - `data_dir` config option - `ephemeral` config option @@ -241,17 +162,14 @@ Procedure when bumping the version number: - Key bindings to view and open links in a message ### Changed - - Some key bindings in the rooms list ### Fixed - - Rooms being stuck in "Connecting" state ## v0.3.0 - 2022-08-22 ### Added - - Account login and logout - Authentication dialog for password-protected rooms - Error popups in rooms when something goes wrong @@ -259,12 +177,10 @@ Procedure when bumping the version number: - Key binding to download more logs ### Changed - - Reduced amount of unnecessary redraws - Description of `export` CLI command ### Fixed - - Crash when connecting to nonexistent rooms - Crash when connecting to rooms that require authentication - Pasting multi-line strings into the editor @@ -272,18 +188,15 @@ Procedure when bumping the version number: ## v0.2.1 - 2022-08-11 ### Added - - Support for modifiers on special keys via the [kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) ### Fixed - - Joining new rooms no longer crashes cove - Scrolling when exiting message editor ## v0.2.0 - 2022-08-10 ### Added - - New messages are now marked as unseen - Sub-trees can now be folded - Support for pasting text into editors @@ -296,12 +209,10 @@ Procedure when bumping the version number: - Support for exporting multiple/all rooms at once ### Changed - - Reorganized export command - Slowed down room history download speed ### Fixed - - Chat rendering when deleting and re-joining a room - Spacing in some popups diff --git a/CONFIG.md b/CONFIG.md index 82a7242..66625d0 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -53,14 +53,6 @@ Available modifiers: ## Available options -### `bell_on_mention` - -**Required:** yes -**Type:** boolean -**Default:** `false` - -Ring the bell (character 0x07) when you are mentioned in a room. - ### `data_dir` **Required:** no @@ -101,9 +93,9 @@ Whether to automatically join this room on startup. **Type:** boolean **Default:** `false` -If `euph.servers..rooms..username` is set, this will force -cove to set the username even if there is already a different username -associated with the current session. +If `euph.rooms..username` is set, this will force cove to set the +username even if there is already a different username associated with +the current session. ### `euph.servers..rooms..password` @@ -537,14 +529,6 @@ Reply to message, inline if possible. Reply opposite to normal reply. -### `keys.tree.action.toggle_nick_emoji` - -**Required:** yes -**Type:** key binding -**Default:** `"e"` - -Toggle agent id based nick emoji. - ### `keys.tree.action.toggle_seen` **Required:** yes @@ -623,11 +607,12 @@ Move to root. **Type:** boolean **Default:** `false` -Whether to measure the width of graphemes (i.e. characters) as displayed -by the terminal emulator instead of estimating the width. +Whether to measure the width of characters as displayed by the terminal +emulator instead of guessing the width. Enabling this makes rendering a bit slower but more accurate. The screen -might also flash when encountering new graphemes. +might also flash when encountering new characters (or, more accurately, +graphemes). See also the `--measure-widths` command line option. @@ -671,41 +656,18 @@ order of priority): Time zone that chat timestamps should be displayed in. -This option can either be the string `"localtime"`, a [POSIX TZ string], -or a [tz identifier] from the [tz database]. +This option is interpreted as a POSIX TZ string. It is described here in +further detail: + -When not set or when set to `"localtime"`, cove attempts to use your -system's configured time zone, falling back to UTC. +On a normal system, the string `"localtime"` as well as any value from +the "TZ identifier" column of the following wikipedia article should be +valid TZ strings: + -When the string begins with a colon or doesn't match the a POSIX TZ -string format, it is interpreted as a tz identifier and looked up in -your system's tz database (or a bundled tz database on Windows). +If the `TZ` environment variable exists, it overrides this option. If +neither exist, cove uses the system's local time zone. -If the `TZ` environment variable exists, it overrides this option. - -[POSIX TZ string]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03 -[tz identifier]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones -[tz database]: https://en.wikipedia.org/wiki/Tz_database - -### `width_estimation_method` - -**Required:** yes -**Type:** string -**Values:** `"legacy"`, `"unicode"` -**Default:** `"legacy"` - -How to estimate the width of graphemes (i.e. characters) as displayed by -the terminal emulator. - -`"legacy"`: Use a legacy method that should mostly work on most terminal -emulators. This method will never be correct in all cases since every -terminal emulator handles grapheme widths slightly differently. However, -those cases are usually rare (unless you view a lot of emoji). - -`"unicode"`: Use the unicode standard in a best-effort manner to -determine grapheme widths. Some terminals (e.g. ghostty) can make use of -this. - -This method is used when `measure_widths` is set to `false`. - -See also the `--width-estimation-method` command line option. +**Warning:** On Windows, cove can't get the local time zone and uses UTC +instead. However, you can still specify a path to a tz data file or a +custom time zone string. diff --git a/Cargo.lock b/Cargo.lock index 2f45a5a..441e80e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,21 +1,21 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "addr2line" -version = "0.24.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] [[package]] -name = "adler2" -version = "2.0.0" +name = "adler" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" @@ -26,7 +26,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -39,66 +39,70 @@ dependencies = [ ] [[package]] -name = "anstream" -version = "0.6.18" +name = "allocator-api2" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "once_cell", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "async-trait" -version = "0.1.87" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", @@ -107,76 +111,42 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.4.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "aws-lc-rs" -version = "1.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dabb68eb3a7aa08b46fddfd59a3d55c978243557a90ab804769f7e20e67d2b01" -dependencies = [ - "aws-lc-sys", - "zeroize", -] - -[[package]] -name = "aws-lc-sys" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbe221bbf523b625a4dd8585c7f38166e31167ec2ca98051dbcb4c3b6e825d2" -dependencies = [ - "bindgen", - "cc", - "cmake", - "dunce", - "fs_extra", -] +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", + "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", - "windows-targets", ] [[package]] -name = "bindgen" -version = "0.69.5" +name = "base64" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" -dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "itertools", - "lazy_static", - "lazycell", - "log", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn", - "which", -] +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" [[package]] name = "bitflags" -version = "2.9.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block-buffer" @@ -188,39 +158,38 @@ dependencies = [ ] [[package]] -name = "bytes" -version = "1.10.1" +name = "byteorder" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "case" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "caseless" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8" +checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" dependencies = [ + "regex", "unicode-normalization", ] [[package]] name = "cc" -version = "1.2.16" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" -dependencies = [ - "jobserver", - "libc", - "shlex", -] - -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" [[package]] name = "cfg-if" @@ -228,22 +197,11 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "clang-sys" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" -version = "4.5.32" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -251,9 +209,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.32" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -263,9 +221,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.32" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck", "proc-macro2", @@ -275,24 +233,21 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" - -[[package]] -name = "cmake" -version = "0.1.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" -dependencies = [ - "cc", -] +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "const_fn" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373e9fafaa20882876db20562275ff58d50e0caa2590077fe7ce7bef90211d0d" [[package]] name = "cookie" @@ -306,9 +261,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.10.0" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -316,13 +271,13 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.7" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cove" -version = "0.9.3" +version = "0.8.2" dependencies = [ "anyhow", "async-trait", @@ -333,24 +288,27 @@ dependencies = [ "crossterm", "directories", "euphoxide", - "jiff", "linkify", "log", + "once_cell", "open", "parking_lot", "rusqlite", - "rustls", "serde_json", "thiserror", + "time", "tokio", + "tokio-tungstenite", "toss", + "tz-rs", + "unicode-segmentation", "unicode-width", "vault", ] [[package]] name = "cove-config" -version = "0.9.3" +version = "0.8.2" dependencies = [ "cove-input", "cove-macro", @@ -361,7 +319,7 @@ dependencies = [ [[package]] name = "cove-input" -version = "0.9.3" +version = "0.8.2" dependencies = [ "cove-macro", "crossterm", @@ -375,8 +333,9 @@ dependencies = [ [[package]] name = "cove-macro" -version = "0.9.3" +version = "0.8.2" dependencies = [ + "case", "proc-macro2", "quote", "syn", @@ -384,24 +343,24 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.17" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crossterm" -version = "0.28.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.5.0", "crossterm_winapi", + "libc", "mio", "parking_lot", - "rustix 0.38.44", "signal-hook", "signal-hook-mio", "winapi", @@ -428,9 +387,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.8.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "deranged" @@ -439,6 +398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -453,31 +413,25 @@ dependencies = [ [[package]] name = "directories" -version = "6.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.5.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] -[[package]] -name = "dunce" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" - [[package]] name = "edit" version = "0.1.5" @@ -490,40 +444,40 @@ dependencies = [ [[package]] name = "either" -version = "1.15.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "equivalent" -version = "1.0.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "euphoxide" -version = "0.6.1" -source = "git+https://github.com/Garmelon/euphoxide.git?tag=v0.6.1#7a292c429ad44aa6aa52fc381e3168841d6303b0" +version = "0.5.0" +source = "git+https://github.com/Garmelon/euphoxide.git?tag=v0.5.0#276ff685127c4c392a2ab001f80f7a053e58746b" dependencies = [ "async-trait", "caseless", "clap", "cookie", "futures-util", - "jiff", "log", "serde", "serde_json", + "time", "tokio", "tokio-stream", "tokio-tungstenite", @@ -544,9 +498,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.3.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fnv" @@ -555,34 +509,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "fs_extra" -version = "1.3.0" +name = "form_urlencoded" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-sink", @@ -604,61 +561,38 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "wasi", ] [[package]] name = "gimli" -version = "0.31.1" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - -[[package]] -name = "glob" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "allocator-api2", ] -[[package]] -name = "hashbrown" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" - [[package]] name = "hashlink" -version = "0.9.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +checksum = "692eaaf7f7607518dd3cef090f1474b61edc5301d8012f09579920df68b725ee" dependencies = [ - "hashbrown 0.14.5", + "hashbrown", ] [[package]] @@ -668,19 +602,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] -name = "home" -version = "0.5.11" +name = "hermit-abi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "http" -version = "1.3.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -689,18 +629,28 @@ dependencies = [ [[package]] name = "httparse" -version = "1.10.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] [[package]] name = "indexmap" -version = "2.8.0" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown", ] [[package]] @@ -722,104 +672,17 @@ dependencies = [ "once_cell", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" - -[[package]] -name = "jiff" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e" -dependencies = [ - "jiff-static", - "jiff-tzdb-platform", - "log", - "portable-atomic", - "portable-atomic-util", - "serde", - "windows-sys 0.59.0", -] - -[[package]] -name = "jiff-static" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d16e75759ee0aa64c57a56acbf43916987b20c77373cb7e808979e02b93c9f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "jiff-tzdb" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "962e1dfe9b2d75a84536cf5bf5eaaa4319aa7906c7160134a22883ac316d5f31" - -[[package]] -name = "jiff-tzdb-platform" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a63c62e404e7b92979d2792352d885a7f8f83fd1d0d31eea582d77b2ceca697e" -dependencies = [ - "jiff-tzdb", -] - -[[package]] -name = "jobserver" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" -dependencies = [ - "libc", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" - -[[package]] -name = "libloading" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" -dependencies = [ - "cfg-if", - "windows-targets", -] +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" @@ -827,7 +690,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.5.0", "libc", ] @@ -853,21 +716,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - -[[package]] -name = "linux-raw-sys" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -875,51 +732,35 @@ dependencies = [ [[package]] name = "log" -version = "0.4.26" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ - "adler2", + "adler", ] [[package]] name = "mio" -version = "1.0.3" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", + "wasi", + "windows-sys 0.48.0", ] [[package]] @@ -930,33 +771,43 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-traits" -version = "0.2.19" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] -name = "object" -version = "0.36.7" +name = "num_cpus" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.21.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "open" -version = "5.3.2" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2483562e62ea94312f3576a7aca397306df7990b8d89033e18766744377ef95" +checksum = "449f0ff855d85ddbf1edd5b646d65249ead3f5e422aaa86b7d2d0b049b103e32" dependencies = [ "is-wsl", "libc", @@ -965,9 +816,9 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "option-ext" @@ -986,9 +837,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", "parking_lot_core", @@ -996,28 +847,34 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "pathdiff" -version = "0.2.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1027,24 +884,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.32" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - -[[package]] -name = "portable-atomic" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" - -[[package]] -name = "portable-atomic-util" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" -dependencies = [ - "portable-atomic", -] +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "powerfmt" @@ -1054,57 +896,44 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.21" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy 0.8.23", -] - -[[package]] -name = "prettyplease" -version = "0.2.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" -dependencies = [ - "proc-macro2", - "syn", -] +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "rand" -version = "0.9.0" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ + "libc", "rand_chacha", "rand_core", - "zerocopy 0.8.23", ] [[package]] name = "rand_chacha" -version = "0.9.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", @@ -1112,38 +941,38 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.3.1", + "getrandom", ] [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.5.0" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.11.1" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -1153,9 +982,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -1164,20 +993,21 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "ring" -version = "0.17.14" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.15", + "getrandom", "libc", + "spin", "untrusted", "windows-sys 0.52.0", ] @@ -1188,7 +1018,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" dependencies = [ - "bitflags", + "bitflags 2.5.0", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -1199,51 +1029,31 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.23" 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" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.44" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags", + "bitflags 2.5.0", "errno", "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - -[[package]] -name = "rustix" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys 0.9.3", - "windows-sys 0.59.0", + "linux-raw-sys", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.23.23" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ - "aws-lc-rs", "log", - "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -1252,29 +1062,39 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.8.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", + "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", ] [[package]] -name = "rustls-pki-types" -version = "1.11.0" +name = "rustls-pemfile" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.102.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" dependencies = [ - "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -1282,17 +1102,17 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -1303,11 +1123,11 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "3.2.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -1316,9 +1136,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -1326,9 +1146,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] @@ -1345,9 +1165,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", @@ -1366,21 +1186,20 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", - "memchr", "ryu", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -1396,12 +1215,6 @@ dependencies = [ "digest", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "signal-hook" version = "0.3.17" @@ -1414,9 +1227,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.4" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio", @@ -1443,20 +1256,26 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.14.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.8" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", "windows-sys 0.52.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "strsim" version = "0.11.1" @@ -1465,15 +1284,15 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.6.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.100" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1482,31 +1301,30 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.19.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ + "cfg-if", "fastrand", - "getrandom 0.3.1", - "once_cell", - "rustix 1.0.2", - "windows-sys 0.59.0", + "rustix", + "windows-sys 0.52.0", ] [[package]] name = "thiserror" -version = "2.0.12" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", @@ -1515,9 +1333,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.39" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -1530,15 +1348,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.20" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8093bc3e81c3bc5f7879de09619d06c9a5a5e45ca44dfeeb7225bae38005c5c" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -1546,9 +1364,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.9.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] @@ -1561,27 +1379,28 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.44.1" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", "libc", "mio", + "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", @@ -1590,19 +1409,20 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ "rustls", + "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.17" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -1611,9 +1431,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.26.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", @@ -1627,9 +1447,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.20" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", @@ -1639,18 +1459,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap", "serde", @@ -1661,8 +1481,8 @@ dependencies = [ [[package]] name = "toss" -version = "0.3.4" -source = "git+https://github.com/Garmelon/toss.git?tag=v0.3.4#57aa8c59308f6f0aa82bde415a42b56c3d6f7c4d" +version = "0.2.3" +source = "git+https://github.com/Garmelon/toss.git?tag=v0.2.3#b1d7221bae9e1bb57d8e5b49c315dc3ca56e947a" dependencies = [ "async-trait", "crossterm", @@ -1673,10 +1493,11 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.26.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ + "byteorder", "bytes", "data-encoding", "http", @@ -1687,20 +1508,36 @@ dependencies = [ "rustls-pki-types", "sha1", "thiserror", + "url", "utf-8", ] [[package]] name = "typenum" -version = "1.18.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "tz-rs" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33851b15c848fad2cf4b105c6bb66eb9512b6f6c44a4b13f57c53c73c707e2b4" +dependencies = [ + "const_fn", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-linebreak" @@ -1710,24 +1547,24 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.24" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.12.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.2.0" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "untrusted" @@ -1735,6 +1572,17 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf-8" version = "0.7.6" @@ -1743,9 +1591,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "utf8parse" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "vault" @@ -1764,9 +1612,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" @@ -1774,15 +1622,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi" -version = "0.13.3+wasi-0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "which" version = "4.4.2" @@ -1792,7 +1631,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.44", + "rustix", ] [[package]] @@ -1819,138 +1658,166 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.5", ] [[package]] name = "windows-targets" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] name = "windows_i686_gnullvm" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.6" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.7.4" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" -dependencies = [ - "bitflags", -] - [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" -dependencies = [ - "zerocopy-derive 0.8.23", + "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", @@ -1959,6 +1826,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml index 33f245f..178b652 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,71 +1,29 @@ [workspace] -resolver = "3" +resolver = "2" members = ["cove", "cove-*"] [workspace.package] -version = "0.9.3" -edition = "2024" +version = "0.8.2" +edition = "2021" [workspace.dependencies] -anyhow = "1.0.97" -async-trait = "0.1.87" -clap = { version = "4.5.32", features = ["derive", "deprecated"] } -cookie = "0.18.1" -crossterm = "0.28.1" -directories = "6.0.0" -edit = "0.1.5" -jiff = "0.2.4" -linkify = "0.10.0" -log = { version = "0.4.26", features = ["std"] } -open = "5.3.2" -parking_lot = "0.12.3" -proc-macro2 = "1.0.94" -quote = "1.0.40" -rusqlite = { version = "0.31.0", features = ["bundled", "time"] } -rustls = "0.23.23" -serde = { version = "1.0.219", features = ["derive"] } +crossterm = "0.27.0" +parking_lot = "0.12.1" +serde = { version = "1.0.198", features = ["derive"] } serde_either = "0.2.1" -serde_json = "1.0.140" -syn = "2.0.100" -thiserror = "2.0.12" -tokio = { version = "1.44.1", features = ["full"] } -toml = "0.8.20" -unicode-width = "0.2.0" - -[workspace.dependencies.euphoxide] -git = "https://github.com/Garmelon/euphoxide.git" -tag = "v0.6.1" -features = ["bot"] +thiserror = "1.0.59" [workspace.dependencies.toss] git = "https://github.com/Garmelon/toss.git" -tag = "v0.3.4" - -[workspace.dependencies.vault] -git = "https://github.com/Garmelon/vault.git" -tag = "v0.4.0" -features = ["tokio"] +tag = "v0.2.3" [workspace.lints] -rust.unsafe_code = { level = "forbid", priority = 1 } -# Lint groups -rust.deprecated_safe = "warn" +rust.unsafe_code = "forbid" rust.future_incompatible = "warn" -rust.keyword_idents = "warn" rust.rust_2018_idioms = "warn" rust.unused = "warn" -# Individual lints -rust.non_local_definitions = "warn" -rust.redundant_imports = "warn" -rust.redundant_lifetimes = "warn" +rust.noop_method_call = "warn" rust.single_use_lifetimes = "warn" -rust.unit_bindings = "warn" -rust.unnameable_types = "warn" -rust.unused_crate_dependencies = "warn" -rust.unused_import_braces = "warn" -rust.unused_lifetimes = "warn" -rust.unused_qualifications = "warn" -# Clippy clippy.use_self = "warn" [profile.dev.package."*"] diff --git a/README.md b/README.md index 22fef83..e99e545 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,6 @@ real-time chat platform. It runs on Linux, Windows, and macOS. -## Installing cove - -Download a binary of your choice from the -[latest release on GitHub](https://github.com/Garmelon/cove/releases/latest). - ## Using cove To start cove, simply run `cove` in your terminal. For more info about the @@ -31,3 +26,61 @@ file or via `cove help-config`. When launched, cove prints the location it is loading its config file from. To configure cove, create a config file at that location. This location can be changed via the `--config` command line option. + +## Installation + +At this point, cove is not available via any package manager. + +Cove is available as a Nix Flake. To try it out, you can use +```bash +$ nix run --override-input nixpkgs nixpkgs github:Garmelon/cove/latest +``` + +## Manual installation + +This section contains instructions on how to install cove by compiling it yourself. +It doesn't assume you know how to program, but it does assume basic familiarity with the command line on your platform of choice. +Cove runs in the terminal, after all. + +### Installing rustup + +Cove is written in Rust, so the first step is to install rustup. Either install +it from your package manager of choice (if you have one) or use the +[installer](https://rustup.rs/). + +Test your installation by running `rustup --version` and `cargo --version`. If +rustup is installed correctly, both of these should show a version number. + +Cove is designed on the current version of the stable toolchain. If cove doesn't +compile, you can try switching to the stable toolchain and updating it using the +following commands: +```bash +$ rustup default stable +$ rustup update +``` + +### Installing cove + +To install or update to the latest release of cove, run the following command: + +```bash +$ cargo install --force --git https://github.com/Garmelon/cove --branch latest +``` + +If you like to live dangerously and want to install or update to the latest, +bleeding-edge, possibly-broken commit from the repo's main branch, run the +following command. + +**Warning:** This could corrupt your vault. Make sure to make a backup before +running the command. + +```bash +$ cargo install --force --git https://github.com/Garmelon/cove +``` + +To install a specific version of cove, run the following command and substitute +in the full version you want to install: + +```bash +$ cargo install --force --git https://github.com/Garmelon/cove --tag v0.1.0 +``` diff --git a/cove-config/Cargo.toml b/cove-config/Cargo.toml index 9102bfd..b9c7300 100644 --- a/cove-config/Cargo.toml +++ b/cove-config/Cargo.toml @@ -1,15 +1,16 @@ [package] name = "cove-config" -version.workspace = true -edition.workspace = true +version = { workspace = true } +edition = { workspace = true } [dependencies] cove-input = { path = "../cove-input" } cove-macro = { path = "../cove-macro" } -serde.workspace = true -thiserror.workspace = true -toml.workspace = true +serde = { workspace = true } +thiserror = { workspace = true } + +toml = "0.8.12" [lints] workspace = true diff --git a/cove-config/src/doc.rs b/cove-config/src/doc.rs index 35f6074..16ed3ac 100644 --- a/cove-config/src/doc.rs +++ b/cove-config/src/doc.rs @@ -1,6 +1,7 @@ //! Auto-generate markdown documentation. -use std::{collections::HashMap, path::PathBuf}; +use std::collections::HashMap; +use std::path::PathBuf; use cove_input::KeyBinding; pub use cove_macro::Document; diff --git a/cove-config/src/euph.rs b/cove-config/src/euph.rs index 5ed0fb5..5b1f12a 100644 --- a/cove-config/src/euph.rs +++ b/cove-config/src/euph.rs @@ -23,9 +23,9 @@ pub struct EuphRoom { /// associated with the current session. pub username: Option, - /// If `euph.servers..rooms..username` is set, this will force - /// cove to set the username even if there is already a different username - /// associated with the current session. + /// If `euph.rooms..username` is set, this will force cove to set the + /// username even if there is already a different username associated with + /// the current session. #[serde(default)] pub force_username: bool, diff --git a/cove-config/src/keys.rs b/cove-config/src/keys.rs index 47c171c..8b5adeb 100644 --- a/cove-config/src/keys.rs +++ b/cove-config/src/keys.rs @@ -104,7 +104,6 @@ default_bindings! { pub fn mark_older_seen => ["ctrl+s"]; pub fn info => ["i"]; pub fn links => ["I"]; - pub fn toggle_nick_emoji => ["e"]; pub fn increase_caesar => ["c"]; pub fn decrease_caesar => ["C"]; } @@ -357,9 +356,6 @@ pub struct TreeAction { /// List links found in message. #[serde(default = "default::tree_action::links")] pub links: KeyBinding, - /// Toggle agent id based nick emoji. - #[serde(default = "default::tree_action::toggle_nick_emoji")] - pub toggle_nick_emoji: KeyBinding, /// Increase caesar cipher rotation. #[serde(default = "default::tree_action::increase_caesar")] pub increase_caesar: KeyBinding, diff --git a/cove-config/src/lib.rs b/cove-config/src/lib.rs index 0cb6cc7..086e372 100644 --- a/cove-config/src/lib.rs +++ b/cove-config/src/lib.rs @@ -1,18 +1,17 @@ -use std::{ - fs, - io::{self, ErrorKind}, - path::{Path, PathBuf}, -}; - -use doc::Document; -use serde::{Deserialize, Serialize}; - -pub use crate::{euph::*, keys::*}; - pub mod doc; mod euph; mod keys; +use std::io::ErrorKind; +use std::path::{Path, PathBuf}; +use std::{fs, io}; + +use doc::Document; +use serde::Deserialize; + +pub use crate::euph::*; +pub use crate::keys::*; + #[derive(Debug, thiserror::Error)] pub enum Error { #[error("failed to read config file")] @@ -21,14 +20,6 @@ pub enum Error { Toml(#[from] toml::de::Error), } -#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, Document)] -#[serde(rename_all = "snake_case")] -pub enum WidthEstimationMethod { - #[default] - Legacy, - Unicode, -} - #[derive(Debug, Default, Deserialize, Document)] pub struct Config { /// The directory that cove stores its data in when not running in ephemeral @@ -49,29 +40,12 @@ pub struct Config { #[serde(default)] pub ephemeral: bool, - /// How to estimate the width of graphemes (i.e. characters) as displayed by - /// the terminal emulator. - /// - /// `"legacy"`: Use a legacy method that should mostly work on most terminal - /// emulators. This method will never be correct in all cases since every - /// terminal emulator handles grapheme widths slightly differently. However, - /// those cases are usually rare (unless you view a lot of emoji). - /// - /// `"unicode"`: Use the unicode standard in a best-effort manner to - /// determine grapheme widths. Some terminals (e.g. ghostty) can make use of - /// this. - /// - /// This method is used when `measure_widths` is set to `false`. - /// - /// See also the `--width-estimation-method` command line option. - #[serde(default)] - pub width_estimation_method: WidthEstimationMethod, - - /// Whether to measure the width of graphemes (i.e. characters) as displayed - /// by the terminal emulator instead of estimating the width. + /// Whether to measure the width of characters as displayed by the terminal + /// emulator instead of guessing the width. /// /// Enabling this makes rendering a bit slower but more accurate. The screen - /// might also flash when encountering new graphemes. + /// might also flash when encountering new characters (or, more accurately, + /// graphemes). /// /// See also the `--measure-widths` command line option. #[serde(default)] @@ -100,27 +74,23 @@ pub struct Config { #[serde(default)] pub rooms_sort_order: RoomsSortOrder, - /// Ring the bell (character 0x07) when you are mentioned in a room. - #[serde(default)] - pub bell_on_mention: bool, - /// Time zone that chat timestamps should be displayed in. /// - /// This option can either be the string `"localtime"`, a [POSIX TZ string], - /// or a [tz identifier] from the [tz database]. + /// This option is interpreted as a POSIX TZ string. It is described here in + /// further detail: + /// /// - /// When not set or when set to `"localtime"`, cove attempts to use your - /// system's configured time zone, falling back to UTC. + /// On a normal system, the string `"localtime"` as well as any value from + /// the "TZ identifier" column of the following wikipedia article should be + /// valid TZ strings: + /// /// - /// When the string begins with a colon or doesn't match the a POSIX TZ - /// string format, it is interpreted as a tz identifier and looked up in - /// your system's tz database (or a bundled tz database on Windows). + /// If the `TZ` environment variable exists, it overrides this option. If + /// neither exist, cove uses the system's local time zone. /// - /// If the `TZ` environment variable exists, it overrides this option. - /// - /// [POSIX TZ string]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03 - /// [tz identifier]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - /// [tz database]: https://en.wikipedia.org/wiki/Tz_database + /// **Warning:** On Windows, cove can't get the local time zone and uses UTC + /// instead. However, you can still specify a path to a tz data file or a + /// custom time zone string. #[serde(default)] #[document(default = "`$TZ` or local system time zone")] pub time_zone: Option, diff --git a/cove-input/Cargo.toml b/cove-input/Cargo.toml index 5005be2..428060f 100644 --- a/cove-input/Cargo.toml +++ b/cove-input/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "cove-input" -version.workspace = true -edition.workspace = true +version = { workspace = true } +edition = { workspace = true } [dependencies] cove-macro = { path = "../cove-macro" } -crossterm.workspace = true -edit.workspace = true -parking_lot.workspace = true -serde.workspace = true -serde_either.workspace = true -thiserror.workspace = true -toss.workspace = true +crossterm = { workspace = true } +parking_lot = { workspace = true } +serde = { workspace = true } +serde_either = { workspace = true } +thiserror = { workspace = true } +toss = { workspace = true } + +edit = "0.1.5" [lints] workspace = true diff --git a/cove-input/src/keys.rs b/cove-input/src/keys.rs index 8d2fdf1..337a5f3 100644 --- a/cove-input/src/keys.rs +++ b/cove-input/src/keys.rs @@ -1,7 +1,10 @@ -use std::{fmt, num::ParseIntError, str::FromStr}; +use std::fmt; +use std::num::ParseIntError; +use std::str::FromStr; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; -use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error}; +use serde::{de::Error, Deserialize, Deserializer}; +use serde::{Serialize, Serializer}; use serde_either::SingleOrVec; #[derive(Debug, thiserror::Error)] @@ -114,7 +117,7 @@ impl KeyPress { "alt" if !self.alt => self.alt = true, "any" if !self.shift && !self.ctrl && !self.alt => self.any = true, m @ ("shift" | "ctrl" | "alt" | "any") => { - return Err(ParseKeysError::ConflictingModifier(m.to_string())); + return Err(ParseKeysError::ConflictingModifier(m.to_string())) } m => return Err(ParseKeysError::UnknownModifier(m.to_string())), } diff --git a/cove-input/src/lib.rs b/cove-input/src/lib.rs index f6b2e92..ba3bd63 100644 --- a/cove-input/src/lib.rs +++ b/cove-input/src/lib.rs @@ -1,4 +1,7 @@ -use std::{io, sync::Arc}; +mod keys; + +use std::io; +use std::sync::Arc; pub use cove_macro::KeyGroup; use crossterm::event::{Event, KeyEvent, KeyEventKind}; @@ -7,8 +10,6 @@ use toss::{Frame, Terminal, WidthDb}; pub use crate::keys::*; -mod keys; - pub struct KeyBindingInfo<'a> { pub name: &'static str, pub binding: &'a KeyBinding, @@ -39,7 +40,7 @@ impl<'a> KeyGroupInfo<'a> { } pub struct InputEvent<'a> { - event: Event, + event: crossterm::event::Event, terminal: &'a mut Terminal, crossterm_lock: Arc>, } diff --git a/cove-macro/Cargo.toml b/cove-macro/Cargo.toml index 6c01b7d..acd55fd 100644 --- a/cove-macro/Cargo.toml +++ b/cove-macro/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "cove-macro" -version.workspace = true -edition.workspace = true +version = { workspace = true } +edition = { workspace = true } [dependencies] -proc-macro2.workspace = true -quote.workspace = true -syn.workspace = true +case = "1.0.0" +proc-macro2 = "1.0.81" +quote = "1.0.36" +syn = "2.0.60" [lib] proc-macro = true diff --git a/cove-macro/src/document.rs b/cove-macro/src/document.rs index afec84d..e8e248e 100644 --- a/cove-macro/src/document.rs +++ b/cove-macro/src/document.rs @@ -1,6 +1,7 @@ use proc_macro2::TokenStream; use quote::quote; -use syn::{Data, DataEnum, DataStruct, DeriveInput, Field, Ident, LitStr, spanned::Spanned}; +use syn::spanned::Spanned; +use syn::{Data, DataEnum, DataStruct, DeriveInput, Field, Ident, LitStr}; use crate::util::{self, SerdeDefault}; diff --git a/cove-macro/src/key_group.rs b/cove-macro/src/key_group.rs index 832bfd3..bc7bdea 100644 --- a/cove-macro/src/key_group.rs +++ b/cove-macro/src/key_group.rs @@ -1,8 +1,9 @@ use proc_macro2::TokenStream; use quote::quote; -use syn::{Data, DeriveInput, spanned::Spanned}; +use syn::spanned::Spanned; +use syn::{Data, DeriveInput}; -use crate::util; +use crate::util::{self, bail}; fn decapitalize(s: &str) -> String { let mut chars = s.chars(); @@ -33,7 +34,7 @@ pub fn derive_impl(input: DeriveInput) -> syn::Result { let default = util::serde_default(field)?; let Some(default) = default else { - return util::bail(field_ident.span(), "must have serde default"); + return bail(field_ident.span(), "must have serde default"); }; let default_value = default.value(); diff --git a/cove-macro/src/lib.rs b/cove-macro/src/lib.rs index c655f2a..fd09f5f 100644 --- a/cove-macro/src/lib.rs +++ b/cove-macro/src/lib.rs @@ -1,4 +1,4 @@ -use syn::{DeriveInput, parse_macro_input}; +use syn::{parse_macro_input, DeriveInput}; mod document; mod key_group; diff --git a/cove-macro/src/util.rs b/cove-macro/src/util.rs index d73b7ca..b7bf62a 100644 --- a/cove-macro/src/util.rs +++ b/cove-macro/src/util.rs @@ -1,9 +1,8 @@ use proc_macro2::{Span, TokenStream}; use quote::quote; -use syn::{ - Attribute, Expr, ExprLit, ExprPath, Field, Lit, LitStr, Path, Token, Type, parse::Parse, - punctuated::Punctuated, -}; +use syn::parse::Parse; +use syn::punctuated::Punctuated; +use syn::{Attribute, Expr, ExprLit, ExprPath, Field, Lit, LitStr, Path, Token, Type}; pub fn bail(span: Span, message: &str) -> syn::Result { Err(syn::Error::new(span, message)) diff --git a/cove/Cargo.toml b/cove/Cargo.toml index 3a60a5d..7ea2b12 100644 --- a/cove/Cargo.toml +++ b/cove/Cargo.toml @@ -1,32 +1,50 @@ [package] name = "cove" -version.workspace = true -edition.workspace = true +version = { workspace = true } +edition = { workspace = true } [dependencies] cove-config = { path = "../cove-config" } cove-input = { path = "../cove-input" } -anyhow.workspace = true -async-trait.workspace = true -clap.workspace = true -cookie.workspace = true -crossterm.workspace = true -directories.workspace = true -euphoxide.workspace = true -jiff.workspace = true -linkify.workspace = true -log.workspace = true -open.workspace = true -parking_lot.workspace = true -rusqlite.workspace = true -serde_json.workspace = true -thiserror.workspace = true -tokio.workspace = true -toss.workspace = true -unicode-width.workspace = true -vault.workspace = true -rustls.workspace = true +crossterm = { workspace = true } +parking_lot = { workspace = true } +thiserror = { workspace = true } +toss = { workspace = true } + +anyhow = "1.0.82" +async-trait = "0.1.80" +clap = { version = "4.5.4", features = ["derive", "deprecated"] } +cookie = "0.18.1" +directories = "5.0.1" +linkify = "0.10.0" +log = { version = "0.4.21", features = ["std"] } +once_cell = "1.19.0" +open = "5.1.2" +rusqlite = { version = "0.31.0", features = ["bundled", "time"] } +serde_json = "1.0.116" +tokio = { version = "1.37.0", features = ["full"] } +tz-rs = "0.6.14" +unicode-segmentation = "1.11.0" +unicode-width = "0.1.11" + +[dependencies.time] +version = "0.3.36" +features = ["macros", "formatting", "parsing", "serde"] + +[dependencies.tokio-tungstenite] +version = "0.21.0" +features = ["rustls-tls-native-roots"] + +[dependencies.euphoxide] +git = "https://github.com/Garmelon/euphoxide.git" +tag = "v0.5.0" +features = ["bot"] + +[dependencies.vault] +git = "https://github.com/Garmelon/vault.git" +tag = "v0.4.0" +features = ["tokio"] [lints] workspace = true diff --git a/cove/src/euph.rs b/cove/src/euph.rs index 77bf1db..ab93753 100644 --- a/cove/src/euph.rs +++ b/cove/src/euph.rs @@ -1,9 +1,7 @@ -pub use highlight::*; -pub use room::*; -pub use small_message::*; -pub use util::*; - -mod highlight; mod room; mod small_message; mod util; + +pub use room::*; +pub use small_message::*; +pub use util::*; diff --git a/cove/src/euph/highlight.rs b/cove/src/euph/highlight.rs deleted file mode 100644 index 1c9abd0..0000000 --- a/cove/src/euph/highlight.rs +++ /dev/null @@ -1,211 +0,0 @@ -use std::ops::Range; - -use crossterm::style::Stylize; -use toss::{Style, Styled}; - -use crate::euph::util; - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SpanType { - Mention, - Room, - Emoji, -} - -fn nick_char(ch: char) -> bool { - // Closely following the heim mention regex: - // https://github.com/euphoria-io/heim/blob/978c921063e6b06012fc8d16d9fbf1b3a0be1191/client/lib/stores/chat.js#L14-L15 - // `>` has been experimentally confirmed to delimit mentions as well. - match ch { - ',' | '.' | '!' | '?' | ';' | '&' | '<' | '>' | '\'' | '"' => false, - _ => !ch.is_whitespace(), - } -} - -fn room_char(ch: char) -> bool { - // Basically just \w, see also - // https://github.com/euphoria-io/heim/blob/978c921063e6b06012fc8d16d9fbf1b3a0be1191/client/lib/ui/MessageText.js#L66 - ch.is_ascii_alphanumeric() || ch == '_' -} - -struct SpanFinder<'a> { - content: &'a str, - - span: Option<(SpanType, usize)>, - room_or_mention_possible: bool, - - result: Vec<(SpanType, Range)>, -} - -impl<'a> SpanFinder<'a> { - fn is_valid_span(&self, span: SpanType, range: Range) -> bool { - let text = &self.content[range.start..range.end]; - match span { - SpanType::Mention => range.len() > 1 && text.starts_with('@'), - SpanType::Room => range.len() > 1 && text.starts_with('&'), - SpanType::Emoji => { - if range.len() <= 2 { - return false; - } - - let Some(name) = Some(text) - .and_then(|it| it.strip_prefix(':')) - .and_then(|it| it.strip_suffix(':')) - else { - return false; - }; - - util::EMOJI.get(name).is_some() - } - } - } - - fn close_span(&mut self, end: usize) { - let Some((span, start)) = self.span else { - return; - }; - if self.is_valid_span(span, start..end) { - self.result.push((span, start..end)); - } - self.span = None; - } - - fn open_span(&mut self, span: SpanType, start: usize) { - self.close_span(start); - self.span = Some((span, start)) - } - - fn step(&mut self, idx: usize, char: char) { - match (char, self.span) { - ('@', Some((SpanType::Mention, _))) => {} // Continue the mention - ('@', _) if self.room_or_mention_possible => self.open_span(SpanType::Mention, idx), - ('&', _) if self.room_or_mention_possible => self.open_span(SpanType::Room, idx), - (':', None) => self.open_span(SpanType::Emoji, idx), - (':', Some((SpanType::Emoji, _))) => self.close_span(idx + 1), - (c, Some((SpanType::Mention, _))) if !nick_char(c) => self.close_span(idx), - (c, Some((SpanType::Room, _))) if !room_char(c) => self.close_span(idx), - _ => {} - } - - // More permissive than the heim web client - self.room_or_mention_possible = !char.is_alphanumeric(); - } - - fn find(content: &'a str) -> Vec<(SpanType, Range)> { - let mut this = Self { - content, - span: None, - room_or_mention_possible: true, - result: vec![], - }; - - for (idx, char) in content.char_indices() { - this.step(idx, char); - } - - this.close_span(content.len()); - - this.result - } -} - -pub fn find_spans(content: &str) -> Vec<(SpanType, Range)> { - SpanFinder::find(content) -} - -/// Highlight spans in a string. -/// -/// The list of spans must be non-overlapping and in ascending order. -/// -/// If `exact` is specified, colon-delimited emoji are not replaced with their -/// unicode counterparts. -pub fn apply_spans( - content: &str, - spans: &[(SpanType, Range)], - base: Style, - exact: bool, -) -> Styled { - let mut result = Styled::default(); - let mut i = 0; - - for (span, range) in spans { - assert!(i <= range.start); - assert!(range.end <= content.len()); - - if i < range.start { - result = result.then(&content[i..range.start], base); - } - - let text = &content[range.start..range.end]; - result = match span { - SpanType::Mention if exact => result.and_then(util::style_mention_exact(text, base)), - SpanType::Mention => result.and_then(util::style_mention(text, base)), - SpanType::Room => result.then(text, base.blue().bold()), - SpanType::Emoji if exact => result.then(text, base.magenta()), - SpanType::Emoji => { - let name = text.strip_prefix(':').unwrap_or(text); - let name = name.strip_suffix(':').unwrap_or(name); - if let Some(Some(replacement)) = util::EMOJI.get(name) { - result.then(replacement, base) - } else { - result.then(text, base.magenta()) - } - } - }; - - i = range.end; - } - - if i < content.len() { - result = result.then(&content[i..], base); - } - - result -} - -/// Highlight an euphoria message's content. -/// -/// If `exact` is specified, colon-delimited emoji are not replaced with their -/// unicode counterparts. -pub fn highlight(content: &str, base: Style, exact: bool) -> Styled { - apply_spans(content, &find_spans(content), base, exact) -} - -#[cfg(test)] -mod tests { - - use crate::euph::SpanType; - - use super::find_spans; - - #[test] - fn mentions() { - assert_eq!(find_spans("@foo"), vec![(SpanType::Mention, 0..4)]); - assert_eq!(find_spans("&@foo"), vec![(SpanType::Mention, 1..5)]); - assert_eq!(find_spans("a @foo b"), vec![(SpanType::Mention, 2..6)]); - assert_eq!(find_spans("@@foo@@"), vec![(SpanType::Mention, 0..7)]); - assert_eq!(find_spans("a @b@c d"), vec![(SpanType::Mention, 2..6)]); - assert_eq!( - find_spans("a @b @c d"), - vec![(SpanType::Mention, 2..4), (SpanType::Mention, 5..7)] - ); - } - - #[test] - fn rooms() { - assert_eq!(find_spans("&foo"), vec![(SpanType::Room, 0..4)]); - assert_eq!(find_spans("@&foo"), vec![(SpanType::Room, 1..5)]); - assert_eq!(find_spans("a &foo b"), vec![(SpanType::Room, 2..6)]); - assert_eq!(find_spans("&&foo&&"), vec![(SpanType::Room, 1..5)]); - assert_eq!(find_spans("a &b&c d"), vec![(SpanType::Room, 2..4)]); - assert_eq!( - find_spans("a &b &c d"), - vec![(SpanType::Room, 2..4), (SpanType::Room, 5..7)] - ); - } - - #[test] - fn emoji_in_mentions() { - assert_eq!(find_spans(" @a:b:c "), vec![(SpanType::Mention, 1..7)]); - } -} diff --git a/cove/src/euph/room.rs b/cove/src/euph/room.rs index a4e29cf..64ddfe6 100644 --- a/cove/src/euph/room.rs +++ b/cove/src/euph/room.rs @@ -1,17 +1,21 @@ -use std::{convert::Infallible, time::Duration}; +// TODO Remove rl2dev-specific code -use euphoxide::{ - api::{ - Auth, AuthOption, Data, Log, Login, Logout, MessageId, Nick, Send, SendEvent, SendReply, - Time, UserId, packet::ParsedPacket, - }, - bot::instance::{ConnSnapshot, Event, Instance, InstanceConfig}, - conn::{self, ConnTx, Joined}, +use std::convert::Infallible; +use std::time::Duration; + +use euphoxide::api::packet::ParsedPacket; +use euphoxide::api::{ + Auth, AuthOption, Data, Log, Login, Logout, MessageId, Nick, Send, SendEvent, SendReply, Time, + UserId, }; -use log::{debug, info, warn}; -use tokio::{select, sync::oneshot}; +use euphoxide::bot::instance::{ConnSnapshot, Event, Instance, InstanceConfig}; +use euphoxide::conn::{self, ConnTx, Joined}; +use log::{debug, error, info, warn}; +use tokio::select; +use tokio::sync::oneshot; -use crate::{macros::logging_unwrap, vault::EuphRoomVault}; +use crate::macros::logging_unwrap; +use crate::vault::EuphRoomVault; const LOG_INTERVAL: Duration = Duration::from_secs(10); @@ -69,13 +73,20 @@ impl Room { where F: Fn(Event) + std::marker::Send + Sync + 'static, { + // &rl2dev's message history is broken and requesting old messages past + // a certain point results in errors. Cove should not keep retrying log + // requests when hitting that limit, so &rl2dev is always opened in + // ephemeral mode. + let is_rl2dev = vault.room().domain == "euphoria.io" && vault.room().name == "rl2dev"; + let ephemeral = vault.vault().vault().ephemeral() || is_rl2dev; + Self { - ephemeral: vault.vault().vault().ephemeral(), + vault, + ephemeral, instance: instance_config.build(on_event), state: State::Disconnected, last_msg_id: None, log_request_canary: None, - vault, } } @@ -183,7 +194,14 @@ impl Room { debug!("{:?}: requesting logs", vault.room()); - let _ = conn_tx.send(Log { n: 1000, before }).await; + // &rl2dev's message history is broken and requesting old messages past + // a certain point results in errors. By reducing the amount of messages + // in each log request, we can get closer to this point. Since &rl2dev + // is fairly low in activity, this should be fine. + let is_rl2dev = vault.room().domain == "euphoria.io" && vault.room().name == "rl2dev"; + let n = if is_rl2dev { 50 } else { 1000 }; + + let _ = conn_tx.send(Log { n, before }).await; // The code handling incoming events and replies also handles // `LogReply`s, so we don't need to do anything special here. } diff --git a/cove/src/euph/small_message.rs b/cove/src/euph/small_message.rs index 5db1790..0642801 100644 --- a/cove/src/euph/small_message.rs +++ b/cove/src/euph/small_message.rs @@ -1,18 +1,214 @@ -use crossterm::style::Stylize; -use euphoxide::api::{MessageId, Snowflake, Time, UserId}; -use jiff::Timestamp; -use toss::{Style, Styled}; +use std::mem; -use crate::{store::Msg, ui::ChatMsg}; +use crossterm::style::Stylize; +use euphoxide::api::{MessageId, Snowflake, Time}; +use time::OffsetDateTime; +use toss::{Style, Styled}; +use tz::TimeZone; + +use crate::store::Msg; +use crate::ui::ChatMsg; use super::util; +fn nick_char(ch: char) -> bool { + // Closely following the heim mention regex: + // https://github.com/euphoria-io/heim/blob/978c921063e6b06012fc8d16d9fbf1b3a0be1191/client/lib/stores/chat.js#L14-L15 + // `>` has been experimentally confirmed to delimit mentions as well. + match ch { + ',' | '.' | '!' | '?' | ';' | '&' | '<' | '>' | '\'' | '"' => false, + _ => !ch.is_whitespace(), + } +} + +fn room_char(ch: char) -> bool { + // Basically just \w, see also + // https://github.com/euphoria-io/heim/blob/978c921063e6b06012fc8d16d9fbf1b3a0be1191/client/lib/ui/MessageText.js#L66 + ch.is_ascii_alphanumeric() || ch == '_' +} + +enum Span { + Nothing, + Mention, + Room, + Emoji, +} + +struct Highlighter<'a> { + content: &'a str, + base_style: Style, + exact: bool, + + span: Span, + span_start: usize, + room_or_mention_possible: bool, + + result: Styled, +} + +impl<'a> Highlighter<'a> { + /// Does *not* guarantee `self.span_start == idx` after running! + fn close_mention(&mut self, idx: usize) { + let span_length = idx.saturating_sub(self.span_start); + if span_length <= 1 { + // We can repurpose the current span + self.span = Span::Nothing; + return; + } + + let text = &self.content[self.span_start..idx]; // Includes @ + self.result = mem::take(&mut self.result).and_then(if self.exact { + util::style_nick_exact(text, self.base_style) + } else { + util::style_nick(text, self.base_style) + }); + + self.span = Span::Nothing; + self.span_start = idx; + } + + /// Does *not* guarantee `self.span_start == idx` after running! + fn close_room(&mut self, idx: usize) { + let span_length = idx.saturating_sub(self.span_start); + if span_length <= 1 { + // We can repurpose the current span + self.span = Span::Nothing; + return; + } + + self.result = mem::take(&mut self.result).then( + &self.content[self.span_start..idx], + self.base_style.blue().bold(), + ); + + self.span = Span::Nothing; + self.span_start = idx; + } + + // Warning: `idx` is the index of the closing colon. + fn close_emoji(&mut self, idx: usize) { + let name = &self.content[self.span_start + 1..idx]; + if let Some(replace) = util::EMOJI.get(name) { + match replace { + Some(replace) if !self.exact => { + self.result = mem::take(&mut self.result).then(replace, self.base_style); + } + _ => { + let text = &self.content[self.span_start..=idx]; + let style = self.base_style.magenta(); + self.result = mem::take(&mut self.result).then(text, style); + } + } + + self.span = Span::Nothing; + self.span_start = idx + 1; + } else { + self.close_plain(idx); + self.span = Span::Emoji; + } + } + + /// Guarantees `self.span_start == idx` after running. + fn close_plain(&mut self, idx: usize) { + if self.span_start == idx { + // Span has length 0 + return; + } + + self.result = + mem::take(&mut self.result).then(&self.content[self.span_start..idx], self.base_style); + + self.span = Span::Nothing; + self.span_start = idx; + } + + fn close_span_before_current_char(&mut self, idx: usize, char: char) { + match self.span { + Span::Mention if !nick_char(char) => self.close_mention(idx), + Span::Room if !room_char(char) => self.close_room(idx), + Span::Emoji if char == '&' || char == '@' => { + self.span = Span::Nothing; + } + _ => {} + } + } + + fn update_span_with_current_char(&mut self, idx: usize, char: char) { + match self.span { + Span::Nothing if char == '@' && self.room_or_mention_possible => { + self.close_plain(idx); + self.span = Span::Mention; + } + Span::Nothing if char == '&' && self.room_or_mention_possible => { + self.close_plain(idx); + self.span = Span::Room; + } + Span::Nothing if char == ':' => { + self.close_plain(idx); + self.span = Span::Emoji; + } + Span::Emoji if char == ':' => self.close_emoji(idx), + _ => {} + } + } + + fn close_final_span(&mut self) { + let idx = self.content.len(); + if self.span_start >= idx { + return; // Span has no contents + } + + match self.span { + Span::Mention => self.close_mention(idx), + Span::Room => self.close_room(idx), + _ => {} + } + + self.close_plain(idx); + } + + fn step(&mut self, idx: usize, char: char) { + if self.span_start < idx { + self.close_span_before_current_char(idx, char); + } + + self.update_span_with_current_char(idx, char); + + // More permissive than the heim web client + self.room_or_mention_possible = !char.is_alphanumeric(); + } + + fn highlight(content: &'a str, base_style: Style, exact: bool) -> Styled { + let mut this = Self { + content: if exact { content } else { content.trim() }, + base_style, + exact, + span: Span::Nothing, + span_start: 0, + room_or_mention_possible: true, + result: Styled::default(), + }; + + for (idx, char) in (if exact { content } else { content.trim() }).char_indices() { + this.step(idx, char); + } + + this.close_final_span(); + + this.result + } +} + +fn highlight_content(content: &str, base_style: Style, exact: bool) -> Styled { + Highlighter::highlight(content, base_style, exact) +} + #[derive(Debug, Clone)] pub struct SmallMessage { pub id: MessageId, pub parent: Option, pub time: Time, - pub user_id: UserId, + pub time_zone: &'static TimeZone, pub nick: String, pub content: String, pub seen: bool, @@ -28,22 +224,22 @@ fn style_me() -> Style { fn styled_nick(nick: &str) -> Styled { Styled::new_plain("[") - .and_then(super::style_nick(nick, Style::new())) + .and_then(util::style_nick(nick, Style::new())) .then_plain("]") } fn styled_nick_me(nick: &str) -> Styled { let style = style_me(); - Styled::new("*", style).and_then(super::style_nick(nick, style)) + Styled::new("*", style).and_then(util::style_nick(nick, style)) } fn styled_content(content: &str) -> Styled { - super::highlight(content.trim(), Style::new(), false) + highlight_content(content.trim(), Style::new(), false) } fn styled_content_me(content: &str) -> Styled { let style = style_me(); - super::highlight(content.trim(), style, false).then("*", style) + highlight_content(content.trim(), style, false).then("*", style) } fn styled_editor_content(content: &str) -> Styled { @@ -52,7 +248,7 @@ fn styled_editor_content(content: &str) -> Styled { } else { Style::new() }; - super::highlight(content, style, true) + highlight_content(content, style, true) } impl Msg for SmallMessage { @@ -73,15 +269,11 @@ impl Msg for SmallMessage { fn last_possible_id() -> Self::Id { MessageId(Snowflake::MAX) } - - fn nick_emoji(&self) -> Option { - Some(util::user_id_emoji(&self.user_id)) - } } impl ChatMsg for SmallMessage { - fn time(&self) -> Option { - Some(self.time.as_timestamp()) + fn time(&self) -> Option { + crate::util::convert_to_time_zone(self.time_zone, self.time.0) } fn styled(&self) -> (Styled, Styled) { diff --git a/cove/src/euph/util.rs b/cove/src/euph/util.rs index ea1782a..fdf11a3 100644 --- a/cove/src/euph/util.rs +++ b/cove/src/euph/util.rs @@ -1,27 +1,9 @@ -use std::{ - collections::HashSet, - hash::{DefaultHasher, Hash, Hasher}, - sync::LazyLock, -}; - use crossterm::style::{Color, Stylize}; -use euphoxide::{Emoji, api::UserId}; +use euphoxide::Emoji; +use once_cell::sync::Lazy; use toss::{Style, Styled}; -pub static EMOJI: LazyLock = LazyLock::new(Emoji::load); - -pub static EMOJI_LIST: LazyLock> = LazyLock::new(|| { - let mut list = EMOJI - .0 - .values() - .flatten() - .cloned() - .collect::>() - .into_iter() - .collect::>(); - list.sort_unstable(); - list -}); +pub static EMOJI: Lazy = Lazy::new(Emoji::load); /// Convert HSL to RGB following [this approach from wikipedia][1]. /// @@ -72,25 +54,3 @@ pub fn style_nick(nick: &str, base: Style) -> Styled { pub fn style_nick_exact(nick: &str, base: Style) -> Styled { Styled::new(nick, nick_style(nick, base)) } - -pub fn style_mention(mention: &str, base: Style) -> Styled { - let nick = mention - .strip_prefix('@') - .expect("mention must start with @"); - Styled::new(EMOJI.replace(mention), nick_style(nick, base)) -} - -pub fn style_mention_exact(mention: &str, base: Style) -> Styled { - let nick = mention - .strip_prefix('@') - .expect("mention must start with @"); - Styled::new(mention, nick_style(nick, base)) -} - -pub fn user_id_emoji(user_id: &UserId) -> String { - let mut hasher = DefaultHasher::new(); - user_id.0.hash(&mut hasher); - let hash = hasher.finish(); - let emoji = &EMOJI_LIST[hash as usize % EMOJI_LIST.len()]; - emoji.clone() -} diff --git a/cove/src/export.rs b/cove/src/export.rs index 80db7b6..0ad9414 100644 --- a/cove/src/export.rs +++ b/cove/src/export.rs @@ -1,15 +1,13 @@ //! Export logs from the vault to plain text files. -use std::{ - fs::File, - io::{self, BufWriter, Write}, -}; - -use crate::vault::{EuphRoomVault, EuphVault, RoomIdentifier}; - mod json; mod text; +use std::fs::File; +use std::io::{self, BufWriter, Write}; + +use crate::vault::{EuphRoomVault, EuphVault, RoomIdentifier}; + #[derive(Debug, Clone, Copy, clap::ValueEnum)] pub enum Format { /// Human-readable tree-structured messages. diff --git a/cove/src/export/text.rs b/cove/src/export/text.rs index 2ca6687..bb3cfa1 100644 --- a/cove/src/export/text.rs +++ b/cove/src/export/text.rs @@ -1,11 +1,16 @@ use std::io::Write; use euphoxide::api::MessageId; +use time::format_description::FormatItem; +use time::macros::format_description; use unicode_width::UnicodeWidthStr; -use crate::{euph::SmallMessage, store::Tree, vault::EuphRoomVault}; +use crate::euph::SmallMessage; +use crate::store::Tree; +use crate::vault::EuphRoomVault; -const TIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S"; +const TIME_FORMAT: &[FormatItem<'_>] = + format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); const TIME_EMPTY: &str = " "; pub async fn export(vault: &EuphRoomVault, out: &mut W) -> anyhow::Result<()> { @@ -62,7 +67,11 @@ fn write_msg( for (i, line) in msg.content.lines().enumerate() { if i == 0 { - let time = msg.time.as_timestamp().strftime(TIME_FORMAT); + let time = msg + .time + .0 + .format(TIME_FORMAT) + .expect("time can be formatted"); writeln!(file, "{time} {indent_string}[{nick}] {line}")?; } else { writeln!(file, "{TIME_EMPTY} {indent_string}| {nick_empty} {line}")?; diff --git a/cove/src/logger.rs b/cove/src/logger.rs index 940e1a9..b8b696b 100644 --- a/cove/src/logger.rs +++ b/cove/src/logger.rs @@ -1,22 +1,22 @@ -use std::{convert::Infallible, sync::Arc, vec}; +use std::convert::Infallible; +use std::sync::Arc; +use std::vec; use async_trait::async_trait; use crossterm::style::Stylize; -use jiff::Timestamp; use log::{Level, LevelFilter, Log}; use parking_lot::Mutex; +use time::OffsetDateTime; use tokio::sync::mpsc; use toss::{Style, Styled}; -use crate::{ - store::{Msg, MsgStore, Path, Tree}, - ui::ChatMsg, -}; +use crate::store::{Msg, MsgStore, Path, Tree}; +use crate::ui::ChatMsg; #[derive(Debug, Clone)] pub struct LogMsg { id: usize, - time: Timestamp, + time: OffsetDateTime, level: Level, content: String, } @@ -42,7 +42,7 @@ impl Msg for LogMsg { } impl ChatMsg for LogMsg { - fn time(&self) -> Option { + fn time(&self) -> Option { Some(self.time) } @@ -209,7 +209,7 @@ impl Log for Logger { let mut guard = self.messages.lock(); let msg = LogMsg { id: guard.len(), - time: Timestamp::now(), + time: OffsetDateTime::now_utc(), level: record.level(), content: format!("<{}> {}", record.target(), record.args()), }; diff --git a/cove/src/main.rs b/cove/src/main.rs index 51bc502..fc14b56 100644 --- a/cove/src/main.rs +++ b/cove/src/main.rs @@ -1,23 +1,6 @@ // TODO Remove unnecessary Debug impls and compare compile times // TODO Invoke external notification command? -use std::path::PathBuf; - -use anyhow::Context; -use clap::Parser; -use cove_config::{Config, doc::Document}; -use directories::{BaseDirs, ProjectDirs}; -use log::info; -use tokio::sync::mpsc; -use toss::Terminal; - -use crate::{ - logger::Logger, - ui::Ui, - vault::Vault, - version::{NAME, VERSION}, -}; - mod euph; mod export; mod logger; @@ -28,6 +11,22 @@ mod util; mod vault; mod version; +use std::path::PathBuf; + +use anyhow::Context; +use clap::Parser; +use cove_config::doc::Document; +use cove_config::Config; +use directories::{BaseDirs, ProjectDirs}; +use log::info; +use tokio::sync::mpsc; +use toss::Terminal; + +use crate::logger::Logger; +use crate::ui::Ui; +use crate::vault::Vault; +use crate::version::{NAME, VERSION}; + #[derive(Debug, clap::Parser)] enum Command { /// Run the client interactively (default). @@ -46,12 +45,6 @@ enum Command { HelpConfig, } -#[derive(Debug, Clone, Copy, clap::ValueEnum)] -enum WidthEstimationMethod { - Legacy, - Unicode, -} - impl Default for Command { fn default() -> Self { Self::Run @@ -85,11 +78,6 @@ struct Args { #[arg(long, short)] offline: bool, - /// Method for estimating the width of characters as displayed by the - /// terminal emulator. - #[arg(long, short)] - width_estimation_method: Option, - /// Measure the width of characters as displayed by the terminal emulator /// instead of guessing the width. #[arg(long, short)] @@ -125,23 +113,21 @@ fn update_config_with_args(config: &mut Config, args: &Args) { } config.ephemeral |= args.ephemeral; - if let Some(method) = args.width_estimation_method { - config.width_estimation_method = match method { - WidthEstimationMethod::Legacy => cove_config::WidthEstimationMethod::Legacy, - WidthEstimationMethod::Unicode => cove_config::WidthEstimationMethod::Unicode, - } - } config.measure_widths |= args.measure_widths; config.offline |= args.offline; } fn open_vault(config: &Config, dirs: &ProjectDirs) -> anyhow::Result { + let time_zone = + util::load_time_zone(config.time_zone_ref()).context("failed to load time zone")?; + let time_zone = Box::leak(Box::new(time_zone)); + let vault = if config.ephemeral { - vault::launch_in_memory()? + vault::launch_in_memory(time_zone)? } else { let data_dir = data_dir(config, dirs); eprintln!("Data dir: {}", data_dir.to_string_lossy()); - vault::launch(&data_dir.join("vault.db"))? + vault::launch(&data_dir.join("vault.db"), time_zone)? }; Ok(vault) @@ -154,11 +140,6 @@ async fn main() -> anyhow::Result<()> { let (logger, logger_guard, logger_rx) = Logger::init(args.verbose); let dirs = ProjectDirs::from("de", "plugh", "cove").expect("failed to find config directory"); - // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 - rustls::crypto::aws_lc_rs::default_provider() - .install_default() - .unwrap(); - // Locate config let config_path = config_path(&args, &dirs); eprintln!("Config file: {}", config_path.to_string_lossy()); @@ -193,17 +174,11 @@ async fn run( ) -> anyhow::Result<()> { info!("Welcome to {NAME} {VERSION}",); - let tz = util::load_time_zone(config.time_zone_ref()).context("failed to load time zone")?; - let vault = open_vault(config, dirs)?; let mut terminal = Terminal::new()?; terminal.set_measuring(config.measure_widths); - terminal.set_width_estimation_method(match config.width_estimation_method { - cove_config::WidthEstimationMethod::Legacy => toss::WidthEstimationMethod::Legacy, - cove_config::WidthEstimationMethod::Unicode => toss::WidthEstimationMethod::Unicode, - }); - Ui::run(config, tz, &mut terminal, vault.clone(), logger, logger_rx).await?; + Ui::run(config, &mut terminal, vault.clone(), logger, logger_rx).await?; drop(terminal); vault.close().await; diff --git a/cove/src/store.rs b/cove/src/store.rs index b7031c1..a3601a8 100644 --- a/cove/src/store.rs +++ b/cove/src/store.rs @@ -1,4 +1,7 @@ -use std::{collections::HashMap, fmt::Debug, hash::Hash, vec}; +use std::collections::HashMap; +use std::fmt::Debug; +use std::hash::Hash; +use std::vec; use async_trait::async_trait; @@ -8,10 +11,6 @@ pub trait Msg { fn parent(&self) -> Option; fn seen(&self) -> bool; - fn nick_emoji(&self) -> Option { - None - } - fn last_possible_id() -> Self::Id; } @@ -131,7 +130,6 @@ impl Tree { } } -#[allow(dead_code)] #[async_trait] pub trait MsgStore { type Error; diff --git a/cove/src/ui.rs b/cove/src/ui.rs index 5ebd540..95cc4d1 100644 --- a/cove/src/ui.rs +++ b/cove/src/ui.rs @@ -1,30 +1,3 @@ -use std::{ - convert::Infallible, - io, - sync::{Arc, Weak}, - time::{Duration, Instant}, -}; - -use cove_config::Config; -use cove_input::InputEvent; -use jiff::tz::TimeZone; -use parking_lot::FairMutex; -use tokio::{ - sync::mpsc::{self, UnboundedReceiver, UnboundedSender, error::TryRecvError}, - task, -}; -use toss::{Terminal, WidgetExt, widgets::BoxedAsync}; - -use crate::{ - logger::{LogMsg, Logger}, - macros::logging_unwrap, - util::InfallibleExt, - vault::Vault, -}; - -pub use self::chat::ChatMsg; -use self::{chat::ChatState, rooms::Rooms, widgets::ListState}; - mod chat; mod euph; mod key_bindings; @@ -32,6 +5,30 @@ mod rooms; mod util; mod widgets; +use std::convert::Infallible; +use std::io; +use std::sync::{Arc, Weak}; +use std::time::{Duration, Instant}; + +use cove_config::Config; +use cove_input::InputEvent; +use parking_lot::FairMutex; +use tokio::sync::mpsc::error::TryRecvError; +use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; +use tokio::task; +use toss::widgets::BoxedAsync; +use toss::{Terminal, WidgetExt}; + +use crate::logger::{LogMsg, Logger}; +use crate::macros::logging_unwrap; +use crate::util::InfallibleExt; +use crate::vault::Vault; + +pub use self::chat::ChatMsg; +use self::chat::ChatState; +use self::rooms::Rooms; +use self::widgets::ListState; + /// Time to spend batch processing events before redrawing the screen. const EVENT_PROCESSING_TIME: Duration = Duration::from_millis(1000 / 15); // 15 fps @@ -50,7 +47,6 @@ impl From for UiError { } } -#[expect(clippy::large_enum_variant)] pub enum UiEvent { GraphemeWidthsChanged, LogChanged, @@ -88,7 +84,6 @@ impl Ui { pub async fn run( config: &'static Config, - tz: TimeZone, terminal: &mut Terminal, vault: Vault, logger: Logger, @@ -117,8 +112,8 @@ impl Ui { config, event_tx: event_tx.clone(), mode: Mode::Main, - rooms: Rooms::new(config, tz.clone(), vault, event_tx.clone()).await, - log_chat: ChatState::new(logger, tz), + rooms: Rooms::new(config, vault, event_tx.clone()).await, + log_chat: ChatState::new(logger), key_bindings_visible: false, key_bindings_list: ListState::new(), }; diff --git a/cove/src/ui/chat.rs b/cove/src/ui/chat.rs index 1116935..c8a310c 100644 --- a/cove/src/ui/chat.rs +++ b/cove/src/ui/chat.rs @@ -1,28 +1,25 @@ -use cove_config::Keys; -use cove_input::InputEvent; -use jiff::{Timestamp, tz::TimeZone}; -use toss::{ - Styled, WidgetExt, - widgets::{BoxedAsync, EditorState}, -}; - -use crate::{ - store::{Msg, MsgStore}, - util, -}; - -use super::UiError; - -use self::{cursor::Cursor, tree::TreeViewState}; - mod blocks; mod cursor; mod renderer; mod tree; mod widgets; +use cove_config::Keys; +use cove_input::InputEvent; +use time::OffsetDateTime; +use toss::widgets::{BoxedAsync, EditorState}; +use toss::{Styled, WidgetExt}; + +use crate::store::{Msg, MsgStore}; +use crate::util; + +use self::cursor::Cursor; +use self::tree::TreeViewState; + +use super::UiError; + pub trait ChatMsg { - fn time(&self) -> Option; + fn time(&self) -> Option; fn styled(&self) -> (Styled, Styled); fn edit(nick: &str, content: &str) -> (Styled, Styled); fn pseudo(nick: &str, content: &str) -> (Styled, Styled); @@ -37,7 +34,6 @@ pub struct ChatState> { cursor: Cursor, editor: EditorState, - nick_emoji: bool, caesar: i8, mode: Mode, @@ -45,23 +41,18 @@ pub struct ChatState> { } impl + Clone> ChatState { - pub fn new(store: S, tz: TimeZone) -> Self { + pub fn new(store: S) -> Self { Self { cursor: Cursor::Bottom, editor: EditorState::new(), - nick_emoji: false, caesar: 0, mode: Mode::Tree, - tree: TreeViewState::new(store.clone(), tz), + tree: TreeViewState::new(store.clone()), store, } } - - pub fn nick_emoji(&self) -> bool { - self.nick_emoji - } } impl> ChatState { @@ -85,7 +76,6 @@ impl> ChatState { &mut self.editor, nick, focused, - self.nick_emoji, self.caesar, ) .boxed_async(), @@ -124,11 +114,6 @@ impl> ChatState { Reaction::Composed { parent, content } } - Reaction::NotHandled if event.matches(&keys.tree.action.toggle_nick_emoji) => { - self.nick_emoji = !self.nick_emoji; - Reaction::Handled - } - Reaction::NotHandled if event.matches(&keys.tree.action.increase_caesar) => { self.caesar = (self.caesar + 1).rem_euclid(26); Reaction::Handled diff --git a/cove/src/ui/chat/blocks.rs b/cove/src/ui/chat/blocks.rs index 8360e83..1b91864 100644 --- a/cove/src/ui/chat/blocks.rs +++ b/cove/src/ui/chat/blocks.rs @@ -1,6 +1,6 @@ //! Common rendering logic. -use std::collections::{VecDeque, vec_deque}; +use std::collections::{vec_deque, VecDeque}; use toss::widgets::Predrawn; diff --git a/cove/src/ui/chat/cursor.rs b/cove/src/ui/chat/cursor.rs index 87bd8fc..561f4ed 100644 --- a/cove/src/ui/chat/cursor.rs +++ b/cove/src/ui/chat/cursor.rs @@ -1,6 +1,7 @@ //! Common cursor movement logic. -use std::{collections::HashSet, hash::Hash}; +use std::collections::HashSet; +use std::hash::Hash; use crate::store::{Msg, MsgStore, Tree}; diff --git a/cove/src/ui/chat/renderer.rs b/cove/src/ui/chat/renderer.rs index a619e7c..ae0ad8f 100644 --- a/cove/src/ui/chat/renderer.rs +++ b/cove/src/ui/chat/renderer.rs @@ -14,6 +14,7 @@ pub trait Renderer { fn blocks(&self) -> &Blocks; fn blocks_mut(&mut self) -> &mut Blocks; + fn into_blocks(self) -> Blocks; async fn expand_top(&mut self) -> Result<(), Self::Error>; async fn expand_bottom(&mut self) -> Result<(), Self::Error>; diff --git a/cove/src/ui/chat/tree.rs b/cove/src/ui/chat/tree.rs index d9905fc..37972e5 100644 --- a/cove/src/ui/chat/tree.rs +++ b/cove/src/ui/chat/tree.rs @@ -2,31 +2,29 @@ // TODO Focusing on sub-trees +mod renderer; +mod scroll; +mod widgets; + use std::collections::HashSet; use async_trait::async_trait; use cove_config::Keys; use cove_input::InputEvent; -use jiff::tz::TimeZone; -use toss::{AsyncWidget, Frame, Pos, Size, WidgetExt, WidthDb, widgets::EditorState}; +use toss::widgets::EditorState; +use toss::{AsyncWidget, Frame, Pos, Size, WidgetExt, WidthDb}; -use crate::{ - store::{Msg, MsgStore}, - ui::{UiError, util}, - util::InfallibleExt, -}; - -use super::{ChatMsg, Reaction, cursor::Cursor}; +use crate::store::{Msg, MsgStore}; +use crate::ui::{util, ChatMsg, UiError}; +use crate::util::InfallibleExt; use self::renderer::{TreeContext, TreeRenderer}; -mod renderer; -mod scroll; -mod widgets; +use super::cursor::Cursor; +use super::Reaction; pub struct TreeViewState> { store: S, - tz: TimeZone, last_size: Size, last_nick: String, @@ -38,10 +36,9 @@ pub struct TreeViewState> { } impl> TreeViewState { - pub fn new(store: S, tz: TimeZone) -> Self { + pub fn new(store: S) -> Self { Self { store, - tz, last_size: Size::ZERO, last_nick: String::new(), last_cursor: Cursor::Bottom, @@ -389,7 +386,6 @@ impl> TreeViewState { editor: &'a mut EditorState, nick: String, focused: bool, - nick_emoji: bool, caesar: i8, ) -> TreeView<'a, M, S> { TreeView { @@ -398,7 +394,6 @@ impl> TreeViewState { editor, nick, focused, - nick_emoji, caesar, } } @@ -412,8 +407,6 @@ pub struct TreeView<'a, M: Msg, S: MsgStore> { nick: String, focused: bool, - - nick_emoji: bool, caesar: i8, } @@ -442,7 +435,6 @@ where size, nick: self.nick.clone(), focused: self.focused, - nick_emoji: self.nick_emoji, caesar: self.caesar, last_cursor: self.state.last_cursor.clone(), last_cursor_top: self.state.last_cursor_top, @@ -451,7 +443,6 @@ where let mut renderer = TreeRenderer::new( context, &self.state.store, - &self.state.tz, &mut self.state.folded, self.cursor, self.editor, diff --git a/cove/src/ui/chat/tree/renderer.rs b/cove/src/ui/chat/tree/renderer.rs index 225191b..99f32b5 100644 --- a/cove/src/ui/chat/tree/renderer.rs +++ b/cove/src/ui/chat/tree/renderer.rs @@ -1,26 +1,18 @@ //! A [`Renderer`] for message trees. -use std::{collections::HashSet, convert::Infallible}; +use std::collections::HashSet; +use std::convert::Infallible; use async_trait::async_trait; -use jiff::tz::TimeZone; -use toss::{ - Size, Widget, WidthDb, - widgets::{EditorState, Empty, Predrawn, Resize}, -}; +use toss::widgets::{EditorState, Empty, Predrawn, Resize}; +use toss::{Size, Widget, WidthDb}; -use crate::{ - store::{Msg, MsgStore, Tree}, - ui::{ - ChatMsg, - chat::{ - blocks::{Block, Blocks, Range}, - cursor::Cursor, - renderer::{self, Renderer, overlaps}, - }, - }, - util::InfallibleExt, -}; +use crate::store::{Msg, MsgStore, Tree}; +use crate::ui::chat::blocks::{Block, Blocks, Range}; +use crate::ui::chat::cursor::Cursor; +use crate::ui::chat::renderer::{self, overlaps, Renderer}; +use crate::ui::ChatMsg; +use crate::util::InfallibleExt; use super::widgets; @@ -80,7 +72,6 @@ pub struct TreeContext { pub size: Size, pub nick: String, pub focused: bool, - pub nick_emoji: bool, pub caesar: i8, pub last_cursor: Cursor, pub last_cursor_top: i32, @@ -90,7 +81,6 @@ pub struct TreeRenderer<'a, M: Msg, S: MsgStore> { context: TreeContext, store: &'a S, - tz: &'a TimeZone, folded: &'a mut HashSet, cursor: &'a mut Cursor, editor: &'a mut EditorState, @@ -118,7 +108,6 @@ where pub fn new( context: TreeContext, store: &'a S, - tz: &'a TimeZone, folded: &'a mut HashSet, cursor: &'a mut Cursor, editor: &'a mut EditorState, @@ -127,7 +116,6 @@ where Self { context, store, - tz, folded, cursor, editor, @@ -203,15 +191,7 @@ where }; let highlighted = highlighted && self.context.focused; - let widget = widgets::msg( - highlighted, - self.tz.clone(), - indent, - msg, - self.context.nick_emoji, - self.context.caesar, - folded_info, - ); + let widget = widgets::msg(highlighted, indent, msg, self.context.caesar, folded_info); let widget = Self::predraw(widget, self.context.size, self.widthdb); Block::new(TreeBlockId::Msg(msg_id), widget, true) } @@ -446,7 +426,7 @@ where pub fn into_visible_blocks( self, - ) -> impl Iterator, Block>)> + use { + ) -> impl Iterator, Block>)> { let area = renderer::visible_area(&self); self.blocks .into_iter() @@ -480,6 +460,10 @@ where &mut self.blocks } + fn into_blocks(self) -> TreeBlocks { + self.blocks + } + async fn expand_top(&mut self) -> Result<(), Self::Error> { let prev_root_id = if let Some(top_root_id) = &self.top_root_id { self.store.prev_root_id(top_root_id).await? diff --git a/cove/src/ui/chat/tree/scroll.rs b/cove/src/ui/chat/tree/scroll.rs index a8a1305..822b0b5 100644 --- a/cove/src/ui/chat/tree/scroll.rs +++ b/cove/src/ui/chat/tree/scroll.rs @@ -1,14 +1,12 @@ -use toss::{WidthDb, widgets::EditorState}; +use toss::widgets::EditorState; +use toss::WidthDb; -use crate::{ - store::{Msg, MsgStore}, - ui::{ChatMsg, chat::cursor::Cursor}, -}; +use crate::store::{Msg, MsgStore}; +use crate::ui::chat::cursor::Cursor; +use crate::ui::ChatMsg; -use super::{ - TreeViewState, - renderer::{TreeContext, TreeRenderer}, -}; +use super::renderer::{TreeContext, TreeRenderer}; +use super::TreeViewState; impl TreeViewState where @@ -22,7 +20,6 @@ where size: self.last_size, nick: self.last_nick.clone(), focused: true, - nick_emoji: false, caesar: 0, last_cursor: self.last_cursor.clone(), last_cursor_top: self.last_cursor_top, @@ -40,7 +37,6 @@ where let mut renderer = TreeRenderer::new( context, &self.store, - &self.tz, &mut self.folded, cursor, editor, @@ -68,7 +64,6 @@ where let mut renderer = TreeRenderer::new( context, &self.store, - &self.tz, &mut self.folded, cursor, editor, diff --git a/cove/src/ui/chat/tree/widgets.rs b/cove/src/ui/chat/tree/widgets.rs index dd7fa89..9eb6690 100644 --- a/cove/src/ui/chat/tree/widgets.rs +++ b/cove/src/ui/chat/tree/widgets.rs @@ -1,20 +1,13 @@ use std::convert::Infallible; use crossterm::style::Stylize; -use jiff::tz::TimeZone; -use toss::{ - Style, Styled, WidgetExt, - widgets::{Boxed, EditorState, Join2, Join4, Join5, Text}, -}; +use toss::widgets::{Boxed, EditorState, Join2, Join4, Join5, Text}; +use toss::{Style, Styled, WidgetExt}; -use crate::{ - store::Msg, - ui::{ - ChatMsg, - chat::widgets::{Indent, Seen, Time}, - }, - util, -}; +use crate::store::Msg; +use crate::ui::chat::widgets::{Indent, Seen, Time}; +use crate::ui::ChatMsg; +use crate::util; pub const PLACEHOLDER: &str = "[...]"; @@ -56,20 +49,12 @@ fn style_pseudo_highlight() -> Style { pub fn msg( highlighted: bool, - tz: TimeZone, indent: usize, msg: &M, - nick_emoji: bool, caesar: i8, folded_info: Option, ) -> Boxed<'static, Infallible> { - let (mut nick, mut content) = msg.styled(); - - if nick_emoji { - if let Some(emoji) = msg.nick_emoji() { - nick = nick.then_plain("(").then_plain(emoji).then_plain(")"); - } - } + let (nick, mut content) = msg.styled(); if caesar != 0 { // Apply caesar in inverse because we're decoding @@ -87,7 +72,7 @@ pub fn msg( Join5::horizontal( Seen::new(msg.seen()).segment().with_fixed(true), - Time::new(msg.time().map(|t| t.to_zoned(tz)), style_time(highlighted)) + Time::new(msg.time(), style_time(highlighted)) .padding() .with_right(1) .with_stretch(true) diff --git a/cove/src/ui/chat/widgets.rs b/cove/src/ui/chat/widgets.rs index e0e2fe5..5d35e9c 100644 --- a/cove/src/ui/chat/widgets.rs +++ b/cove/src/ui/chat/widgets.rs @@ -1,11 +1,11 @@ use std::convert::Infallible; use crossterm::style::Stylize; -use jiff::Zoned; -use toss::{ - Frame, Pos, Size, Style, Widget, WidgetExt, WidthDb, - widgets::{Boxed, Empty, Text}, -}; +use time::format_description::FormatItem; +use time::macros::format_description; +use time::OffsetDateTime; +use toss::widgets::{Boxed, Empty, Text}; +use toss::{Frame, Pos, Size, Style, Widget, WidgetExt, WidthDb}; use crate::util::InfallibleExt; @@ -46,15 +46,15 @@ impl Widget for Indent { } } -const TIME_FORMAT: &str = "%Y-%m-%d %H:%M"; +const TIME_FORMAT: &[FormatItem<'_>] = format_description!("[year]-[month]-[day] [hour]:[minute]"); const TIME_WIDTH: u16 = 16; pub struct Time(Boxed<'static, Infallible>); impl Time { - pub fn new(time: Option, style: Style) -> Self { + pub fn new(time: Option, style: Style) -> Self { let widget = if let Some(time) = time { - let text = time.strftime(TIME_FORMAT).to_string(); + let text = time.format(TIME_FORMAT).expect("could not format time"); Text::new((text, style)) .background() .with_style(style) diff --git a/cove/src/ui/euph/account.rs b/cove/src/ui/euph/account.rs index 7aa776f..359e9d5 100644 --- a/cove/src/ui/euph/account.rs +++ b/cove/src/ui/euph/account.rs @@ -1,16 +1,14 @@ use cove_config::Keys; use cove_input::InputEvent; use crossterm::style::Stylize; -use euphoxide::{api::PersonalAccountView, conn}; -use toss::{ - Style, Widget, WidgetExt, - widgets::{EditorState, Empty, Join3, Join4, Join5, Text}, -}; +use euphoxide::api::PersonalAccountView; +use euphoxide::conn; +use toss::widgets::{EditorState, Empty, Join3, Join4, Join5, Text}; +use toss::{Style, Widget, WidgetExt}; -use crate::{ - euph::{self, Room}, - ui::{UiError, util, widgets::Popup}, -}; +use crate::euph::{self, Room}; +use crate::ui::widgets::Popup; +use crate::ui::{util, UiError}; use super::popup::PopupResult; @@ -35,7 +33,7 @@ impl LoggedOut { } } - fn widget(&mut self) -> impl Widget { + fn widget(&mut self) -> impl Widget + '_ { let bold = Style::new().bold(); Join4::vertical( Text::new(("Not logged in", bold.yellow())).segment(), @@ -68,7 +66,7 @@ impl LoggedOut { pub struct LoggedIn(PersonalAccountView); impl LoggedIn { - fn widget(&self) -> impl Widget + use<> { + fn widget(&self) -> impl Widget { let bold = Style::new().bold(); Join5::vertical( Text::new(("Logged in", bold.green())).segment(), @@ -111,7 +109,7 @@ impl AccountUiState { } } - pub fn widget(&mut self) -> impl Widget { + pub fn widget(&mut self) -> impl Widget + '_ { let inner = match self { Self::LoggedOut(logged_out) => logged_out.widget().first2(), Self::LoggedIn(logged_in) => logged_in.widget().second2(), diff --git a/cove/src/ui/euph/auth.rs b/cove/src/ui/euph/auth.rs index 15f8fe1..b938ff1 100644 --- a/cove/src/ui/euph/auth.rs +++ b/cove/src/ui/euph/auth.rs @@ -1,11 +1,11 @@ use cove_config::Keys; use cove_input::InputEvent; -use toss::{Widget, widgets::EditorState}; +use toss::widgets::EditorState; +use toss::Widget; -use crate::{ - euph::Room, - ui::{UiError, util, widgets::Popup}, -}; +use crate::euph::Room; +use crate::ui::widgets::Popup; +use crate::ui::{util, UiError}; use super::popup::PopupResult; @@ -13,7 +13,7 @@ pub fn new() -> EditorState { EditorState::new() } -pub fn widget(editor: &mut EditorState) -> impl Widget { +pub fn widget(editor: &mut EditorState) -> impl Widget + '_ { Popup::new( editor.widget().with_hidden_default_placeholder(), "Enter password", diff --git a/cove/src/ui/euph/inspect.rs b/cove/src/ui/euph/inspect.rs index b3c4e0e..25620a2 100644 --- a/cove/src/ui/euph/inspect.rs +++ b/cove/src/ui/euph/inspect.rs @@ -1,13 +1,13 @@ use cove_config::Keys; use cove_input::InputEvent; use crossterm::style::Stylize; -use euphoxide::{ - api::{Message, NickEvent, SessionView}, - conn::SessionInfo, -}; -use toss::{Style, Styled, Widget, widgets::Text}; +use euphoxide::api::{Message, NickEvent, SessionView}; +use euphoxide::conn::SessionInfo; +use toss::widgets::Text; +use toss::{Style, Styled, Widget}; -use crate::ui::{UiError, widgets::Popup}; +use crate::ui::widgets::Popup; +use crate::ui::UiError; use super::popup::PopupResult; @@ -91,7 +91,7 @@ fn message_lines(mut text: Styled, msg: &Message) -> Styled { text } -pub fn session_widget(session: &SessionInfo) -> impl Widget + use<> { +pub fn session_widget(session: &SessionInfo) -> impl Widget { let heading_style = Style::new().bold(); let text = match session { @@ -108,7 +108,7 @@ pub fn session_widget(session: &SessionInfo) -> impl Widget + use<> { Popup::new(Text::new(text), "Inspect session") } -pub fn message_widget(msg: &Message) -> impl Widget + use<> { +pub fn message_widget(msg: &Message) -> impl Widget { let heading_style = Style::new().bold(); let mut text = Styled::new("Message", heading_style).then_plain("\n"); diff --git a/cove/src/ui/euph/links.rs b/cove/src/ui/euph/links.rs index c64830d..8e3f535 100644 --- a/cove/src/ui/euph/links.rs +++ b/cove/src/ui/euph/links.rs @@ -1,31 +1,19 @@ use cove_config::{Config, Keys}; use cove_input::InputEvent; -use crossterm::{event::KeyCode, style::Stylize}; +use crossterm::event::KeyCode; +use crossterm::style::Stylize; use linkify::{LinkFinder, LinkKind}; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{Join2, Text}, -}; +use toss::widgets::{Join2, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use crate::{ - euph::{self, SpanType}, - ui::{ - UiError, key_bindings, util, - widgets::{ListBuilder, ListState, Popup}, - }, -}; +use crate::ui::widgets::{ListBuilder, ListState, Popup}; +use crate::ui::{key_bindings, util, UiError}; use super::popup::PopupResult; -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] -enum Link { - Url(String), - Room(String), -} - pub struct LinksState { config: &'static Config, - links: Vec, + links: Vec, list: ListState, } @@ -33,34 +21,12 @@ const NUMBER_KEYS: [char; 10] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0 impl LinksState { pub fn new(config: &'static Config, content: &str) -> Self { - let mut links = vec![]; - - // Collect URL-like links - for link in LinkFinder::new() + let links = LinkFinder::new() .url_must_have_scheme(false) .kinds(&[LinkKind::Url]) .links(content) - { - links.push(( - link.start(), - link.end(), - Link::Url(link.as_str().to_string()), - )); - } - - // Collect room links - for (span, range) in euph::find_spans(content) { - if span == SpanType::Room { - let name = &content[range.start + 1..range.end]; - links.push((range.start, range.end, Link::Room(name.to_string()))); - } - } - - links.sort(); - let links = links - .into_iter() - .map(|(_, _, link)| link) - .collect::>(); + .map(|l| l.as_str().to_string()) + .collect(); Self { config, @@ -69,7 +35,7 @@ impl LinksState { } } - pub fn widget(&mut self) -> impl Widget { + pub fn widget(&mut self) -> impl Widget + '_ { let style_selected = Style::new().black().on_white(); let mut list_builder = ListBuilder::new(); @@ -80,29 +46,29 @@ impl LinksState { for (id, link) in self.links.iter().enumerate() { let link = link.clone(); - list_builder.add_sel(id, move |selected| { - let mut text = Styled::default(); - - // Number key indicator - text = match NUMBER_KEYS.get(id) { - None if selected => text.then(" ", style_selected), - None => text.then_plain(" "), - Some(key) if selected => text.then(format!("[{key}] "), style_selected.bold()), - Some(key) => text.then(format!("[{key}] "), Style::new().dark_grey().bold()), - }; - - // The link itself - text = match link { - Link::Url(url) if selected => text.then(url, style_selected), - Link::Url(url) => text.then_plain(url), - Link::Room(name) if selected => { - text.then(format!("&{name}"), style_selected.bold()) - } - Link::Room(name) => text.then(format!("&{name}"), Style::new().blue().bold()), - }; - - Text::new(text).with_wrap(false) - }); + if let Some(&number_key) = NUMBER_KEYS.get(id) { + list_builder.add_sel(id, move |selected| { + let text = if selected { + Styled::new(format!("[{number_key}]"), style_selected.bold()) + .then(" ", style_selected) + .then(link, style_selected) + } else { + Styled::new(format!("[{number_key}]"), Style::new().dark_grey().bold()) + .then_plain(" ") + .then_plain(link) + }; + Text::new(text) + }); + } else { + list_builder.add_sel(id, move |selected| { + let text = if selected { + Styled::new(format!(" {link}"), style_selected) + } else { + Styled::new_plain(format!(" {link}")) + }; + Text::new(text) + }); + } } let hint_style = Style::new().grey().italic(); @@ -126,24 +92,18 @@ impl LinksState { } fn open_link_by_id(&self, id: usize) -> PopupResult { - match self.links.get(id) { - Some(Link::Url(url)) => { - // The `http://` or `https://` schema is necessary for - // open::that to successfully open the link in the browser. - let link = if url.starts_with("http://") || url.starts_with("https://") { - url.clone() - } else { - format!("https://{url}") - }; + if let Some(link) = self.links.get(id) { + // The `http://` or `https://` schema is necessary for open::that to + // successfully open the link in the browser. + let link = if link.starts_with("http://") || link.starts_with("https://") { + link.clone() + } else { + format!("https://{link}") + }; - if let Err(error) = open::that(&link) { - return PopupResult::ErrorOpeningLink { link, error }; - } + if let Err(error) = open::that(&link) { + return PopupResult::ErrorOpeningLink { link, error }; } - - Some(Link::Room(name)) => return PopupResult::SwitchToRoom { name: name.clone() }, - - _ => {} } PopupResult::Handled } diff --git a/cove/src/ui/euph/nick.rs b/cove/src/ui/euph/nick.rs index 707e992..0bb1062 100644 --- a/cove/src/ui/euph/nick.rs +++ b/cove/src/ui/euph/nick.rs @@ -1,12 +1,12 @@ use cove_config::Keys; use cove_input::InputEvent; use euphoxide::conn::Joined; -use toss::{Style, Widget, widgets::EditorState}; +use toss::widgets::EditorState; +use toss::{Style, Widget}; -use crate::{ - euph::{self, Room}, - ui::{UiError, util, widgets::Popup}, -}; +use crate::euph::{self, Room}; +use crate::ui::widgets::Popup; +use crate::ui::{util, UiError}; use super::popup::PopupResult; @@ -14,7 +14,7 @@ pub fn new(joined: Joined) -> EditorState { EditorState::with_initial_text(joined.session.name) } -pub fn widget(editor: &mut EditorState) -> impl Widget { +pub fn widget(editor: &mut EditorState) -> impl Widget + '_ { let inner = editor .widget() .with_highlight(|s| euph::style_nick_exact(s, Style::new())); diff --git a/cove/src/ui/euph/nick_list.rs b/cove/src/ui/euph/nick_list.rs index 8fbdb7b..23160bd 100644 --- a/cove/src/ui/euph/nick_list.rs +++ b/cove/src/ui/euph/nick_list.rs @@ -1,31 +1,22 @@ use std::iter; use crossterm::style::{Color, Stylize}; -use euphoxide::{ - api::{NickEvent, SessionId, SessionType, SessionView, UserId}, - conn::{Joined, SessionInfo}, -}; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{Background, Text}, -}; +use euphoxide::api::{NickEvent, SessionId, SessionType, SessionView, UserId}; +use euphoxide::conn::{Joined, SessionInfo}; +use toss::widgets::{Background, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use crate::{ - euph, - ui::{ - UiError, - widgets::{ListBuilder, ListState}, - }, -}; +use crate::euph; +use crate::ui::widgets::{ListBuilder, ListState}; +use crate::ui::UiError; pub fn widget<'a>( list: &'a mut ListState, joined: &Joined, focused: bool, - nick_emoji: bool, -) -> impl Widget + use<'a> { +) -> impl Widget + 'a { let mut list_builder = ListBuilder::new(); - render_rows(&mut list_builder, joined, focused, nick_emoji); + render_rows(&mut list_builder, joined, focused); list_builder.build(list) } @@ -71,7 +62,6 @@ fn render_rows( list_builder: &mut ListBuilder<'_, SessionId, Background>, joined: &Joined, focused: bool, - nick_emoji: bool, ) { let mut people = vec![]; let mut bots = vec![]; @@ -97,38 +87,10 @@ fn render_rows( lurkers.sort_unstable(); nurkers.sort_unstable(); - render_section( - list_builder, - "People", - &people, - &joined.session, - focused, - nick_emoji, - ); - render_section( - list_builder, - "Bots", - &bots, - &joined.session, - focused, - nick_emoji, - ); - render_section( - list_builder, - "Lurkers", - &lurkers, - &joined.session, - focused, - nick_emoji, - ); - render_section( - list_builder, - "Nurkers", - &nurkers, - &joined.session, - focused, - nick_emoji, - ); + render_section(list_builder, "People", &people, &joined.session, focused); + render_section(list_builder, "Bots", &bots, &joined.session, focused); + render_section(list_builder, "Lurkers", &lurkers, &joined.session, focused); + render_section(list_builder, "Nurkers", &nurkers, &joined.session, focused); } fn render_section( @@ -137,7 +99,6 @@ fn render_section( sessions: &[HalfSession], own_session: &SessionView, focused: bool, - nick_emoji: bool, ) { if sessions.is_empty() { return; @@ -155,7 +116,7 @@ fn render_section( list_builder.add_unsel(Text::new(row).background()); for session in sessions { - render_row(list_builder, session, own_session, focused, nick_emoji); + render_row(list_builder, session, own_session, focused); } } @@ -164,7 +125,6 @@ fn render_row( session: &HalfSession, own_session: &SessionView, focused: bool, - nick_emoji: bool, ) { let (name, style, style_inv, perms_style_inv) = if session.name.is_empty() { let name = "lurk".to_string(); @@ -198,24 +158,16 @@ fn render_row( " " }; - let emoji = if nick_emoji { - format!(" ({})", euph::user_id_emoji(&session.id)) - } else { - "".to_string() - }; - list_builder.add_sel(session.session_id.clone(), move |selected| { if focused && selected { let text = Styled::new_plain(owner) .then(name, style_inv) - .then(perms, perms_style_inv) - .then(emoji, perms_style_inv); + .then(perms, perms_style_inv); Text::new(text).background().with_style(style_inv) } else { let text = Styled::new_plain(owner) .then(&name, style) - .then_plain(perms) - .then_plain(emoji); + .then_plain(perms); Text::new(text).background() } }); diff --git a/cove/src/ui/euph/popup.rs b/cove/src/ui/euph/popup.rs index c434fb6..f70e999 100644 --- a/cove/src/ui/euph/popup.rs +++ b/cove/src/ui/euph/popup.rs @@ -1,16 +1,18 @@ use std::io; use crossterm::style::Stylize; -use toss::{Style, Styled, Widget, widgets::Text}; +use toss::widgets::Text; +use toss::{Style, Styled, Widget}; -use crate::ui::{UiError, widgets::Popup}; +use crate::ui::widgets::Popup; +use crate::ui::UiError; pub enum RoomPopup { Error { description: String, reason: String }, } impl RoomPopup { - fn server_error_widget(description: &str, reason: &str) -> impl Widget + use<> { + fn server_error_widget(description: &str, reason: &str) -> impl Widget { let border_style = Style::new().red().bold(); let text = Styled::new_plain(description) .then_plain("\n\n") @@ -21,7 +23,7 @@ impl RoomPopup { Popup::new(Text::new(text), ("Error", border_style)).with_border_style(border_style) } - pub fn widget(&self) -> impl Widget + use<> { + pub fn widget(&self) -> impl Widget { match self { Self::Error { description, @@ -35,6 +37,5 @@ pub enum PopupResult { NotHandled, Handled, Close, - SwitchToRoom { name: String }, ErrorOpeningLink { link: String, error: io::Error }, } diff --git a/cove/src/ui/euph/room.rs b/cove/src/ui/euph/room.rs index 7e8ff99..8fc2fe5 100644 --- a/cove/src/ui/euph/room.rs +++ b/cove/src/ui/euph/room.rs @@ -3,40 +3,25 @@ use std::collections::VecDeque; use cove_config::{Config, Keys}; use cove_input::InputEvent; use crossterm::style::Stylize; -use euphoxide::{ - api::{Data, Message, MessageId, PacketType, SessionId, packet::ParsedPacket}, - bot::instance::{ConnSnapshot, Event, ServerConfig}, - conn::{self, Joined, Joining, SessionInfo}, -}; -use jiff::tz::TimeZone; -use tokio::sync::{ - mpsc, - oneshot::{self, error::TryRecvError}, -}; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{BoxedAsync, EditorState, Join2, Layer, Text}, -}; +use euphoxide::api::{Data, Message, MessageId, PacketType, SessionId}; +use euphoxide::bot::instance::{Event, ServerConfig}; +use euphoxide::conn::{self, Joined, Joining, SessionInfo}; +use tokio::sync::oneshot::error::TryRecvError; +use tokio::sync::{mpsc, oneshot}; +use toss::widgets::{BoxedAsync, EditorState, Join2, Layer, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use crate::{ - euph::{self, SpanType}, - macros::logging_unwrap, - ui::{ - UiError, UiEvent, - chat::{ChatState, Reaction}, - util, - widgets::ListState, - }, - vault::{EuphRoomVault, RoomIdentifier}, -}; +use crate::euph; +use crate::macros::logging_unwrap; +use crate::ui::chat::{ChatState, Reaction}; +use crate::ui::widgets::ListState; +use crate::ui::{util, UiError, UiEvent}; +use crate::vault::EuphRoomVault; -use super::{ - account::AccountUiState, - auth, inspect, - links::LinksState, - nick, nick_list, - popup::{PopupResult, RoomPopup}, -}; +use super::account::AccountUiState; +use super::links::LinksState; +use super::popup::{PopupResult, RoomPopup}; +use super::{auth, inspect, nick, nick_list}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum Focus { @@ -73,8 +58,6 @@ pub struct EuphRoom { last_msg_sent: Option>, nick_list: ListState, - - mentioned: bool, } impl EuphRoom { @@ -83,7 +66,6 @@ impl EuphRoom { server_config: ServerConfig, room_config: cove_config::EuphRoom, vault: EuphRoomVault, - tz: TimeZone, ui_event_tx: mpsc::UnboundedSender, ) -> Self { Self { @@ -95,10 +77,9 @@ impl EuphRoom { focus: Focus::Chat, state: State::Normal, popups: VecDeque::new(), - chat: ChatState::new(vault, tz), + chat: ChatState::new(vault), last_msg_sent: None, nick_list: ListState::new(), - mentioned: false, } } @@ -121,7 +102,7 @@ impl EuphRoom { .server_config .clone() .room(self.vault().room().name.clone()) - .name(format!("{room:?}-{next_instance_id}")) + .name(format!("{room:?}-{}", next_instance_id)) .human(true) .username(self.room_config.username.clone()) .force_username(self.room_config.force_username) @@ -167,12 +148,6 @@ impl EuphRoom { } } - pub fn retrieve_mentioned(&mut self) -> bool { - let mentioned = self.mentioned; - self.mentioned = false; - mentioned - } - pub async fn unseen_msgs_count(&self) -> usize { logging_unwrap!(self.vault().unseen_msgs_count().await) } @@ -291,16 +266,11 @@ impl EuphRoom { joined: &Joined, focus: Focus, ) -> BoxedAsync<'a, UiError> { - let nick_list_widget = nick_list::widget( - nick_list, - joined, - focus == Focus::NickList, - chat.nick_emoji(), - ) - .padding() - .with_right(1) - .border() - .desync(); + let nick_list_widget = nick_list::widget(nick_list, joined, focus == Focus::NickList) + .padding() + .with_right(1) + .border() + .desync(); let chat_widget = chat.widget(joined.session.name.clone(), focus == Focus::Chat); @@ -315,7 +285,7 @@ impl EuphRoom { .boxed_async() } - async fn status_widget(&self, state: Option<&euph::State>) -> impl Widget + use<> { + async fn status_widget(&self, state: Option<&euph::State>) -> impl Widget { let room_style = Style::new().bold().blue(); let mut info = Styled::new(format!("{} ", self.domain()), Style::new().grey()) .then(format!("&{}", self.name()), room_style); @@ -514,22 +484,18 @@ impl EuphRoom { false } - pub async fn handle_input_event( - &mut self, - event: &mut InputEvent<'_>, - keys: &Keys, - ) -> RoomResult { + pub async fn handle_input_event(&mut self, event: &mut InputEvent<'_>, keys: &Keys) -> bool { if !self.popups.is_empty() { if event.matches(&keys.general.abort) { self.popups.pop_back(); - return RoomResult::Handled; + return true; } // Prevent event from reaching anything below the popup - return RoomResult::NotHandled; + return false; } let result = match &mut self.state { - State::Normal => return self.handle_normal_input_event(event, keys).await.into(), + State::Normal => return self.handle_normal_input_event(event, keys).await, State::Auth(editor) => auth::handle_input_event(event, keys, &self.room, editor), State::Nick(editor) => nick::handle_input_event(event, keys, &self.room, editor), State::Account(account) => account.handle_input_event(event, keys, &self.room), @@ -540,24 +506,18 @@ impl EuphRoom { }; match result { - PopupResult::NotHandled => RoomResult::NotHandled, - PopupResult::Handled => RoomResult::Handled, + PopupResult::NotHandled => false, + PopupResult::Handled => true, PopupResult::Close => { self.state = State::Normal; - RoomResult::Handled + true } - PopupResult::SwitchToRoom { name } => RoomResult::SwitchToRoom { - room: RoomIdentifier { - domain: self.vault().room().domain.clone(), - name, - }, - }, PopupResult::ErrorOpeningLink { link, error } => { self.popups.push_front(RoomPopup::Error { description: format!("Failed to open link: {link}"), reason: format!("{error}"), }); - RoomResult::Handled + true } } } @@ -571,35 +531,6 @@ impl EuphRoom { return false; } - if let Event::Packet( - _, - ParsedPacket { - content: Ok(Data::SendEvent(send)), - .. - }, - ConnSnapshot { - state: conn::State::Joined(joined), - .. - }, - ) = &event - { - let normalized_name = euphoxide::nick::normalize(&joined.session.name); - let content = &*send.0.content; - for (rtype, rspan) in euph::find_spans(content) { - if rtype != SpanType::Mention { - continue; - } - let Some(mention) = content[rspan].strip_prefix('@') else { - continue; - }; - let normalized_mention = euphoxide::nick::normalize(mention); - if normalized_name == normalized_mention { - self.mentioned = true; - break; - } - } - } - // We handle the packet internally first because the room event handling // will consume it while we only need a reference. let handled = if let Event::Packet(_, packet, _) = &event { @@ -691,18 +622,3 @@ impl EuphRoom { true } } - -pub enum RoomResult { - NotHandled, - Handled, - SwitchToRoom { room: RoomIdentifier }, -} - -impl From for RoomResult { - fn from(value: bool) -> Self { - match value { - true => Self::Handled, - false => Self::NotHandled, - } - } -} diff --git a/cove/src/ui/key_bindings.rs b/cove/src/ui/key_bindings.rs index daedc16..8fceda6 100644 --- a/cove/src/ui/key_bindings.rs +++ b/cove/src/ui/key_bindings.rs @@ -5,15 +5,11 @@ use std::convert::Infallible; use cove_config::{Config, Keys}; use cove_input::{InputEvent, KeyBinding, KeyBindingInfo, KeyGroupInfo}; use crossterm::style::Stylize; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{Either2, Join2, Padding, Text}, -}; +use toss::widgets::{Either2, Join2, Padding, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use super::{ - UiError, util, - widgets::{ListBuilder, ListState, Popup}, -}; +use super::widgets::{ListBuilder, ListState, Popup}; +use super::{util, UiError}; type Line = Either2, Text>>; type Builder = ListBuilder<'static, Infallible, Line>; @@ -73,7 +69,7 @@ fn render_group_info(builder: &mut Builder, group_info: KeyGroupInfo<'_>) { pub fn widget<'a>( list: &'a mut ListState, config: &Config, -) -> impl Widget + use<'a> { +) -> impl Widget + 'a { let mut list_builder = ListBuilder::new(); for group_info in config.keys.groups() { diff --git a/cove/src/ui/rooms.rs b/cove/src/ui/rooms.rs index c3d6a40..f40bfc5 100644 --- a/cove/src/ui/rooms.rs +++ b/cove/src/ui/rooms.rs @@ -1,46 +1,33 @@ -use std::{ - collections::{HashMap, HashSet, hash_map::Entry}, - iter, - sync::{Arc, Mutex}, - time::Duration, -}; +mod connect; +mod delete; + +use std::collections::hash_map::Entry; +use std::collections::{HashMap, HashSet}; +use std::iter; +use std::sync::{Arc, Mutex}; +use std::time::Duration; use cove_config::{Config, Keys, RoomsSortOrder}; use cove_input::InputEvent; use crossterm::style::Stylize; -use euphoxide::{ - api::SessionType, - bot::instance::{Event, ServerConfig}, - conn::{self, Joined}, -}; -use jiff::tz::TimeZone; +use euphoxide::api::SessionType; +use euphoxide::bot::instance::{Event, ServerConfig}; +use euphoxide::conn::{self, Joined}; use tokio::sync::mpsc; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{BellState, BoxedAsync, Empty, Join2, Text}, -}; +use toss::widgets::{BoxedAsync, Empty, Join2, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use crate::{ - euph, - macros::logging_unwrap, - vault::{EuphVault, RoomIdentifier, Vault}, - version::{NAME, VERSION}, -}; +use crate::euph; +use crate::macros::logging_unwrap; +use crate::vault::{EuphVault, RoomIdentifier, Vault}; +use crate::version::{NAME, VERSION}; -use super::{ - UiError, UiEvent, - euph::room::{EuphRoom, RoomResult}, - key_bindings, util, - widgets::{ListBuilder, ListState}, -}; +use self::connect::{ConnectResult, ConnectState}; +use self::delete::{DeleteResult, DeleteState}; -use self::{ - connect::{ConnectResult, ConnectState}, - delete::{DeleteResult, DeleteState}, -}; - -mod connect; -mod delete; +use super::euph::room::EuphRoom; +use super::widgets::{ListBuilder, ListState}; +use super::{key_bindings, util, UiError, UiEvent}; enum State { ShowList, @@ -86,7 +73,6 @@ impl EuphServer { pub struct Rooms { config: &'static Config, - tz: TimeZone, vault: Vault, ui_event_tx: mpsc::UnboundedSender, @@ -95,7 +81,6 @@ pub struct Rooms { list: ListState, order: Order, - bell: BellState, euph_servers: HashMap, euph_rooms: HashMap, @@ -104,19 +89,16 @@ pub struct Rooms { impl Rooms { pub async fn new( config: &'static Config, - tz: TimeZone, vault: Vault, ui_event_tx: mpsc::UnboundedSender, ) -> Self { let mut result = Self { config, - tz, vault, ui_event_tx, state: State::ShowList, list: ListState::new(), order: Order::from_rooms_sort_order(config.rooms_sort_order), - bell: BellState::new(), euph_servers: HashMap::new(), euph_rooms: HashMap::new(), }; @@ -160,7 +142,6 @@ impl Rooms { server.config.clone(), self.config.euph_room(&room.domain, &room.name), self.vault.euph().room(room), - self.tz.clone(), self.ui_event_tx.clone(), ) }) @@ -177,7 +158,6 @@ impl Rooms { server.config.clone(), self.config.euph_room(&room.domain, &room.name), self.vault.euph().room(room), - self.tz.clone(), self.ui_event_tx.clone(), ) }); @@ -246,9 +226,7 @@ impl Rooms { .retain(|n, r| !r.stopped() || rooms_set.contains(n)); for room in rooms_set { - let room = self.get_or_insert_room(room).await; - room.retain(); - self.bell.ring |= room.retrieve_mentioned(); + self.get_or_insert_room(room).await.retain(); } } @@ -258,7 +236,7 @@ impl Rooms { _ => self.stabilize_rooms().await, } - let widget = match &mut self.state { + match &mut self.state { State::ShowList => Self::rooms_widget( &self.vault, self.config, @@ -301,12 +279,6 @@ impl Rooms { .below(delete.widget()) .desync() .boxed_async(), - }; - - if self.config.bell_on_mention { - widget.above(self.bell.widget().desync()).boxed_async() - } else { - widget } } @@ -445,7 +417,7 @@ impl Rooms { list: &'a mut ListState, order: Order, euph_rooms: &HashMap, - ) -> impl Widget + use<'a> { + ) -> impl Widget + 'a { let version_info = Styled::new_plain("Welcome to ") .then(format!("{NAME} {VERSION}"), Style::new().yellow().bold()) .then_plain("!"); @@ -536,10 +508,7 @@ impl Rooms { } if event.matches(&keys.rooms.action.connect_autojoin) { for (domain, server) in &self.config.euph.servers { - for (name, room) in &server.rooms { - if !room.autojoin { - continue; - } + for name in server.rooms.keys() { let id = RoomIdentifier::new(domain.clone(), name.clone()); self.connect_to_room(id).await; } @@ -587,15 +556,8 @@ impl Rooms { } State::ShowRoom(name) => { if let Some(room) = self.euph_rooms.get_mut(name) { - match room.handle_input_event(event, keys).await { - RoomResult::NotHandled => {} - RoomResult::Handled => return true, - RoomResult::SwitchToRoom { room } => { - self.list.move_cursor_to_id(&room); - self.connect_to_room(room.clone()).await; - self.state = State::ShowRoom(room); - return true; - } + if room.handle_input_event(event, keys).await { + return true; } if event.matches(&keys.general.abort) { self.state = State::ShowList; @@ -609,7 +571,6 @@ impl Rooms { return true; } ConnectResult::Connect(room) => { - self.list.move_cursor_to_id(&room); self.connect_to_room(room.clone()).await; self.state = State::ShowRoom(room); return true; diff --git a/cove/src/ui/rooms/connect.rs b/cove/src/ui/rooms/connect.rs index 83a359e..2bf90c5 100644 --- a/cove/src/ui/rooms/connect.rs +++ b/cove/src/ui/rooms/connect.rs @@ -1,15 +1,12 @@ use cove_config::Keys; use cove_input::InputEvent; use crossterm::style::Stylize; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{EditorState, Empty, Join2, Join3, Text}, -}; +use toss::widgets::{EditorState, Empty, Join2, Join3, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use crate::{ - ui::{UiError, util, widgets::Popup}, - vault::RoomIdentifier, -}; +use crate::ui::widgets::Popup; +use crate::ui::{util, UiError}; +use crate::vault::RoomIdentifier; #[derive(Clone, Copy, PartialEq, Eq)] enum Focus { @@ -84,7 +81,7 @@ impl ConnectState { ConnectResult::Unhandled } - pub fn widget(&mut self) -> impl Widget { + pub fn widget(&mut self) -> impl Widget + '_ { let room_style = Style::new().bold().blue(); let domain_style = Style::new().grey(); diff --git a/cove/src/ui/rooms/delete.rs b/cove/src/ui/rooms/delete.rs index baa96b1..5a20415 100644 --- a/cove/src/ui/rooms/delete.rs +++ b/cove/src/ui/rooms/delete.rs @@ -1,15 +1,12 @@ use cove_config::Keys; use cove_input::InputEvent; use crossterm::style::Stylize; -use toss::{ - Style, Styled, Widget, WidgetExt, - widgets::{EditorState, Empty, Join2, Text}, -}; +use toss::widgets::{EditorState, Empty, Join2, Text}; +use toss::{Style, Styled, Widget, WidgetExt}; -use crate::{ - ui::{UiError, util, widgets::Popup}, - vault::RoomIdentifier, -}; +use crate::ui::widgets::Popup; +use crate::ui::{util, UiError}; +use crate::vault::RoomIdentifier; pub struct DeleteState { id: RoomIdentifier, @@ -47,7 +44,7 @@ impl DeleteState { DeleteResult::Unhandled } - pub fn widget(&mut self) -> impl Widget { + pub fn widget(&mut self) -> impl Widget + '_ { let warn_style = Style::new().bold().red(); let room_style = Style::new().bold().blue(); let text = Styled::new_plain("Are you sure you want to delete ") diff --git a/cove/src/ui/widgets.rs b/cove/src/ui/widgets.rs index c00d26e..aed063a 100644 --- a/cove/src/ui/widgets.rs +++ b/cove/src/ui/widgets.rs @@ -1,5 +1,5 @@ -pub use self::list::*; -pub use self::popup::*; - mod list; mod popup; + +pub use self::list::*; +pub use self::popup::*; diff --git a/cove/src/ui/widgets/list.rs b/cove/src/ui/widgets/list.rs index 3d7c6c8..bb27540 100644 --- a/cove/src/ui/widgets/list.rs +++ b/cove/src/ui/widgets/list.rs @@ -239,12 +239,6 @@ impl ListState { }) } - pub fn move_cursor_to_id(&mut self, id: &Id) { - if let Some(new_cursor) = self.selectable_of_id(id) { - self.move_cursor_to(new_cursor); - } - } - fn fix_cursor(&mut self) { let new_cursor = if let Some(cursor) = &self.cursor { self.selectable_of_id(&cursor.id) diff --git a/cove/src/ui/widgets/popup.rs b/cove/src/ui/widgets/popup.rs index 559e283..40b41cb 100644 --- a/cove/src/ui/widgets/popup.rs +++ b/cove/src/ui/widgets/popup.rs @@ -1,7 +1,5 @@ -use toss::{ - Frame, Size, Style, Styled, Widget, WidgetExt, WidthDb, - widgets::{Background, Border, Desync, Float, Layer2, Padding, Text}, -}; +use toss::widgets::{Background, Border, Desync, Float, Layer2, Padding, Text}; +use toss::{Frame, Size, Style, Styled, Widget, WidgetExt, WidthDb}; type Body = Background>>; type Title = Float>>>; diff --git a/cove/src/util.rs b/cove/src/util.rs index c6a572c..4844d68 100644 --- a/cove/src/util.rs +++ b/cove/src/util.rs @@ -1,6 +1,8 @@ -use std::{convert::Infallible, env}; +use std::convert::Infallible; +use std::env; -use jiff::tz::TimeZone; +use time::{OffsetDateTime, UtcOffset}; +use tz::{TimeZone, TzError}; pub trait InfallibleExt { type Inner; @@ -24,30 +26,27 @@ impl InfallibleExt for Result { /// /// If no `TZ` environment variable could be found and no string is provided, /// the system local time (or UTC on Windows) is used. -pub fn load_time_zone(tz_string: Option<&str>) -> Result { +pub fn load_time_zone(tz_string: Option<&str>) -> Result { let env_string = env::var("TZ").ok(); let tz_string = env_string.as_ref().map(|s| s as &str).or(tz_string); - let Some(tz_string) = tz_string else { - return Ok(TimeZone::system()); - }; - - if tz_string == "localtime" { - return Ok(TimeZone::system()); + match &tz_string { + // At the moment, TimeZone::from_posix_tz does not support "localtime" + // on Windows, so we handle that case manually. + Some("localtime") | None => TimeZone::local(), + Some(tz_string) => TimeZone::from_posix_tz(tz_string), } +} - if let Some(tz_string) = tz_string.strip_prefix(':') { - return TimeZone::get(tz_string); - } +pub fn convert_to_time_zone(tz: &TimeZone, time: OffsetDateTime) -> Option { + let utc_offset_in_seconds = tz + .find_local_time_type(time.unix_timestamp()) + .ok()? + .ut_offset(); - // The time zone is either a manually specified string or a file in the tz - // database. We'll try to parse it as a manually specified string first - // because that doesn't require a fs lookup. - if let Ok(tz) = TimeZone::posix(tz_string) { - return Ok(tz); - } + let utc_offset = UtcOffset::from_whole_seconds(utc_offset_in_seconds).ok()?; - TimeZone::get(tz_string) + Some(time.to_offset(utc_offset)) } pub fn caesar(text: &str, by: i8) -> String { diff --git a/cove/src/vault.rs b/cove/src/vault.rs index 05bd1a5..55abbf0 100644 --- a/cove/src/vault.rs +++ b/cove/src/vault.rs @@ -1,17 +1,21 @@ -use std::{fs, path::Path}; - -use rusqlite::Connection; -use vault::{Action, tokio::TokioVault}; - -pub use self::euph::{EuphRoomVault, EuphVault, RoomIdentifier}; - mod euph; mod migrate; mod prepare; +use std::fs; +use std::path::Path; + +use rusqlite::Connection; +use tz::TimeZone; +use vault::tokio::TokioVault; +use vault::Action; + +pub use self::euph::{EuphRoomVault, EuphVault, RoomIdentifier}; + #[derive(Debug, Clone)] pub struct Vault { tokio_vault: TokioVault, + time_zone: &'static TimeZone, ephemeral: bool, } @@ -44,18 +48,23 @@ impl Vault { } } -fn launch_from_connection(conn: Connection, ephemeral: bool) -> rusqlite::Result { +fn launch_from_connection( + conn: Connection, + time_zone: &'static TimeZone, + ephemeral: bool, +) -> rusqlite::Result { conn.pragma_update(None, "foreign_keys", true)?; conn.pragma_update(None, "trusted_schema", false)?; let tokio_vault = TokioVault::launch_and_prepare(conn, &migrate::MIGRATIONS, prepare::prepare)?; Ok(Vault { tokio_vault, + time_zone, ephemeral, }) } -pub fn launch(path: &Path) -> rusqlite::Result { +pub fn launch(path: &Path, time_zone: &'static TimeZone) -> rusqlite::Result { // If this fails, rusqlite will complain about not being able to open the db // file, which saves me from adding a separate vault error type. let _ = fs::create_dir_all(path.parent().expect("path to file")); @@ -70,10 +79,10 @@ pub fn launch(path: &Path) -> rusqlite::Result { conn.pragma_update(None, "locking_mode", "exclusive")?; conn.pragma_update(None, "journal_mode", "wal")?; - launch_from_connection(conn, false) + launch_from_connection(conn, time_zone, false) } -pub fn launch_in_memory() -> rusqlite::Result { +pub fn launch_in_memory(time_zone: &'static TimeZone) -> rusqlite::Result { let conn = Connection::open_in_memory()?; - launch_from_connection(conn, true) + launch_from_connection(conn, time_zone, true) } diff --git a/cove/src/vault/euph.rs b/cove/src/vault/euph.rs index 4a4109e..f922345 100644 --- a/cove/src/vault/euph.rs +++ b/cove/src/vault/euph.rs @@ -1,25 +1,23 @@ -use std::{fmt, mem, str::FromStr}; +use std::str::FromStr; +use std::{fmt, mem}; use async_trait::async_trait; use cookie::{Cookie, CookieJar}; use euphoxide::api::{Message, MessageId, SessionId, SessionView, Snowflake, Time, UserId}; -use rusqlite::{ - Connection, OptionalExtension, Row, ToSql, Transaction, named_params, params, - types::{FromSql, FromSqlError, ToSqlOutput, Value, ValueRef}, -}; +use rusqlite::types::{FromSql, FromSqlError, ToSqlOutput, Value, ValueRef}; +use rusqlite::{named_params, params, Connection, OptionalExtension, Row, ToSql, Transaction}; +use time::OffsetDateTime; use vault::Action; -use crate::{ - euph::SmallMessage, - store::{MsgStore, Path, Tree}, -}; +use crate::euph::SmallMessage; +use crate::store::{MsgStore, Path, Tree}; /// Wrapper for [`Snowflake`] that implements useful rusqlite traits. struct WSnowflake(Snowflake); impl ToSql for WSnowflake { fn to_sql(&self) -> rusqlite::Result> { - self.0.0.to_sql() + self.0 .0.to_sql() } } @@ -34,7 +32,7 @@ struct WTime(Time); impl ToSql for WTime { fn to_sql(&self) -> rusqlite::Result> { - let timestamp = self.0.0; + let timestamp = self.0 .0.unix_timestamp(); Ok(ToSqlOutput::Owned(Value::Integer(timestamp))) } } @@ -42,7 +40,9 @@ impl ToSql for WTime { impl FromSql for WTime { fn column_result(value: ValueRef<'_>) -> rusqlite::types::FromSqlResult { let timestamp = i64::column_result(value)?; - Ok(Self(Time(timestamp))) + Ok(Self(Time( + OffsetDateTime::from_unix_timestamp(timestamp).expect("timestamp in range"), + ))) } } @@ -255,6 +255,8 @@ macro_rules! euph_room_vault_actions { $( struct $struct { room: RoomIdentifier, + #[allow(unused)] + time_zone: &'static tz::TimeZone, $( $arg: $arg_ty, )* } )* @@ -264,6 +266,7 @@ macro_rules! euph_room_vault_actions { pub async fn $fn(&self, $( $arg: $arg_ty, )* ) -> Result<$res, vault::tokio::Error> { self.vault.vault.tokio_vault.execute($struct { room: self.room.clone(), + time_zone: self.vault.vault.time_zone, $( $arg, )* }).await } @@ -611,7 +614,7 @@ impl Action for GetMsg { let msg = conn .query_row( " - SELECT id, parent, time, user_id, name, content, seen + SELECT id, parent, time, name, content, seen FROM euph_msgs WHERE domain = ? AND room = ? @@ -623,10 +626,10 @@ impl Action for GetMsg { id: MessageId(row.get::<_, WSnowflake>(0)?.0), parent: row.get::<_, Option>(1)?.map(|s| MessageId(s.0)), time: row.get::<_, WTime>(2)?.0, - user_id: UserId(row.get(3)?), - nick: row.get(4)?, - content: row.get(5)?, - seen: row.get(6)?, + time_zone: self.time_zone, + nick: row.get(3)?, + content: row.get(4)?, + seen: row.get(5)?, }) }, ) @@ -704,7 +707,7 @@ impl Action for GetTree { AND tree.room = euph_msgs.room AND tree.id = euph_msgs.parent ) - SELECT id, parent, time, user_id, name, content, seen + SELECT id, parent, time, name, content, seen FROM euph_msgs JOIN tree USING (domain, room, id) ORDER BY id ASC @@ -717,10 +720,10 @@ impl Action for GetTree { id: MessageId(row.get::<_, WSnowflake>(0)?.0), parent: row.get::<_, Option>(1)?.map(|s| MessageId(s.0)), time: row.get::<_, WTime>(2)?.0, - user_id: UserId(row.get(3)?), - nick: row.get(4)?, - content: row.get(5)?, - seen: row.get(6)?, + time_zone: self.time_zone, + nick: row.get(3)?, + content: row.get(4)?, + seen: row.get(5)?, }) }, )? diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1e52d47 --- /dev/null +++ b/flake.lock @@ -0,0 +1,47 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713520724, + "narHash": "sha256-CO8MmVDmqZX2FovL75pu5BvwhW+Vugc7Q6ze7Hj8heI=", + "owner": "nix-community", + "repo": "naersk", + "rev": "c5037590290c6c7dae2e42e7da1e247e54ed2d49", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1714068967, + "narHash": "sha256-jfQUewdwBVs0HHLH10qxyn0+J53e1aQoPSkuBnYf15s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "10b682b6e5ed139ee2bef863ada3043f2d79c1cc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..286f9b7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + description = "TUI client for euphoria.leet.nu, a threaded real-time chat platform"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + + naersk.url = "github:nix-community/naersk"; + naersk.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, naersk }: + let forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + in { + packages = forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + naersk' = pkgs.callPackage naersk { }; + cargoToml = pkgs.lib.importTOML ./Cargo.toml; + in + { + default = naersk'.buildPackage { + name = "cove"; + version = cargoToml.workspace.package.version; + root = ./.; + }; + } + ); + }; +}