@native-sdk/cli 0.8.4 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/build/app.zig +1178 -74
  2. package/build.zig +715 -17
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +10 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +435 -3
  7. package/packages/core/package-lock.json +11 -11
  8. package/packages/core/package.json +2 -2
  9. package/packages/core/scripts/compiler_typecheck.mjs +116 -15
  10. package/packages/core/scripts/gen_service_surface.mjs +268 -0
  11. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +64 -0
  13. package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
  14. package/packages/core/scripts/run_external_service_compiler.mjs +280 -0
  15. package/packages/core/scripts/stage_external_core.mjs +9 -1
  16. package/packages/core/scripts/stage_external_services.mjs +172 -0
  17. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  18. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  19. package/packages/core/sdk/core.d.ts +224 -0
  20. package/packages/core/sdk/core.ts +694 -22
  21. package/packages/core/sdk/events.d.ts +89 -0
  22. package/packages/core/sdk/events.ts +128 -0
  23. package/packages/core/src/checker.ts +936 -15
  24. package/packages/core/src/cli.ts +156 -3
  25. package/packages/core/src/contract.ts +28 -5
  26. package/packages/core/src/devhost.ts +1876 -16
  27. package/packages/core/src/devhost_journal.mjs +183 -0
  28. package/packages/core/src/devhost_resolver.mjs +17 -1
  29. package/packages/core/src/devhost_service_worker.mjs +90 -0
  30. package/packages/core/src/diagnostics.ts +179 -22
  31. package/packages/core/src/frontend.ts +210 -34
  32. package/packages/core/src/infer.ts +24 -0
  33. package/packages/core/src/modules.ts +129 -80
  34. package/packages/core/src/service_contract.ts +597 -0
  35. package/packages/core/src/sqlite_cli.ts +93 -0
  36. package/packages/core/src/sqlite_codegen.ts +806 -0
  37. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  38. package/packages/core/src/typed_ast.ts +36 -8
  39. package/skill-data/automation/SKILL.md +1 -1
  40. package/skill-data/core/references/project-anatomy.md +1 -1
  41. package/skill-data/native-ui/SKILL.md +58 -5
  42. package/skill-data/ts-core/SKILL.md +123 -41
  43. package/skill-data/ts-services/SKILL.md +126 -0
  44. package/skill-data/ts-services/references/service-surface.md +604 -0
  45. package/skill-data/zig/SKILL.md +1 -1
  46. package/skills/native-sdk/SKILL.md +1 -1
  47. package/src/app_runner/no_migrations.zig +3 -0
  48. package/src/app_runner/no_services.zig +20 -0
  49. package/src/app_runner/root.zig +133 -4
  50. package/src/app_runner/ts_core_main.zig +254 -8
  51. package/src/app_runner/ts_core_mobile.zig +241 -0
  52. package/src/automation/protocol.zig +5 -1
  53. package/src/automation/snapshot.zig +31 -11
  54. package/src/embed/app_exports.zig +12 -1
  55. package/src/embed/c_api.zig +48 -2
  56. package/src/embed/conversions.zig +4 -5
  57. package/src/embed/host.zig +109 -1
  58. package/src/embed/root.zig +8 -0
  59. package/src/embed/tests.zig +241 -0
  60. package/src/embed/types.zig +51 -0
  61. package/src/embed/ui_host.zig +185 -5
  62. package/src/platform/android/NativeSdkActivity.java +131 -0
  63. package/src/platform/android/android_host.c +182 -1
  64. package/src/platform/android/native_sdk_app.h +17 -0
  65. package/src/platform/ios/native_sdk_app.h +17 -0
  66. package/src/platform/ios/uikit_host.m +115 -0
  67. package/src/platform/linux/cef_host.cpp +8 -2
  68. package/src/platform/linux/gtk_host.c +289 -22
  69. package/src/platform/linux/gtk_host.h +5 -1
  70. package/src/platform/linux/root.zig +109 -22
  71. package/src/platform/macos/appkit_host.h +24 -7
  72. package/src/platform/macos/appkit_host.m +686 -64
  73. package/src/platform/macos/cef_host.mm +400 -66
  74. package/src/platform/macos/root.zig +304 -47
  75. package/src/platform/null_platform.zig +435 -48
  76. package/src/platform/null_platform_tests.zig +113 -0
  77. package/src/platform/root.zig +19 -0
  78. package/src/platform/types.zig +281 -28
  79. package/src/platform/windows/root.zig +207 -27
  80. package/src/platform/windows/webview2_host.cpp +334 -51
  81. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  82. package/src/primitives/app_manifest/root.zig +4 -0
  83. package/src/primitives/app_manifest/tests.zig +3 -0
  84. package/src/primitives/app_manifest/types.zig +32 -0
  85. package/src/primitives/app_manifest/validation.zig +19 -1
  86. package/src/root.zig +53 -0
  87. package/src/runtime/api.zig +19 -0
  88. package/src/runtime/automation_commands.zig +35 -2
  89. package/src/runtime/automation_snapshot.zig +32 -20
  90. package/src/runtime/bridge_permission_tests.zig +58 -3
  91. package/src/runtime/bridge_responses.zig +4 -2
  92. package/src/runtime/builtin_bridge.zig +11 -1
  93. package/src/runtime/canvas_frame.zig +18 -11
  94. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  95. package/src/runtime/clock.zig +13 -1
  96. package/src/runtime/core.zig +145 -7
  97. package/src/runtime/credentials_store.zig +115 -0
  98. package/src/runtime/effects.zig +3701 -231
  99. package/src/runtime/effects_credentials_tests.zig +332 -0
  100. package/src/runtime/effects_file_tests.zig +587 -0
  101. package/src/runtime/effects_host_tests.zig +208 -1
  102. package/src/runtime/effects_notification_tests.zig +11 -0
  103. package/src/runtime/effects_relational_tests.zig +314 -0
  104. package/src/runtime/effects_store_tests.zig +211 -0
  105. package/src/runtime/file_access.zig +400 -0
  106. package/src/runtime/file_effect_crash_helper.zig +28 -0
  107. package/src/runtime/file_effect_crash_tests.zig +37 -0
  108. package/src/runtime/flow.zig +35 -10
  109. package/src/runtime/gpu_surface_events.zig +6 -1
  110. package/src/runtime/native_command_event_tests.zig +86 -2
  111. package/src/runtime/persist_store.zig +666 -0
  112. package/src/runtime/pty.zig +5 -2
  113. package/src/runtime/record_store.zig +788 -0
  114. package/src/runtime/relational_store.zig +854 -0
  115. package/src/runtime/root.zig +54 -0
  116. package/src/runtime/runtime_event_tests.zig +70 -0
  117. package/src/runtime/service_host.zig +711 -0
  118. package/src/runtime/service_pool.zig +1314 -0
  119. package/src/runtime/session_blobs.zig +4 -1
  120. package/src/runtime/session_journal.zig +158 -5
  121. package/src/runtime/session_record.zig +215 -0
  122. package/src/runtime/session_replay.zig +206 -11
  123. package/src/runtime/session_tests.zig +81 -0
  124. package/src/runtime/shell_layout.zig +1 -0
  125. package/src/runtime/shell_layout_tests.zig +120 -0
  126. package/src/runtime/sqlite_engine.zig +474 -0
  127. package/src/runtime/state.zig +16 -0
  128. package/src/runtime/system_services.zig +170 -38
  129. package/src/runtime/tests.zig +4 -0
  130. package/src/runtime/ts_core_host.zig +1067 -95
  131. package/src/runtime/ts_core_host_tests.zig +325 -11
  132. package/src/runtime/ts_ui_app.zig +953 -2
  133. package/src/runtime/ui_app.zig +434 -96
  134. package/src/runtime/ui_app_tests.zig +287 -11
  135. package/src/runtime/ui_app_window_tests.zig +61 -7
  136. package/src/runtime/validation.zig +42 -0
  137. package/src/runtime/view.zig +9 -0
  138. package/src/runtime/window_storage.zig +1 -0
  139. package/src/runtime/window_view_runtime.zig +2 -3
  140. package/src/runtime/window_views.zig +19 -0
  141. package/src/tooling/android.zig +21 -16
  142. package/src/tooling/db.zig +160 -0
  143. package/src/tooling/ios.zig +7 -1
  144. package/src/tooling/manifest.zig +214 -2
  145. package/src/tooling/package.zig +116 -0
  146. package/src/tooling/raw_manifest.zig +30 -0
  147. package/src/tooling/root.zig +1 -0
  148. package/src/tooling/templates.zig +189 -4
  149. package/src/tooling/ts_core.zig +366 -17
  150. package/src/tooling/verbs.zig +7 -0
  151. package/third_party/sqlite/README.md +13 -0
  152. package/third_party/sqlite/sqlite3.c +269649 -0
  153. package/third_party/sqlite/sqlite3.h +14349 -0
  154. package/tools/corewire/core_abi.zig +14 -2
  155. package/tools/corewire/emit.zig +98 -29
  156. package/tools/corewire/emit_facade.zig +442 -27
  157. package/tools/corewire/emit_profile.zig +6 -2
  158. package/tools/corewire/emit_service.zig +924 -0
  159. package/tools/corewire/main.zig +122 -0
  160. package/tools/corewire/service_contract.zig +250 -0
  161. package/tools/corewire/sidecar.zig +26 -15
