@native-sdk/cli 0.4.3 → 0.5.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.
Files changed (100) hide show
  1. package/build/app.zig +308 -72
  2. package/build/ts_run.mjs +63 -0
  3. package/build.zig +336 -7
  4. package/build.zig.zon +1 -0
  5. package/package.json +15 -10
  6. package/packages/core/package-lock.json +43 -0
  7. package/packages/core/package.json +37 -0
  8. package/packages/core/rt/rt.zig +1579 -0
  9. package/packages/core/sdk/bytes_text_methods.d.ts +88 -0
  10. package/packages/core/sdk/core.ts +694 -0
  11. package/packages/core/sdk/events.ts +137 -0
  12. package/packages/core/sdk/text.ts +519 -0
  13. package/packages/core/src/checker.ts +1869 -0
  14. package/packages/core/src/cli.ts +68 -0
  15. package/packages/core/src/devhost.ts +291 -0
  16. package/packages/core/src/devhost_resolver.mjs +22 -0
  17. package/packages/core/src/diagnostics.ts +417 -0
  18. package/packages/core/src/emitter.ts +8815 -0
  19. package/packages/core/src/infer.ts +1515 -0
  20. package/packages/core/src/modules.ts +173 -0
  21. package/packages/core/src/ownership.ts +740 -0
  22. package/packages/core/src/text_polyfill.ts +337 -0
  23. package/packages/core/src/text_tables.ts +408 -0
  24. package/packages/core/src/transpile.ts +146 -0
  25. package/packages/core/src/typed_ast.ts +536 -0
  26. package/packages/core/src/types.ts +815 -0
  27. package/skill-data/core/SKILL.md +3 -0
  28. package/skill-data/native-ui/SKILL.md +30 -0
  29. package/skill-data/ts-core/SKILL.md +493 -0
  30. package/skill-data/zig/SKILL.md +208 -0
  31. package/skills/native-sdk/SKILL.md +1 -1
  32. package/src/app_runner/root.zig +75 -9
  33. package/src/app_runner/ts_core_main.zig +231 -0
  34. package/src/platform/linux/gtk_host.c +226 -21
  35. package/src/platform/windows/webview2_host.cpp +16 -10
  36. package/src/primitives/app_manifest/comptime_scene.zig +341 -0
  37. package/src/primitives/app_manifest/root.zig +13 -0
  38. package/src/primitives/app_manifest/types.zig +14 -0
  39. package/src/primitives/app_manifest/validation.zig +18 -0
  40. package/src/primitives/app_manifest/web_layer.zig +366 -0
  41. package/src/primitives/canvas/commands.zig +14 -7
  42. package/src/primitives/canvas/lazy_tls.zig +73 -0
  43. package/src/primitives/canvas/render_generic_resources.zig +22 -15
  44. package/src/primitives/canvas/root.zig +6 -0
  45. package/src/primitives/canvas/tests.zig +1 -0
  46. package/src/primitives/canvas/text_atlas.zig +40 -32
  47. package/src/primitives/canvas/text_layout_cache.zig +29 -22
  48. package/src/primitives/canvas/text_measure_cache.zig +56 -41
  49. package/src/primitives/canvas/text_spans.zig +39 -26
  50. package/src/primitives/canvas/tokens.zig +54 -0
  51. package/src/primitives/canvas/ui.zig +125 -0
  52. package/src/primitives/canvas/ui_markup.zig +22 -3
  53. package/src/primitives/canvas/ui_markup_compiled.zig +97 -7
  54. package/src/primitives/canvas/ui_markup_compiled_tests.zig +275 -0
  55. package/src/primitives/canvas/ui_markup_contract.zig +68 -14
  56. package/src/primitives/canvas/ui_markup_contract_tests.zig +257 -2
  57. package/src/primitives/canvas/ui_markup_reflect.zig +214 -0
  58. package/src/primitives/canvas/ui_markup_view.zig +105 -1
  59. package/src/primitives/canvas/ui_markup_view_tests.zig +336 -0
  60. package/src/primitives/canvas/ui_schema.zig +8 -0
  61. package/src/primitives/canvas/ui_schema_tests.zig +5 -4
  62. package/src/primitives/canvas/widget_invalidation.zig +14 -7
  63. package/src/primitives/canvas/widget_render.zig +25 -15
  64. package/src/primitives/canvas/widget_render_controls.zig +15 -9
  65. package/src/primitives/canvas/widget_runtime_tests.zig +44 -0
  66. package/src/root.zig +7 -0
  67. package/src/runtime/api.zig +7 -0
  68. package/src/runtime/bridge_responses.zig +2 -0
  69. package/src/runtime/builtin_bridge.zig +6 -0
  70. package/src/runtime/canvas_frame.zig +57 -36
  71. package/src/runtime/canvas_images.zig +9 -3
  72. package/src/runtime/canvas_widget_control_tests.zig +5 -6
  73. package/src/runtime/canvas_widget_runtime.zig +7 -4
  74. package/src/runtime/effects.zig +490 -2
  75. package/src/runtime/effects_host_tests.zig +594 -0
  76. package/src/runtime/flow.zig +8 -0
  77. package/src/runtime/platform_bridge_tests.zig +1 -0
  78. package/src/runtime/root.zig +18 -0
  79. package/src/runtime/session_replay.zig +7 -1
  80. package/src/runtime/session_tests.zig +35 -8
  81. package/src/runtime/tests.zig +2 -0
  82. package/src/runtime/ts_core_host.zig +1505 -0
  83. package/src/runtime/ts_core_host_tests.zig +1408 -0
  84. package/src/runtime/ts_ui_app.zig +469 -0
  85. package/src/runtime/ui_app.zig +58 -0
  86. package/src/runtime/view_canvas.zig +24 -17
  87. package/src/runtime/view_widget_tree.zig +2 -2
  88. package/src/runtime/web_layer_gate_tests.zig +242 -0
  89. package/src/runtime/window_storage.zig +5 -0
  90. package/src/runtime/window_view_runtime.zig +1 -0
  91. package/src/tooling/buildgraph.zig +7 -1
  92. package/src/tooling/codesign.zig +212 -105
  93. package/src/tooling/doctor.zig +78 -0
  94. package/src/tooling/manifest.zig +314 -1
  95. package/src/tooling/package.zig +722 -18
  96. package/src/tooling/raw_manifest.zig +16 -0
  97. package/src/tooling/root.zig +1 -0
  98. package/src/tooling/templates.zig +911 -88
  99. package/src/tooling/ts_core.zig +486 -0
  100. package/src/tooling/verbs.zig +22 -0
@@ -1,5 +1,6 @@
1
1
  const std = @import("std");
2
2
  const junction = @import("junction.zig");
3
+ const ts_core = @import("ts_core.zig");
3
4
 
4
5
  /// The SDK's default app icon, rendered from vector source by
5
6
  /// `zig build generate-icon` (tools/generate_app_icon.zig). Embedded so
@@ -64,11 +65,32 @@ pub const Shape = enum {
64
65
  full,
65
66
  };
66
67
 
68
+ /// Which core the native-frontend scaffold writes. No language flag and no
69
+ /// persistent config anywhere: the choice leaves NOTHING behind but the
70
+ /// tree itself (src/core.ts vs src/main.zig) - the build graph detects the
71
+ /// core from the tree on every build.
72
+ pub const CoreTemplate = enum {
73
+ /// TypeScript core (src/core.ts) + markup view - the default.
74
+ ts,
75
+ /// Zig core (src/main.zig) + markup view - the same starter app,
76
+ /// authored in Zig.
77
+ zig,
78
+
79
+ pub fn parse(value: []const u8) ?CoreTemplate {
80
+ if (std.mem.eql(u8, value, "ts-core")) return .ts;
81
+ if (std.mem.eql(u8, value, "zig-core")) return .zig;
82
+ return null;
83
+ }
84
+ };
85
+
67
86
  pub const InitOptions = struct {
68
87
  app_name: []const u8,
69
88
  framework_path: []const u8 = ".",
70
89
  frontend: Frontend = .vite,
71
90
  shape: Shape = .slim,
91
+ /// Applies to the native frontend only (web frontends have no core
92
+ /// tier to scaffold).
93
+ core: CoreTemplate = .ts,
72
94
  };
73
95
 
