@native-sdk/cli 0.5.1 → 0.5.3
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 +41 -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/events.ts +39 -2
- package/packages/core/src/checker.ts +1 -1
- package/packages/core/src/emitter.ts +39 -3
- package/packages/core/src/infer.ts +53 -7
- package/skill-data/automation/SKILL.md +7 -4
- package/skill-data/core/references/app-model-runtime.md +3 -0
- package/skill-data/native-ui/SKILL.md +3 -2
- package/src/app_runner/root.zig +25 -0
- package/src/automation/protocol.zig +20 -1
- package/src/embed/host.zig +27 -0
- package/src/embed/tests.zig +69 -0
- package/src/embed/ui_host.zig +4 -0
- package/src/platform/macos/appkit_host.h +11 -0
- package/src/platform/macos/appkit_host.m +130 -0
- package/src/platform/macos/root.zig +34 -0
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +3 -0
- package/src/platform/types.zig +118 -4
- package/src/primitives/canvas/chart.zig +7 -7
- package/src/primitives/canvas/chart_tests.zig +66 -0
- package/src/primitives/canvas/commands.zig +48 -0
- package/src/primitives/canvas/events.zig +161 -0
- package/src/primitives/canvas/font_ttf.zig +155 -8
- package/src/primitives/canvas/font_ttf_tests.zig +686 -0
- package/src/primitives/canvas/reference.zig +67 -8
- package/src/primitives/canvas/render_fingerprints.zig +8 -0
- package/src/primitives/canvas/root.zig +26 -0
- package/src/primitives/canvas/tokens.zig +170 -7
- package/src/primitives/canvas/ui.zig +62 -7
- package/src/primitives/canvas/ui_markup.zig +51 -4
- package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +49 -4
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +160 -0
- package/src/primitives/canvas/ui_markup_contract.zig +9 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +24 -0
- package/src/primitives/canvas/ui_markup_tests.zig +73 -0
- package/src/primitives/canvas/ui_markup_view.zig +63 -5
- package/src/primitives/canvas/ui_markup_view_tests.zig +151 -2
- package/src/primitives/canvas/ui_schema.zig +31 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -11
- package/src/primitives/canvas/ui_tests.zig +31 -0
- package/src/primitives/canvas/vector.zig +258 -141
- package/src/primitives/canvas/widget_access.zig +1 -1
- package/src/primitives/canvas/widget_builtin_tests.zig +259 -0
- package/src/primitives/canvas/widget_layout.zig +13 -5
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_render.zig +78 -40
- package/src/primitives/canvas/widget_render_controls.zig +15 -4
- package/src/primitives/canvas/widget_semantics.zig +6 -1
- package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
- package/src/primitives/canvas/widget_text_input.zig +118 -10
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +28 -0
- package/src/root.zig +5 -0
- package/src/runtime/api.zig +13 -0
- package/src/runtime/automation_commands.zig +33 -0
- package/src/runtime/automation_widget_dispatch.zig +159 -28
- package/src/runtime/canvas_font_tests.zig +272 -3
- package/src/runtime/canvas_fonts.zig +60 -20
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_frame_helpers.zig +15 -0
- package/src/runtime/canvas_image_tests.zig +26 -0
- package/src/runtime/canvas_images.zig +33 -7
- package/src/runtime/canvas_limits.zig +44 -8
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
- package/src/runtime/canvas_widget_events.zig +1295 -7
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_runtime.zig +24 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +88 -6
- package/src/runtime/canvas_widget_text_tests.zig +277 -0
- package/src/runtime/core.zig +112 -6
- package/src/runtime/flow.zig +51 -1
- package/src/runtime/gpu_surface_events.zig +51 -5
- package/src/runtime/media_surface.zig +726 -0
- package/src/runtime/media_surface_tests.zig +1476 -0
- package/src/runtime/root.zig +9 -0
- package/src/runtime/session_journal.zig +52 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +575 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_ui_app.zig +56 -0
- package/src/runtime/ui_app.zig +64 -1
- package/src/runtime/ui_app_tests.zig +794 -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
|
@@ -193,6 +193,12 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
193
193
|
}
|
|
194
194
|
stamped.on_key = keyMsgAdapter;
|
|
195
195
|
}
|
|
196
|
+
if (comptime @hasDecl(core, "pinchMsg")) {
|
|
197
|
+
if (options.on_pinch != null) {
|
|
198
|
+
@panic("TsUiApp wires on_pinch from the core's pinchMsg export - remove the wiring's on_pinch");
|
|
199
|
+
}
|
|
200
|
+
stamped.on_pinch = pinchMsgAdapter;
|
|
201
|
+
}
|
|
196
202
|
if (comptime @hasDecl(core, "appearanceMsg")) {
|
|
197
203
|
if (options.on_appearance != null) {
|
|
198
204
|
@panic("TsUiApp wires on_appearance from the core's appearanceMsg export - remove the wiring's on_appearance");
|
|
@@ -360,6 +366,56 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
360
366
|
return core.keyMsg(arg);
|
|
361
367
|
}
|
|
362
368
|
|
|
369
|
+
/// `Options.on_pinch` over the core's `pinchMsg(pinch)` export:
|
|
370
|
+
/// the emitted PinchEvent record — `windowId`/`label` (the
|
|
371
|
+
/// source identity: `x`/`y` are view-local, so a coordinate
|
|
372
|
+
/// without its view is not a position; multi-window cores tell
|
|
373
|
+
/// pinches apart by these), `phase` (the declared
|
|
374
|
+
/// begin/change/end alias, matched by member name), `scale` (the
|
|
375
|
+
/// magnification DELTA on "change" — multiplicative, so the
|
|
376
|
+
/// cumulative gesture scale is the product of `1 + scale`,
|
|
377
|
+
/// applied memorylessly), and the `x`/`y` pointer anchor
|
|
378
|
+
/// in view-local canvas points. The core's return gates the channel
|
|
379
|
+
/// exactly like a Zig `on_pinch` (null drops the event).
|
|
380
|
+
fn pinchMsgAdapter(pinch: platform.PinchEvent) ?Msg {
|
|
381
|
+
const params = @typeInfo(@TypeOf(core.pinchMsg)).@"fn".params;
|
|
382
|
+
if (comptime params.len != 1) {
|
|
383
|
+
@compileError("TsUiApp: pinchMsg must take one PinchEvent parameter - regenerate the core");
|
|
384
|
+
}
|
|
385
|
+
const PinchArg = params[0].type.?;
|
|
386
|
+
comptime {
|
|
387
|
+
const fields = @typeInfo(PinchArg).@"struct".fields;
|
|
388
|
+
if (fields.len != 6 or !@hasField(PinchArg, "windowId") or !@hasField(PinchArg, "label") or
|
|
389
|
+
!@hasField(PinchArg, "phase") or !@hasField(PinchArg, "scale") or
|
|
390
|
+
!@hasField(PinchArg, "x") or !@hasField(PinchArg, "y"))
|
|
391
|
+
{
|
|
392
|
+
@compileError("TsUiApp: pinchMsg's PinchEvent must be exactly { windowId: number; label: string; phase: \"begin\" | \"change\" | \"end\"; scale: number; x: number; y: number }");
|
|
393
|
+
}
|
|
394
|
+
const Phase = @FieldType(PinchArg, "phase");
|
|
395
|
+
const phase_info = @typeInfo(Phase);
|
|
396
|
+
if (phase_info != .@"enum" or phase_info.@"enum".fields.len != 3 or
|
|
397
|
+
!@hasField(Phase, "begin") or !@hasField(Phase, "change") or !@hasField(Phase, "end"))
|
|
398
|
+
{
|
|
399
|
+
@compileError("TsUiApp: pinchMsg's PinchEvent.phase must be the named \"begin\" | \"change\" | \"end\" alias");
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
var arg: PinchArg = undefined;
|
|
403
|
+
const Phase = @FieldType(PinchArg, "phase");
|
|
404
|
+
arg.phase = switch (pinch.phase) {
|
|
405
|
+
inline else => |phase| @field(Phase, @tagName(phase)),
|
|
406
|
+
};
|
|
407
|
+
// The label slice stays borrowed exactly through the core
|
|
408
|
+
// call, like the Zig channel's contract: a Msg built from it
|
|
409
|
+
// commits (copies) on dispatch like every routed bytes
|
|
410
|
+
// payload.
|
|
411
|
+
arg.windowId = channelNum(@FieldType(PinchArg, "windowId"), @floatFromInt(pinch.window_id));
|
|
412
|
+
arg.label = pinch.label;
|
|
413
|
+
arg.scale = channelNum(@FieldType(PinchArg, "scale"), pinch.scale);
|
|
414
|
+
arg.x = channelNum(@FieldType(PinchArg, "x"), pinch.x);
|
|
415
|
+
arg.y = channelNum(@FieldType(PinchArg, "y"), pinch.y);
|
|
416
|
+
return core.pinchMsg(arg);
|
|
417
|
+
}
|
|
418
|
+
|
|
363
419
|
/// `Options.on_appearance` over the core's `appearanceMsg` arm
|
|
364
420
|
/// export: the appearance record — `colorScheme` (a declared
|
|
365
421
|
/// light/dark enum, matched by member name), `reduceMotion`,
|
package/src/runtime/ui_app.zig
CHANGED
|
@@ -537,6 +537,26 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
537
537
|
/// can never steal typing — a fallback that yields to every
|
|
538
538
|
/// consuming widget can carry them safely.
|
|
539
539
|
on_key: ?*const fn (keyboard: canvas.WidgetKeyboardEvent) ?MsgT = null,
|
|
540
|
+
/// Optional mapping from trackpad pinch gestures into
|
|
541
|
+
/// messages — the app-level gesture channel (the `on_key`
|
|
542
|
+
/// shape). Pinch deliberately bypasses the widget pipeline:
|
|
543
|
+
/// it is a view-global gesture (timeline/canvas zoom is an
|
|
544
|
+
/// app-level concern), delivered phase-explicit (`begin`,
|
|
545
|
+
/// `change`, `end`) with the per-event magnification DELTA
|
|
546
|
+
/// on `change` — a MULTIPLICATIVE delta: the cumulative
|
|
547
|
+
/// gesture scale is the running product of `(1 + scale)`,
|
|
548
|
+
/// applied memorylessly (`zoom *= 1 + scale`); on macOS the
|
|
549
|
+
/// host forwards AppKit's raw `NSEvent.magnification`,
|
|
550
|
+
/// which IS that delta per the browser-engine convention
|
|
551
|
+
/// — and the pointer anchor in
|
|
552
|
+
/// view-local canvas points (`x`/`y`, the zoom-at-cursor
|
|
553
|
+
/// anchor). Every event names its source window and view
|
|
554
|
+
/// (`window_id`/`label`, the `on_frame` identity shape) —
|
|
555
|
+
/// view-local coordinates mean nothing without their view,
|
|
556
|
+
/// so multi-window apps tell pinches apart. Only hosts with
|
|
557
|
+
/// a pinch source emit these (macOS today); everywhere else
|
|
558
|
+
/// the channel simply never fires.
|
|
559
|
+
on_pinch: ?*const fn (pinch: platform.PinchEvent) ?MsgT = null,
|
|
540
560
|
/// Optional mapping from runtime timer events (started via
|
|
541
561
|
/// `runtime.startTimer`) into messages. Framework-reserved timer
|
|
542
562
|
/// ids (>= `platform.reserved_timer_id_base`) are handled
|
|
@@ -1190,8 +1210,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1190
1210
|
// The manifest accent layers over the resolved pack —
|
|
1191
1211
|
// except under high contrast, where the pack's own loud
|
|
1192
1212
|
// register wins untouched (accessibility beats brand).
|
|
1213
|
+
// The bundle takes the resolved scheme: the dark ring
|
|
1214
|
+
// derives desaturated (canvas.accentFocusRing).
|
|
1193
1215
|
if (!self.system_appearance.high_contrast) {
|
|
1194
|
-
tokens = tokens.withOverrides(canvas.accentOverrides(accent)
|
|
1216
|
+
tokens = tokens.withOverrides(canvas.accentOverrides(accent, switch (self.system_appearance.color_scheme) {
|
|
1217
|
+
.light => .light,
|
|
1218
|
+
.dark => .dark,
|
|
1219
|
+
}));
|
|
1195
1220
|
}
|
|
1196
1221
|
}
|
|
1197
1222
|
tokens.pixel_snap.scale = self.pixel_snap_scale;
|
|
@@ -2765,6 +2790,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2765
2790
|
.canvas_widget_change => |change_event| try self.handleWidgetChange(runtime, change_event),
|
|
2766
2791
|
.window_closed => |closed| try self.handleWindowClosed(runtime, closed),
|
|
2767
2792
|
.automation_provenance => |query| try self.handleProvenanceQuery(runtime, query),
|
|
2793
|
+
// Raw gpu-surface input stays runtime-internal EXCEPT the
|
|
2794
|
+
// pinch kinds, which surface through the app-level pinch
|
|
2795
|
+
// channel (widget routing never claims a pinch).
|
|
2796
|
+
.gpu_surface_input => |input_event| try self.handlePinch(runtime, input_event),
|
|
2768
2797
|
else => {},
|
|
2769
2798
|
}
|
|
2770
2799
|
}
|
|
@@ -2830,6 +2859,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2830
2859
|
"font \"{s}\" (id {d}) failed to register: {s}",
|
|
2831
2860
|
.{ font.name, font.id, canvas.font_ttf.parseFailureReason(font.ttf) orelse "not a parseable TrueType face" },
|
|
2832
2861
|
),
|
|
2862
|
+
error.FontExceedsGlyphBudgets => if (canvas.font_ttf.declaredGlyphMaxima(font.ttf)) |maxima| ui_app_log.warn(
|
|
2863
|
+
"font \"{s}\" (id {d}) failed to register: its 'maxp' declares glyphs up to {d} points / {d} contours, flattened composites up to {d} points / {d} contours, with composites {d} deep of {d} components, beyond the outline budgets ({d} points, {d} contours, {d} composite points, {d} composite contours, {d} deep, {d} components — canvas.font_ttf); past-budget glyphs would render as block fallbacks, so registration refuses the face whole",
|
|
2864
|
+
.{ font.name, font.id, maxima.points, maxima.contours, maxima.composite_points, maxima.composite_contours, maxima.component_depth, maxima.component_elements, canvas.font_ttf.max_glyph_points, canvas.font_ttf.max_glyph_contours, canvas.font_ttf.max_composite_points, canvas.font_ttf.max_composite_contours, canvas.font_ttf.max_composite_depth, canvas.font_ttf.max_composite_components },
|
|
2865
|
+
) else ui_app_log.warn(
|
|
2866
|
+
"font \"{s}\" (id {d}) failed to register: it declares glyph outlines denser than the renderer's budgets ({d} points / {d} contours per glyph — canvas.font_ttf), so its densest glyphs could not render as outlines",
|
|
2867
|
+
.{ font.name, font.id, canvas.font_ttf.max_glyph_points, canvas.font_ttf.max_glyph_contours },
|
|
2868
|
+
),
|
|
2833
2869
|
error.FontTooLarge => ui_app_log.warn(
|
|
2834
2870
|
"font \"{s}\" (id {d}) failed to register: the file is {d} bytes but the per-font budget is {d} bytes (canvas_limits.max_registered_canvas_font_bytes)",
|
|
2835
2871
|
.{ font.name, font.id, font.ttf.len, canvas_limits.max_registered_canvas_font_bytes },
|
|
@@ -3338,6 +3374,33 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
3338
3374
|
}
|
|
3339
3375
|
}
|
|
3340
3376
|
|
|
3377
|
+
/// Trackpad pinch reaches the app as the view-global gesture
|
|
3378
|
+
/// channel (`Options.on_pinch`): only the pinch kinds of the raw
|
|
3379
|
+
/// gpu-surface input surface here — every other raw input kind
|
|
3380
|
+
/// stays runtime-internal (widgets and the semantic Msg surface
|
|
3381
|
+
/// already carry it). The Msg dispatch rides the same journaled
|
|
3382
|
+
/// input event, so a recorded pinch replays to the identical
|
|
3383
|
+
/// model.
|
|
3384
|
+
fn handlePinch(self: *Self, runtime: *Runtime, input_event: platform.GpuSurfaceInputEvent) anyerror!void {
|
|
3385
|
+
const map = self.options.on_pinch orelse return;
|
|
3386
|
+
const phase: platform.PinchPhase = switch (input_event.kind) {
|
|
3387
|
+
.pinch_begin => .begin,
|
|
3388
|
+
.pinch_change => .change,
|
|
3389
|
+
.pinch_end => .end,
|
|
3390
|
+
else => return,
|
|
3391
|
+
};
|
|
3392
|
+
if (map(.{
|
|
3393
|
+
.window_id = input_event.window_id,
|
|
3394
|
+
.label = input_event.label,
|
|
3395
|
+
.phase = phase,
|
|
3396
|
+
.scale = input_event.scale,
|
|
3397
|
+
.x = input_event.x,
|
|
3398
|
+
.y = input_event.y,
|
|
3399
|
+
})) |msg| {
|
|
3400
|
+
try self.dispatch(runtime, input_event.window_id, msg);
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3341
3404
|
/// Split-fraction changes route through the split's `on_resize`
|
|
3342
3405
|
/// constructor. The payload is the fraction the runtime already
|
|
3343
3406
|
/// applied, so a model that stores it and echoes it back into
|