@native-sdk/cli 0.8.4 → 0.9.1

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 (161) hide show
  1. package/build/app.zig +1178 -74
  2. package/build.zig +715 -17
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +10 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +435 -3
  7. package/packages/core/package-lock.json +11 -11
  8. package/packages/core/package.json +2 -2
  9. package/packages/core/scripts/compiler_typecheck.mjs +116 -15
  10. package/packages/core/scripts/gen_service_surface.mjs +268 -0
  11. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +64 -0
  13. package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
  14. package/packages/core/scripts/run_external_service_compiler.mjs +280 -0
  15. package/packages/core/scripts/stage_external_core.mjs +9 -1
  16. package/packages/core/scripts/stage_external_services.mjs +172 -0
  17. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  18. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  19. package/packages/core/sdk/core.d.ts +224 -0
  20. package/packages/core/sdk/core.ts +694 -22
  21. package/packages/core/sdk/events.d.ts +89 -0
  22. package/packages/core/sdk/events.ts +128 -0
  23. package/packages/core/src/checker.ts +936 -15
  24. package/packages/core/src/cli.ts +156 -3
  25. package/packages/core/src/contract.ts +28 -5
  26. package/packages/core/src/devhost.ts +1876 -16
  27. package/packages/core/src/devhost_journal.mjs +183 -0
  28. package/packages/core/src/devhost_resolver.mjs +17 -1
  29. package/packages/core/src/devhost_service_worker.mjs +90 -0
  30. package/packages/core/src/diagnostics.ts +179 -22
  31. package/packages/core/src/frontend.ts +210 -34
  32. package/packages/core/src/infer.ts +24 -0
  33. package/packages/core/src/modules.ts +129 -80
  34. package/packages/core/src/service_contract.ts +597 -0
  35. package/packages/core/src/sqlite_cli.ts +93 -0
  36. package/packages/core/src/sqlite_codegen.ts +806 -0
  37. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  38. package/packages/core/src/typed_ast.ts +36 -8
  39. package/skill-data/automation/SKILL.md +1 -1
  40. package/skill-data/core/references/project-anatomy.md +1 -1
  41. package/skill-data/native-ui/SKILL.md +58 -5
  42. package/skill-data/ts-core/SKILL.md +123 -41
  43. package/skill-data/ts-services/SKILL.md +126 -0
  44. package/skill-data/ts-services/references/service-surface.md +604 -0
  45. package/skill-data/zig/SKILL.md +1 -1
  46. package/skills/native-sdk/SKILL.md +1 -1
  47. package/src/app_runner/no_migrations.zig +3 -0
  48. package/src/app_runner/no_services.zig +20 -0
  49. package/src/app_runner/root.zig +133 -4
  50. package/src/app_runner/ts_core_main.zig +254 -8
  51. package/src/app_runner/ts_core_mobile.zig +241 -0
  52. package/src/automation/protocol.zig +5 -1
  53. package/src/automation/snapshot.zig +31 -11
  54. package/src/embed/app_exports.zig +12 -1
  55. package/src/embed/c_api.zig +48 -2
  56. package/src/embed/conversions.zig +4 -5
  57. package/src/embed/host.zig +109 -1
  58. package/src/embed/root.zig +8 -0
  59. package/src/embed/tests.zig +241 -0
  60. package/src/embed/types.zig +51 -0
  61. package/src/embed/ui_host.zig +185 -5
  62. package/src/platform/android/NativeSdkActivity.java +131 -0
  63. package/src/platform/android/android_host.c +182 -1
  64. package/src/platform/android/native_sdk_app.h +17 -0
  65. package/src/platform/ios/native_sdk_app.h +17 -0
  66. package/src/platform/ios/uikit_host.m +115 -0
  67. package/src/platform/linux/cef_host.cpp +8 -2
  68. package/src/platform/linux/gtk_host.c +289 -22
  69. package/src/platform/linux/gtk_host.h +5 -1
  70. package/src/platform/linux/root.zig +109 -22
  71. package/src/platform/macos/appkit_host.h +24 -7
  72. package/src/platform/macos/appkit_host.m +686 -64
  73. package/src/platform/macos/cef_host.mm +400 -66
  74. package/src/platform/macos/root.zig +304 -47
  75. package/src/platform/null_platform.zig +435 -48
  76. package/src/platform/null_platform_tests.zig +113 -0
  77. package/src/platform/root.zig +19 -0
  78. package/src/platform/types.zig +281 -28
  79. package/src/platform/windows/root.zig +207 -27
  80. package/src/platform/windows/webview2_host.cpp +334 -51
  81. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  82. package/src/primitives/app_manifest/root.zig +4 -0
  83. package/src/primitives/app_manifest/tests.zig +3 -0
  84. package/src/primitives/app_manifest/types.zig +32 -0
  85. package/src/primitives/app_manifest/validation.zig +19 -1
  86. package/src/root.zig +53 -0
  87. package/src/runtime/api.zig +19 -0
  88. package/src/runtime/automation_commands.zig +35 -2
  89. package/src/runtime/automation_snapshot.zig +32 -20
  90. package/src/runtime/bridge_permission_tests.zig +58 -3
  91. package/src/runtime/bridge_responses.zig +4 -2
  92. package/src/runtime/builtin_bridge.zig +11 -1
  93. package/src/runtime/canvas_frame.zig +18 -11
  94. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  95. package/src/runtime/clock.zig +13 -1
  96. package/src/runtime/core.zig +145 -7
  97. package/src/runtime/credentials_store.zig +115 -0
  98. package/src/runtime/effects.zig +3701 -231
  99. package/src/runtime/effects_credentials_tests.zig +332 -0
  100. package/src/runtime/effects_file_tests.zig +587 -0
  101. package/src/runtime/effects_host_tests.zig +208 -1
  102. package/src/runtime/effects_notification_tests.zig +11 -0
  103. package/src/runtime/effects_relational_tests.zig +314 -0
  104. package/src/runtime/effects_store_tests.zig +211 -0
  105. package/src/runtime/file_access.zig +400 -0
  106. package/src/runtime/file_effect_crash_helper.zig +28 -0
  107. package/src/runtime/file_effect_crash_tests.zig +37 -0
  108. package/src/runtime/flow.zig +35 -10
  109. package/src/runtime/gpu_surface_events.zig +6 -1
  110. package/src/runtime/native_command_event_tests.zig +86 -2
  111. package/src/runtime/persist_store.zig +666 -0
  112. package/src/runtime/pty.zig +5 -2
  113. package/src/runtime/record_store.zig +788 -0
  114. package/src/runtime/relational_store.zig +854 -0
  115. package/src/runtime/root.zig +54 -0
  116. package/src/runtime/runtime_event_tests.zig +70 -0
  117. package/src/runtime/service_host.zig +711 -0
  118. package/src/runtime/service_pool.zig +1314 -0
  119. package/src/runtime/session_blobs.zig +4 -1
  120. package/src/runtime/session_journal.zig +158 -5
  121. package/src/runtime/session_record.zig +215 -0
  122. package/src/runtime/session_replay.zig +206 -11
  123. package/src/runtime/session_tests.zig +81 -0
  124. package/src/runtime/shell_layout.zig +1 -0
  125. package/src/runtime/shell_layout_tests.zig +120 -0
  126. package/src/runtime/sqlite_engine.zig +474 -0
  127. package/src/runtime/state.zig +16 -0
  128. package/src/runtime/system_services.zig +170 -38
  129. package/src/runtime/tests.zig +4 -0
  130. package/src/runtime/ts_core_host.zig +1067 -95
  131. package/src/runtime/ts_core_host_tests.zig +325 -11
  132. package/src/runtime/ts_ui_app.zig +953 -2
  133. package/src/runtime/ui_app.zig +434 -96
  134. package/src/runtime/ui_app_tests.zig +287 -11
  135. package/src/runtime/ui_app_window_tests.zig +61 -7
  136. package/src/runtime/validation.zig +42 -0
  137. package/src/runtime/view.zig +9 -0
  138. package/src/runtime/window_storage.zig +1 -0
  139. package/src/runtime/window_view_runtime.zig +2 -3
  140. package/src/runtime/window_views.zig +19 -0
  141. package/src/tooling/android.zig +21 -16
  142. package/src/tooling/db.zig +160 -0
  143. package/src/tooling/ios.zig +7 -1
  144. package/src/tooling/manifest.zig +214 -2
  145. package/src/tooling/package.zig +116 -0
  146. package/src/tooling/raw_manifest.zig +30 -0
  147. package/src/tooling/root.zig +1 -0
  148. package/src/tooling/templates.zig +189 -4
  149. package/src/tooling/ts_core.zig +366 -17
  150. package/src/tooling/verbs.zig +7 -0
  151. package/third_party/sqlite/README.md +13 -0
  152. package/third_party/sqlite/sqlite3.c +269649 -0
  153. package/third_party/sqlite/sqlite3.h +14349 -0
  154. package/tools/corewire/core_abi.zig +14 -2
  155. package/tools/corewire/emit.zig +98 -29
  156. package/tools/corewire/emit_facade.zig +442 -27
  157. package/tools/corewire/emit_profile.zig +6 -2
  158. package/tools/corewire/emit_service.zig +924 -0
  159. package/tools/corewire/main.zig +122 -0
  160. package/tools/corewire/service_contract.zig +250 -0
  161. package/tools/corewire/sidecar.zig +26 -15