74
96
  pub fn writeDefaultApp(allocator: std.mem.Allocator, io: std.Io, destination: []const u8, options: InitOptions) !void {
@@ -86,6 +108,15 @@ pub fn writeDefaultApp(allocator: std.mem.Allocator, io: std.Io, destination: []
86
108
  try app_dir.createDirPath(io, "assets");
87
109
 
88
110
  if (options.frontend == .native) {
111
+ if (options.core == .ts) {
112
+ if (options.shape == .slim) {
113
+ return writeTsAppSlim(allocator, io, app_dir, names, destination, options.framework_path);
114
+ }
115
+ // build.zig.zon path dependencies must be relative to the app root.
116
+ const dependency_path = try nativeDependencyPath(allocator, io, destination, framework_path);
117
+ defer allocator.free(dependency_path);
118
+ return writeTsApp(allocator, io, app_dir, names, dependency_path, destination, options.framework_path);
119
+ }
89
120
  if (options.shape == .slim) {
90
121
  return writeNativeAppSlim(allocator, io, app_dir, names);
91
122
  }
@@ -151,6 +182,322 @@ fn slimGitignore() []const u8 {
151
182
  ;
152
183
  }
153
184
 
185
+ /// The TypeScript-core zero-config scaffold - the `native init` default:
186
+ /// core.ts (logic), app.native (view), app.zon (manifest). ZERO Zig in the
187
+ /// tree; the build graph detects src/core.ts, transpiles it, and stages the
188
+ /// generated wiring outside the app on every build.
189
+ ///
190
+ /// The tree also carries the EDITOR surface: package.json + tsconfig.json,
191
+ /// so stock editor TypeScript resolves `@native-sdk/core` with full
192
+ /// IntelliSense, plus a materialized node_modules copy of the SDK package
193
+ /// (ts_core.zig owns that contract). None of it is build truth — the tree
194
+ /// detection above keys on src/core.ts alone, and every `native` verb
195
+ /// works with node_modules deleted.
196
+ fn writeTsAppSlim(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir, names: TemplateNames, destination: []const u8, sdk_source: []const u8) !void {
197
+ const app_zon = try nativeAppZon(allocator, names);
198
+ defer allocator.free(app_zon);
199
+ const readme_md = try tsSlimReadme(allocator, names);
200
+ defer allocator.free(readme_md);
201
+
202
+ try writeFile(app_dir, io, "src/core.ts", tsCoreStarter());
203
+ try writeFile(app_dir, io, "src/app.native", tsAppMarkup());
204
+ try writeFile(app_dir, io, "app.zon", app_zon);
205
+ try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
206
+ try writeFile(app_dir, io, ".gitignore", tsGitignore());
207
+ try writeFile(app_dir, io, "README.md", readme_md);
208
+ try writeTsEditorSurface(allocator, io, app_dir, names, destination, sdk_source);
209
+ }
210
+
211
+ /// The `--full` twin: the same TS tree plus an owned build.zig/zon pair
212
+ /// (the plain addApp call - the build graph's tree detection does the
213
+ /// rest) and a CI workflow, for users who want to own the build from day
214
+ /// one — the same full-shape contract as the Zig template.
215
+ fn writeTsApp(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir, names: TemplateNames, framework_path: []const u8, destination: []const u8, sdk_source: []const u8) !void {
216
+ const build_zig = try nativeBuildZig(allocator, names);
217
+ defer allocator.free(build_zig);
218
+ const build_zon = try nativeBuildZon(allocator, names, framework_path);
219
+ defer allocator.free(build_zon);
220
+ const app_zon = try nativeAppZon(allocator, names);
221
+ defer allocator.free(app_zon);
222
+ const readme_md = try tsSlimReadme(allocator, names);
223
+ defer allocator.free(readme_md);
224
+ const ci_yaml = try nativeCiYaml(allocator, names, framework_path, .ts);
225
+ defer allocator.free(ci_yaml);
226
+
227
+ try app_dir.createDirPath(io, ".github/workflows");
228
+ try writeFile(app_dir, io, ".github/workflows/ci.yml", ci_yaml);
229
+ try writeFile(app_dir, io, "build.zig", build_zig);
230
+ try writeFile(app_dir, io, "build.zig.zon", build_zon);
231
+ try writeFile(app_dir, io, "src/core.ts", tsCoreStarter());
232
+ try writeFile(app_dir, io, "src/app.native", tsAppMarkup());
233
+ try writeFile(app_dir, io, "app.zon", app_zon);
234
+ try writeFile(app_dir, io, "assets/icon.png", default_icon_png);
235
+ try writeFile(app_dir, io, ".gitignore", tsGitignore());
236
+ try writeFile(app_dir, io, "README.md", readme_md);
237
+ try writeTsEditorSurface(allocator, io, app_dir, names, destination, sdk_source);
238
+ }
239
+
240
+ /// The editor-and-versioning surface of a TS scaffold: package.json (the
241
+ /// app's name and its `@native-sdk/core` dependency at the SDK's bundled
242
+ /// version), tsconfig.json (the checker's own compiler options, so editor
243
+ /// errors match `native check` reality), and a materialized
244
+ /// node_modules/@native-sdk/core so resolution works BEFORE the package is
245
+ /// published to npm. `sdk_source` is the framework checkout as reachable
246
+ /// from the CLI's cwd (unlike the destination-relative build.zig.zon path).
247
+ fn writeTsEditorSurface(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir, names: TemplateNames, destination: []const u8, sdk_source: []const u8) !void {
248
+ const sdk_version = ts_core.bundledSdkVersion(allocator, io, sdk_source) catch |err| {
249
+ std.debug.print("the Native SDK at {s} is missing packages/core/package.json - is the checkout (or npm install) complete?\n", .{sdk_source});
250
+ return err;
251
+ };
252
+ defer allocator.free(sdk_version);
253
+ const package_json = try tsPackageJson(allocator, names, sdk_version);
254
+ defer allocator.free(package_json);
255
+ try writeFile(app_dir, io, "package.json", package_json);
256
+ try writeFile(app_dir, io, "tsconfig.json", tsTsconfig());
257
+ _ = try ts_core.ensureEditorPackage(allocator, io, sdk_source, destination);
258
+ }
259
+
260
+ /// The app's package.json: name + the pinned `@native-sdk/core` dependency,
261
+ /// nothing else. It exists for editors and versioning only — the `native`
262
+ /// verbs never read it (tree detection keys on src/core.ts; the build
263
+ /// transpiles against the SDK checkout) — and the pin is exact so the
264
+ /// post-publish `npm install` resolves the same content the CLI
265
+ /// materialized.
266
+ fn tsPackageJson(allocator: std.mem.Allocator, names: TemplateNames, sdk_version: []const u8) ![]const u8 {
267
+ var out: std.ArrayList(u8) = .empty;
268
+ errdefer out.deinit(allocator);
269
+ try out.appendSlice(allocator, "{\n \"name\": ");
270
+ try appendJsonString(&out, allocator, names.package_name);
271
+ try out.appendSlice(allocator,
272
+ \\,
273
+ \\ "private": true,
274
+ \\ "description": "Editor and versioning surface only: stock TypeScript tooling resolves @native-sdk/core from here. The native CLI never reads it and builds with node_modules absent.",
275
+ \\ "dependencies": {
276
+ \\ "@native-sdk/core":
277
+ );
278
+ try out.appendSlice(allocator, " ");
279
+ try appendJsonString(&out, allocator, sdk_version);
280
+ try out.appendSlice(allocator,
281
+ \\
282
+ \\ }
283
+ \\}
284
+ \\
285
+ );
286
+ return out.toOwnedSlice(allocator);
287
+ }
288
+
289
+ /// The editor tsconfig: the same compiler options the @native-sdk/core
290
+ /// checker builds its program with (typed_ast.ts subsetCompilerOptions), so
291
+ /// what the editor flags is what `native check` flags — minus the SDK
292
+ /// `paths` injection: editors resolve `@native-sdk/core` through
293
+ /// node_modules like any package.
294
+ fn tsTsconfig() []const u8 {
295
+ return
296
+ \\{
297
+ \\ // Mirrors the compiler options the @native-sdk/core checker enforces,
298
+ \\ // so editor diagnostics match `native check` reality. @native-sdk/core
299
+ \\ // resolves from node_modules: the native CLI materializes the SDK's
300
+ \\ // copy there (and keeps it fresh) until the package is on npm.
301
+ \\ "compilerOptions": {
302
+ \\ "strict": true,
303
+ \\ "target": "esnext",
304
+ \\ "module": "esnext",
305
+ \\ "moduleResolution": "bundler",
306
+ \\ "lib": ["esnext"],
307
+ \\ "types": [],
308
+ \\ "allowImportingTsExtensions": true,
309
+ \\ "verbatimModuleSyntax": true,
310
+ \\ "exactOptionalPropertyTypes": true,
311
+ \\ "noFallthroughCasesInSwitch": true,
312
+ \\ "isolatedModules": true,
313
+ \\ "noEmit": true,
314
+ \\ "skipLibCheck": true
315
+ \\ },
316
+ \\ "include": ["src/**/*.ts"]
317
+ \\}
318
+ \\
319
+ ;
320
+ }
321
+
322
+ /// TS scaffolds ignore node_modules on top of the slim set: the
323
+ /// @native-sdk/core copy in there is CLI-managed (npm-managed after
324
+ /// publish), never source. `.native/` stays: `native check` stages the
325
+ /// emitted core there for --full trees too.
326
+ fn tsGitignore() []const u8 {
327
+ return
328
+ \\.native/
329
+ \\zig-out/
330
+ \\.zig-cache/
331
+ \\node_modules/
332
+ \\
333
+ ;
334
+ }
335
+
336
+ /// The starter core: a counter with a repeating tick (Sub.timer) and a
337
+ /// timestamp request (Cmd.now) - one of each effect surface, small enough
338
+ /// to read whole.
339
+ fn tsCoreStarter() []const u8 {
340
+ return
341
+ \\// The app core: Model, Msg, update, and the pure helpers they call -
342
+ \\// plain TypeScript in the app-core subset, compiled to native Zig at
343
+ \\// build time (no JS runtime ships in the binary). The view lives in
344
+ \\// app.native and binds this model by its own field names exactly as
345
+ \\// written here (`tickCount` binds as `{tickCount}`).
346
+ \\//
347
+ \\// The loop: edit here -> `native dev --core` for instant logic checks
348
+ \\// under node -> `native dev` to run the real app. `native check`
349
+ \\// verifies this file and the markup together.
350
+ \\
351
+ \\import { Cmd, Sub } from "@native-sdk/core";
352
+ \\
353
+ \\export interface Model {
354
+ \\ readonly count: number;
355
+ \\ readonly ticking: boolean;
356
+ \\ readonly tickCount: number;
357
+ \\ readonly stampedMs: number;
358
+ \\}
359
+ \\
360
+ \\export type Msg =
361
+ \\ | { readonly kind: "increment" }
362
+ \\ | { readonly kind: "decrement" }
363
+ \\ | { readonly kind: "reset" }
364
+ \\ | { readonly kind: "toggle_ticking" }
365
+ \\ | { readonly kind: "stamp" }
366
+ \\ | { readonly kind: "stamped"; readonly at: number }
367
+ \\ | { readonly kind: "tick"; readonly at: number };
368
+ \\
369
+ \\// `tick` and `stamped` are dispatched by the host (timer fires and the
370
+ \\// Cmd.now result), never from markup - this list keeps `native check`'s
371
+ \\// unbound-state lint honest about that.
372
+ \\export const viewUnbound = ["tick", "stamped"] as const;
373
+ \\
374
+ \\export function initialModel(): Model {
375
+ \\ return { count: 0, ticking: false, tickCount: 0, stampedMs: -1 };
376
+ \\}
377
+ \\
378
+ \\// Exported single-model helpers become bindings too: `{total}` in
379
+ \\// app.native reads this.
380
+ \\export function total(model: Model): number {
381
+ \\ return model.count + model.tickCount;
382
+ \\}
383
+ \\
384
+ \\export function update(model: Model, msg: Msg): Model | [Model, Cmd<Msg>] {
385
+ \\ switch (msg.kind) {
386
+ \\ case "increment":
387
+ \\ return { ...model, count: model.count + 1 };
388
+ \\ case "decrement":
389
+ \\ return { ...model, count: model.count - 1 };
390
+ \\ case "reset":
391
+ \\ return { ...model, count: 0, tickCount: 0 };
392
+ \\ case "toggle_ticking":
393
+ \\ return { ...model, ticking: !model.ticking };
394
+ \\ case "stamp":
395
+ \\ // Effects are data: the host performs this after commit and
396
+ \\ // dispatches `stamped` with the time.
397
+ \\ return [model, Cmd.now("stamped")];
398
+ \\ case "stamped":
399
+ \\ return { ...model, stampedMs: msg.at };
400
+ \\ case "tick":
401
+ \\ return { ...model, tickCount: model.tickCount + 1 };
402
+ \\ }
403
+ \\}
404
+ \\
405
+ \\// Recurring effects are declared from the model: while `ticking` holds,
406
+ \\// the host fires `tick` every second; flip it off and the timer stops.
407
+ \\export function subscriptions(model: Model): Sub<Msg> {
408
+ \\ if (!model.ticking) return Sub.none;
409
+ \\ return Sub.timer("tick", 1000, "tick");
410
+ \\}
411
+ \\
412
+ ;
413
+ }
414
+
415
+ fn tsAppMarkup() []const u8 {
416
+ return
417
+ \\<!-- The whole view: markup over the core's emitted model. Embedded at
418
+ \\ build time and hot-reloaded while `native dev` runs. Fields bind
419
+ \\ by the names core.ts wrote ({tickCount}); exported single-model
420
+ \\ helpers bind too ({total}). Validate with: native check -->
421
+ \\<column gap="12" padding="16">
422
+ \\ <row gap="8" cross="center">
423
+ \\ <text grow="1">Counter</text>
424
+ \\ <button size="sm" variant="ghost" on-press="reset">Reset</button>
425
+ \\ </row>
426
+ \\ <row gap="8" main="center" cross="center" grow="1">
427
+ \\ <button variant="secondary" on-press="decrement">-</button>
428
+ \\ <text>{count}</text>
429
+ \\ <button variant="primary" on-press="increment">+</button>
430
+ \\ </row>
431
+ \\ <row gap="8" cross="center">
432
+ \\ <switch checked="{ticking}" on-toggle="toggle_ticking">Tick every second</switch>
433
+ \\ <text grow="1">ticks {tickCount}</text>
434
+ \\ <button size="sm" on-press="stamp">Stamp</button>
435
+ \\ </row>
436
+ \\ <status-bar>total: {total} | stamped: {stampedMs}ms</status-bar>
437
+ \\</column>
438
+ \\
439
+ ;
440
+ }
441
+
442
+ fn tsSlimReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8 {
443
+ var out: std.ArrayList(u8) = .empty;
444
+ errdefer out.deinit(allocator);
445
+ try out.appendSlice(allocator, "# ");
446
+ try out.appendSlice(allocator, names.display_name);
447
+ try out.appendSlice(allocator,
448
+ \\
449
+ \\
450
+ \\A native app authored in TypeScript and markup: the logic lives in
451
+ \\`src/core.ts` (Model, Msg, update - the app-core subset, compiled to
452
+ \\native code at build time; no JS runtime ships in the binary) and the
453
+ \\view in `src/app.native`. There is no Zig in this tree and nothing to
454
+ \\configure: the build detects `src/core.ts` and wires everything.
455
+ \\
456
+ \\## The loop
457
+ \\
458
+ \\```sh
459
+ \\native dev --core # fastest: run the core's logic under node -
460
+ \\ # dispatch messages as JSON lines, watch the model
461
+ \\ # and effect transcript (not a renderer)
462
+ \\native dev # build and run the real app (markup hot reload)
463
+ \\native check # verify core.ts (subset checker) + markup + app.zon
464
+ \\native build # ReleaseFast binary in zig-out/bin/
465
+ \\native test # the app's test suite
466
+ \\```
467
+ \\
468
+ \\Edit `src/core.ts` for behavior, `src/app.native` for the view, and
469
+ \\`app.zon` for windows/identity/permissions. Markup binds the model's
470
+ \\field names exactly as core.ts wrote them (`tickCount` -> `{tickCount}`),
471
+ \\and exported single-model helpers bind as derived values (`{total}`).
472
+ \\
473
+ \\## Try the core loop
474
+ \\
475
+ \\```sh
476
+ \\printf '%s\n' '{"kind":"increment"}' '{"kind":"toggle_ticking"}' '{"advance":3000}' | native dev --core
477
+ \\```
478
+ \\
479
+ \\## Editor support
480
+ \\
481
+ \\Stock editor TypeScript just works: `package.json` and `tsconfig.json`
482
+ \\are the editor-and-versioning surface (the tsconfig mirrors the checker's
483
+ \\own options, so editor errors match `native check`), and
484
+ \\`node_modules/@native-sdk/core` is a CLI-managed copy of the SDK package
485
+ \\so `@native-sdk/core` resolves with full IntelliSense. Builds never read
486
+ \\any of it — delete node_modules and every `native` verb still works; the
487
+ \\next `native check`/`dev`/`build` puts it back. Running `npm install`
488
+ \\is optional for the same reason: the CLI materializes and refreshes the
489
+ \\package itself, and an install simply lands the identical content once
490
+ \\`@native-sdk/core` is on npm.
491
+ \\
492
+ \\## Requirements
493
+ \\
494
+ \\Node.js 22+ on PATH (the TypeScript-to-native transpiler runs at build
495
+ \\time; your shipped binary carries none of it).
496
+ \\
497
+ );
498
+ return out.toOwnedSlice(allocator);
499
+ }
500
+
154
501
  fn slimNativeReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8 {
155
502
  var out: std.ArrayList(u8) = .empty;
156
503
  errdefer out.deinit(allocator);
@@ -205,7 +552,7 @@ fn writeNativeApp(allocator: std.mem.Allocator, io: std.Io, app_dir: std.Io.Dir,
205
552
  defer allocator.free(app_zon);
206
553
  const readme_md = try nativeReadme(allocator, names, framework_path);
207
554
  defer allocator.free(readme_md);
208
- const ci_yaml = try nativeCiYaml(allocator, names, framework_path);
555
+ const ci_yaml = try nativeCiYaml(allocator, names, framework_path, .zig);
209
556
  defer allocator.free(ci_yaml);
210
557
 
211
558
  try writeFile(app_dir, io, "build.zig", build_zig);
@@ -277,9 +624,11 @@ fn nativeMainZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
277
624
  var out: std.ArrayList(u8) = .empty;
278
625
  errdefer out.deinit(allocator);
279
626
  try out.appendSlice(allocator,
280
- \\//! A minimal native-rendered Native SDK app: the view lives in
281
- \\//! `app.native` (embedded into the binary, and watched for hot reload in
282
- \\//! dev); this file is the logic: `Model`, `Msg`, and `update`.
627
+ \\//! The app core in Zig: `Model`, `Msg`, and `update` - the same
628
+ \\//! counter-with-effects starter the TypeScript template builds. The view
629
+ \\//! lives in `app.native` (embedded into the binary, and watched for hot
630
+ \\//! reload in dev); recurring work and clock reads ride the effects
631
+ \\//! channel, so `update` stays a plain function of model + message.
283
632
  \\
284
633
  \\const std = @import("std");
285
634
  \\const runner = @import("runner");
@@ -319,17 +668,66 @@ fn nativeMainZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
319
668
  \\ increment,
320
669
  \\ decrement,
321
670
  \\ reset,
671
+ \\ toggle_ticking,
672
+ \\ stamp,
673
+ \\ tick: native_sdk.EffectTimer,
674
+ \\
675
+ \\ // `tick` is dispatched by the host (the repeating timer fires),
676
+ \\ // never from markup - this keeps the unbound-state lint honest
677
+ \\ // about that.
678
+ \\ pub const view_unbound = .{"tick"};
322
679
  \\};
323
680
  \\
324
681
  \\pub const Model = struct {
325
682
  \\ count: i64 = 0,
683
+ \\ ticking: bool = false,
684
+ \\ tick_count: i64 = 0,
685
+ \\ stamped_ms: i64 = -1,
686
+ \\
687
+ \\ // Public single-model helpers become bindings too: `{total}` in
688
+ \\ // app.native reads this.
689
+ \\ pub fn total(model: *const Model) i64 {
690
+ \\ return model.count + model.tick_count;
691
+ \\ }
326
692
  \\};
327
693
  \\
328
- \\pub fn update(model: *Model, msg: Msg) void {
694
+ \\pub const Effects = native_sdk.Effects(Msg);
695
+ \\
696
+ \\/// The repeating tick's effects-channel key: starting an active key
697
+ \\/// replaces the timer in place, so toggling never double-registers.
698
+ \\pub const tick_timer_key: u64 = 1;
699
+ \\
700
+ \\pub fn update(model: *Model, msg: Msg, fx: *Effects) void {
329
701
  \\ switch (msg) {
330
702
  \\ .increment => model.count += 1,
331
703
  \\ .decrement => model.count -= 1,
332
- \\ .reset => model.count = 0,
704
+ \\ .reset => {
705
+ \\ model.count = 0;
706
+ \\ model.tick_count = 0;
707
+ \\ },
708
+ \\ .toggle_ticking => {
709
+ \\ model.ticking = !model.ticking;
710
+ \\ // Recurring effects are timers on the effects channel: while
711
+ \\ // `ticking` holds, the host fires `tick` every second; flip
712
+ \\ // it off and the timer stops.
713
+ \\ if (model.ticking) {
714
+ \\ fx.startTimer(.{
715
+ \\ .key = tick_timer_key,
716
+ \\ .interval_ms = 1000,
717
+ \\ .mode = .repeating,
718
+ \\ .on_fire = Effects.timerMsg(.tick),
719
+ \\ });
720
+ \\ } else {
721
+ \\ fx.cancelTimer(tick_timer_key);
722
+ \\ }
723
+ \\ },
724
+ \\ // The journaled clock read - deterministic under session replay,
725
+ \\ // the Zig equivalent of the TypeScript starter's `Cmd.now`.
726
+ \\ .stamp => model.stamped_ms = fx.wallMs(),
727
+ \\ .tick => |timer| {
728
+ \\ if (timer.outcome != .fired) return;
729
+ \\ model.tick_count += 1;
730
+ \\ },
333
731
  \\ }
334
732
  \\}
335
733
  \\
@@ -360,7 +758,7 @@ fn nativeMainZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
360
758
  \\,
361
759
  \\ .scene = shell_scene,
362
760
  \\ .canvas_label = canvas_label,
363
- \\ .update = update,
761
+ \\ .update_fx = update,
364
762
  \\ .markup = .{ .source = app_markup, .watch_path = "src/app.native", .io = init.io },
365
763
  \\ });
366
764
  \\ defer app_state.destroy();
@@ -406,9 +804,11 @@ fn nativeMainZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
406
804
 
407
805
  fn nativeAppMarkup() []const u8 {
408
806
  return
409
- \\<!-- The whole view. Embedded into the binary and hot-reloaded in dev:
410
- \\ edit this file while the app runs and the window updates without
411
- \\ losing the count. Validate with: native markup check src/app.native -->
807
+ \\<!-- The whole view: markup over the core's model. Embedded into the
808
+ \\ binary and hot-reloaded in dev: edit this file while the app runs
809
+ \\ and the window updates without losing the count. Fields bind by
810
+ \\ the names main.zig wrote ({tick_count}); public single-model
811
+ \\ helpers bind too ({total}). Validate with: native check -->
412
812
  \\<column gap="12" padding="16">
413
813
  \\ <row gap="8" cross="center">
414
814
  \\ <text grow="1">Counter</text>
@@ -419,7 +819,12 @@ fn nativeAppMarkup() []const u8 {
419
819
  \\ <text>{count}</text>
420
820
  \\ <button variant="primary" on-press="increment">+</button>
421
821
  \\ </row>
422
- \\ <status-bar>count: {count}</status-bar>
822
+ \\ <row gap="8" cross="center">
823
+ \\ <switch checked="{ticking}" on-toggle="toggle_ticking">Tick every second</switch>
824
+ \\ <text grow="1">ticks {tick_count}</text>
825
+ \\ <button size="sm" on-press="stamp">Stamp</button>
826
+ \\ </row>
827
+ \\ <status-bar>total: {total} | stamped: {stamped_ms}ms</status-bar>
423
828
  \\</column>
424
829
  \\
425
830
  ;
@@ -440,6 +845,7 @@ fn nativeTestsZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u
440
845
  \\const AppUi = main.AppUi;
441
846
  \\const Model = main.Model;
442
847
  \\const Msg = main.Msg;
848
+ \\const Effects = main.Effects;
443
849
  \\
444
850
  \\const AppMarkup = canvas.MarkupView(Model, Msg);
445
851
  \\
@@ -481,37 +887,106 @@ fn nativeTestsZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u
481
887
  \\ defer arena_state.deinit();
482
888
  \\ const arena = arena_state.allocator();
483
889
  \\
890
+ \\ // A real effects channel in fake-executor mode: requests are
891
+ \\ // recorded for assertions instead of touching the OS.
892
+ \\ var fx = Effects.init(testing.allocator);
893
+ \\ defer fx.deinit();
894
+ \\ fx.executor = .fake;
895
+ \\
484
896
  \\ var model = main.initialModel();
485
897
  \\
486
898
  \\ var tree = try buildTree(arena, &model);
487
899
  \\ _ = try expectByText(tree.root, .text, "0");
488
- \\ _ = try expectByText(tree.root, .status_bar, "count: 0");
900
+ \\ _ = try expectByText(tree.root, .status_bar, "total: 0 | stamped: -1ms");
489
901
  \\
490
902
  \\ // Click "+": the count increments and the view rebuilds with the
491
903
  \\ // new value, keeping widget ids stable.
492
904
  \\ const plus = try expectByText(tree.root, .button, "+");
493
- \\ main.update(&model, tree.msgForPointer(plus.id, .up).?);
905
+ \\ main.update(&model, tree.msgForPointer(plus.id, .up).?, &fx);
494
906
  \\ try testing.expectEqual(@as(i64, 1), model.count);
495
907
  \\
496
908
  \\ tree = try buildTree(arena, &model);
497
909
  \\ _ = try expectByText(tree.root, .text, "1");
498
- \\ _ = try expectByText(tree.root, .status_bar, "count: 1");
910
+ \\ _ = try expectByText(tree.root, .status_bar, "total: 1 | stamped: -1ms");
499
911
  \\ try testing.expectEqual(plus.id, (try expectByText(tree.root, .button, "+")).id);
500
912
  \\
501
913
  \\ // Click "-" twice: the count goes negative.
502
914
  \\ const minus = try expectByText(tree.root, .button, "-");
503
- \\ main.update(&model, tree.msgForPointer(minus.id, .up).?);
504
- \\ main.update(&model, tree.msgForPointer(minus.id, .up).?);
915
+ \\ main.update(&model, tree.msgForPointer(minus.id, .up).?, &fx);
916
+ \\ main.update(&model, tree.msgForPointer(minus.id, .up).?, &fx);
505
917
  \\ try testing.expectEqual(@as(i64, -1), model.count);
506
918
  \\
507
- \\ // Click "Reset": back to zero.
919
+ \\ // Click "Reset": the count and the tick tally both go back to zero.
508
920
  \\ tree = try buildTree(arena, &model);
509
921
  \\ const reset = try expectByText(tree.root, .button, "Reset");
510
- \\ main.update(&model, tree.msgForPointer(reset.id, .up).?);
922
+ \\ main.update(&model, tree.msgForPointer(reset.id, .up).?, &fx);
511
923
  \\ try testing.expectEqual(@as(i64, 0), model.count);
512
924
  \\
513
925
  \\ tree = try buildTree(arena, &model);
514
- \\ _ = try expectByText(tree.root, .status_bar, "count: 0");
926
+ \\ _ = try expectByText(tree.root, .status_bar, "total: 0 | stamped: -1ms");
927
+ \\}
928
+ \\
929
+ \\test "the ticking switch drives the repeating timer through the effects channel" {
930
+ \\ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
931
+ \\ defer arena_state.deinit();
932
+ \\ const arena = arena_state.allocator();
933
+ \\
934
+ \\ var fx = Effects.init(testing.allocator);
935
+ \\ defer fx.deinit();
936
+ \\ fx.executor = .fake;
937
+ \\
938
+ \\ var model = main.initialModel();
939
+ \\ var tree = try buildTree(arena, &model);
940
+ \\
941
+ \\ // Flip the switch on: the model tracks it and one repeating 1s
942
+ \\ // timer is registered on the effects channel.
943
+ \\ const ticker = try expectByText(tree.root, .switch_control, "Tick every second");
944
+ \\ main.update(&model, tree.msgForPointer(ticker.id, .up).?, &fx);
945
+ \\ try testing.expect(model.ticking);
946
+ \\ try testing.expectEqual(@as(usize, 1), fx.pendingTimerCount());
947
+ \\ const request = fx.pendingTimerAt(0).?;
948
+ \\ try testing.expectEqual(main.tick_timer_key, request.key);
949
+ \\ try testing.expectEqual(@as(u64, 1000), request.interval_ms);
950
+ \\
951
+ \\ // Each timer fire arrives as an ordinary `tick` Msg through the
952
+ \\ // same update path as a click.
953
+ \\ main.update(&model, .{ .tick = .{ .key = main.tick_timer_key } }, &fx);
954
+ \\ main.update(&model, .{ .tick = .{ .key = main.tick_timer_key } }, &fx);
955
+ \\ try testing.expectEqual(@as(i64, 2), model.tick_count);
956
+ \\
957
+ \\ tree = try buildTree(arena, &model);
958
+ \\ _ = try expectByText(tree.root, .text, "ticks 2");
959
+ \\ _ = try expectByText(tree.root, .status_bar, "total: 2 | stamped: -1ms");
960
+ \\
961
+ \\ // Flip it off: the timer is cancelled, nothing left armed.
962
+ \\ main.update(&model, tree.msgForPointer(ticker.id, .up).?, &fx);
963
+ \\ try testing.expect(!model.ticking);
964
+ \\ try testing.expectEqual(@as(usize, 0), fx.pendingTimerCount());
965
+ \\}
966
+ \\
967
+ \\test "stamp reads the journaled wall clock" {
968
+ \\ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
969
+ \\ defer arena_state.deinit();
970
+ \\ const arena = arena_state.allocator();
971
+ \\
972
+ \\ var fx = Effects.init(testing.allocator);
973
+ \\ defer fx.deinit();
974
+ \\ fx.executor = .fake;
975
+ \\ // Swap the clock seam for a hand-cranked one: `fx.wallMs()`
976
+ \\ // becomes deterministic, exactly like session replay.
977
+ \\ var test_clock = native_sdk.TestClock{};
978
+ \\ test_clock.setWallMs(4200);
979
+ \\ fx.clock = test_clock.clock();
980
+ \\
981
+ \\ var model = main.initialModel();
982
+ \\ var tree = try buildTree(arena, &model);
983
+ \\
984
+ \\ const stamp = try expectByText(tree.root, .button, "Stamp");
985
+ \\ main.update(&model, tree.msgForPointer(stamp.id, .up).?, &fx);
986
+ \\ try testing.expectEqual(@as(i64, 4200), model.stamped_ms);
987
+ \\
988
+ \\ tree = try buildTree(arena, &model);
989
+ \\ _ = try expectByText(tree.root, .status_bar, "total: 0 | stamped: 4200ms");
515
990
  \\}
516
991
  \\
517
992
  \\test "the view lays out through the canvas engine" {
@@ -665,8 +1140,26 @@ fn nativeReadme(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
665
1140
  /// GitHub Actions workflow for a native-rendered app: a null-platform
666
1141
  /// logic-test job plus a Linux Xvfb automation smoke job that launches the
667
1142
  /// real binary and asserts on the accessibility snapshot. The generated
668
- /// file belongs to the user, like everything init writes.
669
- fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_path: []const u8) ![]const u8 {
1143
+ /// file belongs to the user, like everything init writes. A TypeScript
1144
+ /// core adds the node tier to both jobs: setup-node plus one `npm ci` in
1145
+ /// the fetched SDK's packages/core, because the @native-sdk/core
1146
+ /// transpiler runs under node at build time and needs its own installed
1147
+ /// dependency there — the same install `native build`'s teaching names.
1148
+ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_path: []const u8, core: CoreTemplate) ![]const u8 {
1149
+ const node_setup =
1150
+ \\ - uses: actions/setup-node@v4
1151
+ \\ with:
1152
+ \\ node-version: 22
1153
+ \\
1154
+ ;
1155
+ const transpiler_install =
1156
+ \\ - name: Install the core transpiler dependency
1157
+ \\ # src/core.ts compiles to native code at build time: the
1158
+ \\ # @native-sdk/core transpiler runs under node from the SDK
1159
+ \\ # dependency and needs its dependency installed there once.
1160
+ \\ run: npm ci --prefix "$NATIVE_SDK_PATH/packages/core"
1161
+ \\
1162
+ ;
670
1163
  var out: std.ArrayList(u8) = .empty;
671
1164
  errdefer out.deinit(allocator);
672
1165
  try out.appendSlice(allocator,
@@ -701,11 +1194,19 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
701
1194
  \\ - uses: mlugg/setup-zig@v2
702
1195
  \\ with:
703
1196
  \\ version: 0.16.0
1197
+ \\
1198
+ );
1199
+ if (core == .ts) try out.appendSlice(allocator, node_setup);
1200
+ try out.appendSlice(allocator,
704
1201
  \\ - name: Fetch native-sdk
705
1202
  \\ run: |
706
1203
  \\ if [ ! -f "$NATIVE_SDK_PATH/build.zig" ]; then
707
1204
  \\ git clone --depth 1 https://github.com/vercel-labs/native.git "$NATIVE_SDK_PATH"
708
1205
  \\ fi
1206
+ \\
1207
+ );
1208
+ if (core == .ts) try out.appendSlice(allocator, transpiler_install);
1209
+ try out.appendSlice(allocator,
709
1210
  \\ - run: zig build test -Dplatform=null
710
1211
  \\
711
1212
  \\ smoke:
@@ -716,13 +1217,25 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
716
1217
  \\ - uses: mlugg/setup-zig@v2
717
1218
  \\ with:
718
1219
  \\ version: 0.16.0
1220
+ \\
1221
+ );
1222
+ if (core == .ts) try out.appendSlice(allocator, node_setup);
1223
+ try out.appendSlice(allocator,
719
1224
  \\ - name: Install GTK and Xvfb
720
- \\ run: sudo apt-get update && sudo apt-get install -y libgtk-4-dev libwebkitgtk-6.0-dev xvfb
1225
+ \\ # No WebKitGTK dev package: this app declares no web use, so its
1226
+ \\ # Linux host compiles without the embedded web layer and never
1227
+ \\ # links WebKitGTK (install it alongside a .frontend block or
1228
+ \\ # the "webview" capability if the app grows web content).
1229
+ \\ run: sudo apt-get update && sudo apt-get install -y libgtk-4-dev xvfb
721
1230
  \\ - name: Fetch native-sdk
722
1231
  \\ run: |
723
1232
  \\ if [ ! -f "$NATIVE_SDK_PATH/build.zig" ]; then
724
1233
  \\ git clone --depth 1 https://github.com/vercel-labs/native.git "$NATIVE_SDK_PATH"
725
1234
  \\ fi
1235
+ \\
1236
+ );
1237
+ if (core == .ts) try out.appendSlice(allocator, transpiler_install);
1238
+ try out.appendSlice(allocator,
726
1239
  \\ - name: Build the Native SDK CLI
727
1240
  \\ run: cd "$NATIVE_SDK_PATH" && zig build
728
1241
  \\ - name: Build and drive the app headless
@@ -739,7 +1252,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
739
1252
  \\ pid=$!
740
1253
  \\ trap 'kill "$pid" >/dev/null 2>&1 || true' EXIT
741
1254
  \\ "$cli" automate wait
742
- \\ "$cli" automate assert 'gpu_nonblank=true' 'role=button name="Reset"' 'count: 0'
1255
+ \\ "$cli" automate assert 'gpu_nonblank=true' 'role=button name="Reset"' 'total: 0'
743
1256
  \\ "$cli" automate screenshot main-canvas
744
1257
  \\ test -s .zig-cache/native-sdk-automation/screenshot-main-canvas.png
745
1258
  \\
@@ -853,6 +1366,12 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
853
1366
  \\ chromium,
854
1367
  \\};
855
1368
  \\
1369
+ \\const WebLayerOption = enum {
1370
+ \\ auto,
1371
+ \\ include,
1372
+ \\ exclude,
1373
+ \\};
1374
+ \\
856
1375
  \\const PackageTarget = enum {
857
1376
  \\ macos,
858
1377
  \\ windows,
@@ -876,6 +1395,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
876
1395
  \\ const automation_enabled = b.option(bool, "automation", "Enable Native SDK automation artifacts") orelse false;
877
1396
  \\ const js_bridge_enabled = b.option(bool, "js-bridge", "Enable optional JavaScript bridge stubs") orelse false;
878
1397
  \\ const web_engine_override = b.option(WebEngineOption, "web-engine", "Override app.zon web engine: system, chromium");
1398
+ \\ const web_layer_override = b.option(WebLayerOption, "web-layer", "Override app.zon webview_layer: auto, include, exclude");
879
1399
  \\ const cef_dir_override = b.option([]const u8, "cef-dir", "Override CEF root directory for Chromium builds");
880
1400
  \\ const cef_auto_install_override = b.option(bool, "cef-auto-install", "Override app.zon CEF auto-install setting");
881
1401
  \\ const package_target = b.option(PackageTarget, "package-target", "Package target: macos, windows, linux") orelse .macos;
@@ -894,13 +1414,14 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
894
1414
  \\ if (selected_platform == .windows and target.result.os.tag != .windows) {
895
1415
  \\ @panic("-Dplatform=windows requires a Windows target");
896
1416
  \\ }
897
- \\ const app_web_engine = appWebEngineConfig();
898
- \\ const web_engine = web_engine_override orelse app_web_engine.web_engine;
899
- \\ const cef_dir = cef_dir_override orelse defaultCefDir(selected_platform, app_web_engine.cef_dir);
900
- \\ const cef_auto_install = cef_auto_install_override orelse app_web_engine.cef_auto_install;
1417
+ \\ const app_config = appManifestBuildConfig(b);
1418
+ \\ const web_engine = web_engine_override orelse app_config.web_engine;
1419
+ \\ const cef_dir = cef_dir_override orelse defaultCefDir(selected_platform, app_config.cef_dir);
1420
+ \\ const cef_auto_install = cef_auto_install_override orelse app_config.cef_auto_install;
901
1421
  \\ if (web_engine == .chromium and selected_platform != .macos) {
902
1422
  \\ @panic("-Dweb-engine=chromium currently requires -Dplatform=macos");
903
1423
  \\ }
1424
+ \\ const web_layer = resolveWebLayer(app_config, web_engine, web_layer_override);
904
1425
  \\
905
1426
  \\ const native_sdk_mod = nativeSdkModule(b, target, optimize, native_sdk_path);
906
1427
  \\ const options = b.addOptions();
@@ -916,6 +1437,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
916
1437
  \\ options.addOption(bool, "debug_overlay", debug_overlay);
917
1438
  \\ options.addOption(bool, "automation", automation_enabled);
918
1439
  \\ options.addOption(bool, "js_bridge", js_bridge_enabled);
1440
+ \\ options.addOption(bool, "web_layer", web_layer);
919
1441
  \\ const options_mod = options.createModule();
920
1442
  \\
921
1443
  \\ const runner_mod = localModule(b, target, optimize, "src/runner.zig");
@@ -930,7 +1452,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
930
1452
  \\ .name = app_exe_name,
931
1453
  \\ .root_module = app_mod,
932
1454
  \\ });
933
- \\ linkPlatform(b, target, app_mod, exe, selected_platform, web_engine, native_sdk_path, cef_dir, cef_auto_install);
1455
+ \\ linkPlatform(b, target, app_mod, exe, selected_platform, web_engine, web_layer, native_sdk_path, cef_dir, cef_auto_install);
934
1456
  \\ b.installArtifact(exe);
935
1457
  \\
936
1458
  \\ const frontend_install = b.addSystemCommand(&.{ "npm", "install", "--prefix", "frontend" });
@@ -945,13 +1467,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
945
1467
  \\ const run = b.addRunArtifact(exe);
946
1468
  \\ run.step.dependOn(&frontend_build.step);
947
1469
  \\ addCefRuntimeRunFiles(b, target, run, exe, web_engine, cef_dir);
948
- \\ addWebView2RuntimeRunFiles(b, target, run, web_engine, native_sdk_path);
1470
+ \\ addWebView2RuntimeRunFiles(b, target, run, web_engine, web_layer, native_sdk_path);
949
1471
  \\ const run_step = b.step("run", "Run the app");
950
1472
  \\ run_step.dependOn(&run.step);
951
1473
  \\
952
1474
  \\ const dev = b.addSystemCommand(&.{ "native", "dev", "--manifest", "app.zon", "--binary" });
953
1475
  \\ dev.addFileArg(exe.getEmittedBin());
954
- \\ addWebView2RuntimeRunFiles(b, target, dev, web_engine, native_sdk_path);
1476
+ \\ addWebView2RuntimeRunFiles(b, target, dev, web_engine, web_layer, native_sdk_path);
955
1477
  \\ dev.step.dependOn(&exe.step);
956
1478
  \\ dev.step.dependOn(&frontend_install.step);
957
1479
  \\ const dev_step = b.step("dev", "Run the frontend dev server and native shell");
@@ -982,6 +1504,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
982
1504
  \\ package.setEnvironmentVariable("NATIVE_SDK_PATH", b.pathFromRoot(native_sdk_path));
983
1505
  \\ package.addFileArg(exe.getEmittedBin());
984
1506
  \\ package.addArgs(&.{ "--web-engine", @tagName(web_engine), "--cef-dir", cef_dir });
1507
+ \\ // Forward the RESOLVED web-layer decision, never the raw inputs:
1508
+ \\ // this graph already decided web vs native-only for the exe it is
1509
+ \\ // packaging (app.zon declarations plus -Dweb-layer/-Dweb-engine),
1510
+ \\ // and the CLI re-inferring from app.zon alone would miss a
1511
+ \\ // flag-driven override. Handing over the decision itself makes
1512
+ \\ // exe/package agreement structural.
1513
+ \\ package.addArgs(&.{ "--web-layer", if (web_layer) "include" else "exclude" });
985
1514
  \\ if (cef_auto_install) package.addArg("--cef-auto-install");
986
1515
  \\ package.step.dependOn(&exe.step);
987
1516
  \\ package.step.dependOn(&frontend_build.step);
@@ -1074,7 +1603,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1074
1603
  \\ });
1075
1604
  \\}
1076
1605
  \\
1077
- \\fn linkPlatform(b: *std.Build, target: std.Build.ResolvedTarget, app_mod: *std.Build.Module, exe: *std.Build.Step.Compile, platform: PlatformOption, web_engine: WebEngineOption, native_sdk_path: []const u8, cef_dir: []const u8, cef_auto_install: bool) void {
1606
+ \\fn linkPlatform(b: *std.Build, target: std.Build.ResolvedTarget, app_mod: *std.Build.Module, exe: *std.Build.Step.Compile, platform: PlatformOption, web_engine: WebEngineOption, web_layer: bool, native_sdk_path: []const u8, cef_dir: []const u8, cef_auto_install: bool) void {
1078
1607
  \\ if (platform == .macos) {
1079
1608
  \\ switch (web_engine) {
1080
1609
  \\ .system => {
@@ -1121,11 +1650,23 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1121
1650
  \\ if (web_engine == .chromium) app_mod.linkSystemLibrary("c++", .{});
1122
1651
  \\ } else if (platform == .linux) {
1123
1652
  \\ switch (web_engine) {
1124
- \\ .system => {
1653
+ \\ .system => if (web_layer) {
1125
1654
  \\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/linux/gtk_host.c"), .flags = &.{} });
1126
1655
  \\ app_mod.linkSystemLibrary("gtk4", .{});
1127
1656
  \\ app_mod.linkSystemLibrary("webkitgtk-6.0", .{});
1128
1657
  \\ app_mod.linkSystemLibrary("dl", .{});
1658
+ \\ } else {
1659
+ \\ // Native-only app (nothing in app.zon declares web use):
1660
+ \\ // compile the GTK host without the embedded web layer.
1661
+ \\ // The stub define excludes the layer outright — the host
1662
+ \\ // honors it before probing for the WebKitGTK header, so
1663
+ \\ // the layer stays out even on machines where the
1664
+ \\ // development package is installed — libwebkitgtk is
1665
+ \\ // neither linked nor required at runtime, and the
1666
+ \\ // executable carries no WebKit reference at all.
1667
+ \\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/linux/gtk_host.c"), .flags = &.{"-DNATIVE_SDK_ALLOW_WEBKITGTK_STUB"} });
1668
+ \\ app_mod.linkSystemLibrary("gtk4", .{});
1669
+ \\ app_mod.linkSystemLibrary("dl", .{});
1129
1670
  \\ },
1130
1671
  \\ .chromium => {
1131
1672
  \\ const cef_check = addCefCheck(b, target, cef_dir);
@@ -1147,7 +1688,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1147
1688
  \\ if (web_engine == .chromium) app_mod.linkSystemLibrary("stdc++", .{});
1148
1689
  \\ } else if (platform == .windows) {
1149
1690
  \\ switch (web_engine) {
1150
- \\ .system => {
1691
+ \\ .system => if (web_layer) {
1151
1692
  \\ // The vendored WebView2 SDK header (third_party/webview2)
1152
1693
  \\ // turns on the host's embedded-WebView layer; the host
1153
1694
  \\ // fails the compile by design if it cannot be found.
@@ -1159,6 +1700,16 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1159
1700
  \\ // touch it.
1160
1701
  \\ const loader = b.addInstallBinFile(nativeSdkPath(b, native_sdk_path, webView2LoaderSubPath(target)), "WebView2Loader.dll");
1161
1702
  \\ b.getInstallStep().dependOn(&loader.step);
1703
+ \\ } else {
1704
+ \\ // Native-only app (nothing in app.zon declares web use):
1705
+ \\ // compile the host without the embedded-WebView layer.
1706
+ \\ // The stub define excludes the layer outright — the host
1707
+ \\ // honors it before probing for the WebView2 header, so
1708
+ \\ // the layer stays out even on machines where the SDK
1709
+ \\ // headers are reachable through the system include paths
1710
+ \\ // — no WebView2Loader.dll is installed or path-wired,
1711
+ \\ // and the executable carries no reference to it at all.
1712
+ \\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/windows/webview2_host.cpp"), .flags = &.{ "-std=c++17", "-DNATIVE_SDK_ALLOW_WEBVIEW2_STUB" } });
1162
1713
  \\ },
1163
1714
  \\ .chromium => {
1164
1715
  \\ const cef_check = addCefCheck(b, target, cef_dir);
@@ -1204,9 +1755,11 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1204
1755
  \\/// `zig build run` and `zig build dev` execute the cached artifact, which
1205
1756
  \\/// has no installed WebView2Loader.dll beside it; the vendored loader's
1206
1757
  \\/// directory goes on the step's PATH so the host's LoadLibrary resolves it
1207
- \\/// (`native dev` passes its environment on to the app it spawns).
1208
- \\fn addWebView2RuntimeRunFiles(b: *std.Build, target: std.Build.ResolvedTarget, run: *std.Build.Step.Run, web_engine: WebEngineOption, native_sdk_path: []const u8) void {
1758
+ \\/// (`native dev` passes its environment on to the app it spawns). A
1759
+ \\/// native-only build never loads the library, so its PATH stays clean.
1760
+ \\fn addWebView2RuntimeRunFiles(b: *std.Build, target: std.Build.ResolvedTarget, run: *std.Build.Step.Run, web_engine: WebEngineOption, web_layer: bool, native_sdk_path: []const u8) void {
1209
1761
  \\ if (web_engine != .system) return;
1762
+ \\ if (!web_layer) return;
1210
1763
  \\ if (target.result.os.tag != .windows) return;
1211
1764
  \\ const loader_dir = std.fs.path.dirname(webView2LoaderSubPath(target)).?;
1212
1765
  \\ run.addPathDir(b.pathFromRoot(b.pathJoin(&.{ native_sdk_path, loader_dir })));
@@ -1280,10 +1833,42 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1280
1833
  \\ };
1281
1834
  \\}
1282
1835
  \\
1283
- \\const AppWebEngineConfig = struct {
1836
+ \\/// What this build graph reads out of app.zon: the web-engine/CEF
1837
+ \\/// knobs and the web-layer inference inputs. An unreadable or
1838
+ \\/// unparsable manifest falls back to the system engine WITH the web
1839
+ \\/// layer kept — over-inclusion is a size cost, wrong exclusion is a
1840
+ \\/// broken app.
1841
+ \\const AppManifestBuildConfig = struct {
1284
1842
  \\ web_engine: WebEngineOption = .system,
1285
1843
  \\ cef_dir: []const u8 = "third_party/cef/macos",
1286
1844
  \\ cef_auto_install: bool = false,
1845
+ \\ webview_layer: WebLayerOption = .auto,
1846
+ \\ /// The first web declaration found (for teaching messages), or
1847
+ \\ /// null when app.zon declares no web use. `web_engine = "system"`
1848
+ \\ /// alone is NOT web intent — it is the default in many canvas
1849
+ \\ /// manifests.
1850
+ \\ web_declaration: ?[]const u8 = null,
1851
+ \\};
1852
+ \\
1853
+ \\/// The lenient app.zon shape parsed for inference: only the fields
1854
+ \\/// that decide the web layer and the web engine; everything else is
1855
+ \\/// ignored. Full schema validation stays with `native validate`.
1856
+ \\const InferenceManifest = struct {
1857
+ \\ capabilities: []const []const u8 = &.{},
1858
+ \\ web_engine: []const u8 = "system",
1859
+ \\ webview_layer: []const u8 = "auto",
1860
+ \\ cef: struct {
1861
+ \\ dir: []const u8 = "third_party/cef/macos",
1862
+ \\ auto_install: bool = false,
1863
+ \\ } = .{},
1864
+ \\ frontend: ?struct {} = null,
1865
+ \\ shell: struct {
1866
+ \\ windows: []const struct {
1867
+ \\ views: []const struct {
1868
+ \\ kind: []const u8 = "",
1869
+ \\ } = &.{},
1870
+ \\ } = &.{},
1871
+ \\ } = .{},
1287
1872
  \\};
1288
1873
  \\
1289
1874
  \\fn defaultCefDir(platform: PlatformOption, configured: []const u8) []const u8 {
@@ -1295,58 +1880,74 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1295
1880
  \\ };
1296
1881
  \\}
1297
1882
  \\
1298
- \\fn appWebEngineConfig() AppWebEngineConfig {
1299
- \\ const source = @embedFile("app.zon");
1300
- \\ var config: AppWebEngineConfig = .{};
1301
- \\ if (stringField(source, ".web_engine")) |value| {
1302
- \\ config.web_engine = parseWebEngine(value) orelse .system;
1303
- \\ }
1304
- \\ if (objectSection(source, ".cef")) |cef| {
1305
- \\ if (stringField(cef, ".dir")) |value| config.cef_dir = value;
1306
- \\ if (boolField(cef, ".auto_install")) |value| config.cef_auto_install = value;
1307
- \\ }
1883
+ \\fn appManifestBuildConfig(b: *std.Build) AppManifestBuildConfig {
1884
+ \\ // The fallback for a manifest this lenient parse cannot read
1885
+ \\ // keeps the web layer (see AppManifestBuildConfig): a shape
1886
+ \\ // mismatch here is not proof the app declares no web use.
1887
+ \\ const fallback: AppManifestBuildConfig = .{ .web_declaration = "an app.zon this build graph could not parse" };
1888
+ \\ const source: [:0]const u8 = @embedFile("app.zon");
1889
+ \\ @setEvalBranchQuota(2000);
1890
+ \\ const raw = std.zon.parse.fromSliceAlloc(InferenceManifest, b.allocator, source, null, .{ .ignore_unknown_fields = true }) catch return fallback;
1891
+ \\ var config: AppManifestBuildConfig = .{
1892
+ \\ .web_engine = parseWebEngine(raw.web_engine) orelse .system,
1893
+ \\ .cef_dir = raw.cef.dir,
1894
+ \\ .cef_auto_install = raw.cef.auto_install,
1895
+ \\ .webview_layer = parseWebLayer(raw.webview_layer) orelse @panic("app.zon .webview_layer must be \"auto\", \"include\", or \"exclude\""),
1896
+ \\ };
1897
+ \\ config.web_declaration = blk: {
1898
+ \\ if (raw.frontend != null) break :blk "a .frontend block";
1899
+ \\ for (raw.capabilities) |capability| {
1900
+ \\ if (std.mem.eql(u8, capability, "webview")) break :blk "the \"webview\" capability";
1901
+ \\ }
1902
+ \\ for (raw.shell.windows) |window| {
1903
+ \\ for (window.views) |view| {
1904
+ \\ if (std.mem.eql(u8, view.kind, "webview")) break :blk "a .shell webview view";
1905
+ \\ }
1906
+ \\ }
1907
+ \\ break :blk null;
1908
+ \\ };
1308
1909
  \\ return config;
1309
1910
  \\}
1310
1911
  \\
1912
+ \\/// The web-layer decision for this build — the same declare-to-use
1913
+ \\/// contract the Native SDK's standard build graph, CLI, and runner
1914
+ \\/// apply: an app is WEB when app.zon declares web use (a .frontend
1915
+ \\/// block, the "webview" capability, a .shell webview view) or the
1916
+ \\/// build resolves to the Chromium engine; otherwise it is
1917
+ \\/// NATIVE-ONLY and the platform host compiles without the
1918
+ \\/// embedded-WebView layer. `.webview_layer` (and `-Dweb-layer`)
1919
+ \\/// override the inference — but an exclude that contradicts a web
1920
+ \\/// declaration is a hard configure error, never a silently broken
1921
+ \\/// app.
1922
+ \\fn resolveWebLayer(config: AppManifestBuildConfig, web_engine: WebEngineOption, override: ?WebLayerOption) bool {
1923
+ \\ const setting = override orelse config.webview_layer;
1924
+ \\ const declaration: ?[]const u8 = config.web_declaration orelse
1925
+ \\ (if (web_engine == .chromium) "the Chromium web engine" else null);
1926
+ \\ return switch (setting) {
1927
+ \\ .include => true,
1928
+ \\ .auto => declaration != null,
1929
+ \\ .exclude => {
1930
+ \\ if (declaration) |reason| {
1931
+ \\ std.debug.panic(
1932
+ \\ "the web layer is excluded ({s}) but the app declares web use ({s}); remove the exclude or drop the web declaration",
1933
+ \\ .{ if (override != null) "-Dweb-layer=exclude" else "app.zon .webview_layer = \"exclude\"", reason },
1934
+ \\ );
1935
+ \\ }
1936
+ \\ return false;
1937
+ \\ },
1938
+ \\ };
1939
+ \\}
1940
+ \\
1311
1941
  \\fn parseWebEngine(value: []const u8) ?WebEngineOption {
1312
1942
  \\ if (std.mem.eql(u8, value, "system")) return .system;
1313
1943
  \\ if (std.mem.eql(u8, value, "chromium")) return .chromium;
1314
1944
  \\ return null;
1315
1945
  \\}
1316
1946
  \\
1317
- \\fn stringField(source: []const u8, field: []const u8) ?[]const u8 {
1318
- \\ const field_index = std.mem.indexOf(u8, source, field) orelse return null;
1319
- \\ const equals = std.mem.indexOfScalarPos(u8, source, field_index, '=') orelse return null;
1320
- \\ const start_quote = std.mem.indexOfScalarPos(u8, source, equals, '"') orelse return null;
1321
- \\ const end_quote = std.mem.indexOfScalarPos(u8, source, start_quote + 1, '"') orelse return null;
1322
- \\ return source[start_quote + 1 .. end_quote];
1323
- \\}
1324
- \\
1325
- \\fn objectSection(source: []const u8, field: []const u8) ?[]const u8 {
1326
- \\ const field_index = std.mem.indexOf(u8, source, field) orelse return null;
1327
- \\ const open = std.mem.indexOfScalarPos(u8, source, field_index, '{') orelse return null;
1328
- \\ var depth: usize = 0;
1329
- \\ var index = open;
1330
- \\ while (index < source.len) : (index += 1) {
1331
- \\ switch (source[index]) {
1332
- \\ '{' => depth += 1,
1333
- \\ '}' => {
1334
- \\ depth -= 1;
1335
- \\ if (depth == 0) return source[open + 1 .. index];
1336
- \\ },
1337
- \\ else => {},
1338
- \\ }
1339
- \\ }
1340
- \\ return null;
1341
- \\}
1342
- \\
1343
- \\fn boolField(source: []const u8, field: []const u8) ?bool {
1344
- \\ const field_index = std.mem.indexOf(u8, source, field) orelse return null;
1345
- \\ const equals = std.mem.indexOfScalarPos(u8, source, field_index, '=') orelse return null;
1346
- \\ var index = equals + 1;
1347
- \\ while (index < source.len and std.ascii.isWhitespace(source[index])) : (index += 1) {}
1348
- \\ if (std.mem.startsWith(u8, source[index..], "true")) return true;
1349
- \\ if (std.mem.startsWith(u8, source[index..], "false")) return false;
1947
+ \\fn parseWebLayer(value: []const u8) ?WebLayerOption {
1948
+ \\ if (std.mem.eql(u8, value, "auto")) return .auto;
1949
+ \\ if (std.mem.eql(u8, value, "include")) return .include;
1950
+ \\ if (std.mem.eql(u8, value, "exclude")) return .exclude;
1350
1951
  \\ return null;
1351
1952
  \\}
1352
1953
  \\
@@ -1516,6 +2117,7 @@ fn runnerZig() []const u8 {
1516
2117
  \\ fn appInfo(self: RunOptions, buffers: *StateBuffers) native_sdk.AppInfo {
1517
2118
  \\ var info: native_sdk.AppInfo = .{
1518
2119
  \\ .app_name = self.app_name,
2120
+ \\ .has_web_content = manifestHasWebContent(),
1519
2121
  \\ .window_title = self.window_title,
1520
2122
  \\ .bundle_id = self.bundle_id,
1521
2123
  \\ .icon_path = self.icon_path,
@@ -1766,6 +2368,7 @@ fn runnerZig() []const u8 {
1766
2368
  \\ .builtin_bridge = options.builtin_bridge,
1767
2369
  \\ .security = options.security,
1768
2370
  \\ .js_window_api = options.js_window_api,
2371
+ \\ .web_layer = webLayerEnabled(),
1769
2372
  \\ .commands = commands,
1770
2373
  \\ .menus = menus,
1771
2374
  \\ .shortcuts = shortcuts,
@@ -1815,6 +2418,7 @@ fn runnerZig() []const u8 {
1815
2418
  \\ .builtin_bridge = options.builtin_bridge,
1816
2419
  \\ .security = options.security,
1817
2420
  \\ .js_window_api = options.js_window_api,
2421
+ \\ .web_layer = webLayerEnabled(),
1818
2422
  \\ .commands = commands,
1819
2423
  \\ .menus = menus,
1820
2424
  \\ .shortcuts = shortcuts,
@@ -1864,6 +2468,7 @@ fn runnerZig() []const u8 {
1864
2468
  \\ .builtin_bridge = options.builtin_bridge,
1865
2469
  \\ .security = options.security,
1866
2470
  \\ .js_window_api = options.js_window_api,
2471
+ \\ .web_layer = webLayerEnabled(),
1867
2472
  \\ .commands = commands,
1868
2473
  \\ .menus = menus,
1869
2474
  \\ .shortcuts = shortcuts,
@@ -1913,6 +2518,7 @@ fn runnerZig() []const u8 {
1913
2518
  \\ .builtin_bridge = options.builtin_bridge,
1914
2519
  \\ .security = options.security,
1915
2520
  \\ .js_window_api = options.js_window_api,
2521
+ \\ .web_layer = webLayerEnabled(),
1916
2522
  \\ .commands = commands,
1917
2523
  \\ .menus = menus,
1918
2524
  \\ .shortcuts = shortcuts,
@@ -1936,6 +2542,48 @@ fn runnerZig() []const u8 {
1936
2542
  \\ return .system;
1937
2543
  \\}
1938
2544
  \\
2545
+ \\/// Whether app.zon declares web content — the shared declare-to-use
2546
+ \\/// contract (native_sdk.app_manifest.web_layer) over the comptime
2547
+ \\/// manifest import: a .frontend block, the "webview" capability, a
2548
+ \\/// .shell webview view, or .web_engine = "chromium". Hosts build
2549
+ \\/// honest default menus from this — web items like Reload only exist
2550
+ \\/// when a webview can answer them.
2551
+ \\fn manifestHasWebContent() bool {
2552
+ \\ return manifestWebDeclaration() != null;
2553
+ \\}
2554
+ \\
2555
+ \\/// The first web declaration visible in app.zon, evaluated at
2556
+ \\/// comptime. The engine input is the MANIFEST engine: the runner
2557
+ \\/// never sees the -Dweb-engine flag, so an engine resolved to
2558
+ \\/// Chromium by flag alone stays a configure-time error in build.zig,
2559
+ \\/// which does see the flag.
2560
+ \\fn manifestWebDeclaration() ?native_sdk.app_manifest.web_layer.Declaration {
2561
+ \\ const engine: native_sdk.app_manifest.WebEngine = comptime blk: {
2562
+ \\ if (!@hasField(@TypeOf(app_manifest), "web_engine")) break :blk .system;
2563
+ \\ break :blk native_sdk.app_manifest.web_layer.parseWebEngine(app_manifest.web_engine) orelse .system;
2564
+ \\ };
2565
+ \\ return comptime native_sdk.app_manifest.web_layer.webDeclaration(app_manifest, engine);
2566
+ \\}
2567
+ \\
2568
+ \\/// Whether this build ships the embedded web layer (build.zig's
2569
+ \\/// -Dweb-layer inference); a build_options module that predates the
2570
+ \\/// option keeps the layer — over-inclusion is safe.
2571
+ \\fn webLayerEnabled() bool {
2572
+ \\ if (comptime !@hasDecl(build_options, "web_layer")) return true;
2573
+ \\ return build_options.web_layer;
2574
+ \\}
2575
+ \\
2576
+ \\// A build that excludes the web layer while app.zon declares web use
2577
+ \\// must fail at compile time: the declared webviews of a layerless
2578
+ \\// host would otherwise only fail later, at runtime.
2579
+ \\comptime {
2580
+ \\ if (!webLayerEnabled()) {
2581
+ \\ if (manifestWebDeclaration()) |declaration| {
2582
+ \\ @compileError("this build excludes the web layer (-Dweb-layer=exclude) but app.zon declares web use (" ++ declaration.text() ++ "); remove the exclude or drop the web declaration");
2583
+ \\ }
2584
+ \\ }
2585
+ \\}
2586
+ \\
1939
2587
  \\const StateBuffers = struct {
1940
2588
  \\ state_dir: [1024]u8 = undefined,
1941
2589
  \\ file_path: [1200]u8 = undefined,
@@ -2875,13 +3523,32 @@ test "writeDefaultApp emits Vite project files" {
2875
3523
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "frontend_build.step.dependOn(&frontend_install.step)") != null);
2876
3524
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "\"native\", \"dev\"") != null);
2877
3525
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "dev.step.dependOn(&frontend_install.step)") != null);
2878
- try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "addWebView2RuntimeRunFiles(b, target, dev, web_engine, native_sdk_path)") != null);
3526
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "addWebView2RuntimeRunFiles(b, target, dev, web_engine, web_layer, native_sdk_path)") != null);
2879
3527
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "package.setEnvironmentVariable(\"NATIVE_SDK_PATH\", b.pathFromRoot(native_sdk_path))") != null);
2880
3528
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "chromium") != null);
2881
3529
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "cef-dir") != null);
2882
3530
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "src/platform/macos/cef_host.mm") != null);
2883
3531
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "src/platform/linux/gtk_host.c") != null);
2884
3532
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "app_manifest_zon") != null);
3533
+ // The generated graph carries the whole web-layer feature: the
3534
+ // override option, the app.zon inference with its conflict panic,
3535
+ // the option handed to the runner, and the conditional WebView2
3536
+ // wiring (include + source + loader when web, stubbed host and no
3537
+ // loader when native-only).
3538
+ 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);
3539
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "const web_layer = resolveWebLayer(app_config, web_engine, web_layer_override)") != null);
3540
+ // The emitted package step forwards the graph's resolved decision so
3541
+ // the packaged artifact structurally agrees with the compiled exe.
3542
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "package.addArgs(&.{ \"--web-layer\", if (web_layer) \"include\" else \"exclude\" })") != null);
3543
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "options.addOption(bool, \"web_layer\", web_layer)") != null);
3544
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "std.zon.parse.fromSliceAlloc(InferenceManifest") != null);
3545
+ 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);
3546
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, ".system => if (web_layer) {") != null);
3547
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "\"-DNATIVE_SDK_ALLOW_WEBVIEW2_STUB\"") != null);
3548
+ // The Linux seam mirrors it: gtk_host.c compiles with the WebKitGTK
3549
+ // stub define and webkitgtk-6.0 is not linked when native-only.
3550
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "\"-DNATIVE_SDK_ALLOW_WEBKITGTK_STUB\"") != null);
3551
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "if (!web_layer) return;") != null);
2885
3552
  try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "frontend/dist") != null);
