@native-sdk/cli 0.7.2 → 0.8.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.
- package/build/app.zig +265 -65
- package/build/ts_run.mjs +6 -8
- package/build.zig +292 -349
- package/package.json +13 -11
- package/packages/core/compile-surface/core.ts +559 -0
- package/packages/core/package-lock.json +375 -12
- package/packages/core/package.json +9 -6
- package/packages/core/scripts/compiler_typecheck.mjs +58 -0
- package/packages/core/scripts/gen_case_tables.mjs +130 -0
- package/packages/core/scripts/gen_declarations.mjs +97 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
- package/packages/core/scripts/stage_external_core.mjs +148 -0
- package/packages/core/sdk/core.d.ts +363 -0
- package/packages/core/sdk/events.d.ts +65 -0
- package/packages/core/sdk/text.d.ts +51 -0
- package/packages/core/src/checker.ts +3 -3
- package/packages/core/src/cli.ts +40 -38
- package/packages/core/src/contract.ts +749 -0
- package/packages/core/src/devhost.ts +4 -3
- package/packages/core/src/diagnostics.ts +5 -7
- package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
- package/packages/core/src/infer.ts +1 -1
- package/packages/core/src/typed_ast.ts +16 -15
- package/packages/core/src/wyhash.ts +79 -0
- package/skill-data/native-ui/SKILL.md +3 -2
- package/skill-data/ts-core/SKILL.md +29 -29
- package/src/platform/macos/appkit_host.h +4 -4
- package/src/platform/macos/appkit_host.m +24 -4
- package/src/platform/macos/cef_host.mm +22 -6
- package/src/platform/macos/root.zig +2 -2
- package/src/primitives/canvas/markdown.zig +2010 -57
- package/src/primitives/canvas/markdown_hostile_tests.zig +40 -0
- package/src/primitives/canvas/markdown_tests.zig +778 -3
- package/src/primitives/canvas/ui_markup.zig +9 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +29 -0
- package/src/primitives/canvas/ui_markup_contract.zig +11 -0
- package/src/primitives/canvas/ui_markup_view.zig +20 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +13 -1
- package/src/primitives/canvas/ui_schema.zig +3 -0
- package/src/primitives/canvas/ui_schema_tests.zig +4 -3
- package/src/primitives/canvas/widget_layout.zig +26 -3
- package/src/primitives/canvas/widget_metrics.zig +21 -3
- package/src/primitives/canvas/widget_render.zig +6 -1
- package/src/runtime/effects.zig +9 -0
- package/src/runtime/effects_fetch_tests.zig +21 -0
- package/src/runtime/ts_core_host.zig +38 -38
- package/src/runtime/ts_ui_app.zig +12 -12
- package/src/tooling/manifest.zig +32 -0
- package/src/tooling/raw_manifest.zig +4 -0
- package/src/tooling/templates.zig +25 -20
- package/src/tooling/ts_core.zig +55 -34
- package/src/tooling/verbs.zig +1 -1
- package/tools/corewire/core_abi.zig +169 -0
- package/tools/corewire/emit.zig +2418 -0
- package/tools/corewire/emit_facade.zig +3984 -0
- package/tools/corewire/emit_profile.zig +501 -0
- package/tools/corewire/main.zig +561 -0
- package/tools/corewire/shim_rt.zig +632 -0
- package/tools/corewire/sidecar.zig +2507 -0
- package/packages/core/rt/rt.zig +0 -1986
- package/packages/core/src/emitter.ts +0 -11898
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//! `TsUiApp(core)` — the first-class UiApp adapter for
|
|
2
|
-
//! cores: the committed TS model IS the app model. Where a Zig core
|
|
3
|
-
//! hands `UiApp` a mutable model plus `update`, a
|
|
1
|
+
//! `TsUiApp(core)` — the first-class UiApp adapter for compiled
|
|
2
|
+
//! TypeScript app cores: the committed TS model IS the app model. Where a Zig core
|
|
3
|
+
//! hands `UiApp` a mutable model plus `update`, a compiled TypeScript core is an
|
|
4
4
|
//! immutable committed graph plus a pure `update` returning the next
|
|
5
5
|
//! root — this adapter closes that gap with no per-app glue:
|
|
6
6
|
//!
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
//! `chromeMsg` -> `on_appearance`/`on_chrome`, each host event built
|
|
33
33
|
//! structurally by field name from the core's declared records (the
|
|
34
34
|
//! effects-routing rule applied to the app shell; every shape mismatch
|
|
35
|
-
//! is a teaching compile error re-deriving the
|
|
35
|
+
//! is a teaching compile error re-deriving the frontend's NS1033).
|
|
36
36
|
//! `CoreOptions` carries the launch-boundary channels the wiring
|
|
37
37
|
//! resolves: `boot_images` (app.zon assets, registered on the
|
|
38
38
|
//! installing frame) and `env_values` (the core's `envMsgs` variables,
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
//! Record/replay, automation, and pixel fingerprints need nothing
|
|
53
53
|
//! extra: the adapter rides the ordinary UiApp dispatch path, so the
|
|
54
54
|
//! session journal, the automation verbs, and the screenshot marks see
|
|
55
|
-
//! a
|
|
56
|
-
//! contract is the bridge's: one live app per core module (two
|
|
57
|
-
//! over one
|
|
58
|
-
//!
|
|
55
|
+
//! a compiled TypeScript core exactly as they see a Zig one. The
|
|
56
|
+
//! process contract is the bridge's: one live app per core module (two
|
|
57
|
+
//! apps over one core would share a committed root), and one compiled
|
|
58
|
+
//! archive per process (the fixed-prefix C ABI symbol set).
|
|
59
59
|
|
|
60
60
|
const std = @import("std");
|
|
61
61
|
const canvas = @import("canvas");
|
|
@@ -100,7 +100,7 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
/// Adapter-owned configuration — the knobs that exist because
|
|
103
|
-
/// the core is
|
|
103
|
+
/// the core is TypeScript, kept separate from `App.Options` so
|
|
104
104
|
/// the wiring surface reads as ordinary UiApp wiring.
|
|
105
105
|
pub const CoreOptions = struct {
|
|
106
106
|
/// Platform caches directory for URL audio playback: when a
|
|
@@ -172,7 +172,7 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
172
172
|
|
|
173
173
|
fn stampOptions(options: Options) Options {
|
|
174
174
|
if (options.update != null or options.update_fx != null) {
|
|
175
|
-
@panic("TsUiApp owns update: the
|
|
175
|
+
@panic("TsUiApp owns update: the TypeScript core is the update loop - remove the wiring's update/update_fx");
|
|
176
176
|
}
|
|
177
177
|
if (options.init_fx != null) {
|
|
178
178
|
@panic("TsUiApp owns init_fx: the core's initialModel boots the app - remove the wiring's init_fx");
|
|
@@ -282,7 +282,7 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
/// Teaching re-derivation of the
|
|
285
|
+
/// Teaching re-derivation of the frontend's NS1033 for
|
|
286
286
|
/// hand-assembled cores: every `envMsgs` entry must name a Msg
|
|
287
287
|
/// arm carrying exactly one bytes payload.
|
|
288
288
|
fn validateEnvMsgs() void {
|
|
@@ -472,7 +472,7 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
/// The Msg arm index a channel export names, with the teaching
|
|
475
|
-
/// error the
|
|
475
|
+
/// error the frontend's NS1033 re-derives for hand-written
|
|
476
476
|
/// cores.
|
|
477
477
|
fn channelArmIndex(comptime tag: []const u8, comptime channel: []const u8) usize {
|
|
478
478
|
for (@typeInfo(Msg).@"union".fields, 0..) |arm, index| {
|
package/src/tooling/manifest.zig
CHANGED
|
@@ -28,6 +28,10 @@ pub const Metadata = struct {
|
|
|
28
28
|
/// inferred from the manifest's web declarations), "include", or
|
|
29
29
|
/// "exclude". See `webLayer` for the inference.
|
|
30
30
|
webview_layer: []const u8 = "auto",
|
|
31
|
+
/// How a TypeScript core compiles: "external" (the default and only
|
|
32
|
+
/// lane — the external core compiler). The removed transpiled
|
|
33
|
+
/// lane's spelling is refused with a teaching at validation.
|
|
34
|
+
core_compiler: []const u8 = "external",
|
|
31
35
|
/// The built-in theme pack the app selects (`theme = "geist"`).
|
|
32
36
|
/// Optional — absent keeps the house register. Validated against
|
|
33
37
|
/// the known pack names so a typo is a check error, never a silent
|
|
@@ -64,6 +68,7 @@ pub const Metadata = struct {
|
|
|
64
68
|
allocator.free(self.version);
|
|
65
69
|
allocator.free(self.web_engine);
|
|
66
70
|
allocator.free(self.webview_layer);
|
|
71
|
+
allocator.free(self.core_compiler);
|
|
67
72
|
allocator.free(self.cef.dir);
|
|
68
73
|
for (self.icons) |value| allocator.free(value);
|
|
69
74
|
if (self.icons.len > 0) allocator.free(self.icons);
|
|
@@ -430,6 +435,12 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
|
|
|
430
435
|
defer allocator.free(url_schemes);
|
|
431
436
|
const manifest_web_engine = parseWebEngine(metadata.web_engine) catch return .{ .ok = false, .message = "app.zon web engine is invalid" };
|
|
432
437
|
const manifest_webview_layer = parseWebViewLayer(metadata.webview_layer) catch return .{ .ok = false, .message = "app.zon webview_layer is invalid - expected \"auto\", \"include\", or \"exclude\"" };
|
|
438
|
+
if (!std.mem.eql(u8, metadata.core_compiler, "external")) {
|
|
439
|
+
if (std.mem.eql(u8, metadata.core_compiler, "transpiler")) {
|
|
440
|
+
return .{ .ok = false, .message = "app.zon core_compiler = \"transpiler\" names the removed TS-to-Zig transpiled lane (v0.7.0 removed it) - TypeScript cores compile through the external core compiler now; delete the setting (or spell it \"external\")" };
|
|
441
|
+
}
|
|
442
|
+
return .{ .ok = false, .message = "app.zon core_compiler is invalid - expected \"external\" (the default and only lane)" };
|
|
443
|
+
}
|
|
433
444
|
const platform_settings = parsePlatformSettings(allocator, metadata.platforms) catch return .{ .ok = false, .message = "app.zon platforms are invalid" };
|
|
434
445
|
defer allocator.free(platform_settings);
|
|
435
446
|
|
|
@@ -514,6 +525,7 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
|
|
|
514
525
|
.bridge_commands = try convertRawBridgeCommands(allocator, raw.bridge.commands),
|
|
515
526
|
.web_engine = try allocator.dupe(u8, raw.web_engine),
|
|
516
527
|
.webview_layer = try allocator.dupe(u8, raw.webview_layer),
|
|
528
|
+
.core_compiler = try allocator.dupe(u8, raw.core_compiler),
|
|
517
529
|
.cef = .{
|
|
518
530
|
.dir = try allocator.dupe(u8, raw.cef.dir),
|
|
519
531
|
.auto_install = raw.cef.auto_install,
|
|
@@ -1946,6 +1958,26 @@ test "manifest parser reads window close policies" {
|
|
|
1946
1958
|
try std.testing.expectEqual(app_manifest.WindowClosePolicy.hide, shell.windows[0].close_policy);
|
|
1947
1959
|
}
|
|
1948
1960
|
|
|
1961
|
+
test "manifest parser reads the core-compiler setting and defaults it to external" {
|
|
1962
|
+
const metadata = try parseText(std.testing.allocator,
|
|
1963
|
+
\\.{
|
|
1964
|
+
\\ .id = "com.example.app",
|
|
1965
|
+
\\ .name = "example",
|
|
1966
|
+
\\ .version = "1.2.3",
|
|
1967
|
+
\\ .core_compiler = "external",
|
|
1968
|
+
\\}
|
|
1969
|
+
);
|
|
1970
|
+
defer metadata.deinit(std.testing.allocator);
|
|
1971
|
+
try std.testing.expectEqualStrings("external", metadata.core_compiler);
|
|
1972
|
+
|
|
1973
|
+
// Undeclared is the external lane — the one lane there is.
|
|
1974
|
+
const defaulted = try parseText(std.testing.allocator,
|
|
1975
|
+
\\.{ .id = "com.example.app", .name = "example", .version = "1.2.3" }
|
|
1976
|
+
);
|
|
1977
|
+
defer defaulted.deinit(std.testing.allocator);
|
|
1978
|
+
try std.testing.expectEqualStrings("external", defaulted.core_compiler);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1949
1981
|
test "manifest parser rejects unknown window close policy" {
|
|
1950
1982
|
const metadata = try parseText(std.testing.allocator,
|
|
1951
1983
|
\\.{
|
|
@@ -13,6 +13,10 @@ pub const RawManifest = struct {
|
|
|
13
13
|
bridge: RawBridge = .{},
|
|
14
14
|
web_engine: []const u8 = @tagName(web_engine.default_engine),
|
|
15
15
|
webview_layer: []const u8 = "auto",
|
|
16
|
+
/// How a TypeScript core compiles: "external" (the default and only
|
|
17
|
+
/// lane — the external core compiler). The removed transpiled
|
|
18
|
+
/// lane's spelling is refused with a teaching at validation.
|
|
19
|
+
core_compiler: []const u8 = "external",
|
|
16
20
|
theme: ?[]const u8 = null,
|
|
17
21
|
theme_accent: ?[]const u8 = null,
|
|
18
22
|
cef: RawCef = .{},
|
|
@@ -184,8 +184,9 @@ fn slimGitignore() []const u8 {
|
|
|
184
184
|
|
|
185
185
|
/// The TypeScript-core zero-config scaffold - the `native init` default:
|
|
186
186
|
/// core.ts (logic), app.native (view), app.zon (manifest). ZERO Zig in the
|
|
187
|
-
/// tree; the build graph detects src/core.ts,
|
|
188
|
-
/// generated wiring outside the app
|
|
187
|
+
/// tree; the build graph detects src/core.ts, compiles it through the
|
|
188
|
+
/// external core compiler, and stages the generated wiring outside the app
|
|
189
|
+
/// on every build.
|
|
189
190
|
///
|
|
190
191
|
/// The tree also carries the EDITOR surface: package.json + tsconfig.json,
|
|
191
192
|
/// so stock editor TypeScript resolves `@native-sdk/core` with full
|
|
@@ -260,7 +261,7 @@ fn writeTsEditorSurface(allocator: std.mem.Allocator, io: std.Io, app_dir: std.I
|
|
|
260
261
|
/// The app's package.json: name + the pinned `@native-sdk/core` dependency,
|
|
261
262
|
/// nothing else. It exists for editors and versioning only — the `native`
|
|
262
263
|
/// verbs never read it (tree detection keys on src/core.ts; the build
|
|
263
|
-
///
|
|
264
|
+
/// checks and compiles against the SDK checkout) — and the pin is exact so the
|
|
264
265
|
/// post-publish `npm install` resolves the same content the CLI
|
|
265
266
|
/// materialized.
|
|
266
267
|
fn tsPackageJson(allocator: std.mem.Allocator, names: TemplateNames, sdk_version: []const u8) ![]const u8 {
|
|
@@ -339,7 +340,7 @@ fn tsGitignore() []const u8 {
|
|
|
339
340
|
fn tsCoreStarter() []const u8 {
|
|
340
341
|
return
|
|
341
342
|
\\// The app core: Model, Msg, update, and the pure helpers they call -
|
|
342
|
-
\\// plain TypeScript in the app-core subset, compiled to native
|
|
343
|
+
\\// plain TypeScript in the app-core subset, compiled to native code at
|
|
343
344
|
\\// build time (no JS runtime ships in the binary). The view lives in
|
|
344
345
|
\\// app.native and binds this model by its own field names exactly as
|
|
345
346
|
\\// written here (`tickCount` binds as `{tickCount}`).
|
|
@@ -384,9 +385,12 @@ fn tsCoreStarter() []const u8 {
|
|
|
384
385
|
\\export function update(model: Model, msg: Msg): Model | [Model, Cmd<Msg>] {
|
|
385
386
|
\\ switch (msg.kind) {
|
|
386
387
|
\\ case "increment":
|
|
387
|
-
\\
|
|
388
|
+
\\ // Bounded on purpose: integer model fields carry a compile-time
|
|
389
|
+
\\ // range proof, and the literal comparison is what makes `+ 1`
|
|
390
|
+
\\ // provable.
|
|
391
|
+
\\ return { ...model, count: model.count < 1000000 ? model.count + 1 : model.count };
|
|
388
392
|
\\ case "decrement":
|
|
389
|
-
\\ return { ...model, count: model.count - 1 };
|
|
393
|
+
\\ return { ...model, count: model.count > -1000000 ? model.count - 1 : model.count };
|
|
390
394
|
\\ case "reset":
|
|
391
395
|
\\ return { ...model, count: 0, tickCount: 0 };
|
|
392
396
|
\\ case "toggle_ticking":
|
|
@@ -398,7 +402,7 @@ fn tsCoreStarter() []const u8 {
|
|
|
398
402
|
\\ case "stamped":
|
|
399
403
|
\\ return { ...model, stampedMs: msg.at };
|
|
400
404
|
\\ case "tick":
|
|
401
|
-
\\ return { ...model, tickCount: model.tickCount + 1 };
|
|
405
|
+
\\ return { ...model, tickCount: model.tickCount < 1000000 ? model.tickCount + 1 : model.tickCount };
|
|
402
406
|
\\ }
|
|
403
407
|
\\}
|
|
404
408
|
\\
|
|
@@ -499,8 +503,9 @@ fn tsSlimReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
|
|
|
499
503
|
\\
|
|
500
504
|
\\## Requirements
|
|
501
505
|
\\
|
|
502
|
-
\\Node.js 22.15+ (on the 23 line: 23.5+) on PATH (the TypeScript
|
|
503
|
-
\\
|
|
506
|
+
\\Node.js 22.15+ (on the 23 line: 23.5+) on PATH (the TypeScript frontend
|
|
507
|
+
\\and the core compiler run at build time; your shipped binary carries
|
|
508
|
+
\\none of it).
|
|
504
509
|
\\
|
|
505
510
|
);
|
|
506
511
|
return out.toOwnedSlice(allocator);
|
|
@@ -1150,9 +1155,9 @@ fn nativeReadme(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1150
1155
|
/// real binary and asserts on the accessibility snapshot. The generated
|
|
1151
1156
|
/// file belongs to the user, like everything init writes. A TypeScript
|
|
1152
1157
|
/// core adds the node tier to both jobs: setup-node plus one `npm ci` in
|
|
1153
|
-
/// the fetched SDK's packages/core, because the @native-sdk/core
|
|
1154
|
-
///
|
|
1155
|
-
///
|
|
1158
|
+
/// the fetched SDK's packages/core, because the @native-sdk/core frontend
|
|
1159
|
+
/// and the external core compiler run at build time and arrive with that
|
|
1160
|
+
/// one install — the same install `native build`'s teaching names.
|
|
1156
1161
|
fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_path: []const u8, core: CoreTemplate) ![]const u8 {
|
|
1157
1162
|
const node_setup =
|
|
1158
1163
|
\\ - uses: actions/setup-node@v4
|
|
@@ -1160,11 +1165,11 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1160
1165
|
\\ node-version: 22
|
|
1161
1166
|
\\
|
|
1162
1167
|
;
|
|
1163
|
-
const
|
|
1164
|
-
\\ - name: Install the core
|
|
1168
|
+
const compiler_install =
|
|
1169
|
+
\\ - name: Install the core compiler dependency
|
|
1165
1170
|
\\ # src/core.ts compiles to native code at build time: the
|
|
1166
|
-
\\ # @native-sdk/core
|
|
1167
|
-
\\ #
|
|
1171
|
+
\\ # @native-sdk/core frontend and the external core compiler
|
|
1172
|
+
\\ # run from the SDK dependency and arrive with one install.
|
|
1168
1173
|
\\ run: npm ci --prefix "$NATIVE_SDK_PATH/packages/core"
|
|
1169
1174
|
\\
|
|
1170
1175
|
;
|
|
@@ -1213,7 +1218,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1213
1218
|
\\ fi
|
|
1214
1219
|
\\
|
|
1215
1220
|
);
|
|
1216
|
-
if (core == .ts) try out.appendSlice(allocator,
|
|
1221
|
+
if (core == .ts) try out.appendSlice(allocator, compiler_install);
|
|
1217
1222
|
try out.appendSlice(allocator,
|
|
1218
1223
|
\\ - run: zig build test -Dplatform=null
|
|
1219
1224
|
\\
|
|
@@ -1242,7 +1247,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1242
1247
|
\\ fi
|
|
1243
1248
|
\\
|
|
1244
1249
|
);
|
|
1245
|
-
if (core == .ts) try out.appendSlice(allocator,
|
|
1250
|
+
if (core == .ts) try out.appendSlice(allocator, compiler_install);
|
|
1246
1251
|
try out.appendSlice(allocator,
|
|
1247
1252
|
\\ - name: Build the Native SDK CLI
|
|
1248
1253
|
\\ run: cd "$NATIVE_SDK_PATH" && zig build
|
|
@@ -4173,8 +4178,8 @@ test "writeDefaultApp --full ts-core emits a CI workflow with the node tier" {
|
|
|
4173
4178
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "xvfb-run -a ./zig-out/bin/my-app &") != null);
|
|
4174
4179
|
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);
|
|
4175
4180
|
// Plus the node tier the TS build needs: node on PATH and the
|
|
4176
|
-
//
|
|
4177
|
-
// in BOTH jobs (each builds the app, so each
|
|
4181
|
+
// frontend + compiler install inside the fetched SDK's packages/core,
|
|
4182
|
+
// in BOTH jobs (each builds the app, so each compiles the core).
|
|
4178
4183
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "actions/setup-node@v4") != null);
|
|
4179
4184
|
const npm_ci = "npm ci --prefix \"$NATIVE_SDK_PATH/packages/core\"";
|
|
4180
4185
|
const first = std.mem.indexOf(u8, ci_yaml_text, npm_ci).?;
|
package/src/tooling/ts_core.zig
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//! TypeScript-core plumbing for the `native` CLI: tree detection (which
|
|
2
|
-
//! core does this app carry?), the
|
|
2
|
+
//! core does this app carry?), the frontend check pass `native check`
|
|
3
3
|
//! runs over src/core.ts, and the node dev-harness `native dev --core`
|
|
4
4
|
//! launches. The build graph re-derives the same detection in
|
|
5
5
|
//! build/app.zig; the CLI checks first so a both-cores tree fails with one
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
//! Multi-file cores: src/core.ts stays the detection root AND the entry
|
|
9
9
|
//! module, but a core may split into modules under src/ (relative imports
|
|
10
10
|
//! with real .ts filenames) plus SDK library modules
|
|
11
|
-
//! ("@native-sdk/core/text"). The
|
|
11
|
+
//! ("@native-sdk/core/text"). The frontend walks that import graph
|
|
12
12
|
//! itself, so `native check` reports diagnostics with each module's own
|
|
13
13
|
//! path, and `native dev --core` runs the same graph under node (relative
|
|
14
14
|
//! imports are real files; the resolver hook maps only the SDK names).
|
|
@@ -68,7 +68,7 @@ pub fn failBothCores() Error {
|
|
|
68
68
|
|
|
69
69
|
fn nodeMissing() Error {
|
|
70
70
|
std.debug.print(
|
|
71
|
-
\\TypeScript app cores need node on PATH (the @native-sdk/core
|
|
71
|
+
\\TypeScript app cores need node on PATH (the @native-sdk/core frontend and the
|
|
72
72
|
\\core dev-harness run under it; the binary you ship carries no JS runtime).
|
|
73
73
|
\\Install Node.js 22.15+ (on the 23 line: 23.5+) - https://nodejs.org or
|
|
74
74
|
\\`brew install node` - and re-run.
|
|
@@ -87,7 +87,7 @@ fn transpilerPath(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
|
|
|
87
87
|
return path;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
/// The layout-neutral runner for the
|
|
90
|
+
/// The layout-neutral runner for the frontend tier's .ts modules
|
|
91
91
|
/// (build/ts_run.mjs): a pass-through on a repo checkout, and the type
|
|
92
92
|
/// stripper for the npm-installed layout, where the same modules sit
|
|
93
93
|
/// inside node_modules and node refuses its builtin stripping. Every
|
|
@@ -103,7 +103,7 @@ fn tsRunnerPath(allocator: std.mem.Allocator, io: std.Io, framework_root: []cons
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/// The install command the repo-checkout teaching names. `--include=dev`
|
|
106
|
-
/// is correctness, not style: @typescript/
|
|
106
|
+
/// is correctness, not style: @typescript/old is packages/core's
|
|
107
107
|
/// devDependency, and a plain `npm ci` under ambient production npm config
|
|
108
108
|
/// (NODE_ENV=production, `omit=dev` in an npmrc) skips devDependencies
|
|
109
109
|
/// while exiting 0 — the named command would "succeed" and install
|
|
@@ -131,19 +131,13 @@ pub const npm_ci_teaching_command = "npm ci --include=dev";
|
|
|
131
131
|
/// (nested under the CLI on global prefixes, hoisted to the project
|
|
132
132
|
/// root on local ones, pnpm's sibling node_modules)
|
|
133
133
|
///
|
|
134
|
-
///
|
|
135
|
-
///
|
|
136
|
-
///
|
|
137
|
-
///
|
|
138
|
-
///
|
|
139
|
-
///
|
|
140
|
-
///
|
|
141
|
-
/// hoisted wrapper) while our exact pin lands nested under the CLI — and
|
|
142
|
-
/// that nested copy is precisely what runtime loads from packages/core;
|
|
143
|
-
/// a consumer's own shadowing wrapper install must not sway the verdict
|
|
144
|
-
/// either. The wrapper stays a DECLARED dependency in both manifests
|
|
145
|
-
/// (continuity semantics, and it keeps npm shipping the package) — it is
|
|
146
|
-
/// just not what validation vouches for.
|
|
134
|
+
/// A stray `@typescript/typescript6` compat wrapper in a consumer tree
|
|
135
|
+
/// (a former dependency of this package, or the consumer's own) is
|
|
136
|
+
/// deliberately NOT probed: nothing imports it at run time, and holding
|
|
137
|
+
/// the alias's version as seen FROM a wrapper's origin against the pin
|
|
138
|
+
/// can only FALSE-REJECT healthy trees — a consumer's hoisted conflicting
|
|
139
|
+
/// `@typescript/old` wins the walk from there while the copy runtime
|
|
140
|
+
/// actually loads sits correctly pinned under packages/core.
|
|
147
141
|
///
|
|
148
142
|
/// Resolvable means the alias's manifest AND its entrypoint are present
|
|
149
143
|
/// and its installed version equals the pin — see
|
|
@@ -313,7 +307,7 @@ fn pinnedCompilerVersion(allocator: std.mem.Allocator, io: std.Io, framework_roo
|
|
|
313
307
|
/// `npm ci` there would teach mutating an npm-owned tree.
|
|
314
308
|
fn transpilerDepsMissing(framework_root: []const u8) Error {
|
|
315
309
|
std.debug.print(
|
|
316
|
-
\\the @native-sdk/core
|
|
310
|
+
\\the @native-sdk/core frontend's dependencies are not installed
|
|
317
311
|
\\(its TypeScript compiler, @typescript/old, resolves nowhere). Fix with:
|
|
318
312
|
\\ cd {s}/packages/core && {s}
|
|
319
313
|
\\
|
|
@@ -351,7 +345,7 @@ fn toolchainInstallBroken(framework_root: []const u8) Error {
|
|
|
351
345
|
/// conflict instead.
|
|
352
346
|
fn compilerVersionMismatch(resolved: []const u8, pinned: []const u8) Error {
|
|
353
347
|
std.debug.print(
|
|
354
|
-
\\the
|
|
348
|
+
\\the frontend's TypeScript compiler resolves at the wrong version:
|
|
355
349
|
\\@typescript/old resolves to typescript {s}, but the SDK pins npm:typescript@{s}.
|
|
356
350
|
\\Another package in this tree pins a conflicting @typescript/old - align it with
|
|
357
351
|
\\the SDK's pin (or remove it) and reinstall, so the SDK's exact pin is the copy
|
|
@@ -409,23 +403,21 @@ pub fn ensureResolvedTranspiler(allocator: std.mem.Allocator, io: std.Io, framew
|
|
|
409
403
|
return transpilerDepsMissing(resolved);
|
|
410
404
|
}
|
|
411
405
|
|
|
412
|
-
/// `native check` over a TypeScript core: run the
|
|
413
|
-
///
|
|
414
|
-
/// graph under src/ — and surface its NS diagnostics verbatim —
|
|
415
|
-
/// are the teaching layer, nothing wraps them (each diagnostic
|
|
416
|
-
/// the owning module's path).
|
|
417
|
-
///
|
|
418
|
-
/// typechecked, subset-clean, emitted.
|
|
406
|
+
/// `native check` over a TypeScript core: run the frontend in
|
|
407
|
+
/// check-only mode on src/core.ts — and, through it, the core's whole
|
|
408
|
+
/// import graph under src/ — and surface its NS diagnostics verbatim —
|
|
409
|
+
/// they are the teaching layer, nothing wraps them (each diagnostic
|
|
410
|
+
/// carries the owning module's path). Exit 0 = typechecked,
|
|
411
|
+
/// subset-clean.
|
|
419
412
|
pub fn checkCore(allocator: std.mem.Allocator, io: std.Io, base_env: *std.process.Environ.Map, framework_root: []const u8) !void {
|
|
420
413
|
const cli_path = try transpilerPath(allocator, io, framework_root, "src/cli.ts");
|
|
421
414
|
defer allocator.free(cli_path);
|
|
422
415
|
const runner_path = try tsRunnerPath(allocator, io, framework_root);
|
|
423
416
|
defer allocator.free(runner_path);
|
|
424
417
|
try ensureResolvedTranspiler(allocator, io, framework_root);
|
|
425
|
-
try std.Io.Dir.cwd().createDirPath(io, ".native/check");
|
|
426
418
|
|
|
427
419
|
var child = std.process.spawn(io, .{
|
|
428
|
-
.argv = &.{ "node", runner_path, cli_path, "src/core.ts"
|
|
420
|
+
.argv = &.{ "node", runner_path, cli_path, "src/core.ts" },
|
|
429
421
|
.stdin = .ignore,
|
|
430
422
|
.stdout = .inherit,
|
|
431
423
|
.stderr = .inherit,
|
|
@@ -436,12 +428,41 @@ pub fn checkCore(allocator: std.mem.Allocator, io: std.Io, base_env: *std.proces
|
|
|
436
428
|
.exited => |code| if (code == 0) return,
|
|
437
429
|
else => {},
|
|
438
430
|
}
|
|
439
|
-
// The
|
|
431
|
+
// The frontend's own diagnostics are already on screen; name the
|
|
440
432
|
// failing pass without burying them.
|
|
441
433
|
std.debug.print("native check: src/core.ts failed the @native-sdk/core checker (diagnostics above)\n", .{});
|
|
442
434
|
return error.CoreCheckFailed;
|
|
443
435
|
}
|
|
444
436
|
|
|
437
|
+
/// The compiler-truth pass `checkCore` chains after the frontend: the
|
|
438
|
+
/// pinned external core compiler's analyzer over the same entry, with
|
|
439
|
+
/// the shipped SDK declarations mapped — the check verdict and the
|
|
440
|
+
/// build verdict come from ONE compiler. Analyzer type errors fail the
|
|
441
|
+
/// check with the compiler's own diagnostics; a toolchain that cannot
|
|
442
|
+
/// reach a verdict defers to the build rather than wedging check.
|
|
443
|
+
pub fn compilerTypecheckCore(allocator: std.mem.Allocator, io: std.Io, base_env: *std.process.Environ.Map, framework_root: []const u8) !void {
|
|
444
|
+
const script_path = try transpilerPath(allocator, io, framework_root, "scripts/compiler_typecheck.mjs");
|
|
445
|
+
defer allocator.free(script_path);
|
|
446
|
+
var child = std.process.spawn(io, .{
|
|
447
|
+
.argv = &.{ "node", script_path, "src/core.ts" },
|
|
448
|
+
.stdin = .ignore,
|
|
449
|
+
.stdout = .inherit,
|
|
450
|
+
.stderr = .inherit,
|
|
451
|
+
.environ_map = base_env,
|
|
452
|
+
}) catch return nodeMissing();
|
|
453
|
+
const term = try child.wait(io);
|
|
454
|
+
switch (term) {
|
|
455
|
+
.exited => |code| switch (code) {
|
|
456
|
+
0 => return,
|
|
457
|
+
2 => return error.MissingTranspiler,
|
|
458
|
+
else => {},
|
|
459
|
+
},
|
|
460
|
+
else => {},
|
|
461
|
+
}
|
|
462
|
+
std.debug.print("native check: src/core.ts does not typecheck under the external core compiler (its diagnostics above are the build's verdict too)\n", .{});
|
|
463
|
+
return error.CoreCheckFailed;
|
|
464
|
+
}
|
|
465
|
+
|
|
445
466
|
pub const DevHostOptions = struct {
|
|
446
467
|
base_env: *std.process.Environ.Map,
|
|
447
468
|
/// NDJSON message script; null = interactive stdin.
|
|
@@ -463,7 +484,7 @@ pub fn runDevHost(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
|
|
|
463
484
|
defer allocator.free(devhost_path);
|
|
464
485
|
const runner_path = try tsRunnerPath(allocator, io, framework_root);
|
|
465
486
|
defer allocator.free(runner_path);
|
|
466
|
-
// The harness runs the
|
|
487
|
+
// The harness runs the frontend tier under node, so it needs the
|
|
467
488
|
// TypeScript toolchain to resolve exactly like check/build do.
|
|
468
489
|
try ensureResolvedTranspiler(allocator, io, framework_root);
|
|
469
490
|
|
|
@@ -515,8 +536,8 @@ pub fn runDevHost(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
|
|
|
515
536
|
// the `files: ["sdk"]` allowlist: sdk/core.ts, sdk/text.ts, sdk/events.ts,
|
|
516
537
|
// and the ambient bytes-text method surface core.ts references).
|
|
517
538
|
// The copy is
|
|
518
|
-
// EDITOR-AND-VERSIONING SURFACE ONLY: builds
|
|
519
|
-
// checkout's own sources and never read node_modules — delete it and
|
|
539
|
+
// EDITOR-AND-VERSIONING SURFACE ONLY: builds check and compile against the
|
|
540
|
+
// SDK checkout's own sources and never read node_modules — delete it and
|
|
520
541
|
// `native build|dev|check|test` still work; the next check/dev/build puts
|
|
521
542
|
// it back. Once the real package is published, a user-run `npm install`
|
|
522
543
|
// overwrites the copy with identical content; the refresh below compares
|
|
@@ -776,7 +797,7 @@ test "the checkout teaching's npm command survives production npm config" {
|
|
|
776
797
|
try std.testing.expect(std.mem.indexOf(u8, npm_ci_teaching_command, "--include=dev") != null);
|
|
777
798
|
}
|
|
778
799
|
|
|
779
|
-
/// The minimal manifest of
|
|
800
|
+
/// The minimal manifest of a stray @typescript/typescript6 wrapper a fake
|
|
780
801
|
/// COMPLETED install also lands (npm keeps installing it as a declared
|
|
781
802
|
/// dependency). The gate never probes it — validation tracks only the
|
|
782
803
|
/// aliased real compiler runtime loads — so tests land it exactly where
|
package/src/tooling/verbs.zig
CHANGED
|
@@ -64,7 +64,7 @@ pub fn run(allocator: std.mem.Allocator, io: std.Io, verb: Verb, options: Option
|
|
|
64
64
|
if (buildgraph.resolveFrameworkRoot(allocator, io, options.base_env) catch null) |framework_root| {
|
|
65
65
|
defer allocator.free(framework_root);
|
|
66
66
|
ts_core.selfHealEditorPackage(allocator, io, framework_root);
|
|
67
|
-
// The build graph runs the
|
|
67
|
+
// The build graph runs the frontend inside `zig build`; gate
|
|
68
68
|
// its toolchain resolution before any zig spawns — but ONLY
|
|
69
69
|
// for graphs the CLI itself generates (see the preflight's own
|
|
70
70
|
// doc for why ejected apps must flow past it).
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//! The extern-binding layer for a compiled core: every C-ABI symbol the
|
|
2
|
+
//! generated shim (core_shim.zig) may reference, in one module.
|
|
3
|
+
//!
|
|
4
|
+
//! ISOLATION IS THE POINT OF THIS FILE. The core ABI is a draft pending
|
|
5
|
+
//! cross-repo ratification; the shim generator emits no extern
|
|
6
|
+
//! declarations of its own, so a post-ratification symbol or signature
|
|
7
|
+
//! change is an edit HERE and a regeneration — never a generator-logic
|
|
8
|
+
//! change. The build stages this file (and shim_rt.zig) beside the
|
|
9
|
+
//! generated shim, exactly as the transpiler lane stages rt.zig beside
|
|
10
|
+
//! its emitted core.
|
|
11
|
+
//!
|
|
12
|
+
//! Contract summary (the header is the specification; this file only
|
|
13
|
+
//! binds it):
|
|
14
|
+
//! - Symbols are `prefix + suffix`, ccc calling convention, prefix
|
|
15
|
+
//! declared by the sidecar's abi section (canonical default
|
|
16
|
+
//! "nsc_core_").
|
|
17
|
+
//! - The identity getters are pure, callable before init, and MUST NOT
|
|
18
|
+
//! trap: they are the boot-time staleness fence.
|
|
19
|
+
//! - One dispatch entry per payload-descriptor class; `tag` is the
|
|
20
|
+
//! arm's declaration-order index in the sidecar's msg section (the
|
|
21
|
+
//! sidecar is the tag authority). Each entry runs one update+commit
|
|
22
|
+
//! and returns the cycle's command bytes.
|
|
23
|
+
//! - Inbound pointers are borrowed for the call; the core copies what
|
|
24
|
+
//! it keeps. Outbound buffers are core-owned: cmd/subs bytes live
|
|
25
|
+
//! until frame_reset, the snapshot until the next dispatch entry,
|
|
26
|
+
//! init, or collect. No alignment guarantee on any encoded buffer.
|
|
27
|
+
//! - Encoded buffers use the canonical value encoding (shim_rt.zig):
|
|
28
|
+
//! little-endian, headerless, schema-driven, record fields in sidecar
|
|
29
|
+
//! declaration order.
|
|
30
|
+
//! - Narrow integers in these signatures (u8 tags, u32 member/helper
|
|
31
|
+
//! indices, the sink's u64 address) are C-SIGNATURE PLUMBING for
|
|
32
|
+
//! host-produced values, never value-payload crossings: payload
|
|
33
|
+
//! numbers ride the two-class number model (f64/i64) exclusively.
|
|
34
|
+
//! - Four entries are runtime-owned mode symbols rather than ordinary
|
|
35
|
+
//! compiled-core exports: set_panic_sink, init, frame_reset, and
|
|
36
|
+
//! collect (which folds the transient-arena reset). The rest project
|
|
37
|
+
//! the core module's own surface.
|
|
38
|
+
|
|
39
|
+
const std = @import("std");
|
|
40
|
+
|
|
41
|
+
/// The C-ABI generation these bindings implement. The generator refuses
|
|
42
|
+
/// a sidecar declaring any other value; the generated shim re-checks the
|
|
43
|
+
/// object's own getter at boot (the out-of-graph pairing backstop).
|
|
44
|
+
pub const abi_version: u32 = 1;
|
|
45
|
+
|
|
46
|
+
/// The snapshot-encoding generation the shim's decoder implements.
|
|
47
|
+
pub const snapshot_format: u32 = 1;
|
|
48
|
+
|
|
49
|
+
/// The host-supplied trap sink. `msg` is a UTF-8 teaching message valid
|
|
50
|
+
/// only for the duration of the call; `address` is the faulting return
|
|
51
|
+
/// address (0 when unknown); `ctx` echoes the registered context
|
|
52
|
+
/// pointer. The sink must not return and must not call back into any
|
|
53
|
+
/// core entry point.
|
|
54
|
+
///
|
|
55
|
+
/// The sink covers DETECTED traps only: contract violations the core's
|
|
56
|
+
/// own checks catch throw with their teaching text, and an exception
|
|
57
|
+
/// that escapes the core reaches the sink with an "Uncaught " prefix on
|
|
58
|
+
/// its message. Hardware faults (SIGSEGV/SIGBUS) belong to the host's
|
|
59
|
+
/// process-wide handler — the core installs no signal handlers.
|
|
60
|
+
pub const PanicSinkFn = *const fn (
|
|
61
|
+
ctx: ?*anyopaque,
|
|
62
|
+
msg: [*]const u8,
|
|
63
|
+
msg_len: usize,
|
|
64
|
+
address: u64,
|
|
65
|
+
) callconv(.c) void;
|
|
66
|
+
|
|
67
|
+
// A conditional channel entry hands its whole result back as ONE bytes
|
|
68
|
+
// buffer on the ordinary out-pointer slot — the channel bytes envelope:
|
|
69
|
+
//
|
|
70
|
+
// [produced u8][tag u8][payload…]
|
|
71
|
+
//
|
|
72
|
+
// Byte 0 is 0 (nothing produced; the envelope is exactly two bytes) or
|
|
73
|
+
// 1. Byte 1 is the produced arm's declaration-order wire tag in the
|
|
74
|
+
// sidecar's msg section (meaningless when nothing was produced; the
|
|
75
|
+
// producer emits 0). The remainder is the arm's payload in the
|
|
76
|
+
// canonical value encoding of its mirror payload type (shim_rt.zig; an
|
|
77
|
+
// i64 arm rides as 8-byte two's-complement LE) — so the envelope's tail
|
|
78
|
+
// is byte-identical to the canonical union encoding of the produced
|
|
79
|
+
// message. Envelope bytes are valid until the next core entry call of
|
|
80
|
+
// any kind. One bytes return keeps the one-return-slot rule intact: the
|
|
81
|
+
// multi-value result needs no marshalling shape of its own.
|
|
82
|
+
|
|
83
|
+
/// The full symbol set of ABI version 1, bound under `prefix`. The
|
|
84
|
+
/// conditional channel entries are declared unconditionally here —
|
|
85
|
+
/// `@extern` binds lazily, so a symbol is required at link time only
|
|
86
|
+
/// when the generated shim actually references it, which it does
|
|
87
|
+
/// exactly when the sidecar's abi.exports lists it.
|
|
88
|
+
pub fn Bindings(comptime prefix: []const u8) type {
|
|
89
|
+
return struct {
|
|
90
|
+
fn Symbol(comptime T: type, comptime suffix: []const u8) *const T {
|
|
91
|
+
return @extern(*const T, .{ .name = prefix ++ suffix });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------- identity
|
|
95
|
+
pub const abi_version_fn = Symbol(fn () callconv(.c) u32, "abi_version");
|
|
96
|
+
pub const build_id = Symbol(fn () callconv(.c) u64, "build_id");
|
|
97
|
+
|
|
98
|
+
// -------------------------------------------------- panic sink
|
|
99
|
+
pub const set_panic_sink = Symbol(fn (sink: PanicSinkFn, ctx: ?*anyopaque) callconv(.c) void, "set_panic_sink");
|
|
100
|
+
|
|
101
|
+
// --------------------------------------------------- lifecycle
|
|
102
|
+
/// Deterministic (re)initialization: resets all runtime state,
|
|
103
|
+
/// evaluates the core's init, commits the boot model. Callable
|
|
104
|
+
/// repeatedly (the session-replay re-init seam); invalidates
|
|
105
|
+
/// every previously returned pointer.
|
|
106
|
+
pub const init = Symbol(fn () callconv(.c) void, "init");
|
|
107
|
+
/// The boot command bytes produced by init (empty when the
|
|
108
|
+
/// core's init returns a bare model). Arena truth governs the
|
|
109
|
+
/// lifetime: valid until the next frame_reset, dispatch entry,
|
|
110
|
+
/// or init.
|
|
111
|
+
pub const boot_cmd = Symbol(fn (cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "boot_cmd");
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------- dispatch
|
|
114
|
+
pub const dispatch_void = Symbol(fn (tag: u8, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_void");
|
|
115
|
+
pub const dispatch_bytes = Symbol(fn (tag: u8, ptr: [*]const u8, len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_bytes");
|
|
116
|
+
/// The value crosses as f64; an i64-classed arm narrows
|
|
117
|
+
/// core-side by truncation toward zero (producers guarantee
|
|
118
|
+
/// integer-classed values are exact below 2^53).
|
|
119
|
+
pub const dispatch_number = Symbol(fn (tag: u8, value: f64, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_number");
|
|
120
|
+
pub const dispatch_number_bytes = Symbol(fn (tag: u8, number: f64, ptr: [*]const u8, len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_number_bytes");
|
|
121
|
+
pub const dispatch_bool = Symbol(fn (tag: u8, value: u8, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_bool");
|
|
122
|
+
/// `member` is the declaration-order member index from the
|
|
123
|
+
/// sidecar's type table (= the wire value).
|
|
124
|
+
pub const dispatch_enum = Symbol(fn (tag: u8, member: u32, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_enum");
|
|
125
|
+
/// A record OR non-text-input union payload in the canonical
|
|
126
|
+
/// value encoding (a union rides as its u8 declaration-order arm
|
|
127
|
+
/// index followed by that arm's payload — the same encoding the
|
|
128
|
+
/// snapshot uses, so one decoder serves both directions).
|
|
129
|
+
pub const dispatch_record = Symbol(fn (tag: u8, fields: [*]const u8, fields_len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_record");
|
|
130
|
+
/// The declared text-input mirror union: [arm u8] + arm payload
|
|
131
|
+
/// in the canonical value encoding.
|
|
132
|
+
pub const dispatch_text_input = Symbol(fn (tag: u8, event: [*]const u8, event_len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_text_input");
|
|
133
|
+
/// The declared scroll-state mirror record as direct scalars
|
|
134
|
+
/// (the hottest markup dispatch: per-frame during scrolls) —
|
|
135
|
+
/// the TWO-AXIS record's eight fields in declaration order.
|
|
136
|
+
pub const dispatch_scroll_state = Symbol(fn (tag: u8, offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, content_extent_y: f64, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_scroll_state");
|
|
137
|
+
|
|
138
|
+
// -------------------------------------------------- post-cycle
|
|
139
|
+
pub const subscriptions = Symbol(fn (subs: *[*]const u8, subs_len: *usize) callconv(.c) void, "subscriptions");
|
|
140
|
+
pub const frame_reset = Symbol(fn () callconv(.c) void, "frame_reset");
|
|
141
|
+
/// The committed model in the canonical value encoding of the
|
|
142
|
+
/// sidecar's model type (root record, declaration-order fields),
|
|
143
|
+
/// encoded on demand from the committed heap into a transient
|
|
144
|
+
/// buffer: valid until the next dispatch entry, frame_reset,
|
|
145
|
+
/// init, or collect (arena truth — the buffer does NOT survive a
|
|
146
|
+
/// frame reset; re-read after resetting).
|
|
147
|
+
pub const model_snapshot = Symbol(fn (snap: *[*]const u8, snap_len: *usize) callconv(.c) void, "model_snapshot");
|
|
148
|
+
/// Call the exported helper at `helper` (index into the
|
|
149
|
+
/// sidecar's model_helpers). An unknown index is a generator/
|
|
150
|
+
/// sidecar skew and TRAPS through the panic sink — it is never a
|
|
151
|
+
/// status the host is asked to check.
|
|
152
|
+
pub const helper_call = Symbol(fn (helper: u32, args: [*]const u8, args_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "helper_call");
|
|
153
|
+
/// Reference-cycle collection over the model heap, with the
|
|
154
|
+
/// transient-arena reset folded in (a runtime-owned mode
|
|
155
|
+
/// symbol): observable model state unchanged, every previously
|
|
156
|
+
/// returned snapshot, helper, cmd, and subscription pointer
|
|
157
|
+
/// invalidated.
|
|
158
|
+
pub const collect = Symbol(fn () callconv(.c) void, "collect");
|
|
159
|
+
|
|
160
|
+
// -------------------------- conditional channel entries
|
|
161
|
+
//
|
|
162
|
+
// Each returns the channel bytes envelope (see the module doc
|
|
163
|
+
// above) through the ordinary out-pointer pair.
|
|
164
|
+
pub const command_msg = Symbol(fn (name: [*]const u8, name_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "command_msg");
|
|
165
|
+
pub const frame_msg = Symbol(fn (width: f64, height: f64, timestamp_ms: f64, interval_ms: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "frame_msg");
|
|
166
|
+
pub const key_msg = Symbol(fn (key: [*]const u8, key_len: usize, shift: u8, control: u8, alt: u8, super_mod: u8, out: *[*]const u8, out_len: *usize) callconv(.c) void, "key_msg");
|
|
167
|
+
pub const pinch_msg = Symbol(fn (window_id: f64, label: [*]const u8, label_len: usize, phase: u32, scale: f64, x: f64, y: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "pinch_msg");
|
|
168
|
+
};
|
|
169
|
+
}
|