@@ -66,6 +66,10 @@ pub const PackageOptions = struct {
66
66
  /// as a custom DMG background. The CLI derives it from --manifest.
67
67
  project_dir: []const u8 = ".",
68
68
  binary_path: ?[]const u8 = null,
69
+ /// Phase-1 TypeScript service host. Desktop packages place this next
70
+ /// to the app executable so the generated runner can resolve it by
71
+ /// sibling name and both executables enter the signing boundary.
72
+ service_binary_path: ?[]const u8 = null,
69
73
  assets_dir: []const u8 = "assets",
70
74
  frontend: ?manifest_tool.FrontendMetadata = null,
71
75
  web_engine: WebEngine = .system,
@@ -87,6 +91,45 @@ pub const PackageOptions = struct {
87
91
  env_map: ?*std.process.Environ.Map = null,
88
92
  };
89
93
 
94
+ /// Whether the app source tree declares the TypeScript service class. This
95
+ /// guards CLI auto-discovery so a stale installed helper is never added to a
96
+ /// package after the app's services have been removed.
97
+ pub fn projectHasTypeScriptServices(allocator: std.mem.Allocator, io: std.Io, project_dir: []const u8) !bool {
98
+ const services_path = try std.fs.path.join(allocator, &.{ project_dir, "src", "services" });
99
+ defer allocator.free(services_path);
100
+ var dir = std.Io.Dir.cwd().openDir(io, services_path, .{ .iterate = true }) catch return false;
101
+ defer dir.close(io);
102
+ var walker = try dir.walk(allocator);
103
+ defer walker.deinit();
104
+ while (try walker.next(io)) |entry| {
105
+ if (entry.kind == .file and std.mem.endsWith(u8, entry.basename, ".ts") and
106
+ !std.mem.endsWith(u8, entry.basename, ".d.ts")) return true;
107
+ }
108
+ return false;
109
+ }
110
+
111
+ /// Locate the service host installed by a normal `native build`. Explicit
112
+ /// package inputs still win; this is the CLI's no-flag fallback twin of the
113
+ /// main executable discovery.
114
+ pub fn discoverInstalledServiceBinary(
115
+ allocator: std.mem.Allocator,
116
+ io: std.Io,
117
+ project_dir: []const u8,
118
+ app_name: []const u8,
119
+ target: PackageTarget,
120
+ ) !?[]const u8 {
121
+ const suffix: []const u8 = if (target == .windows) ".exe" else "";
122
+ const file_name = try std.fmt.allocPrint(allocator, "{s}_services{s}", .{ app_name, suffix });
123
+ defer allocator.free(file_name);
124
+ const candidate = try std.fs.path.join(allocator, &.{ project_dir, "zig-out", "bin", file_name });
125
+ var file = std.Io.Dir.cwd().openFile(io, candidate, .{}) catch {
126
+ allocator.free(candidate);
127
+ return null;
128
+ };
129
+ file.close(io);
130
+ return candidate;
131
+ }
132
+
90
133
  /// The Windows subsystem verdict the packaging posture check reaches:
91
134
  /// `gui` and `console` only when the PE optional header actually said
92
135
  /// so, `unknown` when the probe proved nothing — non-PE or truncated
@@ -256,6 +299,12 @@ pub fn createMacosApp(allocator: std.mem.Allocator, io: std.Io, options: Package
256
299
  } else {
257
300
  try writeFile(package_dir, io, "Contents/MacOS/README.txt", "No app binary was supplied for this local package.\n");
258
301
  }
302
+ if (options.service_binary_path) |service_binary_path| {
303
+ const service_subpath = try std.fmt.allocPrint(allocator, "Contents/MacOS/{s}_services", .{executable_name});
304
+ defer allocator.free(service_subpath);
305
+ try copyFileToDir(allocator, io, package_dir, service_binary_path, service_subpath);
306
+ try makeExecutable(package_dir, io, service_subpath);
307
+ }
259
308
 
260
309
  const info_plist = try macosInfoPlist(allocator, options.metadata, executable_name);
261
310
  defer allocator.free(info_plist);
@@ -361,6 +410,13 @@ fn createDesktopArtifact(allocator: std.mem.Allocator, io: std.Io, options: Pack
361
410
  } else {
362
411
  try writeFile(dir, io, "bin/README.txt", "Build the app binary separately and place it here for this target.\n");
363
412
  }
413
+ if (options.service_binary_path) |service_binary_path| {
414
+ const service_suffix: []const u8 = if (options.target == .windows) ".exe" else "";
415
+ const service_subpath = try std.fmt.allocPrint(allocator, "bin/{s}_services{s}", .{ options.metadata.name, service_suffix });
416
+ defer allocator.free(service_subpath);
417
+ try copyFileToDir(allocator, io, dir, service_binary_path, service_subpath);
418
+ try makeExecutable(dir, io, service_subpath);
419
+ }
364
420
 
365
421
  const assets_output = try assetOutputPath(allocator, options.output_path, "resources", options);
366
422
  defer allocator.free(assets_output);
@@ -2854,6 +2910,7 @@ test "mobile package templates ship the toolkit hosts" {
2854
2910
  try std.testing.expect(std.mem.indexOf(u8, ios_host, "native_sdk_app_text_input_state") != null);
2855
2911
  try std.testing.expect(std.mem.indexOf(u8, ios_host, "native_sdk_app_set_text_measure") != null);
2856
2912
  try std.testing.expect(std.mem.indexOf(u8, ios_host, "native_sdk_app_set_asset_root") != null);
2913
+ try std.testing.expect(std.mem.indexOf(u8, ios_host, "native_sdk_app_set_data_root") != null);
2857
2914
  try std.testing.expect(std.mem.indexOf(u8, ios_host, "native_sdk_app_widget_semantics_by_id") != null);
2858
2915
  try std.testing.expect(std.mem.indexOf(u8, ios_host, "view.safeAreaInsets") != null);
2859
2916
  try std.testing.expect(std.mem.indexOf(u8, ios_host, "_dyld_get_image_header_containing_address") != null);
@@ -2879,6 +2936,7 @@ test "mobile package templates ship the toolkit hosts" {
2879
2936
  try std.testing.expect(std.mem.indexOf(u8, android_bridge, "native_sdk_app_text_input_state") != null);
2880
2937
  try std.testing.expect(std.mem.indexOf(u8, android_bridge, "native_sdk_app_set_text_measure") != null);
2881
2938
  try std.testing.expect(std.mem.indexOf(u8, android_bridge, "native_sdk_app_set_asset_root") != null);
2939
+ try std.testing.expect(std.mem.indexOf(u8, android_bridge, "native_sdk_app_set_data_root") != null);
2882
2940
  try std.testing.expect(std.mem.indexOf(u8, android_bridge, "ANativeWindow_fromSurface") != null);
2883
2941
  try std.testing.expect(std.mem.indexOf(u8, android_bridge, "WINDOW_FORMAT_RGBA_8888") != null);
2884
2942
  }
@@ -3300,6 +3358,64 @@ test "macOS app executable is marked executable" {
3300
3358
  try std.testing.expect((permissions.toMode() & 0o111) != 0);
3301
3359
  }
3302
3360
 
3361
+ test "desktop packages place the TypeScript service host beside the app" {
3362
+ var cwd = std.Io.Dir.cwd();
3363
+ const root = ".zig-cache/test-package-service-host";
3364
+ try cwd.deleteTree(std.testing.io, root);
3365
+ defer cwd.deleteTree(std.testing.io, root) catch {};
3366
+ try cwd.createDirPath(std.testing.io, root ++ "/assets");
3367
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/app", .data = "app" });
3368
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/service", .data = "service" });
3369
+
3370
+ const metadata: manifest_tool.Metadata = .{ .id = "dev.example.service", .name = "service-demo", .version = "1.0.0" };
3371
+ _ = try createPackage(std.testing.allocator, std.testing.io, .{
3372
+ .metadata = metadata,
3373
+ .target = .linux,
3374
+ .output_path = root ++ "/linux",
3375
+ .binary_path = root ++ "/app",
3376
+ .service_binary_path = root ++ "/service",
3377
+ .assets_dir = root ++ "/assets",
3378
+ });
3379
+ var linux_dir = try cwd.openDir(std.testing.io, root ++ "/linux", .{});
3380
+ defer linux_dir.close(std.testing.io);
3381
+ var linux_service = try linux_dir.openFile(std.testing.io, "bin/service-demo_services", .{});
3382
+ linux_service.close(std.testing.io);
3383
+
3384
+ _ = try createMacosApp(std.testing.allocator, std.testing.io, .{
3385
+ .metadata = metadata,
3386
+ .output_path = root ++ "/Service.app",
3387
+ .binary_path = root ++ "/app",
3388
+ .service_binary_path = root ++ "/service",
3389
+ .assets_dir = root ++ "/assets",
3390
+ });
3391
+ var mac_dir = try cwd.openDir(std.testing.io, root ++ "/Service.app", .{});
3392
+ defer mac_dir.close(std.testing.io);
3393
+ var mac_service = try mac_dir.openFile(std.testing.io, "Contents/MacOS/service-demo_services", .{});
3394
+ mac_service.close(std.testing.io);
3395
+ }
3396
+
3397
+ test "normal build service host is discovered only for a service-bearing app" {
3398
+ var cwd = std.Io.Dir.cwd();
3399
+ const root = ".zig-cache/test-package-service-discovery";
3400
+ try cwd.deleteTree(std.testing.io, root);
3401
+ defer cwd.deleteTree(std.testing.io, root) catch {};
3402
+ try cwd.createDirPath(std.testing.io, root ++ "/src/services/nested");
3403
+ try cwd.createDirPath(std.testing.io, root ++ "/zig-out/bin");
3404
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/zig-out/bin/service-demo_services", .data = "service" });
3405
+
3406
+ try std.testing.expect(!try projectHasTypeScriptServices(std.testing.allocator, std.testing.io, root));
3407
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/src/services/types.d.ts", .data = "export interface Ignored {}" });
3408
+ try std.testing.expect(!try projectHasTypeScriptServices(std.testing.allocator, std.testing.io, root));
3409
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/src/services/nested/feeds.ts", .data = "export function parse(): Uint8Array { return new Uint8Array(0); }" });
3410
+ try std.testing.expect(try projectHasTypeScriptServices(std.testing.allocator, std.testing.io, root));
3411
+ const discovered = (try discoverInstalledServiceBinary(std.testing.allocator, std.testing.io, root, "service-demo", .linux)).?;
3412
+ defer std.testing.allocator.free(discovered);
3413
+ try std.testing.expectEqualStrings(root ++ "/zig-out/bin/service-demo_services", discovered);
3414
+
3415
+ try cwd.deleteTree(std.testing.io, root ++ "/src/services");
3416
+ try std.testing.expect(!try projectHasTypeScriptServices(std.testing.allocator, std.testing.io, root));
3417
+ }
3418
+
3303
3419
  test "desktop chromium packages are rejected before CEF layout checks" {
3304
3420
  const metadata: manifest_tool.Metadata = .{
3305
3421
  .id = "dev.demo",
@@ -10,6 +10,14 @@ pub const RawManifest = struct {
10
10
  platforms: []const []const u8 = &.{},
11
11
  permissions: []const []const u8 = &.{},
12
12
  capabilities: []const []const u8 = &.{},
13
+ persist: ?RawPersist = null,
14
+ service_packages: []const RawServicePackage = &.{},
15
+ /// Which carrier runs src/services operations: "auto" (the default child
16
+ /// carrier), "in_process", or "child".
17
+ service_carrier: []const u8 = "auto",
18
+ /// In-process service pool width (1-16); 0 keeps the runtime default
19
+ /// (min(4, cores)).
20
+ service_pool_size: u8 = 0,
13
21
  bridge: RawBridge = .{},
14
22
  web_engine: []const u8 = @tagName(web_engine.default_engine),
15
23
  webview_layer: []const u8 = "auto",
@@ -33,6 +41,24 @@ pub const RawManifest = struct {
33
41
  dmg: RawDmg = .{},
34
42
  };
35
43
 
44
+ pub const RawServicePackage = struct {
45
+ name: []const u8,
46
+ version: []const u8,
47
+ content_hash: []const u8,
48
+ };
49
+
50
+ pub const RawPersist = struct {
51
+ version: u64,
52
+ debounce_ms: u32 = 500,
53
+ restore: RawPersistRestore,
54
+ };
55
+
56
+ pub const RawPersistRestore = struct {
57
+ ok: []const u8,
58
+ none: []const u8,
59
+ err: []const u8,
60
+ };
61
+
36
62
  pub const RawCef = struct {
37
63
  dir: []const u8 = web_engine.default_cef_dir,
38
64
  auto_install: bool = false,
@@ -103,6 +129,8 @@ pub const RawWindow = struct {
103
129
  always_on_top: bool = false,
104
130
  click_through: bool = false,
105
131
  activate_on_show: bool = true,
132
+ initially_hidden: bool = false,
133
+ allows_fullscreen: bool = true,
106
134
  min_width: f32 = 0,
107
135
  min_height: f32 = 0,
108
136
  close_policy: []const u8 = "quit",
@@ -145,6 +173,8 @@ pub const RawShellWindow = struct {
145
173
  always_on_top: bool = false,
146
174
  click_through: bool = false,
147
175
  activate_on_show: bool = true,
176
+ initially_hidden: bool = false,
177
+ allows_fullscreen: bool = true,
148
178
  min_width: f32 = 0,
149
179
  min_height: f32 = 0,
150
180
  close_policy: []const u8 = "quit",
@@ -18,6 +18,7 @@ pub const ts_core = @import("ts_core.zig");
18
18
  pub const ios = @import("ios.zig");
19
19
  pub const android = @import("android.zig");
20
20
  pub const xcodeproj = @import("xcodeproj.zig");
21
+ pub const db = @import("db.zig");
21
22
 
22
23
  test {
23
24
  @import("std").testing.refAllDecls(@This());
@@ -1444,6 +1444,10 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1444
1444
  \\ const web_layer = resolveWebLayer(app_config, web_engine, web_layer_override);
1445
1445
  \\
1446
1446
  \\ const native_sdk_mod = nativeSdkModule(b, target, optimize, native_sdk_path);
1447
+ \\ const relational_migrations_source = if (app_config.relational_capability)
1448
+ \\ sqliteMigrationsSource(b, native_sdk_path)
1449
+ \\ else
1450
+ \\ nativeSdkPath(b, native_sdk_path, "src/app_runner/no_migrations.zig");
1447
1451
  \\ const options = b.addOptions();
1448
1452
  \\ options.addOption([]const u8, "platform", switch (selected_platform) {
1449
1453
  \\ .auto => unreachable,
@@ -1464,10 +1468,14 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1464
1468
  \\ runner_mod.addImport("native_sdk", native_sdk_mod);
1465
1469
  \\ runner_mod.addImport("build_options", options_mod);
1466
1470
  \\ runner_mod.addImport("app_manifest_zon", b.createModule(.{ .root_source_file = b.path("app.zon") }));
1471
+ \\ const migrations_mod = b.createModule(.{ .root_source_file = relational_migrations_source, .target = target, .optimize = optimize });
1472
+ \\ migrations_mod.addImport("native_sdk", native_sdk_mod);
1473
+ \\ runner_mod.addImport("relational_migrations", migrations_mod);
1467
1474
  \\
1468
1475
  \\ const app_mod = localModule(b, target, optimize, "src/main.zig");
1469
1476
  \\ app_mod.addImport("native_sdk", native_sdk_mod);
1470
1477
  \\ app_mod.addImport("runner", runner_mod);
1478
+ \\ if (app_config.sqlite_capability) addSqliteEngine(b, app_mod, native_sdk_path);
1471
1479
  \\ addMacosPrivacyInfoPlist(b, app_mod, target, app_config);
1472
1480
  \\ const exe = b.addExecutable(.{
1473
1481
  \\ .name = app_exe_name,
@@ -1527,9 +1535,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1527
1535
  \\ package_runner_mod.addImport("native_sdk", package_sdk_mod);
1528
1536
  \\ package_runner_mod.addImport("build_options", options_mod);
1529
1537
  \\ package_runner_mod.addImport("app_manifest_zon", b.createModule(.{ .root_source_file = b.path("app.zon") }));
1538
+ \\ const package_migrations_mod = b.createModule(.{ .root_source_file = relational_migrations_source, .target = target, .optimize = package_optimize });
1539
+ \\ package_migrations_mod.addImport("native_sdk", package_sdk_mod);
1540
+ \\ package_runner_mod.addImport("relational_migrations", package_migrations_mod);
1530
1541
  \\ const package_app_mod = localModule(b, target, package_optimize, "src/main.zig");
1531
1542
  \\ package_app_mod.addImport("native_sdk", package_sdk_mod);
1532
1543
  \\ package_app_mod.addImport("runner", package_runner_mod);
1544
+ \\ if (app_config.sqlite_capability) addSqliteEngine(b, package_app_mod, native_sdk_path);
1533
1545
  \\ addMacosPrivacyInfoPlist(b, package_app_mod, target, app_config);
1534
1546
  \\ const built = b.addExecutable(.{
1535
1547
  \\ .name = app_exe_name,
@@ -1705,6 +1717,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1705
1717
  \\ debug_mod.addImport("trace", trace_mod);
1706
1718
  \\
1707
1719
  \\ const native_sdk_mod = externalModule(b, target, optimize, native_sdk_path, "src/root.zig");
1720
+ \\ native_sdk_mod.addIncludePath(nativeSdkPath(b, native_sdk_path, "third_party/sqlite"));
1708
1721
  \\ native_sdk_mod.addImport("geometry", geometry_mod);
1709
1722
  \\ native_sdk_mod.addImport("assets", assets_mod);
1710
1723
  \\ native_sdk_mod.addImport("app_dirs", app_dirs_mod);
@@ -1717,6 +1730,44 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1717
1730
  \\ return native_sdk_mod;
1718
1731
  \\}
1719
1732
  \\
1733
+ \\fn sqliteMigrationsSource(b: *std.Build, native_sdk_path: []const u8) std.Build.LazyPath {
1734
+ \\ const generate = b.addSystemCommand(&.{ "node" });
1735
+ \\ generate.addFileArg(nativeSdkPath(b, native_sdk_path, "build/ts_run.mjs"));
1736
+ \\ generate.addFileArg(nativeSdkPath(b, native_sdk_path, "packages/core/src/sqlite_cli.ts"));
1737
+ \\ generate.addArg("--src");
1738
+ \\ generate.addDirectoryArg(b.path("src"));
1739
+ \\ generate.addArg("--zig-out");
1740
+ \\ const migrations = generate.addOutputFileArg("migrations.zig");
1741
+ \\ generate.addArgs(&.{ "--state", "src/schema/migrations.lock.json" });
1742
+ \\ if (b.build_root.handle.access(b.graph.io, "src/schema/migrations.lock.json", .{})) |_| {
1743
+ \\ generate.addFileInput(b.path("src/schema/migrations.lock.json"));
1744
+ \\ } else |_| {}
1745
+ \\ generate.addFileInput(nativeSdkPath(b, native_sdk_path, "packages/core/src/sqlite_codegen.ts"));
1746
+ \\ generate.addFileInput(nativeSdkPath(b, native_sdk_path, "packages/core/src/sqlite_runtime_policy.ts"));
1747
+ \\ addAppSqlDirInputs(b, generate, "src");
1748
+ \\ return migrations;
1749
+ \\}
1750
+ \\
1751
+ \\fn addAppSqlDirInputs(b: *std.Build, run: *std.Build.Step.Run, src_path: []const u8) void {
1752
+ \\ var dir = b.build_root.handle.openDir(b.graph.io, src_path, .{ .iterate = true }) catch return;
1753
+ \\ defer dir.close(b.graph.io);
1754
+ \\ var walker = dir.walk(b.allocator) catch return;
1755
+ \\ defer walker.deinit();
1756
+ \\ while (walker.next(b.graph.io) catch null) |entry| {
1757
+ \\ if (entry.kind != .file or !std.mem.endsWith(u8, entry.basename, ".sql")) continue;
1758
+ \\ run.addFileInput(b.path(b.fmt("{s}/{s}", .{ src_path, entry.path })));
1759
+ \\ }
1760
+ \\}
1761
+ \\
1762
+ \\fn addSqliteEngine(b: *std.Build, app_mod: *std.Build.Module, native_sdk_path: []const u8) void {
1763
+ \\ app_mod.addIncludePath(nativeSdkPath(b, native_sdk_path, "third_party/sqlite"));
1764
+ \\ app_mod.addCSourceFile(.{
1765
+ \\ .file = nativeSdkPath(b, native_sdk_path, "third_party/sqlite/sqlite3.c"),
1766
+ \\ .flags = &.{ "-DSQLITE_THREADSAFE=2", "-DSQLITE_OMIT_LOAD_EXTENSION", "-DSQLITE_DQS=0", "-DSQLITE_ENABLE_FTS5", "-DSQLITE_ENABLE_JSON1", "-DSQLITE_ENABLE_UPDATE_HOOK", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_DEFAULT_MEMSTATUS=0" },
1767
+ \\ });
1768
+ \\ app_mod.link_libc = true;
1769
+ \\}
1770
+ \\
1720
1771
  \\fn externalModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, native_sdk_path: []const u8, path: []const u8) *std.Build.Module {
1721
1772
  \\ return b.createModule(.{
1722
1773
  \\ .root_source_file = nativeSdkPath(b, native_sdk_path, path),
@@ -1992,6 +2043,8 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1992
2043
  \\ webview_layer: WebLayerOption = .auto,
1993
2044
  \\ microphone_permission: bool = false,
1994
2045
  \\ system_audio_permission: bool = false,
2046
+ \\ sqlite_capability: bool = false,
2047
+ \\ relational_capability: bool = false,
1995
2048
  \\ /// The first web declaration found (for teaching messages), or
1996
2049
  \\ /// null when app.zon declares no web use. `web_engine = "system"`
1997
2050
  \\ /// alone is NOT web intent — it is the default in many canvas
@@ -2045,6 +2098,8 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
2045
2098
  \\ .webview_layer = parseWebLayer(raw.webview_layer) orelse @panic("app.zon .webview_layer must be \"auto\", \"include\", or \"exclude\""),
2046
2099
  \\ .microphone_permission = hasManifestPermission(raw.permissions, "microphone"),
2047
2100
  \\ .system_audio_permission = hasManifestPermission(raw.permissions, "system_audio"),
2101
+ \\ .sqlite_capability = hasManifestCapability(raw.capabilities, "store") or hasManifestCapability(raw.capabilities, "sqlite"),
2102
+ \\ .relational_capability = hasManifestCapability(raw.capabilities, "sqlite"),
2048
2103
  \\ };
2049
2104
  \\ config.web_declaration = blk: {
2050
2105
  \\ if (raw.frontend != null) break :blk "a .frontend block";
@@ -2068,6 +2123,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
2068
2123
  \\ return false;
2069
2124
  \\}
2070
2125
  \\
2126
+ \\fn hasManifestCapability(capabilities: []const []const u8, name: []const u8) bool {
2127
+ \\ for (capabilities) |capability| {
2128
+ \\ if (std.mem.eql(u8, capability, name)) return true;
2129
+ \\ }
2130
+ \\ return false;
2131
+ \\}
2132
+ \\
2071
2133
  \\/// The web-layer decision for this build — the same declare-to-use
2072
2134
  \\/// contract the Native SDK's standard build graph, CLI, and runner
2073
2135
  \\/// apply: an app is WEB when app.zon declares web use (a .frontend
@@ -2240,6 +2302,7 @@ fn runnerZig() []const u8 {
2240
2302
  \\const build_options = @import("build_options");
2241
2303
  \\const native_sdk = @import("native_sdk");
2242
2304
  \\const app_manifest = @import("app_manifest_zon");
2305
+ \\const built_relational_migrations = @import("relational_migrations");
2243
2306
  \\const manifest_commands = if (@hasField(@TypeOf(app_manifest), "commands")) app_manifest.commands else .{};
2244
2307
  \\const manifest_shortcuts = if (@hasField(@TypeOf(app_manifest), "shortcuts")) app_manifest.shortcuts else .{};
2245
2308
  \\const manifest_menus = if (@hasField(@TypeOf(app_manifest), "menus")) app_manifest.menus else .{};
@@ -2272,6 +2335,11 @@ fn runnerZig() []const u8 {
2272
2335
  \\ commands: ?[]const native_sdk.Command = null,
2273
2336
  \\ menus: ?[]const native_sdk.Menu = null,
2274
2337
  \\ shortcuts: ?[]const native_sdk.Shortcut = null,
2338
+ \\ record_store: ?native_sdk.RecordStoreBinding = null,
2339
+ \\ relational_store: ?native_sdk.RelationalStoreBinding = null,
2340
+ \\ file_access: ?native_sdk.FileAccessBinding = null,
2341
+ \\ file_access_enforce: bool = true,
2342
+ \\ relational_migrations: []const native_sdk.relational_store.Migration = &built_relational_migrations.migrations,
2275
2343
  \\
2276
2344
  \\ fn appInfo(self: RunOptions, buffers: *StateBuffers) native_sdk.AppInfo {
2277
2345
  \\ var info: native_sdk.AppInfo = .{
@@ -2302,6 +2370,7 @@ fn runnerZig() []const u8 {
2302
2370
  \\ info.main_window.always_on_top = manifestShellStartupBool("always_on_top", false);
2303
2371
  \\ info.main_window.click_through = manifestShellStartupBool("click_through", false);
2304
2372
  \\ info.main_window.activate_on_show = manifestShellStartupBool("activate_on_show", true);
2373
+ \\ info.main_window.allows_fullscreen = manifestShellStartupBool("allows_fullscreen", true);
2305
2374
  \\ // Min-size floors ride the create call like the titlebar:
2306
2375
  \\ // the scene re-applies size/title later, but the window's
2307
2376
  \\ // enforced floor is host state from the first frame on.
@@ -2434,10 +2503,12 @@ fn runnerZig() []const u8 {
2434
2503
  \\ .restore_state = windowBool(window, "restore_state", true),
2435
2504
  \\ .restore_policy = windowRestorePolicy(window),
2436
2505
  \\ .titlebar = windowTitlebarStyle(window),
2506
+ \\ .show = if (windowBool(window, "initially_hidden", false)) .hidden else .immediate,
2437
2507
  \\ .transparent = windowBool(window, "transparent", false),
2438
2508
  \\ .always_on_top = windowBool(window, "always_on_top", false),
2439
2509
  \\ .click_through = windowBool(window, "click_through", false),
2440
2510
  \\ .activate_on_show = windowBool(window, "activate_on_show", true),
2511
+ \\ .allows_fullscreen = windowBool(window, "allows_fullscreen", true),
2441
2512
  \\ .min_width = windowMinSize(window, "min_width"),
2442
2513
  \\ .min_height = windowMinSize(window, "min_height"),
2443
2514
  \\ .close_policy = windowClosePolicy(window),
@@ -2557,6 +2628,7 @@ fn runnerZig() []const u8 {
2557
2628
  \\ if (comptime !@hasField(@TypeOf(shell), "windows")) return .immediate;
2558
2629
  \\ if (comptime shell.windows.len == 0) return .immediate;
2559
2630
  \\ const window = shell.windows[0];
2631
+ \\ if (comptime windowBool(window, "initially_hidden", false)) return .hidden;
2560
2632
  \\ if (comptime !@hasField(@TypeOf(window), "views")) return .immediate;
2561
2633
  \\ inline for (window.views) |view| {
2562
2634
  \\ if (comptime @hasField(@TypeOf(view), "kind")) {
@@ -2602,6 +2674,24 @@ fn runnerZig() []const u8 {
2602
2674
  \\ return false;
2603
2675
  \\}
2604
2676
  \\
2677
+ \\fn manifestDeclaresStore() bool {
2678
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
2679
+ \\ inline for (app_manifest.capabilities) |capability| {
2680
+ \\ const name: []const u8 = capability;
2681
+ \\ if (comptime std.mem.eql(u8, name, "store")) return true;
2682
+ \\ }
2683
+ \\ return false;
2684
+ \\}
2685
+ \\
2686
+ \\fn manifestDeclaresSqlite() bool {
2687
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
2688
+ \\ inline for (app_manifest.capabilities) |capability| {
2689
+ \\ const name: []const u8 = capability;
2690
+ \\ if (comptime std.mem.eql(u8, name, "sqlite")) return true;
2691
+ \\ }
2692
+ \\ return false;
2693
+ \\}
2694
+ \\
2605
2695
  \\fn menuItem(comptime item: anytype) native_sdk.MenuItem {
2606
2696
  \\ return .{
2607
2697
  \\ .label = if (@hasField(@TypeOf(item), "label")) item.label else "",
@@ -2640,14 +2730,78 @@ fn runnerZig() []const u8 {
2640
2730
  \\ if (build_options.debug_overlay) {
2641
2731
  \\ std.debug.print("debug-overlay=true backend={s} web-engine={s} trace={s}\n", .{ build_options.platform, build_options.web_engine, build_options.trace });
2642
2732
  \\ }
2733
+ \\ const RecordStoreType = if (comptime manifestDeclaresStore()) native_sdk.RecordStore else void;
2734
+ \\ var record_store_value: RecordStoreType = undefined;
2735
+ \\ var record_store_open = false;
2736
+ \\ var resolved_options = options;
2737
+ \\ var file_root_buffers: [6][1024]u8 = undefined;
2738
+ \\ var file_roots: [6][]const u8 = undefined;
2739
+ \\ const resolved_file_dirs = native_sdk.app_dirs.resolve(
2740
+ \\ .{ .name = options.bundle_id },
2741
+ \\ native_sdk.app_dirs.currentPlatform(),
2742
+ \\ native_sdk.debug.envFromMap(init.environ_map),
2743
+ \\ native_sdk.app_dirs.Buffers.fromArray(1024, &file_root_buffers),
2744
+ \\ ) catch null;
2745
+ \\ var file_root_count: usize = 0;
2746
+ \\ if (resolved_file_dirs) |dirs| {
2747
+ \\ file_roots = .{ dirs.config, dirs.cache, dirs.data, dirs.state, dirs.logs, dirs.temp };
2748
+ \\ file_root_count = file_roots.len;
2749
+ \\ }
2750
+ \\ resolved_options.file_access = .{
2751
+ \\ .roots = file_roots[0..file_root_count],
2752
+ \\ .permitted = native_sdk.security.hasPermission(options.security.permissions, native_sdk.security.permission_filesystem),
2753
+ \\ .enforce = options.file_access_enforce,
2754
+ \\ };
2755
+ \\ if (comptime manifestDeclaresStore()) {
2756
+ \\ var data_dir_buffer: [512]u8 = undefined;
2757
+ \\ const app_data_dir = native_sdk.app_dirs.resolveOne(
2758
+ \\ .{ .name = options.bundle_id },
2759
+ \\ native_sdk.app_dirs.currentPlatform(),
2760
+ \\ native_sdk.debug.envFromMap(init.environ_map),
2761
+ \\ .data,
2762
+ \\ &data_dir_buffer,
2763
+ \\ ) catch return error.StoreDataDirUnavailable;
2764
+ \\ try std.Io.Dir.cwd().createDirPath(init.io, app_data_dir);
2765
+ \\ record_store_value = try native_sdk.RecordStore.open(std.heap.page_allocator, app_data_dir);
2766
+ \\ record_store_open = true;
2767
+ \\ resolved_options.record_store = record_store_value.binding();
2768
+ \\ }
2769
+ \\ defer if (comptime manifestDeclaresStore()) {
2770
+ \\ if (record_store_open) record_store_value.deinit();
2771
+ \\ };
2772
+ \\ const RelationalStoreType = if (comptime manifestDeclaresSqlite()) native_sdk.RelationalStore else void;
2773
+ \\ var relational_store_value: RelationalStoreType = undefined;
2774
+ \\ var relational_store_open = false;
2775
+ \\ if (comptime manifestDeclaresSqlite()) {
2776
+ \\ var data_dir_buffer: [512]u8 = undefined;
2777
+ \\ const app_data_dir = native_sdk.app_dirs.resolveOne(
2778
+ \\ .{ .name = options.bundle_id },
2779
+ \\ native_sdk.app_dirs.currentPlatform(),
2780
+ \\ native_sdk.debug.envFromMap(init.environ_map),
2781
+ \\ .data,
2782
+ \\ &data_dir_buffer,
2783
+ \\ ) catch return error.SqliteDataDirUnavailable;
2784
+ \\ try std.Io.Dir.cwd().createDirPath(init.io, app_data_dir);
2785
+ \\ const open_result = try native_sdk.RelationalStore.openMigrated(std.heap.page_allocator, app_data_dir, options.relational_migrations);
2786
+ \\ relational_store_value = switch (open_result.outcome) {
2787
+ \\ .ok => open_result.database.?,
2788
+ \\ .migrate_failed => return error.SqliteMigrationFailed,
2789
+ \\ .version_unknown => return error.SqliteVersionUnknown,
2790
+ \\ };
2791
+ \\ relational_store_open = true;
2792
+ \\ resolved_options.relational_store = relational_store_value.binding();
2793
+ \\ }
2794
+ \\ defer if (comptime manifestDeclaresSqlite()) {
2795
+ \\ if (relational_store_open) relational_store_value.deinit();
2796
+ \\ };
2643
2797
  \\ if (comptime std.mem.eql(u8, build_options.platform, "macos")) {
2644
- \\ try runMacos(app, options, init);
2798
+ \\ try runMacos(app, resolved_options, init);
2645
2799
  \\ } else if (comptime std.mem.eql(u8, build_options.platform, "linux")) {
2646
- \\ try runLinux(app, options, init);
2800
+ \\ try runLinux(app, resolved_options, init);
2647
2801
  \\ } else if (comptime std.mem.eql(u8, build_options.platform, "windows")) {
2648
- \\ try runWindows(app, options, init);
2802
+ \\ try runWindows(app, resolved_options, init);
2649
2803
  \\ } else {
2650
- \\ try runNull(app, options, init);
2804
+ \\ try runNull(app, resolved_options, init);
2651
2805
  \\ }
2652
2806
  \\}
2653
2807
  \\
@@ -2699,6 +2853,9 @@ fn runnerZig() []const u8 {
2699
2853
  \\ .shortcuts = shortcuts,
2700
2854
  \\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
2701
2855
  \\ .window_state_store = store,
2856
+ \\ .record_store = options.record_store,
2857
+ \\ .relational_store = options.relational_store,
2858
+ \\ .file_access = options.file_access,
2702
2859
  \\ .environ = init.minimal.environ,
2703
2860
  \\ });
2704
2861
  \\
@@ -2753,6 +2910,9 @@ fn runnerZig() []const u8 {
2753
2910
  \\ .shortcuts = shortcuts,
2754
2911
  \\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
2755
2912
  \\ .window_state_store = store,
2913
+ \\ .record_store = options.record_store,
2914
+ \\ .relational_store = options.relational_store,
2915
+ \\ .file_access = options.file_access,
2756
2916
  \\ .environ = init.minimal.environ,
2757
2917
  \\ });
2758
2918
  \\
@@ -2807,6 +2967,9 @@ fn runnerZig() []const u8 {
2807
2967
  \\ .shortcuts = shortcuts,
2808
2968
  \\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
2809
2969
  \\ .window_state_store = store,
2970
+ \\ .record_store = options.record_store,
2971
+ \\ .relational_store = options.relational_store,
2972
+ \\ .file_access = options.file_access,
2810
2973
  \\ .environ = init.minimal.environ,
2811
2974
  \\ });
2812
2975
  \\
@@ -2861,6 +3024,9 @@ fn runnerZig() []const u8 {
2861
3024
  \\ .shortcuts = shortcuts,
2862
3025
  \\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
2863
3026
  \\ .window_state_store = store,
3027
+ \\ .record_store = options.record_store,
3028
+ \\ .relational_store = options.relational_store,
3029
+ \\ .file_access = options.file_access,
2864
3030
  \\ .environ = init.minimal.environ,
2865
3031
  \\ });
2866
3032
  \\
@@ -3872,6 +4038,13 @@ test "writeDefaultApp emits Vite project files" {
3872
4038
  // as the managed graph (for both dev and the separately optimized exe).
3873
4039
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "permissions: []const []const u8") != null);
3874
4040
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "hasManifestPermission(raw.permissions, \"microphone\")") != null);
4041
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "hasManifestCapability(raw.capabilities, \"store\")") != null);
4042
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "addSqliteEngine(b, app_mod, native_sdk_path)") != null);
4043
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "sqliteMigrationsSource(b, native_sdk_path)") != null);
4044
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "sqlite_runtime_policy.ts") != null);
4045
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "addAppSqlDirInputs(b, generate, \"src\")") != null);
4046
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "run.addFileInput(b.path(b.fmt") != null);
4047
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "runner_mod.addImport(\"relational_migrations\", migrations_mod)") != null);
3875
4048
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSMicrophoneUsageDescription") != null);
3876
4049
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSAudioCaptureUsageDescription") != null);
3877
4050
  try std.testing.expect(std.mem.count(u8, build_zig_text, "addMacosPrivacyInfoPlist(b, ") == 2);
@@ -3920,11 +4093,23 @@ test "writeDefaultApp emits Vite project files" {
3920
4093
  try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "frontend/dist") != null);
3921
4094
  try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "127.0.0.1:5173") != null);
3922
4095
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@import(\"app_manifest_zon\")") != null);
4096
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@import(\"relational_migrations\")") != null);
4097
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "RelationalStore.openMigrated") != null);
3923
4098
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "commands: ?[]const native_sdk.Command = null") != null);
3924
4099
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedCommands") != null);
3925
4100
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "menus: ?[]const native_sdk.Menu = null") != null);
3926
4101
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedMenus") != null);
3927
4102
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "shortcuts: ?[]const native_sdk.Shortcut = null") != null);
4103
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "record_store: ?native_sdk.RecordStoreBinding = null") != null);
4104
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresStore()") != null);
4105
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".record_store = options.record_store") != null);
4106
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "relational_store: ?native_sdk.RelationalStoreBinding = null") != null);
4107
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresSqlite()") != null);
4108
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".relational_store = options.relational_store") != null);
4109
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "file_access: ?native_sdk.FileAccessBinding = null") != null);
4110
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "file_access_enforce: bool = true") != null);
4111
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "native_sdk.app_dirs.Buffers.fromArray") != null);
4112
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".file_access = options.file_access") != null);
3928
4113
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedShortcuts") != null);
3929
4114
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "const manifest_windows") != null);
3930
4115
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn appInfo(self: RunOptions, buffers: *StateBuffers)") != null);