@native-sdk/cli 0.7.1 → 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.
Files changed (59) hide show
  1. package/build/app.zig +8 -0
  2. package/build.zig +49 -12
  3. package/native-sdk.d.ts +6 -3
  4. package/package.json +9 -9
  5. package/packages/core/package-lock.json +2 -2
  6. package/packages/core/package.json +1 -1
  7. package/skill-data/native-ui/SKILL.md +4 -2
  8. package/src/platform/macos/appkit_host.m +51 -3
  9. package/src/platform/types.zig +4 -0
  10. package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
  11. package/src/platform/windows/gpu_surface_renderer.h +86 -0
  12. package/src/platform/windows/root.zig +298 -20
  13. package/src/platform/windows/webview2_host.cpp +343 -33
  14. package/src/primitives/canvas/code.zig +50 -0
  15. package/src/primitives/canvas/code_tests.zig +174 -1
  16. package/src/primitives/canvas/frame.zig +45 -1
  17. package/src/primitives/canvas/gpu.zig +6 -0
  18. package/src/primitives/canvas/render_tests.zig +93 -0
  19. package/src/primitives/canvas/root.zig +2 -0
  20. package/src/primitives/canvas/serialization.zig +150 -21
  21. package/src/primitives/canvas/themes/geist.zig +51 -5
  22. package/src/primitives/canvas/tokens.zig +33 -4
  23. package/src/primitives/canvas/ui.zig +52 -7
  24. package/src/primitives/canvas/ui_markup.zig +38 -1
  25. package/src/primitives/canvas/ui_markup_compiled.zig +28 -0
  26. package/src/primitives/canvas/ui_markup_contract.zig +9 -0
  27. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  28. package/src/primitives/canvas/ui_markup_view_tests.zig +10 -2
  29. package/src/primitives/canvas/ui_schema.zig +5 -0
  30. package/src/primitives/canvas/ui_schema_tests.zig +4 -3
  31. package/src/primitives/canvas/ui_tests.zig +14 -0
  32. package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
  33. package/src/primitives/canvas/widget_invalidation.zig +11 -1
  34. package/src/primitives/canvas/widget_layout.zig +260 -21
  35. package/src/primitives/canvas/widget_metrics.zig +45 -9
  36. package/src/primitives/canvas/widget_render.zig +220 -70
  37. package/src/primitives/canvas/widget_render_controls.zig +79 -21
  38. package/src/primitives/canvas/widget_render_style.zig +52 -8
  39. package/src/primitives/canvas/widget_text_input.zig +2 -0
  40. package/src/primitives/canvas/widgets.zig +53 -2
  41. package/src/runtime/canvas_frame.zig +60 -7
  42. package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
  43. package/src/runtime/canvas_frame_packet_tests.zig +83 -9
  44. package/src/runtime/canvas_frame_patch_tests.zig +16 -0
  45. package/src/runtime/canvas_images.zig +8 -2
  46. package/src/runtime/canvas_widget_clipboard_tests.zig +1 -1
  47. package/src/runtime/canvas_widget_runtime.zig +11 -8
  48. package/src/runtime/effects.zig +6 -0
  49. package/src/runtime/effects_tests.zig +30 -0
  50. package/src/runtime/gpu_surface_events.zig +38 -7
  51. package/src/runtime/media_surface_tests.zig +1 -1
  52. package/src/runtime/runtime_event_tests.zig +74 -0
  53. package/src/runtime/ui_app.zig +10 -8
  54. package/src/runtime/ui_app_tests.zig +67 -0
  55. package/src/runtime/view.zig +6 -0
  56. package/src/runtime/view_canvas.zig +15 -0
  57. package/src/runtime/view_widget_text.zig +6 -4
  58. package/src/runtime/window_view_runtime.zig +1 -0
  59. package/src/tooling/templates.zig +9 -6