2886
3553
  try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "127.0.0.1:5173") != null);
2887
3554
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@import(\"app_manifest_zon\")") != null);
@@ -2902,6 +3569,13 @@ test "writeDefaultApp emits Vite project files" {
2902
3569
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "defer std.heap.page_allocator.destroy(runtime)") != null);
2903
3570
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "native_sdk.Runtime.initAt(runtime, .{") != null);
2904
3571
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "Runtime.init(.{") == null);
3572
+ // The generated runner consumes the same web-layer contract: the
3573
+ // shared inference for honest menus, the build option threaded into
3574
+ // every runtime init, and the comptime conflict guard.
3575
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".has_web_content = manifestHasWebContent()") != null);
3576
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "native_sdk.app_manifest.web_layer.webDeclaration(app_manifest, engine)") != null);
3577
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".web_layer = webLayerEnabled(),") != null);
3578
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@compileError(\"this build excludes the web layer") != null);
2905
3579
  try std.testing.expect(std.mem.indexOf(u8, package_json_text, "\"vite\"") != null);
2906
3580
  try std.testing.expect(std.mem.indexOf(u8, main_js_text, "window.zero") != null);
2907
3581
 
@@ -2936,14 +3610,113 @@ test "writeDefaultApp emits frontend-specific Next paths" {
2936
3610
  try std.testing.expect(std.mem.indexOf(u8, tsconfig_text, "\"@/*\": [\"./app/*\"]") != null);
2937
3611
  }
