@native-sdk/cli 0.5.0 → 0.5.2
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/app.zig +198 -13
- package/build/ts_run.mjs +58 -19
- package/build.zig +42 -0
- package/package.json +13 -9
- package/packages/core/package-lock.json +4 -3
- package/packages/core/package.json +3 -2
- package/packages/core/src/typed_ast.ts +11 -1
- package/skill-data/native-ui/SKILL.md +2 -2
- package/src/platform/types.zig +9 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/tokens.zig +185 -7
- package/src/primitives/canvas/ui.zig +27 -5
- package/src/primitives/canvas/ui_markup.zig +27 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +47 -0
- package/src/primitives/canvas/ui_markup_view.zig +10 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +78 -0
- package/src/primitives/canvas/ui_schema.zig +15 -1
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +439 -5
- package/src/primitives/canvas/widget_layout.zig +142 -3
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +12 -0
- package/src/runtime/automation_widget_dispatch.zig +95 -28
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_events.zig +1271 -3
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +82 -5
- package/src/runtime/core.zig +30 -0
- package/src/runtime/effects.zig +1037 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/flow.zig +24 -1
- package/src/runtime/gpu_surface_events.zig +44 -5
- package/src/runtime/session_journal.zig +25 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +453 -0
- package/src/runtime/ui_app.zig +137 -39
- package/src/runtime/ui_app_tests.zig +681 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view.zig +86 -0
- package/src/runtime/view_widget_text.zig +18 -1
- package/src/runtime/view_widget_tree.zig +339 -20
- package/src/runtime/widget_bridge.zig +26 -0
- package/src/runtime/window_storage.zig +61 -15
- package/src/runtime/window_view_runtime.zig +13 -0
- package/src/runtime/window_views.zig +6 -0
- package/src/tooling/package.zig +311 -8
- package/src/tooling/templates.zig +97 -9
- package/src/tooling/ts_core.zig +626 -13
- package/src/tooling/verbs.zig +88 -2
|
@@ -132,80 +132,89 @@ fn pickerOptions() PickerApp.Options {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
.
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
135
|
+
/// The TEA harness shape every anchored fixture in this file shares,
|
|
136
|
+
/// parameterized over the app so the tooltip-coexistence picker below
|
|
137
|
+
/// reuses the picker's dispatch helpers verbatim.
|
|
138
|
+
fn AppFixture(comptime AppType: type, comptime appOptions: fn () AppType.Options) type {
|
|
139
|
+
return struct {
|
|
140
|
+
harness: *core.TestHarness(),
|
|
141
|
+
app_state: *AppType,
|
|
142
|
+
app: core.App,
|
|
143
|
+
|
|
144
|
+
const Self = @This();
|
|
145
|
+
|
|
146
|
+
fn create() !Self {
|
|
147
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
148
|
+
errdefer harness.destroy(std.testing.allocator);
|
|
149
|
+
harness.null_platform.gpu_surfaces = true;
|
|
150
|
+
const app_state = try AppType.create(std.heap.page_allocator, appOptions());
|
|
151
|
+
const app = app_state.app();
|
|
152
|
+
try harness.start(app);
|
|
153
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
154
|
+
.label = canvas_label,
|
|
155
|
+
.size = geometry.SizeF.init(400, 300),
|
|
156
|
+
.scale_factor = 2,
|
|
157
|
+
.frame_index = 1,
|
|
158
|
+
.timestamp_ns = 1_000_000,
|
|
159
|
+
.nonblank = true,
|
|
160
|
+
} });
|
|
161
|
+
return .{ .harness = harness, .app_state = app_state, .app = app };
|
|
162
|
+
}
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
fn destroy(self: Self) void {
|
|
165
|
+
self.app_state.destroy();
|
|
166
|
+
self.harness.destroy(std.testing.allocator);
|
|
167
|
+
}
|
|
162
168
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
fn widgetIdByText(self: Self, kind: canvas.WidgetKind, text: []const u8) ?canvas.ObjectId {
|
|
170
|
+
return findIn(self.app_state.tree.?.root, kind, text);
|
|
171
|
+
}
|
|
166
172
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
fn findIn(widget: canvas.Widget, kind: canvas.WidgetKind, text: []const u8) ?canvas.ObjectId {
|
|
174
|
+
if (widget.kind == kind and std.mem.eql(u8, widget.text, text)) return widget.id;
|
|
175
|
+
for (widget.children) |child| {
|
|
176
|
+
if (findIn(child, kind, text)) |id| return id;
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
171
179
|
}
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
180
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
fn retainedFrame(self: Self, id: canvas.ObjectId) !?geometry.RectF {
|
|
182
|
+
const layout = try self.harness.runtime.canvasWidgetLayout(1, canvas_label);
|
|
183
|
+
const node = layout.findById(id) orelse return null;
|
|
184
|
+
if (node.widget.semantics.hidden) return null;
|
|
185
|
+
return node.frame;
|
|
186
|
+
}
|
|
181
187
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
fn pointer(self: Self, kind: support.platform.GpuSurfaceInputKind, point: geometry.PointF) !void {
|
|
189
|
+
try self.harness.runtime.dispatchPlatformEvent(self.app, .{ .gpu_surface_input = .{
|
|
190
|
+
.label = canvas_label,
|
|
191
|
+
.kind = kind,
|
|
192
|
+
.x = point.x,
|
|
193
|
+
.y = point.y,
|
|
194
|
+
} });
|
|
195
|
+
}
|
|
190
196
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
fn click(self: Self, point: geometry.PointF) !void {
|
|
198
|
+
try self.pointer(.pointer_down, point);
|
|
199
|
+
try self.pointer(.pointer_up, point);
|
|
200
|
+
}
|
|
195
201
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
fn clickWidget(self: Self, id: canvas.ObjectId) !void {
|
|
203
|
+
const frame = (try self.retainedFrame(id)) orelse return error.TestUnexpectedResult;
|
|
204
|
+
try self.click(frame.center());
|
|
205
|
+
}
|
|
200
206
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
207
|
+
fn key(self: Self, name: []const u8) !void {
|
|
208
|
+
try self.harness.runtime.dispatchPlatformEvent(self.app, .{ .gpu_surface_input = .{
|
|
209
|
+
.label = canvas_label,
|
|
210
|
+
.kind = .key_down,
|
|
211
|
+
.key = name,
|
|
212
|
+
} });
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const Fixture = AppFixture(PickerApp, pickerOptions);
|
|
209
218
|
|
|
210
219
|
test "anchored picker: trigger opens, menu floats, item click picks and closes" {
|
|
211
220
|
const fixture = try Fixture.create();
|
|
@@ -676,3 +685,182 @@ test "the per-view anchored budget rejects a surface per row loudly" {
|
|
|
676
685
|
harness.runtime.setCanvasWidgetLayout(1, "canvas", over_budget),
|
|
677
686
|
);
|
|
678
687
|
}
|
|
688
|
+
|
|
689
|
+
// ------------------------------------------- tooltip + menu coexistence
|
|
690
|
+
//
|
|
691
|
+
// With `<tooltip>` anchorable beside `dropdown-menu`, one trigger stack
|
|
692
|
+
// can float TWO anchored surfaces at once: Tab earns the focus-shown
|
|
693
|
+
// tooltip, ArrowDown opens the menu beneath it. The tests below pin the
|
|
694
|
+
// keymap against that coexistence — the menu-specific lookups must scan
|
|
695
|
+
// FOR menu kinds instead of kind-checking whatever floats topmost, and
|
|
696
|
+
// Escape peels one surface per press, topmost (the tooltip) first.
|
|
697
|
+
|
|
698
|
+
const CoexistModel = struct {
|
|
699
|
+
open: bool = false,
|
|
700
|
+
picked: u32 = 99,
|
|
701
|
+
picks: u32 = 0,
|
|
702
|
+
toggles: u32 = 0,
|
|
703
|
+
dismissals: u32 = 0,
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
const CoexistMsg = union(enum) {
|
|
707
|
+
toggle_picker,
|
|
708
|
+
close_picker,
|
|
709
|
+
pick: u32,
|
|
710
|
+
noop,
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
const CoexistApp = ui_app_model.UiApp(CoexistModel, CoexistMsg);
|
|
714
|
+
|
|
715
|
+
fn coexistUpdate(model: *CoexistModel, msg: CoexistMsg) void {
|
|
716
|
+
switch (msg) {
|
|
717
|
+
.toggle_picker => {
|
|
718
|
+
model.open = !model.open;
|
|
719
|
+
model.toggles += 1;
|
|
720
|
+
},
|
|
721
|
+
.close_picker => {
|
|
722
|
+
model.open = false;
|
|
723
|
+
model.dismissals += 1;
|
|
724
|
+
},
|
|
725
|
+
.pick => |index| {
|
|
726
|
+
model.picked = index;
|
|
727
|
+
model.picks += 1;
|
|
728
|
+
model.open = false;
|
|
729
|
+
},
|
|
730
|
+
.noop => {},
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/// The coexistence stack in the order that shadows: select trigger,
|
|
735
|
+
/// then the anchored dropdown-menu, then the anchored tooltip LAST —
|
|
736
|
+
/// while focus-shown, the tooltip is the topmost anchored child of the
|
|
737
|
+
/// very stack that anchors the open menu. The tooltip carries an
|
|
738
|
+
/// explicit key so its identity survives the open/close rebuilds that
|
|
739
|
+
/// insert and remove the menu ahead of it.
|
|
740
|
+
fn coexistView(ui: *CoexistApp.Ui, model: *const CoexistModel) CoexistApp.Ui.Node {
|
|
741
|
+
const trigger = ui.el(.select, .{ .text = "Repo", .width = 160, .on_press = .toggle_picker }, .{});
|
|
742
|
+
const tooltip = ui.el(.tooltip, .{ .key = .{ .int = 7 }, .text = "Choose the repository", .anchor = .above }, .{});
|
|
743
|
+
const picker = if (model.open) ui.stack(.{ .height = 28 }, .{
|
|
744
|
+
trigger,
|
|
745
|
+
ui.el(.dropdown_menu, .{
|
|
746
|
+
.key = .{ .int = 3 },
|
|
747
|
+
.anchor = .below,
|
|
748
|
+
.anchor_alignment = .stretch,
|
|
749
|
+
.width = 160,
|
|
750
|
+
.height = 90,
|
|
751
|
+
.on_dismiss = .close_picker,
|
|
752
|
+
}, .{
|
|
753
|
+
ui.el(.menu_item, .{ .key = .{ .int = 0 }, .text = "Alpha", .height = 26, .selected = model.picked == 0, .on_press = CoexistMsg{ .pick = 0 } }, .{}),
|
|
754
|
+
ui.el(.menu_item, .{ .key = .{ .int = 1 }, .text = "Beta", .height = 26, .selected = model.picked == 1, .on_press = CoexistMsg{ .pick = 1 } }, .{}),
|
|
755
|
+
}),
|
|
756
|
+
tooltip,
|
|
757
|
+
}) else ui.stack(.{ .height = 28 }, .{ trigger, tooltip });
|
|
758
|
+
|
|
759
|
+
return ui.column(.{ .gap = 8, .padding = 12 }, .{
|
|
760
|
+
picker,
|
|
761
|
+
ui.button(.{ .on_press = .noop }, "After"),
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
fn coexistOptions() CoexistApp.Options {
|
|
766
|
+
return .{
|
|
767
|
+
.name = "ui-app-coexist",
|
|
768
|
+
.scene = picker_scene,
|
|
769
|
+
.canvas_label = canvas_label,
|
|
770
|
+
.update = coexistUpdate,
|
|
771
|
+
.view = coexistView,
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
const CoexistFixture = AppFixture(CoexistApp, coexistOptions);
|
|
776
|
+
|
|
777
|
+
/// Tab onto the select earns the focus-shown tooltip, then ArrowDown
|
|
778
|
+
/// opens the menu beneath it. Returns the trigger id after asserting
|
|
779
|
+
/// the coexistence really holds: menu mounted AND tooltip shown.
|
|
780
|
+
fn coexistOpenWithTooltip(fixture: CoexistFixture) !canvas.ObjectId {
|
|
781
|
+
const trigger_id = fixture.widgetIdByText(.select, "Repo").?;
|
|
782
|
+
try fixture.key("tab");
|
|
783
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focus_visible_id);
|
|
784
|
+
const tooltip_id = fixture.widgetIdByText(.tooltip, "Choose the repository").?;
|
|
785
|
+
try std.testing.expectEqual(tooltip_id, fixture.harness.runtime.views[0].canvas_tooltip_shown_id);
|
|
786
|
+
|
|
787
|
+
// ArrowDown on the closed trigger presses it (the model-owned
|
|
788
|
+
// open); the arrow is no activation key, so the focus-shown
|
|
789
|
+
// tooltip survives the press AND the rebuild that mounts the menu.
|
|
790
|
+
try fixture.key("arrowdown");
|
|
791
|
+
try std.testing.expect(fixture.app_state.model.open);
|
|
792
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.app_state.model.toggles);
|
|
793
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
794
|
+
try std.testing.expectEqual(tooltip_id, fixture.harness.runtime.views[0].canvas_tooltip_shown_id);
|
|
795
|
+
try std.testing.expect((try fixture.retainedFrame(tooltip_id)) != null);
|
|
796
|
+
try std.testing.expect((try fixture.retainedFrame(fixture.widgetIdByText(.menu_item, "Alpha").?)) != null);
|
|
797
|
+
return trigger_id;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
test "tooltip coexistence: arrows walk into the open menu beneath the focus-shown tooltip" {
|
|
801
|
+
const fixture = try CoexistFixture.create();
|
|
802
|
+
defer fixture.destroy();
|
|
803
|
+
|
|
804
|
+
_ = try coexistOpenWithTooltip(fixture);
|
|
805
|
+
|
|
806
|
+
// The next ArrowDown walks INTO the menu — the tooltip floating
|
|
807
|
+
// topmost must not shadow the owned-menu lookup into re-pressing
|
|
808
|
+
// the trigger (which would toggle the picker closed).
|
|
809
|
+
const alpha_id = fixture.widgetIdByText(.menu_item, "Alpha").?;
|
|
810
|
+
try fixture.key("arrowdown");
|
|
811
|
+
try std.testing.expectEqual(alpha_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
812
|
+
try std.testing.expect(fixture.app_state.model.open);
|
|
813
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.app_state.model.toggles);
|
|
814
|
+
|
|
815
|
+
// Entering the menu moved focus off the trigger: the focus-shown
|
|
816
|
+
// tooltip hides through its own blur cause, not through any menu
|
|
817
|
+
// machinery.
|
|
818
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 0), fixture.harness.runtime.views[0].canvas_tooltip_shown_id);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
test "tooltip coexistence: Tab departure closes the menu the tooltip floats over" {
|
|
822
|
+
const fixture = try CoexistFixture.create();
|
|
823
|
+
defer fixture.destroy();
|
|
824
|
+
|
|
825
|
+
const trigger_id = try coexistOpenWithTooltip(fixture);
|
|
826
|
+
const tooltip_id = fixture.harness.runtime.views[0].canvas_tooltip_shown_id;
|
|
827
|
+
|
|
828
|
+
// Tab is focus departure: it must find and dismiss the MENU even
|
|
829
|
+
// though the tooltip is the topmost anchored child, consume the
|
|
830
|
+
// Tab, and leave the keyboard on the trigger. The tooltip is not
|
|
831
|
+
// the departure's business: focus never left the trigger, so the
|
|
832
|
+
// focus-shown tooltip stays.
|
|
833
|
+
try fixture.key("tab");
|
|
834
|
+
try std.testing.expect(!fixture.app_state.model.open);
|
|
835
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.app_state.model.dismissals);
|
|
836
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.picks);
|
|
837
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
838
|
+
try std.testing.expectEqual(tooltip_id, fixture.harness.runtime.views[0].canvas_tooltip_shown_id);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
test "tooltip coexistence: escape peels the tooltip first, then the menu, one per press" {
|
|
842
|
+
const fixture = try CoexistFixture.create();
|
|
843
|
+
defer fixture.destroy();
|
|
844
|
+
|
|
845
|
+
const trigger_id = try coexistOpenWithTooltip(fixture);
|
|
846
|
+
const tooltip_id = fixture.harness.runtime.views[0].canvas_tooltip_shown_id;
|
|
847
|
+
|
|
848
|
+
// Escape dismisses exactly one surface per press, topmost
|
|
849
|
+
// (last-mounted) first: the tooltip goes while the menu stays
|
|
850
|
+
// open and the keyboard stays on the trigger.
|
|
851
|
+
try fixture.key("escape");
|
|
852
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 0), fixture.harness.runtime.views[0].canvas_tooltip_shown_id);
|
|
853
|
+
try std.testing.expect((try fixture.retainedFrame(tooltip_id)) == null);
|
|
854
|
+
try std.testing.expect(fixture.app_state.model.open);
|
|
855
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.dismissals);
|
|
856
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
857
|
+
|
|
858
|
+
// The next Escape reaches the menu through the model's on_dismiss,
|
|
859
|
+
// still without committing, and the keyboard stays on the trigger.
|
|
860
|
+
try fixture.key("escape");
|
|
861
|
+
try std.testing.expect(!fixture.app_state.model.open);
|
|
862
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.app_state.model.dismissals);
|
|
863
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.picks);
|
|
864
|
+
try std.testing.expectEqual(@as(u32, 99), fixture.app_state.model.picked);
|
|
865
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
866
|
+
}
|
|
@@ -274,8 +274,9 @@ pub fn RuntimeCanvasWidgetContextMenu(comptime Runtime: type) type {
|
|
|
274
274
|
/// the event to the app — the same two motions keyboard-driven
|
|
275
275
|
/// edits perform, so runtime widget and app model stay in sync.
|
|
276
276
|
fn applyEditKeyboardEvent(self: *Runtime, app: runtime_api.App(Runtime), keyboard_event: runtime_api.CanvasWidgetKeyboardEvent) anyerror!void {
|
|
277
|
-
|
|
278
|
-
try
|
|
277
|
+
var event = keyboard_event;
|
|
278
|
+
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromKeyboard(self, &event);
|
|
279
|
+
try self.dispatchEvent(app, .{ .canvas_widget_keyboard = event });
|
|
279
280
|
}
|
|
280
281
|
|
|
281
282
|
fn editableSelectionText(self: *Runtime, view_index: usize, target_id: canvas.ObjectId) ?[]const u8 {
|