@native-sdk/cli 0.8.4 → 0.9.0
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.
- package/build/app.zig +859 -62
- package/build.zig +543 -13
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +2 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +365 -2
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +149 -0
- package/packages/core/sdk/core.ts +529 -12
- package/packages/core/sdk/events.d.ts +36 -0
- package/packages/core/sdk/events.ts +57 -0
- package/packages/core/src/checker.ts +468 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1847 -16
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +82 -16
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +47 -0
- package/skill-data/ts-core/SKILL.md +80 -31
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +249 -8
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +109 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +119 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +40 -18
- package/src/platform/macos/appkit_host.h +16 -3
- package/src/platform/macos/appkit_host.m +536 -36
- package/src/platform/macos/cef_host.mm +248 -36
- package/src/platform/macos/root.zig +244 -34
- package/src/platform/null_platform.zig +223 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +179 -15
- package/src/platform/windows/root.zig +187 -21
- package/src/platform/windows/webview2_host.cpp +293 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/root.zig +46 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +18 -11
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2295 -113
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +49 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +4 -0
- package/src/runtime/ts_core_host.zig +788 -86
- package/src/runtime/ts_core_host_tests.zig +231 -11
- package/src/runtime/ts_ui_app.zig +499 -1
- package/src/runtime/ui_app.zig +142 -16
- package/src/runtime/ui_app_tests.zig +155 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +9 -0
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +214 -2
- package/src/tooling/package.zig +116 -0
- package/src/tooling/raw_manifest.zig +30 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +161 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +378 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
package/src/tooling/package.zig
CHANGED
|
@@ -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",
|
package/src/tooling/root.zig
CHANGED
|
@@ -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,9 @@ 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
|
+
\\ relational_migrations: []const native_sdk.relational_store.Migration = &built_relational_migrations.migrations,
|
|
2275
2341
|
\\
|
|
2276
2342
|
\\ fn appInfo(self: RunOptions, buffers: *StateBuffers) native_sdk.AppInfo {
|
|
2277
2343
|
\\ var info: native_sdk.AppInfo = .{
|
|
@@ -2302,6 +2368,7 @@ fn runnerZig() []const u8 {
|
|
|
2302
2368
|
\\ info.main_window.always_on_top = manifestShellStartupBool("always_on_top", false);
|
|
2303
2369
|
\\ info.main_window.click_through = manifestShellStartupBool("click_through", false);
|
|
2304
2370
|
\\ info.main_window.activate_on_show = manifestShellStartupBool("activate_on_show", true);
|
|
2371
|
+
\\ info.main_window.allows_fullscreen = manifestShellStartupBool("allows_fullscreen", true);
|
|
2305
2372
|
\\ // Min-size floors ride the create call like the titlebar:
|
|
2306
2373
|
\\ // the scene re-applies size/title later, but the window's
|
|
2307
2374
|
\\ // enforced floor is host state from the first frame on.
|
|
@@ -2434,10 +2501,12 @@ fn runnerZig() []const u8 {
|
|
|
2434
2501
|
\\ .restore_state = windowBool(window, "restore_state", true),
|
|
2435
2502
|
\\ .restore_policy = windowRestorePolicy(window),
|
|
2436
2503
|
\\ .titlebar = windowTitlebarStyle(window),
|
|
2504
|
+
\\ .show = if (windowBool(window, "initially_hidden", false)) .hidden else .immediate,
|
|
2437
2505
|
\\ .transparent = windowBool(window, "transparent", false),
|
|
2438
2506
|
\\ .always_on_top = windowBool(window, "always_on_top", false),
|
|
2439
2507
|
\\ .click_through = windowBool(window, "click_through", false),
|
|
2440
2508
|
\\ .activate_on_show = windowBool(window, "activate_on_show", true),
|
|
2509
|
+
\\ .allows_fullscreen = windowBool(window, "allows_fullscreen", true),
|
|
2441
2510
|
\\ .min_width = windowMinSize(window, "min_width"),
|
|
2442
2511
|
\\ .min_height = windowMinSize(window, "min_height"),
|
|
2443
2512
|
\\ .close_policy = windowClosePolicy(window),
|
|
@@ -2557,6 +2626,7 @@ fn runnerZig() []const u8 {
|
|
|
2557
2626
|
\\ if (comptime !@hasField(@TypeOf(shell), "windows")) return .immediate;
|
|
2558
2627
|
\\ if (comptime shell.windows.len == 0) return .immediate;
|
|
2559
2628
|
\\ const window = shell.windows[0];
|
|
2629
|
+
\\ if (comptime windowBool(window, "initially_hidden", false)) return .hidden;
|
|
2560
2630
|
\\ if (comptime !@hasField(@TypeOf(window), "views")) return .immediate;
|
|
2561
2631
|
\\ inline for (window.views) |view| {
|
|
2562
2632
|
\\ if (comptime @hasField(@TypeOf(view), "kind")) {
|
|
@@ -2602,6 +2672,24 @@ fn runnerZig() []const u8 {
|
|
|
2602
2672
|
\\ return false;
|
|
2603
2673
|
\\}
|
|
2604
2674
|
\\
|
|
2675
|
+
\\fn manifestDeclaresStore() bool {
|
|
2676
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
|
|
2677
|
+
\\ inline for (app_manifest.capabilities) |capability| {
|
|
2678
|
+
\\ const name: []const u8 = capability;
|
|
2679
|
+
\\ if (comptime std.mem.eql(u8, name, "store")) return true;
|
|
2680
|
+
\\ }
|
|
2681
|
+
\\ return false;
|
|
2682
|
+
\\}
|
|
2683
|
+
\\
|
|
2684
|
+
\\fn manifestDeclaresSqlite() bool {
|
|
2685
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
|
|
2686
|
+
\\ inline for (app_manifest.capabilities) |capability| {
|
|
2687
|
+
\\ const name: []const u8 = capability;
|
|
2688
|
+
\\ if (comptime std.mem.eql(u8, name, "sqlite")) return true;
|
|
2689
|
+
\\ }
|
|
2690
|
+
\\ return false;
|
|
2691
|
+
\\}
|
|
2692
|
+
\\
|
|
2605
2693
|
\\fn menuItem(comptime item: anytype) native_sdk.MenuItem {
|
|
2606
2694
|
\\ return .{
|
|
2607
2695
|
\\ .label = if (@hasField(@TypeOf(item), "label")) item.label else "",
|
|
@@ -2640,14 +2728,60 @@ fn runnerZig() []const u8 {
|
|
|
2640
2728
|
\\ if (build_options.debug_overlay) {
|
|
2641
2729
|
\\ 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
2730
|
\\ }
|
|
2731
|
+
\\ const RecordStoreType = if (comptime manifestDeclaresStore()) native_sdk.RecordStore else void;
|
|
2732
|
+
\\ var record_store_value: RecordStoreType = undefined;
|
|
2733
|
+
\\ var record_store_open = false;
|
|
2734
|
+
\\ var resolved_options = options;
|
|
2735
|
+
\\ if (comptime manifestDeclaresStore()) {
|
|
2736
|
+
\\ var data_dir_buffer: [512]u8 = undefined;
|
|
2737
|
+
\\ const app_data_dir = native_sdk.app_dirs.resolveOne(
|
|
2738
|
+
\\ .{ .name = options.bundle_id },
|
|
2739
|
+
\\ native_sdk.app_dirs.currentPlatform(),
|
|
2740
|
+
\\ native_sdk.debug.envFromMap(init.environ_map),
|
|
2741
|
+
\\ .data,
|
|
2742
|
+
\\ &data_dir_buffer,
|
|
2743
|
+
\\ ) catch return error.StoreDataDirUnavailable;
|
|
2744
|
+
\\ try std.Io.Dir.cwd().createDirPath(init.io, app_data_dir);
|
|
2745
|
+
\\ record_store_value = try native_sdk.RecordStore.open(std.heap.page_allocator, app_data_dir);
|
|
2746
|
+
\\ record_store_open = true;
|
|
2747
|
+
\\ resolved_options.record_store = record_store_value.binding();
|
|
2748
|
+
\\ }
|
|
2749
|
+
\\ defer if (comptime manifestDeclaresStore()) {
|
|
2750
|
+
\\ if (record_store_open) record_store_value.deinit();
|
|
2751
|
+
\\ };
|
|
2752
|
+
\\ const RelationalStoreType = if (comptime manifestDeclaresSqlite()) native_sdk.RelationalStore else void;
|
|
2753
|
+
\\ var relational_store_value: RelationalStoreType = undefined;
|
|
2754
|
+
\\ var relational_store_open = false;
|
|
2755
|
+
\\ if (comptime manifestDeclaresSqlite()) {
|
|
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.SqliteDataDirUnavailable;
|
|
2764
|
+
\\ try std.Io.Dir.cwd().createDirPath(init.io, app_data_dir);
|
|
2765
|
+
\\ const open_result = try native_sdk.RelationalStore.openMigrated(std.heap.page_allocator, app_data_dir, options.relational_migrations);
|
|
2766
|
+
\\ relational_store_value = switch (open_result.outcome) {
|
|
2767
|
+
\\ .ok => open_result.database.?,
|
|
2768
|
+
\\ .migrate_failed => return error.SqliteMigrationFailed,
|
|
2769
|
+
\\ .version_unknown => return error.SqliteVersionUnknown,
|
|
2770
|
+
\\ };
|
|
2771
|
+
\\ relational_store_open = true;
|
|
2772
|
+
\\ resolved_options.relational_store = relational_store_value.binding();
|
|
2773
|
+
\\ }
|
|
2774
|
+
\\ defer if (comptime manifestDeclaresSqlite()) {
|
|
2775
|
+
\\ if (relational_store_open) relational_store_value.deinit();
|
|
2776
|
+
\\ };
|
|
2643
2777
|
\\ if (comptime std.mem.eql(u8, build_options.platform, "macos")) {
|
|
2644
|
-
\\ try runMacos(app,
|
|
2778
|
+
\\ try runMacos(app, resolved_options, init);
|
|
2645
2779
|
\\ } else if (comptime std.mem.eql(u8, build_options.platform, "linux")) {
|
|
2646
|
-
\\ try runLinux(app,
|
|
2780
|
+
\\ try runLinux(app, resolved_options, init);
|
|
2647
2781
|
\\ } else if (comptime std.mem.eql(u8, build_options.platform, "windows")) {
|
|
2648
|
-
\\ try runWindows(app,
|
|
2782
|
+
\\ try runWindows(app, resolved_options, init);
|
|
2649
2783
|
\\ } else {
|
|
2650
|
-
\\ try runNull(app,
|
|
2784
|
+
\\ try runNull(app, resolved_options, init);
|
|
2651
2785
|
\\ }
|
|
2652
2786
|
\\}
|
|
2653
2787
|
\\
|
|
@@ -2699,6 +2833,8 @@ fn runnerZig() []const u8 {
|
|
|
2699
2833
|
\\ .shortcuts = shortcuts,
|
|
2700
2834
|
\\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
|
|
2701
2835
|
\\ .window_state_store = store,
|
|
2836
|
+
\\ .record_store = options.record_store,
|
|
2837
|
+
\\ .relational_store = options.relational_store,
|
|
2702
2838
|
\\ .environ = init.minimal.environ,
|
|
2703
2839
|
\\ });
|
|
2704
2840
|
\\
|
|
@@ -2753,6 +2889,8 @@ fn runnerZig() []const u8 {
|
|
|
2753
2889
|
\\ .shortcuts = shortcuts,
|
|
2754
2890
|
\\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
|
|
2755
2891
|
\\ .window_state_store = store,
|
|
2892
|
+
\\ .record_store = options.record_store,
|
|
2893
|
+
\\ .relational_store = options.relational_store,
|
|
2756
2894
|
\\ .environ = init.minimal.environ,
|
|
2757
2895
|
\\ });
|
|
2758
2896
|
\\
|
|
@@ -2807,6 +2945,8 @@ fn runnerZig() []const u8 {
|
|
|
2807
2945
|
\\ .shortcuts = shortcuts,
|
|
2808
2946
|
\\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
|
|
2809
2947
|
\\ .window_state_store = store,
|
|
2948
|
+
\\ .record_store = options.record_store,
|
|
2949
|
+
\\ .relational_store = options.relational_store,
|
|
2810
2950
|
\\ .environ = init.minimal.environ,
|
|
2811
2951
|
\\ });
|
|
2812
2952
|
\\
|
|
@@ -2861,6 +3001,8 @@ fn runnerZig() []const u8 {
|
|
|
2861
3001
|
\\ .shortcuts = shortcuts,
|
|
2862
3002
|
\\ .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
|
|
2863
3003
|
\\ .window_state_store = store,
|
|
3004
|
+
\\ .record_store = options.record_store,
|
|
3005
|
+
\\ .relational_store = options.relational_store,
|
|
2864
3006
|
\\ .environ = init.minimal.environ,
|
|
2865
3007
|
\\ });
|
|
2866
3008
|
\\
|
|
@@ -3872,6 +4014,13 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
3872
4014
|
// as the managed graph (for both dev and the separately optimized exe).
|
|
3873
4015
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "permissions: []const []const u8") != null);
|
|
3874
4016
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "hasManifestPermission(raw.permissions, \"microphone\")") != null);
|
|
4017
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "hasManifestCapability(raw.capabilities, \"store\")") != null);
|
|
4018
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "addSqliteEngine(b, app_mod, native_sdk_path)") != null);
|
|
4019
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "sqliteMigrationsSource(b, native_sdk_path)") != null);
|
|
4020
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "sqlite_runtime_policy.ts") != null);
|
|
4021
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "addAppSqlDirInputs(b, generate, \"src\")") != null);
|
|
4022
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "run.addFileInput(b.path(b.fmt") != null);
|
|
4023
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "runner_mod.addImport(\"relational_migrations\", migrations_mod)") != null);
|
|
3875
4024
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSMicrophoneUsageDescription") != null);
|
|
3876
4025
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSAudioCaptureUsageDescription") != null);
|
|
3877
4026
|
try std.testing.expect(std.mem.count(u8, build_zig_text, "addMacosPrivacyInfoPlist(b, ") == 2);
|
|
@@ -3920,11 +4069,19 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
3920
4069
|
try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "frontend/dist") != null);
|
|
3921
4070
|
try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "127.0.0.1:5173") != null);
|
|
3922
4071
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@import(\"app_manifest_zon\")") != null);
|
|
4072
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@import(\"relational_migrations\")") != null);
|
|
4073
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "RelationalStore.openMigrated") != null);
|
|
3923
4074
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "commands: ?[]const native_sdk.Command = null") != null);
|
|
3924
4075
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedCommands") != null);
|
|
3925
4076
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "menus: ?[]const native_sdk.Menu = null") != null);
|
|
3926
4077
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedMenus") != null);
|
|
3927
4078
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "shortcuts: ?[]const native_sdk.Shortcut = null") != null);
|
|
4079
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "record_store: ?native_sdk.RecordStoreBinding = null") != null);
|
|
4080
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresStore()") != null);
|
|
4081
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".record_store = options.record_store") != null);
|
|
4082
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "relational_store: ?native_sdk.RelationalStoreBinding = null") != null);
|
|
4083
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresSqlite()") != null);
|
|
4084
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".relational_store = options.relational_store") != null);
|
|
3928
4085
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedShortcuts") != null);
|
|
3929
4086
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "const manifest_windows") != null);
|
|
3930
4087
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn appInfo(self: RunOptions, buffers: *StateBuffers)") != null);
|