@native-sdk/cli 0.9.3 → 0.9.5

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 (84) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +323 -76
  3. package/build/ts_run.mjs +15 -18
  4. package/build.zig +83 -8
  5. package/package.json +14 -10
  6. package/packages/core/compile-surface/core.ts +1 -0
  7. package/packages/core/package-lock.json +16 -13
  8. package/packages/core/package.json +5 -2
  9. package/packages/core/scripts/compiler_command.mjs +71 -0
  10. package/packages/core/scripts/compiler_typecheck.mjs +4 -4
  11. package/packages/core/scripts/embed_markup_c.mjs +25 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +3 -3
  13. package/packages/core/scripts/run_external_core_compiler.mjs +21 -10
  14. package/packages/core/scripts/run_external_service_compiler.mjs +17 -7
  15. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  16. package/packages/core/sdk/core.ts +1 -0
  17. package/packages/core/sdk/events.d.ts +36 -4
  18. package/packages/core/sdk/events.ts +49 -6
  19. package/packages/core/src/checker.ts +106 -10
  20. package/packages/core/src/modules.ts +6 -2
  21. package/packages/core/src/sqlite_cli.ts +22 -2
  22. package/packages/core/src/typed_ast.ts +4 -2
  23. package/packages/core/src/types.ts +8 -8
  24. package/schemas/app.schema.json +435 -0
  25. package/skill-data/core/SKILL.md +53 -15
  26. package/skill-data/core/references/project-anatomy.md +6 -6
  27. package/skill-data/native-ui/SKILL.md +28 -6
  28. package/skill-data/ts-core/SKILL.md +9 -6
  29. package/skill-data/ts-services/references/service-surface.md +1 -1
  30. package/skills/native-sdk/SKILL.md +2 -2
  31. package/src/app_runner/ts_core_main.zig +12 -4
  32. package/src/app_runner/ts_core_mobile.zig +6 -2
  33. package/src/automation/snapshot.zig +91 -3
  34. package/src/platform/macos/appkit_host.h +41 -2
  35. package/src/platform/macos/appkit_host.m +198 -9
  36. package/src/platform/macos/cef_host.mm +191 -9
  37. package/src/platform/macos/root.zig +110 -3
  38. package/src/platform/null_platform.zig +50 -1
  39. package/src/platform/null_platform_tests.zig +53 -0
  40. package/src/platform/root.zig +9 -0
  41. package/src/platform/types.zig +58 -0
  42. package/src/platform/windows/root.zig +88 -15
  43. package/src/primitives/canvas/reference.zig +37 -15
  44. package/src/primitives/canvas/reference_tests.zig +63 -0
  45. package/src/primitives/canvas/ui.zig +9 -0
  46. package/src/primitives/canvas/ui_markup.zig +29 -0
  47. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  48. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  49. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  50. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  51. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  52. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  53. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  54. package/src/primitives/canvas/ui_schema.zig +9 -0
  55. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  56. package/src/primitives/canvas/ui_tests.zig +4 -2
  57. package/src/primitives/canvas/widget_render.zig +7 -2
  58. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  59. package/src/root.zig +4 -0
  60. package/src/runtime/automation_snapshot.zig +3 -0
  61. package/src/runtime/flow.zig +1 -1
  62. package/src/runtime/state.zig +14 -0
  63. package/src/runtime/system_services.zig +62 -0
  64. package/src/runtime/ts_ui_app.zig +181 -39
  65. package/src/runtime/ui_app.zig +40 -1
  66. package/src/runtime/ui_app_tests.zig +63 -0
  67. package/src/runtime/ui_app_window_tests.zig +23 -0
  68. package/src/runtime/validation.zig +87 -1
  69. package/src/tooling/android.zig +5 -4
  70. package/src/tooling/buildgraph.zig +24 -8
  71. package/src/tooling/db.zig +1 -1
  72. package/src/tooling/doctor.zig +1 -1
  73. package/src/tooling/ios.zig +5 -4
  74. package/src/tooling/json_to_zon.zig +136 -0
  75. package/src/tooling/manifest.zig +120 -33
  76. package/src/tooling/raw_manifest.zig +4 -0
  77. package/src/tooling/root.zig +1 -0
  78. package/src/tooling/templates.zig +171 -118
  79. package/src/tooling/ts_core.zig +12 -8
  80. package/src/tooling/verbs.zig +233 -5
  81. package/src/tooling/web_engine.zig +17 -1
  82. package/tools/corewire/emit_profile.zig +20 -7
  83. package/tools/corewire/emit_service.zig +49 -24
  84. package/tools/corewire/main.zig +21 -2