package/build/app.zig CHANGED
@@ -1040,6 +1040,7 @@ fn linkPlatform(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Res
1040
1040
  // fails the compile by design if it cannot be found.
1041
1041
  app_mod.addIncludePath(dep.path("third_party/webview2/include"));
1042
1042
  app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/webview2_host.cpp"), .flags = &.{"-std=c++17"} });
1043
+ app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/gpu_surface_renderer.cpp"), .flags = &.{"-std=c++17"} });
1043
1044
  // WebView2Loader.dll rides next to the installed app
1044
1045
  // executable: the host loads it at runtime to discover
1045
1046
  // the machine's WebView2 runtime. Canvas apps never
@@ -1064,6 +1065,7 @@ fn linkPlatform(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Res
1064
1065
  // WebViewNotFound the moment an app actually uses a
1065
1066
  // WebView.
1066
1067
  app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/webview2_host.cpp"), .flags = &.{ "-std=c++17", "-DNATIVE_SDK_ALLOW_WEBVIEW2_STUB" } });
1068
+ app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/gpu_surface_renderer.cpp"), .flags = &.{"-std=c++17"} });
1067
1069
  },
1068
1070
  .chromium => {
1069
1071
  const cef_check = addCefCheck(b, target, cef_dir);
@@ -1075,6 +1077,7 @@ fn linkPlatform(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Res
1075
1077
  const include_arg = b.fmt("-I{s}", .{cef_dir});
1076
1078
  const define_arg = b.fmt("-DNATIVE_SDK_CEF_DIR=\"{s}\"", .{cef_dir});
1077
1079
  app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/cef_host.cpp"), .flags = &.{ "-std=c++17", include_arg, define_arg } });
1080
+ app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/gpu_surface_renderer.cpp"), .flags = &.{"-std=c++17"} });
1078
1081
  app_mod.addObjectFile(b.path(b.fmt("{s}/libcef_dll_wrapper/libcef_dll_wrapper.lib", .{cef_dir})));
1079
1082
  app_mod.addLibraryPath(b.path(b.fmt("{s}/Release", .{cef_dir})));
1080
1083
  },
@@ -1083,6 +1086,11 @@ fn linkPlatform(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Res
1083
1086
  app_mod.linkSystemLibrary("c++", .{});
1084
1087
  app_mod.linkSystemLibrary("user32", .{});
1085
1088
  app_mod.linkSystemLibrary("gdi32", .{});
1089
+ // Retained gpu_surface packets are composited into a hardware
1090
+ // Direct2D target; DirectWrite draws the engine-measured text
1091
+ // runs (including registered in-memory fonts) on that target.
1092
+ app_mod.linkSystemLibrary("d2d1", .{});
1093
+ app_mod.linkSystemLibrary("dwrite", .{});
1086
1094
  app_mod.linkSystemLibrary("imm32", .{});
1087
1095
  app_mod.linkSystemLibrary("comctl32", .{});
1088
1096
  app_mod.linkSystemLibrary("ole32", .{});
package/build.zig CHANGED
@@ -566,6 +566,9 @@ pub fn build(b: *std.Build) void {
566
566
  .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "\"gpu_surfaces\"" },
567
567
  .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "\"gpuSurfaces\"" },
568
568
  .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuFirstFrameLatencyNs: number" },
569
+ .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuBackend: NativeSdkGpuSurfaceBackend;" },
570
+ .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "export type NativeSdkGpuSurfaceBackendRequest = \"metal\" | \"software\";" },
571
+ .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuBackend?: NativeSdkGpuSurfaceBackendRequest;" },
569
572
  });
570
573
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-ts-toolchain-twins", "Verify the CLI's toolchain-resolution gate and its direct-`zig build` twin stay in lockstep (both resolve the aliased real compiler @typescript/old from packages/core — the same origin runtime imports it from — hold its resolved version against the manifest-read pin, never probe the unused @typescript/typescript6 wrapper, and teach instead of panicking)", &.{
571
574
  // The resolution twins probe the aliased REAL compiler
@@ -630,19 +633,19 @@ pub fn build(b: *std.Build) void {
630
633
  .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "close:function(options){return invoke('native-sdk.view.close',viewSelectorPayload(options))" },
631
634
  });
632
635
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-command-contracts", "Verify command docs match native view update contracts", &.{
633
- .{ .path = "docs/src/app/commands/page.mdx", .pattern = ".text = \"Refreshed\"" },
634
- .{ .path = "docs/src/app/commands/page.mdx", .pattern = "const commands = await window.zero.commands.list();" },
636
+ .{ .path = "docs/src/app/docs/commands/page.mdx", .pattern = ".text = \"Refreshed\"" },
637
+ .{ .path = "docs/src/app/docs/commands/page.mdx", .pattern = "const commands = await window.zero.commands.list();" },
635
638
  });
