@native-sdk/cli 0.11.0 → 0.11.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.
Files changed (182) hide show
  1. package/build/app.zig +73 -37
  2. package/build.zig +239 -5
  3. package/native-sdk.d.ts +5 -1
  4. package/package.json +13 -12
  5. package/packages/core/compile-surface/core.ts +30 -0
  6. package/packages/core/package-lock.json +6 -6
  7. package/packages/core/package.json +3 -3
  8. package/packages/core/scripts/scriptc-toolchain.json +44 -44
  9. package/packages/core/scripts/stage_external_core.mjs +27 -16
  10. package/packages/core/sdk/core.d.ts +24 -1
  11. package/packages/core/sdk/core.ts +51 -1
  12. package/packages/core/sdk/events.d.ts +5 -0
  13. package/packages/core/sdk/events.ts +10 -0
  14. package/packages/core/src/bridge_descriptors.ts +3 -3
  15. package/packages/core/src/checker.ts +20 -0
  16. package/packages/core/src/cli.ts +2 -11
  17. package/packages/core/src/context_menus.ts +76 -0
  18. package/packages/core/src/diagnostics.ts +7 -0
  19. package/packages/core/src/extent_program.ts +53 -0
  20. package/packages/core/src/frontend.ts +12 -10
  21. package/packages/core/src/markup_canonical.ts +140 -0
  22. package/packages/core/src/markup_construction.ts +189 -0
  23. package/packages/core/src/markup_display.ts +43 -0
  24. package/packages/core/src/markup_document.ts +226 -0
  25. package/packages/core/src/markup_elements.ts +225 -0
  26. package/packages/core/src/markup_expressions.ts +79 -0
  27. package/packages/core/src/markup_imports.ts +146 -0
  28. package/packages/core/src/markup_parser.ts +228 -0
  29. package/packages/core/src/markup_runtime.ts +93 -0
  30. package/packages/core/src/markup_scalars.ts +143 -0
  31. package/packages/core/src/markup_shapes.ts +243 -0
  32. package/packages/core/src/markup_specialized.ts +242 -0
  33. package/packages/core/src/markup_text.ts +86 -0
  34. package/packages/core/src/markup_values.ts +336 -0
  35. package/packages/core/src/portable_sources.json +24 -0
  36. package/packages/core/src/registered_font.ts +2 -3
  37. package/packages/core/src/runtime_policy.ts +24 -0
  38. package/packages/core/src/scalar_text.ts +1 -3
  39. package/packages/core/src/scroll_mutation.ts +86 -0
  40. package/packages/core/src/scroll_tree.ts +86 -0
  41. package/packages/core/src/service_contract.ts +53 -2
  42. package/packages/core/src/sqlite_cli.ts +3 -46
  43. package/packages/core/src/sqlite_codegen.ts +84 -0
  44. package/packages/core/src/staged_rebuild.ts +60 -0
  45. package/packages/core/src/view_bridge.ts +161 -0
  46. package/packages/core/src/view_check.ts +145 -0
  47. package/packages/core/src/view_evaluator.ts +823 -0
  48. package/packages/core/src/view_frontend.ts +340 -218
  49. package/packages/core/src/view_program.ts +221 -0
  50. package/packages/core/src/view_reload.ts +166 -0
  51. package/packages/core/src/view_reload_watch.ts +98 -0
  52. package/packages/core/src/view_sources.ts +34 -0
  53. package/packages/core/src/virtual_windows.ts +88 -0
  54. package/packages/core/src/web_panes.ts +67 -0
  55. package/packages/core/src/widget_continuity.ts +37 -0
  56. package/packages/core/src/widget_reconcile.ts +63 -0
  57. package/packages/core/src/widget_retention.ts +62 -0
  58. package/skill-data/native-ui/SKILL.md +2 -2
  59. package/skill-data/ts-core/SKILL.md +5 -3
  60. package/skill-data/ts-services/references/service-surface.md +29 -5
  61. package/src/app_runner/root.zig +14 -0
  62. package/src/app_runner/ts_compiled_view.zig +88 -17
  63. package/src/app_runner/ts_core_main.zig +43 -5
  64. package/src/app_runner/ts_core_mobile.zig +1 -1
  65. package/src/automation/server.zig +56 -3
  66. package/src/embed/host.zig +2 -0
  67. package/src/embed/tests.zig +2 -0
  68. package/src/embed/ui_host.zig +2 -0
  69. package/src/platform/keyboard_input.zig +32 -0
  70. package/src/platform/linux/root.zig +2 -0
  71. package/src/platform/macos/appkit_host.h +7 -2
  72. package/src/platform/macos/appkit_host.m +31 -9
  73. package/src/platform/macos/cef_host.mm +15 -1
  74. package/src/platform/macos/global_shortcuts.zig +138 -0
  75. package/src/platform/macos/key_codes.zig +102 -0
  76. package/src/platform/macos/keyboard_input.zig +81 -0
  77. package/src/platform/macos/root.zig +25 -3
  78. package/src/platform/macos/webview_inspection_test.m +106 -0
  79. package/src/platform/null_platform.zig +104 -0
  80. package/src/platform/root.zig +14 -0
  81. package/src/platform/types.zig +102 -0
  82. package/src/platform/windows/global_shortcuts.zig +157 -0
  83. package/src/platform/windows/key_codes.zig +63 -0
  84. package/src/platform/windows/keyboard_input.zig +136 -0
  85. package/src/platform/windows/root.zig +15 -0
  86. package/src/primitives/canvas/decision_reuse.zig +133 -0
  87. package/src/primitives/canvas/font_ttf.zig +27 -3
  88. package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
  89. package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
  90. package/src/primitives/canvas/fonts/OFL.txt +93 -0
  91. package/src/primitives/canvas/fonts/README.md +15 -0
  92. package/src/primitives/canvas/intrinsic_measure_policy.zig +4 -1
  93. package/src/primitives/canvas/markdown_tests.zig +3 -3
  94. package/src/primitives/canvas/reference.zig +3 -5
  95. package/src/primitives/canvas/reference_tests.zig +58 -0
  96. package/src/primitives/canvas/registered_font_policy.zig +1 -1
  97. package/src/primitives/canvas/root.zig +7 -4
  98. package/src/primitives/canvas/text_metrics.zig +32 -39
  99. package/src/primitives/canvas/text_metrics_tests.zig +52 -7
  100. package/src/primitives/canvas/text_query_policy.zig +142 -3
  101. package/src/primitives/canvas/text_scalar_policy.zig +80 -2
  102. package/src/primitives/canvas/tokens.zig +9 -0
  103. package/src/primitives/canvas/ui.zig +1 -0
  104. package/src/primitives/canvas/ui_markup.zig +69 -14
  105. package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
  106. package/src/primitives/canvas/ui_markup_compiled.zig +1407 -23
  107. package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
  108. package/src/primitives/canvas/ui_markup_construction.zig +146 -0
  109. package/src/primitives/canvas/ui_markup_display.zig +82 -0
  110. package/src/primitives/canvas/ui_markup_document.zig +196 -0
  111. package/src/primitives/canvas/ui_markup_elements.zig +163 -0
  112. package/src/primitives/canvas/ui_markup_expr.zig +192 -2
  113. package/src/primitives/canvas/ui_markup_imports.zig +262 -0
  114. package/src/primitives/canvas/ui_markup_parser.zig +117 -0
  115. package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
  116. package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
  117. package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
  118. package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
  119. package/src/primitives/canvas/ui_markup_text.zig +128 -0
  120. package/src/primitives/canvas/ui_markup_values.zig +368 -0
  121. package/src/primitives/canvas/ui_markup_view.zig +2817 -74
  122. package/src/primitives/canvas/virtual_extent_policy.zig +58 -0
  123. package/src/primitives/canvas/virtual_extents.zig +47 -33
  124. package/src/primitives/canvas/widget_metric_policy.zig +4 -1
  125. package/src/primitives/canvas/widget_runtime.zig +2 -1
  126. package/src/root.zig +5 -0
  127. package/src/runtime/api.zig +1 -0
  128. package/src/runtime/bridge_descriptor_policy.zig +1 -1
  129. package/src/runtime/bridge_payload.zig +2 -0
  130. package/src/runtime/canvas_widget_context_menu.zig +179 -0
  131. package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
  132. package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
  133. package/src/runtime/canvas_widget_runtime.zig +306 -92
  134. package/src/runtime/context_menu_policy.zig +112 -0
  135. package/src/runtime/core.zig +14 -0
  136. package/src/runtime/effects.zig +172 -4
  137. package/src/runtime/effects_host_tests.zig +25 -0
  138. package/src/runtime/flow.zig +1 -0
  139. package/src/runtime/flow_reference.zig +1 -0
  140. package/src/runtime/global_shortcuts.zig +75 -0
  141. package/src/runtime/keyboard_input.zig +86 -0
  142. package/src/runtime/root.zig +3 -0
  143. package/src/runtime/scroll_mutation_policy.zig +130 -0
  144. package/src/runtime/scroll_mutation_runtime.zig +158 -0
  145. package/src/runtime/scroll_tree_policy.zig +99 -0
  146. package/src/runtime/session_record.zig +7 -0
  147. package/src/runtime/staged_rebuild_policy.zig +83 -0
  148. package/src/runtime/system_services.zig +19 -0
  149. package/src/runtime/tests.zig +1 -0
  150. package/src/runtime/ts_core_host.zig +126 -0
  151. package/src/runtime/ts_ui_app.zig +24 -0
  152. package/src/runtime/ui_app.zig +274 -31
  153. package/src/runtime/ui_app_tests.zig +48 -179
  154. package/src/runtime/ui_app_window_tests.zig +133 -0
  155. package/src/runtime/view_reload.zig +226 -0
  156. package/src/runtime/view_widget_scroll.zig +30 -21
  157. package/src/runtime/view_widget_tree.zig +43 -13
  158. package/src/runtime/virtual_window_policy.zig +128 -0
  159. package/src/runtime/web_pane_policy.zig +111 -0
  160. package/src/runtime/web_pane_test_cases.zig +204 -0
  161. package/src/runtime/widget_continuity_policy.zig +73 -0
  162. package/src/runtime/widget_reconcile_policy.zig +81 -0
  163. package/src/runtime/widget_retention_policy.zig +75 -0
  164. package/src/runtime/window_views.zig +19 -4
  165. package/src/security/root.zig +1 -0
  166. package/src/tooling/templates.zig +8 -0
  167. package/src/tooling/ts_core.zig +84 -1
  168. package/src/tooling/verbs.zig +79 -15
  169. package/tools/corewire/core.test.ts +25 -3
  170. package/tools/corewire/core_abi.zig +4 -0
  171. package/tools/corewire/core_contract.ts +1 -1
  172. package/tools/corewire/core_goldens.json +75 -75
  173. package/tools/corewire/core_projection.ts +3 -2
  174. package/tools/corewire/emit_mirror.ts +19 -9
  175. package/tools/corewire/facade_templates.ts +1 -1
  176. package/tools/corewire/intake.test.ts +4 -0
  177. package/tools/corewire/intake_goldens.json +50 -50
  178. package/tools/corewire/invocation.test.ts +4 -0
  179. package/tools/corewire/invocation_goldens.json +3 -3
  180. package/tools/corewire/mirror_templates.ts +4 -0
  181. package/tools/corewire/profile_emission.ts +2 -0
  182. package/tools/corewire/sidecar.zig +2 -0
