@native-sdk/cli 0.8.3 → 0.8.4

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 (89) hide show
  1. package/build/app.zig +50 -3
  2. package/build.zig +131 -360
  3. package/native-sdk.d.ts +4 -0
  4. package/package.json +9 -9
  5. package/packages/core/compile-surface/core.ts +90 -1
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/sdk/core.d.ts +65 -2
  9. package/packages/core/sdk/core.ts +189 -33
  10. package/packages/core/sdk/events.d.ts +14 -0
  11. package/packages/core/sdk/events.ts +18 -0
  12. package/packages/core/src/checker.ts +61 -1
  13. package/packages/core/src/devhost.ts +3 -3
  14. package/packages/core/src/diagnostics.ts +4 -4
  15. package/skill-data/core/SKILL.md +4 -2
  16. package/skill-data/core/references/project-anatomy.md +2 -1
  17. package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
  18. package/skill-data/native-ui/SKILL.md +8 -8
  19. package/skill-data/ts-core/SKILL.md +16 -13
  20. package/src/app_runner/ts_core_main.zig +25 -2
  21. package/src/embed/host.zig +6 -0
  22. package/src/embed/ui_host.zig +2 -0
  23. package/src/platform/linux/root.zig +1 -0
  24. package/src/platform/macos/appkit_host.h +10 -0
  25. package/src/platform/macos/appkit_host.m +515 -93
  26. package/src/platform/macos/capture_info_plist.c +25 -0
  27. package/src/platform/macos/cef_host.mm +22 -0
  28. package/src/platform/macos/root.zig +68 -0
  29. package/src/platform/null_platform.zig +58 -0
  30. package/src/platform/root.zig +7 -0
  31. package/src/platform/types.zig +100 -0
  32. package/src/platform/windows/root.zig +56 -0
  33. package/src/platform/windows/webview2_host.cpp +171 -0
  34. package/src/primitives/app_manifest/types.zig +2 -0
  35. package/src/primitives/canvas/code_tests.zig +9 -9
  36. package/src/primitives/canvas/events.zig +12 -11
  37. package/src/primitives/canvas/frame.zig +44 -9
  38. package/src/primitives/canvas/icons/mic.svg +1 -0
  39. package/src/primitives/canvas/icons.zig +2 -0
  40. package/src/primitives/canvas/root.zig +8 -0
  41. package/src/primitives/canvas/text_span_tests.zig +39 -0
  42. package/src/primitives/canvas/ui.zig +23 -4
  43. package/src/primitives/canvas/ui_markup.zig +15 -0
  44. package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
  45. package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
  46. package/src/primitives/canvas/ui_markup_tests.zig +5 -0
  47. package/src/primitives/canvas/ui_markup_view.zig +9 -0
  48. package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
  49. package/src/primitives/canvas/ui_schema.zig +19 -10
  50. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  51. package/src/primitives/canvas/ui_tests.zig +18 -4
  52. package/src/primitives/canvas/widget_invalidation.zig +9 -2
  53. package/src/primitives/canvas/widget_render.zig +296 -114
  54. package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
  55. package/src/primitives/canvas/widget_text_input.zig +10 -10
  56. package/src/primitives/canvas/widget_tree.zig +1 -1
  57. package/src/primitives/canvas/widgets.zig +29 -5
  58. package/src/root.zig +10 -0
  59. package/src/runtime/automation_widget_dispatch.zig +1 -0
  60. package/src/runtime/bridge_payload.zig +2 -0
  61. package/src/runtime/canvas_frame.zig +13 -2
  62. package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
  63. package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
  64. package/src/runtime/canvas_widget_events.zig +69 -24
  65. package/src/runtime/canvas_widget_runtime.zig +101 -6
  66. package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
  67. package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
  68. package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
  69. package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
  70. package/src/runtime/canvas_widget_state.zig +6 -1
  71. package/src/runtime/canvas_widget_text_tests.zig +112 -3
  72. package/src/runtime/effects.zig +313 -2
  73. package/src/runtime/effects_audio_capture_tests.zig +251 -0
  74. package/src/runtime/root.zig +3 -0
  75. package/src/runtime/tests.zig +1 -0
  76. package/src/runtime/ts_core_host.zig +401 -32
  77. package/src/runtime/ts_core_host_tests.zig +407 -0
  78. package/src/runtime/ts_ui_app.zig +39 -1
  79. package/src/runtime/ui_app.zig +18 -3
  80. package/src/runtime/ui_app_tests.zig +48 -0
  81. package/src/runtime/view.zig +2 -0
  82. package/src/runtime/view_widget_scroll.zig +56 -5
  83. package/src/runtime/view_widget_text.zig +24 -5
  84. package/src/runtime/view_widget_tree.zig +1 -1
  85. package/src/tooling/manifest.zig +1034 -0
  86. package/src/tooling/package.zig +837 -6
  87. package/src/tooling/raw_manifest.zig +35 -0
  88. package/src/tooling/templates.zig +55 -0
  89. package/tools/corewire/emit_facade.zig +36 -0