@@ -4,7 +4,7 @@
4
4
  // this CLI is the frontend — the subset's teaching surface and the
5
5
  // contract source.
6
6
  //
7
- // native-core <entry.ts> [--contract <out.contract.json>] [--contract-entry <spelling>]
7
+ // native-core <entry.ts> [--contract <out.contract.json>] [--services-contract <services.contract.json>]
8
8
  //
9
9
  // --contract writes the contract sidecar (core.contract.json, schema
10
10
  // format 1) emitted directly from the checked program — the document the
@@ -16,18 +16,111 @@
16
16
  // errors (teaching diagnostics on stderr); 2 usage.
17
17
 
18
18
  import { checkFile, formatDiagnostic, type FrontendOptions } from "./frontend.ts";
19
+ import type { ServicePackage } from "./service_contract.ts";
19
20
  import fs from "node:fs";
21
+ import path from "node:path";
22
+ import ts from "@typescript/old";
20
23
 
21
24
  function main(argv: string[]): number {
22
25
  const args = argv.slice(2);
23
26
  let entry: string | null = null;
24
27
  let contractOut: string | null = null;
28
+ let servicesContractOut: string | null = null;
29
+ let servicesClientOut: string | null = null;
30
+ let servicesEditorClientOut: string | null = null;
25
31
  let contractEntry: string | null = null;
32
+ let persistVersion: number | null = null;
33
+ let persistStatePath: string | null = null;
34
+ let persistOk: string | null = null;
35
+ let persistNone: string | null = null;
36
+ let persistErr: string | null = null;
37
+ let sdkCorePath: string | null = null;
38
+ let windowViewsEnabled = false;
39
+ const windowViews: string[] = [];
40
+ const capabilities: string[] = [];
41
+ const permissions: string[] = [];
42
+ const servicePackages: ServicePackage[] = [];
26
43
  for (let i = 0; i < args.length; i++) {
27
44
  if (args[i] === "--contract") {
28
45
  contractOut = args[++i] ?? null;
46
+ } else if (args[i] === "--services-contract") {
47
+ servicesContractOut = args[++i] ?? null;
48
+ } else if (args[i] === "--services-client") {
49
+ servicesClientOut = args[++i] ?? null;
50
+ } else if (args[i] === "--services-editor-client") {
51
+ servicesEditorClientOut = args[++i] ?? null;
52
+ } else if (args[i] === "--service-package") {
53
+ const spelling = args[++i] ?? "";
54
+ const [name, version, content_hash, extra] = spelling.split("|");
55
+ if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/i.test(name ?? "") || !/^\d+\.\d+\.\d+$/.test(version ?? "") || !/^[0-9a-f]{64}$/.test(content_hash ?? "") || extra !== undefined) {
56
+ console.error("--service-package requires name|exact-version|64-hex-content-hash");
57
+ return 2;
58
+ }
59
+ servicePackages.push({ name, version, content_hash });
29
60
  } else if (args[i] === "--contract-entry") {
30
61
  contractEntry = args[++i] ?? null;
62
+ } else if (args[i] === "--capability") {
63
+ const capability = args[++i] ?? null;
64
+ if (capability === null) {
65
+ console.error("--capability requires a name");
66
+ return 2;
67
+ }
68
+ capabilities.push(capability);
69
+ } else if (args[i] === "--permission") {
70
+ const permission = args[++i] ?? null;
71
+ if (permission === null) {
72
+ console.error("--permission requires a name");
73
+ return 2;
74
+ }
75
+ permissions.push(permission);
76
+ } else if (args[i] === "--persist-version") {
77
+ const spelling = args[++i] ?? "";
78
+ const version = Number(spelling);
79
+ if (!Number.isSafeInteger(version) || version <= 0) {
80
+ console.error("--persist-version requires a positive safe integer");
81
+ return 2;
82
+ }
83
+ persistVersion = version;
84
+ } else if (args[i] === "--persist-state") {
85
+ persistStatePath = args[++i] ?? null;
86
+ if (persistStatePath === null) {
87
+ console.error("--persist-state requires a path");
88
+ return 2;
89
+ }
90
+ } else if (args[i] === "--persist-ok") {
91
+ persistOk = args[++i] ?? null;
92
+ if (persistOk === null) {
93
+ console.error("--persist-ok requires a Msg arm name");
94
+ return 2;
95
+ }
96
+ } else if (args[i] === "--persist-none") {
97
+ persistNone = args[++i] ?? null;
98
+ if (persistNone === null) {
99
+ console.error("--persist-none requires a Msg arm name");
100
+ return 2;
101
+ }
102
+ } else if (args[i] === "--persist-err") {
103
+ persistErr = args[++i] ?? null;
104
+ if (persistErr === null) {
105
+ console.error("--persist-err requires a Msg arm name");
106
+ return 2;
107
+ }
108
+ } else if (args[i] === "--sdk-core") {
109
+ sdkCorePath = args[++i] ?? null;
110
+ if (sdkCorePath === null) {
111
+ console.error("--sdk-core requires a generated core.ts path");
112
+ return 2;
113
+ }
114
+ } else if (args[i] === "--window-views") {
115
+ windowViewsEnabled = true;
116
+ } else if (args[i] === "--window-view") {
117
+ windowViewsEnabled = true;
118
+ const label = args[++i] ?? null;
119
+ if (label === null || label.length === 0) {
120
+ console.error("--window-view requires a non-empty label");
121
+ return 2;
122
+ }
123
+ windowViews.push(label);
31
124
  } else if (args[i] === "-o" || args[i] === "--out") {
32
125
  console.error(
33
126
  "-o named the removed TS-to-Zig emitter (v0.7.0 removed it): TypeScript cores compile through the external core compiler now, and this CLI checks the core and emits its contract sidecar (--contract). Drop the flag.",
@@ -42,19 +135,37 @@ function main(argv: string[]): number {
42
135
  }
43
136
  if (!entry) {
44
137
  console.error(
45
- "usage: native-core <entry.ts> [--contract <out.contract.json>] [--contract-entry <spelling>]",
138
+ "usage: native-core <entry.ts> [--contract <out.contract.json>] [--services-contract <services.contract.json>] [--contract-entry <spelling>]",
46
139
  );
47
140
  return 2;
48
141
  }
142
+ const persistRouteCount = [persistOk, persistNone, persistErr].filter((route) => route !== null).length;
143
+ if (persistRouteCount !== 0 && persistRouteCount !== 3) {
144
+ console.error("--persist-ok, --persist-none, and --persist-err must be provided together");
145
+ return 2;
146
+ }
147
+ const persistRoutes =
148
+ persistOk !== null && persistNone !== null && persistErr !== null
149
+ ? { ok: persistOk, none: persistNone, err: persistErr }
150
+ : undefined;
49
151
  const options: FrontendOptions = {
50
152
  // The document's entry spelling defaults to the argument's own,
51
153
  // POSIX separators (the sidecar/facade contract is platform-free).
52
154
  contractEntry: contractOut !== null ? (contractEntry ?? entry.split("\\").join("/")) : undefined,
155
+ servicesContract: servicesContractOut !== null,
156
+ servicePackages,
157
+ capabilities,
158
+ permissions,
159
+ persistVersion: persistVersion ?? undefined,
160
+ persistStatePath: persistStatePath ?? undefined,
161
+ persistRoutes,
162
+ sdkCorePath: sdkCorePath ?? undefined,
163
+ windowViews: windowViewsEnabled ? windowViews : undefined,
53
164
  };
54
165
  const result = checkFile(entry, options);
55
166
  for (const e of result.typeErrors) console.error(e);
56
167
  for (const d of result.diagnostics) console.error(formatDiagnostic(d));
57
- // Teaching notices (NS1028): printed, never failing the build.
168
+ // Teaching notices: printed, never failing the build.
58
169
  for (const w of result.warnings) console.error(formatDiagnostic(w, "warning"));
59
170
  if (!result.ok) return 1;
60
171
  if (contractOut !== null) {
@@ -64,6 +175,48 @@ function main(argv: string[]): number {
64
175
  }
65
176
  fs.writeFileSync(contractOut, result.contract);
66
177
  }
178
+ if (servicesContractOut !== null) {
179
+ if (result.servicesContract === null) {
180
+ console.error("the app has no src/services/**/*.ts modules, so there is no service contract to emit");
181
+ return 1;
182
+ }
183
+ fs.writeFileSync(servicesContractOut, result.servicesContract);
184
+ }
185
+ if (servicesClientOut !== null) {
186
+ if (result.servicesClient === null) {
187
+ console.error("the app has no src/services/**/*.ts modules, so there is no typed service client to emit");
188
+ return 1;
189
+ }
190
+ fs.writeFileSync(servicesClientOut, result.servicesClient);
191
+ }
192
+ if (servicesEditorClientOut !== null) {
193
+ if (result.servicesClient === null) {
194
+ console.error("the app has no src/services/**/*.ts modules, so there is no typed service client to emit");
195
+ return 1;
196
+ }
197
+ const editorDir = path.dirname(servicesEditorClientOut);
198
+ fs.mkdirSync(editorDir, { recursive: true });
199
+ const sourcePrefix = path.relative(path.resolve(editorDir), path.dirname(path.resolve(entry))).split(path.sep).join("/");
200
+ const editorSource = result.servicesClient.replaceAll('from "./', `from "${sourcePrefix}/`);
201
+ fs.writeFileSync(servicesEditorClientOut, editorSource);
202
+ const declaration = ts.transpileDeclaration(editorSource, {
203
+ fileName: "index.ts",
204
+ compilerOptions: { target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext },
205
+ reportDiagnostics: true,
206
+ });
207
+ if (declaration.diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) {
208
+ console.error("internal: the generated editor service client could not emit declarations");
209
+ return 1;
210
+ }
211
+ fs.writeFileSync(`${editorDir}/index.d.ts`, declaration.outputText);
212
+ fs.writeFileSync(`${editorDir}/package.json`, `${JSON.stringify({
213
+ name: "@native-sdk/services",
214
+ private: true,
215
+ type: "module",
216
+ types: "./index.d.ts",
217
+ exports: { ".": { types: "./index.d.ts", default: "./index.ts" } },
218
+ }, null, 2)}\n`);
219
+ }
67
220
  return 0;
68
221
  }
69
222
 
@@ -457,6 +457,13 @@ class ContractEmitter {
457
457
  }
458
458
  }
459
459
  }
