@native-sdk/cli 0.5.4 → 0.6.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/app.zig +50 -1
- package/build.zig +534 -3
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +280 -8
- package/packages/core/sdk/core.ts +481 -2
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1283 -66
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +16 -0
- package/src/runtime/api.zig +70 -1
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +1 -0
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +240 -24
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +109 -15
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2333 -63
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +268 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
|
@@ -5,6 +5,7 @@ const text_model = @import("text.zig");
|
|
|
5
5
|
const text_spans_model = @import("text_spans.zig");
|
|
6
6
|
const token_model = @import("tokens.zig");
|
|
7
7
|
const chart_model = @import("chart.zig");
|
|
8
|
+
const terminal_grid_model = @import("terminal_grid.zig");
|
|
8
9
|
|
|
9
10
|
const Error = canvas.Error;
|
|
10
11
|
const ObjectId = canvas.ObjectId;
|
|
@@ -20,6 +21,7 @@ const TextRange = text_model.TextRange;
|
|
|
20
21
|
const TextSelection = text_model.TextSelection;
|
|
21
22
|
const CanvasRenderAnimation = canvas.CanvasRenderAnimation;
|
|
22
23
|
const BlurTokenRef = token_model.BlurTokenRef;
|
|
24
|
+
const ScrollAxes = token_model.ScrollAxes;
|
|
23
25
|
const Easing = token_model.Easing;
|
|
24
26
|
const MotionDuration = token_model.MotionDuration;
|
|
25
27
|
const MotionTokens = token_model.MotionTokens;
|
|
@@ -148,6 +150,18 @@ pub const WidgetKind = enum {
|
|
|
148
150
|
/// `ReferenceImage.presentation_only`), so goldens and session
|
|
149
151
|
/// fingerprints never depend on producer output.
|
|
150
152
|
media_surface,
|
|
153
|
+
/// The terminal leaf: paints a RESOLVED emulator viewport (a
|
|
154
|
+
/// `terminal_grid.TerminalGrid` snapshot the widget's `terminal`
|
|
155
|
+
/// binding references) as real text runs and geometric box drawing,
|
|
156
|
+
/// clipped to its frame. A stateful focus target like the text
|
|
157
|
+
/// inputs — focused, it routes keys and committed text to the
|
|
158
|
+
/// framework-owned session behind its bound pty id and consumes
|
|
159
|
+
/// wheel scrollback — but never a text-input kind: the emulator,
|
|
160
|
+
/// not a TextBuffer, owns the editing model. Its semantics label
|
|
161
|
+
/// carries the viewport's plain text (a terminal's semantic content
|
|
162
|
+
/// IS its text), so assistive tech reads the real screen and the
|
|
163
|
+
/// session fingerprint covers cell state.
|
|
164
|
+
terminal,
|
|
151
165
|
};
|
|
152
166
|
|
|
153
167
|
/// STABLE code for a widget kind: assigned at birth, never reused or
|
|
@@ -226,6 +240,7 @@ pub fn widgetKindCode(kind: WidgetKind) u16 {
|
|
|
226
240
|
.tree => 59,
|
|
227
241
|
.input_group => 60,
|
|
228
242
|
.media_surface => 61,
|
|
243
|
+
.terminal => 62,
|
|
229
244
|
};
|
|
230
245
|
}
|
|
231
246
|
|
|
@@ -249,6 +264,12 @@ pub const WidgetState = struct {
|
|
|
249
264
|
};
|
|
250
265
|
|
|
251
266
|
pub const WidgetRenderState = struct {
|
|
267
|
+
/// Whether the app is active and this widget tree's window is key.
|
|
268
|
+
/// Runtime focus ids stay retained while false so focus-visible
|
|
269
|
+
/// chrome and per-window restoration keep their existing semantics;
|
|
270
|
+
/// controls whose pixels represent CURRENT keyboard ownership (the
|
|
271
|
+
/// terminal cursor) consult this gate too.
|
|
272
|
+
keyboard_active: bool = true,
|
|
252
273
|
focused_id: ?ObjectId = null,
|
|
253
274
|
focus_visible_id: ?ObjectId = null,
|
|
254
275
|
hovered_id: ?ObjectId = null,
|
|
@@ -323,6 +344,16 @@ pub const WidgetAnchor = struct {
|
|
|
323
344
|
alignment: WidgetAnchorAlignment = .start,
|
|
324
345
|
/// Gap in points between the anchor edge and the surface.
|
|
325
346
|
offset: f32 = 4,
|
|
347
|
+
/// Point-anchor mode: when set, the surface anchors at this explicit
|
|
348
|
+
/// point in the window's coordinate space instead of the parent
|
|
349
|
+
/// widget's frame (the context-menu-at-the-pointer shape). The point
|
|
350
|
+
/// acts as a zero-size anchor rect, so the standard popup edge rules
|
|
351
|
+
/// apply unchanged: `placement` prefers a side of the point, the
|
|
352
|
+
/// surface flips to the other side when it would cross the window
|
|
353
|
+
/// edge and the other side has more room, and both axes clamp into
|
|
354
|
+
/// the window. `stretch` alignment has no width to inherit from a
|
|
355
|
+
/// point and behaves like `start`.
|
|
356
|
+
point: ?geometry.PointF = null,
|
|
326
357
|
};
|
|
327
358
|
|
|
328
359
|
pub const WidgetLayoutStyle = struct {
|
|
@@ -381,6 +412,17 @@ pub const WidgetLayoutStyle = struct {
|
|
|
381
412
|
/// into both `min_size` and `max_size`, so intrinsic content can
|
|
382
413
|
/// neither shrink nor silently grow the box past it.
|
|
383
414
|
max_size: geometry.SizeF = .{},
|
|
415
|
+
/// The media sizing contract for a COMPOSED container: report no
|
|
416
|
+
/// intrinsic size, exactly like the media-surface leaf it wraps
|
|
417
|
+
/// (definite width/height or flex grow size it; a hug container
|
|
418
|
+
/// gives it nothing). Chrome composed beside a zero-intrinsic
|
|
419
|
+
/// surface — a transport bar — must not leak its own intrinsic
|
|
420
|
+
/// size into the element, or an unsized element would render as a
|
|
421
|
+
/// chrome-only strip. Declared sizes stay definite (they ride the
|
|
422
|
+
/// frame and the min/max bounds, never the intrinsic measure);
|
|
423
|
+
/// pair with `clip_content` so chrome cannot paint past a box the
|
|
424
|
+
/// layout granted nothing.
|
|
425
|
+
zero_intrinsic: bool = false,
|
|
384
426
|
};
|
|
385
427
|
|
|
386
428
|
pub const WidgetStyle = struct {
|
|
@@ -718,6 +760,49 @@ pub const WidgetOverscroll = enum {
|
|
|
718
760
|
rubber_band,
|
|
719
761
|
};
|
|
720
762
|
|
|
763
|
+
/// The `.terminal` widget's binding: `pty` is the MODEL-OWNED pty
|
|
764
|
+
/// effect key the element binds (the id `fx.ptySpawn` named — ids are
|
|
765
|
+
/// model data, never markup literals; 0 is the unbound sentinel and the
|
|
766
|
+
/// surface paints its background only). `scrollback` is the declared
|
|
767
|
+
/// scrollback offset in rows, following the scroll `value` source-wins
|
|
768
|
+
/// reconcile rule: echo the `on-terminal` state's `scrollback` back
|
|
769
|
+
/// here and the runtime-owned position survives rebuilds; change it
|
|
770
|
+
/// model-side to scroll programmatically. `grid` is the RESOLVED
|
|
771
|
+
/// viewport snapshot the producer published for the key.
|
|
772
|
+
///
|
|
773
|
+
/// LIFETIME: `grid` is a BORROWED pointer, not copied into a retained
|
|
774
|
+
/// tree the way `text`/`spans` are — so the producer must own it for at
|
|
775
|
+
/// least as long as any retained tree built from this widget, since a
|
|
776
|
+
/// focus/hover repaint re-emits from the retained tree without a
|
|
777
|
+
/// rebuild. The sanctioned producer is the framework's terminal-session
|
|
778
|
+
/// store (installed via `Ui.TerminalGridLookup`), whose grids live in
|
|
779
|
+
/// stable per-session storage across frames and are freed only when the
|
|
780
|
+
/// session ends and the widget unmounts — so the runtime flow satisfies
|
|
781
|
+
/// the contract by construction. It is `null` whenever no lookup is
|
|
782
|
+
/// installed (every app- or test-built tree today), which paints the
|
|
783
|
+
/// honest empty surface; a direct builder caller that sets it must honor
|
|
784
|
+
/// the same outlive-the-retained-tree contract, exactly as it must for a
|
|
785
|
+
/// borrowed `text` slice.
|
|
786
|
+
pub const TerminalBinding = struct {
|
|
787
|
+
pty: u64 = 0,
|
|
788
|
+
scrollback: u32 = 0,
|
|
789
|
+
grid: ?*const terminal_grid_model.TerminalGrid = null,
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
/// A house video-transport chrome role for a control the RUNTIME
|
|
793
|
+
/// consumes: `Ui.video` stamps it on the chrome it composes (`.toggle`
|
|
794
|
+
/// on the play/pause button, `.scrub` on the seek slider), and the app
|
|
795
|
+
/// loop drives the single video playback channel from presses/changes
|
|
796
|
+
/// on these widgets instead of resolving an app Msg — declarative
|
|
797
|
+
/// playback needs no model plumbing to keep its transport honest.
|
|
798
|
+
/// `.none` everywhere else, including every app-authored widget:
|
|
799
|
+
/// builder-internal, never an `ElementOptions` channel.
|
|
800
|
+
pub const VideoControlVerb = enum(u8) {
|
|
801
|
+
none,
|
|
802
|
+
toggle,
|
|
803
|
+
scrub,
|
|
804
|
+
};
|
|
805
|
+
|
|
721
806
|
/// Where a control sits inside a FLUSH button group (`button_group`
|
|
722
807
|
/// with gap 0), stamped onto the render-time widget copy by BOTH render
|
|
723
808
|
/// walks — never authored, never serialized, never retained. The stamp
|
|
@@ -801,9 +886,33 @@ pub const Widget = struct {
|
|
|
801
886
|
image_fit: ImageFit = .stretch,
|
|
802
887
|
image_sampling: ImageSampling = .linear,
|
|
803
888
|
image_opacity: f32 = 1,
|
|
889
|
+
/// The video stream's REPORTED dimensions for a contain-fitted
|
|
890
|
+
/// media surface (`Ui.stampVideoSurfaceFit` writes it from the
|
|
891
|
+
/// LOADED event's journaled report; null until then): the emit
|
|
892
|
+
/// computes the letterboxed frame quad from this, never from
|
|
893
|
+
/// `image_src` — which keeps its ordinary source-crop meaning on
|
|
894
|
+
/// every widget. Engine-internal: no builder option, no markup
|
|
895
|
+
/// attribute.
|
|
896
|
+
stream_size: ?geometry.SizeF = null,
|
|
804
897
|
text_selection: ?TextSelection = null,
|
|
805
898
|
text_composition: ?TextRange = null,
|
|
806
899
|
value: f32 = 0,
|
|
900
|
+
/// The HORIZONTAL scroll offset of a horizontal-capable
|
|
901
|
+
/// `.scroll_view` (`value_x:` in the builder, `value-x=` in markup)
|
|
902
|
+
/// — the horizontal counterpart of the retained offset that rides
|
|
903
|
+
/// `value`. Follows the same source-wins reconcile rule: the
|
|
904
|
+
/// runtime-owned offset (user scrolling) survives rebuilds while
|
|
905
|
+
/// the source offset is unchanged; a source-side change
|
|
906
|
+
/// (programmatic scroll) wins. Meaningless on every other kind.
|
|
907
|
+
value_x: f32 = 0,
|
|
908
|
+
/// Which axes a `.scroll_view` scrolls (`axis:` in the builder,
|
|
909
|
+
/// `axis=` in markup). Vertical — the pre-axis behavior — is the
|
|
910
|
+
/// default; `horizontal` and `both` opt the region into wheel
|
|
911
|
+
/// `delta_x`, the horizontal scrollbar, and the horizontal keymap.
|
|
912
|
+
/// Virtualized regions ignore the horizontal grant (windowed
|
|
913
|
+
/// virtualization prices rows, not columns). Meaningless on every
|
|
914
|
+
/// other kind.
|
|
915
|
+
scroll_axes: ScrollAxes = .vertical,
|
|
807
916
|
layer: ?i32 = null,
|
|
808
917
|
/// Modal surfaces (dialog/drawer/sheet) paint a token-driven scrim
|
|
809
918
|
/// (dim + backdrop blur) across the whole tree behind them. False
|
|
@@ -879,12 +988,35 @@ pub const Widget = struct {
|
|
|
879
988
|
/// widget a hit target; platforms without a window-drag channel
|
|
880
989
|
/// treat the press as dead space.
|
|
881
990
|
window_drag: bool = false,
|
|
991
|
+
/// The widget listens for hover-enter/hover-leave Msgs
|
|
992
|
+
/// (`ElementOptions.on_hover_enter` / `on_hover_leave`; markup
|
|
993
|
+
/// `on-hover-enter` / `on-hover-leave`): the builder stamps this
|
|
994
|
+
/// from the bound handlers, and the runtime tracks the pointer's
|
|
995
|
+
/// containment against it — enter when the pointer enters the
|
|
996
|
+
/// widget's hit region, leave when it exits. Like the chart's
|
|
997
|
+
/// `hover_details`, the flag makes the widget hit-testable WITHOUT
|
|
998
|
+
/// claiming presses (clicks keep falling through to the nearest
|
|
999
|
+
/// claiming ancestor) and without any hover wash of its own — the
|
|
1000
|
+
/// wash stays a per-kind visual channel, so binding hover on a
|
|
1001
|
+
/// quiet content tile never lights it up.
|
|
1002
|
+
hover_msgs: bool = false,
|
|
882
1003
|
/// Plot data for `.chart` widgets: model-derived series (values,
|
|
883
1004
|
/// token colors, kind) plus domain/grid options. The retained tree
|
|
884
1005
|
/// copies series and points into per-view storage like text/spans,
|
|
885
1006
|
/// bounded by `canvas_limits.max_canvas_widget_chart_*` budgets.
|
|
886
1007
|
/// `Ui.chart` downsamples long series before they land here.
|
|
887
1008
|
chart: chart_model.ChartData = .{},
|
|
1009
|
+
/// The `.terminal` widget's binding (see `TerminalBinding`): the
|
|
1010
|
+
/// model-owned pty effect key the element binds, the declared
|
|
1011
|
+
/// scrollback echo, and the resolved grid snapshot published for
|
|
1012
|
+
/// that key. Default (unbound) on every other kind.
|
|
1013
|
+
terminal: TerminalBinding = .{},
|
|
1014
|
+
/// House video-transport role (see `VideoControlVerb`): `Ui.video`
|
|
1015
|
+
/// stamps `.toggle`/`.scrub` on the chrome controls it composes, and
|
|
1016
|
+
/// the app loop consumes presses/changes on them by driving the
|
|
1017
|
+
/// video playback channel — never by resolving an app Msg. `.none`
|
|
1018
|
+
/// on every app-authored widget.
|
|
1019
|
+
video_control: VideoControlVerb = .none,
|
|
888
1020
|
/// Render-walk stamp for flush button-group segments (see
|
|
889
1021
|
/// `WidgetGroupSegment`). Derived at emit time from the widget's
|
|
890
1022
|
/// position among its group's visible children; `.none` everywhere
|
package/src/root.zig
CHANGED
|
@@ -76,12 +76,28 @@ pub const EffectAudioEventKind = runtime.EffectAudioEventKind;
|
|
|
76
76
|
pub const EffectAudioSource = runtime.EffectAudioSource;
|
|
77
77
|
pub const audioCachePath = runtime.audioCachePath;
|
|
78
78
|
pub const max_effect_audio_path_bytes = runtime.max_effect_audio_path_bytes;
|
|
79
|
+
pub const EffectVideo = runtime.EffectVideo;
|
|
80
|
+
pub const EffectVideoEventKind = runtime.EffectVideoEventKind;
|
|
81
|
+
pub const EffectVideoSource = runtime.EffectVideoSource;
|
|
82
|
+
pub const max_effect_video_path_bytes = runtime.max_effect_video_path_bytes;
|
|
79
83
|
pub const EffectImageResult = runtime.EffectImageResult;
|
|
80
84
|
pub const EffectImageOutcome = runtime.EffectImageOutcome;
|
|
81
85
|
pub const imageCachePath = runtime.imageCachePath;
|
|
82
86
|
pub const max_effect_image_path_bytes = runtime.max_effect_image_path_bytes;
|
|
83
87
|
pub const max_effect_image_bytes = runtime.max_effect_image_bytes;
|
|
84
88
|
pub const effect_image_blob_hash_len = runtime.effect_image_blob_hash_len;
|
|
89
|
+
pub const EffectChannelEvent = runtime.EffectChannelEvent;
|
|
90
|
+
pub const EffectChannelEventKind = runtime.EffectChannelEventKind;
|
|
91
|
+
pub const ChannelHandle = runtime.ChannelHandle;
|
|
92
|
+
pub const max_effect_channels = runtime.max_effect_channels;
|
|
93
|
+
pub const max_effect_channel_bytes = runtime.max_effect_channel_bytes;
|
|
94
|
+
pub const max_effect_channel_pending = runtime.max_effect_channel_pending;
|
|
95
|
+
pub const EffectPtyEvent = runtime.EffectPtyEvent;
|
|
96
|
+
pub const EffectPtyEventKind = runtime.EffectPtyEventKind;
|
|
97
|
+
pub const max_effect_ptys = runtime.max_effect_ptys;
|
|
98
|
+
pub const max_effect_pty_chunk_bytes = runtime.max_effect_pty_chunk_bytes;
|
|
99
|
+
pub const max_effect_pty_write_bytes = runtime.max_effect_pty_write_bytes;
|
|
100
|
+
pub const max_effect_pty_term_bytes = runtime.max_effect_pty_term_bytes;
|
|
85
101
|
pub const EffectHostResult = runtime.EffectHostResult;
|
|
86
102
|
pub const HostCallBinding = runtime.HostCallBinding;
|
|
87
103
|
pub const max_effect_host_name_bytes = runtime.max_effect_host_name_bytes;
|
package/src/runtime/api.zig
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
2
|
const trace = @import("trace");
|
|
3
3
|
const canvas = @import("canvas");
|
|
4
|
+
const geometry = @import("geometry");
|
|
4
5
|
const automation = @import("../automation/root.zig");
|
|
5
6
|
const bridge = @import("../bridge/root.zig");
|
|
6
7
|
const extensions = @import("../extensions/root.zig");
|
|
@@ -78,6 +79,21 @@ pub const CanvasWidgetKeyboardEvent = struct {
|
|
|
78
79
|
keyboard: canvas.WidgetKeyboardEvent,
|
|
79
80
|
target: ?canvas.WidgetFocusTarget = null,
|
|
80
81
|
route: []const canvas.WidgetEventRouteEntry = &.{},
|
|
82
|
+
/// This committed-text payload came from terminal Paste (the
|
|
83
|
+
/// clipboard shortcut or context menu), not ordinary typing or IME
|
|
84
|
+
/// input. UiApp routes it through the emulator's paste encoder
|
|
85
|
+
/// (bracketed-paste framing, newline normalization, and unsafe-
|
|
86
|
+
/// control stripping) before writing it to the pty.
|
|
87
|
+
terminal_paste: bool = false,
|
|
88
|
+
/// True when this event is dispatched OUTSIDE a gpu-surface input
|
|
89
|
+
/// cycle — the accessibility selection edits and the default
|
|
90
|
+
/// context-menu cut/paste/select-all, which have no terminal
|
|
91
|
+
/// `gpu_surface_input` dispatch following them. The ui-app layer's
|
|
92
|
+
/// hover drain, which normally defers mid-cycle keyboard events to
|
|
93
|
+
/// that terminal dispatch, drains standalone ones at their own
|
|
94
|
+
/// tail so an edit that unmounts the hovered listener never
|
|
95
|
+
/// strands its leave.
|
|
96
|
+
standalone: bool = false,
|
|
81
97
|
};
|
|
82
98
|
|
|
83
99
|
/// A scroll container's offset changed from a user gesture (wheel,
|
|
@@ -202,6 +218,38 @@ pub const CanvasWidgetContextMenuEvent = struct {
|
|
|
202
218
|
view_label: []const u8,
|
|
203
219
|
target_id: canvas.ObjectId,
|
|
204
220
|
item_index: usize,
|
|
221
|
+
/// The resolved request's correlation token. When it matches a
|
|
222
|
+
/// `canvas_widget_context_menu_shown` snapshot, `UiApp` resolves the
|
|
223
|
+
/// selection against that snapshot — never the live tree, which may
|
|
224
|
+
/// have rebuilt (and reordered or re-mapped the items) while the
|
|
225
|
+
/// asynchronous menu was open. A token without a snapshot (the
|
|
226
|
+
/// automation verb's direct dispatch, which validates against the
|
|
227
|
+
/// live tree itself) resolves through the live tree.
|
|
228
|
+
token: u64 = 0,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/// A widget's app-declared context menu was handed to the native
|
|
232
|
+
/// presenter. `UiApp` answers by snapshotting the shown items' dispatch
|
|
233
|
+
/// payloads keyed by `token`: presentation is asynchronous (GTK
|
|
234
|
+
/// popovers outlive event dispatch), so the selection must resolve
|
|
235
|
+
/// against what the user SAW, not the tree at selection time.
|
|
236
|
+
pub const CanvasWidgetContextMenuShownEvent = struct {
|
|
237
|
+
window_id: platform.WindowId = 1,
|
|
238
|
+
view_label: []const u8,
|
|
239
|
+
target_id: canvas.ObjectId,
|
|
240
|
+
token: u64,
|
|
241
|
+
item_count: usize,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/// The presented app-declared context menu closed WITHOUT a selection.
|
|
245
|
+
/// `UiApp` answers by disarming the matching token's snapshot and
|
|
246
|
+
/// releasing the presented build's pinned storage — without this
|
|
247
|
+
/// notice, a dismissed menu's pin would hold that storage until the
|
|
248
|
+
/// next presentation.
|
|
249
|
+
pub const CanvasWidgetContextMenuDismissedEvent = struct {
|
|
250
|
+
window_id: platform.WindowId = 1,
|
|
251
|
+
view_label: []const u8,
|
|
252
|
+
token: u64,
|
|
205
253
|
};
|
|
206
254
|
|
|
207
255
|
/// A right/ctrl-click landed on a widget with a declared context menu,
|
|
@@ -213,6 +261,10 @@ pub const CanvasWidgetContextMenuRequestEvent = struct {
|
|
|
213
261
|
window_id: platform.WindowId = 1,
|
|
214
262
|
view_label: []const u8,
|
|
215
263
|
target_id: canvas.ObjectId,
|
|
264
|
+
/// The secondary click's pointer location (view-local canvas points):
|
|
265
|
+
/// the fallback surface anchors here — like a native menu — not at a
|
|
266
|
+
/// target-widget edge.
|
|
267
|
+
point: geometry.PointF = .{},
|
|
216
268
|
};
|
|
217
269
|
|
|
218
270
|
/// A window the RUNTIME knew as open was closed by the platform — the
|
|
@@ -269,6 +321,12 @@ pub const Event = union(enum) {
|
|
|
269
321
|
/// tick, completion, failure): the ui-app layer routes it back
|
|
270
322
|
/// through `Effects.takeAudioMsg` into the app's `on_event` Msg.
|
|
271
323
|
audio: platform.AudioEvent,
|
|
324
|
+
/// A platform video player report (load acknowledgment with
|
|
325
|
+
/// dimensions, position tick, completion, failure): routed back
|
|
326
|
+
/// through `Effects.takeVideoMsg` into the app's `on_event` Msg.
|
|
327
|
+
/// Pixels never ride events — frames feed the media-surface
|
|
328
|
+
/// texture channel platform-side.
|
|
329
|
+
video: platform.VideoEvent,
|
|
272
330
|
files_dropped: platform.FileDropEvent,
|
|
273
331
|
gpu_surface_frame: GpuSurfaceFrameEvent,
|
|
274
332
|
gpu_surface_resized: GpuSurfaceResizeEvent,
|
|
@@ -279,6 +337,8 @@ pub const Event = union(enum) {
|
|
|
279
337
|
canvas_widget_file_drop: CanvasWidgetFileDropEvent,
|
|
280
338
|
canvas_widget_drag: CanvasWidgetDragEvent,
|
|
281
339
|
canvas_widget_context_menu: CanvasWidgetContextMenuEvent,
|
|
340
|
+
canvas_widget_context_menu_shown: CanvasWidgetContextMenuShownEvent,
|
|
341
|
+
canvas_widget_context_menu_dismissed: CanvasWidgetContextMenuDismissedEvent,
|
|
282
342
|
canvas_widget_context_menu_request: CanvasWidgetContextMenuRequestEvent,
|
|
283
343
|
canvas_widget_dismiss: CanvasWidgetDismissEvent,
|
|
284
344
|
canvas_widget_context_press: CanvasWidgetContextPressEvent,
|
|
@@ -296,6 +356,7 @@ pub const Event = union(enum) {
|
|
|
296
356
|
.timer => "timer",
|
|
297
357
|
.effects_wake => "effects_wake",
|
|
298
358
|
.audio => "audio",
|
|
359
|
+
.video => "video",
|
|
299
360
|
.files_dropped => "files_dropped",
|
|
300
361
|
.gpu_surface_frame => "gpu_surface_frame",
|
|
301
362
|
.gpu_surface_resized => "gpu_surface_resized",
|
|
@@ -306,6 +367,8 @@ pub const Event = union(enum) {
|
|
|
306
367
|
.canvas_widget_file_drop => "canvas_widget_file_drop",
|
|
307
368
|
.canvas_widget_drag => "canvas_widget_drag",
|
|
308
369
|
.canvas_widget_context_menu => "canvas_widget_context_menu",
|
|
370
|
+
.canvas_widget_context_menu_shown => "canvas_widget_context_menu_shown",
|
|
371
|
+
.canvas_widget_context_menu_dismissed => "canvas_widget_context_menu_dismissed",
|
|
309
372
|
.canvas_widget_context_menu_request => "canvas_widget_context_menu_request",
|
|
310
373
|
.canvas_widget_dismiss => "canvas_widget_dismiss",
|
|
311
374
|
.canvas_widget_context_press => "canvas_widget_context_press",
|
|
@@ -322,10 +385,16 @@ pub const Event = union(enum) {
|
|
|
322
385
|
/// switches the app's effects channel into replay mode (fake executor,
|
|
323
386
|
/// journaled results as the only terminal source) before the first
|
|
324
387
|
/// replayed event; `.feed` delivers one journaled effect result into
|
|
325
|
-
/// the stub executor's pending request with the matching key
|
|
388
|
+
/// the stub executor's pending request with the matching key; `.finish`
|
|
389
|
+
/// runs the end-of-journal consistency checks and must ERROR if any
|
|
390
|
+
/// journaled feed went unconsumed, any replayed read outran the
|
|
391
|
+
/// journal, or any queued record was never claimed by the load it
|
|
392
|
+
/// named — divergence a fingerprint checkpoint cannot see because the
|
|
393
|
+
/// optimistic answer changed no state.
|
|
326
394
|
pub const ReplayControl = union(enum) {
|
|
327
395
|
arm,
|
|
328
396
|
feed: runtime_effects.EffectResultRecord,
|
|
397
|
+
finish,
|
|
329
398
|
};
|
|
330
399
|
|
|
331
400
|
pub fn App(comptime Runtime: type) type {
|
|
@@ -40,6 +40,9 @@ pub const AutomationWidgetTarget = struct {
|
|
|
40
40
|
pub const AutomationWidgetWheel = struct {
|
|
41
41
|
target: AutomationWidgetTarget,
|
|
42
42
|
delta_y: f32,
|
|
43
|
+
/// Horizontal wheel delta (the optional fourth token): 0 — the
|
|
44
|
+
/// classic three-token form — scrolls vertically exactly as before.
|
|
45
|
+
delta_x: f32 = 0,
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
/// `widget-context-menu <view-label> <id> <item-index>`: invoke one of
|
|
@@ -238,18 +241,27 @@ pub fn parseAutomationProvenanceTarget(value: []const u8) !AutomationProvenanceT
|
|
|
238
241
|
return .{ .view_label = view.token, .id = id };
|
|
239
242
|
}
|
|
240
243
|
|
|
244
|
+
/// `widget-wheel <view-label> <id> <delta-y> [delta-x]`: the optional
|
|
245
|
+
/// fourth token scrolls the horizontal axis (per-axis routing applies,
|
|
246
|
+
/// exactly like a real trackpad gesture with both deltas).
|
|
241
247
|
pub fn parseAutomationWidgetWheel(value: []const u8) !AutomationWidgetWheel {
|
|
242
248
|
const view = takeAutomationToken(value) orelse return error.InvalidCommand;
|
|
243
249
|
const id_part = takeAutomationToken(view.rest) orelse return error.InvalidCommand;
|
|
244
250
|
const delta_part = takeAutomationToken(id_part.rest) orelse return error.InvalidCommand;
|
|
245
|
-
if (takeAutomationToken(delta_part.rest) != null) return error.InvalidCommand;
|
|
246
251
|
const id = std.fmt.parseInt(canvas.ObjectId, id_part.token, 10) catch return error.InvalidCommand;
|
|
247
252
|
if (id == 0) return error.InvalidCommand;
|
|
248
253
|
const delta_y = std.fmt.parseFloat(f32, delta_part.token) catch return error.InvalidCommand;
|
|
249
254
|
if (!std.math.isFinite(delta_y)) return error.InvalidCommand;
|
|
255
|
+
var delta_x: f32 = 0;
|
|
256
|
+
if (takeAutomationToken(delta_part.rest)) |delta_x_part| {
|
|
257
|
+
if (takeAutomationToken(delta_x_part.rest) != null) return error.InvalidCommand;
|
|
258
|
+
delta_x = std.fmt.parseFloat(f32, delta_x_part.token) catch return error.InvalidCommand;
|
|
259
|
+
if (!std.math.isFinite(delta_x)) return error.InvalidCommand;
|
|
260
|
+
}
|
|
250
261
|
return .{
|
|
251
262
|
.target = .{ .view_label = view.token, .id = id },
|
|
252
263
|
.delta_y = delta_y,
|
|
264
|
+
.delta_x = delta_x,
|
|
253
265
|
};
|
|
254
266
|
}
|
|
255
267
|
|
|
@@ -627,6 +639,12 @@ test "runtime parses automation widget wheel targets" {
|
|
|
627
639
|
try std.testing.expectEqualStrings("canvas", wheel.target.view_label);
|
|
628
640
|
try std.testing.expectEqual(@as(canvas.ObjectId, 42), wheel.target.id);
|
|
629
641
|
try std.testing.expectEqual(@as(f32, 18.5), wheel.delta_y);
|
|
642
|
+
try std.testing.expectEqual(@as(f32, 0), wheel.delta_x);
|
|
643
|
+
|
|
644
|
+
// The optional fourth token is the horizontal delta.
|
|
645
|
+
const diagonal = try parseAutomationWidgetWheel("canvas 42 18.5 -6");
|
|
646
|
+
try std.testing.expectEqual(@as(f32, 18.5), diagonal.delta_y);
|
|
647
|
+
try std.testing.expectEqual(@as(f32, -6), diagonal.delta_x);
|
|
630
648
|
|
|
631
649
|
try std.testing.expectError(error.InvalidCommand, parseAutomationWidgetWheel(""));
|
|
632
650
|
try std.testing.expectError(error.InvalidCommand, parseAutomationWidgetWheel("canvas"));
|
|
@@ -635,6 +653,7 @@ test "runtime parses automation widget wheel targets" {
|
|
|
635
653
|
try std.testing.expectError(error.InvalidCommand, parseAutomationWidgetWheel("canvas 42 nope"));
|
|
636
654
|
try std.testing.expectError(error.InvalidCommand, parseAutomationWidgetWheel("canvas 42 nan"));
|
|
637
655
|
try std.testing.expectError(error.InvalidCommand, parseAutomationWidgetWheel("canvas 42 18 extra"));
|
|
656
|
+
try std.testing.expectError(error.InvalidCommand, parseAutomationWidgetWheel("canvas 42 18 6 extra"));
|
|
638
657
|
}
|
|
639
658
|
|
|
640
659
|
test "runtime parses automation widget context-menu items" {
|
|
@@ -34,6 +34,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
34
34
|
.frame_profile = automationFrameProfile(self),
|
|
35
35
|
.tray = automationTray(self),
|
|
36
36
|
.audio = automationAudio(self),
|
|
37
|
+
.video = automationVideo(self),
|
|
37
38
|
.errors = self.dispatchErrors(),
|
|
38
39
|
.source = self.loaded_source,
|
|
39
40
|
.widget_node_budget = canvas_limits.max_canvas_widget_nodes_per_view,
|
|
@@ -67,6 +68,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
67
68
|
.frame_profile = automationFrameProfile(self),
|
|
68
69
|
.tray = automationTray(self),
|
|
69
70
|
.audio = automationAudio(self),
|
|
71
|
+
.video = automationVideo(self),
|
|
70
72
|
.errors = self.dispatchErrors(),
|
|
71
73
|
.source = self.loaded_source,
|
|
72
74
|
.widget_node_budget = canvas_limits.max_canvas_widget_nodes_per_view,
|
|
@@ -118,6 +120,28 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
/// Live video playback as the ui-app layer last mirrored it
|
|
124
|
+
/// (`Runtime.video_*`), or null when nothing is loaded — the
|
|
125
|
+
/// audio report's twin. Texture contents stay out of every
|
|
126
|
+
/// snapshot; the transport line plus the surface's placeholder
|
|
127
|
+
/// widget are the automation-visible evidence.
|
|
128
|
+
fn automationVideo(self: *Runtime) ?automation.snapshot.Video {
|
|
129
|
+
if (!self.video_active) return null;
|
|
130
|
+
return .{
|
|
131
|
+
.key = self.video_key,
|
|
132
|
+
.surface = self.video_surface_id,
|
|
133
|
+
.playing = self.video_playing,
|
|
134
|
+
.buffering = self.video_buffering,
|
|
135
|
+
.looping = self.video_looping,
|
|
136
|
+
.muted = self.video_muted,
|
|
137
|
+
.source = @tagName(self.video_source),
|
|
138
|
+
.position_ms = self.video_position_ms,
|
|
139
|
+
.duration_ms = self.video_duration_ms,
|
|
140
|
+
.width = self.video_width,
|
|
141
|
+
.height = self.video_height,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
121
145
|
/// The frame profile's per-stage p50/p90 stats, non-null while
|
|
122
146
|
/// `profile on` is active. Percentile sorting happens HERE — the
|
|
123
147
|
/// snapshot path — never in the frame path; entries land in
|
|
@@ -197,7 +221,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
197
221
|
},
|
|
198
222
|
.virtual_range = canvasVirtualRange(layout.virtualRangeById(node.id)),
|
|
199
223
|
.bounds = node.bounds.translate(geometry.OffsetF.init(view.frame.x, view.frame.y)),
|
|
200
|
-
.focused = node.state.focused or (view.focused and node.id == view.canvas_widget_focused_id),
|
|
224
|
+
.focused = node.state.focused or (view.keyboard_active and view.focused and node.id == view.canvas_widget_focused_id),
|
|
201
225
|
.enabled = !node.state.disabled,
|
|
202
226
|
.hovered = node.state.hovered or (node.id != 0 and node.id == view.canvas_widget_hovered_id),
|
|
203
227
|
.pressed = node.state.pressed or (node.id != 0 and node.id == view.canvas_widget_pressed_id),
|
|
@@ -9,6 +9,7 @@ const runtime_clock = @import("clock.zig");
|
|
|
9
9
|
const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
|
|
10
10
|
const runtime_canvas_widget_display = @import("canvas_widget_display.zig");
|
|
11
11
|
const runtime_canvas_widget_events = @import("canvas_widget_events.zig");
|
|
12
|
+
const runtime_canvas_widget_context_menu = @import("canvas_widget_context_menu.zig");
|
|
12
13
|
|
|
13
14
|
const AutomationWidgetAction = automation_commands.AutomationWidgetAction;
|
|
14
15
|
const AutomationWidgetTarget = automation_commands.AutomationWidgetTarget;
|
|
@@ -197,8 +198,10 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
|
|
|
197
198
|
/// replays, and resolves through `dispatchContextMenuAction`
|
|
198
199
|
/// into the widget's `.context_menu` handler. Named errors say
|
|
199
200
|
/// why an invocation cannot happen: no declared menu, an index
|
|
200
|
-
/// past the declared items, a separator slot,
|
|
201
|
-
///
|
|
201
|
+
/// past the declared items, a separator slot, a disabled item —
|
|
202
|
+
/// the same items the snapshot lists per widget — or a dismissal
|
|
203
|
+
/// handler that presented a superseding menu, or closed the
|
|
204
|
+
/// target's view, mid-verb.
|
|
202
205
|
pub fn dispatchAutomationWidgetContextMenuItem(self: *Runtime, app: runtime_api.App(Runtime), item: automation_commands.AutomationWidgetContextMenuItem) anyerror!void {
|
|
203
206
|
const view_index = try automationWidgetTargetViewIndex(self, item.target);
|
|
204
207
|
const node_index = self.views[view_index].canvasWidgetNodeIndexById(item.target.id) orelse return error.InvalidCommand;
|
|
@@ -209,17 +212,75 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
|
|
|
209
212
|
if (declared.separator) return error.ContextMenuItemSeparator;
|
|
210
213
|
if (!declared.enabled) return error.ContextMenuItemDisabled;
|
|
211
214
|
|
|
212
|
-
|
|
215
|
+
// This direct dispatch supersedes any pending presentation:
|
|
216
|
+
// the replacement request commits first (bookkeeping must
|
|
217
|
+
// match the state the events describe), then the superseded
|
|
218
|
+
// app menu's snapshot/pin release through the fallible
|
|
219
|
+
// dismissed notice.
|
|
220
|
+
const superseded = self.canvas_widget_context_menu_pending;
|
|
221
|
+
const token = runtime_canvas_widget_context_menu.RuntimeCanvasWidgetContextMenu(Runtime).nextContextMenuToken(self);
|
|
222
|
+
var pending: runtime_canvas_widget_context_menu.PendingCanvasWidgetContextMenu = .{
|
|
213
223
|
.window_id = self.views[view_index].window_id,
|
|
214
|
-
.token =
|
|
224
|
+
.token = token,
|
|
225
|
+
.target_id = widget.id,
|
|
215
226
|
.kind = .app,
|
|
216
227
|
};
|
|
228
|
+
pending.setViewLabel(self.views[view_index].label);
|
|
229
|
+
self.canvas_widget_context_menu_pending = pending;
|
|
230
|
+
// The notice keeps its place in the event order (the old
|
|
231
|
+
// menu's dismissal before the successor's outcome, like
|
|
232
|
+
// every superseding path), but its error must not skip the
|
|
233
|
+
// synthetic selection below: unlike a presented menu, whose
|
|
234
|
+
// outcome the platform delivers later regardless, this
|
|
235
|
+
// dispatch is the armed request's ONLY outcome. No error
|
|
236
|
+
// path may leave a pending token with no presented menu and
|
|
237
|
+
// no delivered outcome — so capture the notice's error,
|
|
238
|
+
// dispatch the selection, and re-raise after (the dispatch
|
|
239
|
+
// ring already recorded it, matching `.propagate` semantics
|
|
240
|
+
// elsewhere: bookkeeping settles first, the error still
|
|
241
|
+
// surfaces).
|
|
242
|
+
const notice = runtime_canvas_widget_context_menu.RuntimeCanvasWidgetContextMenu(Runtime).notifySupersededPending(self, app, superseded);
|
|
243
|
+
// The notice ran arbitrary app code that may itself have
|
|
244
|
+
// PRESENTED a menu, superseding this verb's freshly armed
|
|
245
|
+
// request: the synthetic action below would fail the token
|
|
246
|
+
// gate and the command would report success without ever
|
|
247
|
+
// dispatching its item. Refuse by name instead — the
|
|
248
|
+
// handler's successor menu is on the glass with its own
|
|
249
|
+
// pending request, so nothing is orphaned.
|
|
250
|
+
const still_armed = if (self.canvas_widget_context_menu_pending) |current| current.token == token else false;
|
|
251
|
+
if (!still_armed) {
|
|
252
|
+
try notice;
|
|
253
|
+
return error.ContextMenuSuperseded;
|
|
254
|
+
}
|
|
255
|
+
// The notice may instead have CLOSED the verb's target view:
|
|
256
|
+
// the armed request can never resolve (the action dispatch
|
|
257
|
+
// would clear the token, fail its view lookup, and silently
|
|
258
|
+
// drop the selection). Disarm it and refuse by name — never
|
|
259
|
+
// a silent success, never an orphaned token.
|
|
260
|
+
const view_open = view_check: {
|
|
261
|
+
for (self.views[0..self.view_count]) |*view| {
|
|
262
|
+
if (view.open and view.window_id == pending.window_id and std.mem.eql(u8, view.label, pending.viewLabel())) break :view_check true;
|
|
263
|
+
}
|
|
264
|
+
break :view_check false;
|
|
265
|
+
};
|
|
266
|
+
if (!view_open) {
|
|
267
|
+
self.canvas_widget_context_menu_pending = null;
|
|
268
|
+
try notice;
|
|
269
|
+
return error.ContextMenuViewClosed;
|
|
270
|
+
}
|
|
271
|
+
// The synthetic event names its view from the request's own
|
|
272
|
+
// bounded copy, never `self.views[view_index]` re-read here:
|
|
273
|
+
// the notice above ran arbitrary app code that may have
|
|
274
|
+
// closed views and compacted their indices — a stale index
|
|
275
|
+
// would dispatch this target against another view, or strand
|
|
276
|
+
// the pending token behind the action gate's window check.
|
|
217
277
|
try self.dispatchPlatformEvent(app, .{ .context_menu_action = .{
|
|
218
|
-
.window_id =
|
|
219
|
-
.view_label =
|
|
220
|
-
.token =
|
|
278
|
+
.window_id = pending.window_id,
|
|
279
|
+
.view_label = pending.viewLabel(),
|
|
280
|
+
.token = token,
|
|
221
281
|
.item_id = @intCast(item.item_index + 1),
|
|
222
282
|
} });
|
|
283
|
+
try notice;
|
|
223
284
|
}
|
|
224
285
|
|
|
225
286
|
/// Where a pointer verb lands on a widget: the control's aim
|
|
@@ -260,6 +321,7 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
|
|
|
260
321
|
.timestamp_ns = timestamp_ns,
|
|
261
322
|
.x = point.x,
|
|
262
323
|
.y = point.y,
|
|
324
|
+
.delta_x = wheel.delta_x,
|
|
263
325
|
.delta_y = wheel.delta_y,
|
|
264
326
|
} });
|
|
265
327
|
}
|
|
@@ -423,7 +485,7 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
|
|
|
423
485
|
// moves focus with the visible ring. Without this gate, a
|
|
424
486
|
// window-level default focus landing on a button dressed an
|
|
425
487
|
// idle control in the focus ring.
|
|
426
|
-
const focus_visible_id: canvas.ObjectId = if (canvas_widget_runtime.
|
|
488
|
+
const focus_visible_id: canvas.ObjectId = if (canvas_widget_runtime.canvasWidgetShowsPointerFocusRing(target.kind)) target.id else 0;
|
|
427
489
|
if (self.views[view_index].canvas_widget_focused_id != target.id or self.views[view_index].canvas_widget_focus_visible_id != focus_visible_id) {
|
|
428
490
|
const previous_state = self.views[view_index].canvasWidgetRenderState();
|
|
429
491
|
self.views[view_index].canvas_widget_focused_id = target.id;
|
|
@@ -590,6 +652,9 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
|
|
|
590
652
|
.view_label = self.views[view_index].label,
|
|
591
653
|
.keyboard = .{ .phase = .key_down, .focused_id = id, .edit = edit },
|
|
592
654
|
.target = target,
|
|
655
|
+
// No gpu-surface input cycle wraps this selection edit:
|
|
656
|
+
// the ui-app hover drain runs at its own tail.
|
|
657
|
+
.standalone = true,
|
|
593
658
|
};
|
|
594
659
|
// Same observability contract as selectAutomationCanvasWidget:
|
|
595
660
|
// the repaint this edit triggers must publish its completing
|
|
@@ -117,6 +117,7 @@ pub fn platformFeatureFromString(value: []const u8) ?platform.PlatformFeature {
|
|
|
117
117
|
if (std.mem.eql(u8, value, "audioStreaming")) return .audio_streaming;
|
|
118
118
|
if (std.mem.eql(u8, value, "audioSpectrum")) return .audio_spectrum;
|
|
119
119
|
if (std.mem.eql(u8, value, "windowHideOnClose")) return .window_hide_on_close;
|
|
120
|
+
if (std.mem.eql(u8, value, "videoPlayback")) return .video_playback;
|
|
120
121
|
return null;
|
|
121
122
|
}
|
|
122
123
|
|