2938
3612
 
2939
- test "writeDefaultApp emits a slim native scaffold by default" {
2940
- const destination = ".zig-cache/test-native-slim-template";
3613
+ test "writeDefaultApp emits the TS-core scaffold by default: three files of truth, zero Zig" {
3614
+ const destination = ".zig-cache/test-ts-slim-template";
2941
3615
  try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native });
2942
3616
 
3617
+ const core_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "src/core.ts");
3618
+ defer std.testing.allocator.free(core_text);
3619
+ const markup_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "src/app.native");
3620
+ defer std.testing.allocator.free(markup_text);
3621
+ const ts_app_zon = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.zon");
3622
+ defer std.testing.allocator.free(ts_app_zon);
3623
+ const ts_readme = try readTestFile(std.testing.allocator, std.testing.io, destination, "README.md");
3624
+ defer std.testing.allocator.free(ts_readme);
3625
+
3626
+ // ZERO Zig in the tree, no build files: the build graph detects
3627
+ // src/core.ts and stages the wiring outside the app. Zero-config
3628
+ // parity with the slim Zig scaffold: no CI workflow either — the
3629
+ // full shape owns that surface.
3630
+ try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "src/main.zig"));
3631
+ try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig"));
3632
+ try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, ".github/workflows/ci.yml"));
3633
+
3634
+ // The starter uses one Cmd and one Sub, declares the lint opt-out, and
3635
+ // exports a bindable helper.
3636
+ try std.testing.expect(std.mem.indexOf(u8, core_text, "Cmd.now(") != null);
3637
+ try std.testing.expect(std.mem.indexOf(u8, core_text, "Sub.timer(") != null);
3638
+ try std.testing.expect(std.mem.indexOf(u8, core_text, "export const viewUnbound") != null);
3639
+ try std.testing.expect(std.mem.indexOf(u8, core_text, "export function total(") != null);
3640
+ // The markup binds the model's own TS field names and the helper.
3641
+ try std.testing.expect(std.mem.indexOf(u8, markup_text, "{tickCount}") != null);
3642
+ try std.testing.expect(std.mem.indexOf(u8, markup_text, "{total}") != null);
3643
+ try std.testing.expect(std.mem.indexOf(u8, ts_app_zon, "gpu_surface") != null);
3644
+ // The README teaches the loop, node-first.
3645
+ try std.testing.expect(std.mem.indexOf(u8, ts_readme, "native dev --core") != null);
3646
+ try std.testing.expect(std.mem.indexOf(u8, ts_readme, "native check") != null);
3647
+
3648
+ // The editor surface: package.json pins @native-sdk/core at the SDK's
3649
+ // bundled version, tsconfig.json mirrors the checker's options, and
3650
+ // node_modules carries the materialized SDK package so stock tsc
3651
+ // resolves both entry points before the npm publish exists.
3652
+ const package_json = try readTestFile(std.testing.allocator, std.testing.io, destination, "package.json");
3653
+ defer std.testing.allocator.free(package_json);
3654
+ try std.testing.expect(std.mem.indexOf(u8, package_json, "\"name\": \"my-app\"") != null);
3655
+ try std.testing.expect(std.mem.indexOf(u8, package_json, "\"private\": true") != null);
3656
+ const bundled_version = try ts_core.bundledSdkVersion(std.testing.allocator, std.testing.io, ".");
3657
+ defer std.testing.allocator.free(bundled_version);
3658
+ const pinned = try std.fmt.allocPrint(std.testing.allocator, "\"@native-sdk/core\": \"{s}\"", .{bundled_version});
3659
+ defer std.testing.allocator.free(pinned);
3660
+ try std.testing.expect(std.mem.indexOf(u8, package_json, pinned) != null);
3661
+
3662
+ const tsconfig = try readTestFile(std.testing.allocator, std.testing.io, destination, "tsconfig.json");
3663
+ defer std.testing.allocator.free(tsconfig);
3664
+ try std.testing.expect(std.mem.indexOf(u8, tsconfig, "\"strict\": true") != null);
3665
+ try std.testing.expect(std.mem.indexOf(u8, tsconfig, "\"moduleResolution\": \"bundler\"") != null);
3666
+ try std.testing.expect(std.mem.indexOf(u8, tsconfig, "\"noEmit\": true") != null);
3667
+ try std.testing.expect(std.mem.indexOf(u8, tsconfig, "\"exactOptionalPropertyTypes\": true") != null);
3668
+
3669
+ const editor_manifest = try readTestFile(std.testing.allocator, std.testing.io, destination, "node_modules/@native-sdk/core/package.json");
3670
+ defer std.testing.allocator.free(editor_manifest);
3671
+ try std.testing.expect(std.mem.indexOf(u8, editor_manifest, "\"@native-sdk/core\"") != null);
3672
+ const editor_core = try readTestFile(std.testing.allocator, std.testing.io, destination, "node_modules/@native-sdk/core/sdk/core.ts");
3673
+ defer std.testing.allocator.free(editor_core);
3674
+ try std.testing.expect(editor_core.len > 0);
3675
+ const editor_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "node_modules/@native-sdk/core/sdk/text.ts");
3676
+ defer std.testing.allocator.free(editor_text);
3677
+ try std.testing.expect(editor_text.len > 0);
3678
+ const editor_events = try readTestFile(std.testing.allocator, std.testing.io, destination, "node_modules/@native-sdk/core/sdk/events.ts");
3679
+ defer std.testing.allocator.free(editor_events);
3680
+ try std.testing.expect(editor_events.len > 0);
3681
+
3682
+ // node_modules is generated surface: ignored, never source.
3683
+ const ts_gitignore = try readTestFile(std.testing.allocator, std.testing.io, destination, ".gitignore");
3684
+ defer std.testing.allocator.free(ts_gitignore);
3685
+ try std.testing.expect(std.mem.indexOf(u8, ts_gitignore, "node_modules/") != null);
3686
+ try std.testing.expect(std.mem.indexOf(u8, ts_gitignore, ".native/") != null);
3687
+ }
3688
+
3689
+ test "writeDefaultApp --full ts-core carries the same editor surface" {
3690
+ const destination = ".zig-cache/test-ts-full-template";
3691
+ try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full });
3692
+
3693
+ const build_zig_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig");
3694
+ defer std.testing.allocator.free(build_zig_text);
3695
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "native_sdk.addApp") != null);
3696
+ const package_json = try readTestFile(std.testing.allocator, std.testing.io, destination, "package.json");
3697
+ defer std.testing.allocator.free(package_json);
3698
+ try std.testing.expect(std.mem.indexOf(u8, package_json, "\"@native-sdk/core\"") != null);
3699
+ const tsconfig = try readTestFile(std.testing.allocator, std.testing.io, destination, "tsconfig.json");
3700
+ defer std.testing.allocator.free(tsconfig);
3701
+ try std.testing.expect(std.mem.indexOf(u8, tsconfig, "\"moduleResolution\": \"bundler\"") != null);
3702
+ const editor_core = try readTestFile(std.testing.allocator, std.testing.io, destination, "node_modules/@native-sdk/core/sdk/core.ts");
3703
+ defer std.testing.allocator.free(editor_core);
3704
+ try std.testing.expect(editor_core.len > 0);
3705
+ const gitignore_text = try readTestFile(std.testing.allocator, std.testing.io, destination, ".gitignore");
3706
+ defer std.testing.allocator.free(gitignore_text);
3707
+ try std.testing.expect(std.mem.indexOf(u8, gitignore_text, "node_modules/") != null);
3708
+ }
3709
+
3710
+ test "writeDefaultApp --template zig-core emits the slim Zig scaffold at ts-core parity" {
3711
+ const destination = ".zig-cache/test-native-slim-template";
3712
+ try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .core = .zig });
3713
+
2943
3714
  const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.zon");