@@ -314,6 +314,10 @@ test "structural validation reports positions for grammar misuse" {
314
314
  var autofocus_parser = markup.Parser.init(arena_state.allocator(), autofocus_source);
315
315
  try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try autofocus_parser.parse()));
316
316
 
317
+ const submit_on_enter_source = "<column>\n <textarea submit-on-enter=\"true\" label=\"Prompt\" on-input=\"edit\" on-submit=\"send\" />\n</column>";
318
+ var submit_on_enter_parser = markup.Parser.init(arena_state.allocator(), submit_on_enter_source);
319
+ try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try submit_on_enter_parser.parse()));
320
+
317
321
  const cases = [_]struct { source: []const u8, message: []const u8 }{
318
322
  .{ .source = "<column>\n <weird />\n</column>", .message = "unknown element" },
319
323
  .{ .source = "<column bogus=\"1\" />", .message = "unknown attribute" },
@@ -362,6 +366,7 @@ test "structural validation reports positions for grammar misuse" {
362
366
  // elements can never take the keyboard.
363
367
  .{ .source = "<column>\n <row autofocus=\"true\">\n <text>x</text>\n </row>\n</column>", .message = markup.autofocus_element_message },
364
368
  .{ .source = "<column>\n <badge autofocus=\"true\">3</badge>\n</column>", .message = markup.autofocus_element_message },
369
+ .{ .source = "<column>\n <text-field submit-on-enter=\"true\" label=\"Prompt\" />\n</column>", .message = markup.submit_on_enter_element_message },
365
370
  };
366
371
  for (cases) |case| {
367
372
  var case_parser = markup.Parser.init(arena_state.allocator(), case.source);
@@ -364,6 +364,15 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
364
364
  }
365
365
  }
366
366
  }
367
+ // Only textarea has a configurable Enter-vs-newline policy.
368
+ // Mirrors validation and the compiled engine.
369
+ if (kind != .textarea) {
370
+ for (node.attrs) |attribute| {
371
+ if (std.mem.eql(u8, attribute.name, "submit-on-enter")) {
372
+ return self.failNode(node, markup.submit_on_enter_element_message);
373
+ }
374
+ }
375
+ }
367
376
  // The overflow policy's closed literal vocabulary. Mirrors
368
377
  // the validator and the compiled engine's compile error;
369
378
  // bindings resolve below like any enum option.
@@ -2025,7 +2025,7 @@ test "code markup builds the reusable component with opt-in numbers and horizont
2025
2025
  var editable_ui = CodeUi.init(arena);
2026
2026
  const editable_tree = try editable_ui.finalize(try view.build(&editable_ui, &editable_model));
2027
2027
  try testing.expectEqual(canvas.WidgetKind.textarea, editable_tree.root.kind);
2028
- try testing.expect(editable_tree.root.code_editor);
2028
+ try testing.expect(editable_tree.root.runtime_flags.code_editor);
2029
2029
  try testing.expectEqual(@as(usize, 1), editable_tree.root.spans.len);
2030
2030
  try testing.expectEqual(code_model.Language.tsx, editable_tree.root.code_language);
2031
2031
  try testing.expect(editable_tree.root.text_no_wrap);
@@ -3356,7 +3356,7 @@ pub const pane_markup_source =
3356
3356
  \\ </panel>
3357
3357
  \\ </for>
3358
3358
  \\ </tree>
3359
- \\ <column min-width="120">
3359
+ \\ <column min-width="120" max-width="720">
3360
3360
  \\ <text>Editor</text>
3361
3361
  \\ </column>
3362
3362
  \\</split>