636
639
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-native-view-contracts", "Verify native surface docs describe view identity", &.{
637
- .{ .path = "docs/src/app/native-surfaces/page.mdx", .pattern = "ViewInfo.id" },
638
- .{ .path = "docs/src/app/native-surfaces/page.mdx", .pattern = "window.zero.views.update(\"status\"" },
639
- .{ .path = "docs/src/app/native-surfaces/page.mdx", .pattern = "first-frame latency budget" },
640
+ .{ .path = "docs/src/app/docs/native-surfaces/page.mdx", .pattern = "ViewInfo.id" },
641
+ .{ .path = "docs/src/app/docs/native-surfaces/page.mdx", .pattern = "window.zero.views.update(\"status\"" },
642
+ .{ .path = "docs/src/app/docs/native-surfaces/page.mdx", .pattern = "first-frame latency budget" },
640
643
  });
641
644
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-shell-manifest-contracts", "Verify app.zon docs describe shell compatibility window labels", &.{
642
- .{ .path = "docs/src/app/app-zon/page.mdx", .pattern = "labels must stay unique across both lists" },
645
+ .{ .path = "docs/src/app/docs/app-zon/page.mdx", .pattern = "labels must stay unique across both lists" },
643
646
  });
644
647
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-media-producer-contracts", "Verify the media producer docs' typed callback stays mirrored by the compile-shaped pin in media_surface_tests.zig", &.{
645
- .{ .path = "docs/src/app/media-producers/page.mdx", .pattern = "producer: media.MediaSurfaceProducer" },
648
+ .{ .path = "docs/src/app/docs/media-producers/page.mdx", .pattern = "producer: media.MediaSurfaceProducer" },
646
649
  .{ .path = "src/runtime/media_surface_tests.zig", .pattern = "producer: media.MediaSurfaceProducer" },
647
650
  });
648
651
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-session-replay-image-codec", "Verify the replay runner installs the host image codec headlessly (the desktop arms cannot link in unit tests; the null-fallback arm is covered in session_tests.zig)", &.{
@@ -986,9 +989,37 @@ pub fn build(b: *std.Build) void {
986
989
  // this step until the encoder comment, the host decoder comment, and
987
990
  // the patterns below move with it.
988
991
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-wire-format-version-prose", "Verify wire-format version prose matches the packet version constant", &.{
989
- .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "pub const binary_packet_version: u8 = 4;" },
990
- .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "Compact binary gpu-surface packet encoding (wire format v4)." },
991
- .{ .path = "src/platform/macos/appkit_host.m", .pattern = "Compact binary gpu-surface packet decoding (wire format v4)." },
992
+ .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "pub const binary_packet_version: u8 = 5;" },
993
+ .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "Compact binary gpu-surface packet encoding (wire format v5)." },
994
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "Compact binary gpu-surface packet decoding (wire format v5)." },
995
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "Compact binary gpu-surface packet decoding (wire format v5)." },
996
+ });
997
+ addFileContainsCheckStep(b, file_contains_checker, test_step, "test-windows-gpu-packet-presenter", "Verify Windows uses retained Direct2D packets with recovery, bounded resources, and dirty-region pixel fallback", &.{
998
+ .{ .path = "src/platform/windows/root.zig", .pattern = ".present_gpu_surface_packet_binary_fn = presentGpuSurfacePacketBinary" },
999
+ .{ .path = "src/platform/windows/root.zig", .pattern = ".backend = if (event.gpu_backend == 1) .direct2d else .software" },
1000
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "view.gpu_surface->present(request, &info)" },
1001
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "InvalidateRect(view.hwnd, &info.dirty_rects[index], FALSE)" },
1002
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "for (size_t y_index = y0; y_index < y1; ++y_index)" },
1003
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "InvalidateRect(view.hwnd, partial_update ? &dirty_pixels : nullptr, FALSE)" },
1004
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "D2D1_RENDER_TARGET_TYPE_HARDWARE" },
1005
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "retained_commands_ = std::move(next_retained)" },
1006
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "PushAxisAlignedClip(d2dRect(requested)" },
1007
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "const float expansion = effect.spread + blur" },
1008
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "releaseImageBitmap(action.id)" },
1009
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "resumeAndDrawBlur" },
1010
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "const Rect target = blurTarget(*command, outer_clip)" },
1011
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "blur_snapshot_->CopyFromBitmap" },
1012
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "command.effect.blur * transformScale(command.transform)" },
1013
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "D2D1_EXTEND_MODE_CLAMP" },
1014
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "!GetClientRect(view.hwnd, &client) || !PtInRect(&client, sample)" },
1015
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "draw_line(text.text, text.origin.x, text.origin.y)" },
1016
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "gpuSurfaceUpdateRegionRects" },
1017
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "info.dirty_rect_count > 0" },
1018
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "view->gpu_force_full_repaint_pending = true" },
1019
+ .{ .path = "src/platform/windows/root.zig", .pattern = ".canvas_frame_full_repaint = event.force_full_repaint != 0" },
1020
+ .{ .path = ".github/scripts/windows-canvas-smoke.sh", .pattern = "gpu_backend=direct2d" },
1021
+ .{ .path = ".github/scripts/windows-effects-smoke.sh", .pattern = "gpu_backend=direct2d" },
1022
+ .{ .path = "build/app.zig", .pattern = "app_mod.linkSystemLibrary(\"d2d1\", .{})" },
992
1023
  });