460
+ // `statusItem` is consumed by the generated launcher, not markup. It
461
+ // is still an ordinary Model helper in the core ABI, so teach native
462
+ // check that this one helper is intentionally shell-bound without
463
+ // making every app repeat it in `viewUnbound`.
464
+ if (helperNames.includes("statusItem") && !model.includes("statusItem")) model.push("statusItem");
465
+ if (helperNames.includes("statusItems") && !model.includes("statusItems")) model.push("statusItems");
466
+ if (helperNames.includes("windows") && !model.includes("windows")) model.push("windows");
460
467
  return { model, msg };
461
468
  }
462
469
 
@@ -507,6 +514,11 @@ class ContractEmitter {
507
514
  // payload the number_bytes family does not absorb, then helper
508
515
  // returns (first-visit order; the extractor's root order).
509
516
  this.collect({ k: "struct", name: modelName }, null, "", "");
517
+ // collect(Model) recursively closes over every type reachable from the
518
+ // model. Remember that prefix before Msg/helper-only types join the table;
519
+ // persistence fingerprints exactly this prefix, so a Msg-only edit does
520
+ // not spuriously require a snapshot schema bump.
521
+ const modelEntryCount = this.entries.length;
510
522
  for (const arm of msg.arms) {
511
523
  if (arm.fields.length === 0) continue;
512
524
  if (this.isNumberBytesShape(arm)) continue;
@@ -525,7 +537,8 @@ class ContractEmitter {
525
537
  let structCount = 0;
526
538
  let enumCount = 0;
527
539
  let unionCount = 0;
528
- for (const entry of this.entries) {
540
+ const modelShapeParts: string[] = [];
541
+ for (const [entryIndex, entry] of this.entries.entries()) {
529
542
  if (entry.kind === "struct") {
530
543
  let fields = "";
531
544
  entry.fields.forEach((f, index) => {
@@ -535,11 +548,13 @@ class ContractEmitter {
535
548
  });
536
549
  if (structCount > 0) structs += ",\n ";
537
550
  structs += `{"name": ${js(entry.name)}${this.originFragment(entry.name)}, "fields": [${fields}]}`;
551
+ if (entryIndex < modelEntryCount) modelShapeParts.push(`struct:${entry.name}:${fields}`);
538
552
  structCount += 1;
539
553
  } else if (entry.kind === "enum") {
540
554
  const members = entry.members.map((m) => js(m)).join(", ");
541
555
  if (enumCount > 0) enums += ",\n ";
542
556
  enums += `{"name": ${js(entry.name)}${this.originFragment(entry.name)}, "members": [${members}]}`;
557
+ if (entryIndex < modelEntryCount) modelShapeParts.push(`enum:${entry.name}:${members}`);
543
558
  enumCount += 1;
544
559
  } else {
545
560
  let arms = "";
@@ -552,6 +567,7 @@ class ContractEmitter {
552
567
  });
553
568
  if (unionCount > 0) unions += ",\n ";
554
569
  unions += `{"name": ${js(entry.name)}${this.originFragment(entry.name)}, "arms": [${arms}]}`;
570
+ if (entryIndex < modelEntryCount) modelShapeParts.push(`union:${entry.name}:${arms}`);
555
571
  unionCount += 1;
556
572
  }
557
573
  }
@@ -600,13 +616,14 @@ class ContractEmitter {
600
616
  const initReturnsBare = initReturnsCmd && this.returnsBareModel(this.entryExportedFunction("initialModel"));
601
617
  const updateReturnsBare = updateReturnsCmd && this.returnsBareModel(this.entryExportedFunction("update"));
602
618
  const hasSubscriptions = this.entryExportedFunction("subscriptions") !== null;
619
+ const hasMigrate = this.entryExportedFunction("migrate") !== null;
603
620
 
604
621
  let abiExports =
605
622
  '"abi_version", "build_id", "set_panic_sink", "init", "collect", ' +
606
623
  '"frame_reset", "boot_cmd", "dispatch_void", "dispatch_bytes", ' +
607
624
  '"dispatch_number", "dispatch_number_bytes", "dispatch_bool", "dispatch_enum", ' +
608
625
  '"dispatch_record", "dispatch_text_input", "dispatch_scroll_state", ' +
609
- '"subscriptions", "model_snapshot", "helper_call"';
626
+ '"subscriptions", "model_snapshot", "persist_snapshot", "restore_model", "migrate_model", "helper_call"';
610
627
  if (hasCommand) abiExports += ', "command_msg"';
611
628
  if (hasFrame) abiExports += ', "frame_msg"';
612
629
  if (hasKey) abiExports += ', "key_msg"';
@@ -639,20 +656,25 @@ class ContractEmitter {
639
656
  `\x00exports=${abiExports}` +
640
657
  `\x00flags=${boolJson(initReturnsCmd)}${boolJson(updateReturnsCmd)}` +
641
658
  `${boolJson(hasSubscriptions)}${boolJson(hasCommand)}${boolJson(hasFrame)}` +
642
- `${boolJson(hasKey)}${boolJson(hasPinch)}${boolJson(hasDrop)}`;
659
+ `${boolJson(hasKey)}${boolJson(hasPinch)}${boolJson(hasDrop)}${boolJson(hasMigrate)}`;
643
660
  const surfaceBytes = new TextEncoder().encode(surface);
644
661
  const sourceHash = wyhashHex(0x5eedc0den, surfaceBytes);
645
662
  const buildId = wyhashHex(0xb11d1d00n, surfaceBytes);
663
+ const modelFingerprint = wyhashHex(
664
+ 0x5a9e5eedn,
665
+ new TextEncoder().encode(`model=${modelName}\x00${modelShapeParts.join("\x00")}`),
666
+ );
646
667
 
647
668
  return (
648
669
  "{\n" +
649
670
  ' "format": 1,\n' +
650
- ' "wire_version": 3,\n' +
651
- ' "abi_version": 1,\n' +
671
+ ' "wire_version": 7,\n' +
672
+ ' "abi_version": 2,\n' +
652
673
  ' "compiler_version": "0.0.1",\n' +
653
674
  ` "entry": ${js(this.entry)},\n` +
654
675
  ` "source_hash": "${sourceHash}",\n` +
655
676
  ` "build_id": "${buildId}",\n` +
677
+ ` "model_fingerprint": "${modelFingerprint}",\n` +
656
678
  ` "types": ${typesJson},\n` +
657
679
  ` "model": ${js(modelName)},\n` +
658
680
  ` "model_helpers": [${helperCount > 0 ? `\n ${helpers}\n ` : ""}],\n` +
@@ -663,6 +685,7 @@ class ContractEmitter {
663
685
  (initReturnsBare ? ' "init_returns_bare": true,\n' : "") +
664
686
  (updateReturnsBare ? ' "update_returns_bare": true,\n' : "") +
665
687
  ` "has_subscriptions": ${boolJson(hasSubscriptions)},\n` +
688
+ ` "has_migrate": ${boolJson(hasMigrate)},\n` +
666
689
  ' "channels": {\n' +
667
690
  ` "command_msg": ${boolJson(hasCommand)},\n` +
668
691
  ` "frame_msg": ${boolJson(hasFrame)},\n` +