@native-sdk/cli 0.9.0 → 0.9.2
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 +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// return path (NS1017) — they never live in the Model, in a Msg, in a local,
|
|
11
11
|
// or in a helper.
|
|
12
12
|
//
|
|
13
|
-
// The
|
|
13
|
+
// The v5 command set:
|
|
14
14
|
//
|
|
15
15
|
// Cmd.none no effects (what a bare `return model` means)
|
|
16
16
|
// Cmd.persist() ask the host to persist the committed model
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
// re-issuing a live key replaces it, and
|
|
33
33
|
// Cmd.cancel(key) drops it.
|
|
34
34
|
// Cmd.cancel(key) drop the in-flight keyed effect — request,
|
|
35
|
-
// readFile/writeFile/fetch/
|
|
35
|
+
// readFile/writeFile/readFileStream/fetch/
|
|
36
|
+
// clipboardRead, or
|
|
36
37
|
// delay — SILENTLY (no terminal arm dispatch).
|
|
37
38
|
// Aimed at a live spawn, streaming fetch, or
|
|
38
|
-
// streaming service it
|
|
39
|
+
// streaming service or write-file sink it
|
|
39
40
|
// stays LOUD: the err arm runs with
|
|
40
41
|
// "cancelled" — ending a stream is observable
|
|
41
42
|
// Cmd.batch([a, b, ...]) several commands from one dispatch
|
|
@@ -53,6 +54,12 @@
|
|
|
53
54
|
// whole-file write (parents created, replaced
|
|
54
55
|
// whole); ok arm carries NOTHING (an arm with
|
|
55
56
|
// no payload fields), err arm the reason bytes
|
|
57
|
+
// Cmd.appendFile / statFile / deleteFile
|
|
58
|
+
// bounded append, metadata probe, and deletion
|
|
59
|
+
// Cmd.readFileStream 256-KiB chunks, then done(total) or err
|
|
60
|
+
// Cmd.writeFileStream / writeFileChunk / writeFileClose
|
|
61
|
+
// atomic streamed sink; chunks are acknowledged
|
|
62
|
+
// in order and close installs the destination
|
|
56
63
|
// Cmd.fetch({ url, method?, headers?, body?, timeoutMs? }, { key?, ok, err })
|
|
57
64
|
// buffered HTTP(S) exchange; ok arm carries a
|
|
58
65
|
// two-field record — one number field (the real
|
|
@@ -73,7 +80,7 @@
|
|
|
73
80
|
// clipboard read; ok arm carries the text bytes,
|
|
74
81
|
// err arm the reason bytes ("failed",
|
|
75
82
|
// "rejected")
|
|
76
|
-
// Cmd.showNotification({ title, subtitle?, body? })
|
|
83
|
+
// Cmd.showNotification({ id?, title, subtitle?, body?, actionLabel?, actionCommand? })
|
|
77
84
|
// fire-and-forget desktop notification; the OS
|
|
78
85
|
// remains authoritative over final delivery
|
|
79
86
|
// Cmd.openExternalUrl(url) open an allowed HTTP(S) URL in the system
|
|
@@ -255,10 +262,12 @@
|
|
|
255
262
|
// The keyed-effect discipline is ONE rule: a keyed effect REPLACES its live
|
|
256
263
|
// predecessor (the superseded effect's result is dropped — no message), and
|
|
257
264
|
// Cmd.cancel drops it silently. That holds for request, readFile, writeFile,
|
|
258
|
-
// buffered fetch, clipboardRead, and delay alike.
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
//
|
|
265
|
+
// readFileStream, buffered fetch, clipboardRead, and delay alike. A reissued
|
|
266
|
+
// readFileStream key retires the old read silently and starts the replacement.
|
|
267
|
+
// Live spawn, streaming-fetch, streaming-service, and write-file SINK keys are
|
|
268
|
+
// the exceptions: a duplicate REJECTS the new stream/sink so two producers are
|
|
269
|
+
// never spliced. Cancelling a sink is loud (`err: cancelled`) because a
|
|
270
|
+
// half-written export is observable; cancelling a read stream is silent.
|
|
262
271
|
//
|
|
263
272
|
// `Sub` is the recurring-effects surface: an app may export
|
|
264
273
|
// `subscriptions(model): Sub<Msg>` returning declarative descriptors the
|
|
@@ -366,6 +375,32 @@ export function utf8Bytes(s: string): Uint8Array {
|
|
|
366
375
|
/// Every app Msg is a discriminated union on a string `kind` tag.
|
|
367
376
|
export type Msgish = { readonly kind: string };
|
|
368
377
|
|
|
378
|
+
import { type WindowDescriptor, type WindowDescriptorSpec } from "./events.ts";
|
|
379
|
+
|
|
380
|
+
/// Fill the canonical defaults for a model-declared secondary window.
|
|
381
|
+
export function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor {
|
|
382
|
+
return {
|
|
383
|
+
label: spec.label,
|
|
384
|
+
canvasLabel: spec.canvasLabel,
|
|
385
|
+
title: spec.title ?? new Uint8Array(0),
|
|
386
|
+
width: spec.width ?? 480,
|
|
387
|
+
height: spec.height ?? 360,
|
|
388
|
+
x: spec.x ?? null,
|
|
389
|
+
y: spec.y ?? null,
|
|
390
|
+
resizable: spec.resizable ?? true,
|
|
391
|
+
minWidth: spec.minWidth ?? 0,
|
|
392
|
+
minHeight: spec.minHeight ?? 0,
|
|
393
|
+
titlebar: spec.titlebar ?? "standard",
|
|
394
|
+
transparent: spec.transparent ?? false,
|
|
395
|
+
alwaysOnTop: spec.alwaysOnTop ?? false,
|
|
396
|
+
clickThrough: spec.clickThrough ?? false,
|
|
397
|
+
activateOnShow: spec.activateOnShow ?? true,
|
|
398
|
+
allowsFullscreen: spec.allowsFullscreen ?? true,
|
|
399
|
+
closePolicy: spec.closePolicy ?? "quit",
|
|
400
|
+
onCloseCommand: spec.onCloseCommand ?? new Uint8Array(0),
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
369
404
|
/** Cooperative cancellation capability supplied by generated service hosts. */
|
|
370
405
|
export interface ServiceCancellation {
|
|
371
406
|
/** True after Cmd.cancel or the operation deadline requests cancellation. */
|
|
@@ -579,7 +614,9 @@ export type VideoEventKind<M extends Msgish> = M extends Msgish
|
|
|
579
614
|
/// live id), "not_found" (missing local file, no url), "io_failed" (a local
|
|
580
615
|
/// read failure), "connect_failed"/"tls_failed"/"protocol_failed"/"timed_out"
|
|
581
616
|
/// (the fetch taxonomy), "http_status" (a non-2xx answer; `status` carries
|
|
582
|
-
/// it), "cancelled", "too_large" (
|
|
617
|
+
/// it), "cancelled", "too_large" (the encoded source exceeds the fixed
|
|
618
|
+
/// source bound; conforming codecs decode photo-scale pixels down to the
|
|
619
|
+
/// app's registered-image budget),
|
|
583
620
|
/// "unsupported" (no platform codec), "decode_failed", "registry_full", and
|
|
584
621
|
/// "alloc_failed" (the host refused the memory the registration needed —
|
|
585
622
|
/// resource exhaustion, not corrupt bytes: the same source may load once
|
|
@@ -850,6 +887,36 @@ export interface WriteRoute<M extends Msgish> {
|
|
|
850
887
|
readonly err: BytesKind<M>;
|
|
851
888
|
}
|
|
852
889
|
|
|
890
|
+
/// Streaming read routing: zero or more 256-KiB `chunk` messages, then one
|
|
891
|
+
/// `done` carrying the total byte count, or one `err` carrying a closed file
|
|
892
|
+
/// outcome.
|
|
893
|
+
export interface FileReadStreamRoute<M extends Msgish> {
|
|
894
|
+
readonly key?: string;
|
|
895
|
+
readonly chunk: BytesKind<M>;
|
|
896
|
+
readonly done: TimestampKind<M>;
|
|
897
|
+
readonly err: BytesKind<M>;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export interface FileStatArm {
|
|
901
|
+
readonly exists: boolean;
|
|
902
|
+
readonly size: number;
|
|
903
|
+
readonly mtimeMs: number;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export type FileStatKind<M extends Msgish> = M extends Msgish
|
|
907
|
+
? [Exclude<keyof M, "kind">] extends [keyof FileStatArm]
|
|
908
|
+
? [keyof FileStatArm] extends [Exclude<keyof M, "kind">]
|
|
909
|
+
? M extends Msgish & FileStatArm ? M["kind"] : never
|
|
910
|
+
: never
|
|
911
|
+
: never
|
|
912
|
+
: never;
|
|
913
|
+
|
|
914
|
+
export interface FileStatRoute<M extends Msgish> {
|
|
915
|
+
readonly key?: string;
|
|
916
|
+
readonly ok: FileStatKind<M>;
|
|
917
|
+
readonly err: BytesKind<M>;
|
|
918
|
+
}
|
|
919
|
+
|
|
853
920
|
/// Pagination controls for `Cmd.store.scan`. `limit` defaults to 100 and is
|
|
854
921
|
/// bounded at 256. `after` is the opaque key cursor returned by the previous
|
|
855
922
|
/// page; omit it for the first page.
|
|
@@ -1042,9 +1109,12 @@ export interface FetchStreamSpec extends FetchSpec {
|
|
|
1042
1109
|
/// fire-and-forget because the OS may suppress an accepted request through
|
|
1043
1110
|
/// Focus / Do Not Disturb or the user's notification settings.
|
|
1044
1111
|
export interface NotificationSpec {
|
|
1112
|
+
readonly id?: Uint8Array;
|
|
1045
1113
|
readonly title: Uint8Array;
|
|
1046
1114
|
readonly subtitle?: Uint8Array;
|
|
1047
1115
|
readonly body?: Uint8Array;
|
|
1116
|
+
readonly actionLabel?: Uint8Array;
|
|
1117
|
+
readonly actionCommand?: Uint8Array;
|
|
1048
1118
|
}
|
|
1049
1119
|
|
|
1050
1120
|
/// The three bounded host-local timestamp presentations. Unlike the markup
|
|
@@ -1099,6 +1169,56 @@ export type Cmd<M extends Msgish> =
|
|
|
1099
1169
|
readonly path: Uint8Array;
|
|
1100
1170
|
readonly bytes: Uint8Array;
|
|
1101
1171
|
}
|
|
1172
|
+
| {
|
|
1173
|
+
readonly op: "append_file";
|
|
1174
|
+
readonly key: string;
|
|
1175
|
+
readonly okKind: string;
|
|
1176
|
+
readonly errKind: string;
|
|
1177
|
+
readonly path: Uint8Array;
|
|
1178
|
+
readonly bytes: Uint8Array;
|
|
1179
|
+
}
|
|
1180
|
+
| {
|
|
1181
|
+
readonly op: "stat_file";
|
|
1182
|
+
readonly key: string;
|
|
1183
|
+
readonly okKind: string;
|
|
1184
|
+
readonly errKind: string;
|
|
1185
|
+
readonly path: Uint8Array;
|
|
1186
|
+
}
|
|
1187
|
+
| {
|
|
1188
|
+
readonly op: "delete_file";
|
|
1189
|
+
readonly key: string;
|
|
1190
|
+
readonly okKind: string;
|
|
1191
|
+
readonly errKind: string;
|
|
1192
|
+
readonly path: Uint8Array;
|
|
1193
|
+
}
|
|
1194
|
+
| {
|
|
1195
|
+
readonly op: "read_file_stream";
|
|
1196
|
+
readonly key: string;
|
|
1197
|
+
readonly chunkKind: string;
|
|
1198
|
+
readonly doneKind: string;
|
|
1199
|
+
readonly errKind: string;
|
|
1200
|
+
readonly path: Uint8Array;
|
|
1201
|
+
}
|
|
1202
|
+
| {
|
|
1203
|
+
readonly op: "write_file_stream";
|
|
1204
|
+
readonly key: string;
|
|
1205
|
+
readonly okKind: string;
|
|
1206
|
+
readonly errKind: string;
|
|
1207
|
+
readonly path: Uint8Array;
|
|
1208
|
+
}
|
|
1209
|
+
| {
|
|
1210
|
+
readonly op: "write_file_chunk";
|
|
1211
|
+
readonly key: string;
|
|
1212
|
+
readonly okKind: string;
|
|
1213
|
+
readonly errKind: string;
|
|
1214
|
+
readonly bytes: Uint8Array;
|
|
1215
|
+
}
|
|
1216
|
+
| {
|
|
1217
|
+
readonly op: "write_file_close";
|
|
1218
|
+
readonly key: string;
|
|
1219
|
+
readonly okKind: string;
|
|
1220
|
+
readonly errKind: string;
|
|
1221
|
+
}
|
|
1102
1222
|
| {
|
|
1103
1223
|
readonly op: "store_set";
|
|
1104
1224
|
readonly key: string;
|
|
@@ -1176,7 +1296,7 @@ export type Cmd<M extends Msgish> =
|
|
|
1176
1296
|
}
|
|
1177
1297
|
| { readonly op: "clip_write"; readonly bytes: Uint8Array }
|
|
1178
1298
|
| { readonly op: "clip_read"; readonly key: string; readonly okKind: string; readonly errKind: string }
|
|
1179
|
-
| { readonly op: "show_notification"; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array }
|
|
1299
|
+
| { readonly op: "show_notification"; readonly id: Uint8Array; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array; readonly actionLabel: Uint8Array; readonly actionCommand: Uint8Array }
|
|
1180
1300
|
| { readonly op: "delay"; readonly key: string; readonly afterMs: number; readonly msgKind: string }
|
|
1181
1301
|
| {
|
|
1182
1302
|
readonly op: "spawn";
|
|
@@ -1511,7 +1631,7 @@ export const Cmd = {
|
|
|
1511
1631
|
|
|
1512
1632
|
/// Drop the in-flight keyed effect — request, named engine op, or delay —
|
|
1513
1633
|
/// with this key, if any, SILENTLY (neither routing arm is dispatched for
|
|
1514
|
-
/// it). Live spawn, streaming-fetch,
|
|
1634
|
+
/// it). Live spawn, streaming-fetch, streaming-service, and write-file-sink operations are the exceptions:
|
|
1515
1635
|
/// cancel ends the stream and its err arm runs with "cancelled".
|
|
1516
1636
|
cancel(key: string): Cmd<never> {
|
|
1517
1637
|
return { op: "cancel", key };
|
|
@@ -1531,6 +1651,37 @@ export const Cmd = {
|
|
|
1531
1651
|
return { op: "write_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path, bytes };
|
|
1532
1652
|
},
|
|
1533
1653
|
|
|
1654
|
+
appendFile<M extends Msgish>(path: Uint8Array, bytes: Uint8Array, route: WriteRoute<M>): Cmd<M> {
|
|
1655
|
+
return { op: "append_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path, bytes };
|
|
1656
|
+
},
|
|
1657
|
+
|
|
1658
|
+
statFile<M extends Msgish>(path: Uint8Array, route: FileStatRoute<M>): Cmd<M> {
|
|
1659
|
+
return { op: "stat_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path };
|
|
1660
|
+
},
|
|
1661
|
+
|
|
1662
|
+
/// Delete one file. The ok arm carries no payload. A final symlink is
|
|
1663
|
+
/// unlinked without deleting its target. A missing file routes the err arm
|
|
1664
|
+
/// with "not_found"; directories and other OS refusals route "io_failed".
|
|
1665
|
+
deleteFile<M extends Msgish>(path: Uint8Array, route: WriteRoute<M>): Cmd<M> {
|
|
1666
|
+
return { op: "delete_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path };
|
|
1667
|
+
},
|
|
1668
|
+
|
|
1669
|
+
readFileStream<M extends Msgish>(path: Uint8Array, route: FileReadStreamRoute<M>): Cmd<M> {
|
|
1670
|
+
return { op: "read_file_stream", key: route.key ?? "", chunkKind: route.chunk, doneKind: route.done, errKind: route.err, path };
|
|
1671
|
+
},
|
|
1672
|
+
|
|
1673
|
+
writeFileStream<M extends Msgish>(key: string, path: Uint8Array, route: WriteRoute<M>): Cmd<M> {
|
|
1674
|
+
return { op: "write_file_stream", key, okKind: route.ok, errKind: route.err, path };
|
|
1675
|
+
},
|
|
1676
|
+
|
|
1677
|
+
writeFileChunk<M extends Msgish>(key: string, bytes: Uint8Array, route: WriteRoute<M>): Cmd<M> {
|
|
1678
|
+
return { op: "write_file_chunk", key, okKind: route.ok, errKind: route.err, bytes };
|
|
1679
|
+
},
|
|
1680
|
+
|
|
1681
|
+
writeFileClose<M extends Msgish>(key: string, route: WriteRoute<M>): Cmd<M> {
|
|
1682
|
+
return { op: "write_file_close", key, okKind: route.ok, errKind: route.err };
|
|
1683
|
+
},
|
|
1684
|
+
|
|
1534
1685
|
/// Capability-gated, engine-owned per-record storage. Keys are UTF-8 text
|
|
1535
1686
|
/// up to 512 bytes; values are bytes up to 1 MiB. Results remain effects:
|
|
1536
1687
|
/// they arrive through the supplied Msg routes after update commits.
|
|
@@ -1645,14 +1796,20 @@ export const Cmd = {
|
|
|
1645
1796
|
|
|
1646
1797
|
/// Ask the desktop host to show a system notification. Fire-and-forget:
|
|
1647
1798
|
/// platform acceptance cannot promise display while OS focus modes and user
|
|
1648
|
-
/// notification settings remain authoritative.
|
|
1649
|
-
///
|
|
1799
|
+
/// notification settings remain authoritative. A stable id replaces the
|
|
1800
|
+
/// earlier notification with that id; paired actionLabel/actionCommand bytes
|
|
1801
|
+
/// dispatch through the normal app-command path while the process is live.
|
|
1802
|
+
/// Empty or over-bound titles, over-bound optional fields, unpaired actions,
|
|
1803
|
+
/// invalid command names, and unavailable services fail closed.
|
|
1650
1804
|
showNotification(spec: NotificationSpec): Cmd<never> {
|
|
1651
1805
|
return {
|
|
1652
1806
|
op: "show_notification",
|
|
1807
|
+
id: spec.id ?? new Uint8Array(0),
|
|
1653
1808
|
title: spec.title,
|
|
1654
1809
|
subtitle: spec.subtitle ?? new Uint8Array(0),
|
|
1655
1810
|
body: spec.body ?? new Uint8Array(0),
|
|
1811
|
+
actionLabel: spec.actionLabel ?? new Uint8Array(0),
|
|
1812
|
+
actionCommand: spec.actionCommand ?? new Uint8Array(0),
|
|
1656
1813
|
};
|
|
1657
1814
|
},
|
|
1658
1815
|
|
|
@@ -35,6 +35,59 @@ export interface StatusItemState {
|
|
|
35
35
|
readonly presentation: StatusItemPresentation;
|
|
36
36
|
readonly items: readonly StatusItemMenuItem[];
|
|
37
37
|
}
|
|
38
|
+
export interface StatusItemDescriptor {
|
|
39
|
+
readonly id: number;
|
|
40
|
+
readonly visible: boolean;
|
|
41
|
+
readonly iconPath: Uint8Array;
|
|
42
|
+
readonly tooltip: Uint8Array;
|
|
43
|
+
readonly activationCommand: Uint8Array;
|
|
44
|
+
readonly alternateActivationCommand: Uint8Array;
|
|
45
|
+
readonly openCommand: Uint8Array;
|
|
46
|
+
readonly presentation: StatusItemPresentation;
|
|
47
|
+
readonly items: readonly StatusItemMenuItem[];
|
|
48
|
+
}
|
|
49
|
+
export type WindowClosePolicy = "quit" | "hide";
|
|
50
|
+
export type WindowTitlebarStyle = "standard" | "hidden_inset" | "hidden_inset_tall" | "chromeless";
|
|
51
|
+
export interface WindowDescriptorSpec {
|
|
52
|
+
readonly label: Uint8Array;
|
|
53
|
+
readonly canvasLabel: Uint8Array;
|
|
54
|
+
readonly title?: Uint8Array;
|
|
55
|
+
readonly width?: number;
|
|
56
|
+
readonly height?: number;
|
|
57
|
+
readonly x?: number | null;
|
|
58
|
+
readonly y?: number | null;
|
|
59
|
+
readonly resizable?: boolean;
|
|
60
|
+
readonly minWidth?: number;
|
|
61
|
+
readonly minHeight?: number;
|
|
62
|
+
readonly titlebar?: WindowTitlebarStyle;
|
|
63
|
+
readonly transparent?: boolean;
|
|
64
|
+
readonly alwaysOnTop?: boolean;
|
|
65
|
+
readonly clickThrough?: boolean;
|
|
66
|
+
readonly activateOnShow?: boolean;
|
|
67
|
+
readonly allowsFullscreen?: boolean;
|
|
68
|
+
readonly closePolicy?: WindowClosePolicy;
|
|
69
|
+
readonly onCloseCommand?: Uint8Array;
|
|
70
|
+
}
|
|
71
|
+
export interface WindowDescriptor {
|
|
72
|
+
readonly label: Uint8Array;
|
|
73
|
+
readonly canvasLabel: Uint8Array;
|
|
74
|
+
readonly title: Uint8Array;
|
|
75
|
+
readonly width: number;
|
|
76
|
+
readonly height: number;
|
|
77
|
+
readonly x: number | null;
|
|
78
|
+
readonly y: number | null;
|
|
79
|
+
readonly resizable: boolean;
|
|
80
|
+
readonly minWidth: number;
|
|
81
|
+
readonly minHeight: number;
|
|
82
|
+
readonly titlebar: WindowTitlebarStyle;
|
|
83
|
+
readonly transparent: boolean;
|
|
84
|
+
readonly alwaysOnTop: boolean;
|
|
85
|
+
readonly clickThrough: boolean;
|
|
86
|
+
readonly activateOnShow: boolean;
|
|
87
|
+
readonly allowsFullscreen: boolean;
|
|
88
|
+
readonly closePolicy: WindowClosePolicy;
|
|
89
|
+
readonly onCloseCommand: Uint8Array;
|
|
90
|
+
}
|
|
38
91
|
export interface ScrollState {
|
|
39
92
|
readonly offsetX: number;
|
|
40
93
|
readonly offsetY: number;
|
|
@@ -37,9 +37,10 @@
|
|
|
37
37
|
// - `AppearanceEvent`, `ChromeEvent`, `AudioEvent`: the full arm
|
|
38
38
|
// payload shapes, canonical and importable for helper signatures
|
|
39
39
|
// (an arm value is structurally assignable to its event record).
|
|
40
|
-
// - `StatusItemState` and
|
|
41
|
-
// returned by `statusItem(model)
|
|
42
|
-
//
|
|
40
|
+
// - `StatusItemState`, `StatusItemDescriptor`, and their nested records:
|
|
41
|
+
// the model-derived shell returned by `statusItem(model)` or keyed
|
|
42
|
+
// `statusItems(model)`; the generated launcher refreshes shell,
|
|
43
|
+
// presentation, visibility, and menu after committed model changes.
|
|
43
44
|
|
|
44
45
|
export type { TextCaretDirection, TextCaretMove, TextSelection, TextInputEvent } from "./text.ts";
|
|
45
46
|
|
|
@@ -83,10 +84,9 @@ export interface StatusItemMenuItem {
|
|
|
83
84
|
|
|
84
85
|
/// The generated launcher's model-derived menu-bar status item. Export
|
|
85
86
|
/// `statusItem(model: Model): StatusItemState` from `src/core.ts`; its
|
|
86
|
-
///
|
|
87
|
-
///
|
|
88
|
-
///
|
|
89
|
-
/// so returning literals or freshly built arrays is safe.
|
|
87
|
+
/// shell, presentation, and rows are re-derived after every committed model
|
|
88
|
+
/// update. Byte slices are borrowed only for that apply, so returning literals
|
|
89
|
+
/// or freshly built arrays is safe.
|
|
90
90
|
export interface StatusItemState {
|
|
91
91
|
readonly iconPath: Uint8Array;
|
|
92
92
|
readonly tooltip: Uint8Array;
|
|
@@ -97,6 +97,77 @@ export interface StatusItemState {
|
|
|
97
97
|
readonly items: readonly StatusItemMenuItem[];
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/// One independently reconciled menu-bar status item. Export
|
|
101
|
+
/// `statusItems(model: Model): readonly StatusItemDescriptor[]`; `id`
|
|
102
|
+
/// preserves the native item while all remaining fields update live.
|
|
103
|
+
export interface StatusItemDescriptor {
|
|
104
|
+
readonly id: number;
|
|
105
|
+
readonly visible: boolean;
|
|
106
|
+
readonly iconPath: Uint8Array;
|
|
107
|
+
readonly tooltip: Uint8Array;
|
|
108
|
+
readonly activationCommand: Uint8Array;
|
|
109
|
+
readonly alternateActivationCommand: Uint8Array;
|
|
110
|
+
readonly openCommand: Uint8Array;
|
|
111
|
+
readonly presentation: StatusItemPresentation;
|
|
112
|
+
readonly items: readonly StatusItemMenuItem[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// What the user's close affordance does for a model-declared secondary
|
|
116
|
+
/// window. `quit` really closes it and routes `onCloseCommand`; `hide` keeps
|
|
117
|
+
/// the native window and view tree alive for `Cmd.showWindow(label)`.
|
|
118
|
+
export type WindowClosePolicy = "quit" | "hide";
|
|
119
|
+
|
|
120
|
+
export type WindowTitlebarStyle = "standard" | "hidden_inset" | "hidden_inset_tall" | "chromeless";
|
|
121
|
+
|
|
122
|
+
/// Author-facing input to `windowDescriptor`; omitted fields receive the
|
|
123
|
+
/// same defaults as UiApp.WindowDescriptor.
|
|
124
|
+
export interface WindowDescriptorSpec {
|
|
125
|
+
readonly label: Uint8Array;
|
|
126
|
+
readonly canvasLabel: Uint8Array;
|
|
127
|
+
readonly title?: Uint8Array;
|
|
128
|
+
readonly width?: number;
|
|
129
|
+
readonly height?: number;
|
|
130
|
+
readonly x?: number | null;
|
|
131
|
+
readonly y?: number | null;
|
|
132
|
+
readonly resizable?: boolean;
|
|
133
|
+
readonly minWidth?: number;
|
|
134
|
+
readonly minHeight?: number;
|
|
135
|
+
readonly titlebar?: WindowTitlebarStyle;
|
|
136
|
+
readonly transparent?: boolean;
|
|
137
|
+
readonly alwaysOnTop?: boolean;
|
|
138
|
+
readonly clickThrough?: boolean;
|
|
139
|
+
readonly activateOnShow?: boolean;
|
|
140
|
+
readonly allowsFullscreen?: boolean;
|
|
141
|
+
readonly closePolicy?: WindowClosePolicy;
|
|
142
|
+
readonly onCloseCommand?: Uint8Array;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// One independently reconciled secondary window returned by
|
|
146
|
+
/// `windows(model)`. The generated launcher compiles
|
|
147
|
+
/// `src/windows/<label>.native` as its view; presence is liveness. Construct
|
|
148
|
+
/// entries with `windowDescriptor` and spell `label` as a literal
|
|
149
|
+
/// `asciiBytes("<label>")` so check/build can prove that root exists.
|
|
150
|
+
export interface WindowDescriptor {
|
|
151
|
+
readonly label: Uint8Array;
|
|
152
|
+
readonly canvasLabel: Uint8Array;
|
|
153
|
+
readonly title: Uint8Array;
|
|
154
|
+
readonly width: number;
|
|
155
|
+
readonly height: number;
|
|
156
|
+
readonly x: number | null;
|
|
157
|
+
readonly y: number | null;
|
|
158
|
+
readonly resizable: boolean;
|
|
159
|
+
readonly minWidth: number;
|
|
160
|
+
readonly minHeight: number;
|
|
161
|
+
readonly titlebar: WindowTitlebarStyle;
|
|
162
|
+
readonly transparent: boolean;
|
|
163
|
+
readonly alwaysOnTop: boolean;
|
|
164
|
+
readonly clickThrough: boolean;
|
|
165
|
+
readonly activateOnShow: boolean;
|
|
166
|
+
readonly allowsFullscreen: boolean;
|
|
167
|
+
readonly closePolicy: WindowClosePolicy;
|
|
168
|
+
readonly onCloseCommand: Uint8Array;
|
|
169
|
+
}
|
|
170
|
+
|
|
100
171
|
/// The scroll-state mirror markup's `on-scroll` matches structurally: a
|
|
101
172
|
/// record of exactly these eight numeric fields — the TWO-AXIS shape, one
|
|
102
173
|
/// offset/velocity/viewport/content quartet per axis. Offsets and extents
|