@@ -3365,7 +3365,7 @@ pub const pane_markup_source =
3365
3365
  pub fn handPaneView(ui: *PaneUi, model: *const PaneModel) PaneUi.Node {
3366
3366
  return ui.split(.{ .value = model.sidebar_fraction, .on_resize = PaneUi.valueMsg(.sidebar_resized) }, .{
3367
3367
  ui.tree(.{ .semantics = .{ .label = "Folders" } }, ui.each(PaneModel.folders[0..], Folder.key, folderRow)),
3368
- ui.column(.{ .min_width = 120 }, .{
3368
+ ui.column(.{ .min_width = 120, .max_width = 720 }, .{
3369
3369
  ui.text(.{}, "Editor"),
3370
3370
  }),
3371
3371
  });
@@ -3427,10 +3427,11 @@ test "markup split and tree build the hand-written view with the divider synthes
3427
3427
  }).?.select_folder);
3428
3428
  try testing.expectEqual(@as(u32, 1), markup_tree.msgFor(row.id, .toggle).?.toggle_folder);
3429
3429
 
3430
- // min-width lands as a floor only (no definite max).
3430
+ // The independent responsive bounds land without becoming a
3431
+ // definite width.
3431
3432
  const editor = markup_tree.root.children[2];
3432
3433
  try testing.expectEqual(@as(f32, 120), editor.layout.min_size.width);
3433
- try testing.expectEqual(@as(f32, 0), editor.layout.max_size.width);
3434
+ try testing.expectEqual(@as(f32, 720), editor.layout.max_size.width);
3434
3435
  }
3435
3436
 
