@native-sdk/cli 0.8.0 → 0.8.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 (75) hide show
  1. package/README.md +4 -4
  2. package/build.zig +49 -23
  3. package/package.json +10 -10
  4. package/packages/core/compile-surface/core.ts +16 -0
  5. package/packages/core/package-lock.json +2 -2
  6. package/packages/core/package.json +1 -1
  7. package/packages/core/sdk/core.d.ts +11 -0
  8. package/packages/core/sdk/core.ts +29 -2
  9. package/packages/core/sdk/events.d.ts +10 -0
  10. package/packages/core/sdk/events.ts +24 -4
  11. package/packages/core/src/checker.ts +1 -1
  12. package/packages/core/src/contract.ts +4 -1
  13. package/packages/core/src/devhost.ts +10 -1
  14. package/packages/core/src/diagnostics.ts +1 -1
  15. package/skill-data/core/SKILL.md +48 -20
  16. package/skill-data/core/references/app-model-runtime.md +2 -2
  17. package/skill-data/core/references/project-anatomy.md +22 -6
  18. package/skill-data/native-ui/SKILL.md +71 -29
  19. package/skill-data/ts-core/SKILL.md +13 -8
  20. package/skill-data/zig/SKILL.md +1 -1
  21. package/skills/native-sdk/SKILL.md +6 -5
  22. package/src/app_runner/ts_core_main.zig +2 -1
  23. package/src/embed/tests.zig +3 -1
  24. package/src/platform/macos/appkit_host.h +4 -4
  25. package/src/platform/macos/appkit_host.m +24 -4
  26. package/src/platform/macos/cef_host.mm +22 -6
  27. package/src/platform/macos/root.zig +2 -2
  28. package/src/primitives/canvas/events.zig +8 -0
  29. package/src/primitives/canvas/markdown.zig +2010 -57
  30. package/src/primitives/canvas/markdown_hostile_tests.zig +40 -0
  31. package/src/primitives/canvas/markdown_tests.zig +778 -3
  32. package/src/primitives/canvas/root.zig +2 -0
  33. package/src/primitives/canvas/test_support.zig +1 -0
  34. package/src/primitives/canvas/ui.zig +53 -8
  35. package/src/primitives/canvas/ui_markup.zig +10 -1
  36. package/src/primitives/canvas/ui_markup_compiled.zig +61 -3
  37. package/src/primitives/canvas/ui_markup_compiled_tests.zig +27 -0
  38. package/src/primitives/canvas/ui_markup_contract.zig +31 -3
  39. package/src/primitives/canvas/ui_markup_reflect.zig +41 -0
  40. package/src/primitives/canvas/ui_markup_view.zig +49 -3
  41. package/src/primitives/canvas/ui_markup_view_tests.zig +61 -2
  42. package/src/primitives/canvas/ui_schema.zig +8 -1
  43. package/src/primitives/canvas/ui_schema_tests.zig +7 -6
  44. package/src/primitives/canvas/ui_tests.zig +14 -0
  45. package/src/primitives/canvas/widget_access.zig +4 -3
  46. package/src/primitives/canvas/widget_invalidation.zig +11 -0
  47. package/src/primitives/canvas/widget_layout.zig +26 -3
  48. package/src/primitives/canvas/widget_metrics.zig +21 -3
  49. package/src/primitives/canvas/widget_render.zig +87 -1
  50. package/src/primitives/canvas/widget_routing.zig +12 -7
  51. package/src/primitives/canvas/widget_runtime_tests.zig +132 -0
  52. package/src/primitives/canvas/widgets.zig +40 -0
  53. package/src/root.zig +1 -0
  54. package/src/runtime/automation_widget_dispatch.zig +19 -0
  55. package/src/runtime/canvas_limits.zig +5 -0
  56. package/src/runtime/canvas_widget_event_tests.zig +424 -8
  57. package/src/runtime/canvas_widget_events.zig +254 -7
  58. package/src/runtime/canvas_widget_state.zig +123 -1
  59. package/src/runtime/core.zig +6 -0
  60. package/src/runtime/effects.zig +36 -1
  61. package/src/runtime/effects_fetch_tests.zig +21 -0
  62. package/src/runtime/effects_notification_tests.zig +65 -0
  63. package/src/runtime/gpu_surface_events.zig +60 -14
  64. package/src/runtime/tests.zig +1 -0
  65. package/src/runtime/ts_core_host.zig +16 -0
  66. package/src/runtime/ts_ui_app.zig +55 -2
  67. package/src/runtime/ui_app.zig +112 -0
  68. package/src/runtime/ui_app_tests.zig +356 -0
  69. package/src/runtime/view.zig +35 -0
  70. package/src/runtime/view_widget_tree.zig +12 -0
  71. package/tools/corewire/core_abi.zig +1 -0
  72. package/tools/corewire/emit.zig +55 -8
  73. package/tools/corewire/emit_facade.zig +63 -2
  74. package/tools/corewire/emit_profile.zig +4 -1
  75. package/tools/corewire/sidecar.zig +36 -6
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The command line for [Native SDK](https://native-sdk.dev): the complete toolkit for building native desktop applications.
4
4
 
5
- Views are declarative markup in `.native` files, logic is plain Zig, and Native SDK's own engine draws every pixel into real OS windows — no browser, no WebView, no interpreter in the binary.
5
+ Apps are authored in TypeScript + declarative Native markup by default. The TypeScript core compiles ahead of time to native code, and Native SDK's own engine draws every pixel into real OS windows — no browser, WebView, JS runtime, or interpreter in the binary. Zig is a first-class app-core alternative by explicit choice and the language the toolkit itself is built in.
6
6
 
7
7
  ## Install
8
8
 
@@ -20,7 +20,7 @@ cd my_app
20
20
  native dev
21
21
  ```
22
22
 
23
- A native window opens with a working counter. The scaffold is a native-rendered markup app with no build files — `native dev|build|test` own the build — and `src/app.native` hot-reloads while the app runs, keeping your state. `native check` validates every view in milliseconds without building.
23
+ A native window opens with a working counter. The primary scaffold is three files of truth and no build config: `src/core.ts` (`Model`, `Msg`, `update`), `src/app.native` (the UI), and `app.zon` (the manifest). `native dev|build|test` own the generated build; `src/app.native` hot-reloads while the app runs, keeping your state; `native dev --core` runs the TypeScript logic loop under node; and `native check` validates the core and every view in milliseconds without building. Prefer a Zig core? Use `native init my_app --template zig-core`.
24
24
 
25
25
  When part of your product is the web, WebView surfaces coexist with the native canvas; web-frontend scaffolds (`--frontend next`, `--frontend vite`, and more) install their generated frontend dependencies automatically on first run.
26
26
 
@@ -30,7 +30,7 @@ Read the full guide at [native-sdk.dev/quick-start](https://native-sdk.dev/quick
30
30
 
31
31
  | Command | Description |
32
32
  |---------|-------------|
33
- | `native init [path] [--frontend <native\|next\|vite\|react\|svelte\|vue>] [--full]` | Scaffold a new Native SDK app |
33
+ | `native init [path] [--template <ts-core\|zig-core>] [--frontend <native\|next\|vite\|react\|svelte\|vue>] [--full]` | Scaffold a new Native SDK app (TypeScript core + Native markup by default) |
34
34
  | `native dev [dir]` | Build and run the app (markup hot reload; managed frontend dev server when configured) |
35
35
  | `native build [dir]` | Build a ReleaseFast binary into `zig-out/bin/` |
36
36
  | `native test [dir]` | Run the app's test suite |
@@ -47,6 +47,6 @@ Read the full guide at [native-sdk.dev/quick-start](https://native-sdk.dev/quick
47
47
 
48
48
  ## More
49
49
 
50
- The full documentation is at [native-sdk.dev](https://native-sdk.dev) — the [app model](https://native-sdk.dev/app-model), [native UI authoring](https://native-sdk.dev/native-ui), [components](https://native-sdk.dev/components), [testing](https://native-sdk.dev/testing), [automation](https://native-sdk.dev/automation), [capabilities](https://native-sdk.dev/capabilities), [packaging](https://native-sdk.dev/packaging), and [platform support](https://native-sdk.dev/platform-support).
50
+ The full documentation is at [native-sdk.dev](https://native-sdk.dev) — the [quick start](https://native-sdk.dev/quick-start), [TypeScript cores](https://native-sdk.dev/typescript), [native UI authoring](https://native-sdk.dev/native-ui), [app model](https://native-sdk.dev/app-model), [components](https://native-sdk.dev/components), [testing](https://native-sdk.dev/testing), [automation](https://native-sdk.dev/automation), [capabilities](https://native-sdk.dev/capabilities), [packaging](https://native-sdk.dev/packaging), and [platform support](https://native-sdk.dev/platform-support).
51
51
 
52
52
  Native SDK is pre-1.0 and Apache-2.0 licensed; the source lives at [github.com/vercel-labs/native](https://github.com/vercel-labs/native).
package/build.zig CHANGED
@@ -484,6 +484,7 @@ pub fn build(b: *std.Build) void {
484
484
  const ts_core_e2e_step = b.step("test-ts-core-e2e", "Run the TypeScript-core end-to-end suites over externally compiled fixture cores (requires node and `npm ci` in packages/core)");
485
485
  const host_e2e_run = b.addRunArtifact(ts_core_artifacts.host);
486
486
  const markup_e2e_run = b.addRunArtifact(ts_core_artifacts.markup);
487
+ const kanban_e2e_run = b.addRunArtifact(ts_core_artifacts.kanban);
487
488
  const soundboard_e2e_run = b.addRunArtifact(ts_core_artifacts.soundboard);
488
489
  const monitor_e2e_run = b.addRunArtifact(ts_core_artifacts.system_monitor);
489
490
  const scaffold_ide_e2e_run = b.addRunArtifact(ts_core_artifacts.scaffold_ide);
@@ -514,12 +515,14 @@ pub fn build(b: *std.Build) void {
514
515
  }
515
516
  ts_core_e2e_step.dependOn(&host_e2e_run.step);
516
517
  ts_core_e2e_step.dependOn(&markup_e2e_run.step);
518
+ ts_core_e2e_step.dependOn(&kanban_e2e_run.step);
517
519
  ts_core_e2e_step.dependOn(&soundboard_e2e_run.step);
518
520
  ts_core_e2e_step.dependOn(&monitor_e2e_run.step);
519
521
  ts_core_e2e_step.dependOn(&scaffold_ide_e2e_run.step);
520
522
  ts_core_e2e_step.dependOn(&ai_chat_e2e_run.step);
521
523
  test_step.dependOn(&host_e2e_run.step);
522
524
  test_step.dependOn(&markup_e2e_run.step);
525
+ test_step.dependOn(&kanban_e2e_run.step);
523
526
  test_step.dependOn(&soundboard_e2e_run.step);
524
527
  test_step.dependOn(&monitor_e2e_run.step);
525
528
  test_step.dependOn(&scaffold_ide_e2e_run.step);
@@ -1918,8 +1921,8 @@ pub fn build(b: *std.Build) void {
1918
1921
  const writeback_smoke_step = b.step("test-writeback-smoke", "Run macOS provenance + write-back automation smoke test");
1919
1922
  // Debug on purpose: the write-back loop lives on the markup
1920
1923
  // interpreter + hot-reload watch, which apps enable in Debug
1921
- // (kanban's dev_markup_reload) - the release engine is compiled and
1922
- // watchless by design.
1924
+ // (including the generated TS-core wiring) - the release engine is
1925
+ // compiled and watchless by design.
1923
1926
  const writeback_smoke_build = managedExampleRun(b, cli_exe, &.{ "build", "-Dplatform=macos", "-Dweb-engine=system", "-Dautomation=true", "-Doptimize=Debug" });
1924
1927
  writeback_smoke_build.setCwd(b.path("examples/kanban"));
1925
1928
  const writeback_smoke_run = b.addSystemCommand(&.{
@@ -1932,45 +1935,45 @@ pub fn build(b: *std.Build) void {
1932
1935
  \\automation_dir=".zig-cache/native-sdk-automation"
1933
1936
  \\mkdir -p "$automation_dir"
1934
1937
  \\rm -f "$automation_dir/snapshot.txt" "$automation_dir"/command*.txt "$automation_dir/provenance.txt"
1935
- \\# The smoke edits src/board.native through the write-back verb and restores
1938
+ \\# The smoke edits src/app.native through the write-back verb and restores
1936
1939
  \\# it through the same verb; the trap restores from the backup on ANY
1937
1940
  \\# failure so an aborted run never leaves the example dirty.
1938
- \\cp src/board.native .zig-cache/board.native.smoke-backup
1941
+ \\cp src/app.native .zig-cache/app.native.smoke-backup
1939
1942
  \\"$app" > .zig-cache/native-sdk-writeback-smoke.log 2>&1 &
1940
1943
  \\pid=$!
1941
- \\trap 'status=$?; kill "$pid" >/dev/null 2>&1 || true; wait "$pid" >/dev/null 2>&1 || true; cp .zig-cache/board.native.smoke-backup src/board.native; if [ "$status" -ne 0 ]; then echo "---- app log (.zig-cache/native-sdk-writeback-smoke.log) ----" >&2; cat .zig-cache/native-sdk-writeback-smoke.log >&2 2>/dev/null || true; fi' EXIT
1944
+ \\trap 'status=$?; kill "$pid" >/dev/null 2>&1 || true; wait "$pid" >/dev/null 2>&1 || true; cp .zig-cache/app.native.smoke-backup src/app.native; if [ "$status" -ne 0 ]; then echo "---- app log (.zig-cache/native-sdk-writeback-smoke.log) ----" >&2; cat .zig-cache/native-sdk-writeback-smoke.log >&2 2>/dev/null || true; fi' EXIT
1942
1945
  \\"$cli" automate assert --timeout-ms 30000 'ready=true' >/dev/null
1943
1946
  \\snapshot="$(cat "$automation_dir/snapshot.txt")"
1944
1947
  \\button_id="$(printf '%s\n' "$snapshot" | sed -n 's/.*widget @w1\/kanban-canvas#\([0-9][0-9]*\) role=button name="Add card".*/\1/p' | head -n 1)"
1945
1948
  \\case "$button_id" in ''|*[!0-9]*) echo "writeback smoke: Add card button id was missing from the snapshot" >&2; exit 1 ;; esac
1949
+ \\heading_id="$(printf '%s\n' "$snapshot" | sed -n 's/.*widget @w1\/kanban-canvas#\([0-9][0-9]*\) role=text name="Todo".*/\1/p' | head -n 1)"
1950
+ \\case "$heading_id" in ''|*[!0-9]*) echo "writeback smoke: Todo heading id was missing from the snapshot" >&2; exit 1 ;; esac
1946
1951
  \\# 1. Provenance: the button reports its authored span in the root file.
1947
1952
  \\provenance="$("$cli" automate provenance kanban-canvas "$button_id" 2>/dev/null)"
1948
- \\case "$provenance" in *"authored=markup"*"root=src/board.native"*) ;; *) echo "writeback smoke: button provenance was not markup-authored: $provenance" >&2; exit 1 ;; esac
1949
- \\case "$provenance" in *"node file=src/board.native"*) ;; *) echo "writeback smoke: button provenance named the wrong file: $provenance" >&2; exit 1 ;; esac
1950
- \\# 2. Template + import chain: a card title reports its definition site in
1951
- \\# the component file plus the <use> site in the root file, with the
1952
- \\# for-loop iteration key.
1953
- \\card_id="$(printf '%s\n' "$snapshot" | sed -n 's/.*widget @w1\/kanban-canvas#\([0-9][0-9]*\) role=text name="Sketch the board layout".*/\1/p' | head -n 1)"
1953
+ \\case "$provenance" in *"authored=markup"*"root=src/app.native"*) ;; *) echo "writeback smoke: button provenance was not markup-authored: $provenance" >&2; exit 1 ;; esac
1954
+ \\case "$provenance" in *"node file=src/app.native"*) ;; *) echo "writeback smoke: button provenance named the wrong file: $provenance" >&2; exit 1 ;; esac
1955
+ \\# 2. Loop provenance: the boot view is deliberately self-contained,
1956
+ \\# so a card title reports its node in app.native plus its iteration key.
1957
+ \\card_id="$(printf '%s\n' "$snapshot" | sed -n 's/.*widget @w1\/kanban-canvas#\([0-9][0-9]*\) role=text name="Retry failed agent runs".*/\1/p' | head -n 1)"
1954
1958
  \\case "$card_id" in ''|*[!0-9]*) echo "writeback smoke: card text id was missing from the snapshot" >&2; exit 1 ;; esac
1955
1959
  \\card_provenance="$("$cli" automate provenance kanban-canvas "$card_id" 2>/dev/null)"
1956
- \\case "$card_provenance" in *"node file=src/components/board-column.native"*) ;; *) echo "writeback smoke: card provenance missed the component file: $card_provenance" >&2; exit 1 ;; esac
1957
- \\case "$card_provenance" in *"use file=src/board.native"*) ;; *) echo "writeback smoke: card provenance missed the use-site chain: $card_provenance" >&2; exit 1 ;; esac
1960
+ \\case "$card_provenance" in *"node file=src/app.native"*) ;; *) echo "writeback smoke: card provenance named the wrong file: $card_provenance" >&2; exit 1 ;; esac
1958
1961
  \\case "$card_provenance" in *"keys="*) ;; *) echo "writeback smoke: card provenance missed the iteration key: $card_provenance" >&2; exit 1 ;; esac
1959
- \\# 3. Write-back: flip the button label through the verb; the app's own
1962
+ \\# 3. Write-back: flip the Todo heading through the verb; the app's own
1960
1963
  \\# hot-reload watch picks the file change up and repaints.
1961
- \\"$cli" automate edit kanban-canvas "$button_id" set-text "Add task" >/dev/null 2>&1
1962
- \\"$cli" automate assert --timeout-ms 15000 'role=button name="Add task"' >/dev/null
1963
- \\# The file diff is byte-exact: exactly the label bytes changed.
1964
- \\sed 's/>Add card</>Add task</' .zig-cache/board.native.smoke-backup > .zig-cache/board.native.smoke-expected
1965
- \\cmp -s .zig-cache/board.native.smoke-expected src/board.native || { echo "writeback smoke: the edit was not minimal-diff" >&2; exit 1; }
1964
+ \\"$cli" automate edit kanban-canvas "$heading_id" set-text "Backlog" >/dev/null 2>&1
1965
+ \\"$cli" automate assert --timeout-ms 15000 'role=text name="Backlog"' >/dev/null
1966
+ \\# The file diff is byte-exact: exactly the heading bytes changed.
1967
+ \\sed 's/>Todo</>Backlog</' .zig-cache/app.native.smoke-backup > .zig-cache/app.native.smoke-expected
1968
+ \\cmp -s .zig-cache/app.native.smoke-expected src/app.native || { echo "writeback smoke: the edit was not minimal-diff" >&2; exit 1; }
1966
1969
  \\# 4. Flip it back through the same verb: the structural id survived the
1967
1970
  \\# reload (text is not identity), and the file restores byte-identical.
1968
- \\"$cli" automate edit kanban-canvas "$button_id" set-text "Add card" >/dev/null 2>&1
1969
- \\"$cli" automate assert --timeout-ms 15000 'role=button name="Add card"' >/dev/null
1970
- \\cmp -s .zig-cache/board.native.smoke-backup src/board.native || { echo "writeback smoke: the flip-back did not restore the file byte-identically" >&2; exit 1; }
1971
+ \\"$cli" automate edit kanban-canvas "$heading_id" set-text "Todo" >/dev/null 2>&1
1972
+ \\"$cli" automate assert --timeout-ms 15000 'role=text name="Todo"' >/dev/null
1973
+ \\cmp -s .zig-cache/app.native.smoke-backup src/app.native || { echo "writeback smoke: the flip-back did not restore the file byte-identically" >&2; exit 1; }
1971
1974
  \\# 5. Refusal: an edit that fails validation leaves the file untouched.
1972
1975
  \\if "$cli" automate edit kanban-canvas "$button_id" set-attr bogus 1 >/dev/null 2>&1; then echo "writeback smoke: an invalid edit was not refused" >&2; exit 1; fi
1973
- \\cmp -s .zig-cache/board.native.smoke-backup src/board.native || { echo "writeback smoke: a refused edit touched the file" >&2; exit 1; }
1976
+ \\cmp -s .zig-cache/app.native.smoke-backup src/app.native || { echo "writeback smoke: a refused edit touched the file" >&2; exit 1; }
1974
1977
  \\echo "writeback smoke ok"
1975
1978
  ,
1976
1979
  "sh",
@@ -2979,6 +2982,7 @@ const TsCoreE2eArtifacts = struct {
2979
2982
  /// set is a fixed-prefix C ABI, so one process carries ONE archive
2980
2983
  /// — every fixture battery links exactly its own core.
2981
2984
  markup: *std.Build.Step.Compile,
2985
+ kanban: *std.Build.Step.Compile,
2982
2986
  soundboard: *std.Build.Step.Compile,
2983
2987
  system_monitor: *std.Build.Step.Compile,
2984
2988
  /// The stock-IDE contract: a fresh scaffold (and the committed TS
@@ -3086,6 +3090,26 @@ fn tsCoreE2eArtifact(
3086
3090
  markup_e2e_mod.addImport("native_sdk", desktop_mod);
3087
3091
  markup_e2e_mod.addImport("ts_markup_fixture", markup_fixture_mod);
3088
3092
 
3093
+ // The rewritten Kanban example's real TypeScript core and self-contained
3094
+ // shipping markup. Its battery drives native multi-file drops through
3095
+ // the generated dropMsg adapter and then moves the created cards.
3096
+ const kanban_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3097
+ .entry = "examples/kanban/src/core.ts",
3098
+ .src_dir = b.path("examples/kanban/src"),
3099
+ .name = "kanban_core",
3100
+ });
3101
+ const kanban_core_mod = kanban_fixture.module;
3102
+ const kanban_stage = b.addWriteFiles();
3103
+ const kanban_root = kanban_stage.addCopyFile(b.path("tests/ts-core/kanban_e2e_tests.zig"), "kanban_e2e_tests.zig");
3104
+ _ = kanban_stage.addCopyFile(b.path("examples/kanban/src/app.native"), "app.native");
3105
+ const kanban_mod = b.createModule(.{
3106
+ .root_source_file = kanban_root,
3107
+ .target = target,
3108
+ .optimize = optimize,
3109
+ });
3110
+ kanban_mod.addImport("native_sdk", desktop_mod);
3111
+ kanban_mod.addImport("ts_kanban_core", kanban_core_mod);
3112
+
3089
3113
  // The soundboard-ts example's core and markup, tested as one app:
3090
3114
  // the test root stages beside a copy of the example's app.native so
3091
3115
  // the compiled markup engine builds the SHIPPING view over the
@@ -3181,6 +3205,7 @@ fn tsCoreE2eArtifact(
3181
3205
  f64_slots: []const []const u8 = &.{},
3182
3206
  }{
3183
3207
  .{ .shim_import = "shim_host_core", .contract_name = "host-fixture", .core = host_fixture, .f64_slots = &.{"Model.pastBytes"} },
3208
+ .{ .shim_import = "shim_kanban_core", .contract_name = "kanban", .core = kanban_fixture },
3184
3209
  .{ .shim_import = "shim_soundboard_core", .contract_name = "soundboard", .core = soundboard_fixture },
3185
3210
  .{ .shim_import = "shim_monitor_core", .contract_name = "system-monitor", .core = monitor_fixture },
3186
3211
  .{ .shim_import = "shim_ai_chat_core", .contract_name = "ai-chat", .core = ai_chat_fixture },
@@ -3228,6 +3253,7 @@ fn tsCoreE2eArtifact(
3228
3253
  return .{
3229
3254
  .host = filteredTestArtifact(b, e2e_mod, "ts-core-e2e-tests", &.{}),
3230
3255
  .markup = filteredTestArtifact(b, markup_e2e_mod, "ts-markup-e2e-tests", &.{}),
3256
+ .kanban = filteredTestArtifact(b, kanban_mod, "ts-kanban-e2e-tests", &.{}),
3231
3257
  .soundboard = filteredTestArtifact(b, soundboard_mod, "ts-soundboard-e2e-tests", &.{}),
3232
3258
  .system_monitor = filteredTestArtifact(b, monitor_mod, "ts-system-monitor-e2e-tests", &.{}),
3233
3259
  .scaffold_ide = filteredTestArtifact(b, scaffold_ide_mod, "ts-scaffold-ide-e2e-tests", &.{}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.8.0",
3
+ "version": "0.8.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": {
@@ -34,14 +34,14 @@
34
34
  "scriptc": "0.0.22"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@native-sdk/cli-darwin-arm64": "0.8.0",
38
- "@native-sdk/cli-darwin-x64": "0.8.0",
39
- "@native-sdk/cli-linux-arm64-gnu": "0.8.0",
40
- "@native-sdk/cli-linux-arm64-musl": "0.8.0",
41
- "@native-sdk/cli-linux-x64-gnu": "0.8.0",
42
- "@native-sdk/cli-linux-x64-musl": "0.8.0",
43
- "@native-sdk/cli-win32-arm64": "0.8.0",
44
- "@native-sdk/cli-win32-x64": "0.8.0"
37
+ "@native-sdk/cli-darwin-arm64": "0.8.2",
38
+ "@native-sdk/cli-darwin-x64": "0.8.2",
39
+ "@native-sdk/cli-linux-arm64-gnu": "0.8.2",
40
+ "@native-sdk/cli-linux-arm64-musl": "0.8.2",
41
+ "@native-sdk/cli-linux-x64-gnu": "0.8.2",
42
+ "@native-sdk/cli-linux-x64-musl": "0.8.2",
43
+ "@native-sdk/cli-win32-arm64": "0.8.2",
44
+ "@native-sdk/cli-win32-x64": "0.8.2"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "homepage": "https://native-sdk.dev",
51
51
  "scripts": {
52
- "version": "npm run version:sync && git add ../../tools/native-sdk/main.zig ../../packages/core/package.json ../../packages/core/package-lock.json ../../examples/soundboard-ts/package.json ../../examples/system-monitor-ts/package.json npm/*/package.json package.json",
52
+ "version": "npm run version:sync && git add ../../tools/native-sdk/main.zig ../../packages/core/package.json ../../packages/core/package-lock.json ../../examples/kanban/package.json ../../examples/soundboard-ts/package.json ../../examples/system-monitor-ts/package.json npm/*/package.json package.json",
53
53
  "version:sync": "node scripts/sync-version.js",
54
54
  "version:check": "node scripts/check-version-sync.js",
55
55
  "scripts:check": "node --check bin/native.js && node --check scripts/copy-native.js && node --check scripts/copy-framework.js && node --check scripts/sync-version.js && node --check scripts/check-version-sync.js && node --check scripts/check-framework-sync.js && node --check scripts/check-runtime-types.js && node scripts/copy-framework.js && node scripts/check-framework-sync.js && node scripts/check-runtime-types.js",
@@ -140,6 +140,12 @@ export interface FetchSpec {
140
140
  readonly timeoutMs?: number;
141
141
  }
142
142
 
143
+ export interface NotificationSpec {
144
+ readonly title: Uint8Array;
145
+ readonly subtitle?: Uint8Array;
146
+ readonly body?: Uint8Array;
147
+ }
148
+
143
149
  /// The inert command data — the reference module's Cmd<M> union with
144
150
  /// the type parameter erased (M constrains only the factories' arm-name
145
151
  /// checking, never the data).
@@ -186,6 +192,7 @@ export type CmdData =
186
192
  }
187
193
  | { readonly op: "clip_write"; readonly bytes: Uint8Array }
188
194
  | { readonly op: "clip_read"; readonly key: string; readonly okKind: string; readonly errKind: string }
195
+ | { readonly op: "show_notification"; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array }
189
196
  | { readonly op: "delay"; readonly key: string; readonly afterMs: number; readonly msgKind: string }
190
197
  | {
191
198
  readonly op: "spawn";
@@ -379,6 +386,15 @@ export const Cmd = {
379
386
  return { op: "clip_read", key: route.key ?? "", okKind: route.ok, errKind: route.err };
380
387
  },
381
388
 
389
+ showNotification(spec: NotificationSpec): CmdData {
390
+ return {
391
+ op: "show_notification",
392
+ title: spec.title,
393
+ subtitle: spec.subtitle ?? new Uint8Array(0),
394
+ body: spec.body ?? new Uint8Array(0),
395
+ };
396
+ },
397
+
382
398
  delay(key: string, ms: number, msgKind: string): CmdData {
383
399
  return { op: "delay", key, afterMs: ms, msgKind };
384
400
  },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.8.0",
9
+ "version": "0.8.2",
10
10
  "dependencies": {
11
11
  "scriptc": "0.0.22"
12
12
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "The TypeScript authoring tier: the app-core subset, its checker and contract frontend, the exact-pinned core compiler dependency, and the SDK module cores import",
5
5
  "repository": {
6
6
  "type": "git",
@@ -149,6 +149,11 @@ export interface FetchSpec {
149
149
  readonly body?: Uint8Array;
150
150
  readonly timeoutMs?: number;
151
151
  }
152
+ export interface NotificationSpec {
153
+ readonly title: Uint8Array;
154
+ readonly subtitle?: Uint8Array;
155
+ readonly body?: Uint8Array;
156
+ }
152
157
  export type Cmd<M extends Msgish> = {
153
158
  readonly op: "none";
154
159
  } | {
@@ -208,6 +213,11 @@ export type Cmd<M extends Msgish> = {
208
213
  readonly key: string;
209
214
  readonly okKind: string;
210
215
  readonly errKind: string;
216
+ } | {
217
+ readonly op: "show_notification";
218
+ readonly title: Uint8Array;
219
+ readonly subtitle: Uint8Array;
220
+ readonly body: Uint8Array;
211
221
  } | {
212
222
  readonly op: "delay";
213
223
  readonly key: string;
@@ -315,6 +325,7 @@ export declare const Cmd: {
315
325
  fetch<M extends Msgish>(spec: FetchSpec, route: FetchRoute<M>): Cmd<M>;
316
326
  clipboardWrite(bytes: Uint8Array): Cmd<never>;
317
327
  clipboardRead<M extends Msgish>(route: RequestRoute<M>): Cmd<M>;
328
+ showNotification(spec: NotificationSpec): Cmd<never>;
318
329
  delay<M extends Msgish>(key: string, ms: number, msgKind: TimestampKind<M>): Cmd<M>;
319
330
  spawn<M extends Msgish>(argv: readonly Uint8Array[], route: SpawnRoute<M> | SpawnCollectRoute<M>): Cmd<M>;
320
331
  audioPlay<M extends Msgish>(key: string, source: AudioSource, route: AudioRoute<M>): Cmd<M>;
@@ -66,6 +66,9 @@
66
66
  // clipboard read; ok arm carries the text bytes,
67
67
  // err arm the reason bytes ("failed",
68
68
  // "rejected")
69
+ // Cmd.showNotification({ title, subtitle?, body? })
70
+ // fire-and-forget desktop notification; the OS
71
+ // remains authoritative over final delivery
69
72
  // Cmd.delay(key, ms, "fired") a keyed ONE-SHOT timer: dispatches the named
70
73
  // arm once after `ms`, with the fire time (ms)
71
74
  // as its single number payload; re-issuing a
@@ -328,8 +331,8 @@ export type FetchedKind<M extends Msgish> = M extends Msgish
328
331
  // The generated wiring's opt-in host-event channels: export the channel
329
332
  // and it is wired (`commandMsg(name: string): Msg | null` is the same
330
333
  // family — menus, shortcuts, chrome tabs — and predates these). Event
331
- // RECORD shapes (`frameMsg`'s FrameEvent, `keyMsg`'s KeyEvent, the
332
- // appearanceMsg/chromeMsg arm payloads) are DECLARED IN YOUR CORE and
334
+ // RECORD shapes (`frameMsg`'s FrameEvent, `keyMsg`'s KeyEvent,
335
+ // `dropMsg`'s FileDropEvent, the appearanceMsg/chromeMsg arm payloads) are DECLARED IN YOUR CORE and
333
336
  // matched by field name, the TextInputEvent rule — they must emit as your
334
337
  // module's own records, so an SDK interface cannot stand in for them.
335
338
 
@@ -764,6 +767,16 @@ export interface FetchSpec {
764
767
  readonly timeoutMs?: number;
765
768
  }
766
769
 
770
+ /// A desktop notification request. Text is bytes so every field may come
771
+ /// directly from model data; subtitle and body default to empty. Delivery is
772
+ /// fire-and-forget because the OS may suppress an accepted request through
773
+ /// Focus / Do Not Disturb or the user's notification settings.
774
+ export interface NotificationSpec {
775
+ readonly title: Uint8Array;
776
+ readonly subtitle?: Uint8Array;
777
+ readonly body?: Uint8Array;
778
+ }
779
+
767
780
  /// An inert command value, parameterized by the app's Msg union so the
768
781
  /// factories can validate message targets. Opaque to app code: build with
769
782
  /// the `Cmd.*` factories, return from `update`/`initialModel`, never inspect
@@ -815,6 +828,7 @@ export type Cmd<M extends Msgish> =
815
828
  }
816
829
  | { readonly op: "clip_write"; readonly bytes: Uint8Array }
817
830
  | { readonly op: "clip_read"; readonly key: string; readonly okKind: string; readonly errKind: string }
831
+ | { readonly op: "show_notification"; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array }
818
832
  | { readonly op: "delay"; readonly key: string; readonly afterMs: number; readonly msgKind: string }
819
833
  | {
820
834
  readonly op: "spawn";
@@ -1037,6 +1051,19 @@ export const Cmd = {
1037
1051
  return { op: "clip_read", key: route.key ?? "", okKind: route.ok, errKind: route.err };
1038
1052
  },
1039
1053
 
1054
+ /// Ask the desktop host to show a system notification. Fire-and-forget:
1055
+ /// platform acceptance cannot promise display while OS focus modes and user
1056
+ /// notification settings remain authoritative. Empty or over-bound titles,
1057
+ /// over-bound optional fields, and unavailable services fail closed.
1058
+ showNotification(spec: NotificationSpec): Cmd<never> {
1059
+ return {
1060
+ op: "show_notification",
1061
+ title: spec.title,
1062
+ subtitle: spec.subtitle ?? new Uint8Array(0),
1063
+ body: spec.body ?? new Uint8Array(0),
1064
+ };
1065
+ },
1066
+
1040
1067
  /// A keyed one-shot delay: dispatch the named Msg arm once, `ms` from now,
1041
1068
  /// with the fire time (milliseconds) as its single number payload field.
1042
1069
  /// Re-issuing a live key re-arms it from now (the debounce discipline);
@@ -31,6 +31,16 @@ export interface PinchEvent {
31
31
  readonly x: number;
32
32
  readonly y: number;
33
33
  }
34
+ export interface FileDropPoint {
35
+ readonly x: number;
36
+ readonly y: number;
37
+ }
38
+ export interface FileDropEvent {
39
+ readonly windowId: number;
40
+ readonly viewLabel: string;
41
+ readonly point: FileDropPoint | null;
42
+ readonly paths: readonly Uint8Array[];
43
+ }
34
44
  export type ColorScheme = "light" | "dark";
35
45
  export interface AppearanceEvent {
36
46
  readonly colorScheme: ColorScheme;
@@ -6,8 +6,8 @@
6
6
  // Every record here matches, field for field, the structural shape a
7
7
  // runtime matcher expects — markup's `on-input`/`on-scroll` mirrors
8
8
  // (`declaredTextInputUnion`/`declaredScrollStateRecord`), the generated
9
- // wiring's channel builders (`frameMsg`/`keyMsg`/`appearanceMsg`/
10
- // `chromeMsg`), and the audio event arm validator. Matching stays
9
+ // wiring's channel builders (`frameMsg`/`keyMsg`/`pinchMsg`/`dropMsg`/
10
+ // `appearanceMsg`/`chromeMsg`), and the audio event arm validator. Matching stays
11
11
  // STRUCTURAL either way (type identity cannot cross the emission
12
12
  // boundary), so declaring the same shape in your own core remains legal;
13
13
  // these exports exist so no core has to re-type the vocabulary and no
@@ -26,9 +26,10 @@
26
26
  // - `TextInputEvent`, `ScrollState`: Msg-arm PAYLOAD fields —
27
27
  // `{ kind: "draft_edit"; edit: TextInputEvent }`,
28
28
  // `{ kind: "scrolled"; scroll: ScrollState }`.
29
- // - `FrameEvent`, `KeyEvent`, `PinchEvent`: the wiring channels'
29
+ // - `FrameEvent`, `KeyEvent`, `PinchEvent`, `FileDropEvent`: the wiring channels'
30
30
  // parameter records — `frameMsg(model, frame: FrameEvent)`,
31
- // `keyMsg(key: KeyEvent)`, `pinchMsg(pinch: PinchEvent)`.
31
+ // `keyMsg(key: KeyEvent)`, `pinchMsg(pinch: PinchEvent)`,
32
+ // `dropMsg(drop: FileDropEvent)`.
32
33
  // - `ColorScheme`, `ChromeInsets`, `ChromeButtons`, `AudioState`: field
33
34
  // types INSIDE the arm records the `appearanceMsg`/`chromeMsg`/audio
34
35
  // routes name (the arms themselves stay inline unions of `kind` plus
@@ -118,6 +119,25 @@ export interface PinchEvent {
118
119
  readonly y: number;
119
120
  }
120
121
 
122
+ /// A file drop's optional point in view-local canvas coordinates. Desktop
123
+ /// hosts that only know the target window leave `FileDropEvent.point` null.
124
+ export interface FileDropPoint {
125
+ readonly x: number;
126
+ readonly y: number;
127
+ }
128
+
129
+ /// The app-level file-drop channel's record (`dropMsg(drop)`). `windowId`
130
+ /// and `viewLabel` identify the source; `point` is present when the host can
131
+ /// resolve view-local coordinates. Paths are byte text so arbitrary UTF-8
132
+ /// filesystem names cross without becoming runtime JS strings. Return null
133
+ /// from `dropMsg` to ignore a drop, or map it to an ordinary Msg.
134
+ export interface FileDropEvent {
135
+ readonly windowId: number;
136
+ readonly viewLabel: string;
137
+ readonly point: FileDropPoint | null;
138
+ readonly paths: readonly Uint8Array[];
139
+ }
140
+
121
141
  /// The appearance vocabulary — a NAMED light/dark alias (the host matches
122
142
  /// enum members by name, so this is the `colorScheme` field's type in the
123
143
  /// arm `appearanceMsg` names).
@@ -1092,7 +1092,7 @@ export class SubsetChecker {
1092
1092
  /// entry points, but the exports themselves live in the entry module.
1093
1093
  private static readonly entryOnlyExports = new Set([
1094
1094
  "update", "initialModel", "subscriptions",
1095
- "commandMsg", "keyMsg", "frameMsg", "pinchMsg", "appearanceMsg", "chromeMsg", "envMsgs",
1095
+ "commandMsg", "keyMsg", "frameMsg", "pinchMsg", "dropMsg", "appearanceMsg", "chromeMsg", "envMsgs",
1096
1096
  "viewUnbound", "modelUnbound", "msgUnbound",
1097
1097
  ]);
1098
1098
 
@@ -584,6 +584,7 @@ class ContractEmitter {
584
584
  const hasFrame = this.entryExportedFunction("frameMsg") !== null;
585
585
  const hasKey = this.entryExportedFunction("keyMsg") !== null;
586
586
  const hasPinch = this.entryExportedFunction("pinchMsg") !== null;
587
+ const hasDrop = this.entryExportedFunction("dropMsg") !== null;
587
588
  const envMsgs = this.envMsgEntries()
588
589
  .map((e) => `{"env": ${js(e.env)}, "msg": ${js(e.msg)}}`)
589
590
  .join(", ");
@@ -610,6 +611,7 @@ class ContractEmitter {
610
611
  if (hasFrame) abiExports += ', "frame_msg"';
611
612
  if (hasKey) abiExports += ', "key_msg"';
612
613
  if (hasPinch) abiExports += ', "pinch_msg"';
614
+ if (hasDrop) abiExports += ', "drop_msg"';
613
615
 
614
616
  const typesJson =
615
617
  `{\n "structs": [\n ${structs}\n ],\n` +
@@ -637,7 +639,7 @@ class ContractEmitter {
637
639
  `\x00exports=${abiExports}` +
638
640
  `\x00flags=${boolJson(initReturnsCmd)}${boolJson(updateReturnsCmd)}` +
639
641
  `${boolJson(hasSubscriptions)}${boolJson(hasCommand)}${boolJson(hasFrame)}` +
640
- `${boolJson(hasKey)}${boolJson(hasPinch)}`;
642
+ `${boolJson(hasKey)}${boolJson(hasPinch)}${boolJson(hasDrop)}`;
641
643
  const surfaceBytes = new TextEncoder().encode(surface);
642
644
  const sourceHash = wyhashHex(0x5eedc0den, surfaceBytes);
643
645
  const buildId = wyhashHex(0xb11d1d00n, surfaceBytes);
@@ -666,6 +668,7 @@ class ContractEmitter {
666
668
  ` "frame_msg": ${boolJson(hasFrame)},\n` +
667
669
  ` "key_msg": ${boolJson(hasKey)},\n` +
668
670
  ` "pinch_msg": ${boolJson(hasPinch)},\n` +
671
+ ` "drop_msg": ${boolJson(hasDrop)},\n` +
669
672
  ` "appearance_msg": ${appearance},\n` +
670
673
  ` "chrome_msg": ${chrome},\n` +
671
674
  ` "env_msgs": [${envMsgs}]\n` +
@@ -33,7 +33,8 @@
33
33
  // - timer/now/delay arms carry exactly one number payload field (pinned
34
34
  // by tsc), so the harness constructs them shape-directed without
35
35
  // needing the field's name.
36
- // Every other effect (files, fetch, clipboard, spawn, audio, host commands)
36
+ // Every other effect (files, fetch, clipboard, notifications, spawn, audio,
37
+ // host commands)
37
38
  // is printed as `cmd ...` and NOT performed — feed its result back yourself
38
39
  // as an ordinary Msg line. That is the point: results are plain messages,
39
40
  // and the loop stays deterministic.
@@ -164,6 +165,14 @@ function performCmd(cmd: Cmdish): void {
164
165
  }
165
166
  return;
166
167
  }
168
+ case "show_notification": {
169
+ const details = Object.entries(cmd)
170
+ .filter(([k]) => k !== "op")
171
+ .map(([k, v]) => `${k}=${JSON.stringify(jsonable(v))}`)
172
+ .join(" ");
173
+ say(`cmd ${cmd.op} ${details}`.trimEnd() + " (not performed by the virtual host; no result Msg)");
174
+ return;
175
+ }
167
176
  default: {
168
177
  // Every other effect is the host's job; print the request and let
169
178
  // the author feed the result back as an ordinary Msg line.
@@ -217,7 +217,7 @@ export const rules = {
217
217
  NS1033: {
218
218
  id: "NS1033",
219
219
  title: "wiring channel exports match their host event shapes",
220
- fix: "Declare the channel exactly: `commandMsg(name: string)` / `keyMsg(key: KeyEvent)` / `frameMsg(model: Model, frame: FrameEvent)` returning `Msg | null`; `export const appearanceMsg = \"<arm>\"` / `chromeMsg = \"<arm>\"` naming a Msg arm with that channel's record shape; `export const envMsgs = [{ env: \"NAME\", msg: \"<arm>\" }] as const` with one-`Uint8Array`-field arms.",
220
+ fix: "Declare the channel exactly: `commandMsg(name: string)` / `keyMsg(key: KeyEvent)` / `frameMsg(model: Model, frame: FrameEvent)` / `pinchMsg(pinch: PinchEvent)` / `dropMsg(drop: FileDropEvent)` returning `Msg | null`; `export const appearanceMsg = \"<arm>\"` / `chromeMsg = \"<arm>\"` naming a Msg arm with that channel's record shape; `export const envMsgs = [{ env: \"NAME\", msg: \"<arm>\" }] as const` with one-`Uint8Array`-field arms.",
221
221
  why: "The generated wiring builds these host events structurally from your declarations at build time (the effects-routing rule applied to the app shell); a wrong shape would otherwise surface as a Zig compile error inside generated code instead of a teaching diagnostic here.",
222
222
  },
223
223
  NS1034: {