@native-sdk/cli 0.4.1 → 0.4.2

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 (36) hide show
  1. package/assets/native-sdk.manifest +17 -1
  2. package/build/app.zig +40 -1
  3. package/build.zig +49 -3
  4. package/package.json +10 -9
  5. package/src/platform/macos/appkit_host.m +21 -6
  6. package/src/platform/windows/webview2_host.cpp +377 -72
  7. package/src/primitives/canvas/chart.zig +8 -7
  8. package/src/primitives/canvas/chart_tests.zig +2 -2
  9. package/src/primitives/canvas/commands.zig +27 -0
  10. package/src/primitives/canvas/gpu.zig +8 -0
  11. package/src/primitives/canvas/markdown_tests.zig +1 -1
  12. package/src/primitives/canvas/reference.zig +82 -3
  13. package/src/primitives/canvas/reference_tests.zig +155 -1
  14. package/src/primitives/canvas/serialization.zig +16 -3
  15. package/src/primitives/canvas/themes/geist.zig +6 -0
  16. package/src/primitives/canvas/tokens.zig +7 -0
  17. package/src/primitives/canvas/widget_builtin_tests.zig +191 -0
  18. package/src/primitives/canvas/widget_render.zig +29 -41
  19. package/src/primitives/canvas/widget_render_controls.zig +55 -42
  20. package/src/primitives/canvas/widget_render_style.zig +53 -0
  21. package/src/primitives/canvas/widget_render_surfaces.zig +19 -18
  22. package/src/primitives/canvas/widget_runtime_tests.zig +20 -21
  23. package/src/runtime/canvas_frame_packet_tests.zig +9 -1
  24. package/src/runtime/canvas_frame_patch_tests.zig +39 -1
  25. package/src/runtime/canvas_widget_control_tests.zig +4 -4
  26. package/src/runtime/ui_app.zig +78 -10
  27. package/src/runtime/ui_app_tests.zig +109 -0
  28. package/src/runtime/ui_app_window_tests.zig +93 -0
  29. package/src/tooling/package.zig +45 -0
  30. package/src/tooling/templates.zig +42 -1
  31. package/third_party/webview2/LICENSE.txt +27 -0
  32. package/third_party/webview2/README.md +19 -0
  33. package/third_party/webview2/arm64/WebView2Loader.dll +0 -0
  34. package/third_party/webview2/include/EventToken.h +12 -0
  35. package/third_party/webview2/include/WebView2.h +60636 -0
  36. package/third_party/webview2/x64/WebView2Loader.dll +0 -0
@@ -436,6 +436,113 @@ test "icon widgets render built-in vector icons as tinted path commands" {
436
436
  }
437
437
  }
438
438
 