@@ -2,6 +2,7 @@ const std = @import("std");
2
2
  const app_icon_tool = @import("app_icon");
3
3
  const app_manifest = @import("app_manifest");
4
4
  const diagnostics = @import("diagnostics");
5
+ const json_to_zon = @import("json_to_zon.zig");
5
6
  const raw_manifest = @import("raw_manifest.zig");
6
7
  const web_engine_tool = @import("web_engine.zig");
7
8
 
@@ -464,104 +465,126 @@ const RawUrlScheme = raw_manifest.RawUrlScheme;
464
465
  const RawDmg = raw_manifest.RawDmg;
465
466
  const RawDmgItem = raw_manifest.RawDmgItem;
466
467
 
468
+ pub const json_name = "app.json";
469
+ pub const zon_name = "app.zon";
470
+
471
+ /// Resolve the conventional manifest in the current app directory. JSON is
472
+ /// the authoring default; app.zon remains a fully supported fallback. When a
473
+ /// project temporarily contains both (for example while migrating), app.json
474
+ /// is authoritative so every CLI boundary makes the same choice.
475
+ pub fn defaultPath(io: std.Io) ?[]const u8 {
476
+ if (pathExists(io, json_name)) return json_name;
477
+ if (pathExists(io, zon_name)) return zon_name;
478
+ return null;
479
+ }
480
+
481
+ fn pathExists(io: std.Io, path: []const u8) bool {
482
+ const stat = std.Io.Dir.cwd().statFile(io, path, .{}) catch return false;
483
+ return stat.kind == .file;
484
+ }
485
+
486
+ pub fn isJsonPath(path: []const u8) bool {
487
+ return json_to_zon.isJsonPath(path);
488
+ }
489
+
467
490
  pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8) !ValidationResult {
468
491
  const source = try readFile(allocator, io, path);
469
492
  defer allocator.free(source);
470
493
 
471
- const metadata = parseText(allocator, source) catch return .{
494
+ const metadata = parseTextForPath(allocator, path, source) catch |err| return .{
472
495
  .ok = false,
473
- .message = zonParseFailureMessage(allocator, source) orelse "app.zon metadata could not be parsed",
496
+ .message = parseFailureMessage(allocator, path, source, err),
474
497
  };
475
498
  defer metadata.deinit(allocator);
476
499
 
477
500
  if (metadata.description) |description| {
478
501
  app_manifest.validateDescription(description) catch return .{
479
502
  .ok = false,
480
- .message = "app.zon description is invalid - it must be one non-empty line of at most 256 bytes with no control characters (it becomes the About panel credits line)",
503
+ .message = "app manifest description is invalid - it must be one non-empty line of at most 256 bytes with no control characters (it becomes the About panel credits line)",
481
504
  };
482
505
  }
483
506
  if (metadata.theme) |theme_name| {
484
507
  if (!isKnownThemePack(theme_name)) return .{
485
508
  .ok = false,
486
- .message = "app.zon theme is invalid - expected one of: house, geist",
509
+ .message = "app manifest theme is invalid - expected one of: house, geist",
487
510
  };
488
511
  }
489
512
  if (metadata.theme_accent) |accent| {
490
513
  if (!isHexColor(accent)) return .{
491
514
  .ok = false,
492
- .message = "app.zon theme_accent is invalid - expected a #rrggbb hex color (e.g. \"#df2670\")",
515
+ .message = "app manifest theme_accent is invalid - expected a #rrggbb hex color (e.g. \"#df2670\")",
493
516
  };
494
517
  }
495
- validateIconPaths(metadata.icons) catch return .{ .ok = false, .message = "app.zon icons are invalid" };
518
+ validateIconPaths(metadata.icons) catch return .{ .ok = false, .message = "app manifest icons are invalid" };
496
519
  if (try checkIconSources(allocator, io, std.fs.path.dirname(path) orelse ".", metadata.icons)) |icon_message| {
497
520
  return .{ .ok = false, .message = icon_message };
498
521
  }
499
- const permissions = parsePermissions(allocator, metadata.permissions) catch return .{ .ok = false, .message = "app.zon permissions are invalid" };
522
+ const permissions = parsePermissions(allocator, metadata.permissions) catch return .{ .ok = false, .message = "app manifest permissions are invalid" };
500
523
  defer allocator.free(permissions);
501
- const capabilities = parseCapabilities(allocator, metadata.capabilities) catch return .{ .ok = false, .message = "app.zon capabilities are invalid" };
524
+ const capabilities = parseCapabilities(allocator, metadata.capabilities) catch return .{ .ok = false, .message = "app manifest capabilities are invalid" };
502
525
  defer allocator.free(capabilities);
503
526
  const persist = convertPersist(metadata.persist);
504
527
  app_manifest.validateImages(.{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes }) catch return .{
505
528
  .ok = false,
506
- .message = "app.zon images.max_image_pixel_bytes must be between 1048576 (the default) and 8388608 bytes; allocation is lazy once per used slot, up to 16 slots",
529
+ .message = "app manifest images.max_image_pixel_bytes must be between 1048576 (the default) and 8388608 bytes; allocation is lazy once per used slot, up to 16 slots",
507
530
  };
508
531
  if (!validServicePackages(metadata.service_packages)) return .{
509
532
  .ok = false,
510
- .message = "app.zon service_packages must use safe npm names, exact X.Y.Z versions, unique names, and lowercase SHA-256 content hashes",
533
+ .message = "app manifest service_packages must use safe npm names, exact X.Y.Z versions, unique names, and lowercase SHA-256 content hashes",
511
534
  };
512
535
  if (!validServiceCarrier(metadata.service_carrier)) return .{
513
536
  .ok = false,
514
- .message = "app.zon service_carrier must be \"auto\", \"in_process\", or \"child\"",
537
+ .message = "app manifest service_carrier must be \"auto\", \"in_process\", or \"child\"",
515
538
  };
516
539
  if (metadata.service_pool_size) |pool_size| {
517
540
  if (pool_size < 1 or pool_size > 16) return .{
518
541
  .ok = false,
519
- .message = "app.zon service_pool_size must be between 1 and 16",
542
+ .message = "app manifest service_pool_size must be between 1 and 16",
520
543
  };
521
544
  }
522
- const bridge_commands = parseBridgeCommands(allocator, metadata.bridge_commands) catch return .{ .ok = false, .message = "app.zon bridge commands are invalid" };
545
+ const bridge_commands = parseBridgeCommands(allocator, metadata.bridge_commands) catch return .{ .ok = false, .message = "app manifest bridge commands are invalid" };
523
546
  defer {
524
547
  for (bridge_commands) |command| allocator.free(command.permissions);
525
548
  allocator.free(bridge_commands);
526
549
  }
527
550
  const frontend = if (metadata.frontend) |frontend_value| convertFrontend(frontend_value) else null;
528
- const security = convertSecurity(metadata.security) catch return .{ .ok = false, .message = "app.zon security policy is invalid" };
529
- const windows = convertWindows(allocator, metadata.windows) catch return .{ .ok = false, .message = "app.zon windows are invalid" };
551
+ const security = convertSecurity(metadata.security) catch return .{ .ok = false, .message = "app manifest security policy is invalid" };
552
+ const windows = convertWindows(allocator, metadata.windows) catch return .{ .ok = false, .message = "app manifest windows are invalid" };
530
553
  defer allocator.free(windows);
531
- const shell = parseShell(allocator, metadata.shell) catch return .{ .ok = false, .message = "app.zon shell is invalid" };
554
+ const shell = parseShell(allocator, metadata.shell) catch return .{ .ok = false, .message = "app manifest shell is invalid" };
532
555
  defer deinitParsedShell(allocator, shell);
533
- const commands = parseCommands(allocator, metadata.commands) catch return .{ .ok = false, .message = "app.zon commands are invalid" };
556
+ const commands = parseCommands(allocator, metadata.commands) catch return .{ .ok = false, .message = "app manifest commands are invalid" };
534
557
  defer allocator.free(commands);
535
- const menus = parseMenus(allocator, metadata.menus) catch return .{ .ok = false, .message = "app.zon menus are invalid" };
558
+ const menus = parseMenus(allocator, metadata.menus) catch return .{ .ok = false, .message = "app manifest menus are invalid" };
536
559
  defer deinitParsedMenus(allocator, menus);
537
- const shortcuts = parseShortcuts(allocator, metadata.shortcuts) catch return .{ .ok = false, .message = "app.zon shortcuts are invalid" };
560
+ const shortcuts = parseShortcuts(allocator, metadata.shortcuts) catch return .{ .ok = false, .message = "app manifest shortcuts are invalid" };
538
561
  defer allocator.free(shortcuts);
539
- const file_associations = parseFileAssociations(allocator, metadata.file_associations) catch return .{ .ok = false, .message = "app.zon file associations are invalid" };
562
+ const file_associations = parseFileAssociations(allocator, metadata.file_associations) catch return .{ .ok = false, .message = "app manifest file associations are invalid" };
540
563
  defer allocator.free(file_associations);
541
- const url_schemes = parseUrlSchemes(allocator, metadata.url_schemes) catch return .{ .ok = false, .message = "app.zon URL schemes are invalid" };
564
+ const url_schemes = parseUrlSchemes(allocator, metadata.url_schemes) catch return .{ .ok = false, .message = "app manifest URL schemes are invalid" };
542
565
  defer allocator.free(url_schemes);
543
566
  // General manifest validation owns only values the app explicitly
544
567
  // declared. Archive-time fallbacks (notably display_name as the volume
545
568
  // name) are validated when a macOS archive is actually requested, so an
546
569
  // otherwise valid display name does not make every `native check` fail.
547
- validateDmgSettings(metadata.dmg) catch return .{ .ok = false, .message = "app.zon dmg settings are invalid - check the volume/bundle names, window/icon geometry, and positions; an explicit items list needs exactly one app and unique safe destination names" };
570
+ validateDmgSettings(metadata.dmg) catch return .{ .ok = false, .message = "app manifest dmg settings are invalid - check the volume/bundle names, window/icon geometry, and positions; an explicit items list needs exactly one app and unique safe destination names" };
548
571
  if (try checkDmgSources(allocator, io, std.fs.path.dirname(path) orelse ".", metadata.dmg)) |dmg_message| {
549
572
  return .{ .ok = false, .message = dmg_message };
550
573
  }
551
- const manifest_web_engine = parseWebEngine(metadata.web_engine) catch return .{ .ok = false, .message = "app.zon web engine is invalid" };
552
- const manifest_webview_layer = parseWebViewLayer(metadata.webview_layer) catch return .{ .ok = false, .message = "app.zon webview_layer is invalid - expected \"auto\", \"include\", or \"exclude\"" };
574
+ const manifest_web_engine = parseWebEngine(metadata.web_engine) catch return .{ .ok = false, .message = "app manifest web engine is invalid" };
575
+ const manifest_webview_layer = parseWebViewLayer(metadata.webview_layer) catch return .{ .ok = false, .message = "app manifest webview_layer is invalid - expected \"auto\", \"include\", or \"exclude\"" };
553
576
  if (!std.mem.eql(u8, metadata.core_compiler, "external")) {
554
577
  if (std.mem.eql(u8, metadata.core_compiler, "transpiler")) {
555
- return .{ .ok = false, .message = "app.zon core_compiler = \"transpiler\" names the removed TS-to-Zig transpiled lane (v0.7.0 removed it) - TypeScript cores compile through the external core compiler now; delete the setting (or spell it \"external\")" };
578
+ return .{ .ok = false, .message = "app manifest core_compiler = \"transpiler\" names the removed TS-to-Zig transpiled lane (v0.7.0 removed it) - TypeScript cores compile through the external core compiler now; delete the setting (or spell it \"external\")" };
556
579
  }
557
- return .{ .ok = false, .message = "app.zon core_compiler is invalid - expected \"external\" (the default and only lane)" };
580
+ return .{ .ok = false, .message = "app manifest core_compiler is invalid - expected \"external\" (the default and only lane)" };
558
581
  }
559
- const platform_settings = parsePlatformSettings(allocator, metadata.platforms) catch return .{ .ok = false, .message = "app.zon platforms are invalid" };
582
+ const platform_settings = parsePlatformSettings(allocator, metadata.platforms) catch return .{ .ok = false, .message = "app manifest platforms are invalid" };
560
583
  defer allocator.free(platform_settings);
561
584
 
562
585
  const manifest: app_manifest.Manifest = .{
563
586
  .identity = .{ .id = metadata.id, .name = metadata.name, .display_name = metadata.display_name, .description = metadata.description },
564
- .version = parseVersion(metadata.version) catch return .{ .ok = false, .message = "app.zon version is invalid" },
587
+ .version = parseVersion(metadata.version) catch return .{ .ok = false, .message = "app manifest version is invalid" },
565
588
  .permissions = permissions,
566
589
  .capabilities = capabilities,
567
590
  .dock_visible = metadata.dock_visible,
@@ -585,12 +608,12 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
585
608
  app_manifest.validateManifest(manifest) catch |err| return .{
586
609
  .ok = false,
587
610
  .message = switch (err) {
588
- error.MissingTrayCapability => "app.zon dock_visible = false requires the \"tray\" capability: an accessory app has no Dock/app-switcher route back to hidden windows - add \"tray\" to .capabilities and install a status item, or keep dock_visible = true (the default)",
611
+ error.MissingTrayCapability => "app manifest dock_visible = false requires the \"tray\" capability: an accessory app has no Dock/app-switcher route back to hidden windows - add \"tray\" to capabilities and install a status item, or keep dock_visible = true (the default)",
589
612
  error.WebViewLayerConflict => web_layer_conflict_message,
590
613
  else => "manifest fields failed semantic validation",
591
614
  },
592
615
  };
593
- return .{ .ok = true, .message = "app.zon is valid" };
616
+ return .{ .ok = true, .message = if (isJsonPath(path)) "app.json is valid" else "app.zon is valid" };
594
617
  }
595
618
 
596
619
  /// Re-parse a failed manifest with std.zon diagnostics enabled so the
@@ -616,12 +639,21 @@ fn zonParseFailureMessage(allocator: std.mem.Allocator, source: []const u8) ?[]c
616
639
  }
617
640
  }