3436
3437
  test "split and tree misuse is validated with teaching messages" {
@@ -4017,7 +4018,7 @@ pub const ComposerUi = canvas.Ui(ComposerMsg);
4017
4018
  pub const composer_markup_source =
4018
4019
  \\<column gap="8">
4019
4020
  \\ <input-group label="Message composer" height="120">
4020
- \\ <textarea text="{draft}" placeholder="Type a message" on-input="edit" label="Message" />
4021
+ \\ <textarea text="{draft}" placeholder="Type a message" submit-on-enter="true" on-input="edit" label="Message" />
4021
4022
  \\ <input-group-actions>
4022
4023
  \\ <button icon="plus" variant="ghost" size="icon" on-press="attach" label="Attach"></button>
4023
4024
  \\ <spacer grow="1" />
@@ -4035,6 +4036,7 @@ pub fn handComposerView(ui: *ComposerUi, model: *const ComposerModel) ComposerUi
4035
4036
  const entry = ui.el(.textarea, .{
4036
4037
  .text = model.draft(),
4037
4038
  .placeholder = "Type a message",
4039
+ .submit_on_enter = true,
4038
4040
  .on_input = ComposerUi.inputMsg(.edit),
4039
4041
  .semantics = .{ .label = "Message" },
4040
4042
  }, .{});
@@ -4089,6 +4091,7 @@ test "the input-group element builds the hand-written Ui.inputGroup tree" {
4089
4091
  try testing.expectEqual(canvas.WidgetKind.textarea, entry.kind);
4090
4092
  try testing.expectEqualStrings("hello", entry.text);
4091
4093
  try testing.expectEqualStrings("Type a message", entry.placeholder);
4094
+ try testing.expect(entry.submit_on_enter);
4092
4095
  try testing.expectEqual(@as(f32, 1), entry.layout.grow);
4093
4096
  try testing.expectEqual(@as(u8, 0), entry.style.background.?.a);
4094
4097
  try testing.expectEqual(@as(u8, 0), entry.style.border.?.a);
@@ -579,6 +579,14 @@ pub const attrs = [_]AttrInfo{
579
579
  // Markdown's caller-owned source -> registered ImageId mapping. The
580
580
  // markdown rule hook scopes and type-checks the iterable binding.
581
581
  .{ .code = 96, .name = "images", .class = .binding_only, .group = .composite },
582
+ // Textarea Enter policy (textarea only): false preserves the
583
+ // multiline default (Enter inserts, primary+Enter submits); true is
584
+ // the chat-composer convention (Enter submits, Shift+Enter inserts).
585
+ .{ .code = 97, .name = "submit-on-enter", .class = .flag, .group = .option, .field = "submit_on_enter" },
586
+ // Responsive width ceiling: unlike definite `width`, this leaves the
587
+ // minimum unconstrained so a capped element still shrinks with a
588
+ // narrow parent.
589
+ .{ .code = 98, .name = "max-width", .class = .number, .group = .option, .field = "max_width" },
582
590
  };
583
591
 
584
592
  // ----------------------------------------------------------------- events
@@ -657,16 +665,17 @@ pub const control_size_value_names = [_][]const u8{ "default", "sm", "lg", "icon
657
665
  pub const text_size_value_names = [_][]const u8{ "heading", "display" };
658
666
 
659
667
  pub const icon_names = [_][]const u8{
660
- "alert", "archive", "arrow-down", "arrow-right", "arrow-up",
661
- "check", "check-circle", "chevron-down", "chevron-left", "chevron-right",
662
- "chevron-up", "circle-dot", "clock", "copy", "download",
663
- "edit", "ellipsis", "external-link", "eye", "file-text",
664
- "folder", "folder-open", "git-branch", "git-merge", "git-pull-request",
665
- "info", "menu", "moon", "music", "panel-left",
666
- "panel-right", "pause", "play", "plus", "refresh-cw",
667
- "repeat", "save", "search", "send", "settings",
668
- "shuffle", "skip-back", "skip-forward", "sun", "terminal",
669
- "trash", "volume", "wrench", "x", "x-circle",
668
+ "alert", "archive", "arrow-down", "arrow-right", "arrow-up",
669
+ "check", "check-circle", "chevron-down", "chevron-left", "chevron-right",
670
+ "chevron-up", "circle-dot", "clock", "copy", "download",
671
+ "edit", "ellipsis", "external-link", "eye", "file-text",
672
+ "folder", "folder-open", "git-branch", "git-merge", "git-pull-request",
673
+ "info", "menu", "mic", "moon", "music",
674
+ "panel-left", "panel-right", "pause", "play", "plus",
675
+ "refresh-cw", "repeat", "save", "search", "send",
676
+ "settings", "shuffle", "skip-back", "skip-forward", "sun",
677
+ "terminal", "trash", "volume", "wrench", "x",
678
+ "x-circle",
670
679
  };
671
680
 
672
681
  /// The semantic role vocabulary the `role` attribute accepts: the field
@@ -22,7 +22,7 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
22
22
  // the new fingerprint ONLY for additions; renames/renumbers are
23
23
  // schema-version-bump events, not silent edits.
24
24
  try testing.expectEqual(@as(usize, 70), schema.elements.len);
25
- try testing.expectEqual(@as(usize, 96), schema.attrs.len);
25
+ try testing.expectEqual(@as(usize, 98), schema.attrs.len);
26
26
  try testing.expectEqual(@as(usize, 15), schema.events.len);
27
27
  // The element table runs through the span composite (64), the
28
28
  // bubble-reactions composite (65), the media surface (66), the
@@ -46,9 +46,11 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
46
46
  // (90), line-numbers (91), and editable-code (92) declarations,
47
47
  // the flat disclosure-tree hierarchy level tree-level (93), and the
48
48
  // code-diff line sets added-lines (94) and removed-lines (95), and
49
- // Markdown's registered-image iterable binding images (96).
49
+ // Markdown's registered-image iterable binding images (96), and the
50
+ // textarea Enter policy submit-on-enter (97), and the responsive
51
+ // layout ceiling max-width (98).
50
52
  try testing.expectEqual(
51
- @as(u64, 0xc0ab8db72d6e2110),
53
+ @as(u64, 0xb8991dcb86471877),
52
54
  tableFingerprint(schema.AttrInfo, &schema.attrs),
53
55
  );
54
56
  // The event table runs through the pointer-hover containment pair
@@ -375,15 +375,17 @@ test "tree keyboard navigation can select without dispatching pointer activation
375
375
  }).?);
376
376
  }
377
377
 