439
+ test "checkbox check mark strokes one anti-aliased vector path" {
440
+ const checkbox = Widget{
441
+ .id = 63,
442
+ .kind = WidgetKind.checkbox,
443
+ .frame = geometry.RectF.init(0, 0, 24, 24),
444
+ .value = 1,
445
+ };
446
+ const tokens = DesignTokens{};
447
+ var commands: [8]CanvasCommand = undefined;
448
+ var builder = Builder.init(&commands);
449
+ try emitWidgetTree(&builder, checkbox, tokens);
450
+ const display_list = builder.displayList();
451
+ // The mark is ONE stroked polyline through the vector core — move
452
+ // plus two lines, round caps (and the vector core's round joins at
453
+ // the vee vertex), the same rasterization the built-in stroke icons
454
+ // get — not a pair of hard-edged line commands.
455
+ switch (display_list.findCommandById(widgetPartId(63, 4)).?.command) {
456
+ .stroke_path => |stroke| {
457
+ try std.testing.expectEqual(@as(usize, 3), stroke.elements.len);
458
+ try std.testing.expectEqual(PathVerb.move_to, stroke.elements[0].verb);
459
+ try std.testing.expectEqual(PathVerb.line_to, stroke.elements[1].verb);
460
+ try std.testing.expectEqual(PathVerb.line_to, stroke.elements[2].verb);
461
+ try std.testing.expectEqual(@as(f32, 2), stroke.stroke.width);
462
+ try std.testing.expectEqual(canvas.LineCap.round, stroke.cap);
463
+ },
464
+ else => return error.TestUnexpectedResult,
465
+ }
466
+
467
+ // Rasterized, the diagonal carries partial-coverage edge pixels —
468
+ // anti-aliasing a binary point-in-capsule test can never produce —
469
+ // and the whole render pins byte-identical.
470
+ var render_commands: [8]RenderCommand = undefined;
471
+ const plan = try (DisplayList{ .commands = display_list.commands }).renderPlan(&render_commands);
472
+ var pixels: [24 * 24 * 4]u8 = undefined;
473
+ @memset(&pixels, 0);
474
+ const surface = try ReferenceRenderSurface.init(24, 24, &pixels);
475
+ try surface.renderPass(.{
476
+ .commands = plan.commands,
477
+ .surface_size = geometry.SizeF.init(24, 24),
478
+ .full_repaint = true,
479
+ }, Color.rgb8(255, 255, 255));
480
+ // Sample strictly inside the accent fill (the 16px box spans y 4-20;
481
+ // stay clear of its border ring and corners) and count pixels that
482
+ // blend between the dark fill and the light mark.
483
+ var partial: usize = 0;
484
+ var y: usize = 6;
485
+ while (y < 18) : (y += 1) {
486
+ var x: usize = 2;
487
+ while (x < 14) : (x += 1) {
488
+ const value = pixels[(y * 24 + x) * 4];
489
+ if (value > 60 and value < 200) partial += 1;
490
+ }
491
+ }
492
+ try std.testing.expect(partial >= 4);
493
+ try std.testing.expectEqual(@as(u64, 12485073109273199295), support.referenceSurfaceSignature(&pixels));
494
+ }
495
+
496
+ test "a builder accumulating two widget trees keeps each checkbox mark's own geometry" {
497
+ const tokens = DesignTokens{};
498
+ const first = Widget{
499
+ .id = 63,
500
+ .kind = WidgetKind.checkbox,
501
+ .frame = geometry.RectF.init(0, 0, 24, 24),
502
+ .value = 1,
503
+ };
504
+ const second = Widget{
505
+ .id = 64,
506
+ .kind = WidgetKind.checkbox,
507
+ .frame = geometry.RectF.init(40, 8, 48, 48),
508
+ .value = 1,
509
+ };
510
+
511
+ // Snapshot the first mark's vertices from a solo emit, deep-copied
512
+ // before any other emission runs.
513
+ var solo_commands: [8]CanvasCommand = undefined;
514
+ var solo_builder = Builder.init(&solo_commands);
515
+ try emitWidgetTree(&solo_builder, first, tokens);
516
+ var expected: [3]canvas.PathElement = undefined;
517
+ switch (solo_builder.displayList().findCommandById(widgetPartId(63, 4)).?.command) {
518
+ .stroke_path => |stroke| {
519
+ try std.testing.expectEqual(@as(usize, 3), stroke.elements.len);
520
+ @memcpy(&expected, stroke.elements[0..3]);
521
+ },
522
+ else => return error.TestUnexpectedResult,
523
+ }
524
+
525
+ // One builder accumulating two separately emitted trees: the first
526
+ // tree's mark command must still describe the FIRST checkbox after
527
+ // the second emit — its elements live in builder-owned storage, so
528
+ // no later emission can overwrite them out from under the retained
529
+ // display list.
530
+ var commands: [16]CanvasCommand = undefined;
531
+ var builder = Builder.init(&commands);
532
+ try emitWidgetTree(&builder, first, tokens);
533
+ try emitWidgetTree(&builder, second, tokens);
534
+ switch (builder.displayList().findCommandById(widgetPartId(63, 4)).?.command) {
535
+ .stroke_path => |stroke| {
536
+ try std.testing.expectEqual(@as(usize, 3), stroke.elements.len);
537
+ for (expected, stroke.elements) |expected_element, element| {
538
+ try std.testing.expectEqual(expected_element.verb, element.verb);
539
+ try std.testing.expectEqual(expected_element.points[0], element.points[0]);
540
+ }
541
+ },
542
+ else => return error.TestUnexpectedResult,
543
+ }
544
+ }
545
+
439
546
  test "app-registered icons draw through the widget paths like built-ins" {
440
547
  var buffer = canvas.svg_icon.IconBuffer{};
441
548
  const parsed = try canvas.svg_icon.parse(
@@ -3158,3 +3265,87 @@ test "theme packs resolve by name and compose with every theme axis" {
3158
3265
  // Fields the override left null keep the pack's values.
3159
3266
  try std.testing.expectEqual(geist_light.metrics.control_height_lg, overridden.metrics.control_height_lg);
3160
3267
  }
3268
+
3269
+ test "hairline borders snap to whole device columns with smooth arcs" {
3270
+ const snapHairlineStrokeRect = @import("widget_render_style.zig").snapHairlineStrokeRect;
3271
+ const white = Color{ .r = 1, .g = 1, .b = 1, .a = 1 };
3272
+
3273
+ // Inactive without the geometry token or a usable scale.
3274
+ const unsnapped: StrokeRect = .{ .rect = geometry.RectF.init(4, 3, 24, 14), .radius = Radius.all(6), .stroke = .{ .fill = .{ .color = white }, .width = 1 } };
3275
+ const off = DesignTokens{ .pixel_snap = .{ .geometry = false, .scale = 1 } };
3276
+ try std.testing.expectEqual(unsnapped.rect.x, snapHairlineStrokeRect(off, unsnapped).rect.x);
3277
+
3278
+ // 1x: a 1px border pulls its centerline half a pixel inward so the
3279
+ // band covers exactly one column with its outer edge on the frame.
3280
+ const at_1x = DesignTokens{ .pixel_snap = .{ .geometry = true, .scale = 1 } };
3281
+ const snapped = snapHairlineStrokeRect(at_1x, unsnapped);
3282
+ try std.testing.expectEqual(@as(f32, 4.5), snapped.rect.x);
3283
+ try std.testing.expectEqual(@as(f32, 3.5), snapped.rect.y);
3284
+ try std.testing.expectEqual(@as(f32, 23), snapped.rect.width);
3285
+ try std.testing.expectEqual(@as(f32, 1), snapped.stroke.width);
3286
+ // The outer arc keeps the frame's radius: centerline radius shrinks
3287
+ // by the half-width inset.
3288
+ try std.testing.expectEqual(@as(f32, 5.5), snapped.radius.top_left);
3289
+
3290
+ // Wider borders keep true geometry (device width above the
3291
+ // hairline range).
3292
+ const wide: StrokeRect = .{ .rect = geometry.RectF.init(4, 3, 24, 14), .radius = Radius.all(6), .stroke = .{ .fill = .{ .color = white }, .width = 3 } };
3293
+ try std.testing.expectEqual(@as(f32, 4), snapHairlineStrokeRect(at_1x, wide).rect.x);
3294
+
3295
+ // Fractional scale: snapping happens on the DEVICE grid. At 1.25x a
3296
+ // 1px logical border snaps to one device pixel (0.8 logical) — the
3297
+ // floor of its exact 1.25-device width — and a frame edge at
3298
+ // logical 4 (device 5) pulls the centerline to device 5.5 =
3299
+ // logical 4.4.
3300
+ const at_fractional = DesignTokens{ .pixel_snap = .{ .geometry = true, .scale = 1.25 } };
3301
+ const fractional = snapHairlineStrokeRect(at_fractional, unsnapped);
3302
+ try std.testing.expectEqual(@as(f32, 4.4), fractional.rect.x);
3303
+ try std.testing.expectEqual(@as(f32, 0.8), fractional.stroke.width);
3304
+
3305
+ // At 1.5x the exact device width of a 1px logical border is 1.5 —
3306
+ // between grid widths — and the snap takes the FLOOR: one device
3307
+ // column (2/3 logical), the crisp-and-light choice, never two. The
3308
+ // frame edge at logical 4 (device 6) pulls the centerline to
3309
+ // device 6.5.
3310
+ const at_halfstep = DesignTokens{ .pixel_snap = .{ .geometry = true, .scale = 1.5 } };
3311
+ const halfstep = snapHairlineStrokeRect(at_halfstep, unsnapped);
3312
+ try std.testing.expectEqual(@as(f32, 6.5 / 1.5), halfstep.rect.x);
3313
+ try std.testing.expectEqual(@as(f32, 1.0 / 1.5), halfstep.stroke.width);
3314
+
3315
+ // A stroke whose device width rounds to zero stays unsnapped — the
3316
+ // floor's one-pixel minimum never darkens a sub-half-pixel stroke.
3317
+ var whisper = unsnapped;
3318
+ whisper.stroke.width = 0.25;
3319
+ try std.testing.expectEqual(@as(f32, 0.25), snapHairlineStrokeRect(at_halfstep, whisper).stroke.width);
3320
+ try std.testing.expectEqual(unsnapped.rect.x, snapHairlineStrokeRect(at_halfstep, whisper).rect.x);
3321
+
3322
+ // Rendered at 1x, the straight runs land as exactly one full-alpha
3323
+ // column inside the frame — no half-covered neighbors — while the
3324
+ // corners keep fractional arc coverage from the continuous field.
3325
+ var pixels: [40 * 24 * 4]u8 = undefined;
3326
+ const surface = try ReferenceRenderSurface.init(40, 24, &pixels);
3327
+ const bounds = geometry.RectF.init(0, 0, 40, 24);
3328
+ const command = RenderCommand{
3329
+ .command = .{ .stroke_rect = snapped },
3330
+ .local_bounds = bounds,
3331
+ .bounds = bounds,
3332
+ };
3333
+ try surface.renderPass(.{
3334
+ .surface_size = geometry.SizeF.init(40, 24),
3335
+ .scale = 1,
3336
+ .full_repaint = true,
3337
+ .commands = &.{command},
3338
+ }, Color{ .r = 0, .g = 0, .b = 0, .a = 0 });
3339
+ // Mid-height row: outside column empty, frame column fully inked,
3340
+ // next column inside empty again.
3341
+ try std.testing.expectEqual(@as(u8, 0), surface.pixelRgba8(3, 10)[3]);
3342
+ try std.testing.expectEqual(@as(u8, 255), surface.pixelRgba8(4, 10)[3]);
3343
+ try std.testing.expectEqual(@as(u8, 0), surface.pixelRgba8(5, 10)[3]);
3344
+ // Mid-width column: same on the top run.
3345
+ try std.testing.expectEqual(@as(u8, 0), surface.pixelRgba8(16, 2)[3]);
3346
+ try std.testing.expectEqual(@as(u8, 255), surface.pixelRgba8(16, 3)[3]);
3347
+ try std.testing.expectEqual(@as(u8, 0), surface.pixelRgba8(16, 4)[3]);
3348
+ // Corner pixels carry fractional arc coverage — smooth, not binary.
3349
+ const corner = surface.pixelRgba8(5, 4)[3];
3350
+ try std.testing.expect(corner > 0 and corner < 255);
3351
+ }
@@ -87,6 +87,7 @@ const widgetAccentForegroundColor = widget_render_style.widgetAccentForegroundCo
87
87
  const widgetRadius = widget_render_style.widgetRadius;
88
88
  pub const controlRadius = widget_render_style.controlRadius;
89
89
  pub const controlStrokeWidth = widget_render_style.controlStrokeWidth;
90
+ const snapHairlineStrokeRect = widget_render_style.snapHairlineStrokeRect;
90
91
  pub const selectControlVisualTokens = widget_render_style.selectControlVisualTokens;
91
92
  pub const textInputControlVisualTokens = widget_render_style.textInputControlVisualTokens;
92
93
  const alertControlVisualTokens = widget_render_style.alertControlVisualTokens;
@@ -112,29 +113,23 @@ pub const sliderWidgetKnobRect = widget_render_controls.sliderWidgetKnobRect;
112
113
 
113
114
  const max_widget_depth: usize = 32;
114
115
 
115
- /// Frame-lifetime scratch for widget-built path elements: `.chart`
116
- /// widgets build their line/band `PathElement`s here at emit time, and
117
- /// `.spinner` widgets their arc segment (unlike icons, whose elements
118
- /// are comptime-static); emitted commands slice into it. The event loop
119
- /// is single-threaded and the runtime copies the display list into
120
- /// per-view storage within the same emit call stack, so one threadlocal
121
- /// buffer per frame is sound — reset at each emit entry point. Sized to
122
- /// mirror the runtime's per-view path-element budget
123
- /// (`canvas_limits.max_canvas_path_elements_per_view`; a lockstep test
124
- /// keeps them equal), so overflow here fails exactly where the per-view
125
- /// copy would have refused anyway — loudly, by budget name.
126
- threadlocal var frame_path_elements: [chart_model.max_chart_path_elements_per_frame]drawing_model.PathElement = undefined;
127
- threadlocal var frame_path_len: usize = 0;
116
+ // Widget-built path elements (`.chart` lines/bands, the `.spinner` arc
117
+ // and segments, the `.checkbox` check mark — unlike icons, whose
118
+ // elements are comptime-static) allocate from the display-list builder's
119
+ // own store (`Builder.allocPathElements`), so the emitted commands'
120
+ // element slices share the builder's lifetime instead of pointing into
121
+ // shared scratch that a later emission could overwrite.
128
122
 
129
123
  /// Frame-lifetime scratch for formatted chart label text (y tick values
130
- /// and hover-detail rows): `drawText` commands slice into it under the
131
- /// same single-threaded copy-before-return contract as the path
132
- /// elements above. Overflow fails loudly by budget name.
124
+ /// and hover-detail rows): `drawText` commands slice into it. The event
125
+ /// loop is single-threaded and the runtime copies the display list into
126
+ /// per-view storage within the same emit call stack, so one threadlocal
127
+ /// buffer per frame is sound — reset at each emit entry point. Overflow
128
+ /// fails loudly by budget name.
133
129
  threadlocal var frame_label_bytes: [chart_model.max_chart_label_bytes_per_frame]u8 = undefined;
134
130
  threadlocal var frame_label_len: usize = 0;
135
131
 
136
- fn resetFramePathScratch() void {
137
- frame_path_len = 0;
132
+ fn resetFrameLabelScratch() void {
138
133
  frame_label_len = 0;
139
134
  }
140
135
 
@@ -149,21 +144,14 @@ fn allocFrameLabelBytes(text: []const u8) Error![]const u8 {
149
144
  }
150
145
 
151
146
  /// Frame-lifetime scratch (same single-threaded emit contract as the
152
- /// path-element scratch above) holding the root bounds of the tree being
147
+ /// label scratch above) holding the root bounds of the tree being
153
148
  /// emitted: the rect a modal surface's scrim covers. Chrome emission
154
149
  /// happens deep in the recursion where no ancestor frame is in scope, so
155
150
  /// the entry points record it here.
156
151
  threadlocal var scrim_viewport: ?geometry.RectF = null;
157
152
 
158
- fn allocFramePathElements(count: usize) Error![]drawing_model.PathElement {
159
- if (frame_path_len + count > frame_path_elements.len) return error.ChartPathElementListFull;
160
- const start = frame_path_len;
161
- frame_path_len += count;
162
- return frame_path_elements[start .. start + count];
163
- }
164
-
165
153
  pub fn emitWidgetTree(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
166
- resetFramePathScratch();
154
+ resetFrameLabelScratch();
167
155
  scrim_viewport = widget.frame.normalized();
168
156
  try emitWidgetDepth(builder, widget, tokens, 0);
169
157
  }
@@ -173,7 +161,7 @@ pub fn emitWidgetLayout(builder: *Builder, layout: anytype, tokens: DesignTokens
173
161
  }
174
162
 
175
163
  pub fn emitWidgetLayoutWithState(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
176
- resetFramePathScratch();
164
+ resetFrameLabelScratch();
177
165
  scrim_viewport = widgetLayoutRootBounds(layout);
178
166
  try emitWidgetLayoutChildren(builder, layout, null, tokens, state);
179
167
  try emitWidgetLayoutAnchored(builder, layout, tokens, state);
@@ -1201,7 +1189,7 @@ fn emitAvatarWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Err
1201
1189
  });
1202
1190
  }
1203
1191
 
1204
- try builder.strokeRect(.{
1192
+ try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
1205
1193
  .id = widgetPartId(widget.id, 4),
1206
1194
  .rect = widget.frame,
1207
1195
  .radius = radius,
@@ -1209,7 +1197,7 @@ fn emitAvatarWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Err
1209
1197
  .fill = widgetBorderFill(widget, visual.border orelse tokens.colors.border),
1210
1198
  .width = controlStrokeWidth(widget, visual, tokens.stroke.hairline),
1211
1199
  },
1212
- });
1200
+ }));
1213
1201
  }