@@ -0,0 +1,136 @@
1
+ //! Windows keyboard synthesis: SendInput with virtual keys for chords.
2
+ const std = @import("std");
3
+ const types = @import("../types.zig");
4
+ const key_codes = @import("key_codes.zig");
5
+
6
+ const input_keyboard: u32 = 1;
7
+ const keyeventf_extendedkey: u32 = 0x0001;
8
+ const keyeventf_keyup: u32 = 0x0002;
9
+
10
+ const vk_shift: u16 = 0x10;
11
+ const vk_control: u16 = 0x11;
12
+ const vk_menu: u16 = 0x12;
13
+ const vk_lwin: u16 = 0x5B;
14
+ const vk_rwin: u16 = 0x5C;
15
+ const vk_mask: u16 = 0xE8;
16
+
17
+ const modifier_groups = [_][3]u16{
18
+ .{ vk_control, 0xA2, 0xA3 },
19
+ .{ vk_menu, 0xA4, 0xA5 },
20
+ .{ vk_shift, 0xA0, 0xA1 },
21
+ .{ vk_lwin, vk_lwin, vk_rwin },
22
+ };
23
+
24
+ const max_inputs = 2 * (2 + 2 * modifier_groups.len) + 2;
25
+
26
+ const KeyboardInput = extern struct {
27
+ virtual_key: u16,
28
+ scan: u16,
29
+ flags: u32,
30
+ time: u32 = 0,
31
+ extra_info: usize = 0,
32
+ };
33
+
34
+ const Input = extern struct {
35
+ kind: u32 = input_keyboard,
36
+ keyboard: KeyboardInput,
37
+ mouse_input_padding: [8]u8 = @splat(0),
38
+ };
39
+
40
+ extern "user32" fn SendInput(count: u32, inputs: [*]const Input, size: c_int) callconv(.winapi) u32;
41
+ extern "user32" fn GetAsyncKeyState(vk: c_int) callconv(.winapi) i16;
42
+ extern "user32" fn MapVirtualKeyW(code: u32, map_type: u32) callconv(.winapi) u32;
43
+
44
+ pub fn sendKeyChord(_: ?*anyopaque, chord: types.KeyChord) anyerror!void {
45
+ const key = key_codes.virtualKey(chord.key()) orelse return error.KeyboardInputFailed;
46
+ var held: [modifier_groups.len][2]bool = undefined;
47
+ for (modifier_groups, &held) |group, *sides| sides.* = .{ GetAsyncKeyState(group[1]) < 0, GetAsyncKeyState(group[2]) < 0 };
48
+ var inputs: [max_inputs]Input = undefined;
49
+ const count = chordInputs(chord.modifiers, key, held, &inputs);
50
+ for (inputs[0..count]) |*input| input.keyboard.scan = @truncate(MapVirtualKeyW(input.keyboard.virtual_key, 0));
51
+ const sent: usize = SendInput(@intCast(count), &inputs, @sizeOf(Input));
52
+ if (sent == count) return;
53
+ const tail = @min(sent, count - sent);
54
+ if (tail > 0) _ = SendInput(@intCast(tail), inputs[count - tail ..].ptr, @sizeOf(Input));
55
+ return error.KeyboardInputBlocked;
56
+ }
57
+
58
+ pub fn access(_: ?*anyopaque, _: bool) anyerror!types.KeyboardInputAccess {
59
+ return .not_required;
60
+ }
61
+
62
+ /// Lifts held modifiers the chord lacks, presses missing chord modifiers, taps the key, then mirrors every step in reverse.
63
+ /// A lifted Alt or Win gets a mask tap on both ends so neither the synthetic nor the user's later release opens a menu.
64
+ fn chordInputs(modifiers: types.ShortcutModifiers, key: u16, held: [modifier_groups.len][2]bool, inputs: *[max_inputs]Input) usize {
65
+ const wanted = [modifier_groups.len]bool{ modifiers.primary or modifiers.control, modifiers.option, modifiers.shift, modifiers.command };
66
+ var half: usize = 0;
67
+ if ((!wanted[1] and (held[1][0] or held[1][1])) or (!wanted[3] and (held[3][0] or held[3][1]))) {
68
+ inputs[0] = virtualKeyInput(vk_mask, false);
69
+ inputs[1] = virtualKeyInput(vk_mask, true);
70
+ half = 2;
71
+ }
72
+ for (modifier_groups, wanted, held) |group, want, sides| {
73
+ if (want) continue;
74
+ for (sides, group[1..]) |down, vk| {
75
+ if (!down) continue;
76
+ inputs[half] = virtualKeyInput(vk, true);
77
+ half += 1;
78
+ }
79
+ }
80
+ for (modifier_groups, wanted, held) |group, want, sides| {
81
+ if (!want or sides[0] or sides[1]) continue;
82
+ inputs[half] = virtualKeyInput(group[0], false);
83
+ half += 1;
84
+ }
85
+ const count = 2 * half + 2;
86
+ inputs[half] = virtualKeyInput(key, false);
87
+ inputs[half + 1] = virtualKeyInput(key, true);
88
+ for (0..half) |i| {
89
+ inputs[count - 1 - i] = inputs[i];
90
+ inputs[count - 1 - i].keyboard.flags ^= keyeventf_keyup;
91
+ }
92
+ return count;
93
+ }
94
+
95
+ fn virtualKeyInput(vk: u16, key_up: bool) Input {
96
+ const extended = switch (vk) {
97
+ 0x21...0x28, 0x2D, 0x2E, 0xA3, 0xA5, vk_lwin, vk_rwin => true,
98
+ else => false,
99
+ };
100
+ return .{ .keyboard = .{
101
+ .virtual_key = vk,
102
+ .scan = 0,
103
+ .flags = (if (key_up) keyeventf_keyup else 0) | (if (extended) keyeventf_extendedkey else 0),
104
+ } };
105
+ }
106
+
107
+ test "input records match the Win32 INPUT layout" {
108
+ try std.testing.expectEqual(@as(usize, if (@sizeOf(usize) == 8) 40 else 28), @sizeOf(Input));
109
+ try std.testing.expectEqual(@as(usize, @sizeOf(usize)), @offsetOf(Input, "keyboard"));
110
+ }
111
+
112
+ test "chord inputs lift stray held modifiers, keep held chord modifiers, and mask a lifted Alt or Win on both ends" {
113
+ const v: u16 = 0x56;
114
+ const cases = [_]struct { types.ShortcutModifiers, [modifier_groups.len][2]bool, []const struct { u16, bool } }{
115
+ .{ .{ .primary = true }, @splat(.{ false, false }), &.{ .{ 0x11, false }, .{ v, false }, .{ v, true }, .{ 0x11, true } } },
116
+ .{ .{ .primary = true }, .{ .{ true, false }, .{ false, false }, .{ false, false }, .{ false, false } }, &.{ .{ v, false }, .{ v, true } } },
117
+ .{ .{ .primary = true }, .{ .{ false, false }, .{ false, false }, .{ false, true }, .{ false, false } }, &.{ .{ 0xA1, true }, .{ 0x11, false }, .{ v, false }, .{ v, true }, .{ 0x11, true }, .{ 0xA1, false } } },
118
+ .{ .{ .primary = true }, .{ .{ false, false }, .{ true, false }, .{ false, false }, .{ false, false } }, &.{ .{ vk_mask, false }, .{ vk_mask, true }, .{ 0xA4, true }, .{ 0x11, false }, .{ v, false }, .{ v, true }, .{ 0x11, true }, .{ 0xA4, false }, .{ vk_mask, false }, .{ vk_mask, true } } },
119
+ .{ .{ .command = true }, .{ .{ false, false }, .{ false, false }, .{ false, false }, .{ false, true } }, &.{ .{ v, false }, .{ v, true } } },
120
+ .{ .{ .primary = true }, .{ .{ false, false }, .{ false, false }, .{ false, false }, .{ true, false } }, &.{ .{ vk_mask, false }, .{ vk_mask, true }, .{ vk_lwin, true }, .{ 0x11, false }, .{ v, false }, .{ v, true }, .{ 0x11, true }, .{ vk_lwin, false }, .{ vk_mask, false }, .{ vk_mask, true } } },
121
+ .{ .{ .control = true, .option = true, .shift = true }, @splat(.{ false, false }), &.{ .{ 0x11, false }, .{ 0x12, false }, .{ 0x10, false }, .{ v, false }, .{ v, true }, .{ 0x10, true }, .{ 0x12, true }, .{ 0x11, true } } },
122
+ };
123
+ for (cases) |case| {
124
+ var inputs: [max_inputs]Input = undefined;
125
+ const count = chordInputs(case[0], v, case[1], &inputs);
126
+ try std.testing.expectEqual(case[2].len, count);
127
+ for (case[2], inputs[0..count]) |want, got| {
128
+ try std.testing.expectEqual(want[0], got.keyboard.virtual_key);
129
+ try std.testing.expectEqual(want[1], got.keyboard.flags & keyeventf_keyup != 0);
130
+ }
131
+ }
132
+ var inputs: [max_inputs]Input = undefined;
133
+ try std.testing.expectEqual(@as(usize, max_inputs), chordInputs(.{}, v, @splat(.{ true, true }), &inputs));
134
+ try std.testing.expect(virtualKeyInput(0x25, false).keyboard.flags & keyeventf_extendedkey != 0);
135
+ try std.testing.expect(virtualKeyInput(v, false).keyboard.flags & keyeventf_extendedkey == 0);
136
+ }
@@ -3,6 +3,8 @@ const geometry = @import("geometry");
3
3
  const platform_mod = @import("../root.zig");
