@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.
Files changed (97) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +75 -57
  3. package/build/ts_run.mjs +1 -1
  4. package/build.zig +20 -2
  5. package/package.json +11 -10
  6. package/packages/core/package-lock.json +12 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/compiler_command.mjs +1 -1
  9. package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
  10. package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
  11. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  12. package/packages/core/sdk/events.d.ts +33 -4
  13. package/packages/core/sdk/events.ts +45 -6
  14. package/packages/core/src/checker.ts +103 -8
  15. package/packages/core/src/modules.ts +6 -2
  16. package/packages/core/src/sqlite_cli.ts +22 -2
  17. package/packages/core/src/typed_ast.ts +4 -2
  18. package/packages/core/src/types.ts +8 -8
  19. package/schemas/app.schema.json +446 -0
  20. package/skill-data/core/SKILL.md +53 -15
  21. package/skill-data/core/references/project-anatomy.md +6 -6
  22. package/skill-data/native-ui/SKILL.md +26 -5
  23. package/skill-data/ts-core/SKILL.md +6 -6
  24. package/skill-data/ts-services/references/service-surface.md +1 -1
  25. package/skills/native-sdk/SKILL.md +2 -2
  26. package/src/app_runner/root.zig +25 -0
  27. package/src/automation/snapshot.zig +91 -3
  28. package/src/platform/macos/appkit_host.h +66 -2
  29. package/src/platform/macos/appkit_host.m +735 -24
  30. package/src/platform/macos/cef_host.mm +208 -9
  31. package/src/platform/macos/root.zig +205 -3
  32. package/src/platform/null_platform.zig +50 -1
  33. package/src/platform/null_platform_tests.zig +53 -0
  34. package/src/platform/root.zig +12 -0
  35. package/src/platform/types.zig +73 -0
  36. package/src/platform/windows/root.zig +88 -15
  37. package/src/primitives/app_manifest/tests.zig +19 -0
  38. package/src/primitives/app_manifest/validation.zig +14 -2
  39. package/src/primitives/canvas/font_ttf.zig +24 -0
  40. package/src/primitives/canvas/gpu.zig +5 -0
  41. package/src/primitives/canvas/reference.zig +41 -16
  42. package/src/primitives/canvas/reference_tests.zig +63 -0
  43. package/src/primitives/canvas/render_tests.zig +1 -1
  44. package/src/primitives/canvas/root.zig +1 -0
  45. package/src/primitives/canvas/serialization.zig +1 -0
  46. package/src/primitives/canvas/test_support.zig +1 -0
  47. package/src/primitives/canvas/text.zig +1 -0
  48. package/src/primitives/canvas/text_layout.zig +84 -15
  49. package/src/primitives/canvas/text_layout_hash.zig +3 -1
  50. package/src/primitives/canvas/text_layout_types.zig +3 -0
  51. package/src/primitives/canvas/text_metrics.zig +28 -1
  52. package/src/primitives/canvas/text_tests.zig +61 -6
  53. package/src/primitives/canvas/ui.zig +9 -0
  54. package/src/primitives/canvas/ui_markup.zig +29 -0
  55. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  56. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  57. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  58. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  59. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  60. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  61. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  62. package/src/primitives/canvas/ui_schema.zig +9 -0
  63. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  64. package/src/primitives/canvas/ui_tests.zig +4 -2
  65. package/src/primitives/canvas/widget_render.zig +13 -2
  66. package/src/primitives/canvas/widget_render_controls.zig +1 -0
  67. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  68. package/src/root.zig +6 -0
  69. package/src/runtime/automation_snapshot.zig +3 -0
  70. package/src/runtime/canvas_fonts.zig +87 -0
  71. package/src/runtime/core.zig +1 -0
  72. package/src/runtime/flow.zig +8 -1
  73. package/src/runtime/native_command_event_tests.zig +58 -0
  74. package/src/runtime/state.zig +14 -0
  75. package/src/runtime/system_services.zig +62 -0
  76. package/src/runtime/ts_ui_app.zig +161 -33
  77. package/src/runtime/ui_app.zig +33 -1
  78. package/src/runtime/ui_app_tests.zig +63 -0
  79. package/src/runtime/validation.zig +87 -1
  80. package/src/tooling/android.zig +5 -4
  81. package/src/tooling/buildgraph.zig +24 -8
  82. package/src/tooling/db.zig +1 -1
  83. package/src/tooling/doctor.zig +1 -1
  84. package/src/tooling/ios.zig +5 -4
  85. package/src/tooling/json_to_zon.zig +136 -0
  86. package/src/tooling/manifest.zig +199 -35
  87. package/src/tooling/package.zig +33 -0
  88. package/src/tooling/raw_manifest.zig +11 -0
  89. package/src/tooling/root.zig +2 -0
  90. package/src/tooling/templates.zig +210 -116
  91. package/src/tooling/ts_core.zig +11 -7
  92. package/src/tooling/update.zig +576 -0
  93. package/src/tooling/verbs.zig +7 -6
  94. package/src/tooling/web_engine.zig +17 -1
  95. package/src/updater/c_api.zig +123 -0
  96. package/src/updater/feed.zig +215 -0
  97. package/src/updater/root.zig +10 -0
