@native-sdk/cli 0.5.4 → 0.6.1
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 +588 -32
- 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 +1368 -74
- 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 +76 -6
- 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 +268 -26
- 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 +475 -15
- 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 +114 -19
- 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 +2338 -67
- 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
|
@@ -1,43 +1,79 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const layout_fingerprint = @import("layout_fingerprint.zig");
|
|
2
3
|
|
|
3
4
|
pub const default_dir = ".zig-cache/native-sdk-automation";
|
|
4
5
|
pub const max_command_bytes: usize = 16 * 1024 + 64;
|
|
5
6
|
|
|
6
|
-
/// CLI <-> app dropbox protocol
|
|
7
|
-
///
|
|
8
|
-
/// header (`protocol=
|
|
9
|
-
/// its own — so a stale `native` binary driving a
|
|
10
|
-
/// the reverse) fails loudly, naming both
|
|
11
|
-
/// reading yesterday's state.
|
|
12
|
-
/// would misread: the dropbox directory name, the snapshot header/format,
|
|
13
|
-
/// or the command vocabulary.
|
|
7
|
+
/// CLI <-> app dropbox protocol identity. Both binaries bake this
|
|
8
|
+
/// fingerprint at THEIR build time: the app stamps it into every
|
|
9
|
+
/// snapshot header (`protocol=0x...`), the CLI refuses a snapshot whose
|
|
10
|
+
/// fingerprint is not its own — so a stale `native` binary driving a
|
|
11
|
+
/// freshly built app (or the reverse) fails loudly, naming both
|
|
12
|
+
/// fingerprints, instead of silently reading yesterday's state.
|
|
14
13
|
///
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
///
|
|
18
|
-
///
|
|
19
|
-
///
|
|
20
|
-
///
|
|
21
|
-
///
|
|
22
|
-
///
|
|
23
|
-
///
|
|
24
|
-
///
|
|
25
|
-
///
|
|
26
|
-
///
|
|
27
|
-
///
|
|
28
|
-
///
|
|
29
|
-
///
|
|
14
|
+
/// This replaces the manually-bumped integer counter the handshake
|
|
15
|
+
/// carried through v8. No skew is ever migrated — both sides always
|
|
16
|
+
/// rebuild from one checkout — so an ORDERED version carried no
|
|
17
|
+
/// information ("same or different" is the entire question) while
|
|
18
|
+
/// costing two recurring failures: parallel branches contending for the
|
|
19
|
+
/// next integer, and forgettable bumps. The fingerprint is a comptime
|
|
20
|
+
/// Wyhash over a canonical description of the protocol surface this
|
|
21
|
+
/// file declares (see `layoutDescription`), so any change to that
|
|
22
|
+
/// surface moves the identity with no manual step.
|
|
23
|
+
///
|
|
24
|
+
/// History of the retired integer counter, kept because the refusal
|
|
25
|
+
/// teachings it produced are still in the field: 1 = the first stamped
|
|
26
|
+
/// version (post-rename dropbox `.zig-cache/native-sdk-automation`,
|
|
27
|
+
/// publisher_pid liveness, stdout payloads). 2 = the gesture verbs
|
|
28
|
+
/// (`widget-hold`, `widget-context-press`) and per-window snapshot
|
|
29
|
+
/// view/widget scoping. 3 = the `profile on|off` verb and the
|
|
30
|
+
/// snapshot's `frame_profile` per-stage timing line. 4 = the
|
|
31
|
+
/// `provenance` verb (widget id or point -> authored markup) and its
|
|
32
|
+
/// `provenance.txt` response artifact, the write-back read half. 5 =
|
|
33
|
+
/// the `widget-context-menu` verb and the snapshot's per-widget
|
|
34
|
+
/// `context_menu=[...]` item listing. 6 = the queued command dropbox:
|
|
35
|
+
/// numbered `command-<n>.txt` entries replace the single-entry
|
|
30
36
|
/// `command.txt` slot that rapid back-to-back writers could overwrite
|
|
31
|
-
/// before the app drained it
|
|
32
|
-
///
|
|
33
|
-
///
|
|
34
|
-
///
|
|
35
|
-
///
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
///
|
|
39
|
-
///
|
|
40
|
-
|
|
37
|
+
/// before the app drained it (snapshots without a `protocol=` field
|
|
38
|
+
/// predate the handshake entirely). 7 = the `widget-pinch` verb. 8 =
|
|
39
|
+
/// context-menu action tokens as per-request generations, not widget
|
|
40
|
+
/// ids — a SEMANTIC break with identical bytes, exactly the shape
|
|
41
|
+
/// `semantic_epoch` now expresses.
|
|
42
|
+
pub const fingerprint: u64 = layout_fingerprint.hash(layoutDescription(semantic_epoch));
|
|
43
|
+
|
|
44
|
+
/// The escape hatch for protocol changes `layoutDescription` cannot
|
|
45
|
+
/// see. Bump this ONLY for: a same-bytes MEANING change (the
|
|
46
|
+
/// per-request context-menu action-token generations were exactly that
|
|
47
|
+
/// — identical layout, values a stale peer could never match), a
|
|
48
|
+
/// snapshot text-format change a stale binary would misread
|
|
49
|
+
/// (snapshot.zig hand-writes that layout), or a verb spelling change in
|
|
50
|
+
/// `Command.parse` (the wire strings live there, not in the `Action`
|
|
51
|
+
/// enum). Declared-shape changes — new verbs, renamed actions, budget
|
|
52
|
+
/// or naming changes — need NO action here: the fingerprint moves on
|
|
53
|
+
/// its own.
|
|
54
|
+
pub const semantic_epoch: u32 = 1;
|
|
55
|
+
|
|
56
|
+
/// The canonical description the protocol fingerprint hashes: the
|
|
57
|
+
/// command vocabulary (the `Action` enum, reflected — names and values,
|
|
58
|
+
/// so additions, removals, renames, and reorders all move the
|
|
59
|
+
/// identity), the `Command` shape, the dropbox directory and
|
|
60
|
+
/// queue-entry naming, and the size budgets. Deliberate constants cover
|
|
61
|
+
/// what reflection cannot see; anything else invisible to this string
|
|
62
|
+
/// is `semantic_epoch`'s job (see its doc).
|
|
63
|
+
fn layoutDescription(comptime epoch: u32) []const u8 {
|
|
64
|
+
comptime {
|
|
65
|
+
@setEvalBranchQuota(200_000);
|
|
66
|
+
return "native-sdk automation protocol layout\n" ++
|
|
67
|
+
std.fmt.comptimePrint("semantic_epoch={d}\n", .{epoch}) ++
|
|
68
|
+
"dropbox_dir=" ++ default_dir ++ "\n" ++
|
|
69
|
+
"queue_entry=" ++ queue_file_prefix ++ "<n>" ++ queue_file_suffix ++ "\n" ++
|
|
70
|
+
std.fmt.comptimePrint("max_command_bytes={d} max_queued_commands={d} max_screenshot_label_bytes={d}\n", .{
|
|
71
|
+
max_command_bytes, max_queued_commands, max_screenshot_label_bytes,
|
|
72
|
+
}) ++
|
|
73
|
+
"actions=" ++ layout_fingerprint.describe(Action) ++ "\n" ++
|
|
74
|
+
"command=" ++ layout_fingerprint.describe(Command) ++ "\n";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
41
77
|
|
|
42
78
|
/// How many commands may sit in the dropbox queue at once. Automation
|
|
43
79
|
/// drivers are scripts, not firehoses: the app drains one command per
|
|
@@ -294,6 +330,19 @@ test "queue entry names round-trip and reject non-queue files" {
|
|
|
294
330
|
try std.testing.expectEqual(@as(?u64, null), queueFileSequence("bridge-response.txt"));
|
|
295
331
|
}
|
|
296
332
|
|
|
333
|
+
test "semantic epoch moves the protocol fingerprint" {
|
|
334
|
+
// Same layout, bumped epoch: the combined identity must move, so a
|
|
335
|
+
// meaning-only change still refuses stale peers loudly.
|
|
336
|
+
const bumped = layout_fingerprint.hash(comptime layoutDescription(semantic_epoch + 1));
|
|
337
|
+
try std.testing.expect(bumped != fingerprint);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
test {
|
|
341
|
+
// The description builder's own suite (including the pinned proof
|
|
342
|
+
// that an added field moves a fingerprint with no manual step).
|
|
343
|
+
_ = layout_fingerprint;
|
|
344
|
+
}
|
|
345
|
+
|
|
297
346
|
test "screenshot file names stay inside the automation directory" {
|
|
298
347
|
var buffer: [128]u8 = undefined;
|
|
299
348
|
try std.testing.expectEqualStrings("screenshot-inbox-canvas.png", try screenshotFileName("inbox-canvas", &buffer));
|
package/src/automation/root.zig
CHANGED
|
@@ -448,7 +448,7 @@ test "server reports pending commands without consuming them" {
|
|
|
448
448
|
|
|
449
449
|
// An empty dropbox is idle, and so is one holding only non-queue
|
|
450
450
|
// files — response artifacts and, pointedly, a retired-v5 writer's
|
|
451
|
-
// `command.txt` slot, which this protocol
|
|
451
|
+
// `command.txt` slot, which this protocol must never consume
|
|
452
452
|
// (acking it would tell that stale CLI its command dispatched).
|
|
453
453
|
try std.testing.expect(!server.hasPendingCommand());
|
|
454
454
|
try writePath(std.testing.io, server.path("command.txt", &path_buffer), "widget-click canvas 7\n");
|
|
@@ -73,11 +73,26 @@ pub const FrameProfile = struct {
|
|
|
73
73
|
/// verb targeted.
|
|
74
74
|
pub const DispatchError = struct {
|
|
75
75
|
timestamp_ns: u64 = 0,
|
|
76
|
-
|
|
76
|
+
event_storage: [max_dispatch_error_event_bytes]u8 = undefined,
|
|
77
|
+
event_len: u8 = 0,
|
|
77
78
|
error_name: []const u8 = "",
|
|
78
79
|
detail_storage: [max_dispatch_error_detail_bytes]u8 = undefined,
|
|
79
80
|
detail_len: u8 = 0,
|
|
80
81
|
|
|
82
|
+
/// The event name is INLINE storage like `detail`, never a borrowed
|
|
83
|
+
/// slice: records are copied by value into a ring that outlives any
|
|
84
|
+
/// caller's buffer, so a name passed from stack or reusable storage
|
|
85
|
+
/// must be owned at record time.
|
|
86
|
+
pub fn event(self: *const DispatchError) []const u8 {
|
|
87
|
+
return self.event_storage[0..self.event_len];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pub fn setEvent(self: *DispatchError, text: []const u8) void {
|
|
91
|
+
const len = @min(text.len, self.event_storage.len);
|
|
92
|
+
@memcpy(self.event_storage[0..len], text[0..len]);
|
|
93
|
+
self.event_len = @intCast(len);
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
pub fn detail(self: *const DispatchError) []const u8 {
|
|
82
97
|
return self.detail_storage[0..self.detail_len];
|
|
83
98
|
}
|
|
@@ -89,6 +104,10 @@ pub const DispatchError = struct {
|
|
|
89
104
|
}
|
|
90
105
|
};
|
|
91
106
|
|
|
107
|
+
/// Event-name bytes kept per degraded dispatch error (a truncated copy,
|
|
108
|
+
/// owned by the record — the ring outlives every caller's buffer).
|
|
109
|
+
pub const max_dispatch_error_event_bytes: usize = 64;
|
|
110
|
+
|
|
92
111
|
/// Detail context kept per degraded dispatch error (a truncated copy of
|
|
93
112
|
/// the failing automation command's arguments).
|
|
94
113
|
pub const max_dispatch_error_detail_bytes: usize = 48;
|
|
@@ -238,6 +257,29 @@ pub const Audio = struct {
|
|
|
238
257
|
spectrum_bands: []const u8 = &.{},
|
|
239
258
|
};
|
|
240
259
|
|
|
260
|
+
/// Live video playback state (the effects channel's single player), as
|
|
261
|
+
/// the runtime last mirrored it — the audio snapshot's twin. The
|
|
262
|
+
/// advancing `position_ms` and the `.loaded` dimensions are the
|
|
263
|
+
/// automation-visible evidence a video is actually decoding; `surface`
|
|
264
|
+
/// names the media-surface texture channel its frames feed. Like the
|
|
265
|
+
/// media-surface texture itself, this line prints in the FULL snapshot
|
|
266
|
+
/// only, never the a11y text session fingerprints hash — playback
|
|
267
|
+
/// transport is journaled effect truth, not tree state, so a replay
|
|
268
|
+
/// with no producer stays fingerprint-identical by construction.
|
|
269
|
+
pub const Video = struct {
|
|
270
|
+
key: u64 = 0,
|
|
271
|
+
surface: u64 = 0,
|
|
272
|
+
playing: bool = false,
|
|
273
|
+
buffering: bool = false,
|
|
274
|
+
looping: bool = false,
|
|
275
|
+
muted: bool = false,
|
|
276
|
+
source: []const u8 = "local",
|
|
277
|
+
position_ms: u64 = 0,
|
|
278
|
+
duration_ms: u64 = 0,
|
|
279
|
+
width: u64 = 0,
|
|
280
|
+
height: u64 = 0,
|
|
281
|
+
};
|
|
282
|
+
|
|
241
283
|
pub const Input = struct {
|
|
242
284
|
windows: []const Window,
|
|
243
285
|
views: []const platform.ViewInfo = &.{},
|
|
@@ -263,6 +305,8 @@ pub const Input = struct {
|
|
|
263
305
|
/// Live audio playback, when the app started any (null once stopped
|
|
264
306
|
/// or failed — an idle player is honest, not zeroed-out noise).
|
|
265
307
|
audio: ?Audio = null,
|
|
308
|
+
/// Live video playback, same contract as `audio`.
|
|
309
|
+
video: ?Video = null,
|
|
266
310
|
/// The most recent degraded dispatch errors, oldest first (bounded
|
|
267
311
|
/// ring; `diagnostics.dispatch_error_count` is the lifetime total).
|
|
268
312
|
errors: []const DispatchError = &.{},
|
|
@@ -271,11 +315,11 @@ pub const Input = struct {
|
|
|
271
315
|
|
|
272
316
|
pub fn writeText(input: Input, writer: anytype) !void {
|
|
273
317
|
// `protocol=` is the CLI/app handshake: the publishing app
|
|
274
|
-
// stamps ITS baked-in protocol
|
|
275
|
-
// (or a stale app) is refused loudly instead of silently
|
|
276
|
-
// yesterday's dropbox shape.
|
|
277
|
-
try writer.print("ready=true protocol={
|
|
278
|
-
protocol.
|
|
318
|
+
// stamps ITS baked-in protocol fingerprint so a stale `native`
|
|
319
|
+
// binary (or a stale app) is refused loudly instead of silently
|
|
320
|
+
// driving yesterday's dropbox shape.
|
|
321
|
+
try writer.print("ready=true protocol=0x{x:0>16} frame={d} commands={d} runtime_uptime_ns={d} dispatch_errors={d} dropped_trace_records={d} publisher_pid={d} markup_watch={s}\n", .{
|
|
322
|
+
protocol.fingerprint,
|
|
279
323
|
input.diagnostics.frame_index,
|
|
280
324
|
input.diagnostics.command_count,
|
|
281
325
|
input.diagnostics.runtime_uptime_ns,
|
|
@@ -577,17 +621,32 @@ pub fn writeText(input: Input, writer: anytype) !void {
|
|
|
577
621
|
}
|
|
578
622
|
try writer.print("\n", .{});
|
|
579
623
|
}
|
|
624
|
+
if (input.video) |video| {
|
|
625
|
+
try writer.print("video key={d} surface={d} state={s} source={s} position_ms={d} duration_ms={d} dimensions={d}x{d} loop={any} muted={any}\n", .{
|
|
626
|
+
video.key,
|
|
627
|
+
video.surface,
|
|
628
|
+
// The audio line's honest third state, verbatim.
|
|
629
|
+
if (video.buffering) "buffering" else if (video.playing) "playing" else "paused",
|
|
630
|
+
video.source,
|
|
631
|
+
video.position_ms,
|
|
632
|
+
video.duration_ms,
|
|
633
|
+
video.width,
|
|
634
|
+
video.height,
|
|
635
|
+
video.looping,
|
|
636
|
+
video.muted,
|
|
637
|
+
});
|
|
638
|
+
}
|
|
580
639
|
for (input.errors) |dispatch_error| {
|
|
581
640
|
if (dispatch_error.detail_len > 0) {
|
|
582
641
|
try writer.print(" error event={s} name={s} detail=\"{s}\" timestamp_ns={d}\n", .{
|
|
583
|
-
dispatch_error.event,
|
|
642
|
+
dispatch_error.event(),
|
|
584
643
|
dispatch_error.error_name,
|
|
585
644
|
dispatch_error.detail(),
|
|
586
645
|
dispatch_error.timestamp_ns,
|
|
587
646
|
});
|
|
588
647
|
} else {
|
|
589
648
|
try writer.print(" error event={s} name={s} timestamp_ns={d}\n", .{
|
|
590
|
-
dispatch_error.event,
|
|
649
|
+
dispatch_error.event(),
|
|
591
650
|
dispatch_error.error_name,
|
|
592
651
|
dispatch_error.timestamp_ns,
|
|
593
652
|
});
|
|
@@ -809,7 +868,7 @@ test "snapshot emits window and source" {
|
|
|
809
868
|
try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "runtime_uptime_ns=42") != null);
|
|
810
869
|
try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "publisher_pid=4242") != null);
|
|
811
870
|
var protocol_field_buffer: [32]u8 = undefined;
|
|
812
|
-
const protocol_field = try std.fmt.bufPrint(&protocol_field_buffer, "protocol={
|
|
871
|
+
const protocol_field = try std.fmt.bufPrint(&protocol_field_buffer, "protocol=0x{x:0>16} ", .{protocol.fingerprint});
|
|
813
872
|
try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), protocol_field) != null);
|
|
814
873
|
try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "@w1") != null);
|
|
815
874
|
try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "view @w1/main kind=webview") != null);
|
|
@@ -134,7 +134,7 @@ test "watcher requests frames while a command is pending" {
|
|
|
134
134
|
// Idle queue: give the watcher a few polls; no frame requests. A
|
|
135
135
|
// leftover non-queue file (a retired-v5 writer's `command.txt`)
|
|
136
136
|
// stays invisible — the watcher must not wake the loop for traffic
|
|
137
|
-
// this protocol
|
|
137
|
+
// this protocol never consumes.
|
|
138
138
|
var path_buffer: [96]u8 = undefined;
|
|
139
139
|
try cwd.writeFile(std.testing.io, .{
|
|
140
140
|
.sub_path = try std.fmt.bufPrint(&path_buffer, "{s}/command.txt", .{directory}),
|
package/src/embed/host.zig
CHANGED
|
@@ -725,6 +725,11 @@ pub const MobileHostApp = struct {
|
|
|
725
725
|
// below so the runtime's service table starts without audio.
|
|
726
726
|
self.null_platform.audio_playback = false;
|
|
727
727
|
self.null_platform.audio_streaming = false;
|
|
728
|
+
// Video is declined the same way: no mobile shim registers a
|
|
729
|
+
// decoder yet, and the null platform's fake player belongs to
|
|
730
|
+
// hermetic tests — a load that "succeeds" but never decodes
|
|
731
|
+
// would be a lie. Apps hear one honest failed event instead.
|
|
732
|
+
self.null_platform.video_playback = false;
|
|
728
733
|
self.last_error = null;
|
|
729
734
|
self.activation_count = 0;
|
|
730
735
|
self.deactivation_count = 0;
|
package/src/embed/ui_host.zig
CHANGED
|
@@ -178,6 +178,19 @@ pub fn UiAppHost(comptime AppDef: type) type {
|
|
|
178
178
|
// its heap-owned registrations (registered canvas font
|
|
179
179
|
// bytes) before the host storage goes.
|
|
180
180
|
self.embedded.deinit();
|
|
181
|
+
// The embedded null platform lives inside `self`, so freeing
|
|
182
|
+
// `self` IS this path's platform destruction — and an
|
|
183
|
+
// abandoned channel wake call may still enter that platform
|
|
184
|
+
// at any later time (see
|
|
185
|
+
// `PlatformServices.note_channel_wake_abandoned_fn`; the
|
|
186
|
+
// null platform's own enqueue-only wake never triggers it,
|
|
187
|
+
// but a shim-registered service could). Consult the latch
|
|
188
|
+
// like every first-party destroy path: skip the free and
|
|
189
|
+
// leak the host storage, process-lived, with one loud line.
|
|
190
|
+
if (self.null_platform.channel_wake_abandoned.load(.seq_cst)) {
|
|
191
|
+
std.debug.print("mobile ui host teardown: an abandoned channel wake call may still enter the embedded platform; skipping the host free and leaking it, process-lived, so the stale call stays safe\n", .{});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
181
194
|
std.heap.page_allocator.destroy(self);
|
|
182
195
|
}
|
|
183
196
|
|