1214
1202
 
1215
1203
  fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
@@ -1223,7 +1211,7 @@ fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Erro
1223
1211
  .radius = radius,
1224
1212
  .fill = colorFill(badgeBackgroundColor(widget, tokens, visual)),
1225
1213
  });
1226
- try builder.strokeRect(.{
1214
+ try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
1227
1215
  .id = widgetPartId(widget.id, 2),
1228
1216
  .rect = widget.frame,
1229
1217
  .radius = radius,
@@ -1231,7 +1219,7 @@ fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Erro
1231
1219
  .fill = widgetBorderFill(widget, badgeBorderColor(widget, tokens, visual)),
1232
1220
  .width = badgeStrokeWidth(widget, tokens, visual),
1233
1221
  },
1234
- });
1222
+ }));
1235
1223
  const content_color = badgeTextColor(widget, tokens, visual);
1236
1224
  // Inline vector icon: icon-only badges center it (the stepper's
1237
1225
  // completed check, status chips); icon + text draws it before the
@@ -1329,7 +1317,7 @@ fn emitSplitDividerWidget(builder: *Builder, widget: Widget, tokens: DesignToken
1329
1317
  .fill = colorFill(line_color),
1330
1318
  });
1331
1319
  if (widget.state.focused) {
1332
- try builder.strokeRect(.{
1320
+ try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
1333
1321
  .id = widgetPartId(widget.id, 2),
1334
1322
  .rect = pixelSnapGeometryRect(tokens, normalized),
1335
1323
  .radius = Radius.all(tokens.radius.sm),
@@ -1337,7 +1325,7 @@ fn emitSplitDividerWidget(builder: *Builder, widget: Widget, tokens: DesignToken
1337
1325
  .fill = widget_render_style.widgetFocusRingFill(widget, tokens),
1338
1326
  .width = tokens.stroke.focus,
1339
1327
  },
1340
- });
1328
+ }));
1341
1329
  }
