@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
|
@@ -58,6 +58,19 @@ const SessionModel = struct {
|
|
|
58
58
|
zoom: f32 = 1,
|
|
59
59
|
pinch_begins: u32 = 0,
|
|
60
60
|
pinch_ends: u32 = 0,
|
|
61
|
+
/// Hover-Msg counters: the reference session moves the pointer onto
|
|
62
|
+
/// the increment button (a hover listener) and off again, so the
|
|
63
|
+
/// journal records only the raw pointer moves and replay must
|
|
64
|
+
/// re-derive the same enter/leave containment edges.
|
|
65
|
+
hover_enters: u32 = 0,
|
|
66
|
+
hover_leaves: u32 = 0,
|
|
67
|
+
/// The two-axis shelf's `on_scroll` mirror: a recorded diagonal
|
|
68
|
+
/// wheel must replay to the identical per-axis offsets — the
|
|
69
|
+
/// journal records only the raw scroll input event (both deltas),
|
|
70
|
+
/// and replay re-derives the same per-axis routing and physics.
|
|
71
|
+
shelf_offset_x: f32 = 0,
|
|
72
|
+
shelf_offset_y: f32 = 0,
|
|
73
|
+
shelf_scrolls: u32 = 0,
|
|
61
74
|
|
|
62
75
|
fn bodyText(self: *const SessionModel) []const u8 {
|
|
63
76
|
return self.body[0..self.body_len];
|
|
@@ -82,11 +95,14 @@ const SessionMsg = union(enum) {
|
|
|
82
95
|
query_edit: canvas.TextInputEvent,
|
|
83
96
|
name_edit: canvas.TextInputEvent,
|
|
84
97
|
pinch: platform.PinchEvent,
|
|
98
|
+
hover_enter,
|
|
99
|
+
hover_leave,
|
|
85
100
|
fetched: effects_mod.EffectResponse,
|
|
86
101
|
line: effects_mod.EffectLine,
|
|
87
102
|
exited: effects_mod.EffectExit,
|
|
88
103
|
tick: effects_mod.EffectTimer,
|
|
89
104
|
audio_event: effects_mod.EffectAudio,
|
|
105
|
+
shelf_scrolled: canvas.ScrollState,
|
|
90
106
|
};
|
|
91
107
|
|
|
92
108
|
const SessionApp = ui_app_mod.UiApp(SessionModel, SessionMsg);
|
|
@@ -114,6 +130,11 @@ fn sessionUpdate(model: *SessionModel, msg: SessionMsg, fx: *SessionApp.Effects)
|
|
|
114
130
|
.on_fire = SessionApp.Effects.timerMsg(.tick),
|
|
115
131
|
});
|
|
116
132
|
},
|
|
133
|
+
.shelf_scrolled => |scroll_state| {
|
|
134
|
+
model.shelf_offset_x = scroll_state.offset_x;
|
|
135
|
+
model.shelf_offset_y = scroll_state.offset_y;
|
|
136
|
+
model.shelf_scrolls += 1;
|
|
137
|
+
},
|
|
117
138
|
.start_audio => fx.playAudio(.{
|
|
118
139
|
.key = 9,
|
|
119
140
|
.path = "assets/session-track.mp3",
|
|
@@ -133,6 +154,8 @@ fn sessionUpdate(model: *SessionModel, msg: SessionMsg, fx: *SessionApp.Effects)
|
|
|
133
154
|
},
|
|
134
155
|
.query_edit => |edit| applyMirrorEdit(&model.query, &model.query_len, &model.query_anchor, &model.query_focus, &model.query_edits, edit),
|
|
135
156
|
.name_edit => |edit| applyMirrorEdit(&model.name, &model.name_len, &model.name_anchor, &model.name_focus, &model.name_edits, edit),
|
|
157
|
+
.hover_enter => model.hover_enters += 1,
|
|
158
|
+
.hover_leave => model.hover_leaves += 1,
|
|
136
159
|
.pinch => |pinch| switch (pinch.phase) {
|
|
137
160
|
.begin => model.pinch_begins += 1,
|
|
138
161
|
.change => model.zoom *= (1 + pinch.scale),
|
|
@@ -184,7 +207,12 @@ fn sessionView(ui: *SessionApp.Ui, model: *const SessionModel) SessionApp.Ui.Nod
|
|
|
184
207
|
ui.el(.textarea, .{ .text = "line one\nline two" }, .{}),
|
|
185
208
|
ui.text(.{}, ui.fmt("Query {s} ({d}) Name {s} ({d})", .{ model.queryText(), model.query_edits, model.nameText(), model.name_edits })),
|
|
186
209
|
ui.text(.{}, ui.fmt("Zoom {d:.4} ({d}/{d})", .{ model.zoom, model.pinch_begins, model.pinch_ends })),
|
|
187
|
-
ui.
|
|
210
|
+
ui.text(.{}, ui.fmt("Hover {d}/{d}", .{ model.hover_enters, model.hover_leaves })),
|
|
211
|
+
// A BOTH-axes scroll region wider and taller than its viewport:
|
|
212
|
+
// the recorded diagonal wheel below scrolls it on both axes.
|
|
213
|
+
ui.scroll(.{ .height = 60, .axis = .both, .on_scroll = SessionApp.Ui.scrollMsg(.shelf_scrolled) }, ui.el(.panel, .{ .width = 600, .height = 200 }, .{})),
|
|
214
|
+
ui.text(.{}, ui.fmt("Shelf {d:.1},{d:.1} ({d})", .{ model.shelf_offset_x, model.shelf_offset_y, model.shelf_scrolls })),
|
|
215
|
+
ui.button(.{ .on_press = .increment, .on_hover_enter = .hover_enter, .on_hover_leave = .hover_leave }, "Increment"),
|
|
188
216
|
});
|
|
189
217
|
}
|
|
190
218
|
|
|
@@ -456,6 +484,52 @@ fn recordReferenceSession(gpa: std.mem.Allocator, buffer: *JournalBuffer, web_la
|
|
|
456
484
|
try harness.runtime.dispatchAutomationCommand(app, pinch_command);
|
|
457
485
|
try harness.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
458
486
|
|
|
487
|
+
// Hover containment edges from raw journaled moves: onto the
|
|
488
|
+
// increment button (a hover listener), then off — replay re-derives
|
|
489
|
+
// the same enter/leave Msgs from the pointer events alone.
|
|
490
|
+
var button_frame: ?geometry.RectF = null;
|
|
491
|
+
for ((try harness.runtime.canvasWidgetLayout(1, canvas_label)).nodes) |node| {
|
|
492
|
+
if (node.widget.kind == .button) button_frame = node.frame;
|
|
493
|
+
}
|
|
494
|
+
const hover_frame = button_frame.?;
|
|
495
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
496
|
+
.window_id = 1,
|
|
497
|
+
.label = canvas_label,
|
|
498
|
+
.kind = .pointer_move,
|
|
499
|
+
.x = hover_frame.x + hover_frame.width * 0.5,
|
|
500
|
+
.y = hover_frame.y + hover_frame.height * 0.5,
|
|
501
|
+
} });
|
|
502
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
503
|
+
.window_id = 1,
|
|
504
|
+
.label = canvas_label,
|
|
505
|
+
.kind = .pointer_move,
|
|
506
|
+
.x = 2,
|
|
507
|
+
.y = 2,
|
|
508
|
+
} });
|
|
509
|
+
try harness.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
510
|
+
// A DIAGONAL wheel over the both-axes shelf: one recorded scroll
|
|
511
|
+
// input event carrying both deltas. Per-axis routing applies both
|
|
512
|
+
// (the shelf grants both axes), and the on_scroll observation
|
|
513
|
+
// mirrors the applied offsets into the model — replay must land on
|
|
514
|
+
// the identical pair from the raw journaled event alone.
|
|
515
|
+
var shelf_frame: ?geometry.RectF = null;
|
|
516
|
+
for ((try harness.runtime.canvasWidgetLayout(1, canvas_label)).nodes) |node| {
|
|
517
|
+
if (node.widget.kind == .scroll_view) shelf_frame = node.frame;
|
|
518
|
+
}
|
|
519
|
+
const shelf = shelf_frame.?;
|
|
520
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
521
|
+
.window_id = 1,
|
|
522
|
+
.label = canvas_label,
|
|
523
|
+
.kind = .scroll,
|
|
524
|
+
.x = shelf.x + shelf.width * 0.5,
|
|
525
|
+
.y = shelf.y + shelf.height * 0.5,
|
|
526
|
+
.delta_x = 30,
|
|
527
|
+
.delta_y = 24,
|
|
528
|
+
} });
|
|
529
|
+
try harness.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
530
|
+
try std.testing.expectEqual(@as(f32, 30), app_state.model.shelf_offset_x);
|
|
531
|
+
try std.testing.expectEqual(@as(f32, 24), app_state.model.shelf_offset_y);
|
|
532
|
+
|
|
459
533
|
recorder.finish();
|
|
460
534
|
try std.testing.expect(!recorder.failed);
|
|
461
535
|
|
|
@@ -508,16 +582,24 @@ test "a recorded session replays to identical model state and fingerprints" {
|
|
|
508
582
|
try std.testing.expect(recorded.model.stamp_ms != 0);
|
|
509
583
|
try std.testing.expectEqual(@as(u32, 1), recorded.model.spectrum_count);
|
|
510
584
|
try std.testing.expect(recorded.model.band_checksum != 0);
|
|
511
|
-
//
|
|
512
|
-
// multi-line paste all reached the
|
|
513
|
-
//
|
|
514
|
-
|
|
585
|
+
// Both pointer caret placements, the typed insert, the DERIVED
|
|
586
|
+
// Escape-clear, and the sanitized multi-line paste all reached the
|
|
587
|
+
// model's `on_input` mirror — five edits total, with the paste
|
|
588
|
+
// landing STRIPPED of its line breaks (single-line rule).
|
|
589
|
+
try std.testing.expectEqual(@as(u32, 5), recorded.model.query_edits);
|
|
515
590
|
try std.testing.expectEqualStrings("line oneline two", recorded.model.queryText());
|
|
516
591
|
// Both pinch gestures reached the model: the raw stream's product
|
|
517
592
|
// (1.25 * 0.75 = 0.9375) times the verb's exact 1.5.
|
|
518
593
|
try std.testing.expectEqual(@as(u32, 2), recorded.model.pinch_begins);
|
|
519
594
|
try std.testing.expectEqual(@as(u32, 2), recorded.model.pinch_ends);
|
|
520
595
|
try std.testing.expectEqual(@as(f32, 1.40625), recorded.model.zoom);
|
|
596
|
+
// The hover moves dispatched exactly one containment pair.
|
|
597
|
+
try std.testing.expectEqual(@as(u32, 1), recorded.model.hover_enters);
|
|
598
|
+
try std.testing.expectEqual(@as(u32, 1), recorded.model.hover_leaves);
|
|
599
|
+
// The diagonal wheel reached both axes of the shelf.
|
|
600
|
+
try std.testing.expectEqual(@as(f32, 30), recorded.model.shelf_offset_x);
|
|
601
|
+
try std.testing.expectEqual(@as(f32, 24), recorded.model.shelf_offset_y);
|
|
602
|
+
try std.testing.expect(recorded.model.shelf_scrolls > 0);
|
|
521
603
|
|
|
522
604
|
const replayed = try replayIntoFreshApp(gpa, buffer.journalBytes(), true);
|
|
523
605
|
try std.testing.expect(replayed.report.ok());
|
|
@@ -2812,12 +2894,23 @@ test "a journal referencing blobs refuses to replay without its blob store" {
|
|
|
2812
2894
|
try std.testing.expectError(error.ReplayMissingBlob, result);
|
|
2813
2895
|
}
|
|
2814
2896
|
|
|
2815
|
-
///
|
|
2816
|
-
///
|
|
2817
|
-
///
|
|
2818
|
-
///
|
|
2819
|
-
///
|
|
2820
|
-
///
|
|
2897
|
+
/// Bytes of the trailer at the END of every effect payload after the
|
|
2898
|
+
/// image fields (see `journal.encodeEffect`): the v8 channel fields —
|
|
2899
|
+
/// channel_kind (1), channel_dropped_total (4) — then the video
|
|
2900
|
+
/// fields — video_kind (1), position (8), duration (8), playing (1),
|
|
2901
|
+
/// buffering (1), width (8), height (8), token (8), source (1),
|
|
2902
|
+
/// handled (1) — then the pty fields — pty_kind (1), pty_signal (4),
|
|
2903
|
+
/// pty_dropped_writes (4), pty_blob_hash (16), pty_blob_len (8). The
|
|
2904
|
+
/// image fields the damage helpers below patch sit immediately before
|
|
2905
|
+
/// it.
|
|
2906
|
+
const effect_post_image_trailer_len: usize = 83;
|
|
2907
|
+
|
|
2908
|
+
/// Zero the `image_blob_len` field — the last eight bytes before the
|
|
2909
|
+
/// post-image trailer of the effect payload, see `journal.encodeEffect`
|
|
2910
|
+
/// — of the first journaled `.loaded` image record, in place. Framing
|
|
2911
|
+
/// and every other field stay valid, so the journal reader decodes the
|
|
2912
|
+
/// record fine: only replay's record-consistency gate can catch the
|
|
2913
|
+
/// damage. Returns whether a record was damaged.
|
|
2821
2914
|
fn zeroFirstLoadedImageBlobLen(bytes: []u8) bool {
|
|
2822
2915
|
var pos: usize = journal.preamble_len;
|
|
2823
2916
|
while (bytes.len - pos >= 5) {
|
|
@@ -2828,7 +2921,8 @@ fn zeroFirstLoadedImageBlobLen(bytes: []u8) bool {
|
|
|
2828
2921
|
if (kind != @intFromEnum(journal.RecordKind.effect)) continue;
|
|
2829
2922
|
const record = journal.decodeEffect(payload) catch continue;
|
|
2830
2923
|
if (record.kind != .image or record.image_outcome != .loaded or record.image_blob_len == 0) continue;
|
|
2831
|
-
|
|
2924
|
+
const end = payload.len - effect_post_image_trailer_len;
|
|
2925
|
+
@memset(payload[end - 8 .. end], 0);
|
|
2832
2926
|
return true;
|
|
2833
2927
|
}
|
|
2834
2928
|
return false;
|
|
@@ -2836,12 +2930,12 @@ fn zeroFirstLoadedImageBlobLen(bytes: []u8) bool {
|
|
|
2836
2930
|
|
|
2837
2931
|
/// Overwrite the decoded-dimension fields of the first journaled image
|
|
2838
2932
|
/// record whose outcome matches, in place — `zeroFirstLoadedImageBlobLen`'s
|
|
2839
|
-
/// sibling. Per `journal.encodeEffect`, the
|
|
2933
|
+
/// sibling. Per `journal.encodeEffect`, the image fields end with
|
|
2840
2934
|
/// image_width (u64), image_height (u64), image_blob_hash (16 bytes),
|
|
2841
|
-
/// image_blob_len (u64)
|
|
2842
|
-
///
|
|
2843
|
-
///
|
|
2844
|
-
/// record was damaged.
|
|
2935
|
+
/// image_blob_len (u64) followed by the post-image trailer, so the dims
|
|
2936
|
+
/// live 40 and 32 bytes from the trailer's start. Framing and every
|
|
2937
|
+
/// other field stay valid: only replay's record-consistency gate can
|
|
2938
|
+
/// catch the damage. Returns whether a record was damaged.
|
|
2845
2939
|
fn patchFirstImageDims(bytes: []u8, outcome: effects_mod.EffectImageOutcome, width: u64, height: u64) bool {
|
|
2846
2940
|
var pos: usize = journal.preamble_len;
|
|
2847
2941
|
while (bytes.len - pos >= 5) {
|
|
@@ -2852,8 +2946,9 @@ fn patchFirstImageDims(bytes: []u8, outcome: effects_mod.EffectImageOutcome, wid
|
|
|
2852
2946
|
if (kind != @intFromEnum(journal.RecordKind.effect)) continue;
|
|
2853
2947
|
const record = journal.decodeEffect(payload) catch continue;
|
|
2854
2948
|
if (record.kind != .image or record.image_outcome != outcome) continue;
|
|
2855
|
-
|
|
2856
|
-
std.mem.writeInt(u64, payload[
|
|
2949
|
+
const end = payload.len - effect_post_image_trailer_len;
|
|
2950
|
+
std.mem.writeInt(u64, payload[end - 40 ..][0..8], width, .little);
|
|
2951
|
+
std.mem.writeInt(u64, payload[end - 32 ..][0..8], height, .little);
|
|
2857
2952
|
return true;
|
|
2858
2953
|
}
|
|
2859
2954
|
return false;
|