378
- test "textarea keyboard: enter edits a newline, submit rides the primary chord" {
378
+ test "textarea keyboard: the default and chat-composer Enter policies stay distinct" {
379
379
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
380
380
  defer arena_state.deinit();
381
381
 
382
382
  var ui = InboxUi.init(arena_state.allocator());
383
383
  const tree = try ui.finalize(ui.column(.{ .gap = 8 }, .{
384
384
  ui.el(.textarea, .{ .on_input = InboxUi.inputMsg(.draft), .on_submit = .add }, .{}),
385
+ ui.el(.textarea, .{ .submit_on_enter = true, .on_input = InboxUi.inputMsg(.draft), .on_submit = .add }, .{}),
385
386
  }));
386
- const textarea = findByKind(tree.root, .textarea).?;
387
+ const textarea = tree.root.children[0];
388
+ const prompt = tree.root.children[1];
387
389
 
388
390
  // Plain Enter is an EDIT: the model's on_input hears the newline the
389
391
  // runtime applied to the retained text — never a submit.
@@ -406,6 +408,13 @@ test "textarea keyboard: enter edits a newline, submit rides the primary chord"
406
408
  try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(textarea.id, cmd_shift_enter));
407
409
  const alt_enter = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "enter", .modifiers = .{ .alt = true } };
408
410
  try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(textarea.id, alt_enter));
411
+
412
+ // A chat composer opts into plain Enter submission, but Shift+Enter
413
+ // remains the explicit multiline gesture. The primary chord remains
414
+ // accepted too, preserving the standard textarea shortcut.
415
+ try testing.expectEqual(Msg.add, tree.msgForKeyboard(prompt.id, enter).?);
416
+ try testing.expectEqualStrings("\n", tree.msgForKeyboard(prompt.id, shift_enter).?.draft.insert_text);
417
+ try testing.expectEqual(Msg.add, tree.msgForKeyboard(prompt.id, cmd_enter).?);
409
418
  }
410
419
 
411
420
  test "single-line keyboard fallback derivation sanitizes line breaks like the runtime seam" {
@@ -758,13 +767,14 @@ test "wrapped text reserves its wrapped height in a definite-width pane" {
758
767
  try testing.expect(below_frame.?.y >= wrapped_frame.?.y + wrapped_frame.?.height);
759
768
  }
760
769
 
761
- test "explicit sizes are definite except on resizable" {
770
+ test "explicit sizes are definite, max width is a ceiling, and resizable keeps its exception" {
762
771
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
763
772
  defer arena_state.deinit();
764
773
 
765
774
  var ui = InboxUi.init(arena_state.allocator());
766
775
  const tree = try ui.finalize(ui.column(.{}, .{
767
776
  ui.el(.panel, .{ .width = 240, .height = 40 }, .{}),
777
+ ui.el(.panel, .{ .max_width = 720 }, .{}),
768
778
  // Resizable keeps width as the initial/min width only: the engine's
769
779
  // drag handle writes larger frames past it.
770
780
  ui.el(.resizable, .{ .width = 240 }, .{}),
@@ -776,7 +786,11 @@ test "explicit sizes are definite except on resizable" {
776
786
  try testing.expectEqual(@as(f32, 40), panel.layout.min_size.height);
777
787
  try testing.expectEqual(@as(f32, 40), panel.layout.max_size.height);
778
788
 
779
- const resizable = tree.root.children[1];
789
+ const capped = tree.root.children[1];
790
+ try testing.expectEqual(@as(f32, 0), capped.layout.min_size.width);
791
+ try testing.expectEqual(@as(f32, 720), capped.layout.max_size.width);
792
+
793
+ const resizable = tree.root.children[2];
780
794
  try testing.expectEqual(@as(f32, 240), resizable.layout.min_size.width);
781
795
  try testing.expectEqual(@as(f32, 0), resizable.layout.max_size.width);
782
796
  }
@@ -71,8 +71,15 @@ fn widgetWithFrame(widget: Widget, frame: geometry.RectF) Widget {
71
71
  fn widgetWithRenderState(widget: Widget, state: WidgetRenderState) Widget {
72
72
  var copy = widget;
73
73
  if (state.focused_id != null or state.focus_visible_id != null) {
74
- copy.state.focused = if (state.focus_visible_id) |focus_visible_id|
75
- copy.id != 0 and copy.id == focus_visible_id
74
+ // Keep dirty-bounds projection identical to display emission:
75
+ // menu rows paint logical focus as their active-row wash, while
76
+ // all focus-ring controls continue to follow focus-visible.
77
+ const painted_focus_id = if (copy.kind == .menu_item)
78
+ state.focused_id
79
+ else
80
+ state.focus_visible_id;
81
+ copy.state.focused = if (painted_focus_id) |focused_id|
82
+ copy.id != 0 and copy.id == focused_id
76
83
  else
77
84
  false;
78
85
  }