2944
3715
  defer std.testing.allocator.free(app_zon_text);
2945
3716
  const main_zig_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "src/main.zig");
2946
3717
  defer std.testing.allocator.free(main_zig_text);
3718
+ const markup_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "src/app.native");
3719
+ defer std.testing.allocator.free(markup_text);
2947
3720
  const gitignore_text = try readTestFile(std.testing.allocator, std.testing.io, destination, ".gitignore");
2948
3721
  defer std.testing.allocator.free(gitignore_text);
2949
3722
  const readme_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "README.md");
@@ -2951,14 +3724,34 @@ test "writeDefaultApp emits a slim native scaffold by default" {
2951
3724
  const icon = try readTestFile(std.testing.allocator, std.testing.io, destination, "assets/icon.png");
2952
3725
  defer std.testing.allocator.free(icon);
2953
3726
 
2954
- // Zero-config: no build files, no editor config, no CI workflow.
3727
+ // Zero-config: no build files, no editor config, no CI workflow — and
3728
+ // none of the TS scaffold's editor surface: a Zig app carries no
3729
+ // package.json/tsconfig/node_modules (zero residue; the tree is the
3730
+ // only language marker).
2955
3731
  try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig"));
2956
3732
  try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "build.zig.zon"));
2957
3733
  try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, ".vscode/settings.json"));
