diff --git a/CHANGELOG.md b/CHANGELOG.md index a26608b9..a27ec38e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## SDK 0.1.0-alpha.6 and CLI 0.1.0-alpha.7 — 2026-11-23 + +- Added the app-scoped native keychain secrets API, owned global shortcut + registrations, and single-instance activation forwarding. Window-state + persistence now drains pending writes with a bounded quit deadline. +- Added live system appearance palettes, external file drops on desktop and Web, + and native file icons with a bounded cache. +- Added bounded private application logging and `rake ctl logs` for reading and + following logs. Rake redacts user content from its own runtime diagnostics. +- Added styled selectable paragraphs and accessible inline and standalone links + with keyboard activation and drag selection. Published Rake uses the stock + GPUI Base 0.9.0 window selection. Its Root trims leading and trailing + whitespace on copy and binds Control-C on Web. The workspace Root also + preserves whitespace and binds Command-C on Web. +- Added experimental signal-based function components and the `locale` and + `locale-icu` prototypes for Fluent messages, locale switching, and ICU number + and date formatting. Inspection can find controls by their message keys. +- Improved CLI Windows inspection and source opening, development profile + diagnostics, and view syntax support. Registry scaffolds pin SDK alpha.6. +- Released the first `rake-shortcuts` package along with the changed supporting + crates at alpha.5. + ## CLI 0.1.0-alpha.6 — 2026-11-14 - Pins Blaze rake.3, fixing missing dependency manifests such as `hdrhistogram` diff --git a/Cargo.lock b/Cargo.lock index e92f0448..0059711c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7348,7 +7348,7 @@ dependencies = [ [[package]] name = "rake-app" -version = "0.1.0-alpha.5" +version = "0.1.0-alpha.6" dependencies = [ "anyhow", "async-io", @@ -7424,7 +7424,7 @@ dependencies = [ [[package]] name = "rake-app-cli" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "async-io", "base64 0.22.1", @@ -7498,7 +7498,7 @@ dependencies = [ [[package]] name = "rake-client" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "async-io", "futures", @@ -7523,7 +7523,7 @@ dependencies = [ [[package]] name = "rake-diagnostics" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "serde", "serde_json", @@ -7537,7 +7537,7 @@ dependencies = [ [[package]] name = "rake-dist" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "base64 0.23.1", "command-group", @@ -7676,7 +7676,7 @@ dependencies = [ [[package]] name = "rake-http" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "async-compat", "async-io", @@ -7704,7 +7704,7 @@ dependencies = [ [[package]] name = "rake-macros" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7715,7 +7715,7 @@ dependencies = [ [[package]] name = "rake-native" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "futures", "gpui-base", @@ -7757,7 +7757,7 @@ dependencies = [ [[package]] name = "rake-protocol" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "percent-encoding", "rake-diagnostics", @@ -7790,7 +7790,7 @@ dependencies = [ [[package]] name = "rake-shortcuts" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "ashpd", "async-io", @@ -7831,7 +7831,7 @@ dependencies = [ [[package]] name = "rake-ui" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "gpui-base", "gpui-fast", @@ -7877,7 +7877,7 @@ dependencies = [ [[package]] name = "rake-view-syntax" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 36d7c90f..52171cea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,15 +17,15 @@ gpui = { package = "gpui-pre", version = "=0.3.11", default-features = false } gpui_platform = { package = "gpui-pre-platform", version = "=0.3.11", default-features = false } gpui_fast = { package = "gpui-fast", version = "=0.1.13", default-features = false } gpui_fast_platform = { package = "gpui-fast-platform", version = "=0.1.13", default-features = false } -gpui-base = { version = "=0.9.0", path = "vendor/gpui-base" } +gpui-base = "=0.9.0" gpui-kit = "=0.9.0" -rake = { package = "rake-app", version = "=0.1.0-alpha.5", path = "crates/rake" } -rake-diagnostics = { version = "=0.1.0-alpha.4", path = "crates/rake-diagnostics" } -rake-http = { version = "=0.1.0-alpha.4", path = "crates/rake-http" } -rake-ui = { version = "=0.1.0-alpha.4", path = "crates/rake-ui" } -rake-native = { version = "=0.1.0-alpha.4", path = "crates/rake-native" } -rake-protocol = { version = "=0.1.0-alpha.4", path = "crates/rake-protocol" } -rake-client = { version = "=0.1.0-alpha.4", path = "crates/rake-client" } +rake = { package = "rake-app", version = "=0.1.0-alpha.6", path = "crates/rake" } +rake-diagnostics = { version = "=0.1.0-alpha.5", path = "crates/rake-diagnostics" } +rake-http = { version = "=0.1.0-alpha.5", path = "crates/rake-http" } +rake-ui = { version = "=0.1.0-alpha.5", path = "crates/rake-ui" } +rake-native = { version = "=0.1.0-alpha.5", path = "crates/rake-native" } +rake-protocol = { version = "=0.1.0-alpha.5", path = "crates/rake-protocol" } +rake-client = { version = "=0.1.0-alpha.5", path = "crates/rake-client" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tracing = "0.1" diff --git a/README.md b/README.md index 411655d9..439b7e5b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Rake needs Rust 1.98.0 and native development tools. Install the CLI and create a desktop/browser app: ```sh -cargo install rake-app-cli --version 0.1.0-alpha.6 --locked +cargo install rake-app-cli --version 0.1.0-alpha.7 --locked rake new hello-rake cd hello-rake rake dev @@ -68,7 +68,7 @@ fn app() -> App { } ``` -To add Rake to an existing crate, use `cargo add rake-app@0.1.0-alpha.5 --rename rake` +To add Rake to an existing crate, use `cargo add rake-app@0.1.0-alpha.6 --rename rake` and then use the Hello entry above. `view!`, themes and style presets are included by default; Kit and DevTools remain optional. diff --git a/crates/rake-cli/Cargo.toml b/crates/rake-cli/Cargo.toml index 4ef6a543..e1c12ec1 100644 --- a/crates/rake-cli/Cargo.toml +++ b/crates/rake-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-app-cli" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true license.workspace = true @@ -17,12 +17,12 @@ path = "src/main.rs" doc = false [dependencies] -rake-view-syntax = { version = "=0.1.0-alpha.4", path = "../rake-view-syntax" } +rake-view-syntax = { version = "=0.1.0-alpha.5", path = "../rake-view-syntax" } proc-macro2 = { version = "1", features = ["span-locations"] } syn = { version = "2", features = ["full", "visit"] } toml = "0.9" tempfile = "3" -rake-dist = { version = "=0.1.0-alpha.4", path = "../rake-dist" } +rake-dist = { version = "=0.1.0-alpha.5", path = "../rake-dist" } ctrlc = { version = "3.5", features = ["termination"] } base64 = "0.22.1" regex = "1" @@ -53,7 +53,7 @@ tungstenite = { version = "0.28", default-features = false, features = ["handsha [dev-dependencies] dunce = "1" -rake = { package = "rake-app", version = "=0.1.0-alpha.5", path = "../rake", default-features = false } +rake = { package = "rake-app", version = "=0.1.0-alpha.6", path = "../rake", default-features = false } [features] # Explicit consumer builds: real compiler/SDK/wasm prerequisites, outside the fast suite. diff --git a/crates/rake-cli/src/scaffold.rs b/crates/rake-cli/src/scaffold.rs index 5a9c419d..89350c64 100644 --- a/crates/rake-cli/src/scaffold.rs +++ b/crates/rake-cli/src/scaffold.rs @@ -405,7 +405,7 @@ mod tests { assert_eq!(dependency["rake"]["package"].as_str(), Some("rake-app")); assert_eq!( dependency["rake"]["version"].as_str(), - Some("=0.1.0-alpha.5") + Some("=0.1.0-alpha.6") ); } diff --git a/crates/rake-cli/tests/new_build.rs b/crates/rake-cli/tests/new_build.rs index ca40c6a8..768ae8ff 100644 --- a/crates/rake-cli/tests/new_build.rs +++ b/crates/rake-cli/tests/new_build.rs @@ -47,8 +47,11 @@ fn generated_app_builds_natively_and_for_the_browser() { packages .iter() .any(|package| package["name"].as_str() == Some("gpui-base") - && package.get("source").is_none()), - "external apps must retain Rake's patched selection runtime" + && package["version"].as_str() == Some("0.9.0") + && package["source"] + .as_str() + .is_some_and(|source| source.starts_with("registry+"))), + "external apps must resolve stock GPUI Base 0.9.0" ); for name in ["rake-blaze-live", "gpui-fast", "hdrhistogram"] { diff --git a/crates/rake-client/Cargo.toml b/crates/rake-client/Cargo.toml index 1dcef8c1..3dbbbc2f 100644 --- a/crates/rake-client/Cargo.toml +++ b/crates/rake-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-client" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake-diagnostics/Cargo.toml b/crates/rake-diagnostics/Cargo.toml index 430e557a..b3003a13 100644 --- a/crates/rake-diagnostics/Cargo.toml +++ b/crates/rake-diagnostics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-diagnostics" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake-dist/Cargo.toml b/crates/rake-dist/Cargo.toml index b6e02bd6..e971c6fd 100644 --- a/crates/rake-dist/Cargo.toml +++ b/crates/rake-dist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-dist" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake-http/Cargo.toml b/crates/rake-http/Cargo.toml index 2d0127f0..8add8d72 100644 --- a/crates/rake-http/Cargo.toml +++ b/crates/rake-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-http" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake-macros/Cargo.toml b/crates/rake-macros/Cargo.toml index 497a20c2..a37de928 100644 --- a/crates/rake-macros/Cargo.toml +++ b/crates/rake-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-macros" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true @@ -24,4 +24,4 @@ proc-macro2 = { version = "1", features = ["span-locations"] } quote = "1" syn = { version = "2", features = ["full", "visit", "visit-mut"] } proc-macro-crate = "3.5" -rake-view-syntax = { version = "=0.1.0-alpha.4", path = "../rake-view-syntax", optional = true } +rake-view-syntax = { version = "=0.1.0-alpha.5", path = "../rake-view-syntax", optional = true } diff --git a/crates/rake-native/Cargo.toml b/crates/rake-native/Cargo.toml index 474fd05d..ba68fd9d 100644 --- a/crates/rake-native/Cargo.toml +++ b/crates/rake-native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-native" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake-protocol/Cargo.toml b/crates/rake-protocol/Cargo.toml index 684b67a2..a18e036d 100644 --- a/crates/rake-protocol/Cargo.toml +++ b/crates/rake-protocol/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-protocol" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake-shortcuts/Cargo.toml b/crates/rake-shortcuts/Cargo.toml index 6935e873..43f4cccf 100644 --- a/crates/rake-shortcuts/Cargo.toml +++ b/crates/rake-shortcuts/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "rake-shortcuts" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true repository.workspace = true +publish = ["crates-io"] description = "Owned native global shortcut registrations for Rake" [lints] diff --git a/crates/rake-ui/Cargo.toml b/crates/rake-ui/Cargo.toml index 482543e0..66568717 100644 --- a/crates/rake-ui/Cargo.toml +++ b/crates/rake-ui/Cargo.toml @@ -1,19 +1,18 @@ [package] name = "rake-ui" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true repository.workspace = true -# Release hold until gpui-base ships the selectable text APIs and Rake upgrades. -publish = false +publish = ["crates-io"] description = "GPUI view helpers, themes and overlays" [lints] workspace = true [dependencies] -rake-macros = { version = "=0.1.0-alpha.4", path = "../rake-macros" } +rake-macros = { version = "=0.1.0-alpha.5", path = "../rake-macros" } tracing.workspace = true unicode-segmentation = "1.13.3" gpui_pre = { package = "gpui-pre", version = "=0.3.11", default-features = false } diff --git a/crates/rake-ui/LICENSE-GPUI-BASE b/crates/rake-ui/LICENSE-GPUI-BASE new file mode 100644 index 00000000..1e9e81e7 --- /dev/null +++ b/crates/rake-ui/LICENSE-GPUI-BASE @@ -0,0 +1,191 @@ +Copyright 2024 - 2026 Longbridge + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/crates/rake-ui/src/view.rs b/crates/rake-ui/src/view.rs index 7a05ac11..daa4a033 100644 --- a/crates/rake-ui/src/view.rs +++ b/crates/rake-ui/src/view.rs @@ -3,6 +3,7 @@ mod button; mod link; mod paragraph; +mod selectable_text; pub use link::{HrefKind, classify_href, install_link_router}; diff --git a/crates/rake-ui/src/view/paragraph/interactive.rs b/crates/rake-ui/src/view/paragraph/interactive.rs index a2ed7cdd..28cf6f97 100644 --- a/crates/rake-ui/src/view/paragraph/interactive.rs +++ b/crates/rake-ui/src/view/paragraph/interactive.rs @@ -16,6 +16,7 @@ use std::{ use unicode_segmentation::UnicodeSegmentation; use super::{ParagraphText, layout}; +use crate::view::selectable_text::SelectableText; type LinkInspector = dyn Fn(gpui::Stateful, Option<&FocusHandle>) -> AnyElement; type PointerGesture = Rc, bool)>>>; @@ -104,10 +105,8 @@ impl Frame { let styled = StyledText::new(visible.clone()).with_runs(runs); let text_layout = styled.layout().clone(); - let mut text = gpui_base::SelectableText::new("selection", visible.clone()) - .styled(styled) - .selectable(paragraph.selectable) - .into_any_element(); + let mut text = + SelectableText::new(visible.clone(), styled, paragraph.selectable).into_any_element(); text.layout_as_root(bounds.size.map(gpui::AvailableSpace::Definite), window, cx); text.prepaint_at(bounds.origin, window, cx); diff --git a/crates/rake-ui/src/view/paragraph/tests.rs b/crates/rake-ui/src/view/paragraph/tests.rs index 5304a297..860c41f4 100644 --- a/crates/rake-ui/src/view/paragraph/tests.rs +++ b/crates/rake-ui/src/view/paragraph/tests.rs @@ -318,10 +318,10 @@ mod selection_frames { "ctrl-c" }); cx.update(|_, cx| { - assert_eq!( - cx.read_from_clipboard().and_then(|item| item.text()), - Some(" alpha link omega ".into()) - ) + let copied = cx.read_from_clipboard().and_then(|item| item.text()); + + // Stock and workspace Base roots differ in their whitespace policy. + assert_eq!(copied.as_deref().map(str::trim), Some("alpha link omega")); }); } diff --git a/crates/rake-ui/src/view/selectable_text.rs b/crates/rake-ui/src/view/selectable_text.rs new file mode 100644 index 00000000..1928856c --- /dev/null +++ b/crates/rake-ui/src/view/selectable_text.rs @@ -0,0 +1,265 @@ +// Copyright 2024 - 2026 Longbridge +// SPDX-License-Identifier: Apache-2.0 +// Adapted from longbridge/gpui-kit crates/base (gpui-base 0.9.0). +// Rake accepts pre-styled runs and makes selection registration optional. +// The selection engine stays in Base. See LICENSE-GPUI-BASE. + +use std::ops::Range; + +use gpui::{ + App, BorderStyle, Bounds, Corners, Edges, Element, ElementId, GlobalElementId, HitboxBehavior, + Hsla, InspectorElementId, IntoElement, LayoutId, PaintQuad, Pixels, Point, SharedString, + StyledText, Window, transparent_black, +}; + +use gpui_base::{TextSelectionHandle, TextSelectionRegistration, TextSelectionRun}; + +pub(super) struct SelectableText { + text: SharedString, + styled_text: StyledText, + selectable: bool, +} + +impl SelectableText { + pub(super) fn new(text: SharedString, styled_text: StyledText, selectable: bool) -> Self { + Self { + text, + styled_text, + selectable, + } + } + + fn paint_selection( + layout: &gpui::TextLayout, + range: Range, + color: Hsla, + window: &mut Window, + ) { + let (Some(start), Some(end)) = ( + layout.position_for_index(range.start), + layout.position_for_index(range.end), + ) else { + return; + }; + + for bounds in selection_quad_bounds(start, end, layout.bounds(), layout.line_height()) { + window.paint_quad(PaintQuad { + bounds, + background: color.into(), + corner_radii: Corners::default(), + border_widths: Edges::default(), + border_color: transparent_black(), + border_style: BorderStyle::default(), + }); + } + } +} + +fn selection_quad_bounds( + start: Point, + end: Point, + bounds: Bounds, + line_height: Pixels, +) -> Vec> { + if start.y == end.y { + return vec![Bounds::from_corners( + start, + Point::new(end.x, end.y + line_height), + )]; + } + + let mut quads = vec![Bounds::from_corners( + start, + Point::new(bounds.right(), start.y + line_height), + )]; + + if end.y > start.y + line_height { + quads.push(Bounds::from_corners( + Point::new(bounds.left(), start.y + line_height), + Point::new(bounds.right(), end.y), + )); + } + + quads.push(Bounds::from_corners( + Point::new(bounds.left(), end.y), + Point::new(end.x, end.y + line_height), + )); + + quads +} + +impl IntoElement for SelectableText { + type Element = Self; + + fn into_element(self) -> Self::Element { + self + } +} + +impl Element for SelectableText { + type RequestLayoutState = Option; + type PrepaintState = (); + + fn id(&self) -> Option { + Some("selection".into()) + } + + fn source_location(&self) -> Option<&'static std::panic::Location<'static>> { + None + } + + fn request_layout( + &mut self, + global_id: Option<&GlobalElementId>, + inspector_id: Option<&InspectorElementId>, + window: &mut Window, + cx: &mut App, + ) -> (LayoutId, Self::RequestLayoutState) { + let selection = self.selectable.then(|| { + window.with_element_state( + global_id.expect("selectable paragraph must have a stable element id"), + |retained: Option, _| { + let handle = + retained.unwrap_or_else(|| TextSelectionHandle::new(self.text.clone(), cx)); + + (handle.clone(), handle) + }, + ) + }); + + let (layout_id, ()) = self + .styled_text + .request_layout(global_id, inspector_id, window, cx); + + (layout_id, selection) + } + + fn prepaint( + &mut self, + global_id: Option<&GlobalElementId>, + inspector_id: Option<&InspectorElementId>, + bounds: Bounds, + selection: &mut Self::RequestLayoutState, + window: &mut Window, + cx: &mut App, + ) { + self.styled_text + .prepaint(global_id, inspector_id, bounds, &mut (), window, cx); + + if let Some(handle) = selection { + let hitbox = window.insert_hitbox(bounds, HitboxBehavior::Normal); + + let registration = TextSelectionRegistration::new(hitbox, bounds) + .with_text_bounds(vec![bounds]) + .with_rendered_element(handle, window, cx); + + handle.register(registration, window, cx); + } + } + + fn paint( + &mut self, + global_id: Option<&GlobalElementId>, + inspector_id: Option<&InspectorElementId>, + bounds: Bounds, + selection: &mut Self::RequestLayoutState, + _: &mut Self::PrepaintState, + window: &mut Window, + cx: &mut App, + ) { + if let Some(handle) = selection { + let layout = self.styled_text.layout(); + + let projection = handle.update_runs( + &[TextSelectionRun::new( + self.text.clone(), + layout.clone(), + bounds, + )], + cx, + ); + + // Base caches the copy text while projecting the run. + if let Some(Some(range)) = projection.ranges().first() { + let color = gpui_base::Theme::global(cx).tokens.colors.selection; + + Self::paint_selection(layout, range.clone(), color, window); + } + } + + self.styled_text.paint( + global_id, + inspector_id, + bounds, + &mut (), + &mut (), + window, + cx, + ); + } +} + +#[cfg(all(test, feature = "test-support", not(target_family = "wasm")))] +mod tests { + use gpui::{ + Context, InteractiveElement as _, IntoElement, Modifiers, MouseButton, ParentElement as _, + Render, SharedString, Styled as _, StyledText, TestAppContext, Window, div, point, px, + }; + + use gpui_base::{TextSelection, TextSelectionLayer}; + + use super::SelectableText; + + struct MixedSelection; + + impl Render for MixedSelection { + fn render(&mut self, _: &mut Window, _: &mut Context) -> impl IntoElement { + let text = |value, selectable| { + let value = SharedString::from(value); + let styled = StyledText::new(value.clone()); + + SelectableText::new(value, styled, selectable) + }; + + div().size_full().child(TextSelectionLayer).child( + div() + .flex() + .flex_col() + .w(px(240.)) + .line_height(px(20.)) + .child(text("Rake", true)) + .child(div().id("excluded").child(text("Excluded", false))) + .child(gpui_base::SelectableText::new("base", "Base")), + ) + } + } + + #[test] + fn rake_and_base_share_window_selection() { + let mut cx = TestAppContext::single(); + + let (_, cx) = cx.add_window_view(|_, cx| { + crate::init(cx); + + MixedSelection + }); + + cx.update(|window, cx| window.draw(cx).clear(cx)); + let start = point(px(1.), px(8.)); + let end = point(px(200.), px(45.)); + + cx.simulate_mouse_move(start, None, Modifiers::default()); + cx.simulate_mouse_down(start, MouseButton::Left, Modifiers::default()); + cx.simulate_mouse_move(end, Some(MouseButton::Left), Modifiers::default()); + cx.simulate_mouse_up(end, MouseButton::Left, Modifiers::default()); + + cx.update(|window, cx| { + window.draw(cx).clear(cx); + let selected = TextSelection::selected_text(window, cx); + let mut runs: Vec<_> = selected.lines().collect(); + + runs.sort_unstable(); + assert_eq!(runs, ["Base", "Rake"]); + }); + } +} diff --git a/crates/rake-view-syntax/Cargo.toml b/crates/rake-view-syntax/Cargo.toml index 981c2633..4af52e9f 100644 --- a/crates/rake-view-syntax/Cargo.toml +++ b/crates/rake-view-syntax/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-view-syntax" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/crates/rake/Cargo.toml b/crates/rake/Cargo.toml index 2cd9b4b3..deffb714 100644 --- a/crates/rake/Cargo.toml +++ b/crates/rake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rake-app" -version = "0.1.0-alpha.5" +version = "0.1.0-alpha.6" edition.workspace = true rust-version.workspace = true license.workspace = true @@ -52,7 +52,7 @@ icu_provider = { version = "2.4", features = ["sync"], optional = true } icu_provider_blob = { version = "2.4", optional = true } writeable = { version = "0.6", optional = true } zeroize = "1" -rake-shortcuts = { version = "=0.1.0-alpha.4", path = "../rake-shortcuts", optional = true } +rake-shortcuts = { version = "=0.1.0-alpha.5", path = "../rake-shortcuts", optional = true } image = { version = "0.25.10", default-features = false, features = ["png"] } rake-autostart = { version = "=0.1.0-alpha.4", path = "../rake-autostart", optional = true } rake-tray = { version = "=0.1.0-alpha.4", path = "../rake-tray", optional = true } @@ -62,7 +62,7 @@ rake-ui = { workspace = true, optional = true } rake-native = { workspace = true, optional = true } rake-http = { workspace = true, features = ["task-errors"] } rake-protocol.workspace = true -rake-macros = { version = "=0.1.0-alpha.4", path = "../rake-macros" } +rake-macros = { version = "=0.1.0-alpha.5", path = "../rake-macros" } rake-diagnostics.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/docs/development.md b/docs/development.md index 45518b50..7bb3929e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -241,9 +241,8 @@ of that exact published archive offline: BLAZE_ARCHIVE=/absolute/path/to/blaze-v0.20261030.1-rake.3-aarch64-apple-darwin.tar.gz rake dev --live --bin rake-view ``` -CLI `0.1.0-alpha.6` embeds rake.3; published CLI alpha.5 retains rake.2. -Upgrade the installed CLI to receive the compiler fix. Updating an app's SDK -alone does not change the compiler pin. +CLI `0.1.0-alpha.7` uses the Blaze rake.3 pin introduced in CLI alpha.6. +The compiler pin is part of the installed CLI. `BLAZE_ARCHIVE` supplies bytes, not a checksum bypass. `RAKE_BLAZE=/absolute/path/to/blaze` is an explicit developer override; it requires the patched diff --git a/docs/experimental-view.md b/docs/experimental-view.md index 575c1c60..5910a0c6 100644 --- a/docs/experimental-view.md +++ b/docs/experimental-view.md @@ -1,6 +1,6 @@ # Experimental function components -Enable `experimental-reactive` on a local `rake-app` dependency to use +Enable `experimental-reactive` on a `rake-app` dependency to use `#[rake::component]` and `rake::reactive`. This source-checkout prototype follows [issue #27](https://github.com/1bye/rake/issues/27)'s signals redesign. It replaces the earlier `experimental-components` hooks API and is not enabled by default. diff --git a/docs/getting-started.md b/docs/getting-started.md index 749e49bb..0bd068fe 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -13,7 +13,7 @@ This takes you from nothing to a running app, then adds the CLI, the browser and Install the CLI, then scaffold an app: ```sh -cargo install rake-app-cli --version 0.1.0-alpha.6 --locked +cargo install rake-app-cli --version 0.1.0-alpha.7 --locked rake new my-app cd my-app rake dev @@ -32,7 +32,7 @@ first `rake dev` or `rake build` resolves dependencies and creates `Cargo.lock`; commit it. Subsequent builds use `--locked`. The installed CLI pins the generated project to its tested `rake-app` SDK release, -which can differ from the CLI version. CLI alpha.6 uses SDK alpha.5. A CLI built +which can differ from the CLI version. CLI alpha.7 uses SDK alpha.6. A CLI built from a checkout pins that checkout revision instead. Pass `--rake-rev REV` to use a full Git commit hash from a revision with the `rake-app` package name. @@ -46,7 +46,7 @@ rake new my-app --rake-path /absolute/path/to/rake/crates/rake --git The path is stored absolutely, so moving the generated app doesn't silently change its dependency. Its README explains where to change the application ID. -For an existing crate, run `cargo add rake-app@0.1.0-alpha.5 --rename rake` and follow the [README Hello example](../README.md#quick-start). +For an existing crate, run `cargo add rake-app@0.1.0-alpha.6 --rename rake` and follow the [README Hello example](../README.md#quick-start). Use the helper versions supported by that SDK when upgrading an existing app; CLI, SDK and supporting-crate version numbers can differ. diff --git a/vendor/gpui-base/RAKE-PATCH.md b/vendor/gpui-base/RAKE-PATCH.md index ea8dcf79..08774246 100644 --- a/vendor/gpui-base/RAKE-PATCH.md +++ b/vendor/gpui-base/RAKE-PATCH.md @@ -11,15 +11,12 @@ Remove the Cargo patch once the pinned upstream release supports these behaviors ## Issue 87: styled selectable paragraphs -`SelectableText::styled` accepts the facade’s styled text and `selectable` allows the same layout for nonselectable links. Selection gestures, projection, copy, and theme selection color remain Base-owned. - -Root copy preserves selected leading/trailing whitespace instead of trimming the visible text. - -Web also binds Command-C alongside Control-C, since the Wasm target’s OS is not the browser host OS. - -The workspace dependency also names this directory directly so external path and Git consumers retain the selection APIs; Cargo does not inherit dependency-root patches. - -**Release hold:** rake-ui must not be published until gpui-base ships these APIs -and Rake upgrades to that release. Publishing drops the workspace path and uses -the crates.io version of gpui-base, which currently lacks both methods. -Re-enable publishing in `crates/rake-ui/Cargo.toml` after the upgrade. +Rake's styled selectable element lives in `crates/rake-ui`. It uses the public +Base 0.9.0 selection registration and projection APIs, sharing the window's +selection state with Base text. The workspace patch retains the original +`SelectableText::styled` and `selectable` methods for local Base users. + +The patched Root preserves selected leading and trailing whitespace on copy +and adds Command-C alongside Control-C on Web. Published Rake packages resolve +stock Base 0.9.0, whose Root trims the copied selection and binds only Control-C +on Web.