@native-sdk/cli 0.7.0 → 0.7.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.
- package/build/app.zig +8 -0
- package/build.zig +114 -103
- package/native-sdk.d.ts +6 -3
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/text.ts +25 -14
- package/packages/core/src/checker.ts +39 -0
- package/packages/core/src/emitter.ts +125 -1
- package/skill-data/native-ui/SKILL.md +11 -7
- package/src/platform/macos/appkit_host.m +76 -4
- package/src/platform/macos/cef_host.mm +24 -2
- package/src/platform/macos/root.zig +13 -0
- package/src/platform/types.zig +4 -0
- package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
- package/src/platform/windows/gpu_surface_renderer.h +86 -0
- package/src/platform/windows/root.zig +298 -20
- package/src/platform/windows/webview2_host.cpp +343 -33
- package/src/primitives/canvas/code.zig +501 -33
- package/src/primitives/canvas/code_tests.zig +1029 -6
- package/src/primitives/canvas/events.zig +111 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/markdown_tests.zig +17 -18
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/text.zig +6 -0
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +160 -36
- package/src/primitives/canvas/ui_markup.zig +60 -9
- package/src/primitives/canvas/ui_markup_compiled.zig +41 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +12 -0
- package/src/primitives/canvas/ui_markup_contract.zig +17 -1
- package/src/primitives/canvas/ui_markup_view.zig +44 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +80 -6
- package/src/primitives/canvas/ui_schema.zig +18 -0
- package/src/primitives/canvas/ui_schema_tests.zig +10 -7
- package/src/primitives/canvas/ui_tests.zig +40 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +12 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +47 -6
- package/src/primitives/canvas/widget_render.zig +849 -78
- package/src/primitives/canvas/widget_render_controls.zig +83 -25
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_runtime.zig +2 -0
- package/src/primitives/canvas/widget_text_input.zig +167 -8
- package/src/primitives/canvas/widget_tree.zig +6 -5
- package/src/primitives/canvas/widgets.zig +78 -2
- package/src/runtime/canvas_budget_edge_tests.zig +3 -2
- package/src/runtime/canvas_frame.zig +60 -7
- package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
- package/src/runtime/canvas_frame_packet_tests.zig +83 -9
- package/src/runtime/canvas_frame_patch_tests.zig +16 -0
- package/src/runtime/canvas_images.zig +8 -2
- package/src/runtime/canvas_limits.zig +13 -6
- package/src/runtime/canvas_widget_clipboard_tests.zig +8 -5
- package/src/runtime/canvas_widget_context_menu.zig +7 -2
- package/src/runtime/canvas_widget_event_tests.zig +18 -14
- package/src/runtime/canvas_widget_events.zig +51 -20
- package/src/runtime/canvas_widget_runtime.zig +108 -4
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +59 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +100 -0
- package/src/runtime/canvas_widget_state.zig +27 -0
- package/src/runtime/canvas_widget_text_tests.zig +326 -0
- package/src/runtime/core.zig +15 -5
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +50 -19
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +60 -16
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_scroll.zig +48 -18
- package/src/runtime/view_widget_text.zig +59 -16
- package/src/runtime/window_view_runtime.zig +10 -0
- package/src/tooling/templates.zig +9 -6
|
@@ -134,6 +134,104 @@ pub fn widgetKeyboardNewlineTextEditEvent(kind: WidgetKind, event: WidgetKeyboar
|
|
|
134
134
|
return .{ .insert_text = "\n" };
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/// Editable code owns a plain Tab as indentation input. The file's
|
|
138
|
+
/// leading whitespace votes for tabs versus spaces; space widths 2..8
|
|
139
|
+
/// compete by how many indentation levels they divide cleanly, with the
|
|
140
|
+
/// wider width winning exact ties (4-space files also divide by 2).
|
|
141
|
+
/// Ambiguous or unindented source falls back to two spaces.
|
|
142
|
+
pub fn widgetCodeTabTextEditEvent(widget: Widget, event: WidgetKeyboardEvent) ?TextInputEvent {
|
|
143
|
+
if (widget.kind != .textarea or !widget.code_editor or widget.state.disabled) return null;
|
|
144
|
+
if (event.phase != .key_down or event.focus_moved or event.text.len != 0) return null;
|
|
145
|
+
if (event.modifiers.shift or event.modifiers.hasNavigationModifier()) return null;
|
|
146
|
+
if (!std.ascii.eqlIgnoreCase(event.key, "tab")) return null;
|
|
147
|
+
return .{ .insert_text = codeIndentationInsertion(widget) };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const CodeIndentKind = enum { none, spaces, tabs };
|
|
151
|
+
|
|
152
|
+
fn codeIndentationInsertion(widget: Widget) []const u8 {
|
|
153
|
+
var tab_lines: usize = 0;
|
|
154
|
+
var space_lines: usize = 0;
|
|
155
|
+
var space_width_scores: [9]usize = @splat(0);
|
|
156
|
+
var only_space_indent: ?usize = null;
|
|
157
|
+
|
|
158
|
+
var line_start: usize = 0;
|
|
159
|
+
while (line_start <= widget.text.len) {
|
|
160
|
+
const newline = std.mem.indexOfScalarPos(u8, widget.text, line_start, '\n');
|
|
161
|
+
const line_end = newline orelse widget.text.len;
|
|
162
|
+
const line = widget.text[line_start..line_end];
|
|
163
|
+
var cursor: usize = 0;
|
|
164
|
+
var spaces: usize = 0;
|
|
165
|
+
var tabs: usize = 0;
|
|
166
|
+
while (cursor < line.len) : (cursor += 1) {
|
|
167
|
+
switch (line[cursor]) {
|
|
168
|
+
' ' => spaces += 1,
|
|
169
|
+
'\t' => tabs += 1,
|
|
170
|
+
else => break,
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Whitespace-only lines do not state a file convention.
|
|
174
|
+
if (cursor < line.len and cursor > 0) {
|
|
175
|
+
if (tabs > 0) {
|
|
176
|
+
tab_lines += 1;
|
|
177
|
+
} else {
|
|
178
|
+
space_lines += 1;
|
|
179
|
+
only_space_indent = if (space_lines == 1) spaces else null;
|
|
180
|
+
for (2..space_width_scores.len) |width| {
|
|
181
|
+
if (spaces % width == 0) space_width_scores[width] += 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (newline == null) break;
|
|
187
|
+
line_start = line_end + 1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const selection = widget.text_selection orelse text_model.TextSelection.collapsed(widget.text.len);
|
|
191
|
+
const local_kind = codeIndentKindAt(widget.text, selection.focus);
|
|
192
|
+
const tabs_win = tab_lines > space_lines or
|
|
193
|
+
(tab_lines == space_lines and tab_lines > 0 and local_kind == .tabs);
|
|
194
|
+
if (tabs_win) return "\t";
|
|
195
|
+
|
|
196
|
+
var inferred_width: usize = 2;
|
|
197
|
+
if (space_lines == 1) {
|
|
198
|
+
const width = only_space_indent orelse 0;
|
|
199
|
+
if (width >= 2 and width <= 8) inferred_width = width;
|
|
200
|
+
} else if (space_lines > 1) {
|
|
201
|
+
var best_width: usize = 2;
|
|
202
|
+
var best_score: usize = 0;
|
|
203
|
+
for (2..space_width_scores.len) |width| {
|
|
204
|
+
const score = space_width_scores[width];
|
|
205
|
+
if (score > best_score or (score == best_score and score > 0 and width > best_width)) {
|
|
206
|
+
best_width = width;
|
|
207
|
+
best_score = score;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (best_score * 2 >= space_lines) inferred_width = best_width;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return switch (inferred_width) {
|
|
214
|
+
3 => " ",
|
|
215
|
+
4 => " ",
|
|
216
|
+
5 => " ",
|
|
217
|
+
6 => " ",
|
|
218
|
+
7 => " ",
|
|
219
|
+
8 => " ",
|
|
220
|
+
else => " ",
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
fn codeIndentKindAt(text: []const u8, offset: usize) CodeIndentKind {
|
|
225
|
+
const caret = @min(offset, text.len);
|
|
226
|
+
const line_start = if (std.mem.lastIndexOfScalar(u8, text[0..caret], '\n')) |newline| newline + 1 else 0;
|
|
227
|
+
if (line_start >= text.len) return .none;
|
|
228
|
+
return switch (text[line_start]) {
|
|
229
|
+
'\t' => .tabs,
|
|
230
|
+
' ' => .spaces,
|
|
231
|
+
else => .none,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
137
235
|
/// The single-line text-entry kinds: their value can never hold a line
|
|
138
236
|
/// break (Enter submits instead of editing — see
|
|
139
237
|
/// `widgetKeyboardNewlineTextEditEvent`), so text inserted into them
|
|
@@ -152,7 +250,7 @@ pub fn widgetKindSingleLineTextEntry(kind: WidgetKind) bool {
|
|
|
152
250
|
/// runtime's per-view widget-text budget
|
|
153
251
|
/// (`max_canvas_widget_text_bytes_per_view`), the largest insert the
|
|
154
252
|
/// editor could accept anyway.
|
|
155
|
-
const max_sanitized_text_edit_bytes: usize =
|
|
253
|
+
const max_sanitized_text_edit_bytes: usize = text_model.max_widget_text_bytes_per_view;
|
|
156
254
|
const SanitizedTextEditScratch = struct {
|
|
157
255
|
bytes: [max_sanitized_text_edit_bytes]u8,
|
|
158
256
|
};
|
|
@@ -946,3 +1044,15 @@ test "sanitizedSingleLineTextInputEvent strips composition text and shifts the p
|
|
|
946
1044
|
const multi = sanitizedSingleLineTextInputEvent(.textarea, .{ .set_composition = .{ .text = "a\nb" } }).?;
|
|
947
1045
|
try testing.expectEqualStrings("a\nb", multi.set_composition.text);
|
|
948
1046
|
}
|
|
1047
|
+
|
|
1048
|
+
test "sanitizedSingleLineTextInputEvent sanitizes inserts above the former 64 KiB ceiling" {
|
|
1049
|
+
const testing = std.testing;
|
|
1050
|
+
const input = try testing.allocator.alloc(u8, 65537);
|
|
1051
|
+
defer testing.allocator.free(input);
|
|
1052
|
+
@memset(input, 'a');
|
|
1053
|
+
input[32768] = '\n';
|
|
1054
|
+
|
|
1055
|
+
const sanitized = sanitizedSingleLineTextInputEvent(.text_field, .{ .insert_text = input }).?;
|
|
1056
|
+
try testing.expectEqual(@as(usize, input.len - 1), sanitized.insert_text.len);
|
|
1057
|
+
try testing.expect(std.mem.indexOfAny(u8, sanitized.insert_text, "\r\n") == null);
|
|
1058
|
+
}
|
|
@@ -599,7 +599,7 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
599
599
|
storage.text_layout_cache_actions,
|
|
600
600
|
);
|
|
601
601
|
|
|
602
|
-
|
|
602
|
+
var full_repaint = options.full_repaint or previous == null;
|
|
603
603
|
var changes: []const DiffChange = storage.changes[0..0];
|
|
604
604
|
var dirty_bounds: ?geometry.RectF = null;
|
|
605
605
|
|
|
@@ -615,6 +615,18 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
615
615
|
// pixels so a fractional dirty edge cannot erase an unchanged
|
|
616
616
|
// neighbor's boundary-pixel coverage without redrawing it.
|
|
617
617
|
dirty_bounds = bleedAlignedDirtyBounds(unionOptionalBounds(dirtyBoundsFromChanges(changes), render_override_dirty_bounds), options.scale, 1, options.surface_size);
|
|
618
|
+
if (incrementalDamageIntersectsBackdropBlur(render_plan.commands, dirty_bounds)) {
|
|
619
|
+
// A backdrop blur reads pixels around its output from the
|
|
620
|
+
// destination as it existed at this point in draw order.
|
|
621
|
+
// Retained pixels outside an incremental scissor already
|
|
622
|
+
// contain the PREVIOUS frame's blur and later commands, so
|
|
623
|
+
// they cannot supply that pre-blur backdrop. Reconstruct it
|
|
624
|
+
// by replaying the complete list whenever damage reaches a
|
|
625
|
+
// blur's resolved read footprint.
|
|
626
|
+
full_repaint = true;
|
|
627
|
+
changes = storage.changes[0..0];
|
|
628
|
+
dirty_bounds = fullRepaintBounds(options.surface_size, render_plan.bounds);
|
|
629
|
+
}
|
|
618
630
|
}
|
|
619
631
|
|
|
620
632
|
return .{
|
|
@@ -649,6 +661,38 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
649
661
|
};
|
|
650
662
|
}
|
|
651
663
|
|
|
664
|
+
/// Whether incremental damage reaches a backdrop blur's resolved read
|
|
665
|
+
/// footprint. Replaying only the dirty output is not sufficient: pixels
|
|
666
|
+
/// outside the scissor hold the previous fully composited frame rather
|
|
667
|
+
/// than the backdrop at the blur command's position in draw order.
|
|
668
|
+
pub fn incrementalDamageIntersectsBackdropBlur(commands: []const RenderCommand, dirty_bounds: ?geometry.RectF) bool {
|
|
669
|
+
const dirty = dirty_bounds orelse return false;
|
|
670
|
+
const normalized_dirty = dirty.normalized();
|
|
671
|
+
for (commands) |command| {
|
|
672
|
+
switch (command.command) {
|
|
673
|
+
.blur => |blur| {
|
|
674
|
+
if (!(blur.radius > 0) or !(command.opacity > 0)) continue;
|
|
675
|
+
var output = command.transform.transformRect(blur.rect.normalized());
|
|
676
|
+
if (command.clip) |clip| output = geometry.RectF.intersection(output, clip.normalized());
|
|
677
|
+
if (output.isEmpty()) continue;
|
|
678
|
+
|
|
679
|
+
// Do not use `command.bounds` here: the render planner
|
|
680
|
+
// intersects that inflated bound with the output clip,
|
|
681
|
+
// while a clipped output pixel still samples backdrop
|
|
682
|
+
// pixels up to `radius` OUTSIDE the clip. Transforming
|
|
683
|
+
// the full local read footprint is a conservative AABB
|
|
684
|
+
// for every sample the surviving output can consume.
|
|
685
|
+
const read_footprint = command.transform.transformRect(
|
|
686
|
+
blur.rect.normalized().inflate(geometry.InsetsF.all(@max(0, blur.radius))),
|
|
687
|
+
).normalized();
|
|
688
|
+
if (read_footprint.intersects(normalized_dirty)) return true;
|
|
689
|
+
},
|
|
690
|
+
else => {},
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
|
|
652
696
|
fn dirtyBoundsFromChanges(changes: []const DiffChange) ?geometry.RectF {
|
|
653
697
|
var result: ?geometry.RectF = null;
|
|
654
698
|
for (changes) |change| {
|
|
@@ -552,6 +552,12 @@ pub fn canvasGpuCommandFromRenderCommand(command: RenderCommand, command_index:
|
|
|
552
552
|
packet_command.uses_resource = true;
|
|
553
553
|
},
|
|
554
554
|
.draw_text => |value| {
|
|
555
|
+
// DirectWrite glyph indices are UINT16. A larger author-supplied
|
|
556
|
+
// id cannot ride the positioned-glyph wire faithfully, so keep
|
|
557
|
+
// the packet negotiation truthful and select the pixel path.
|
|
558
|
+
for (value.glyphs) |glyph| {
|
|
559
|
+
if (glyph.id > 65535) return packet_command;
|
|
560
|
+
}
|
|
555
561
|
packet_command.kind = .draw_text;
|
|
556
562
|
packet_command.pipeline = .glyph_run;
|
|
557
563
|
packet_command.paint = .{ .color = value.color };
|
|
@@ -203,8 +203,8 @@ test "markdown maps lists, task lists, code fences, quotes, and rules" {
|
|
|
203
203
|
try testing.expectEqual(canvas.WidgetKind.column, ordered_row.children[0].kind);
|
|
204
204
|
try testing.expectEqualStrings("1.", ordered_row.children[0].children[0].text);
|
|
205
205
|
|
|
206
|
-
//
|
|
207
|
-
try testing.expectEqual(@as(usize,
|
|
206
|
+
// Fences use the same deliberately bare code component.
|
|
207
|
+
try testing.expectEqual(@as(usize, 0), countKind(tree.root, .panel));
|
|
208
208
|
const code = findParagraphContaining(tree.root, "const x = 1;").?;
|
|
209
209
|
try testing.expect(code.spans[0].monospace);
|
|
210
210
|
try testing.expectEqual(@as(?canvas.TextSpanColor, .syntax_keyword), code.spans[0].color);
|
|
@@ -223,22 +223,22 @@ test "language-tagged code fences highlight tokens and preserve indentation" {
|
|
|
223
223
|
\\```
|
|
224
224
|
, .{});
|
|
225
225
|
|
|
226
|
-
const
|
|
226
|
+
const code = findParagraphContaining(tree.root, "pub fn main() void").?;
|
|
227
227
|
var source_text: std.ArrayListUnmanaged(u8) = .empty;
|
|
228
228
|
defer source_text.deinit(testing.allocator);
|
|
229
|
-
try appendParagraphText(
|
|
229
|
+
try appendParagraphText(code, &source_text, testing.allocator);
|
|
230
230
|
try testing.expectEqualStrings(
|
|
231
231
|
"pub fn main() void {\n const message = \"hello\";\n // keep this indentation\n return 42;\n}",
|
|
232
232
|
source_text.items,
|
|
233
233
|
);
|
|
234
|
-
try testing.expect(allSpansMonospace(
|
|
235
|
-
try testing.expect(hasSpan(
|
|
236
|
-
try testing.expect(hasSpan(
|
|
237
|
-
try testing.expect(hasSpan(
|
|
238
|
-
try testing.expect(hasSpan(
|
|
239
|
-
try testing.expect(hasSpan(
|
|
240
|
-
|
|
241
|
-
const indented = findParagraphContaining(
|
|
234
|
+
try testing.expect(allSpansMonospace(code));
|
|
235
|
+
try testing.expect(hasSpan(code, "pub", .syntax_keyword));
|
|
236
|
+
try testing.expect(hasSpan(code, "void", .syntax_literal));
|
|
237
|
+
try testing.expect(hasSpan(code, "\"hello\"", .syntax_literal));
|
|
238
|
+
try testing.expect(hasSpan(code, "// keep this indentation", .syntax_comment));
|
|
239
|
+
try testing.expect(hasSpan(code, "42", .syntax_literal));
|
|
240
|
+
|
|
241
|
+
const indented = findParagraphContaining(code, "const message").?;
|
|
242
242
|
var runs: [text_spans.max_text_span_runs_per_paragraph]text_spans.TextSpanRun = undefined;
|
|
243
243
|
const layout = text_spans.layoutTextSpans(indented.spans, .{ .size = 14, .max_width = 10_000 }, &runs);
|
|
244
244
|
var indented_keyword_x: ?f32 = null;
|
|
@@ -284,12 +284,11 @@ test "per-line syntax highlighting does not drop fenced code" {
|
|
|
284
284
|
var doc = TestDoc.init();
|
|
285
285
|
defer doc.deinit();
|
|
286
286
|
const tree = try doc.build(source, .{});
|
|
287
|
-
const panel = findKind(tree.root, .panel).?;
|
|
288
287
|
var rendered: std.ArrayListUnmanaged(u8) = .empty;
|
|
289
288
|
defer rendered.deinit(testing.allocator);
|
|
290
|
-
try appendParagraphText(
|
|
289
|
+
try appendParagraphText(tree.root, &rendered, testing.allocator);
|
|
291
290
|
try testing.expectEqualStrings(code_source, rendered.items);
|
|
292
|
-
try testing.expect(hasSpan(
|
|
291
|
+
try testing.expect(hasSpan(tree.root, "const", .syntax_keyword));
|
|
293
292
|
}
|
|
294
293
|
|
|
295
294
|
test "details blocks are caller-controlled collapsibles" {
|
|
@@ -480,7 +479,7 @@ test "the README-shaped fixture renders through the mapper and the reference ren
|
|
|
480
479
|
const cli_link = findRoleLabel(tree.root, .link, "`flg`").?;
|
|
481
480
|
const open_msg = tree.msgForPointer(cli_link.id, .up).?;
|
|
482
481
|
try testing.expectEqualStrings("https://example.com/flg", open_msg.open_url);
|
|
483
|
-
try testing.
|
|
482
|
+
try testing.expectEqual(@as(usize, 0), countKind(tree.root, .panel));
|
|
484
483
|
|
|
485
484
|
// Layout + emit + reference-render the document; the pixel signature is
|
|
486
485
|
// the golden. Estimator-driven and provider-free: deterministic.
|
|
@@ -549,11 +548,11 @@ test "the README-shaped fixture renders through the mapper and the reference ren
|
|
|
549
548
|
// scales, wrapped bullets and em-dash spacing at the face's real
|
|
550
549
|
// advances, real sans and mono outlines (fixed-pitch runs sit in their
|
|
551
550
|
// 0.6 em cells), GFM tables as borderless cells on hairline row
|
|
552
|
-
// separators, fenced
|
|
551
|
+
// separators, bare fenced code with preserved source indentation and
|
|
553
552
|
// language-token colors, and near-black underlined links.
|
|
554
553
|
// Update deliberately when markdown rendering changes, reviewing the
|
|
555
554
|
// rendered pixels first (see reference_tests.zig conventions).
|
|
556
|
-
const markdown_document_reference_signature: u64 =
|
|
555
|
+
const markdown_document_reference_signature: u64 = 5787917808851547223;
|
|
557
556
|
|
|
558
557
|
fn markdownGoldenDumpRequested() bool {
|
|
559
558
|
if (comptime !@import("builtin").link_libc) return false;
|
|
@@ -2273,6 +2273,57 @@ test "canvas render pass builds gpu packet for backend handoff" {
|
|
|
2273
2273
|
try std.testing.expect(std.mem.indexOf(u8, packet_json, "\"effect\":{\"kind\":\"blur\",\"rect\":[44,36,20,20],\"radius\":4}") != null);
|
|
2274
2274
|
}
|
|
2275
2275
|
|
|
2276
|
+
test "gpu packet preserves authoritative text glyph positions" {
|
|
2277
|
+
const glyphs = [_]Glyph{.{
|
|
2278
|
+
.id = 65,
|
|
2279
|
+
.x = 9,
|
|
2280
|
+
.y = 13,
|
|
2281
|
+
.advance = 11,
|
|
2282
|
+
.text_len = 1,
|
|
2283
|
+
}};
|
|
2284
|
+
const bounds = geometry.RectF.init(4, 4, 24, 16);
|
|
2285
|
+
const render_commands = [_]RenderCommand{.{
|
|
2286
|
+
.command = .{ .draw_text = .{
|
|
2287
|
+
.id = 1,
|
|
2288
|
+
.font_id = 7,
|
|
2289
|
+
.size = 12,
|
|
2290
|
+
.origin = geometry.PointF.init(4, 16),
|
|
2291
|
+
.color = Color.rgb8(15, 23, 42),
|
|
2292
|
+
.text = "A",
|
|
2293
|
+
.glyphs = &glyphs,
|
|
2294
|
+
} },
|
|
2295
|
+
.id = 1,
|
|
2296
|
+
.local_bounds = bounds,
|
|
2297
|
+
.bounds = bounds,
|
|
2298
|
+
}};
|
|
2299
|
+
|
|
2300
|
+
var gpu_commands: [1]CanvasGpuCommand = undefined;
|
|
2301
|
+
var planner = CanvasGpuPacketPlanner.init(&gpu_commands);
|
|
2302
|
+
const packet = try planner.build(.{
|
|
2303
|
+
.full_repaint = true,
|
|
2304
|
+
.surface_size = geometry.SizeF.init(32, 24),
|
|
2305
|
+
.commands = &render_commands,
|
|
2306
|
+
});
|
|
2307
|
+
|
|
2308
|
+
try std.testing.expect(packet.fullyRepresentable());
|
|
2309
|
+
try std.testing.expectEqual(@as(usize, 0), packet.unsupported_command_count);
|
|
2310
|
+
try std.testing.expectEqual(CanvasGpuCommandKind.draw_text, packet.commands[0].kind);
|
|
2311
|
+
try std.testing.expectEqualDeep(glyphs[0], packet.commands[0].text.?.glyphs[0]);
|
|
2312
|
+
|
|
2313
|
+
var binary_buffer: [512]u8 = undefined;
|
|
2314
|
+
var binary_writer = std.Io.Writer.fixed(&binary_buffer);
|
|
2315
|
+
try packet.writeBinary(&binary_writer);
|
|
2316
|
+
// id=65, no font override, final pen=(origin.x, origin.y + glyph.y),
|
|
2317
|
+
// advance=11 — the compact v5 record DirectWrite consumes.
|
|
2318
|
+
const positioned_glyph_wire = [_]u8{
|
|
2319
|
+
0x41, 0x00, 0x00,
|
|
2320
|
+
0x00, 0x00, 0x80, 0x40,
|
|
2321
|
+
0x00, 0x00, 0xe8, 0x41,
|
|
2322
|
+
0x00, 0x00, 0x30, 0x41,
|
|
2323
|
+
};
|
|
2324
|
+
try std.testing.expect(std.mem.indexOf(u8, binary_writer.buffered(), &positioned_glyph_wire) != null);
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2276
2327
|
test "canvas gpu packet skips clean passes and reports output overflow" {
|
|
2277
2328
|
var clean_gpu_commands: [1]CanvasGpuCommand = undefined;
|
|
2278
2329
|
const clean_packet = try (CanvasRenderPass{}).gpuPacket(&clean_gpu_commands);
|
|
@@ -2893,6 +2944,48 @@ test "canvas frame plan clips incremental dirty bounds to surface" {
|
|
|
2893
2944
|
try std.testing.expect(std.mem.indexOf(u8, profile_json, "\"risk\":\"high\"") != null);
|
|
2894
2945
|
}
|
|
2895
2946
|
|
|
2947
|
+
test "canvas frame plan fully repaints damage inside a backdrop blur apron" {
|
|
2948
|
+
const previous_commands = [_]CanvasCommand{
|
|
2949
|
+
.{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(44, 15, 4, 4), .fill = .{ .color = Color.rgb8(255, 0, 0) } } },
|
|
2950
|
+
.{ .push_clip = .{ .id = 2, .rect = geometry.RectF.init(50, 10, 20, 20) } },
|
|
2951
|
+
.{ .blur = .{ .id = 3, .rect = geometry.RectF.init(50, 10, 20, 20), .radius = 8 } },
|
|
2952
|
+
.pop_clip,
|
|
2953
|
+
};
|
|
2954
|
+
const next_commands = [_]CanvasCommand{
|
|
2955
|
+
.{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(44, 15, 4, 4), .fill = .{ .color = Color.rgb8(0, 0, 255) } } },
|
|
2956
|
+
previous_commands[1],
|
|
2957
|
+
previous_commands[2],
|
|
2958
|
+
previous_commands[3],
|
|
2959
|
+
};
|
|
2960
|
+
|
|
2961
|
+
var render_commands: [2]RenderCommand = undefined;
|
|
2962
|
+
var render_batches: [2]RenderBatch = undefined;
|
|
2963
|
+
var resources: [1]RenderResource = undefined;
|
|
2964
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
2965
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
2966
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
2967
|
+
var changes: [2]DiffChange = undefined;
|
|
2968
|
+
const frame = try (DisplayList{ .commands = &next_commands }).framePlan(.{ .commands = &previous_commands }, .{
|
|
2969
|
+
.surface_size = geometry.SizeF.init(100, 40),
|
|
2970
|
+
}, .{
|
|
2971
|
+
.render_commands = &render_commands,
|
|
2972
|
+
.render_batches = &render_batches,
|
|
2973
|
+
.resources = &resources,
|
|
2974
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
2975
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
2976
|
+
.glyph_atlas_entries = &glyphs,
|
|
2977
|
+
.changes = &changes,
|
|
2978
|
+
});
|
|
2979
|
+
|
|
2980
|
+
// The changed fill ends at x=48, before the blur output begins at
|
|
2981
|
+
// x=50, but inside its radius-8 read footprint. Incremental replay
|
|
2982
|
+
// cannot reconstruct the pre-blur backdrop outside its scissor.
|
|
2983
|
+
try std.testing.expect(frame.full_repaint);
|
|
2984
|
+
try std.testing.expectEqual(@as(usize, 0), frame.changes.len);
|
|
2985
|
+
try expectRect(geometry.RectF.init(0, 0, 100, 40), frame.dirty_bounds);
|
|
2986
|
+
try std.testing.expectEqual(CanvasRenderPassLoadAction.clear, frame.renderPass().loadAction());
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2896
2989
|
test "canvas frame plan leaves unchanged retained frame clean" {
|
|
2897
2990
|
const commands = [_]CanvasCommand{
|
|
2898
2991
|
.{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(0, 0, 40, 40), .fill = .{ .color = Color.rgb8(255, 255, 255) } } },
|
|
@@ -204,6 +204,7 @@ pub const TextCaretDirection = text_model.TextCaretDirection;
|
|
|
204
204
|
pub const TextCaretMove = text_model.TextCaretMove;
|
|
205
205
|
pub const TextCompositionUpdate = text_model.TextCompositionUpdate;
|
|
206
206
|
pub const TextInputEvent = text_model.TextInputEvent;
|
|
207
|
+
pub const max_widget_text_bytes_per_view = text_model.max_widget_text_bytes_per_view;
|
|
207
208
|
pub const TextEditState = text_model.TextEditState;
|
|
208
209
|
pub const TextBuffer = text_model.TextBuffer;
|
|
209
210
|
|
|
@@ -297,6 +298,7 @@ pub const CanvasRenderPass = frame_model.CanvasRenderPass;
|
|
|
297
298
|
pub const CanvasFrame = frame_model.CanvasFrame;
|
|
298
299
|
pub const max_canvas_frame_dirty_rects = frame_model.max_canvas_frame_dirty_rects;
|
|
299
300
|
pub const buildCanvasFrame = frame_model.buildCanvasFrame;
|
|
301
|
+
pub const incrementalDamageIntersectsBackdropBlur = frame_model.incrementalDamageIntersectsBackdropBlur;
|
|
300
302
|
|
|
301
303
|
// Canvas GPU packet and encoder data live in `gpu.zig`; root keeps the public API stable.
|
|
302
304
|
pub const CanvasRenderPassLoadAction = gpu_model.CanvasRenderPassLoadAction;
|
|
@@ -448,6 +450,7 @@ pub const builtinComponentDescriptor = widget_model.builtinComponentDescriptor;
|
|
|
448
450
|
pub const WidgetActions = widget_model.WidgetActions;
|
|
449
451
|
pub const WidgetSemantics = widget_model.WidgetSemantics;
|
|
450
452
|
pub const WidgetContextMenuItem = widget_model.WidgetContextMenuItem;
|
|
453
|
+
pub const CodeDiffLines = widget_model.CodeDiffLines;
|
|
451
454
|
pub const Widget = widget_model.Widget;
|
|
452
455
|
pub const BuiltinComponentOptions = widget_model.BuiltinComponentOptions;
|
|
453
456
|
pub const WidgetCommandPart = widget_model.WidgetCommandPart;
|
|
@@ -637,6 +640,7 @@ pub const WidgetInvalidation = event_model.WidgetInvalidation;
|
|
|
637
640
|
pub const WidgetClipboardAction = event_model.WidgetClipboardAction;
|
|
638
641
|
pub const widgetKeyboardClipboardAction = event_model.widgetKeyboardClipboardAction;
|
|
639
642
|
pub const widgetKeyboardNewlineTextEditEvent = event_model.widgetKeyboardNewlineTextEditEvent;
|
|
643
|
+
pub const widgetCodeTabTextEditEvent = event_model.widgetCodeTabTextEditEvent;
|
|
640
644
|
pub const widgetKindSingleLineTextEntry = event_model.widgetKindSingleLineTextEntry;
|
|
641
645
|
pub const sanitizedSingleLineTextInputEvent = event_model.sanitizedSingleLineTextInputEvent;
|
|
642
646
|
pub const widgetKeyboardControlIntent = event_model.widgetKeyboardControlIntent;
|
|
@@ -718,6 +722,8 @@ pub const textInputViewportForWidget = widget_runtime.textInputViewportForWidget
|
|
|
718
722
|
pub const textInputClearButtonRect = widget_runtime.textInputClearButtonRect;
|
|
719
723
|
pub const textInputClearButtonHitRect = widget_runtime.textInputClearButtonHitRect;
|
|
720
724
|
pub const textInputContentExtentForWidget = widget_runtime.textInputContentExtentForWidget;
|
|
725
|
+
pub const textInputContentWidthForWidget = widget_runtime.textInputContentWidthForWidget;
|
|
726
|
+
pub const cacheTextInputContentWidthForWidget = widget_runtime.cacheTextInputContentWidthForWidget;
|
|
721
727
|
pub const textInputMaxScrollOffsetForWidget = widget_runtime.textInputMaxScrollOffsetForWidget;
|
|
722
728
|
pub const clampedTextInputScrollOffsetForWidget = widget_runtime.clampedTextInputScrollOffsetForWidget;
|
|
723
729
|
pub const textInputMaxHorizontalScrollOffsetForWidget = widget_runtime.textInputMaxHorizontalScrollOffsetForWidget;
|