2958
3734
  try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, ".github/workflows/ci.yml"));
3735
+ try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "package.json"));
3736
+ try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "tsconfig.json"));
3737
+ try std.testing.expectError(error.FileNotFound, readTestFile(std.testing.allocator, std.testing.io, destination, "node_modules/@native-sdk/core/package.json"));
2959
3738
 
2960
3739
  try std.testing.expect(std.mem.indexOf(u8, app_zon_text, "gpu_surface") != null);
2961
3740
  try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "native_sdk.UiApp(Model, Msg)") != null);
3741
+ // Feature parity with the ts-core starter: the same counter app with a
3742
+ // repeating fx timer (the Sub.timer equivalent), a journaled clock
3743
+ // read (the Cmd.now equivalent), the lint opt-out for the host-fired
3744
+ // arm, and a bindable single-model helper.
3745
+ try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "fx.startTimer(") != null);
3746
+ try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "fx.wallMs()") != null);
3747
+ try std.testing.expect(std.mem.indexOf(u8, main_zig_text, ".update_fx = update,") != null);
3748
+ try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "pub const view_unbound = .{\"tick\"};") != null);
3749
+ try std.testing.expect(std.mem.indexOf(u8, main_zig_text, "pub fn total(") != null);
3750
+ // The markup is the ts starter's view over the Zig core's own field
3751
+ // names, bound exactly as main.zig wrote them.
3752
+ try std.testing.expect(std.mem.indexOf(u8, markup_text, "{tick_count}") != null);
3753
+ try std.testing.expect(std.mem.indexOf(u8, markup_text, "{total}") != null);
3754
+ try std.testing.expect(std.mem.indexOf(u8, markup_text, "on-toggle=\"toggle_ticking\"") != null);
2962
3755
  // The generated + derived state is ignored wholesale.