@@ -266,7 +266,7 @@ export class TypeTable {
266
266
  this.declOrder.push(name);
267
267
  continue;
268
268
  }
269
- const projectOptional = this.isCanonicalThemeState(stmt);
269
+ const projectOptional = this.isCanonicalOptionalSdkRecord(stmt);
270
270
  if (ts.isTypeLiteralNode(stmt.type) && this.tast.propsOfTypeLiteral(stmt.type, projectOptional) !== null) {
271
271
  // A plain-record object-literal alias is a struct exactly like
272
272
  // an interface; the alias FORM is how a contract projection
@@ -275,8 +275,8 @@ export class TypeTable {
275
275
  // promotion walk. Shapes the plain-record walk cannot carry
276
276
  // whole (quoted or optional properties) stay unclassified and
277
277
  // refuse at emission instead of losing fields silently. The
278
- // canonical SDK ThemeState is the sole optional-property record:
279
- // omission is its manifest/system inheritance signal.
278
+ // A tiny closed set of SDK shell records may carry optional
279
+ // properties; authored records still spell absence as `| null`.
280
280
  this.structs.set(name, {
281
281
  name,
282
282
  decl: stmt,
@@ -323,7 +323,7 @@ export class TypeTable {
323
323
  }
324
324
  const structInfo = this.structs.get(stmt.name.text);
325
325
  if (structInfo && structInfo.decl === stmt && ts.isTypeLiteralNode(stmt.type)) {
326
- const projectOptional = this.isCanonicalThemeState(stmt);
326
+ const projectOptional = this.isCanonicalOptionalSdkRecord(stmt);
327
327
  const props = this.tast.propsOfTypeLiteral(stmt.type, projectOptional);
328
328
  if (props) structInfo.fields = props.map((p) => this.fieldOf(p, projectOptional));
329
329
  }
@@ -331,9 +331,9 @@ export class TypeTable {
331
331
  }
332
332
  }
333
333
 
334
- private isCanonicalThemeState(decl: ts.TypeAliasDeclaration): boolean {
334
+ private isCanonicalOptionalSdkRecord(decl: ts.TypeAliasDeclaration): boolean {
335
335
  const events = sdkLibraryModules.get("@native-sdk/core/events");
336
- return decl.name.text === "ThemeState" && events !== undefined &&
336
+ return (decl.name.text === "ThemeState" || decl.name.text === "StatusItemPresentation" || decl.name.text === "StatusItemMenuItem") && events !== undefined &&
337
337
  path.resolve(decl.getSourceFile().fileName) === path.resolve(events);
338
338
  }
339
339
 
@@ -342,8 +342,8 @@ export class TypeTable {
342
342
  return {
343
343
  tsName: p.name,
344
344
  zigName: zigDeclName(p.name),
345
- // Only the canonical ThemeState projects JS `undefined` omission onto
346
- // the contract's ordinary optional slot. Applying this globally would
345
+ // Only canonical SDK shell records project JS `undefined` omission
346
+ // onto the contract's ordinary optional slot. Applying this globally would
347
347
  // let service records acquire an absent state while their generated
348
348
  // codecs still accept only explicit null.
349
349
  type: projectOptional && p.optional && resolved.k !== "void" && resolved.k !== "optional"
@@ -0,0 +1,446 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schema.native-sdk.dev/app/v1.json",
4
+ "title": "Native SDK app manifest",
5
+ "description": "Complete app.json manifest for a Native SDK application. app.zon remains supported as a legacy alternative.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["id", "name", "version"],
9
+ "properties": {
10
+ "$schema": { "type": "string", "format": "uri-reference" },
11
+ "id": { "type": "string", "minLength": 1, "maxLength": 128, "description": "Reverse-DNS application identifier." },
12
+ "name": { "type": "string", "minLength": 1, "description": "Short machine-readable app name." },
13
+ "display_name": { "type": "string", "minLength": 1, "description": "Human-readable app name." },
14
+ "description": { "type": "string", "minLength": 1, "maxLength": 256 },
15
+ "version": { "type": "string", "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" },
16
+ "icons": { "$ref": "#/$defs/stringArray" },
17
+ "platforms": {
18
+ "type": "array",
19
+ "uniqueItems": true,
20
+ "items": { "enum": ["macos", "linux", "windows", "ios", "android", "web"] }
21
+ },
22
+ "permissions": { "$ref": "#/$defs/stringArray" },
23
+ "capabilities": {
24
+ "type": "array",
25
+ "uniqueItems": true,
26
+ "items": {
27
+ "enum": [
28
+ "native_module", "webview", "js_bridge", "native_views", "gpu_surfaces",
29
+ "menus", "shortcuts", "tray", "filesystem", "network", "notifications",
30
+ "dialog", "clipboard", "credentials", "persist", "store", "sqlite",
31
+ "open_url", "reveal_path", "recent_documents", "file_drops",
32
+ "app_activation_events", "file_associations", "url_schemes"
33
+ ]
34
+ }
35
+ },
36
+ "dock_visible": { "type": "boolean", "default": true },
37
+ "persist": { "$ref": "#/$defs/persist" },
38
+ "images": { "$ref": "#/$defs/images" },
39
+ "service_packages": {
40
+ "type": "array",
41
+ "items": { "$ref": "#/$defs/servicePackage" }
42
+ },
43
+ "service_carrier": { "enum": ["auto", "in_process", "child"], "default": "auto" },
44
+ "service_pool_size": { "type": "integer", "minimum": 1, "maximum": 16 },
45
+ "bridge": { "$ref": "#/$defs/bridge" },
46
+ "web_engine": { "enum": ["system", "chromium"], "default": "system" },
47
+ "webview_layer": { "enum": ["auto", "include", "exclude"], "default": "auto" },
48
+ "core_compiler": { "const": "external", "default": "external" },
49
+ "theme": { "enum": ["house", "geist"] },
50
+ "theme_accent": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
51
+ "cef": { "$ref": "#/$defs/cef" },
52
+ "frontend": { "$ref": "#/$defs/frontend" },
53
+ "security": { "$ref": "#/$defs/security" },
54
+ "assets": { "$ref": "#/$defs/assets" },
55
+ "windows": {
56
+ "type": "array",
57
+ "items": { "$ref": "#/$defs/window" }
58
+ },
59
+ "shell": { "$ref": "#/$defs/shell" },
60
+ "commands": {
61
+ "type": "array",
62
+ "items": { "$ref": "#/$defs/command" }
63
+ },
64
+ "menus": {
65
+ "type": "array",
66
+ "items": { "$ref": "#/$defs/menu" }
67
+ },
68
+ "shortcuts": {
69
+ "type": "array",
70
+ "items": { "$ref": "#/$defs/shortcut" }
71
+ },
72
+ "file_associations": {
73
+ "type": "array",
74
+ "items": { "$ref": "#/$defs/fileAssociation" }
75
+ },
76
+ "url_schemes": {
77
+ "type": "array",
78
+ "items": { "$ref": "#/$defs/urlScheme" }
79
+ },
80
+ "updates": { "$ref": "#/$defs/updates" },
81
+ "dmg": { "$ref": "#/$defs/dmg" }
82
+ },
83
+ "$defs": {
84
+ "stringArray": {
85
+ "type": "array",
86
+ "uniqueItems": true,
87
+ "items": { "type": "string" }
88
+ },
89
+ "position": {
90
+ "type": "object",
91
+ "additionalProperties": false,
92
+ "required": ["x", "y"],
93
+ "properties": {
94
+ "x": { "type": "integer", "minimum": 0, "maximum": 65535 },
95
+ "y": { "type": "integer", "minimum": 0, "maximum": 65535 }
96
+ }
97
+ },
98
+ "persist": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "required": ["version", "restore"],
102
+ "properties": {
103
+ "version": { "type": "integer", "minimum": 1 },
104
+ "debounce_ms": { "type": "integer", "minimum": 0, "maximum": 60000, "default": 500 },
105
+ "restore": {
106
+ "type": "object",
107
+ "additionalProperties": false,
108
+ "required": ["ok", "none", "err"],
109
+ "properties": {
110
+ "ok": { "type": "string", "minLength": 1 },
111
+ "none": { "type": "string", "minLength": 1 },
112
+ "err": { "type": "string", "minLength": 1 }
113
+ }
114
+ }
115
+ }
116
+ },
117
+ "images": {
118
+ "type": "object",
119
+ "additionalProperties": false,
120
+ "properties": {
121
+ "max_image_pixel_bytes": { "type": "integer", "minimum": 1048576, "maximum": 8388608, "default": 1048576 }
122
+ }
123
+ },
124
+ "servicePackage": {
125
+ "type": "object",
126
+ "additionalProperties": false,
127
+ "required": ["name", "version", "content_hash"],
128
+ "properties": {
129
+ "name": { "type": "string", "minLength": 1 },
130
+ "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
131
+ "content_hash": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
132
+ }
133
+ },
134
+ "updates": {
135
+ "type": "object",
136
+ "additionalProperties": false,
137
+ "required": ["feed_url", "public_key"],
138
+ "properties": {
139
+ "feed_url": { "type": "string", "pattern": "^https://", "maxLength": 4096 },
140
+ "public_key": { "type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$" },
141
+ "check_on_start": { "type": "boolean", "default": false }
142
+ }
143
+ },
144
+ "bridge": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "properties": {
148
+ "commands": {
149
+ "type": "array",
150
+ "items": {
151
+ "type": "object",
152
+ "additionalProperties": false,
153
+ "required": ["name"],
154
+ "properties": {
155
+ "name": { "type": "string", "minLength": 1 },
156
+ "permissions": { "$ref": "#/$defs/stringArray" },
157
+ "origins": { "$ref": "#/$defs/stringArray" }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ },
163
+ "cef": {
164
+ "type": "object",
165
+ "additionalProperties": false,
166
+ "properties": {
167
+ "dir": { "type": "string", "default": "third_party/cef/macos" },
168
+ "auto_install": { "type": "boolean", "default": false }
169
+ }
170
+ },
171
+ "frontend": {
172
+ "type": "object",
173
+ "additionalProperties": false,
174
+ "properties": {
175
+ "dist": { "type": "string", "default": "dist" },
176
+ "entry": { "type": "string", "default": "index.html" },
177
+ "spa_fallback": { "type": "boolean", "default": true },
178
+ "dev": {
179
+ "type": "object",
180
+ "additionalProperties": false,
181
+ "required": ["url"],
182
+ "properties": {
183
+ "url": { "type": "string", "format": "uri" },
184
+ "command": { "$ref": "#/$defs/stringArray" },
185
+ "ready_path": { "type": "string", "default": "/" },
186
+ "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 4294967295, "default": 30000 }
187
+ }
188
+ }
189
+ }
190
+ },
191
+ "security": {
192
+ "type": "object",
193
+ "additionalProperties": false,
194
+ "properties": {
195
+ "navigation": {
196
+ "type": "object",
197
+ "additionalProperties": false,
198
+ "properties": {
199
+ "allowed_origins": { "$ref": "#/$defs/stringArray" },
200
+ "external_links": {
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "properties": {
204
+ "action": { "enum": ["deny", "open_system_browser"], "default": "deny" },
205
+ "allowed_urls": { "$ref": "#/$defs/stringArray" }
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ },
212
+ "assets": {
213
+ "type": "object",
214
+ "additionalProperties": false,
215
+ "properties": {
216
+ "images": {
217
+ "type": "array",
218
+ "items": {
219
+ "type": "object",
220
+ "additionalProperties": false,
221
+ "required": ["id", "path"],
222
+ "properties": {
223
+ "id": { "type": "integer", "minimum": 1 },
224
+ "path": { "type": "string", "minLength": 1 }
225
+ }
226
+ }
227
+ }
228
+ }
229
+ },
230
+ "windowBase": {
231
+ "type": "object",
232
+ "properties": {
233
+ "label": { "type": "string", "default": "main" },
234
+ "title": { "type": "string" },
235
+ "width": { "type": "number", "exclusiveMinimum": 0, "default": 720 },
236
+ "height": { "type": "number", "exclusiveMinimum": 0, "default": 480 },
237
+ "x": { "type": "number" },
238
+ "y": { "type": "number" },
239
+ "resizable": { "type": "boolean", "default": true },
240
+ "restore_state": { "type": "boolean", "default": true },
241
+ "titlebar": { "enum": ["standard", "hidden_inset", "hidden_inset_tall", "chromeless"], "default": "standard" },
242
+ "transparent": { "type": "boolean", "default": false },
243
+ "always_on_top": { "type": "boolean", "default": false },
244
+ "click_through": { "type": "boolean", "default": false },
245
+ "activate_on_show": { "type": "boolean", "default": true },
246
+ "initially_hidden": { "type": "boolean", "default": false },
247
+ "allows_fullscreen": { "type": "boolean", "default": true },
248
+ "min_width": { "type": "number", "minimum": 0, "default": 0 },
249
+ "min_height": { "type": "number", "minimum": 0, "default": 0 },
250
+ "close_policy": { "enum": ["quit", "hide"], "default": "quit" }
251
+ }
252
+ },
253
+ "window": {
254
+ "allOf": [{ "$ref": "#/$defs/windowBase" }],
255
+ "unevaluatedProperties": false
256
+ },
257
+ "shell": {
258
+ "type": "object",
259
+ "additionalProperties": false,
260
+ "properties": {
261
+ "windows": {
262
+ "type": "array",
263
+ "items": { "$ref": "#/$defs/shellWindow" }
264
+ },
265
+ "chrome": { "$ref": "#/$defs/shellChrome" }
266
+ }
267
+ },
268
+ "shellWindow": {
269
+ "allOf": [
270
+ { "$ref": "#/$defs/windowBase" },
271
+ {
272
+ "type": "object",
273
+ "properties": {
274
+ "restore_policy": { "enum": ["clamp_to_visible_screen", "center_on_primary"], "default": "clamp_to_visible_screen" },
275
+ "views": { "type": "array", "items": { "$ref": "#/$defs/shellView" } }
276
+ }
277
+ }
278
+ ],
279
+ "unevaluatedProperties": false
280
+ },
281
+ "shellChrome": {
282
+ "type": "object",
283
+ "additionalProperties": false,
284
+ "properties": {
285
+ "tabs": {
286
+ "type": "array",
287
+ "items": { "$ref": "#/$defs/shellTab" }
288
+ },
289
+ "primary_action": { "$ref": "#/$defs/shellTab" }
290
+ }
291
+ },
292
+ "shellTab": {
293
+ "type": "object",
294
+ "additionalProperties": false,
295
+ "required": ["id", "label"],
296
+ "properties": {
297
+ "id": { "type": "string", "minLength": 1 },
298
+ "label": { "type": "string", "minLength": 1 },
299
+ "icon": { "type": "string", "default": "" }
300
+ }
301
+ },
302
+ "shellView": {
303
+ "type": "object",
304
+ "additionalProperties": false,
305
+ "required": ["label", "kind"],
306
+ "properties": {
307
+ "label": { "type": "string", "minLength": 1 },
308
+ "kind": {
309
+ "enum": [
310
+ "webview", "toolbar", "titlebar_accessory", "sidebar", "statusbar", "split", "stack",
311
+ "button", "icon_button", "list_item", "checkbox", "toggle", "segmented_control",
312
+ "text_field", "search_field", "label", "spacer", "gpu_surface", "progress_indicator"
313
+ ]
314
+ },
315
+ "parent": { "type": "string" },
316
+ "edge": { "enum": ["top", "right", "bottom", "left"] },
317
+ "axis": { "enum": ["row", "horizontal", "column", "vertical"] },
318
+ "x": { "type": "number" },
319
+ "y": { "type": "number" },
320
+ "width": { "type": "number" },
321
+ "height": { "type": "number" },
322
+ "min_width": { "type": "number" },
323
+ "min_height": { "type": "number" },
324
+ "max_width": { "type": "number" },
325
+ "max_height": { "type": "number" },
326
+ "fill": { "type": "boolean", "default": false },
327
+ "layer": { "type": "integer", "minimum": -2147483648, "maximum": 2147483647, "default": 0 },
328
+ "visible": { "type": "boolean", "default": true },
329
+ "enabled": { "type": "boolean", "default": true },
330
+ "role": { "type": "string" },
331
+ "accessibility_label": { "type": "string" },
332
+ "url": { "type": "string" },
333
+ "text": { "type": "string" },
334
+ "command": { "type": "string" },
335
+ "gpu_backend": { "enum": ["none", "metal", "software"] },
336
+ "gpu_pixel_format": { "enum": ["none", "bgra8_unorm"] },
337
+ "gpu_present_mode": { "enum": ["none", "timer"] },
338
+ "gpu_alpha_mode": { "enum": ["none", "opaque", "premultiplied"] },
339
+ "gpu_color_space": { "enum": ["none", "srgb", "display_p3"] },
340
+ "gpu_vsync": { "type": "boolean" }
341
+ }
342
+ },
343
+ "command": {
344
+ "type": "object",
345
+ "additionalProperties": false,
346
+ "required": ["id"],
347
+ "properties": {
348
+ "id": { "type": "string", "minLength": 1 },
349
+ "title": { "type": "string", "default": "" },
350
+ "enabled": { "type": "boolean", "default": true },
351
+ "checked": { "type": "boolean", "default": false }
352
+ }
353
+ },
354
+ "menu": {
355
+ "type": "object",
356
+ "additionalProperties": false,
357
+ "required": ["title"],
358
+ "properties": {
359
+ "title": { "type": "string", "minLength": 1 },
360
+ "items": {
361
+ "type": "array",
362
+ "items": { "$ref": "#/$defs/menuItem" }
363
+ }
364
+ }
365
+ },
366
+ "menuItem": {
367
+ "type": "object",
368
+ "additionalProperties": false,
369
+ "properties": {
370
+ "label": { "type": "string", "default": "" },
371
+ "command": { "type": "string", "default": "" },
372
+ "key": { "type": "string", "default": "" },
373
+ "modifiers": { "$ref": "#/$defs/modifiers" },
374
+ "separator": { "type": "boolean", "default": false },
375
+ "enabled": { "type": "boolean", "default": true },
376
+ "checked": { "type": "boolean", "default": false }
377
+ }
378
+ },
379
+ "modifiers": {
380
+ "type": "array",
381
+ "uniqueItems": true,
382
+ "items": { "enum": ["primary", "command", "control", "option", "alt", "shift"] }
383
+ },
384
+ "shortcut": {
385
+ "type": "object",
386
+ "additionalProperties": false,
387
+ "required": ["id", "key"],
388
+ "properties": {
389
+ "id": { "type": "string", "minLength": 1 },
390
+ "key": { "type": "string", "minLength": 1 },
391
+ "modifiers": { "$ref": "#/$defs/modifiers" }
392
+ }
393
+ },
394
+ "fileAssociation": {
395
+ "type": "object",
396
+ "additionalProperties": false,
397
+ "required": ["name"],
398
+ "properties": {
399
+ "name": { "type": "string", "minLength": 1 },
400
+ "role": { "$ref": "#/$defs/associationRole" },
401
+ "extensions": { "$ref": "#/$defs/stringArray" },
402
+ "mime_types": { "$ref": "#/$defs/stringArray" },
403
+ "icon": { "type": "string" }
404
+ }
405
+ },
406
+ "urlScheme": {
407
+ "type": "object",
408
+ "additionalProperties": false,
409
+ "required": ["scheme"],
410
+ "properties": {
411
+ "scheme": { "type": "string", "minLength": 1 },
412
+ "role": { "$ref": "#/$defs/associationRole" }
413
+ }
414
+ },
415
+ "associationRole": { "enum": ["viewer", "editor", "shell", "none"], "default": "viewer" },
416
+ "dmg": {
417
+ "type": "object",
418
+ "additionalProperties": false,
419
+ "properties": {
420
+ "volume_name": { "type": "string" },
421
+ "background": { "type": "string" },
422
+ "window_width": { "type": "integer", "minimum": 320, "maximum": 2000, "default": 660 },
423
+ "window_height": { "type": "integer", "minimum": 240, "maximum": 1400, "default": 400 },
424
+ "icon_size": { "type": "integer", "minimum": 32, "maximum": 256, "default": 128 },
425
+ "app_position": { "$ref": "#/$defs/position" },
426
+ "applications_position": { "$ref": "#/$defs/position" },
427
+ "applications_link": { "type": "boolean", "default": true },
428
+ "items": {
429
+ "type": "array",
430
+ "items": { "$ref": "#/$defs/dmgItem" }
431
+ }
432
+ }
433
+ },
434
+ "dmgItem": {
435
+ "type": "object",
436
+ "additionalProperties": false,
437
+ "required": ["kind", "position"],
438
+ "properties": {
439
+ "kind": { "enum": ["app", "applications", "file", "link"] },
440
+ "path": { "type": "string" },
441
+ "name": { "type": "string" },
442
+ "position": { "$ref": "#/$defs/position" }
443
+ }
444
+ }
445
+ }
446
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: core
3
- description: Core Native SDK guide for AI agents. Read this before explaining the Native SDK or changing a Native SDK app. Establishes TypeScript + Native markup as the default app-authoring path, routes default app work to the native-ui and ts-core skills, and covers the shared foundation: project structure, app.zon, lower-level App and Runtime patterns, frontend integration, web engines, JavaScript bridge commands, permissions, windows, WebViews, dialogs, packaging, debugging, and testing. Use when the user asks what the Native SDK is, how to build or modify an app, how to package or debug it, or how to add native capabilities.
3
+ description: Core Native SDK guide for AI agents. Read this before explaining the Native SDK or changing a Native SDK app. Establishes TypeScript + Native markup as the default app-authoring path, routes default app work to the native-ui and ts-core skills, and covers the shared foundation: project structure, app.json and legacy app.zon, lower-level App and Runtime patterns, frontend integration, web engines, JavaScript bridge commands, permissions, windows, WebViews, dialogs, packaging, debugging, and testing. Use when the user asks what the Native SDK is, how to build or modify an app, how to package or debug it, or how to add native capabilities.
4
4
  ---
5
5
 
6
6
  # Build Native SDK apps
@@ -13,13 +13,13 @@ Agents should assume they do not know the Native SDK from general model knowledg
13
13
 
14
14
  ## Mental model
15
15
 
16
- - The default app has three files of truth: `src/core.ts` (`Model`, `Msg`, `update`), `src/app.native` (UI), and `app.zon` (manifest).
16
+ - The default app has three files of truth: `src/core.ts` (`Model`, `Msg`, `update`), `src/app.native` (UI), and `app.json` (manifest).
17
17
  - Native markup binds model values and dispatches typed messages; only `update` changes state.
18
18
  - The TypeScript core compiles to native code. Node is a build/check/dev tool, not an app runtime.
19
19
  - `App` is the lower-level product/runtime interface used by generated wiring, Zig-core apps, WebView shells, and extensions.
20
20
  - `Runtime` owns the event loop, windows, bridge dispatch, security checks, automation, tracing, platform services, and window state.
21
21
  - `WebViewSource` tells the runtime what to load: inline HTML, a URL, or packaged assets from a local app origin.
22
- - `app.zon` is the app manifest: identity, icons, windows, frontend assets, web engine, permissions, bridge policy, security policy, and packaging inputs.
22
+ - `app.json` is the default app manifest: identity, icons, windows, frontend assets, web engine, permissions, bridge policy, security policy, and packaging inputs. `app.zon` remains supported.
23
23
  - `src/runner.zig` and `src/main.zig` appear only when an app explicitly owns lower-level Zig wiring (for example a `zig-core` app or a WebView shell). `--full` makes a TypeScript app own `build.zig` but still does not give it Zig app logic. Do not add Zig sources to a default TypeScript app merely because SDK examples contain them.
24
24
  - `frontend/` is normal web code. It talks to native Zig through `window.zero.invoke()` or builtin helpers when those are enabled.
25
25
 
@@ -48,13 +48,13 @@ cd my_app
48
48
  native dev
49
49
  ```
50
50
 
51
- This creates `src/core.ts`, `src/app.native`, and `app.zon`; a native window opens with `native dev`. Use `native init my_app --template zig-core` only when the user chooses Zig. Frontend choices (`--frontend next|vite|react|svelte|vue`) are the separate WebView migration/integration path.
51
+ This creates `src/core.ts`, `src/app.native`, and `app.json`; a native window opens with `native dev`. Use `native init my_app --template zig-core` only when the user chooses Zig. Frontend choices (`--frontend next|vite|react|svelte|vue`) are the separate WebView migration/integration path.
52
52
 
53
53
  ## Workflow for existing apps
54
54
 
55
55
  Before editing an existing Native SDK app:
56
56
 
57
- 1. Read `app.zon` and inspect `src/` before assuming a core language. Read `src/core.ts` + `src/app.native` for the default path; read `src/main.zig`, `src/runner.zig`, and `build.zig` only when they exist.
57
+ 1. Read `app.json` or `app.zon` and inspect `src/` before assuming a core language. Read `src/core.ts` + `src/app.native` for the default path; read `src/main.zig`, `src/runner.zig`, and `build.zig` only when they exist.
58
58
  2. Identify whether the app is TypeScript + Native markup (default), an explicitly chosen Zig core, or a WebView frontend, then identify the layer the change belongs to.
59
59
  3. Follow the generated code and examples in the repository instead of inventing a new app layout.
60
60
  4. Prefer exact security policy changes over broad allowances.
@@ -62,7 +62,7 @@ Before editing an existing Native SDK app:
62
62
 
63
63
  Common file ownership:
64
64
 
65
- - `app.zon`: app identity, version, icons, windows, permissions, capabilities, bridge command policy, allowed origins, frontend dist/dev config, web engine, CEF config.
65
+ - `app.json` / `app.zon`: app identity, version, icons, windows, permissions, capabilities, bridge command policy, allowed origins, frontend dist/dev config, web engine, CEF config.
66
66
  - `src/core.ts`: default app state and behavior — `Model`, `Msg`, `update`, pure helpers, `Cmd`, and `Sub`.
67
67
  - `src/app.native`: default app UI — elements, layout, bindings, and message dispatch.
68
68
  - `src/main.zig`: explicitly chosen Zig-core logic or lower-level `App` behavior, source selection, lifecycle callbacks, and custom bridge handlers.
@@ -106,9 +106,47 @@ fn source(context: *anyopaque) anyerror!native_sdk.WebViewSource {
106
106
 
107
107
  `sourceFromEnv` reads `NATIVE_SDK_FRONTEND_URL`; otherwise it serves the configured asset directory. Use it for most framework apps.
108
108
 
109
- ## app.zon essentials
109
+ ## app.json essentials
110
+
111
+ Keep `app.json` as the source of truth for app-level behavior. Existing `app.zon` projects use the same fields in ZON syntax.
112
+
113
+ ```json
114
+ {
115
+ "$schema": "https://schema.native-sdk.dev/app/v1.json",
116
+ "id": "com.example.my-app",
117
+ "name": "my-app",
118
+ "display_name": "My App",
119
+ "description": "One line about the app, shown in the About panel.",
120
+ "version": "0.1.0",
121
+ "icons": ["assets/icon.png"],
122
+ "platforms": ["macos", "linux"],
123
+ "permissions": [],
124
+ "capabilities": ["webview"],
125
+ "frontend": {
126
+ "dist": "frontend/dist",
127
+ "entry": "index.html",
128
+ "spa_fallback": true,
129
+ "dev": {
130
+ "url": "http://127.0.0.1:5173/",
131
+ "command": ["npm", "--prefix", "frontend", "run", "dev", "--", "--host", "127.0.0.1"],
132
+ "ready_path": "/",
133
+ "timeout_ms": 30000
134
+ }
135
+ },
136
+ "security": {
137
+ "navigation": {
138
+ "allowed_origins": ["zero://app", "http://127.0.0.1:5173"],
139
+ "external_links": { "action": "deny" }
140
+ }
141
+ },
142
+ "web_engine": "system",
143
+ "windows": [
144
+ { "label": "main", "title": "My App", "width": 960, "height": 640, "restore_state": true }
145
+ ]
146
+ }
147
+ ```
110
148
 
111
- Keep `app.zon` as the source of truth for app-level behavior:
149
+ Legacy ZON equivalent:
112
150
 
113
151
  ```zig
114
152
  .{
@@ -151,13 +189,13 @@ Use exact local origins for dev servers. Add `zero://inline` only for inline HTM
151
189
 
152
190
  ### Add a new framework app
153
191
 
154
- Use `native init <path> --frontend <next|vite|react|svelte|vue>`. Then inspect the generated `app.zon`, `src/main.zig`, and `build.zig` before customizing. For framework behavior, keep frontend work in `frontend/` and use `sourceFromEnv` so development and packaged builds share one app shell.
192
+ Use `native init <path> --frontend <next|vite|react|svelte|vue>`. Then inspect the generated `app.json`, `src/main.zig`, and `build.zig` before customizing. For framework behavior, keep frontend work in `frontend/` and use `sourceFromEnv` so development and packaged builds share one app shell.
155
193
 
156
194
  ### Add a native bridge command
157
195
 
158
196
  1. Add state and a handler in `src/main.zig`.
159
197
  2. Register the handler in `bridge()`.
160
- 3. Allow the command in `app.zon` and in the runtime bridge policy if the runner reads manifest policy into runtime.
198
+ 3. Allow the command in the app manifest and in the runtime bridge policy if the runner reads manifest policy into runtime.
161
199
  4. Call it from JavaScript with `window.zero.invoke("namespace.command", payload)`.
162
200
  5. Return valid JSON from Zig. Use `native_sdk.bridge.writeJsonStringValue()` for user-controlled strings.
163
201
 
@@ -182,11 +220,11 @@ native package --target macos --archive
182
220
 
183
221
  On macOS, `--archive` adds a zero-config drag-to-Applications DMG with a generated 1×/2× Retina background. The optional `app.zon` `.dmg` block controls its volume name, PNG/JPEG/TIFF background, usable Finder canvas/icon geometry, and Applications link. An adjacent `name@2x.png`/`.jpg` is discovered automatically. Use `.dmg.items` only for a fully art-directed list: exactly one `app`, plus optional `applications`, project-relative `file`, and absolute `link` entries, each with its own icon-center position.
184
222
 
185
- Apps that own their build (ejected or scaffolded `--full`) wire the same step into the build graph: keep package metadata in `app.zon`, build the frontend assets, build the native binary, then package:
223
+ Apps that own their build (ejected or scaffolded `--full`) wire the same step into the build graph: keep package metadata in the app manifest, build the frontend assets, build the native binary, then package:
186
224
 
187
225
  ```bash
188
226
  zig build package
189
- native doctor --manifest app.zon --strict
227
+ native doctor --manifest app.json --strict
190
228
  ```
191
229
 
192
230
  Use signing and CEF options only when the product requires them.
@@ -211,7 +249,7 @@ zig build dev
211
249
  Or run the CLI directly after building the binary:
212
250
 
213
251
  ```bash
214
- native dev --manifest app.zon --binary zig-out/bin/MyApp
252
+ native dev --manifest app.json --binary zig-out/bin/MyApp
215
253
  ```
216
254
 
217
255
  Vite usually uses `http://127.0.0.1:5173/`; Next.js usually uses `http://127.0.0.1:3000/`. The app WebView loads the dev URL directly, so framework HMR remains owned by Vite, Next.js, or the selected dev server.
@@ -247,8 +285,8 @@ zig build run
247
285
  zig build dev
248
286
  zig build test
249
287
  zig build test-tooling
250
- native validate app.zon
251
- native doctor --manifest app.zon --strict
288
+ native validate app.json
289
+ native doctor --manifest app.json --strict
252
290
  zig build package
253
291
  ```
254
292