993
1024
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-gpu-packet-blur-effects", "Verify AppKit GPU packet presenter applies blur effects", &.{
994
1025
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkPacketApplyBlur" },
@@ -1224,8 +1255,8 @@ pub fn build(b: *std.Build) void {
1224
1255
  .{ .path = "src/platform/macos/root.zig", .pattern = ".appearance_changed => state.emit" },
1225
1256
  });
1226
1257
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-builtin-bridge-policy", "Verify bridge policy docs include guarded dialog commands", &.{
1227
- .{ .path = "docs/src/app/security/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1228
- .{ .path = "docs/src/app/bridge/builtin-commands/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1258
+ .{ .path = "docs/src/app/docs/security/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1259
+ .{ .path = "docs/src/app/docs/bridge/builtin-commands/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1229
1260
  });
1230
1261
 
1231
1262
  addTestStep(b, "test-geometry", "Run geometry module tests", geometry_tests);
@@ -1250,6 +1281,12 @@ pub fn build(b: *std.Build) void {
1250
1281
  // on a Windows runner makes that a Windows-native receipt. The same
1251
1282
  // tests also run inside `zig build test` via the canvas-frame shard.
1252
1283
  addTestStep(b, "test-canvas-fonts", "Run the runtime font-registry tests (includes the registered-CJK Chinese receipt)", filteredTestArtifact(b, desktop_mod, "canvas-fonts-tests", &.{"runtime.canvas_font_tests.test"}));
1284
+ // The console-attachment regression is Windows-only, so the general
1285
+ // Linux `zig build test` lane can only compile and skip it. Expose the
1286
+ // exact test as a focused step for the real-Windows CI runner; this
1287
+ // keeps CREATE_NO_WINDOW behavior covered without making that runner
1288
+ // execute the entire framework runtime suite.
1289
+ addTestStep(b, "test-windows-effects-no-console", "Verify Windows effect spawns run without an attached console", filteredTestArtifact(b, desktop_mod, "windows-effects-no-console-tests", &.{"runtime.effects_tests.test.Windows background spawns run without an attached console"}));
1253
1290
  addTestStep(b, "test-automation-protocol", "Run automation protocol tests", automation_protocol_tests);
1254
1291
  addTestStep(b, "test-automation-cli", "Run native automate CLI tests", automation_cli_tests);
1255
1292
  addTestStep(b, "test-markup-cli", "Run native markup CLI tests", markup_cli_tests);
package/native-sdk.d.ts CHANGED
@@ -178,7 +178,10 @@ export type NativeSdkViewKind =
178
178
  | "progress_indicator"
179
179
  | "progressIndicator";
180
180
 
181
- export type NativeSdkGpuSurfaceBackend = "none" | "metal";
181
+ /** Concrete backend reported by GPU surface view and frame state. */
182
+ export type NativeSdkGpuSurfaceBackend = "none" | "metal" | "direct2d" | "software";
183
+ /** Portable backend request accepted when creating a GPU surface. */
184
+ export type NativeSdkGpuSurfaceBackendRequest = "metal" | "software";
182
185
  export type NativeSdkGpuSurfacePixelFormat = "none" | "bgra8_unorm";
183
186
  export type NativeSdkGpuSurfacePresentMode = "none" | "timer";
184
187
  export type NativeSdkGpuSurfaceAlphaMode = "none" | "opaque" | "premultiplied";
@@ -327,8 +330,8 @@ export interface NativeSdkCreateNativeViewOptions extends NativeSdkCreateViewBas
327
330
  kind: NativeSdkNativeViewKind;
328
331
  frame?: NativeSdkRect;
329
332
  url?: never;
330
- /** Only valid for gpu_surface views. Defaults to the first supported backend. */
331
- gpuBackend?: NativeSdkGpuSurfaceBackend;
333
+ /** Only valid for gpu_surface views. Omit to use the first supported backend. */
334
+ gpuBackend?: NativeSdkGpuSurfaceBackendRequest;
332
335
  /** Only valid for gpu_surface views. */
333
336
  gpuPixelFormat?: NativeSdkGpuSurfacePixelFormat;
334
337
  /** Only valid for gpu_surface views. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,14 +32,14 @@
32
32
  "@typescript/typescript6": "6.0.2"
33
33
  },
34
34
  "optionalDependencies": {
35
- "@native-sdk/cli-darwin-arm64": "0.7.1",
36
- "@native-sdk/cli-darwin-x64": "0.7.1",
37
- "@native-sdk/cli-linux-arm64-gnu": "0.7.1",
38
- "@native-sdk/cli-linux-arm64-musl": "0.7.1",
39
- "@native-sdk/cli-linux-x64-gnu": "0.7.1",
40
- "@native-sdk/cli-linux-x64-musl": "0.7.1",
41
- "@native-sdk/cli-win32-arm64": "0.7.1",
42
- "@native-sdk/cli-win32-x64": "0.7.1"
35
+ "@native-sdk/cli-darwin-arm64": "0.7.2",
36
+ "@native-sdk/cli-darwin-x64": "0.7.2",
37
+ "@native-sdk/cli-linux-arm64-gnu": "0.7.2",
38
+ "@native-sdk/cli-linux-arm64-musl": "0.7.2",
39
+ "@native-sdk/cli-linux-x64-gnu": "0.7.2",
40
+ "@native-sdk/cli-linux-x64-musl": "0.7.2",
41
+ "@native-sdk/cli-win32-arm64": "0.7.2",
42
+ "@native-sdk/cli-win32-x64": "0.7.2"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.7.1",
9
+ "version": "0.7.2",
10
10
  "devDependencies": {
11
11
  "@typescript/old": "npm:typescript@6.0.3",
12
12
  "@typescript/typescript6": "6.0.2"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "The TypeScript authoring tier: the app-core subset, its dev-time transpiler to arena-backed Zig, and the SDK module cores import",
5
5
  "repository": {
6
6
  "type": "git",
@@ -182,7 +182,7 @@ Automation drives the native path honestly: snapshots list every widget's declar
182
182
  | `icon` | vector icon leaf | `name` picks the icon: a bare literal is a curated built-in stroke icon (compile-checked; 49 names: search, plus, x, x-circle, check, check-circle, chevron-up/down/left/right, arrow-up/down/right, menu, panel-left, panel-right, settings, terminal, wrench, trash, edit, copy, external-link, play, pause, skip-back/forward, shuffle, repeat, music, volume, info, alert, download, save, folder, folder-open, file-text, sun, moon, eye, clock, git-pull-request, git-merge, git-branch, circle-dot, archive, refresh-cw, send); `app:<name>` reaches an icon the app registered at boot with `canvas.icons.registerAppIcons` (declare the table as `pub const app_icons` on the app root so `native check` verifies the name against the model contract), and one `{binding}` defers the choice to model data - an unknown resolved name draws the missing-icon fallback (a slashed circle) with a Debug warning naming the value, never a silent gap; tint with `foreground`, size with `width`/`height` |
183
183
  | `media-surface` | media surface leaf | composites a texture produced OUTSIDE the widget tree (video decoder, camera, an external renderer like mpv) into the layout like any widget — clipped, z-ordered, rounded. `surface="{binding}"` (required) binds the model-owned u64 surface id a Zig-tier producer targets (`runtime.acquireMediaSurfaceProducer` pushes RGBA8 frames, latest-wins, paced by the presented-frame clock; 0 = unbound, draws nothing; usable ids are nonzero values below the reserved bit 63). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content). Texture contents are presentation chrome: goldens, reference screenshots, and session replay show the deterministic id-derived placeholder, never producer frames |
184
184
  | `image` | runtime image leaf | draws a RUNTIME-REGISTERED image by its model-owned u64 ImageId — the id `Cmd.imageLoad` (TS) or `fx.loadImage`/`fx.registerImageBytes` (Zig) registered pixels under. `image="{binding}"` (required) binds a model field/fn; ids are model data, never markup literals, and 0 draws nothing (store the id only when the load reports loaded — see the Images section). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content) |
185
- | `code` | bare highlighted source/editor | `source="{binding}"` (required) provides source text and `language="tsx"` selects a literal lexer name; the component supplies no background, border, radius, shadow, or padding, so wrap it in a panel/card when chrome is wanted. It is read-only by default; `editable on-input="edit"` opts into multiline editing while retaining highlighting. It wraps by default, `line-numbers` opts into logical line numbers, and `wrap="false"` preserves lines inside one horizontal scroll region. HTML-family highlighting distinguishes HTML/XML/SVG and JSX/TSX tags, attributes, strings, comments, and embedded expressions. Zig builder: `ui.code(CodeOptions, source)` |
185
+ | `code` | bare highlighted source/editor | `source="{binding}"` (required) provides source text and `language="tsx"` selects a literal lexer name; the component supplies no background, border, radius, shadow, or padding, so wrap it in a panel/card when chrome is wanted. It is read-only by default; `editable on-input="edit"` opts into multiline editing while retaining highlighting. It wraps by default, `line-numbers` opts into logical line numbers, `added-lines="5"` / `removed-lines="2-4"` add Geist-style diff rows without changing copied source, and `wrap="false"` preserves lines inside one horizontal scroll region. HTML-family highlighting distinguishes HTML/XML/SVG and JSX/TSX tags, attributes, strings, comments, and embedded expressions. Zig builder: `ui.code(CodeOptions, source)` |
186
186
  | `markdown` | rendered markdown subtree | leaf; `source` is one `{binding}` — see "Markdown in markup" |
187
187
  | `stepper` > `step` | composite stage track | `active="{index}"` (required) derives each step's completed/active/pending state; steps are text leaves (no attributes) joined by connectors; stepper also takes `key`, `global-key`, `label` |
188
188
  | `timeline` > `timeline-item` | composite ledger list | items only inside a timeline (for/if fine); items are leaves — `title` (required), `description`, `meta`, `indicator`, `variant`, `connector="false"` on the last item, `selected`; `on-press` makes the whole item pressable with a trailing chevron |
@@ -974,6 +974,7 @@ Bare source-bound highlighted content shared with Markdown fences:
974
974
 
975
975
  ```html
976
976
  <code source="{snippet}" language="tsx" line-numbers wrap="false" width="480" label="Component source" />
977
+ <code source="{migration}" language="javascript" line-numbers added-lines="5" removed-lines="2-4" wrap="false" width="480" label="Configuration migration" />
977
978
  ```
978
979
 
979
980
  - `source` is one required `{binding}` producing `[]const u8`; the element has no children.
@@ -982,7 +983,8 @@ Bare source-bound highlighted content shared with Markdown fences:
982
983
  - Code is selectable/read-only by default. Add `editable on-input="edit"` to use the multiline editor path; the message carries `canvas.TextInputEvent`, so apply it to the same model-owned `TextBuffer` that supplies `source`. Editing retains syntax highlighting and does not add textarea chrome.
983
984
  - Wrapping is on by default. `wrap="false"` keeps logical lines intact inside one horizontal scroll region. A definite `height` makes overflow scroll vertically; with wrapping off, that constrained region scrolls on both axes.
984
985
  - `line-numbers` is off by default. Wrapped logical lines stay paired with their number. Numbered mode is limited to 128 logical lines and a reserved share of the per-view node and text-span budgets; sources that exceed any bound preserve all code and omit the gutter.
985
- - Zig builder: `ui.code(.{ .language = .html, .editable = true, .on_input = Ui.inputMsg(.edit), .line_numbers = true, .wrap = false }, model.snippet)`. Omit `editable`/`on_input` for read-only code. The public lexer helpers are under `native_sdk.canvas.code`.
986
+ - `added-lines` and `removed-lines` take one-based comma lists/inclusive ranges up to line 128 (`"2-4, 7"`) or one text binding in that form. They apply Geist's full-width green/red washes and renderer-owned `+`/`-`; the markers never enter source, selection, editing, or clipboard bytes. A line cannot be both added and removed. Read-only sources longer than 128 lines preserve all code and omit diff decoration.
987
+ - Zig builder: `ui.code(.{ .language = .html, .editable = true, .on_input = Ui.inputMsg(.edit), .line_numbers = true, .added_lines = &.{5}, .removed_lines = &.{ 2, 3, 4 }, .wrap = false }, model.snippet)`. Omit `editable`/`on_input` for read-only code. The public lexer helpers are under `native_sdk.canvas.code`.
986
988
 
987
989
  ## Markdown in markup: `<markdown>`
988
990
 
@@ -2958,7 +2958,7 @@ static NSRect NativeSdkPacketAlignRectToPixels(NSRect rect, CGFloat scale, NSUIn
2958
2958
  }
2959
2959
 
2960
2960
  /* ---------------------------------------------------------------------------
2961
- * Compact binary gpu-surface packet decoding (wire format v4).
2961
+ * Compact binary gpu-surface packet decoding (wire format v5).
2962
2962
  *
2963
2963
  * Little-endian, length-prefixed, mirror of the engine's binary packet
2964
2964
  * encoder (serialization.zig, `writeCanvasGpuPacketBinary` and the patch
@@ -2973,7 +2973,8 @@ static NSRect NativeSdkPacketAlignRectToPixels(NSRect rect, CGFloat scale, NSUIn
2973
2973
  * keyed upserts + the full draw-order vector) against the view's retained
2974
2974
  * command dictionary; v3 added the flag-gated dirty rect list after the
2975
2975
  * scissor; v4 added the per-command stroke end-cap code after
2976
- * stroke_width. The version this comment names and the encoder's spec
2976
+ * stroke_width; v5 added compact positioned glyph runs after text UTF-8.
2977
+ * The version this comment names and the encoder's spec
2977
2978
  * comment must agree with `binary_packet_version` (serialization.zig);
2978
2979
  * the `test-wire-format-version-prose` build check pins all three.
2979
2980
  */
@@ -3005,6 +3006,14 @@ static uint8_t NativeSdkBinaryReadU8(NativeSdkBinaryPacketReader *reader) {
3005
3006
  return reader->bytes[reader->offset++];
3006
3007
  }
3007
3008
 
3009
+ static uint16_t NativeSdkBinaryReadU16(NativeSdkBinaryPacketReader *reader) {
3010
+ if (!NativeSdkBinaryHasBytes(reader, 2)) return 0;
3011
+ uint16_t value = 0;
3012
+ memcpy(&value, reader->bytes + reader->offset, 2);
3013
+ reader->offset += 2;
3014
+ return CFSwapInt16LittleToHost(value);
3015
+ }
3016
+
3008
3017
  static uint32_t NativeSdkBinaryReadU32(NativeSdkBinaryPacketReader *reader) {
3009
3018
  if (!NativeSdkBinaryHasBytes(reader, 4)) return 0;
3010
3019
  uint32_t value = 0;
@@ -3209,6 +3218,45 @@ static NSDictionary *NativeSdkBinaryReadText(NativeSdkBinaryPacketReader *reader
3209
3218
  @"color" : color,
3210
3219
  @"text" : text,
3211
3220
  }];
3221
+ uint8_t hasPositionedGlyphs = NativeSdkBinaryReadU8(reader);
3222
+ if (reader->failed) return nil;
3223
+ if (hasPositionedGlyphs) {
3224
+ uint32_t glyphCount = NativeSdkBinaryReadU32(reader);
3225
+ if (reader->failed || glyphCount > 65536 || glyphCount > (reader->length - reader->offset) / 15) {
3226
+ reader->failed = YES;
3227
+ return nil;
3228
+ }
3229
+ NSMutableArray *glyphs = [NSMutableArray arrayWithCapacity:glyphCount];
3230
+ for (uint32_t index = 0; index < glyphCount; index++) {
3231
+ uint16_t glyphId = NativeSdkBinaryReadU16(reader);
3232
+ uint8_t flags = NativeSdkBinaryReadU8(reader);
3233
+ if (flags > 1) {
3234
+ reader->failed = YES;
3235
+ return nil;
3236
+ }
3237
+ uint64_t glyphFontId = (flags & 1) != 0 ? NativeSdkBinaryReadU64(reader) : fontId;
3238
+ NSNumber *x = NativeSdkBinaryReadF32Number(reader);
3239
+ NSNumber *baseline = NativeSdkBinaryReadF32Number(reader);
3240
+ NSNumber *advance = NativeSdkBinaryReadF32Number(reader);
3241
+ if (reader->failed) return nil;
3242
+ [glyphs addObject:@{ @"id" : @(glyphId), @"font" : @(glyphFontId), @"x" : x, @"baseline" : baseline, @"advance" : advance }];
3243
+ }
3244
+ uint32_t fragmentCount = NativeSdkBinaryReadU32(reader);
3245
+ if (reader->failed || fragmentCount > 64 || fragmentCount > (reader->length - reader->offset) / 12) {
3246
+ reader->failed = YES;
3247
+ return nil;
3248
+ }
3249
+ NSMutableArray *fragments = [NSMutableArray arrayWithCapacity:fragmentCount];
3250
+ for (uint32_t index = 0; index < fragmentCount; index++) {
3251
+ NSNumber *x = NativeSdkBinaryReadF32Number(reader);
3252
+ NSNumber *baseline = NativeSdkBinaryReadF32Number(reader);
3253
+ NSString *fragmentText = NativeSdkBinaryReadString(reader);
3254
+ if (reader->failed || !fragmentText) return nil;
3255
+ [fragments addObject:@{ @"x" : x, @"baseline" : baseline, @"text" : fragmentText }];
3256
+ }
3257
+ result[@"positionedGlyphs"] = glyphs;
3258
+ result[@"positionedFragments"] = fragments;
3259
+ }
3212
3260
  uint8_t hasLayout = NativeSdkBinaryReadU8(reader);
3213
3261
  if (reader->failed) return nil;
3214
3262
  if (!hasLayout) return result;
@@ -3358,7 +3406,7 @@ static NSDictionary *NativeSdkPacketDictionaryFromBinary(const uint8_t *bytes, N
3358
3406
  if (memcmp(bytes, "NSGP", 4) != 0) return nil;
3359
3407
  reader.offset = 4;
3360
3408
  uint8_t version = NativeSdkBinaryReadU8(&reader);
3361
- if (version != 4) return nil;
3409
+ if (version != 5) return nil;
3362
3410
  uint8_t loadActionCode = NativeSdkBinaryReadU8(&reader);
3363
3411
  uint8_t packetFlags = NativeSdkBinaryReadU8(&reader);
3364
3412
  (void)NativeSdkBinaryReadU8(&reader); /* reserved */
@@ -766,6 +766,10 @@ pub const ViewKind = enum {
766
766
  pub const GpuSurfaceBackend = enum {
767
767
  none,
768
768
  metal,
769
+ /// Direct2D retained rendering on Windows. The application-facing
770
+ /// backend request remains portable; frame events report the concrete
771
+ /// renderer that actually completed the present.
772
+ direct2d,
769
773
  /// CPU rasterization (reference renderer) presented through the
770
774
  /// platform's pixel blit path. Platforms without a GPU packet renderer
771
775
  /// (Linux/GTK) report this backend in their frame events; manifests