2963
3756
  try std.testing.expect(std.mem.indexOf(u8, gitignore_text, ".native/") != null);
2964
3757
  try std.testing.expect(std.mem.indexOf(u8, gitignore_text, "zig-out/") != null);
@@ -2973,7 +3766,7 @@ test "writeDefaultApp emits a slim native scaffold by default" {
2973
3766
 
2974
3767
  test "writeDefaultApp emits native project files" {
2975
3768
  const destination = ".zig-cache/test-native-init-template";
2976
- try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full });
3769
+ try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full, .core = .zig });
2977
3770
 
2978
3771
  const app_zon_text = try readTestFile(std.testing.allocator, std.testing.io, destination, "app.zon");
2979
3772
  defer std.testing.allocator.free(app_zon_text);
@@ -3017,9 +3810,36 @@ test "writeDefaultApp emits native project files" {
3017
3810
  try std.testing.expect(std.mem.indexOf(u8, readme_text, "hot") != null or std.mem.indexOf(u8, readme_text, "Hot") != null);
3018
3811
  }
3019
3812
 
3813
+ test "writeDefaultApp --full ts-core emits a CI workflow with the node tier" {
3814
+ const destination = ".zig-cache/test-ts-ci-template";
3815
+ try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full });
3816
+
3817
+ const ci_yaml_text = try readTestFile(std.testing.allocator, std.testing.io, destination, ".github/workflows/ci.yml");
3818
+ defer std.testing.allocator.free(ci_yaml_text);
3819
+
3820
+ try expectBasicYaml(ci_yaml_text);
3821
+ // The Zig full template's structure: logic tests plus the Linux
3822
+ // automation smoke, no WebKitGTK for a native-rendered app.
3823
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " test:") != null);
3824
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " smoke:") != null);
3825
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "mlugg/setup-zig@v2") != null);
3826
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null") != null);
3827
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libgtk-4-dev xvfb") != null);
3828
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libwebkitgtk-6.0-dev") == null);
3829
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "xvfb-run -a ./zig-out/bin/my-app &") != null);
3830
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "git clone --depth 1 https://github.com/vercel-labs/native.git \"$NATIVE_SDK_PATH\"") != null);
3831
+ // Plus the node tier the TS build needs: node on PATH and the
3832
+ // transpiler's own install inside the fetched SDK's packages/core,
3833
+ // in BOTH jobs (each builds the app, so each transpiles the core).
3834
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "actions/setup-node@v4") != null);
3835
+ const npm_ci = "npm ci --prefix \"$NATIVE_SDK_PATH/packages/core\"";
3836
+ const first = std.mem.indexOf(u8, ci_yaml_text, npm_ci).?;
3837
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text[first + npm_ci.len ..], npm_ci) != null);
3838
+ }
3839
+
3020
3840
  test "writeDefaultApp emits a CI workflow for native apps" {
3021
3841
  const destination = ".zig-cache/test-native-ci-template";
3022
- try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full });
3842
+ try writeDefaultApp(std.testing.allocator, std.testing.io, destination, .{ .app_name = "My App", .framework_path = ".", .frontend = .native, .shape = .full, .core = .zig });
3023
3843
 
