@native-sdk/cli 0.5.4 → 0.6.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 +50 -1
- package/build.zig +588 -32
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +280 -8
- package/packages/core/sdk/core.ts +481 -2
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1368 -74
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +16 -0
- package/src/runtime/api.zig +76 -6
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +1 -0
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +268 -26
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -4
- package/src/runtime/gpu_surface_events.zig +475 -15
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +114 -19
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2338 -67
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +268 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
package/build.zig.zon
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
.fingerprint = 0xc309966142f33087,
|
|
4
4
|
.version = "0.1.0",
|
|
5
5
|
.minimum_zig_version = "0.16.0",
|
|
6
|
+
// No dependencies. The terminal emulator (libghostty-vt) is
|
|
7
|
+
// deliberately NOT pinned here: a pin in this file is materialized
|
|
8
|
+
// into every consumer's package directory even when lazy and
|
|
9
|
+
// unused. Apps that want live `<terminal>` sessions pin it in their
|
|
10
|
+
// own build.zig.zon and ask for it with
|
|
11
|
+
// `addAppArtifacts(.{ .terminal_sessions = true })` — see
|
|
12
|
+
// examples/workbench, which also owns that path's test coverage.
|
|
6
13
|
.dependencies = .{},
|
|
7
14
|
.paths = .{
|
|
8
15
|
"README.md",
|
package/native-sdk.d.ts
CHANGED
|
@@ -435,7 +435,9 @@ export type NativeSdkPlatformFeature =
|
|
|
435
435
|
| "audio_spectrum"
|
|
436
436
|
| "audioSpectrum"
|
|
437
437
|
| "window_hide_on_close"
|
|
438
|
-
| "windowHideOnClose"
|
|
438
|
+
| "windowHideOnClose"
|
|
439
|
+
| "video_playback"
|
|
440
|
+
| "videoPlayback";
|
|
439
441
|
|
|
440
442
|
export type NativeSdkPlatformFeatureSelector =
|
|
441
443
|
| { feature: NativeSdkPlatformFeature; name?: never }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@typescript/typescript6": "6.0.2"
|
|
33
33
|
},
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@native-sdk/cli-darwin-arm64": "0.
|
|
36
|
-
"@native-sdk/cli-darwin-x64": "0.
|
|
37
|
-
"@native-sdk/cli-linux-arm64-gnu": "0.
|
|
38
|
-
"@native-sdk/cli-linux-arm64-musl": "0.
|
|
39
|
-
"@native-sdk/cli-linux-x64-gnu": "0.
|
|
40
|
-
"@native-sdk/cli-linux-x64-musl": "0.
|
|
41
|
-
"@native-sdk/cli-win32-arm64": "0.
|
|
42
|
-
"@native-sdk/cli-win32-x64": "0.
|
|
35
|
+
"@native-sdk/cli-darwin-arm64": "0.6.1",
|
|
36
|
+
"@native-sdk/cli-darwin-x64": "0.6.1",
|
|
37
|
+
"@native-sdk/cli-linux-arm64-gnu": "0.6.1",
|
|
38
|
+
"@native-sdk/cli-linux-arm64-musl": "0.6.1",
|
|
39
|
+
"@native-sdk/cli-linux-x64-gnu": "0.6.1",
|
|
40
|
+
"@native-sdk/cli-linux-x64-musl": "0.6.1",
|
|
41
|
+
"@native-sdk/cli-win32-arm64": "0.6.1",
|
|
42
|
+
"@native-sdk/cli-win32-x64": "0.6.1"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@native-sdk/core",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.6.1",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@typescript/old": "npm:typescript@6.0.3",
|
|
12
12
|
"@typescript/typescript6": "6.0.2"
|
package/packages/core/rt/rt.zig
CHANGED
|
@@ -1059,16 +1059,32 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1059
1059
|
// [cache_len u32 LE][cache_path][expected_bytes f64 LE]
|
|
1060
1060
|
// image_cancel [op 0x13][id f64 LE]
|
|
1061
1061
|
// image_unregister [op 0x14][id f64 LE]
|
|
1062
|
+
// channel_open [op 0x15][key f64 LE][event_tag u8]
|
|
1063
|
+
// channel_close [op 0x16][key f64 LE]
|
|
1064
|
+
// video_load [op 0x17][key_len u8][key][event_tag u8]
|
|
1065
|
+
// [surface f64 LE][path_len u32 LE][path]
|
|
1066
|
+
// [url_len u32 LE][url][flags u8]
|
|
1067
|
+
// (flags bit0 = autoplay, bit1 = loop, bit2 = muted)
|
|
1068
|
+
// video_ctl [op 0x18][key_len u8][key][verb u8][value f64 LE]
|
|
1069
|
+
// pty_spawn [op 0x19][key_len u8][key bytes][event_tag u8]
|
|
1070
|
+
// [cols f64 LE][rows f64 LE][term_len u8][term bytes]
|
|
1071
|
+
// then [argc u8] and per argv element:
|
|
1072
|
+
// [arg_len u32 LE][arg bytes]
|
|
1073
|
+
// pty_write [op 0x1A][key_len u8][key bytes][bytes_len u32 LE][bytes]
|
|
1074
|
+
// pty_resize [op 0x1B][key_len u8][key bytes][cols f64 LE][rows f64 LE]
|
|
1075
|
+
// pty_kill [op 0x1C][key_len u8][key bytes]
|
|
1062
1076
|
//
|
|
1063
1077
|
// v2 is additive over v1: the 0x01-0x03 records are byte-identical to v1,
|
|
1064
1078
|
// so a v1 effect log replays under a v2 reader unchanged. The named-op
|
|
1065
1079
|
// records 0x07-0x0C are additive within v2 the same way, and so are the
|
|
1066
1080
|
// streaming records 0x0D-0x0F: no existing record's bytes change, new
|
|
1067
1081
|
// opcodes only. v3 appends the window-verb records 0x10-0x11 under the
|
|
1068
|
-
// same rule, and the image records 0x12-0x14
|
|
1082
|
+
// same rule, and the image records 0x12-0x14, channel records
|
|
1083
|
+
// 0x15-0x16, and pty records 0x19-0x1C are additive within v3
|
|
1069
1084
|
// the same way: every existing record is byte-identical, new opcodes
|
|
1070
1085
|
// only (a host predating an opcode refuses it loudly, naming this
|
|
1071
|
-
// version).
|
|
1086
|
+
// version). The video records 0x17-0x18 join additively under
|
|
1087
|
+
// the same rule.
|
|
1072
1088
|
//
|
|
1073
1089
|
// `method` is the closed HTTP verb set in declaration order of `CmdFetchMethod`
|
|
1074
1090
|
// (GET 0, POST 1, PUT 2, DELETE 3, PATCH 4, HEAD 5). `timeout_ms` 0 means
|
|
@@ -1227,6 +1243,86 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1227
1243
|
// flight under the id is untouched and its terminal
|
|
1228
1244
|
// still registers — cancel the load first to keep
|
|
1229
1245
|
// the slot free.
|
|
1246
|
+
// channel_open open an EXTERNAL-SOURCE CHANNEL, keyed by the app's
|
|
1247
|
+
// own numeric key (`key`, an f64-carried positive
|
|
1248
|
+
// integer below 2^53 — the image records' id
|
|
1249
|
+
// convention): the host stages a long-lived,
|
|
1250
|
+
// thread-safe posting seam its NATIVE side feeds
|
|
1251
|
+
// (embedders and platform-services extensions post
|
|
1252
|
+
// bytes from their own threads; transpiled cores are
|
|
1253
|
+
// single-threaded and never post — they open, close,
|
|
1254
|
+
// and receive). Every channel event then dispatches
|
|
1255
|
+
// the `event_tag` arm — a five-field record built by
|
|
1256
|
+
// name: `key` (a number, the channel key echoed so
|
|
1257
|
+
// concurrent channels sharing one arm stay
|
|
1258
|
+
// distinguishable; a key the wire cannot carry exactly
|
|
1259
|
+
// echoes 0), `state` (an enum whose members are
|
|
1260
|
+
// exactly data/closed/rejected, matched by member
|
|
1261
|
+
// NAME), `bytes` (the post's payload; empty outside
|
|
1262
|
+
// "data" events), and `droppedPending`/`droppedTotal`
|
|
1263
|
+
// (numbers — the honest back-pressure counters: posts
|
|
1264
|
+
// refused since the previous event, and over the
|
|
1265
|
+
// channel's whole life). The entry is non-retiring
|
|
1266
|
+
// the spawn way: "data" events flow across dispatches
|
|
1267
|
+
// until the one "closed" terminal (channel_close) —
|
|
1268
|
+
// or a "rejected" terminal for an open the host
|
|
1269
|
+
// refused (duplicate live key, full table, occupied
|
|
1270
|
+
// engine key) — retires it. One channel per key at a
|
|
1271
|
+
// time, never replaced implicitly.
|
|
1272
|
+
// channel_close close the open channel under `key`, if any:
|
|
1273
|
+
// staged posts flush, exactly one "closed" event
|
|
1274
|
+
// (final drop totals aboard) dispatches the entry's
|
|
1275
|
+
// own event arm, and the key frees. A key naming no
|
|
1276
|
+
// open channel — or one the wire cannot carry exactly
|
|
1277
|
+
// — is a no-op, audio_ctl's idle rule. Channels are
|
|
1278
|
+
// keyed by their numeric key, so the string-keyed
|
|
1279
|
+
// `cancel` record never touches them — this is their
|
|
1280
|
+
// close, the way audio_ctl stop is audio's.
|
|
1281
|
+
// pty_spawn open a PSEUDO-TERMINAL SESSION — a spawn with a
|
|
1282
|
+
// different transport: run `argv` (the spawn record's
|
|
1283
|
+
// argv encoding and budgets) on a fresh pty whose
|
|
1284
|
+
// initial grid is `cols` x `rows` and whose TERM is
|
|
1285
|
+
// `term` (empty = the engine's default TERM — the
|
|
1286
|
+
// fetch-timeout convention: the wire never bakes the
|
|
1287
|
+
// default in). Non-retiring the spawn way: every
|
|
1288
|
+
// session event dispatches the `event_tag` arm — a
|
|
1289
|
+
// six-field record built by name: `state` (an enum
|
|
1290
|
+
// whose members are exactly output/exit, matched by
|
|
1291
|
+
// member NAME), `bytes` (a coalesced batch of child
|
|
1292
|
+
// output; empty outside "output" events), `code` (a
|
|
1293
|
+
// number, the child's exit code; -1 for every
|
|
1294
|
+
// non-exited end), `reason` (an enum whose members
|
|
1295
|
+
// are exactly the five spawn exit reasons —
|
|
1296
|
+
// exited/signaled/cancelled/rejected/spawn_failed —
|
|
1297
|
+
// matched by member NAME), `signal` (a number, the
|
|
1298
|
+
// fatal signal after a signaled end, else 0), and
|
|
1299
|
+
// `droppedWrites` (a number: pty_write payloads
|
|
1300
|
+
// refused over the session's life — never silence).
|
|
1301
|
+
// "output" events flow across dispatches until the
|
|
1302
|
+
// exactly-one "exit" terminal retires the entry (a
|
|
1303
|
+
// refused spawn — duplicate live key, full table,
|
|
1304
|
+
// bad grid — is one "exit" with reason "rejected";
|
|
1305
|
+
// a transport that could not start is one with
|
|
1306
|
+
// "spawn_failed"). One session per key at a time,
|
|
1307
|
+
// never replaced implicitly: kill it first, the
|
|
1308
|
+
// spawn discipline.
|
|
1309
|
+
// pty_write write bytes toward the session's child — keystrokes
|
|
1310
|
+
// and pastes, fire-and-forget: a key naming no open
|
|
1311
|
+
// session is a no-op (the exit was already on its
|
|
1312
|
+
// way), and refused payloads count into the exit's
|
|
1313
|
+
// `droppedWrites`, never silence.
|
|
1314
|
+
// pty_resize push a new grid to the session so the child
|
|
1315
|
+
// receives SIGWINCH — fire-and-forget like
|
|
1316
|
+
// pty_write; a key naming no open session is a
|
|
1317
|
+
// no-op.
|
|
1318
|
+
// pty_kill terminate the session's child. LOUD, the spawn
|
|
1319
|
+
// cancel discipline: the session's one "exit"
|
|
1320
|
+
// terminal arrives through its own event arm with
|
|
1321
|
+
// reason "cancelled" and the key frees once it
|
|
1322
|
+
// lands. A key naming no open session is a no-op.
|
|
1323
|
+
// Sessions are their own family's to end — the
|
|
1324
|
+
// string-keyed `cancel` record never touches them,
|
|
1325
|
+
// the way audio_ctl stop is audio's close.
|
|
1230
1326
|
// audio_ctl drive the open stream's playback in place, by verb
|
|
1231
1327
|
// (`CmdAudioVerb` declaration order): pause 0, resume
|
|
1232
1328
|
// 1, stop 2, seek 3 (`value` = position ms), volume 4
|
|
@@ -1237,6 +1333,38 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1237
1333
|
// no open stream is a no-op (the playback it aimed at
|
|
1238
1334
|
// is already gone). `stop` closes the stream: no
|
|
1239
1335
|
// events for that key after it.
|
|
1336
|
+
// video_load open (or replace — one player is the whole surface)
|
|
1337
|
+
// the keyed video EVENT STREAM: claim the media-surface
|
|
1338
|
+
// texture channel `surface` names (the SAME model-owned
|
|
1339
|
+
// id a video widget binds — decoded frames flow
|
|
1340
|
+
// platform-side into it, never through this channel),
|
|
1341
|
+
// resolve the source cascade (local `path` first, then
|
|
1342
|
+
// `url`; empty fields = absent) and start playback per
|
|
1343
|
+
// `flags` (bit0 = autoplay, bit1 = loop, bit2 = muted).
|
|
1344
|
+
// Every playback event — loaded, position ticks,
|
|
1345
|
+
// completed, failed, rejected — then dispatches the
|
|
1346
|
+
// `event_tag` arm until `video_ctl` stop (or a
|
|
1347
|
+
// replacing video_load) closes the stream. The arm is
|
|
1348
|
+
// a seven-field record built by name: `state` (an enum
|
|
1349
|
+
// whose members are exactly loaded/position/completed/
|
|
1350
|
+
// failed/rejected, matched by member NAME so
|
|
1351
|
+
// declaration order is the app's), positionMs and
|
|
1352
|
+
// durationMs (numbers), playing and buffering
|
|
1353
|
+
// (booleans), and width and height (numbers: the
|
|
1354
|
+
// stream's decoded pixel dimensions on "loaded", 0
|
|
1355
|
+
// elsewhere). Failure is never silent: an unplayable
|
|
1356
|
+
// source is one `.failed` event, a refused command one
|
|
1357
|
+
// `.rejected`.
|
|
1358
|
+
// video_ctl drive the open stream's playback in place, by verb
|
|
1359
|
+
// (`CmdVideoVerb` declaration order): play 0, pause 1,
|
|
1360
|
+
// stop 2, seek 3 (`value` = position ms), volume 4
|
|
1361
|
+
// (`value` clamped 0..1), muted 5 and loop 6 (`value`
|
|
1362
|
+
// 0 = off, non-zero = on). `value` is 0 when the verb
|
|
1363
|
+
// takes none. Control verbs are fire-and-forget —
|
|
1364
|
+
// their consequences arrive on the keyed event stream
|
|
1365
|
+
// — and a verb whose key names no open stream is a
|
|
1366
|
+
// no-op. `stop` closes the stream: no events for that
|
|
1367
|
+
// key after it.
|
|
1240
1368
|
// window_show fire-and-forget window verb, LABEL-addressed (the
|
|
1241
1369
|
// declared window label, the same address the Zig
|
|
1242
1370
|
// tier's `fx.showWindow` takes): un-hide + activate
|
|
@@ -1260,15 +1388,16 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1260
1388
|
// the duplicate (err arm "rejected"): a running subprocess is never
|
|
1261
1389
|
// killed implicitly — cancel it first. audio_play also replaces on
|
|
1262
1390
|
// key reuse, per the engine underneath: one player is the whole
|
|
1263
|
-
// surface
|
|
1391
|
+
// surface — and video_load keeps the same rule on its own single
|
|
1392
|
+
// player.
|
|
1264
1393
|
//
|
|
1265
1394
|
// Sub vs streams, the design line: `Sub` descriptors are DECLARATIVE
|
|
1266
1395
|
// recurring effects derived from the model after every commit (the
|
|
1267
|
-
// host reconciles them; the app never opens or closes one). spawn
|
|
1268
|
-
// audio_play are Cmd-INITIATED STREAMS: imperative
|
|
1269
|
-
// lifecycle the app drives (cancel / audio_ctl
|
|
1270
|
-
//
|
|
1271
|
-
// key.
|
|
1396
|
+
// host reconciles them; the app never opens or closes one). spawn,
|
|
1397
|
+
// audio_play, and video_load are Cmd-INITIATED STREAMS: imperative
|
|
1398
|
+
// opens with a keyed lifecycle the app drives (cancel / audio_ctl
|
|
1399
|
+
// stop / video_ctl stop), delivering many results until their
|
|
1400
|
+
// terminal (spawn) or close (audio, video) retires the key.
|
|
1272
1401
|
//
|
|
1273
1402
|
// Host record payload encoding (the `Cmd.host`/`Cmd.request` record form,
|
|
1274
1403
|
// produced identically by the SDK under node and by emitted Zig): fields
|
|
@@ -1307,6 +1436,14 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1307
1436
|
image_load = 0x12,
|
|
1308
1437
|
image_cancel = 0x13,
|
|
1309
1438
|
image_unregister = 0x14,
|
|
1439
|
+
channel_open = 0x15,
|
|
1440
|
+
channel_close = 0x16,
|
|
1441
|
+
video_load = 0x17,
|
|
1442
|
+
video_ctl = 0x18,
|
|
1443
|
+
pty_spawn = 0x19,
|
|
1444
|
+
pty_write = 0x1A,
|
|
1445
|
+
pty_resize = 0x1B,
|
|
1446
|
+
pty_kill = 0x1C,
|
|
1310
1447
|
};
|
|
1311
1448
|
|
|
1312
1449
|
/// The spawn record's "no line routing" sentinel: a `line_tag` of
|
|
@@ -1329,6 +1466,17 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1329
1466
|
volume = 4,
|
|
1330
1467
|
};
|
|
1331
1468
|
|
|
1469
|
+
/// The video_ctl verb set, wire value = declaration order.
|
|
1470
|
+
pub const CmdVideoVerb = enum(u8) {
|
|
1471
|
+
play = 0,
|
|
1472
|
+
pause = 1,
|
|
1473
|
+
stop = 2,
|
|
1474
|
+
seek = 3,
|
|
1475
|
+
volume = 4,
|
|
1476
|
+
muted = 5,
|
|
1477
|
+
loop = 6,
|
|
1478
|
+
};
|
|
1479
|
+
|
|
1332
1480
|
/// The closed HTTP verb set of the fetch record, wire value =
|
|
1333
1481
|
/// declaration order.
|
|
1334
1482
|
pub const CmdFetchMethod = enum(u8) {
|
|
@@ -1646,6 +1794,130 @@ pub fn Kernel(comptime opts: Options) type {
|
|
|
1646
1794
|
return out;
|
|
1647
1795
|
}
|
|
1648
1796
|
|
|
1797
|
+
pub fn cmdChannelOpen(key: f64, event_tag: u8) Cmd {
|
|
1798
|
+
const out = frameAlloc(u8, 1 + 8 + 1);
|
|
1799
|
+
out[0] = @intFromEnum(CmdOp.channel_open);
|
|
1800
|
+
std.mem.writeInt(u64, out[1..][0..8], @bitCast(key), .little);
|
|
1801
|
+
out[9] = event_tag;
|
|
1802
|
+
return out;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
pub fn cmdChannelClose(key: f64) Cmd {
|
|
1806
|
+
const out = frameAlloc(u8, 1 + 8);
|
|
1807
|
+
out[0] = @intFromEnum(CmdOp.channel_close);
|
|
1808
|
+
std.mem.writeInt(u64, out[1..][0..8], @bitCast(key), .little);
|
|
1809
|
+
return out;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
pub fn cmdVideoLoad(
|
|
1813
|
+
key: []const u8,
|
|
1814
|
+
event_tag: u8,
|
|
1815
|
+
surface: f64,
|
|
1816
|
+
path: []const u8,
|
|
1817
|
+
url: []const u8,
|
|
1818
|
+
flags: u8,
|
|
1819
|
+
) Cmd {
|
|
1820
|
+
// The emitter's byte gate on the literal key is the
|
|
1821
|
+
// build-time teaching; this is the loud runtime backstop.
|
|
1822
|
+
// A std.debug.assert compiles out of ReleaseFast, where the
|
|
1823
|
+
// @intCast below would then truncate the length byte and
|
|
1824
|
+
// corrupt the wire record silently — panic in every build
|
|
1825
|
+
// mode instead.
|
|
1826
|
+
if (key.len > 255) @panic("Cmd.videoLoad key over 255 bytes");
|
|
1827
|
+
std.debug.assert(path.len <= std.math.maxInt(u32));
|
|
1828
|
+
std.debug.assert(url.len <= std.math.maxInt(u32));
|
|
1829
|
+
const out = frameAlloc(u8, 2 + key.len + 1 + 8 + 4 + path.len + 4 + url.len + 1);
|
|
1830
|
+
out[0] = @intFromEnum(CmdOp.video_load);
|
|
1831
|
+
out[1] = @intCast(key.len);
|
|
1832
|
+
@memcpy(out[2..][0..key.len], key);
|
|
1833
|
+
var off: usize = 2 + key.len;
|
|
1834
|
+
out[off] = event_tag;
|
|
1835
|
+
std.mem.writeInt(u64, out[off + 1 ..][0..8], @bitCast(surface), .little);
|
|
1836
|
+
off += 9;
|
|
1837
|
+
off = writeLongBytes(out, off, path);
|
|
1838
|
+
off = writeLongBytes(out, off, url);
|
|
1839
|
+
out[off] = flags;
|
|
1840
|
+
return out;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
pub fn cmdVideoCtl(key: []const u8, verb: CmdVideoVerb, value: f64) Cmd {
|
|
1844
|
+
// The same loud backstop as cmdVideoLoad: the length byte
|
|
1845
|
+
// must never truncate silently in ReleaseFast.
|
|
1846
|
+
if (key.len > 255) @panic("Cmd.video verb key over 255 bytes");
|
|
1847
|
+
const out = frameAlloc(u8, 2 + key.len + 1 + 8);
|
|
1848
|
+
out[0] = @intFromEnum(CmdOp.video_ctl);
|
|
1849
|
+
out[1] = @intCast(key.len);
|
|
1850
|
+
@memcpy(out[2..][0..key.len], key);
|
|
1851
|
+
out[2 + key.len] = @intFromEnum(verb);
|
|
1852
|
+
std.mem.writeInt(u64, out[2 + key.len + 1 ..][0..8], @bitCast(value), .little);
|
|
1853
|
+
return out;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
pub fn cmdPtySpawn(
|
|
1857
|
+
key: []const u8,
|
|
1858
|
+
event_tag: u8,
|
|
1859
|
+
cols: f64,
|
|
1860
|
+
rows: f64,
|
|
1861
|
+
term: []const u8,
|
|
1862
|
+
argv: []const []const u8,
|
|
1863
|
+
) Cmd {
|
|
1864
|
+
std.debug.assert(key.len <= 255);
|
|
1865
|
+
std.debug.assert(term.len <= 255);
|
|
1866
|
+
std.debug.assert(argv.len >= 1 and argv.len <= 255);
|
|
1867
|
+
var argv_bytes: usize = 0;
|
|
1868
|
+
for (argv) |arg| {
|
|
1869
|
+
std.debug.assert(arg.len <= std.math.maxInt(u32));
|
|
1870
|
+
argv_bytes += 4 + arg.len;
|
|
1871
|
+
}
|
|
1872
|
+
const out = frameAlloc(u8, 2 + key.len + 1 + 8 + 8 + 1 + term.len + 1 + argv_bytes);
|
|
1873
|
+
out[0] = @intFromEnum(CmdOp.pty_spawn);
|
|
1874
|
+
out[1] = @intCast(key.len);
|
|
1875
|
+
@memcpy(out[2..][0..key.len], key);
|
|
1876
|
+
var off: usize = 2 + key.len;
|
|
1877
|
+
out[off] = event_tag;
|
|
1878
|
+
std.mem.writeInt(u64, out[off + 1 ..][0..8], @bitCast(cols), .little);
|
|
1879
|
+
std.mem.writeInt(u64, out[off + 9 ..][0..8], @bitCast(rows), .little);
|
|
1880
|
+
off += 17;
|
|
1881
|
+
out[off] = @intCast(term.len);
|
|
1882
|
+
@memcpy(out[off + 1 ..][0..term.len], term);
|
|
1883
|
+
off += 1 + term.len;
|
|
1884
|
+
out[off] = @intCast(argv.len);
|
|
1885
|
+
off += 1;
|
|
1886
|
+
for (argv) |arg| off = writeLongBytes(out, off, arg);
|
|
1887
|
+
return out;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
pub fn cmdPtyWrite(key: []const u8, bytes: []const u8) Cmd {
|
|
1891
|
+
std.debug.assert(key.len <= 255);
|
|
1892
|
+
std.debug.assert(bytes.len <= std.math.maxInt(u32));
|
|
1893
|
+
const out = frameAlloc(u8, 2 + key.len + 4 + bytes.len);
|
|
1894
|
+
out[0] = @intFromEnum(CmdOp.pty_write);
|
|
1895
|
+
out[1] = @intCast(key.len);
|
|
1896
|
+
@memcpy(out[2..][0..key.len], key);
|
|
1897
|
+
_ = writeLongBytes(out, 2 + key.len, bytes);
|
|
1898
|
+
return out;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
pub fn cmdPtyResize(key: []const u8, cols: f64, rows: f64) Cmd {
|
|
1902
|
+
std.debug.assert(key.len <= 255);
|
|
1903
|
+
const out = frameAlloc(u8, 2 + key.len + 8 + 8);
|
|
1904
|
+
out[0] = @intFromEnum(CmdOp.pty_resize);
|
|
1905
|
+
out[1] = @intCast(key.len);
|
|
1906
|
+
@memcpy(out[2..][0..key.len], key);
|
|
1907
|
+
std.mem.writeInt(u64, out[2 + key.len ..][0..8], @bitCast(cols), .little);
|
|
1908
|
+
std.mem.writeInt(u64, out[2 + key.len + 8 ..][0..8], @bitCast(rows), .little);
|
|
1909
|
+
return out;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
pub fn cmdPtyKill(key: []const u8) Cmd {
|
|
1913
|
+
std.debug.assert(key.len <= 255);
|
|
1914
|
+
const out = frameAlloc(u8, 2 + key.len);
|
|
1915
|
+
out[0] = @intFromEnum(CmdOp.pty_kill);
|
|
1916
|
+
out[1] = @intCast(key.len);
|
|
1917
|
+
@memcpy(out[2..][0..key.len], key);
|
|
1918
|
+
return out;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1649
1921
|
pub fn cmdBatch(cmds: []const Cmd) Cmd {
|
|
1650
1922
|
var total: usize = 0;
|
|
1651
1923
|
for (cmds) |c| total += c.len;
|