4
4
  const policy_values = @import("../policy_values.zig");
5
5
  const security = @import("../../security/root.zig");
6
+ const global_shortcuts = @import("global_shortcuts.zig");
7
+ const keyboard_input = @import("keyboard_input.zig");
6
8
 
7
9
  const bundled_geist_regular = @embedFile("../../primitives/canvas/fonts/Geist-Regular.ttf");
8
10
  const bundled_geist_mono = @embedFile("../../primitives/canvas/fonts/GeistMono-Regular.ttf");
@@ -322,6 +324,7 @@ pub const WindowsPlatform = struct {
322
324
  /// latch-gated free.
323
325
  channel_wake_abandoned: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
324
326
  audio_capture_sinks: [2]platform_mod.AudioCaptureSink = [_]platform_mod.AudioCaptureSink{.{}} ** 2,
327
+ global_shortcuts: global_shortcuts.Registry = .{},
325
328
 
326
329
  pub fn init(title: []const u8, size: geometry.SizeF) Error!WindowsPlatform {
327
330
  return initWithEngine(title, size, .system);
@@ -411,6 +414,7 @@ pub const WindowsPlatform = struct {
411
414
  std.debug.print("windows platform teardown: an abandoned platform call may still enter this host; skipping destruction and leaking it (and the wrapper it enters through), process-lived, so the stale call stays safe\n", .{});
412
415
  return;
413
416
  }
417
+ self.global_shortcuts.deinit();
414
418
  native_sdk_windows_destroy(self.host);
415
419
  }
416
420
 
@@ -472,6 +476,8 @@ pub const WindowsPlatform = struct {
472
476
  .remove_tray_fn = removeTray,
473
477
  .open_external_url_fn = openExternalUrl,
474
478
  .reveal_path_fn = revealPath,
479
+ .send_key_chord_fn = keyboard_input.sendKeyChord,
480
+ .keyboard_input_access_fn = keyboard_input.access,
475
481
  .add_recent_document_fn = addRecentDocument,
476
482
  .clear_recent_documents_fn = clearRecentDocuments,
477
483
  .set_credential_fn = setCredential,
@@ -496,6 +502,7 @@ pub const WindowsPlatform = struct {
496
502
  .configure_security_policy_fn = configureSecurityPolicy,
497
503
  .configure_menus_fn = configureMenus,
498
504
  .configure_shortcuts_fn = configureShortcuts,
505
+ .configure_global_shortcuts_fn = configureGlobalShortcuts,
499
506
  .emit_window_event_fn = emitWindowEvent,
500
507
  .start_timer_fn = startTimer,
501
508
  .cancel_timer_fn = cancelTimer,
@@ -564,6 +571,8 @@ pub const WindowsPlatform = struct {
564
571
  // app that skips the capability check still learns exactly
565
572
  // what is missing.
566
573
  .video_playback => false,
574
+ .global_shortcuts => global_shortcuts.available(),
575
+ .keyboard_input => true,
567
576
  };
568
577
  }
569
578
 
@@ -1919,6 +1928,11 @@ fn configureMenus(context: ?*anyopaque, menus: []const platform_mod.Menu) anyerr
1919
1928
  self.menus_active = menus.len > 0;
1920
1929
  }
1921
1930
 
1931
+ fn configureGlobalShortcuts(context: ?*anyopaque, shortcuts: []const platform_mod.Shortcut, sink: platform_mod.GlobalShortcutSink, statuses: []platform_mod.GlobalShortcutStatus) anyerror!void {
1932
+ const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1933
+ return self.global_shortcuts.configure(shortcuts, sink, statuses);
1934
+ }
1935
+
1922
1936
  fn configureShortcuts(context: ?*anyopaque, shortcuts: []const platform_mod.Shortcut) anyerror!void {
1923
1937
  const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1924
1938
  if (shortcuts.len > platform_mod.max_shortcuts) return error.InvalidShortcut;
@@ -2755,4 +2769,5 @@ fn flattenFilters(filters: []const platform_mod.FileFilter, buffer: []u8) []cons
2755
2769
 
2756
2770
  test "windows platform module exports type" {
2757
2771
  _ = WindowsPlatform;
2772
+ _ = global_shortcuts;
2758
2773
  }
@@ -0,0 +1,133 @@
1
+ //! Shared pieces for reusing exact compiled-policy decisions.
2
+ //!
3
+ //! Compiled policies answer from their request bytes alone, and layout asks
4
+ //! the same questions on every frame. Callers keep earlier answers and reuse
5
+ //! one only after the stored request equals the new request byte for byte.
6
+ //! The hash below only picks a slot; equality always decides reuse.
7
+ const std = @import("std");
8
+ const builtin = @import("builtin");
9
+
10
+ extern "c" fn memcmp(a: *const anyopaque, b: *const anyopaque, len: usize) c_int;
11
+
12
+ /// Byte equality that stays cheap in Debug hosts: libc's comparison is
13
+ /// optimized regardless of the caller's build mode.
14
+ pub fn bytesEqual(a: []const u8, b: []const u8) bool {
15
+ if (a.len != b.len) return false;
16
+ if (a.len == 0) return true;
17
+ if (comptime builtin.link_libc) return memcmp(a.ptr, b.ptr, a.len) == 0;
18
+ return std.mem.eql(u8, a, b);
19
+ }
20
+
21
+ /// A slot index over a short prefix of the bytes plus their length. Requests
22
+ /// that share the prefix share a slot; reuse still requires full equality.
23
+ pub fn slotHash(seed: u64, bytes: []const u8, prefix: usize) u64 {
24
+ var hash: u64 = 0xcbf29ce484222325 ^ seed ^ (@as(u64, bytes.len) << 32);
25
+ for (bytes[0..@min(prefix, bytes.len)]) |byte| hash = (hash ^ byte) *% 0x100000001b3;
26
+ return hash ^ (hash >> 29);
27
+ }
28
+
29
+ pub const Policy = *const fn ([]const u8, []u8) usize;
30
+
31
+ /// Only registered policies are reused. A host registers a policy when it
32
+ /// answers from its request bytes alone, as a compiled TypeScript core's
33
+ /// window policy does. Any other callback (a custom policy, a recording test
34
+ /// double) is called every time, exactly as before.
35
+ var pure_policies: [8]std.atomic.Value(usize) = @splat(.init(0));
36
+
37
+ pub fn registerPurePolicy(policy: Policy) void {
38
+ const address = @intFromPtr(policy);
39
+ for (&pure_policies) |*slot| {
40
+ if (slot.load(.acquire) == address) return;
41
+ if (slot.cmpxchgStrong(0, address, .acq_rel, .acquire) == null) return;
42
+ }
43
+ }
44
+
45
+ pub fn isPure(policy: Policy) bool {
46
+ const address = @intFromPtr(policy);
47
+ for (&pure_policies) |*slot| {
48
+ const value = slot.load(.acquire);
49
+ if (value == address) return true;
50
+ if (value == 0) return false;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ /// A per-thread table of exact decisions for requests of at most
56
+ /// `max_request` bytes whose result is `result_len` bytes. Each slot keeps one
57
+ /// request and its result; a collision replaces the slot. Allocated on first
58
+ /// use, so threads that never ask pay nothing.
59
+ pub fn Table(comptime slot_count: usize, comptime max_request: usize, comptime result_len: usize) type {
60
+ return struct {
61
+ const Entry = struct {
62
+ policy: ?Policy = null,
63
+ len: usize = 0,
64
+ request: [max_request]u8 = undefined,
65
+ result: [result_len]u8 = undefined,
66
+ };
67
+ threadlocal var entries: ?*[slot_count]Entry = null;
68
+
69
+ /// The same contract as calling `policy(request, result)` directly.
70
+ pub fn decide(policy: Policy, request: []const u8, result: *[result_len]u8) usize {
71
+ if (request.len > max_request or !isPure(policy)) return policy(request, result);
72
+ const table = entries orelse allocate() orelse return policy(request, result);
73
+ const entry = &table[@intCast(slotHash(@intFromPtr(policy), request, 256) % slot_count)];
74
+ const owned = if (entry.policy) |owner| owner == policy else false;
75
+ if (owned and entry.len == request.len and bytesEqual(entry.request[0..request.len], request)) {
76
+ result.* = entry.result;
77
+ return result_len;
78
+ }
79
+ const len = policy(request, result);
80
+ if (len == result_len) {
81
+ entry.policy = policy;
82
+ entry.len = request.len;
83
+ @memcpy(entry.request[0..request.len], request);
84
+ entry.result = result.*;
85
+ }
86
+ return len;
87
+ }
88
+
89
+ fn allocate() ?*[slot_count]Entry {
90
+ const table = std.heap.smp_allocator.create([slot_count]Entry) catch return null;
91
+ table.* = @splat(.{});
92
+ entries = table;
93
+ return table;
94
+ }
95
+ };
96
+ }
97
+
98
+ var table_test_calls: usize = 0;
99
+ fn tableTestPolicy(request: []const u8, result: []u8) usize {
100
+ table_test_calls += 1;
101
+ @memset(result, request[request.len - 1]);
102
+ return result.len;
103
+ }
104
+
105
+ test "decision tables reuse only identical requests of registered policies" {
106
+ const T = Table(8, 4, 2);
107
+ var unregistered: [2]u8 = undefined;
108
+ table_test_calls = 0;
109
+ _ = T.decide(tableTestPolicy, &.{ 1, 2 }, &unregistered);
110
+ _ = T.decide(tableTestPolicy, &.{ 1, 2 }, &unregistered);
111
+ try std.testing.expectEqual(@as(usize, 2), table_test_calls);
112
+ registerPurePolicy(tableTestPolicy);
113
+ var result: [2]u8 = undefined;
114
+ table_test_calls = 0;
115
+ try std.testing.expectEqual(@as(usize, 2), T.decide(tableTestPolicy, &.{ 1, 2 }, &result));
116
+ try std.testing.expectEqualSlices(u8, &.{ 2, 2 }, &result);
117
+ result = .{ 0, 0 };
118
+ try std.testing.expectEqual(@as(usize, 2), T.decide(tableTestPolicy, &.{ 1, 2 }, &result));
119
+ try std.testing.expectEqualSlices(u8, &.{ 2, 2 }, &result);
120
+ try std.testing.expectEqual(@as(usize, 1), table_test_calls);
121
+ _ = T.decide(tableTestPolicy, &.{ 1, 3 }, &result);
122
+ try std.testing.expectEqualSlices(u8, &.{ 3, 3 }, &result);
123
+ _ = T.decide(tableTestPolicy, &.{ 1, 2, 3, 4, 5 }, &result);
124
+ _ = T.decide(tableTestPolicy, &.{ 1, 2, 3, 4, 5 }, &result);
125
+ try std.testing.expectEqual(@as(usize, 4), table_test_calls);
126
+ }
127
+
128
+ test "bytesEqual compares every byte and the length" {
129
+ try std.testing.expect(bytesEqual("", ""));
130
+ try std.testing.expect(bytesEqual("abc", "abc"));
131
+ try std.testing.expect(!bytesEqual("abc", "abd"));
132
+ try std.testing.expect(!bytesEqual("abc", "ab"));
133
+ }
@@ -84,15 +84,39 @@ pub const max_composite_components: usize = 8;
84
84
 
85
85
  /// The bundled Geist Regular face (OFL), embedded so the reference
86
86
  /// renderer paints real text without any platform font machinery. It
87
- /// serves the sans font ids (weight/italic span variants included) at
88
- /// their estimator advances; additional faces can be bundled without
89
- /// changing callers.
87
+ /// serves regular sans text; the matching medium and bold faces below
88
+ /// preserve the weight chosen by widgets and inline spans.
90
89
  pub const geist_regular_bytes: []const u8 = @embedFile("fonts/Geist-Regular.ttf");
91
90
 
92
91
  /// Comptime-validated view over the bundled face. Using a comptime
93
92
  /// constant means table presence and offsets are proven at build time.
94
93
  pub const geist_regular = Face.parse(geist_regular_bytes) catch @compileError("bundled Geist-Regular.ttf failed to parse");
95
94
 
95
+ pub const geist_medium_bytes: []const u8 = @embedFile("fonts/Geist-Medium.ttf");
96
+ pub const geist_medium = Face.parse(geist_medium_bytes) catch @compileError("bundled Geist-Medium.ttf failed to parse");
97
+
98
+ pub const geist_bold_bytes: []const u8 = @embedFile("fonts/Geist-Bold.ttf");
99
+ pub const geist_bold = Face.parse(geist_bold_bytes) catch @compileError("bundled Geist-Bold.ttf failed to parse");
100
+
101
+ pub const bundled_sans_faces = [_]*const Face{ &geist_regular, &geist_medium, &geist_bold };
102
+
103
+ /// The reserved sans ids share one face selection for layout and drawing.
104
+ /// Italic ids retain their weight using upright outlines until an italic
105
+ /// face is bundled. Unknown ids keep the regular fallback.
106
+ pub fn bundledSansFaceIndex(font_id: u64) usize {
107
+ const canvas = @import("root.zig");
108
+ return switch (font_id) {
109
+ canvas.default_sans_medium_font_id => 1,
110
+ canvas.default_sans_bold_font_id, canvas.default_sans_bold_italic_font_id => 2,
111
+ else => 0,
112
+ };
113
+ }
114
+
115
+ pub fn bundledFaceForFontId(font_id: u64) *const Face {
116
+ if (font_id == @import("root.zig").default_mono_font_id) return &geist_mono;
117
+ return bundled_sans_faces[bundledSansFaceIndex(font_id)];
118
+ }
119
+
96
120
  /// The bundled Geist Mono Regular face (OFL, same family): mono runs
97
121
  /// ink real fixed-pitch outlines. Before this face landed, mono font
98
122
  /// ids borrowed the proportional sans outlines centered inside the
@@ -0,0 +1,93 @@
1
+ Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,15 @@
1
+ # Bundled fonts
2
+
3
+ Geist Regular, Medium and Bold are unmodified static TrueType files from
4
+ [Geist 1.4.2](https://github.com/vercel/geist-font/tree/4d655731f83507f0258ce5541c297b6553d5d081/packages/next/dist/fonts/geist-sans),
5
+ distributed under the [SIL Open Font License](./OFL.txt).
6
+
7
+ The software renderer and deterministic text measurement use the same face
8
+ for each built-in weight. Italic styles use upright outlines at the requested
9
+ weight; platform text providers can supply italic faces.
10
+
11
+ | File | SHA-256 |
12
+ | --- | --- |
13
+ | Geist-Regular.ttf | `5e7c3b25da393b1619253c655f95c5d123184759a4961562add5b0f5386e63c9` |
14
+ | Geist-Medium.ttf | `0987db2030200a6b4a45d03398057c27733977b09bde67b8d0afc26b8b8d0768` |
15
+ | Geist-Bold.ttf | `dbe7fbf58111609860bf1b3bebdf4d39efc7e64ed65ef3b393a090680038d920` |
@@ -23,6 +23,9 @@ pub const Result = struct {
23
23
  return float(&self.bytes, 24);
24
24
  }
25
25
  };
26
+ /// Each step is a pure function of the request bytes; children are measured
27
+ /// again and written into the request before the next step is formed.
28
+ const intrinsic_decisions = @import("decision_reuse.zig").Table(256, 2048, 32);
26
29
  pub const Plan = struct {
27
30
  allocator: std.mem.Allocator,
28
31
  policy: @import("surface_layout_policy.zig").Policy,
@@ -85,7 +88,7 @@ pub const Plan = struct {
85
88
  }
86
89
  pub fn run(self: Plan) Result {
87
90
  var result: Result = .{ .bytes = @splat(0xa5) };
88
- if (self.policy(self.request, &result.bytes) != 32 or read(&result.bytes, 0) != 1 or read(&result.bytes, 4) > 4 or read(&result.bytes, 28) != 0) @panic("invalid intrinsic measurement result");
91
+ if (intrinsic_decisions.decide(self.policy, self.request, &result.bytes) != 32 or read(&result.bytes, 0) != 1 or read(&result.bytes, 4) > 4 or read(&result.bytes, 28) != 0) @panic("invalid intrinsic measurement result");
89
92
  const action = result.action();
90
93
  const index = result.index();
91
94
  if (action == .child or action == .wrapped) {
@@ -1321,14 +1321,14 @@ test "the README-shaped fixture renders through the mapper and the reference ren
1321
1321
  // 760x2400 with default tokens and the deterministic bundled-face
1322
1322
  // metrics. It pins the whole document register in one number: heading
1323
1323
  // scales, wrapped bullets and em-dash spacing at the face's real
1324
- // advances, real sans and mono outlines (fixed-pitch runs sit in their
1325
- // 0.6 em cells), GFM tables as borderless cells on hairline row
1324
+ // advances, regular/medium/bold sans and mono outlines (fixed-pitch
1325
+ // runs sit in their 0.6 em cells), GFM tables as borderless cells on hairline row
1326
1326
  // separators with vertically centered cell content, bare fenced code
1327
1327
  // with preserved source indentation and language-token colors, and
1328
1328
  // near-black underlined links.
1329
1329
  // Update deliberately when markdown rendering changes, reviewing the
1330
1330
  // rendered pixels first (see reference_tests.zig conventions).
1331
- const markdown_document_reference_signature: u64 = 17200107192111546862;
1331
+ const markdown_document_reference_signature: u64 = 13932087754745656842;
1332
1332
 
1333
1333
  fn markdownGoldenDumpRequested() bool {
1334
1334
  if (comptime !@import("builtin").link_libc) return false;
@@ -1153,9 +1153,8 @@ fn isReferenceTextSpace(byte: u8) bool {
1153
1153
  /// The face a run's font id inks with: a runtime-registered face when
1154
1154
  /// the id matches one (validated at registration, so a registered id
1155
1155
  /// always resolves — no render-time fallback decision), otherwise the
1156
- /// bundled mapping — the mono face for the reserved mono id, the sans
1157
- /// face for everything else (the weight and italic span variants keep
1158
- /// the regular outlines at their estimator advances, exactly as before).
1156
+ /// bundled mapping — Geist Mono for mono text, and the corresponding
1157
+ /// regular, medium or bold Geist face for reserved sans ids.
1159
1158
  /// Glyphs missing from whichever face wins keep the per-glyph notdef
1160
1159
  /// block fallback in `drawGlyphBox`; a registered face never cascades
1161
1160
  /// into the bundled faces mid-run.
@@ -1163,8 +1162,7 @@ fn referenceFaceForFontId(fonts: []const ReferenceFont, font_id: canvas.FontId)
1163
1162
  for (fonts) |font| {
1164
1163
  if (font.id == font_id) return font.face;
1165
1164
  }
1166
- if (font_id == canvas.default_mono_font_id) return &font_ttf.geist_mono;
1167
- return &font_ttf.geist_regular;
1165
+ return font_ttf.bundledFaceForFontId(font_id);
1168
1166
  }
1169
1167
 
1170
1168
  /// Decode the first codepoint of the cluster `text[start..start+len]`;
@@ -1415,6 +1415,64 @@ test "reference renderer blurs transparent colors without dark fringes" {
1415
1415
  try expectPixelRgba8(.{ 0, 0, 0, 0 }, surface, 2, 0);
1416
1416
  }
1417
1417
 
1418
+ test "bundled sans weights render matching glyph faces" {
1419
+ const font_ttf = canvas.font_ttf;
1420
+ const width = 64;
1421
+ const height = 48;
1422
+ const bounds = geometry.RectF.init(0, 0, width, height);
1423
+ var actual: [width * height * 4]u8 = undefined;
1424
+ var expected: [width * height * 4]u8 = undefined;
1425
+ var coverage: [3]u64 = undefined;
1426
+ const cases = .{
1427
+ .{ canvas.default_sans_font_id, &font_ttf.geist_regular },
1428
+ .{ canvas.default_sans_medium_font_id, &font_ttf.geist_medium },
1429
+ .{ canvas.default_sans_bold_font_id, &font_ttf.geist_bold },
1430
+ };
1431
+ inline for (cases, 0..) |case, index| {
1432
+ // Explicit glyph placement isolates face selection from measurement.
1433
+ // The expected pixels use the same face as an application-registered
1434
+ // resource, independently of the reserved-id fallback mapping.
1435
+ const glyphs = [_]Glyph{.{
1436
+ .id = case[1].glyphIndex('H'),
1437
+ .x = 0,
1438
+ .y = 0,
1439
+ .advance = 32 * case[1].advance(case[1].glyphIndex('H')) / case[1].units_per_em,
1440
+ .text_len = 1,
1441
+ }};
1442
+ var commands = [_]RenderCommand{.{
1443
+ .command = .{ .draw_text = .{
1444
+ .id = 1,
1445
+ .font_id = case[0],
1446
+ .size = 32,
1447
+ .origin = geometry.PointF.init(8, 36),
1448
+ .color = Color.rgb8(255, 255, 255),
1449
+ .text = "H",
1450
+ .glyphs = &glyphs,
1451
+ } },
1452
+ .local_bounds = bounds,
1453
+ .bounds = bounds,
1454
+ }};
1455
+ const pass = canvas.CanvasRenderPass{
1456
+ .surface_size = geometry.SizeF.init(width, height),
1457
+ .full_repaint = true,
1458
+ .commands = &commands,
1459
+ };
1460
+ const surface = try ReferenceRenderSurface.init(width, height, &actual);
1461
+ try surface.renderPass(pass, Color.rgba8(0, 0, 0, 0));
1462
+
1463
+ commands[0].command.draw_text.font_id = canvas.min_registered_font_id;
1464
+ const fonts = [_]canvas.ReferenceFont{.{ .id = canvas.min_registered_font_id, .face = case[1] }};
1465
+ const control = (try ReferenceRenderSurface.init(width, height, &expected)).withFonts(&fonts);
1466
+ try control.renderPass(pass, Color.rgba8(0, 0, 0, 0));
1467
+ try std.testing.expectEqualSlices(u8, &expected, &actual);
1468
+ coverage[index] = 0;
1469
+ for (0..width * height) |pixel| coverage[index] += actual[pixel * 4 + 3];
1470
+ }
1471
+ try std.testing.expect(coverage[0] > 0);
1472
+ try std.testing.expect(coverage[1] > coverage[0]);
1473
+ try std.testing.expect(coverage[2] > coverage[1]);
1474
+ }
1475
+
1418
1476
  test "reference renderer draws proxy text runs" {
1419
1477
  const commands = [_]CanvasCommand{.{ .draw_text = .{
1420
1478
  .id = 1,
@@ -55,7 +55,7 @@ pub fn resultValid(request: []const u8, result: []const u8) bool {
55
55
  pub const Result = struct { width: f32, accepted: bool, ink: metrics.TextInkMetrics };
56
56
  pub fn measure(policy: Policy, registered_face: ?*const font_ttf.Face, font: u64, text: []const u8, size: f32, mode: Mode, advances: []f32) Result {
57
57
  if (mode == .advances and advances.len < text.len) @panic("registered font advance buffer too short");
58
- const face = registered_face orelse &font_ttf.geist_regular;
58
+ const face = registered_face orelse font_ttf.bundledFaceForFontId(font);
59
59
  var request: [128]u8 = @splat(0);
60
60
  var result: [128]u8 = undefined;
61
61
  request[0..5].* = .{ 62, 1, @intFromEnum(mode), 0, @intFromBool(registered_face != null) };