@native-sdk/cli 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.zig +8 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/text.ts +62 -21
- package/skill-data/native-ui/SKILL.md +17 -2
- package/src/platform/macos/appkit_host.h +2 -0
- package/src/platform/macos/appkit_host.m +36 -10
- package/src/platform/macos/root.zig +7 -1
- package/src/platform/types.zig +2 -0
- package/src/primitives/canvas/code.zig +590 -0
- package/src/primitives/canvas/code_tests.zig +1062 -0
- package/src/primitives/canvas/equality.zig +3 -1
- package/src/primitives/canvas/events.zig +4 -0
- package/src/primitives/canvas/layout_audit.zig +3 -1
- package/src/primitives/canvas/markdown.zig +13 -11
- package/src/primitives/canvas/markdown_tests.zig +167 -4
- package/src/primitives/canvas/root.zig +15 -2
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text.zig +10 -0
- package/src/primitives/canvas/text_interaction.zig +164 -22
- package/src/primitives/canvas/text_layout.zig +107 -21
- package/src/primitives/canvas/text_measure_cache.zig +4 -4
- package/src/primitives/canvas/text_span_tests.zig +254 -0
- package/src/primitives/canvas/text_spans.zig +556 -32
- package/src/primitives/canvas/text_tests.zig +86 -0
- package/src/primitives/canvas/themes/geist.zig +29 -0
- package/src/primitives/canvas/tokens.zig +72 -2
- package/src/primitives/canvas/ui.zig +325 -21
- package/src/primitives/canvas/ui_markup.zig +59 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +76 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +33 -0
- package/src/primitives/canvas/ui_markup_contract.zig +34 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +20 -3
- package/src/primitives/canvas/ui_markup_view.zig +73 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +101 -0
- package/src/primitives/canvas/ui_schema.zig +17 -6
- package/src/primitives/canvas/ui_schema_tests.zig +7 -6
- package/src/primitives/canvas/ui_tests.zig +6 -0
- package/src/primitives/canvas/widget_invalidation.zig +3 -0
- package/src/primitives/canvas/widget_layout.zig +57 -8
- package/src/primitives/canvas/widget_layout_tests.zig +35 -0
- package/src/primitives/canvas/widget_metrics.zig +30 -1
- package/src/primitives/canvas/widget_render.zig +454 -9
- package/src/primitives/canvas/widget_runtime.zig +1 -0
- package/src/primitives/canvas/widget_text_input.zig +23 -11
- package/src/primitives/canvas/widget_text_select.zig +2 -2
- package/src/primitives/canvas/widgets.zig +13 -0
- package/src/root.zig +1 -0
- package/src/runtime/api.zig +9 -0
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_limits.zig +7 -0
- package/src/runtime/canvas_widget_accessibility_tests.zig +27 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +146 -0
- package/src/runtime/canvas_widget_context_menu.zig +12 -2
- package/src/runtime/canvas_widget_display.zig +15 -1
- package/src/runtime/canvas_widget_events.zig +50 -20
- package/src/runtime/canvas_widget_runtime.zig +74 -12
- package/src/runtime/canvas_widget_state.zig +1 -0
- package/src/runtime/canvas_widget_text_tests.zig +1935 -70
- package/src/runtime/gpu_surface_events.zig +38 -0
- package/src/runtime/view.zig +37 -3
- package/src/runtime/view_widget_text.zig +1242 -14
- package/src/runtime/view_widget_tree.zig +2 -0
|
@@ -637,6 +637,44 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
637
637
|
if (widget_keyboard_event) |keyboard_event| {
|
|
638
638
|
try CanvasWidgetEventMethods().dispatchCanvasWidgetCommandFromKeyboard(self, app, keyboard_event);
|
|
639
639
|
try self.dispatchEvent(app, .{ .canvas_widget_keyboard = keyboard_event });
|
|
640
|
+
// A logical undo/redo can require select -> replace ->
|
|
641
|
+
// restore-selection. Apply and dispatch each continuation
|
|
642
|
+
// only after the previous on-input Msg rebuilt the
|
|
643
|
+
// controlled tree, keeping runtime and model lockstep at
|
|
644
|
+
// every intermediate state. These synthetic edit carriers
|
|
645
|
+
// are key_down-shaped (not committed text), so a target
|
|
646
|
+
// removed, hidden, or replaced with another editor kind by
|
|
647
|
+
// the rebuild can never receive stale replacement bytes.
|
|
648
|
+
// The route and focus-target snapshot are tree-relative too:
|
|
649
|
+
// re-resolve both after every rebuild so custom event
|
|
650
|
+
// consumers never observe ancestors, indices, bounds, or
|
|
651
|
+
// state from the tree that handled the previous step.
|
|
652
|
+
for (0..2) |_| {
|
|
653
|
+
if (keyboard_event.history_replay_serial == 0) break;
|
|
654
|
+
const view_index = runtimeFindViewIndex(self, keyboard_event.window_id, keyboard_event.view_label) orelse break;
|
|
655
|
+
const target = keyboard_event.target orelse break;
|
|
656
|
+
if (self.views[view_index].kind != .gpu_surface) break;
|
|
657
|
+
const edit = self.views[view_index].canvasWidgetTextHistoryReplayNext(
|
|
658
|
+
target,
|
|
659
|
+
keyboard_event.history_replay_serial,
|
|
660
|
+
keyboard_event.history_replay_redo,
|
|
661
|
+
) orelse break;
|
|
662
|
+
var followup = keyboard_event;
|
|
663
|
+
followup.keyboard = .{
|
|
664
|
+
.phase = .key_down,
|
|
665
|
+
.focused_id = keyboard_event.keyboard.focused_id,
|
|
666
|
+
.edit = edit,
|
|
667
|
+
};
|
|
668
|
+
const route = try self.views[view_index].widgetLayoutTree().routeKeyboardEvent(
|
|
669
|
+
followup.keyboard,
|
|
670
|
+
&self.widget_event_route_entries,
|
|
671
|
+
);
|
|
672
|
+
followup.target = route.target orelse break;
|
|
673
|
+
followup.route = route.entries;
|
|
674
|
+
followup.history_replay = true;
|
|
675
|
+
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromKeyboard(self, &followup);
|
|
676
|
+
try self.dispatchEvent(app, .{ .canvas_widget_keyboard = followup });
|
|
677
|
+
}
|
|
640
678
|
} else if ((input_event.kind == .key_down or input_event.kind == .key_up) and
|
|
641
679
|
!widget_surface_dismissed and !terminal_key_lifetime_suppressed)
|
|
642
680
|
{
|
package/src/runtime/view.zig
CHANGED
|
@@ -31,6 +31,8 @@ const max_canvas_widget_nodes_per_view = canvas_limits.max_canvas_widget_nodes_p
|
|
|
31
31
|
const max_canvas_widget_semantics_per_view = canvas_limits.max_canvas_widget_semantics_per_view;
|
|
32
32
|
const max_canvas_widget_text_bytes_per_view = canvas_limits.max_canvas_widget_text_bytes_per_view;
|
|
33
33
|
const max_canvas_widget_source_text_entries_per_view = canvas_limits.max_canvas_widget_source_text_entries_per_view;
|
|
34
|
+
const max_canvas_widget_text_history_bytes_per_view = canvas_limits.max_canvas_widget_text_history_bytes_per_view;
|
|
35
|
+
const max_canvas_widget_text_history_entries_per_view = canvas_limits.max_canvas_widget_text_history_entries_per_view;
|
|
34
36
|
|
|
35
37
|
const CanvasWidgetSourceTextEntry = canvas_widget_runtime.CanvasWidgetSourceTextEntry;
|
|
36
38
|
const CanvasWidgetSourceScrollEntry = canvas_widget_runtime.CanvasWidgetSourceScrollEntry;
|
|
@@ -686,10 +688,14 @@ pub const RuntimeView = struct {
|
|
|
686
688
|
/// updateCanvasWidgetInteractionFromPointer), so a pointer gliding
|
|
687
689
|
/// within one sample repaints nothing.
|
|
688
690
|
canvas_widget_hover_point: ?geometry.PointF = null,
|
|
689
|
-
/// The static `.text` widget
|
|
690
|
-
/// selection (0 = none).
|
|
691
|
-
///
|
|
691
|
+
/// The static `.text` widget where the view's active click-drag
|
|
692
|
+
/// selection began (0 = none). Ordinary paragraphs keep their range
|
|
693
|
+
/// on that widget. Bounded code paragraphs additionally share the
|
|
694
|
+
/// global group range below so one gesture can cross internal chunks.
|
|
692
695
|
canvas_widget_selected_text_id: canvas.ObjectId = 0,
|
|
696
|
+
canvas_widget_selected_text_group_id: canvas.ObjectId = 0,
|
|
697
|
+
canvas_widget_selected_text_group_anchor: usize = 0,
|
|
698
|
+
canvas_widget_selected_text_group_focus: usize = 0,
|
|
693
699
|
/// Multi-click chain state for the double/triple-click text
|
|
694
700
|
/// gestures. The runtime derives a click count from consecutive
|
|
695
701
|
/// primary pointer-downs (recorded timestamps within the interval,
|
|
@@ -750,10 +756,38 @@ pub const RuntimeView = struct {
|
|
|
750
756
|
accessibility_label_storage: [platform.max_view_accessibility_label_bytes]u8 = undefined,
|
|
751
757
|
text_storage: [platform.max_view_text_bytes]u8 = undefined,
|
|
752
758
|
command_storage: [platform.max_view_command_bytes]u8 = undefined,
|
|
759
|
+
/// Per-view, per-widget undo/redo deltas. Kept at the tail so adding
|
|
760
|
+
/// editor history does not move the established hot render/layout
|
|
761
|
+
/// fields inside RuntimeView. Text bytes are shared across entries, so
|
|
762
|
+
/// ordinary typing costs one byte per step rather than a full document
|
|
763
|
+
/// snapshot.
|
|
764
|
+
canvas_widget_text_history_entries: [max_canvas_widget_text_history_entries_per_view]view_widget_text.CanvasWidgetTextHistoryEntry = undefined,
|
|
765
|
+
canvas_widget_text_history_entry_count: usize = 0,
|
|
766
|
+
canvas_widget_text_history_bytes: [max_canvas_widget_text_history_bytes_per_view]u8 = undefined,
|
|
767
|
+
canvas_widget_text_history_byte_count: usize = 0,
|
|
768
|
+
canvas_widget_text_history_next_serial: u64 = 1,
|
|
769
|
+
/// Native textarea Up/Down retains its painted x coordinate while a
|
|
770
|
+
/// consecutive vertical-navigation run crosses shorter visual lines.
|
|
771
|
+
canvas_widget_text_vertical_goal_id: canvas.ObjectId = 0,
|
|
772
|
+
/// Preferred x in widget-local coordinates, so moving a textarea does
|
|
773
|
+
/// not move the logical column with respect to its text container.
|
|
774
|
+
canvas_widget_text_vertical_goal_x: f32 = 0,
|
|
775
|
+
canvas_widget_text_vertical_goal_text_len: usize = 0,
|
|
776
|
+
canvas_widget_text_vertical_goal_text_hash: u64 = 0,
|
|
777
|
+
canvas_widget_text_vertical_goal_focus: usize = 0,
|
|
778
|
+
canvas_widget_text_vertical_goal_affinity: canvas.TextCaretAffinity = .upstream,
|
|
779
|
+
canvas_widget_text_vertical_goal_frame: geometry.RectF = .{},
|
|
753
780
|
|
|
754
781
|
const CanvasWidgetTextMethods = view_widget_text.RuntimeViewCanvasWidgetText(RuntimeView);
|
|
755
782
|
pub const applyCanvasWidgetTextEdit = CanvasWidgetTextMethods.applyCanvasWidgetTextEdit;
|
|
783
|
+
pub const applyCanvasWidgetTextEditWithoutHistory = CanvasWidgetTextMethods.applyCanvasWidgetTextEditWithoutHistory;
|
|
756
784
|
pub const canvasWidgetKeyboardTextEdit = CanvasWidgetTextMethods.canvasWidgetKeyboardTextEdit;
|
|
785
|
+
pub const canvasWidgetTextHistoryShortcut = CanvasWidgetTextMethods.canvasWidgetTextHistoryShortcut;
|
|
786
|
+
pub const canvasWidgetTextHistoryAvailability = CanvasWidgetTextMethods.canvasWidgetTextHistoryAvailability;
|
|
787
|
+
pub const canvasWidgetTextHistoryReplayNext = CanvasWidgetTextMethods.canvasWidgetTextHistoryReplayNext;
|
|
788
|
+
pub const commitCanvasWidgetTextHistoryReplayIfComplete = CanvasWidgetTextMethods.commitCanvasWidgetTextHistoryReplayIfComplete;
|
|
789
|
+
pub const pruneCanvasWidgetTextHistory = CanvasWidgetTextMethods.pruneCanvasWidgetTextHistory;
|
|
790
|
+
pub const clearCanvasWidgetTextVerticalGoal = CanvasWidgetTextMethods.clearCanvasWidgetTextVerticalGoal;
|
|
757
791
|
pub const canEditCanvasWidgetText = CanvasWidgetTextMethods.canEditCanvasWidgetText;
|
|
758
792
|
pub const applyCanvasWidgetTextPointer = CanvasWidgetTextMethods.applyCanvasWidgetTextPointer;
|
|
759
793
|
pub const clearCanvasWidgetStaticTextSelection = CanvasWidgetTextMethods.clearCanvasWidgetStaticTextSelection;
|