@native-sdk/cli 0.9.4 → 0.10.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/README.md +3 -3
- package/build/app.zig +75 -57
- package/build/ts_run.mjs +1 -1
- package/build.zig +20 -2
- package/package.json +11 -10
- package/packages/core/package-lock.json +12 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_command.mjs +1 -1
- package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
- package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
- package/packages/core/scripts/vendor_service_packages.mjs +121 -8
- package/packages/core/sdk/events.d.ts +33 -4
- package/packages/core/sdk/events.ts +45 -6
- package/packages/core/src/checker.ts +103 -8
- package/packages/core/src/modules.ts +6 -2
- package/packages/core/src/sqlite_cli.ts +22 -2
- package/packages/core/src/typed_ast.ts +4 -2
- package/packages/core/src/types.ts +8 -8
- package/schemas/app.schema.json +446 -0
- package/skill-data/core/SKILL.md +53 -15
- package/skill-data/core/references/project-anatomy.md +6 -6
- package/skill-data/native-ui/SKILL.md +26 -5
- package/skill-data/ts-core/SKILL.md +6 -6
- package/skill-data/ts-services/references/service-surface.md +1 -1
- package/skills/native-sdk/SKILL.md +2 -2
- package/src/app_runner/root.zig +25 -0
- package/src/automation/snapshot.zig +91 -3
- package/src/platform/macos/appkit_host.h +66 -2
- package/src/platform/macos/appkit_host.m +735 -24
- package/src/platform/macos/cef_host.mm +208 -9
- package/src/platform/macos/root.zig +205 -3
- package/src/platform/null_platform.zig +50 -1
- package/src/platform/null_platform_tests.zig +53 -0
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +73 -0
- package/src/platform/windows/root.zig +88 -15
- package/src/primitives/app_manifest/tests.zig +19 -0
- package/src/primitives/app_manifest/validation.zig +14 -2
- package/src/primitives/canvas/font_ttf.zig +24 -0
- package/src/primitives/canvas/gpu.zig +5 -0
- package/src/primitives/canvas/reference.zig +41 -16
- package/src/primitives/canvas/reference_tests.zig +63 -0
- package/src/primitives/canvas/render_tests.zig +1 -1
- package/src/primitives/canvas/root.zig +1 -0
- package/src/primitives/canvas/serialization.zig +1 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_layout.zig +84 -15
- package/src/primitives/canvas/text_layout_hash.zig +3 -1
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_metrics.zig +28 -1
- package/src/primitives/canvas/text_tests.zig +61 -6
- package/src/primitives/canvas/ui.zig +9 -0
- package/src/primitives/canvas/ui_markup.zig +29 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
- package/src/primitives/canvas/ui_markup_contract.zig +7 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
- package/src/primitives/canvas/ui_markup_tests.zig +6 -0
- package/src/primitives/canvas/ui_markup_view.zig +28 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
- package/src/primitives/canvas/ui_schema.zig +9 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +4 -2
- package/src/primitives/canvas/widget_render.zig +13 -2
- package/src/primitives/canvas/widget_render_controls.zig +1 -0
- package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
- package/src/root.zig +6 -0
- package/src/runtime/automation_snapshot.zig +3 -0
- package/src/runtime/canvas_fonts.zig +87 -0
- package/src/runtime/core.zig +1 -0
- package/src/runtime/flow.zig +8 -1
- package/src/runtime/native_command_event_tests.zig +58 -0
- package/src/runtime/state.zig +14 -0
- package/src/runtime/system_services.zig +62 -0
- package/src/runtime/ts_ui_app.zig +161 -33
- package/src/runtime/ui_app.zig +33 -1
- package/src/runtime/ui_app_tests.zig +63 -0
- package/src/runtime/validation.zig +87 -1
- package/src/tooling/android.zig +5 -4
- package/src/tooling/buildgraph.zig +24 -8
- package/src/tooling/db.zig +1 -1
- package/src/tooling/doctor.zig +1 -1
- package/src/tooling/ios.zig +5 -4
- package/src/tooling/json_to_zon.zig +136 -0
- package/src/tooling/manifest.zig +199 -35
- package/src/tooling/package.zig +33 -0
- package/src/tooling/raw_manifest.zig +11 -0
- package/src/tooling/root.zig +2 -0
- package/src/tooling/templates.zig +210 -116
- package/src/tooling/ts_core.zig +11 -7
- package/src/tooling/update.zig +576 -0
- package/src/tooling/verbs.zig +7 -6
- package/src/tooling/web_engine.zig +17 -1
- package/src/updater/c_api.zig +123 -0
- package/src/updater/feed.zig +215 -0
- package/src/updater/root.zig +10 -0
|
@@ -54,7 +54,7 @@ pub const Frontend = enum {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
/// Scaffold shape for the native frontend. `slim` is the zero-config
|
|
57
|
-
/// default: app.
|
|
57
|
+
/// default: app.json + src/ + assets + README only — the `native` CLI owns
|
|
58
58
|
/// the build graph (`native dev|build|test`) and `native eject` writes an
|
|
59
59
|
/// owned build.zig later. `full` keeps the pre-zero-config shape
|
|
60
60
|
/// (build.zig, build.zig.zon, .vscode, CI workflow) for users who want to
|
|
@@ -132,8 +132,8 @@ pub fn writeDefaultApp(allocator: std.mem.Allocator, io: std.Io, destination: []
|
|
|
132
132
|
defer allocator.free(build_zon);
|
|
133
133
|
const main_zig = try mainZig(allocator, names, options.frontend);
|
|
134
134
|
defer allocator.free(main_zig);
|
|
135
|
-
const
|
|
136
|
-
defer allocator.free(
|
|
135
|
+
const app_json = try appJson(allocator, names, options.frontend);
|
|
136
|
+
defer allocator.free(app_json);
|
|
137
137
|
const readme_md = try readme(allocator, names, framework_path, options.frontend);
|
|
138
138
|
defer allocator.free(readme_md);
|
|
139
139
|
const ci_yaml = try frontendCiYaml(allocator, names);
|
|
@@ -144,7 +144,7 @@ pub fn writeDefaultApp(allocator: std.mem.Allocator, io: std.Io, destination: []
|
|
|
144
144
|
try writeFile(app_dir, io, "build.zig.zon", build_zon);
|
|
145
145
|
try writeFile(app_dir, io, "src/main.zig", main_zig);
|
|
146
146
|
try writeFile(app_dir, io, "src/runner.zig", runnerZig());
|
|
147
|
-
try writeFile(app_dir, io, "app.
|
|
147
|
+
try writeFile(app_dir, io, "app.json", app_json);
|
|
148
148
|
try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
|
|
149
149
|
try writeFile(app_dir, io, ".github/workflows/ci.yml", ci_yaml);
|
|
150
150
|
try writeFile(app_dir, io, "README.md", readme_md);
|
|
@@ -159,15 +159,15 @@ fn writeNativeAppSlim(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.
|
|
|
159
159
|
defer allocator.free(main_zig);
|
|
160
160
|
const tests_zig = try nativeTestsZig(allocator, names);
|
|
161
161
|
defer allocator.free(tests_zig);
|
|
162
|
-
const
|
|
163
|
-
defer allocator.free(
|
|
162
|
+
const app_json = try nativeAppJson(allocator, names);
|
|
163
|
+
defer allocator.free(app_json);
|
|
164
164
|
const readme_md = try slimNativeReadme(allocator, names);
|
|
165
165
|
defer allocator.free(readme_md);
|
|
166
166
|
|
|
167
167
|
try writeFile(app_dir, io, "src/main.zig", main_zig);
|
|
168
168
|
try writeFile(app_dir, io, "src/app.native", nativeAppMarkup());
|
|
169
169
|
try writeFile(app_dir, io, "src/tests.zig", tests_zig);
|
|
170
|
-
try writeFile(app_dir, io, "app.
|
|
170
|
+
try writeFile(app_dir, io, "app.json", app_json);
|
|
171
171
|
try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
|
|
172
172
|
try writeFile(app_dir, io, ".gitignore", slimGitignore());
|
|
173
173
|
try writeFile(app_dir, io, "README.md", readme_md);
|
|
@@ -183,7 +183,7 @@ fn slimGitignore() []const u8 {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/// The TypeScript-core zero-config scaffold - the `native init` default:
|
|
186
|
-
/// core.ts (logic), app.native (view), app.
|
|
186
|
+
/// core.ts (logic), app.native (view), app.json (manifest). ZERO Zig in the
|
|
187
187
|
/// tree; the build graph detects src/core.ts, compiles it through the
|
|
188
188
|
/// external core compiler, and stages the generated wiring outside the app
|
|
189
189
|
/// on every build.
|
|
@@ -195,14 +195,14 @@ fn slimGitignore() []const u8 {
|
|
|
195
195
|
/// detection above keys on src/core.ts alone, and every `native` verb
|
|
196
196
|
/// works with node_modules deleted.
|
|
197
197
|
fn writeTsAppSlim(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir, names: TemplateNames, destination: []const u8, sdk_source: []const u8) !void {
|
|
198
|
-
const
|
|
199
|
-
defer allocator.free(
|
|
198
|
+
const app_json = try nativeAppJson(allocator, names);
|
|
199
|
+
defer allocator.free(app_json);
|
|
200
200
|
const readme_md = try tsSlimReadme(allocator, names);
|
|
201
201
|
defer allocator.free(readme_md);
|
|
202
202
|
|
|
203
203
|
try writeFile(app_dir, io, "src/core.ts", tsCoreStarter());
|
|
204
204
|
try writeFile(app_dir, io, "src/app.native", tsAppMarkup());
|
|
205
|
-
try writeFile(app_dir, io, "app.
|
|
205
|
+
try writeFile(app_dir, io, "app.json", app_json);
|
|
206
206
|
try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
|
|
207
207
|
try writeFile(app_dir, io, ".gitignore", tsGitignore());
|
|
208
208
|
try writeFile(app_dir, io, "README.md", readme_md);
|
|
@@ -218,8 +218,8 @@ fn writeTsApp(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir, nam
|
|
|
218
218
|
defer allocator.free(build_zig);
|
|
219
219
|
const build_zon = try nativeBuildZon(allocator, names, framework_path);
|
|
220
220
|
defer allocator.free(build_zon);
|
|
221
|
-
const
|
|
222
|
-
defer allocator.free(
|
|
221
|
+
const app_json = try nativeAppJson(allocator, names);
|
|
222
|
+
defer allocator.free(app_json);
|
|
223
223
|
const readme_md = try tsSlimReadme(allocator, names);
|
|
224
224
|
defer allocator.free(readme_md);
|
|
225
225
|
const ci_yaml = try nativeCiYaml(allocator, names, framework_path, .ts);
|
|
@@ -231,7 +231,7 @@ fn writeTsApp(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir, nam
|
|
|
231
231
|
try writeFile(app_dir, io, "build.zig.zon", build_zon);
|
|
232
232
|
try writeFile(app_dir, io, "src/core.ts", tsCoreStarter());
|
|
233
233
|
try writeFile(app_dir, io, "src/app.native", tsAppMarkup());
|
|
234
|
-
try writeFile(app_dir, io, "app.
|
|
234
|
+
try writeFile(app_dir, io, "app.json", app_json);
|
|
235
235
|
try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
|
|
236
236
|
try writeFile(app_dir, io, ".gitignore", tsGitignore());
|
|
237
237
|
try writeFile(app_dir, io, "README.md", readme_md);
|
|
@@ -472,13 +472,13 @@ fn tsSlimReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
|
|
|
472
472
|
\\ # dispatch messages as JSON lines, watch the model
|
|
473
473
|
\\ # and effect transcript (not a renderer)
|
|
474
474
|
\\native dev # build and run the real app (markup hot reload)
|
|
475
|
-
\\native check # verify core.ts (subset checker) + markup + app.
|
|
475
|
+
\\native check # verify core.ts (subset checker) + markup + app.json
|
|
476
476
|
\\native build # ReleaseFast binary in zig-out/bin/
|
|
477
477
|
\\native test # the app's test suite
|
|
478
478
|
\\```
|
|
479
479
|
\\
|
|
480
480
|
\\Edit `src/core.ts` for behavior, `src/app.native` for the view, and
|
|
481
|
-
\\`app.
|
|
481
|
+
\\`app.json` for windows/identity/permissions. Markup binds the model's
|
|
482
482
|
\\field names exactly as core.ts wrote them (`tickCount` -> `{tickCount}`),
|
|
483
483
|
\\and exported single-model helpers bind as derived values (`{total}`).
|
|
484
484
|
\\
|
|
@@ -530,7 +530,7 @@ fn slimNativeReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const
|
|
|
530
530
|
\\native dev # build and run the app with hot reload
|
|
531
531
|
\\native test # run the app's test suite
|
|
532
532
|
\\native build # produce a ReleaseFast binary in zig-out/bin/
|
|
533
|
-
\\native check # validate src/*.native markup and app.
|
|
533
|
+
\\native check # validate src/*.native markup and app.json
|
|
534
534
|
\\```
|
|
535
535
|
\\
|
|
536
536
|
\\## Hot reload
|
|
@@ -561,8 +561,8 @@ fn writeNativeApp(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir,
|
|
|
561
561
|
defer allocator.free(main_zig);
|
|
562
562
|
const tests_zig = try nativeTestsZig(allocator, names);
|
|
563
563
|
defer allocator.free(tests_zig);
|
|
564
|
-
const
|
|
565
|
-
defer allocator.free(
|
|
564
|
+
const app_json = try nativeAppJson(allocator, names);
|
|
565
|
+
defer allocator.free(app_json);
|
|
566
566
|
const readme_md = try nativeReadme(allocator, names, framework_path);
|
|
567
567
|
defer allocator.free(readme_md);
|
|
568
568
|
const ci_yaml = try nativeCiYaml(allocator, names, framework_path, .zig);
|
|
@@ -573,7 +573,7 @@ fn writeNativeApp(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir,
|
|
|
573
573
|
try writeFile(app_dir, io, "src/main.zig", main_zig);
|
|
574
574
|
try writeFile(app_dir, io, "src/app.native", nativeAppMarkup());
|
|
575
575
|
try writeFile(app_dir, io, "src/tests.zig", tests_zig);
|
|
576
|
-
try writeFile(app_dir, io, "app.
|
|
576
|
+
try writeFile(app_dir, io, "app.json", app_json);
|
|
577
577
|
try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
|
|
578
578
|
try writeFile(app_dir, io, ".vscode/settings.json", nativeVscodeSettings());
|
|
579
579
|
try writeFile(app_dir, io, ".github/workflows/ci.yml", ci_yaml);
|
|
@@ -594,7 +594,7 @@ fn nativeBuildZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u
|
|
|
594
594
|
try out.appendSlice(allocator, " ");
|
|
595
595
|
try appendZigString(&out, allocator, names.package_name);
|
|
596
596
|
try out.appendSlice(allocator,
|
|
597
|
-
|
|
597
|
+
\\, .manifest = "app.json" });
|
|
598
598
|
\\}
|
|
599
599
|
\\
|
|
600
600
|
);
|
|
@@ -626,7 +626,7 @@ fn nativeBuildZon(allocator: std.mem.Allocator, names: TemplateNames, framework_
|
|
|
626
626
|
try appendZigString(&out, allocator, framework_path);
|
|
627
627
|
try out.appendSlice(allocator,
|
|
628
628
|
\\ } },
|
|
629
|
-
\\ .paths = .{ "build.zig", "build.zig.zon", "src", "assets", "app.
|
|
629
|
+
\\ .paths = .{ "build.zig", "build.zig.zon", "src", "assets", "app.json", "README.md" },
|
|
630
630
|
\\}
|
|
631
631
|
\\
|
|
632
632
|
);
|
|
@@ -1023,61 +1023,62 @@ fn nativeTestsZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u
|
|
|
1023
1023
|
return out.toOwnedSlice(allocator);
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
-
fn
|
|
1026
|
+
fn nativeAppJson(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8 {
|
|
1027
1027
|
var out: std.ArrayList(u8) = .empty;
|
|
1028
1028
|
errdefer out.deinit(allocator);
|
|
1029
1029
|
try out.appendSlice(allocator,
|
|
1030
|
-
|
|
1031
|
-
\\ .
|
|
1030
|
+
\\{
|
|
1031
|
+
\\ "$schema": "https://schema.native-sdk.dev/app/v1.json",
|
|
1032
|
+
\\ "id":
|
|
1032
1033
|
);
|
|
1033
1034
|
try out.appendSlice(allocator, " ");
|
|
1034
|
-
try
|
|
1035
|
+
try appendJsonString(&out, allocator, names.app_id);
|
|
1035
1036
|
try out.appendSlice(allocator,
|
|
1036
1037
|
\\,
|
|
1037
|
-
\\
|
|
1038
|
+
\\ "name":
|
|
1038
1039
|
);
|
|
1039
1040
|
try out.appendSlice(allocator, " ");
|
|
1040
|
-
try
|
|
1041
|
+
try appendJsonString(&out, allocator, names.package_name);
|
|
1041
1042
|
try out.appendSlice(allocator,
|
|
1042
1043
|
\\,
|
|
1043
|
-
\\
|
|
1044
|
+
\\ "display_name":
|
|
1044
1045
|
);
|
|
1045
1046
|
try out.appendSlice(allocator, " ");
|
|
1046
|
-
try
|
|
1047
|
+
try appendJsonString(&out, allocator, names.display_name);
|
|
1047
1048
|
try out.appendSlice(allocator,
|
|
1048
1049
|
\\,
|
|
1049
|
-
\\
|
|
1050
|
-
\\
|
|
1051
|
-
\\
|
|
1052
|
-
\\
|
|
1053
|
-
\\
|
|
1054
|
-
\\
|
|
1055
|
-
\\
|
|
1056
|
-
\\
|
|
1057
|
-
\\
|
|
1058
|
-
\\
|
|
1059
|
-
\\
|
|
1050
|
+
\\ "description": "A counter that lives in one native window.",
|
|
1051
|
+
\\ "version": "0.1.0",
|
|
1052
|
+
\\ "icons": ["assets/icon.png"],
|
|
1053
|
+
\\ "platforms": ["macos"],
|
|
1054
|
+
\\ "permissions": ["view", "command"],
|
|
1055
|
+
\\ "capabilities": ["native_views", "gpu_surfaces"],
|
|
1056
|
+
\\ "shell": {
|
|
1057
|
+
\\ "windows": [
|
|
1058
|
+
\\ {
|
|
1059
|
+
\\ "label": "main",
|
|
1060
|
+
\\ "title":
|
|
1060
1061
|
);
|
|
1061
1062
|
try out.appendSlice(allocator, " ");
|
|
1062
|
-
try
|
|
1063
|
+
try appendJsonString(&out, allocator, names.display_name);
|
|
1063
1064
|
try out.appendSlice(allocator,
|
|
1064
1065
|
\\,
|
|
1065
|
-
\\
|
|
1066
|
-
\\
|
|
1067
|
-
\\
|
|
1068
|
-
\\
|
|
1069
|
-
\\
|
|
1070
|
-
\\ }
|
|
1071
|
-
\\
|
|
1066
|
+
\\ "width": 480,
|
|
1067
|
+
\\ "height": 320,
|
|
1068
|
+
\\ "views": [
|
|
1069
|
+
\\ { "label": "main-canvas", "kind": "gpu_surface", "fill": true, "role": "Counter canvas", "accessibility_label": "Counter", "gpu_backend": "metal", "gpu_pixel_format": "bgra8_unorm", "gpu_present_mode": "timer", "gpu_alpha_mode": "opaque", "gpu_color_space": "srgb", "gpu_vsync": true }
|
|
1070
|
+
\\ ]
|
|
1071
|
+
\\ }
|
|
1072
|
+
\\ ]
|
|
1072
1073
|
\\ },
|
|
1073
|
-
\\
|
|
1074
|
-
\\
|
|
1075
|
-
\\
|
|
1076
|
-
\\
|
|
1077
|
-
\\ }
|
|
1074
|
+
\\ "security": {
|
|
1075
|
+
\\ "navigation": {
|
|
1076
|
+
\\ "allowed_origins": ["zero://app", "zero://inline"],
|
|
1077
|
+
\\ "external_links": { "action": "deny" }
|
|
1078
|
+
\\ }
|
|
1078
1079
|
\\ },
|
|
1079
|
-
\\
|
|
1080
|
-
\\
|
|
1080
|
+
\\ "web_engine": "system",
|
|
1081
|
+
\\ "cef": { "dir": "third_party/cef/macos", "auto_install": false }
|
|
1081
1082
|
\\}
|
|
1082
1083
|
\\
|
|
1083
1084
|
);
|
|
@@ -1432,6 +1433,9 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1432
1433
|
\\ }
|
|
1433
1434
|
\\ const app_config = appManifestBuildConfig(b);
|
|
1434
1435
|
\\ const web_engine = web_engine_override orelse app_config.web_engine;
|
|
1436
|
+
\\ if (app_config.updates_enabled and selected_platform == .macos and web_engine == .chromium) {
|
|
1437
|
+
\\ @panic("\nnative updates currently require the system macOS host; use web_engine = \"system\" or remove the updates block\n");
|
|
1438
|
+
\\ }
|
|
1435
1439
|
\\ const cef_dir = cef_dir_override orelse defaultCefDir(selected_platform, app_config.cef_dir);
|
|
1436
1440
|
\\ const cef_auto_install = cef_auto_install_override orelse app_config.cef_auto_install;
|
|
1437
1441
|
\\ if (web_engine == .chromium and selected_platform != .macos) {
|
|
@@ -1463,7 +1467,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1463
1467
|
\\ const runner_mod = localModule(b, target, optimize, "src/runner.zig");
|
|
1464
1468
|
\\ runner_mod.addImport("native_sdk", native_sdk_mod);
|
|
1465
1469
|
\\ runner_mod.addImport("build_options", options_mod);
|
|
1466
|
-
\\ runner_mod.addImport("app_manifest_zon",
|
|
1470
|
+
\\ runner_mod.addImport("app_manifest_zon", appManifestModule(b));
|
|
1467
1471
|
\\ const migrations_mod = b.createModule(.{ .root_source_file = relational_migrations_source, .target = target, .optimize = optimize });
|
|
1468
1472
|
\\ migrations_mod.addImport("native_sdk", native_sdk_mod);
|
|
1469
1473
|
\\ runner_mod.addImport("relational_migrations", migrations_mod);
|
|
@@ -1512,7 +1516,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1512
1516
|
\\ const run_step = b.step("run", "Run the app");
|
|
1513
1517
|
\\ run_step.dependOn(&run.step);
|
|
1514
1518
|
\\
|
|
1515
|
-
\\ const dev = b.addSystemCommand(&.{ "native", "dev", "--manifest", "app.
|
|
1519
|
+
\\ const dev = b.addSystemCommand(&.{ "native", "dev", "--manifest", "app.json", "--binary" });
|
|
1516
1520
|
\\ dev.addFileArg(exe.getEmittedBin());
|
|
1517
1521
|
\\ addWebView2RuntimeRunFiles(b, target, dev, web_engine, web_layer, native_sdk_path);
|
|
1518
1522
|
\\ dev.step.dependOn(&exe.step);
|
|
@@ -1530,7 +1534,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1530
1534
|
\\ const package_runner_mod = localModule(b, target, package_optimize, "src/runner.zig");
|
|
1531
1535
|
\\ package_runner_mod.addImport("native_sdk", package_sdk_mod);
|
|
1532
1536
|
\\ package_runner_mod.addImport("build_options", options_mod);
|
|
1533
|
-
\\ package_runner_mod.addImport("app_manifest_zon",
|
|
1537
|
+
\\ package_runner_mod.addImport("app_manifest_zon", appManifestModule(b));
|
|
1534
1538
|
\\ const package_migrations_mod = b.createModule(.{ .root_source_file = relational_migrations_source, .target = target, .optimize = package_optimize });
|
|
1535
1539
|
\\ package_migrations_mod.addImport("native_sdk", package_sdk_mod);
|
|
1536
1540
|
\\ package_runner_mod.addImport("relational_migrations", package_migrations_mod);
|
|
@@ -1561,7 +1565,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1561
1565
|
\\ "--target",
|
|
1562
1566
|
\\ @tagName(package_target),
|
|
1563
1567
|
\\ "--manifest",
|
|
1564
|
-
\\ "app.
|
|
1568
|
+
\\ "app.json",
|
|
1565
1569
|
\\ "--assets",
|
|
1566
1570
|
);
|
|
1567
1571
|
try appendZigString(&out, allocator, frontend.distDir());
|
|
@@ -1588,6 +1592,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1588
1592
|
\\ // exe/package agreement structural.
|
|
1589
1593
|
\\ package.addArgs(&.{ "--web-layer", if (web_layer) "include" else "exclude" });
|
|
1590
1594
|
\\ if (cef_auto_install) package.addArg("--cef-auto-install");
|
|
1595
|
+
\\ if (app_config.updates_enabled and package_target == .macos and b.graph.host.result.os.tag == .macos) package.addArg("--update-archive");
|
|
1591
1596
|
\\ package.step.dependOn(&package_exe.step);
|
|
1592
1597
|
\\ package.step.dependOn(&frontend_build.step);
|
|
1593
1598
|
\\ const package_step = b.step("package", "Create a local package artifact");
|
|
@@ -2046,6 +2051,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2046
2051
|
\\ system_audio_permission: bool = false,
|
|
2047
2052
|
\\ sqlite_capability: bool = false,
|
|
2048
2053
|
\\ relational_capability: bool = false,
|
|
2054
|
+
\\ updates_enabled: bool = false,
|
|
2049
2055
|
\\ /// The first web declaration found (for teaching messages), or
|
|
2050
2056
|
\\ /// null when app.zon declares no web use. `web_engine = "system"`
|
|
2051
2057
|
\\ /// alone is NOT web intent — it is the default in many canvas
|
|
@@ -2067,6 +2073,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2067
2073
|
\\ auto_install: bool = false,
|
|
2068
2074
|
\\ } = .{},
|
|
2069
2075
|
\\ frontend: ?struct {} = null,
|
|
2076
|
+
\\ updates: ?struct {} = null,
|
|
2070
2077
|
\\ shell: struct {
|
|
2071
2078
|
\\ windows: []const struct {
|
|
2072
2079
|
\\ views: []const struct {
|
|
@@ -2089,10 +2096,10 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2089
2096
|
\\ // The fallback for a manifest this lenient parse cannot read
|
|
2090
2097
|
\\ // keeps the web layer (see AppManifestBuildConfig): a shape
|
|
2091
2098
|
\\ // mismatch here is not proof the app declares no web use.
|
|
2092
|
-
\\ const fallback: AppManifestBuildConfig = .{ .web_declaration = "an app.
|
|
2093
|
-
\\ const source
|
|
2099
|
+
\\ const fallback: AppManifestBuildConfig = .{ .web_declaration = "an app.json this build graph could not parse" };
|
|
2100
|
+
\\ const source = @embedFile("app.json");
|
|
2094
2101
|
\\ @setEvalBranchQuota(4000);
|
|
2095
|
-
\\ const raw = std.
|
|
2102
|
+
\\ const raw = std.json.parseFromSliceLeaky(InferenceManifest, b.allocator, source, .{ .ignore_unknown_fields = true }) catch return fallback;
|
|
2096
2103
|
\\ var config: AppManifestBuildConfig = .{
|
|
2097
2104
|
\\ .web_engine = parseWebEngine(raw.web_engine) orelse .system,
|
|
2098
2105
|
\\ .cef_dir = raw.cef.dir,
|
|
@@ -2103,6 +2110,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2103
2110
|
\\ .system_audio_permission = hasManifestPermission(raw.permissions, "system_audio"),
|
|
2104
2111
|
\\ .sqlite_capability = hasManifestCapability(raw.capabilities, "store") or hasManifestCapability(raw.capabilities, "sqlite"),
|
|
2105
2112
|
\\ .relational_capability = hasManifestCapability(raw.capabilities, "sqlite"),
|
|
2113
|
+
\\ .updates_enabled = raw.updates != null,
|
|
2106
2114
|
\\ };
|
|
2107
2115
|
\\ config.web_declaration = blk: {
|
|
2108
2116
|
\\ if (raw.frontend != null) break :blk "a .frontend block";
|
|
@@ -2119,6 +2127,49 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2119
2127
|
\\ return config;
|
|
2120
2128
|
\\}
|
|
2121
2129
|
\\
|
|
2130
|
+
\\fn appManifestModule(b: *std.Build) *std.Build.Module {
|
|
2131
|
+
\\ const root = std.json.parseFromSliceLeaky(std.json.Value, b.allocator, @embedFile("app.json"), .{ .parse_numbers = false }) catch
|
|
2132
|
+
\\ @panic("cannot parse app.json; run `native check` for a precise diagnostic");
|
|
2133
|
+
\\ if (root != .object) @panic("app.json must contain one object");
|
|
2134
|
+
\\ var out = std.Io.Writer.Allocating.init(b.allocator);
|
|
2135
|
+
\\ writeManifestValue(&out.writer, root, 0) catch |err| switch (err) {
|
|
2136
|
+
\\ error.NullNotAllowed => @panic("app.json cannot contain null values; omit optional fields instead"),
|
|
2137
|
+
\\ else => @panic("out of memory converting app.json"),
|
|
2138
|
+
\\ };
|
|
2139
|
+
\\ const generated = b.addWriteFiles().add("app_manifest.zon", out.written());
|
|
2140
|
+
\\ return b.createModule(.{ .root_source_file = generated });
|
|
2141
|
+
\\}
|
|
2142
|
+
\\
|
|
2143
|
+
\\fn writeManifestValue(writer: *std.Io.Writer, value: std.json.Value, depth: usize) !void {
|
|
2144
|
+
\\ switch (value) {
|
|
2145
|
+
\\ .null => return error.NullNotAllowed,
|
|
2146
|
+
\\ .bool => |v| try writer.writeAll(if (v) "true" else "false"),
|
|
2147
|
+
\\ .integer => |v| try writer.print("{d}", .{v}),
|
|
2148
|
+
\\ .float => |v| try writer.print("{d}", .{v}),
|
|
2149
|
+
\\ .number_string => |v| try writer.writeAll(v),
|
|
2150
|
+
\\ .string => |v| try writer.print("\"{f}\"", .{std.zig.fmtString(v)}),
|
|
2151
|
+
\\ .array => |array| {
|
|
2152
|
+
\\ try writer.writeAll(".{");
|
|
2153
|
+
\\ for (array.items) |item| {
|
|
2154
|
+
\\ try writeManifestValue(writer, item, depth + 1);
|
|
2155
|
+
\\ try writer.writeByte(',');
|
|
2156
|
+
\\ }
|
|
2157
|
+
\\ try writer.writeByte('}');
|
|
2158
|
+
\\ },
|
|
2159
|
+
\\ .object => |object| {
|
|
2160
|
+
\\ try writer.writeAll(".{");
|
|
2161
|
+
\\ var iterator = object.iterator();
|
|
2162
|
+
\\ while (iterator.next()) |entry| {
|
|
2163
|
+
\\ if (depth == 0 and std.mem.eql(u8, entry.key_ptr.*, "$schema")) continue;
|
|
2164
|
+
\\ try writer.print(".{f}=", .{std.zig.fmtId(entry.key_ptr.*)});
|
|
2165
|
+
\\ try writeManifestValue(writer, entry.value_ptr.*, depth + 1);
|
|
2166
|
+
\\ try writer.writeByte(',');
|
|
2167
|
+
\\ }
|
|
2168
|
+
\\ try writer.writeByte('}');
|
|
2169
|
+
\\ },
|
|
2170
|
+
\\ }
|
|
2171
|
+
\\}
|
|
2172
|
+
\\
|
|
2122
2173
|
\\fn hasManifestPermission(permissions: []const []const u8, name: []const u8) bool {
|
|
2123
2174
|
\\ for (permissions) |permission| {
|
|
2124
2175
|
\\ if (std.mem.eql(u8, permission, name)) return true;
|
|
@@ -2199,7 +2250,7 @@ fn buildZon(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8 {
|
|
|
2199
2250
|
\\ .version = "0.1.0",
|
|
2200
2251
|
\\ .minimum_zig_version = "0.16.0",
|
|
2201
2252
|
\\ .dependencies = .{},
|
|
2202
|
-
\\ .paths = .{ "build.zig", "build.zig.zon", "src", "assets", "frontend", "app.
|
|
2253
|
+
\\ .paths = .{ "build.zig", "build.zig.zon", "src", "assets", "frontend", "app.json", "README.md" },
|
|
2203
2254
|
\\}
|
|
2204
2255
|
\\
|
|
2205
2256
|
);
|
|
@@ -2353,12 +2404,18 @@ fn runnerZig() []const u8 {
|
|
|
2353
2404
|
\\ fn appInfo(self: RunOptions, buffers: *StateBuffers) native_sdk.AppInfo {
|
|
2354
2405
|
\\ var info: native_sdk.AppInfo = .{
|
|
2355
2406
|
\\ .app_name = self.app_name,
|
|
2407
|
+
\\ .display_name = manifestStringField("display_name"),
|
|
2408
|
+
\\ .version = manifestStringField("version"),
|
|
2409
|
+
\\ .description = manifestStringField("description"),
|
|
2356
2410
|
\\ .has_web_content = manifestHasWebContent(),
|
|
2357
2411
|
\\ .declares_tray = manifestDeclaresTrayCapability(),
|
|
2358
2412
|
\\ .dock_visible = manifestDockVisible(),
|
|
2359
2413
|
\\ .window_title = self.window_title,
|
|
2360
2414
|
\\ .bundle_id = self.bundle_id,
|
|
2361
2415
|
\\ .icon_path = self.icon_path,
|
|
2416
|
+
\\ .update_feed_url = manifestUpdateString("feed_url"),
|
|
2417
|
+
\\ .update_public_key = manifestUpdateString("public_key"),
|
|
2418
|
+
\\ .update_check_on_start = manifestUpdateCheckOnStart(),
|
|
2362
2419
|
\\ };
|
|
2363
2420
|
\\ const windows = manifestWindowOptions(buffers);
|
|
2364
2421
|
\\ if (windows.len > 0) {
|
|
@@ -2410,6 +2467,30 @@ fn runnerZig() []const u8 {
|
|
|
2410
2467
|
\\ }
|
|
2411
2468
|
\\};
|
|
2412
2469
|
\\
|
|
2470
|
+
\\fn manifestStringField(comptime field: []const u8) []const u8 {
|
|
2471
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), field)) return "";
|
|
2472
|
+
\\ const value = @field(app_manifest, field);
|
|
2473
|
+
\\ if (comptime @TypeOf(value) == @TypeOf(null)) return "";
|
|
2474
|
+
\\ return value;
|
|
2475
|
+
\\}
|
|
2476
|
+
\\
|
|
2477
|
+
\\fn manifestUpdateString(comptime field: []const u8) []const u8 {
|
|
2478
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "updates")) return "";
|
|
2479
|
+
\\ const updates = app_manifest.updates;
|
|
2480
|
+
\\ if (comptime !@hasField(@TypeOf(updates), field)) return "";
|
|
2481
|
+
\\ const value = @field(updates, field);
|
|
2482
|
+
\\ return switch (@typeInfo(@TypeOf(value))) {
|
|
2483
|
+
\\ .optional => value orelse "",
|
|
2484
|
+
\\ else => value,
|
|
2485
|
+
\\ };
|
|
2486
|
+
\\}
|
|
2487
|
+
\\
|
|
2488
|
+
\\fn manifestUpdateCheckOnStart() bool {
|
|
2489
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "updates")) return false;
|
|
2490
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest.updates), "check_on_start")) return false;
|
|
2491
|
+
\\ return app_manifest.updates.check_on_start;
|
|
2492
|
+
\\}
|
|
2493
|
+
\\
|
|
2413
2494
|
\\const CommandStorage = struct {
|
|
2414
2495
|
\\ commands: [native_sdk.app_manifest.max_commands]native_sdk.Command = undefined,
|
|
2415
2496
|
\\
|
|
@@ -3203,46 +3284,47 @@ fn runnerZig() []const u8 {
|
|
|
3203
3284
|
;
|
|
3204
3285
|
}
|
|
3205
3286
|
|
|
3206
|
-
fn
|
|
3287
|
+
fn appJson(allocator: std.mem.Allocator, names: TemplateNames, frontend: Frontend) ![]const u8 {
|
|
3207
3288
|
var out: std.ArrayList(u8) = .empty;
|
|
3208
3289
|
errdefer out.deinit(allocator);
|
|
3209
3290
|
try out.appendSlice(allocator,
|
|
3210
|
-
|
|
3211
|
-
\\ .
|
|
3291
|
+
\\{
|
|
3292
|
+
\\ "$schema": "https://schema.native-sdk.dev/app/v1.json",
|
|
3293
|
+
\\ "id":
|
|
3212
3294
|
);
|
|
3213
|
-
try
|
|
3295
|
+
try appendJsonString(&out, allocator, names.app_id);
|
|
3214
3296
|
try out.appendSlice(allocator,
|
|
3215
3297
|
\\,
|
|
3216
|
-
\\
|
|
3298
|
+
\\ "name":
|
|
3217
3299
|
);
|
|
3218
|
-
try
|
|
3300
|
+
try appendJsonString(&out, allocator, names.package_name);
|
|
3219
3301
|
try out.appendSlice(allocator,
|
|
3220
3302
|
\\,
|
|
3221
|
-
\\
|
|
3303
|
+
\\ "display_name":
|
|
3222
3304
|
);
|
|
3223
|
-
try
|
|
3305
|
+
try appendJsonString(&out, allocator, names.display_name);
|
|
3224
3306
|
try out.appendSlice(allocator,
|
|
3225
3307
|
\\,
|
|
3226
|
-
\\
|
|
3227
|
-
\\
|
|
3228
|
-
\\
|
|
3229
|
-
\\
|
|
3230
|
-
\\
|
|
3231
|
-
\\
|
|
3232
|
-
\\
|
|
3308
|
+
\\ "version": "0.1.0",
|
|
3309
|
+
\\ "icons": ["assets/icon.png"],
|
|
3310
|
+
\\ "platforms": ["macos", "linux"],
|
|
3311
|
+
\\ "permissions": [],
|
|
3312
|
+
\\ "capabilities": ["webview"],
|
|
3313
|
+
\\ "frontend": {
|
|
3314
|
+
\\ "dist":
|
|
3233
3315
|
);
|
|
3234
|
-
try
|
|
3316
|
+
try appendJsonString(&out, allocator, frontend.distDir());
|
|
3235
3317
|
try out.appendSlice(allocator,
|
|
3236
3318
|
\\,
|
|
3237
|
-
\\
|
|
3238
|
-
\\
|
|
3239
|
-
\\
|
|
3240
|
-
\\
|
|
3319
|
+
\\ "entry": "index.html",
|
|
3320
|
+
\\ "spa_fallback": true,
|
|
3321
|
+
\\ "dev": {
|
|
3322
|
+
\\ "url":
|
|
3241
3323
|
);
|
|
3242
|
-
try
|
|
3324
|
+
try appendJsonString(&out, allocator, frontend.devUrl());
|
|
3243
3325
|
try out.appendSlice(allocator,
|
|
3244
3326
|
\\,
|
|
3245
|
-
\\
|
|
3327
|
+
\\ "command": ["npm", "--prefix", "frontend", "run", "dev"
|
|
3246
3328
|
);
|
|
3247
3329
|
if (frontend != .next) {
|
|
3248
3330
|
try out.appendSlice(allocator,
|
|
@@ -3250,33 +3332,33 @@ fn appZon(allocator: std.mem.Allocator, names: TemplateNames, frontend: Frontend
|
|
|
3250
3332
|
);
|
|
3251
3333
|
}
|
|
3252
3334
|
try out.appendSlice(allocator,
|
|
3253
|
-
\\
|
|
3254
|
-
\\
|
|
3255
|
-
\\
|
|
3256
|
-
\\ }
|
|
3335
|
+
\\],
|
|
3336
|
+
\\ "ready_path": "/",
|
|
3337
|
+
\\ "timeout_ms": 30000
|
|
3338
|
+
\\ }
|
|
3257
3339
|
\\ },
|
|
3258
|
-
\\
|
|
3259
|
-
\\
|
|
3260
|
-
\\
|
|
3340
|
+
\\ "security": {
|
|
3341
|
+
\\ "navigation": {
|
|
3342
|
+
\\ "allowed_origins": ["zero://app", "zero://inline",
|
|
3261
3343
|
);
|
|
3262
3344
|
try out.appendSlice(allocator, " ");
|
|
3263
3345
|
const dev_origin = try std.fmt.allocPrint(allocator, "http://127.0.0.1:{s}", .{frontend.devPort()});
|
|
3264
3346
|
defer allocator.free(dev_origin);
|
|
3265
|
-
try
|
|
3347
|
+
try appendJsonString(&out, allocator, dev_origin);
|
|
3266
3348
|
try out.appendSlice(allocator,
|
|
3267
|
-
\\
|
|
3268
|
-
\\
|
|
3269
|
-
\\ }
|
|
3349
|
+
\\],
|
|
3350
|
+
\\ "external_links": { "action": "deny" }
|
|
3351
|
+
\\ }
|
|
3270
3352
|
\\ },
|
|
3271
|
-
\\
|
|
3272
|
-
\\
|
|
3273
|
-
\\
|
|
3274
|
-
\\
|
|
3353
|
+
\\ "web_engine": "system",
|
|
3354
|
+
\\ "cef": { "dir": "third_party/cef/macos", "auto_install": false },
|
|
3355
|
+
\\ "windows": [
|
|
3356
|
+
\\ { "label": "main", "title":
|
|
3275
3357
|
);
|
|
3276
|
-
try
|
|
3358
|
+
try appendJsonString(&out, allocator, names.display_name);
|
|
3277
3359
|
try out.appendSlice(allocator,
|
|
3278
|
-
\\,
|
|
3279
|
-
\\
|
|
3360
|
+
\\, "width": 720, "height": 480, "restore_state": true }
|
|
3361
|
+
\\ ]
|
|
3280
3362
|
\\}
|
|
3281
3363
|
\\
|
|
3282
3364
|
);
|
|
@@ -4004,10 +4086,10 @@ fn readme(allocator: std.mem.Allocator, names: TemplateNames, framework_path: []
|
|
|
4004
4086
|
\\zig build run
|
|
4005
4087
|
\\zig build test
|
|
4006
4088
|
\\zig build package
|
|
4007
|
-
\\native doctor --manifest app.
|
|
4089
|
+
\\native doctor --manifest app.json
|
|
4008
4090
|
\\```
|
|
4009
4091
|
\\
|
|
4010
|
-
\\`zig build dev` starts the frontend dev server from `app.
|
|
4092
|
+
\\`zig build dev` starts the frontend dev server from `app.json`, waits for it, and launches the native shell with `NATIVE_SDK_FRONTEND_URL`.
|
|
4011
4093
|
\\
|
|
4012
4094
|
\\Frontend:
|
|
4013
4095
|
\\
|
|
@@ -4089,7 +4171,7 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
4089
4171
|
const destination = ".zig-cache/test-vite-init-template";
|
|
4090
4172
|
try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .vite });
|
|
4091
4173
|
|
|
4092
|
-
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.
|
|
4174
|
+
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.json");
|
|
4093
4175
|
defer std.testing.allocator.free(app_zon_text);
|
|
4094
4176
|
const build_zig_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig");
|
|
4095
4177
|
defer std.testing.allocator.free(build_zig_text);
|
|
@@ -4102,10 +4184,11 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
4102
4184
|
const main_js_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "frontend/src/main.js");
|
|
4103
4185
|
defer std.testing.allocator.free(main_js_text);
|
|
4104
4186
|
|
|
4105
|
-
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "
|
|
4187
|
+
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "\"frontend\"") != null);
|
|
4106
4188
|
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "frontend/dist") != null);
|
|
4107
4189
|
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "npm") != null);
|
|
4108
|
-
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "
|
|
4190
|
+
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "\"windows\"") != null);
|
|
4191
|
+
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "\"$schema\": \"https://schema.native-sdk.dev/app/v1.json\"") != null);
|
|
4109
4192
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "frontend-install") != null);
|
|
4110
4193
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "\"npm\", \"install\", \"--prefix\", \"frontend\"") != null);
|
|
4111
4194
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "frontend-build") != null);
|
|
@@ -4144,11 +4227,18 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
4144
4227
|
// loader when native-only).
|
|
4145
4228
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "b.option(WebLayerOption, \"web-layer\", \"Override app.zon webview_layer: auto, include, exclude\")") != null);
|
|
4146
4229
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "const web_layer = resolveWebLayer(app_config, web_engine, web_layer_override)") != null);
|
|
4230
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "app_config.updates_enabled and selected_platform == .macos and web_engine == .chromium") != null);
|
|
4231
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "updates: ?struct {} = null") != null);
|
|
4232
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, ".updates_enabled = raw.updates != null") != null);
|
|
4147
4233
|
// The emitted package step forwards the graph's resolved decision so
|
|
4148
4234
|
// the packaged artifact structurally agrees with the compiled exe.
|
|
4149
4235
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "package.addArgs(&.{ \"--web-layer\", if (web_layer) \"include\" else \"exclude\" })") != null);
|
|
4236
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "package.addArg(\"--update-archive\")") != null);
|
|
4150
4237
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "options.addOption(bool, \"web_layer\", web_layer)") != null);
|
|
4151
|
-
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "std.
|
|
4238
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "std.json.parseFromSliceLeaky(InferenceManifest") != null);
|
|
4239
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "fn appManifestModule") != null);
|
|
4240
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, ".{ .parse_numbers = false }") != null);
|
|
4241
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, ".null => return error.NullNotAllowed") != null);
|
|
4152
4242
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "the web layer is excluded ({s}) but the app declares web use ({s})") != null);
|
|
4153
4243
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, ".system => if (web_layer) {") != null);
|
|
4154
4244
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "\"-DNATIVE_SDK_ALLOW_WEBVIEW2_STUB\"") != null);
|
|
@@ -4202,6 +4292,10 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
4202
4292
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedShortcuts") != null);
|
|
4203
4293
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "const manifest_windows") != null);
|
|
4204
4294
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn appInfo(self: RunOptions, buffers: *StateBuffers)") != null);
|
|
4295
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".version = manifestStringField(\"version\")") != null);
|
|
4296
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".update_feed_url = manifestUpdateString(\"feed_url\")") != null);
|
|
4297
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".update_public_key = manifestUpdateString(\"public_key\")") != null);
|
|
4298
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".update_check_on_start = manifestUpdateCheckOnStart()") != null);
|
|
4205
4299
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestWindowOptions") != null);
|
|
4206
4300
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.windows = windows") != null);
|
|
4207
4301
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "for (restored_windows, 0..)") != null);
|
|
@@ -4292,7 +4386,7 @@ test "writeDefaultApp emits frontend-specific Next paths" {
|
|
|
4292
4386
|
const destination = ".zig-cache/test-next-init-template";
|
|
4293
4387
|
try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "Next App", .framework_path = ".", .frontend = .next });
|
|
4294
4388
|
|
|
4295
|
-
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.
|
|
4389
|
+
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.json");
|
|
4296
4390
|
defer std.testing.allocator.free(app_zon_text);
|
|
4297
4391
|
const build_zig_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig");
|
|
4298
4392
|
defer std.testing.allocator.free(build_zig_text);
|
|
@@ -4317,7 +4411,7 @@ test "writeDefaultApp emits the TS-core scaffold by default: three files of trut
|
|
|
4317
4411
|
defer std.testing.allocator.free(core_text);
|
|
4318
4412
|
const markup_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "src/app.native");
|
|
4319
4413
|
defer std.testing.allocator.free(markup_text);
|
|
4320
|
-
const ts_app_zon = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.
|
|
4414
|
+
const ts_app_zon = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.json");
|
|
4321
4415
|
defer std.testing.allocator.free(ts_app_zon);
|
|
4322
4416
|
const ts_readme = try readTestFile(std.testing.allocator, std.testing.io, destination, "README.md");
|
|
4323
4417
|
defer std.testing.allocator.free(ts_readme);
|
|
@@ -4410,7 +4504,7 @@ test "writeDefaultApp --template zig-core emits the slim Zig scaffold at ts-core
|
|
|
4410
4504
|
const destination = ".zig-cache/test-native-slim-template";
|
|
4411
4505
|
try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .core = .zig });
|
|
4412
4506
|
|
|
4413
|
-
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.
|
|
4507
|
+
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.json");
|
|
4414
4508
|
defer std.testing.allocator.free(app_zon_text);
|
|
4415
4509
|
const main_zig_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "src/main.zig");
|
|
4416
4510
|
defer std.testing.allocator.free(main_zig_text);
|
|
@@ -4467,7 +4561,7 @@ test "writeDefaultApp emits native project files" {
|
|
|
4467
4561
|
const destination = ".zig-cache/test-native-init-template";
|
|
4468
4562
|
try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full, .core = .zig });
|
|
4469
4563
|
|
|
4470
|
-
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.
|
|
4564
|
+
const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.json");
|
|
4471
4565
|
defer std.testing.allocator.free(app_zon_text);
|
|
4472
4566
|
const build_zig_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig");
|
|
4473
4567
|
defer std.testing.allocator.free(build_zig_text);
|
|
@@ -4493,8 +4587,8 @@ test "writeDefaultApp emits native project files" {
|
|
|
4493
4587
|
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "gpu_surface") != null);
|
|
4494
4588
|
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "\"native_views\", \"gpu_surfaces\"") != null);
|
|
4495
4589
|
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "dev.native_sdk.my-app") != null);
|
|
4496
|
-
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "
|
|
4497
|
-
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "native_sdk.addApp(b, b.dependency(\"native_sdk\", .{}), .{ .name = \"my-app\" })") != null);
|
|
4590
|
+
try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "\"frontend\"") == null);
|
|
4591
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "native_sdk.addApp(b, b.dependency(\"native_sdk\", .{}), .{ .name = \"my-app\", .manifest = \"app.json\" })") != null);
|
|
4498
4592
|
try std.testing.expect(std.mem.indexOf(u8, build_zon_text, ".native_sdk = .{ .path = ") != null);
|
|
4499
4593
|
try std.testing.expect(std.mem.indexOf(u8, build_zon_text, ".name = .my_app") != null);
|
|
4500
4594
|
try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "native_sdk.UiApp(Model, Msg)") != null);
|