1342
1330
  }
1343
1331
 
@@ -1536,7 +1524,7 @@ fn emitSpinnerArc(builder: *Builder, widget: Widget, visual: ControlVisualTokens
1536
1524
  const delta_degrees = spinner_arc_sweep_degrees / @as(f32, @floatFromInt(segment_total));
1537
1525
  const kappa = (4.0 / 3.0) * @tan(std.math.degreesToRadians(delta_degrees) * 0.25) * radius;
1538
1526
 
1539
- const elements = try allocFramePathElements(1 + segment_total);
1527
+ const elements = try builder.allocPathElements(1 + segment_total);
1540
1528
  const start_radians = std.math.degreesToRadians(start_degrees);
1541
1529
  elements[0] = .{ .verb = .move_to, .points = .{
1542
1530
  geometry.PointF.init(center.x + radius * @cos(start_radians), center.y + radius * @sin(start_radians)),
@@ -1622,7 +1610,7 @@ fn emitSpinnerSegments(builder: *Builder, widget: Widget, tokens: DesignTokens,
1622
1610
  const f = geometry.PointF.init(inner.x - cap * v.x, inner.y - cap * v.y);
1623
1611
  const inner_mid = geometry.PointF.init(inner.x - cap * u.x, inner.y - cap * u.y);
1624
1612
 
1625
- const elements = try allocFramePathElements(8);
1613
+ const elements = try builder.allocPathElements(8);
1626
1614
  elements[0] = .{ .verb = .move_to, .points = .{ a, geometry.PointF.zero(), geometry.PointF.zero() } };
1627
1615
  elements[1] = .{ .verb = .line_to, .points = .{ b, geometry.PointF.zero(), geometry.PointF.zero() } };
1628
1616
  elements[2] = .{ .verb = .cubic_to, .points = .{
@@ -1987,7 +1975,7 @@ fn emitChartLine(
1987
1975
 
1988
1976
  if (series.fill) {
1989
1977
  const base_y = chartMapY(chartBaselineValue(domain), domain, plot, 0);
1990
- const elements = try allocFramePathElements(points.len + 3);
1978
+ const elements = try builder.allocPathElements(points.len + 3);
1991
1979
  for (points, 0..) |point, index| {
1992
1980
  elements[index] = .{
1993
1981
  .verb = if (index == 0) .move_to else .line_to,
@@ -2004,7 +1992,7 @@ fn emitChartLine(
2004
1992
  });
2005
1993
  }
2006
1994
 
2007
- const elements = try allocFramePathElements(points.len);
1995
+ const elements = try builder.allocPathElements(points.len);
2008
1996
  for (points, 0..) |point, index| {
2009
1997
  elements[index] = .{
2010
1998
  .verb = if (index == 0) .move_to else .line_to,
@@ -2035,7 +2023,7 @@ fn emitChartBand(
2035
2023
  const base_y = chartMapY(chartBaselineValue(domain), domain, plot, 0);
2036
2024
  const pair_count = @min(series.values.len, series.low.len);
2037
2025
  const lower_count = if (pair_count >= 2) pair_count else 2;
2038
- const elements = try allocFramePathElements(upper.len + lower_count + 1);
2026
+ const elements = try builder.allocPathElements(upper.len + lower_count + 1);
2039
2027
  for (upper, 0..) |point, index| {
2040
2028
  elements[index] = .{
2041
2029
  .verb = if (index == 0) .move_to else .line_to,
@@ -2322,12 +2310,12 @@ fn emitChartHoverDetail(builder: *Builder, widget: Widget, tokens: DesignTokens,
2322
2310
  .radius = radius,
2323
2311
  .fill = colorFill(tokens.colors.surface),
2324
2312
  });
2325
- try builder.strokeRect(.{
2313
+ try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
2326
2314
  .id = chartCommandId(widget.id, chart_hover_seed, 0, 3),
2327
2315
  .rect = card,
2328
2316
  .radius = radius,
2329
2317
  .stroke = .{ .fill = colorFill(tokens.colors.border), .width = hairline },
2330
- });
2318
+ }));
2331
2319
 
2332
2320
  // Title line, then one swatch/name/value row per series holding
2333
2321
  // this sample. Values right-align on the card's inner edge so a