618
641
 
642
+ fn parseFailureMessage(allocator: std.mem.Allocator, path: []const u8, source: []const u8, err: anyerror) []const u8 {
643
+ if (!isJsonPath(path)) return zonParseFailureMessage(allocator, source) orelse "app.zon metadata could not be parsed";
644
+ if (err == error.NullNotAllowed) return "app.json cannot contain null values - omit optional fields instead";
645
+ return std.fmt.allocPrint(allocator, "{s} could not be parsed as a Native SDK manifest ({s})", .{ std.fs.path.basename(path), @errorName(err) }) catch "app.json metadata could not be parsed";
646
+ }
647
+
619
648
  pub fn readMetadata(allocator: std.mem.Allocator, io: std.Io, path: []const u8) !Metadata {
620
649
  const source = try readFile(allocator, io, path);
621
650
  defer allocator.free(source);
622
- return parseText(allocator, source);
651
+ return parseTextForPath(allocator, path, source);
623
652
  }
624
653
 
654
+ /// Parse legacy ZON text. Kept as the focused test/helper API; file-backed
655
+ /// callers use parseTextForPath so app.json and app.zon share one conversion
656
+ /// and semantic-validation pipeline.
625
657
  pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
626
658
  var arena = std.heap.ArenaAllocator.init(allocator);
