Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and LLVM for code generation.

**Current Version:** 0.5.419
**Current Version:** 0.5.420


## TypeScript Parity Status
Expand Down Expand Up @@ -150,6 +150,7 @@ First-resolved directory cached in `compile_package_dirs`; subsequent imports re

Keep entries to 1-2 lines max. Full details in CHANGELOG.md.

- **v0.5.420** — Phase 2 v3.3 iOS / tvOS / visionOS (PR #327): UIKit ports of the macOS toast + setText pattern from v0.5.419. Each platform gets `widgets/toast.rs` (UIView overlay added to the key UIWindow's root view; alpha-fade in 0.25s + hold 2.5s + fade-out 0.25s; FIFO queue) and `widgets/text_registry.rs` (id→handle map calling existing `widgets::text::set_text_str`). All three platforms share the macOS implementation shape via direct port.
- **v0.5.419** — Phase 2 v3.3 (PR #326): cross-platform showToast + setText, with macOS as the first non-HarmonyOS backend. New `crates/perry-runtime/src/ui_text_registry.rs` module provides always-compiled stubs of `perry_arkts_show_toast` / `perry_arkts_set_text` / `perry_arkts_register_text_id` gated `#[cfg(not(feature = "ohos-napi"))]` so harmonyos keeps its drain-queue impl with zero symbol collision; plus 3 handler-registration FFIs and pending-call buffering so calls during widget construction are replayed when `app_run` registers handlers. macOS impl: `crates/perry-ui-macos/src/widgets/toast.rs` (~280 LOC NSPanel-backed presenter, alpha-fade in/hold/out via NSTimer, FIFO queue) + `crates/perry-ui-macos/src/widgets/text_registry.rs` (~80 LOC id→handle map calling existing `widgets::text::set_text_str`). New codegen arm in `crates/perry-codegen/src/lower_call/native.rs` for `Text(content, id)` before PERRY_UI_TABLE dispatch fixed a pre-existing bug where the trailing string was absorbed as inline_style_arg and silently dropped. iOS / GTK4 / Windows / Android / tvOS / visionOS / watchOS link cleanly via runtime stubs but no-op visibly until each platform's UI crate registers handlers — focused follow-ups using the macOS files as template.
- **v0.5.418** — HarmonyOS Phase 2 v4 (PR #325): 6 new widgets in `perry-codegen-arkts` — `Image`/`ImageFile` (single Image emit_helper registered for both names), `ScrollView` (ArkUI `Scroll() { Column() { children } }`), `LazyVStack` (eagerly emits Column with deferral comment for true LazyForEach in v5), `Picker` (TextPicker with `(value, index)` onChange forwarding to `invokeCallback1` via the v2.5 pipeline), `ProgressView` (ArkUI Progress, type Linear), `Section` (labeled vertical group with smaller-font header). Stack-bearing widgets thread `&mut callbacks` + `&mut text_slots` through `emit_widget` so reactive Text and nested closures compose transparently. `Section(title, children)` TS overload added in `types/perry/ui/index.d.ts`. 31/31 perry-codegen-arkts unit tests pass (was 23 + 8 new). The pre-existing `unsupported_widget_degrades_with_comment_not_error` test now uses `Canvas` as the example unsupported widget since Picker is now supported.
- **v0.5.417** — HarmonyOS Phase 2 v2 + v3 + v2.5 (PR #322 squash-merged): Button onClick callback bridge via NAPI invokeCallback + closure registry; `showToast(msg)` drain queue → ArkUI `promptAction.showToast`; reactive `Text("0", "id")` + `setText(id, val)` via @State binding generated in the harvested Index.ets; multi-arg callbacks for Toggle / TextField / Slider via `invokeCallback1` with NAPI typeof dispatch (boolean / string / number → NaN-box → `js_closure_call1`). End-to-end verified on Pura 90 Pro Max emulator: a 5-widget interactive page (counter + reset, TextField echoing input, Toggle flipping notification state + showing toast, Slider tracking volume) reactively updates the screen on every interaction. Bridge architecture: `crates/perry-runtime/src/arkts_callbacks.rs` holds slot tables + drain queues + GC root scanner; `crates/perry-runtime/src/ohos_napi.rs` exports `run` / `invokeCallback` / `invokeCallback1` / `drainToast` / `drainTextUpdate`; `crates/perry-codegen-arkts/src/lib.rs::HarvestResult` returns ets_source + closure callbacks; `crates/perry/src/commands/compile.rs` harvest pass injects registration calls + auto-emits `cpp/types/libentry/Index.d.ts` for ArkTS type-checking. Module-scoped `println!` override in `builtins.rs` routes `console.log` from stdout to hilog tag `perry`. 23/23 perry-codegen-arkts unit tests pass.
Expand Down
60 changes: 30 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ opt-level = "s" # Optimize for size in stdlib
opt-level = 3

[workspace.package]
version = "0.5.419"
version = "0.5.420"
edition = "2021"
license = "MIT"
repository = "https://github.com/PerryTS/perry"
Expand Down
33 changes: 33 additions & 0 deletions crates/perry-ui-ios/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ pub fn app_run(_app_handle: i64) {
// Install crash reporting hooks before anything else
crate::crash_log::install_crash_hooks();

// Phase 2 v3.3: register cross-platform showToast / setText handlers
// so `showToast("…")` and `setText(id, val)` produce visible UI on iOS.
register_cross_platform_text_handlers();

// Force PerryAppDelegate class registration (define_class! registers it lazily)
let _ = PerryAppDelegate::class();

Expand Down Expand Up @@ -879,3 +883,32 @@ pub fn set_timer(interval_ms: f64, callback: f64) {
std::mem::forget(target);
}
}

// =============================================================================
// Cross-platform showToast / setText handler registration (Phase 2 v3.3)
// =============================================================================

extern "C" {
fn js_register_show_toast_handler(
f: extern "C" fn(msg_ptr: *const u8, msg_len: usize),
);
fn js_register_set_text_handler(
f: extern "C" fn(
id_ptr: *const u8,
id_len: usize,
val_ptr: *const u8,
val_len: usize,
),
);
fn js_register_text_id_handler(
f: extern "C" fn(widget_handle: i64, id_ptr: *const u8, id_len: usize),
);
}

fn register_cross_platform_text_handlers() {
unsafe {
js_register_show_toast_handler(widgets::toast::show_toast_handler);
js_register_set_text_handler(widgets::text_registry::set_text_handler);
js_register_text_id_handler(widgets::text_registry::register_text_id_handler);
}
}
2 changes: 2 additions & 0 deletions crates/perry-ui-ios/src/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ pub mod spacer;
pub mod splitview;
pub mod tabbar;
pub mod text;
pub mod text_registry;
pub mod textarea;
pub mod textfield;
pub mod toast;
pub mod toggle;
pub mod vstack;
pub mod zstack;
Expand Down
Loading
Loading