3024
3844
  const ci_yaml_text = try readTestFile(std.testing.allocator, std.testing.io, destination, ".github/workflows/ci.yml");
3025
3845
  defer std.testing.allocator.free(ci_yaml_text);
@@ -3033,12 +3853,15 @@ test "writeDefaultApp emits a CI workflow for native apps" {
3033
3853
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "version: 0.16.0") != null);
3034
3854
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null") != null);
3035
3855
  // The smoke job builds with automation, launches under Xvfb, and drives
3036
- // the snapshot: the binary name comes from the template context.
3037
- try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libgtk-4-dev libwebkitgtk-6.0-dev xvfb") != null);
3856
+ // the snapshot: the binary name comes from the template context. A
3857
+ // native app's smoke never needs WebKitGTK — its host compiles
3858
+ // without the embedded web layer.
3859
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libgtk-4-dev xvfb") != null);
3860
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libwebkitgtk-6.0-dev") == null);
3038
3861
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build -Dplatform=linux -Dweb-engine=system -Dautomation=true") != null);
3039
3862
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "xvfb-run -a ./zig-out/bin/my-app &") != null);
3040
3863
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "automate wait") != null);
3041
- try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "automate assert 'gpu_nonblank=true' 'role=button name=\"Reset\"' 'count: 0'") != null);
3864
+ try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "automate assert 'gpu_nonblank=true' 'role=button name=\"Reset\"' 'total: 0'") != null);
3042
3865
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "automate screenshot main-canvas") != null);
3043
3866
  try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "test -s .zig-cache/native-sdk-automation/screenshot-main-canvas.png") != null);
3044
3867
  // The framework fetch step reuses the build.zig.zon dependency path.