@native-sdk/cli 0.5.3 → 0.5.4
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 +41 -1
- package/build.zig +223 -3
- package/native-sdk.d.ts +17 -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 +138 -3
- package/packages/core/sdk/core.ts +225 -3
- package/packages/core/src/emitter.ts +2586 -259
- package/skill-data/native-ui/SKILL.md +3 -2
- package/skill-data/ts-core/SKILL.md +9 -1
- package/src/app_runner/root.zig +81 -1
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/embed/tests.zig +119 -1
- package/src/platform/linux/gtk_host.c +112 -3
- package/src/platform/linux/root.zig +71 -0
- package/src/platform/macos/appkit_host.h +48 -2
- package/src/platform/macos/appkit_host.m +533 -34
- package/src/platform/macos/cef_host.mm +262 -10
- package/src/platform/macos/root.zig +92 -4
- package/src/platform/null_platform.zig +298 -5
- package/src/platform/root.zig +33 -0
- package/src/platform/types.zig +138 -4
- package/src/platform/windows/root.zig +134 -0
- package/src/platform/windows/webview2_host.cpp +152 -40
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/ui.zig +11 -7
- package/src/primitives/canvas/ui_markup.zig +58 -34
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +23 -8
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
- package/src/primitives/canvas/ui_markup_contract.zig +1 -1
- package/src/primitives/canvas/ui_markup_contract_tests.zig +26 -0
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_tests.zig +29 -9
- package/src/primitives/canvas/ui_markup_view.zig +29 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +150 -9
- package/src/primitives/canvas/ui_schema.zig +13 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/root.zig +7 -0
- package/src/runtime/api.zig +6 -4
- package/src/runtime/bridge_payload.zig +7 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/core.zig +58 -11
- package/src/runtime/effects.zig +1664 -43
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_tests.zig +153 -0
- package/src/runtime/flow.zig +17 -0
- package/src/runtime/root.zig +11 -0
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +85 -21
- package/src/runtime/session_record.zig +27 -2
- package/src/runtime/session_replay.zig +168 -16
- package/src/runtime/session_tests.zig +1992 -0
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +439 -4
- package/src/runtime/ts_core_host_tests.zig +41 -0
- package/src/runtime/ts_ui_app.zig +7 -0
- package/src/runtime/ui_app.zig +111 -6
- package/src/runtime/ui_app_window_tests.zig +468 -0
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +32 -0
- package/src/runtime/window_views.zig +61 -1
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +219 -1
|
@@ -9,6 +9,7 @@ pub const Error = error{
|
|
|
9
9
|
CreateFailed,
|
|
10
10
|
FocusFailed,
|
|
11
11
|
CloseFailed,
|
|
12
|
+
UnsupportedWindowClosePolicy,
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const GtkHost = opaque {};
|
|
@@ -212,6 +213,20 @@ extern fn native_sdk_gtk_show_open_dialog(host: *GtkHost, opts: *const GtkOpenDi
|
|
|
212
213
|
extern fn native_sdk_gtk_show_save_dialog(host: *GtkHost, opts: *const GtkSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
|
|
213
214
|
extern fn native_sdk_gtk_show_message_dialog(host: *GtkHost, opts: *const GtkMessageDialogOpts) c_int;
|
|
214
215
|
|
|
216
|
+
/// The startup-window twin of the runtime's create-time `.hide` gate:
|
|
217
|
+
/// GTK reports `window_hide_on_close` false (no status item exists to
|
|
218
|
+
/// bring a hidden window back), and every seam that could accept the
|
|
219
|
+
/// declaration must refuse it loudly with the same teaching — the
|
|
220
|
+
/// generated runner refuses at comptime, the runtime refuses secondary
|
|
221
|
+
/// windows at create, and this refuses the platform-created main
|
|
222
|
+
/// window at init. Pure (no GTK externs), so the refusal is
|
|
223
|
+
/// unit-testable on every host.
|
|
224
|
+
fn refuseUnsupportedMainWindowClosePolicy(window_options: platform_mod.WindowOptions) Error!void {
|
|
225
|
+
if (window_options.close_policy != .hide) return;
|
|
226
|
+
std.debug.print("window close_policy \"hide\" is not supported on linux: the GTK host has no status item (tray), so nothing could bring the hidden window back - declare \"quit\" (the default), or scope the .hide declaration to macos/windows builds\n", .{});
|
|
227
|
+
return error.UnsupportedWindowClosePolicy;
|
|
228
|
+
}
|
|
229
|
+
|
|
215
230
|
pub const LinuxPlatform = struct {
|
|
216
231
|
host: *GtkHost,
|
|
217
232
|
web_engine: platform_mod.WebEngine,
|
|
@@ -229,6 +244,14 @@ pub const LinuxPlatform = struct {
|
|
|
229
244
|
|
|
230
245
|
pub fn initWithOptions(size: geometry.SizeF, web_engine: platform_mod.WebEngine, app_info: platform_mod.AppInfo) Error!LinuxPlatform {
|
|
231
246
|
const window_options = app_info.resolvedMainWindow();
|
|
247
|
+
// The MAIN window is created right here, before any runtime
|
|
248
|
+
// exists, so the runtime's create-time `.hide` gate
|
|
249
|
+
// (window_storage's error.UnsupportedWindowClosePolicy) never
|
|
250
|
+
// sees it — without this twin refusal a direct-SDK or
|
|
251
|
+
// custom-runner user declaring `.hide` silently got
|
|
252
|
+
// quit-on-close. Same loud line as the generated runner's
|
|
253
|
+
// comptime check, at the last seam that can hold it.
|
|
254
|
+
try refuseUnsupportedMainWindowClosePolicy(window_options);
|
|
232
255
|
const window_title = window_options.resolvedTitle(app_info.app_name);
|
|
233
256
|
const frame = window_options.default_frame;
|
|
234
257
|
const host = native_sdk_gtk_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height)) orelse return error.CreateFailed;
|
|
@@ -270,6 +293,8 @@ pub const LinuxPlatform = struct {
|
|
|
270
293
|
.focus_window_fn = focusWindow,
|
|
271
294
|
.close_window_fn = closeWindow,
|
|
272
295
|
.minimize_window_fn = minimizeWindow,
|
|
296
|
+
.show_window_fn = showWindow,
|
|
297
|
+
.quit_app_fn = quitApp,
|
|
273
298
|
.start_window_drag_fn = startWindowDrag,
|
|
274
299
|
.set_window_drag_regions_fn = setWindowDragRegions,
|
|
275
300
|
.window_chrome_fn = windowChrome,
|
|
@@ -355,6 +380,10 @@ pub const LinuxPlatform = struct {
|
|
|
355
380
|
// deck's glass rests honestly instead of dancing on fakes.
|
|
356
381
|
.audio_spectrum => self.web_engine == .system and audioSpectrumAvailable(self.host),
|
|
357
382
|
.tray => false,
|
|
383
|
+
// No tray means no affordance to bring a policy-hidden
|
|
384
|
+
// window back — reporting support would strand windows, so
|
|
385
|
+
// GTK refuses `close_policy = .hide` at create instead.
|
|
386
|
+
.window_hide_on_close => false,
|
|
358
387
|
// Native scroll drivers, native context menus, and app-owned
|
|
359
388
|
// view-surface adoption are macOS-only today; GTK keeps the
|
|
360
389
|
// engine's wheel physics and has no popover-menu presenter
|
|
@@ -672,6 +701,15 @@ fn requestFrame(context: ?*anyopaque) anyerror!void {
|
|
|
672
701
|
native_sdk_gtk_request_frame(self.host);
|
|
673
702
|
}
|
|
674
703
|
|
|
704
|
+
/// Headless image codec for session replay: the SAME gdk-pixbuf decode
|
|
705
|
+
/// a live host serves (see `decodeImage` below — a context-free
|
|
706
|
+
/// bytes-to-pixels call, no window, no run loop), so journaled image
|
|
707
|
+
/// bytes re-register the identical pixels under a headless replay on
|
|
708
|
+
/// the same platform.
|
|
709
|
+
pub fn installHeadlessImageCodec(services: *platform_mod.PlatformServices) void {
|
|
710
|
+
services.decode_image_fn = decodeImage;
|
|
711
|
+
}
|
|
712
|
+
|
|
675
713
|
/// gdk-pixbuf-backed image decoding (PNG, JPEG, ... — whatever loaders
|
|
676
714
|
/// the system ships) into straight-alpha RGBA8.
|
|
677
715
|
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
|
|
@@ -731,6 +769,26 @@ fn minimizeWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerr
|
|
|
731
769
|
if (native_sdk_gtk_minimize_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
732
770
|
}
|
|
733
771
|
|
|
772
|
+
/// GTK has no hide-on-close (see `window_hide_on_close`), so show is
|
|
773
|
+
/// honestly the present verb: bring the window to the front and give
|
|
774
|
+
/// it focus — the same call the focus service makes.
|
|
775
|
+
fn showWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
776
|
+
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
777
|
+
if (native_sdk_gtk_focus_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/// The graceful quit: the same emitShutdown + g_application_quit the
|
|
781
|
+
/// last window's close-request runs, queued to the NEXT loop turn —
|
|
782
|
+
/// this verb is requested mid dispatch (the command whose update
|
|
783
|
+
/// returned it is still being dispatched), and `app_shutdown` must
|
|
784
|
+
/// emit only after that dispatch returns, or a recording session
|
|
785
|
+
/// seals its journal before the requesting command commits (the
|
|
786
|
+
/// command record is lost and replay diverges).
|
|
787
|
+
fn quitApp(context: ?*anyopaque) anyerror!void {
|
|
788
|
+
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
789
|
+
native_sdk_gtk_stop(self.host);
|
|
790
|
+
}
|
|
791
|
+
|
|
734
792
|
fn startWindowDrag(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
735
793
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
736
794
|
if (native_sdk_gtk_start_window_drag(self.host, window_id) == 0) return error.WindowNotFound;
|
|
@@ -1517,3 +1575,16 @@ fn viewKindInt(kind: platform_mod.ViewKind) c_int {
|
|
|
1517
1575
|
test "linux platform module exports type" {
|
|
1518
1576
|
_ = LinuxPlatform;
|
|
1519
1577
|
}
|
|
1578
|
+
|
|
1579
|
+
test "linux refuses a .hide main window at platform init instead of a silent quit-on-close" {
|
|
1580
|
+
// The pre-created MAIN window never passes through the runtime's
|
|
1581
|
+
// create gate, so the platform's init gate must hold the same
|
|
1582
|
+
// line. The gate sees exactly the options `initWithOptions`
|
|
1583
|
+
// resolves from the caller's AppInfo.
|
|
1584
|
+
const hide_app: platform_mod.AppInfo = .{ .app_name = "player", .main_window = .{ .close_policy = .hide } };
|
|
1585
|
+
try std.testing.expectError(error.UnsupportedWindowClosePolicy, refuseUnsupportedMainWindowClosePolicy(hide_app.resolvedMainWindow()));
|
|
1586
|
+
// The default (.quit) and every other declaration pass untouched —
|
|
1587
|
+
// the refusal is the .hide declaration's, not the init path's.
|
|
1588
|
+
const quit_app: platform_mod.AppInfo = .{ .app_name = "player" };
|
|
1589
|
+
try refuseUnsupportedMainWindowClosePolicy(quit_app.resolvedMainWindow());
|
|
1590
|
+
}
|
|
@@ -235,6 +235,10 @@ typedef struct {
|
|
|
235
235
|
double y;
|
|
236
236
|
int open;
|
|
237
237
|
int focused;
|
|
238
|
+
/* WINDOW_FRAME: nonzero while the window is alive but hidden by
|
|
239
|
+
* its close_policy (.hide intercepted a user close). open stays 1
|
|
240
|
+
* for the window's whole hidden stretch. */
|
|
241
|
+
int hidden;
|
|
238
242
|
const char *label;
|
|
239
243
|
size_t label_len;
|
|
240
244
|
const char *shortcut_id;
|
|
@@ -342,7 +346,20 @@ void native_sdk_appkit_set_dock_icon_rgba(native_sdk_appkit_host_t *host, const
|
|
|
342
346
|
// keeping the pre-masking behavior (icon shown unshaped) as the floor.
|
|
343
347
|
void native_sdk_appkit_set_dock_icon_file(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
|
|
344
348
|
void native_sdk_appkit_run(native_sdk_appkit_host_t *host, native_sdk_appkit_event_callback_t callback, void *context);
|
|
349
|
+
// The host-side shutdown request: a failed event emit asks the host to
|
|
350
|
+
// deliver SHUTDOWN and stop. While the run loop is live the delivery is
|
|
351
|
+
// queued to the next turn; before [NSApp run] it happens inline (the
|
|
352
|
+
// failed-START precedent — runWithCallback's didShutdown check honors
|
|
353
|
+
// it before the loop would start).
|
|
345
354
|
void native_sdk_appkit_stop(native_sdk_appkit_host_t *host);
|
|
355
|
+
// The quit VERB's landing point (fx.quitApp): always deferred, never
|
|
356
|
+
// inline — the verb arrives mid dispatch, and the shutdown must emit
|
|
357
|
+
// only after the requesting dispatch has committed to the session
|
|
358
|
+
// recorder. While the run loop is live the deferral is a main-queue
|
|
359
|
+
// hop; before [NSApp run] the request parks as a pending flag that
|
|
360
|
+
// runWithCallback drains at top level after the pre-run dispatch that
|
|
361
|
+
// carried it returns.
|
|
362
|
+
void native_sdk_appkit_request_stop(native_sdk_appkit_host_t *host);
|
|
346
363
|
void native_sdk_appkit_load_webview(native_sdk_appkit_host_t *host, const char *source, size_t source_len, int source_kind, const char *asset_root, size_t asset_root_len, const char *asset_entry, size_t asset_entry_len, const char *asset_origin, size_t asset_origin_len, int spa_fallback);
|
|
347
364
|
void native_sdk_appkit_load_window_webview(native_sdk_appkit_host_t *host, uint64_t window_id, const char *source, size_t source_len, int source_kind, const char *asset_root, size_t asset_root_len, const char *asset_entry, size_t asset_entry_len, const char *asset_origin, size_t asset_origin_len, int spa_fallback);
|
|
348
365
|
void native_sdk_appkit_set_bridge_callback(native_sdk_appkit_host_t *host, native_sdk_appkit_bridge_callback_t callback, void *context);
|
|
@@ -364,6 +381,17 @@ int native_sdk_appkit_close_window(native_sdk_appkit_host_t *host, uint64_t wind
|
|
|
364
381
|
// window controls on chromeless windows. Returns 0 when the window id
|
|
365
382
|
// is unknown.
|
|
366
383
|
int native_sdk_appkit_minimize_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
384
|
+
// The show verb: bring the window back to the glass and activate the
|
|
385
|
+
// app (deminiaturize + makeKeyAndOrderFront) — the counterpart to a
|
|
386
|
+
// close_policy .hide hide, and the tray-menu "Open" consequence.
|
|
387
|
+
// Returns 0 when the window id is unknown.
|
|
388
|
+
int native_sdk_appkit_show_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
389
|
+
// What the user's close affordance does to this window: 0 = quit (the
|
|
390
|
+
// default: really close; last close follows app exit semantics),
|
|
391
|
+
// 1 = hide (order out and keep running — the menu-bar-app shape).
|
|
392
|
+
// Applied right after create, like the content min-size floor.
|
|
393
|
+
// Returns 0 when the window id is unknown.
|
|
394
|
+
int native_sdk_appkit_set_window_close_policy(native_sdk_appkit_host_t *host, uint64_t window_id, int close_policy);
|
|
367
395
|
// Window-drag region channel: called during dispatch of the pointer-down
|
|
368
396
|
// that starts the gesture. Single click hands the event to
|
|
369
397
|
// -[NSWindow performWindowDragWithEvent:] (moves only on actual
|
|
@@ -486,8 +514,26 @@ int native_sdk_appkit_measure_text_advances(uint64_t font_id, double size, const
|
|
|
486
514
|
|
|
487
515
|
// Register engine-validated TrueType bytes under a canvas font id so
|
|
488
516
|
// measurement and packet text drawing resolve the id to this exact face.
|
|
489
|
-
// Returns 1 on success, 0 when CoreText rejects the data.
|
|
490
|
-
|
|
517
|
+
// Returns 1 on success, 0 when CoreText rejects the data. On success
|
|
518
|
+
// `*out_token` is the registration's ownership token — the handle the
|
|
519
|
+
// caller must present to native_sdk_appkit_unregister_font, so teardown
|
|
520
|
+
// removes exactly this registration (font ids are per-runtime while
|
|
521
|
+
// host font state is per-process: a later runtime may re-register the
|
|
522
|
+
// id, and its live face must survive the older owner's teardown). Hosts
|
|
523
|
+
// that retain no font state (the Chromium engine's stateless accept)
|
|
524
|
+
// write 0: nothing installed, nothing a token could own.
|
|
525
|
+
int native_sdk_appkit_register_font(uint64_t font_id, const uint8_t *bytes, size_t bytes_len, uint64_t *out_token);
|
|
526
|
+
// Drop the per-id state a registration installed (the descriptor and its
|
|
527
|
+
// caches) — the teardown twin Runtime.deinit calls, because font ids are
|
|
528
|
+
// per-runtime while this host's font state is per-process. `token` must
|
|
529
|
+
// be the value the matching register call reported: state is removed
|
|
530
|
+
// only while the id's current registration still carries it, so an
|
|
531
|
+
// older runtime's deinit never tears down a newer runtime's live face
|
|
532
|
+
// under a shared id. A stale token — like an id with no installed
|
|
533
|
+
// descriptor — is a no-op accept: the registration the token owned is
|
|
534
|
+
// already gone, which is the state the caller asked for. Returns 1 on
|
|
535
|
+
// accept, 0 only for the invalid id 0.
|
|
536
|
+
int native_sdk_appkit_unregister_font(uint64_t font_id, uint64_t token);
|
|
491
537
|
/* Decode encoded image bytes (PNG, JPEG, ... — whatever ImageIO supports)
|
|
492
538
|
* through CGImageSource into tightly packed, row-major, straight-alpha
|
|
493
539
|
* (non-premultiplied) RGBA8 written into `pixels`. Returns 1 on success
|