627
659
  defer arena.deinit();
@@ -629,6 +661,22 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
629
661
  const source_z = try scratch.dupeZ(u8, source);
630
662
  @setEvalBranchQuota(4000);
631
663
  const raw = try std.zon.parse.fromSliceAlloc(RawManifest, scratch, source_z, null, .{});
664
+ return metadataFromRaw(allocator, raw);
665
+ }
666
+
667
+ pub fn parseJsonText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
668
+ try json_to_zon.validateSource(allocator, source);
669
+ var arena = std.heap.ArenaAllocator.init(allocator);
670
+ defer arena.deinit();
671
+ const raw = try std.json.parseFromSliceLeaky(RawManifest, arena.allocator(), source, .{ .ignore_unknown_fields = false });
672
+ return metadataFromRaw(allocator, raw);
673
+ }
674
+
675
+ pub fn parseTextForPath(allocator: std.mem.Allocator, path: []const u8, source: []const u8) !Metadata {
676
+ return if (isJsonPath(path)) parseJsonText(allocator, source) else parseText(allocator, source);
677
+ }
678
+
679
+ fn metadataFromRaw(allocator: std.mem.Allocator, raw: RawManifest) !Metadata {
632
680
  return .{
633
681
  .id = try allocator.dupe(u8, raw.id),
634
682
  .name = try allocator.dupe(u8, raw.name),
@@ -1685,7 +1733,7 @@ fn parseWebViewLayer(value: []const u8) !app_manifest.WebViewLayer {
1685
1733
  /// The teaching message every boundary prints for the same
1686
1734
  /// contradiction: a manifest that excludes the web layer while declaring
1687
1735
  /// web content.
1688
- pub const web_layer_conflict_message = "app.zon sets .webview_layer = \"exclude\" but the app declares web content (a .frontend block, the \"webview\" capability, a .shell webview view, or the Chromium web engine - from .web_engine or --web-engine) - remove the web declarations or drop the exclude";
1736
+ pub const web_layer_conflict_message = "the app manifest sets webview_layer = \"exclude\" but the app declares web content (a frontend block, the \"webview\" capability, a shell webview view, or the Chromium web engine - from web_engine or --web-engine) - remove the web declarations or drop the exclude";
1689
1737
 
1690
1738
  /// The same contradiction arriving through the CLI flag instead of the
1691
1739
  /// manifest field: `--web-layer exclude` against an app that declares
@@ -2390,6 +2438,45 @@ fn parseVersionNumber(value: []const u8) !u32 {
2390
2438
  return std.fmt.parseUnsigned(u32, value, 10);
2391
2439
  }
2392
2440
 
2441
+ test "JSON manifest parser accepts schema metadata and rejects unknown fields" {
2442
+ const metadata = try parseJsonText(std.testing.allocator,
2443
+ \\{
2444
+ \\ "$schema": "https://schema.native-sdk.dev/app/v1.json",
2445
+ \\ "id": "com.example.json",
2446
+ \\ "name": "json-app",
2447
+ \\ "version": "1.2.3",
2448
+ \\ "capabilities": ["native_views"],
2449
+ \\ "windows": [{ "label": "main", "width": 640, "height": 480 }]
2450
+ \\}
2451
+ );
2452
+ defer metadata.deinit(std.testing.allocator);
2453
+ try std.testing.expectEqualStrings("com.example.json", metadata.id);
2454
+ try std.testing.expectEqualStrings("native_views", metadata.capabilities[0]);
2455
+ try std.testing.expectEqual(@as(f32, 640), metadata.windows[0].width);
2456
+
2457
+ try std.testing.expectError(error.UnknownField, parseJsonText(std.testing.allocator,
2458
+ \\{ "id": "com.example.json", "name": "json-app", "version": "1.2.3", "typo": true }
2459
+ ));
2460
+ try std.testing.expectError(error.NullNotAllowed, parseJsonText(std.testing.allocator,
2461
+ \\{ "id": "com.example.json", "name": "json-app", "version": "1.2.3", "theme": null }
2462
+ ));
2463
+ }
2464
+
2465
+ test "JSON file validation rejects null with a teaching diagnostic regardless of extension case" {
2466
+ var cwd = std.Io.Dir.cwd();
2467
+ const root = ".zig-cache/test-validate-json-null";
2468
+ try cwd.deleteTree(std.testing.io, root);
2469
+ defer cwd.deleteTree(std.testing.io, root) catch {};
2470
+ try cwd.createDirPath(std.testing.io, root);
2471
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/APP.JSON", .data =
2472
+ \\{ "id": "com.example.json", "name": "json-app", "version": "1.2.3", "theme": null }
2473
+ });
2474
+
2475
+ const result = try validateFile(std.testing.allocator, std.testing.io, root ++ "/APP.JSON");
2476
+ try std.testing.expect(!result.ok);
2477
+ try std.testing.expectEqualStrings("app.json cannot contain null values - omit optional fields instead", result.message);
2478
+ }
2479
+
2393
2480
  test "manifest metadata parser reads identity version and lists" {
2394
2481
  const metadata = try parseText(std.testing.allocator,
2395
2482
  \\.{
@@ -3296,7 +3383,7 @@ test "validate rejects a web-declaring manifest that excludes the web layer" {
3296
3383
 
3297
3384
  const result = try validateFile(gpa, std.testing.io, root ++ "/app.zon");
3298
3385
  try std.testing.expect(!result.ok);
3299
- try std.testing.expect(std.mem.indexOf(u8, result.message, ".webview_layer = \"exclude\"") != null);
3386
+ try std.testing.expect(std.mem.indexOf(u8, result.message, "webview_layer = \"exclude\"") != null);
3300
3387
  try std.testing.expect(std.mem.indexOf(u8, result.message, "declares web content") != null);
3301
3388
 
3302
3389
  // A native-only manifest with the same exclude is valid.
@@ -1,6 +1,10 @@
1
1
  const web_engine = @import("web_engine.zig");
2
2
 
3
3
  pub const RawManifest = struct {
4
+ /// Editor-only JSON Schema association. The manifest tooling ignores the
5
+ /// value after parsing; app.json scaffolds point it at the published SDK
6
+ /// schema so editors can complete and validate the full manifest surface.
7
+ @"$schema": ?[]const u8 = null,
4
8
  id: []const u8,
5
9
  name: []const u8,
6
10
  display_name: ?[]const u8 = null,
@@ -1,6 +1,7 @@
1
1
  pub const templates = @import("templates.zig");
2
2
  pub const manifest = @import("manifest.zig");
3
3
  pub const raw_manifest = @import("raw_manifest.zig");
4
+ pub const json_to_zon = @import("json_to_zon.zig");
4
5
  pub const assets = @import("assets.zig");
5
6
  pub const codesign = @import("codesign.zig");
6
7
  pub const doctor = @import("doctor.zig");