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