@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
|
@@ -101,6 +101,9 @@ var test_payload: ?[]const u8 = null;
|
|
|
101
101
|
var test_timeout_ms: u32 = effects_mod.default_effect_fetch_timeout_ms;
|
|
102
102
|
var test_response_mode: effects_mod.FetchResponseMode = .buffered;
|
|
103
103
|
var test_max_line_bytes: usize = effects_mod.max_effect_line_bytes;
|
|
104
|
+
/// The poll idiom (one-shot): when set, the update reacts to a response
|
|
105
|
+
/// by immediately fetching the same key again.
|
|
106
|
+
var test_refetch_on_response: bool = false;
|
|
104
107
|
|
|
105
108
|
fn fetchUpdate(model: *FetchModel, msg: FetchMsg, fx: *FetchEffects) void {
|
|
106
109
|
switch (msg) {
|
|
@@ -118,7 +121,17 @@ fn fetchUpdate(model: *FetchModel, msg: FetchMsg, fx: *FetchEffects) void {
|
|
|
118
121
|
}),
|
|
119
122
|
.stop => fx.cancel(fetch_key),
|
|
120
123
|
.line => |line| model.recordLine(line),
|
|
121
|
-
.response => |response|
|
|
124
|
+
.response => |response| {
|
|
125
|
+
model.record(response);
|
|
126
|
+
if (test_refetch_on_response) {
|
|
127
|
+
test_refetch_on_response = false;
|
|
128
|
+
fx.fetch(.{
|
|
129
|
+
.key = fetch_key,
|
|
130
|
+
.url = test_url,
|
|
131
|
+
.on_response = FetchEffects.responseMsg(.response),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
122
135
|
}
|
|
123
136
|
}
|
|
124
137
|
|
|
@@ -1071,3 +1084,78 @@ test "real fetch cancels mid-flight with exactly one cancelled terminal" {
|
|
|
1071
1084
|
try std.testing.expectEqual(@as(usize, 1), h.app_state.model.response_count);
|
|
1072
1085
|
try std.testing.expectEqual(@as(usize, 0), h.app_state.effects.activeCount());
|
|
1073
1086
|
}
|
|
1087
|
+
|
|
1088
|
+
test "a fetch response still undelivered occupies its key against a second fetch; delivery frees it" {
|
|
1089
|
+
var h = try Harness.create();
|
|
1090
|
+
defer h.destroy();
|
|
1091
|
+
const fx = &h.app_state.effects;
|
|
1092
|
+
fx.executor = .fake;
|
|
1093
|
+
|
|
1094
|
+
test_url = "https://api.example.com/v1/data";
|
|
1095
|
+
test_method = .GET;
|
|
1096
|
+
test_headers = &.{};
|
|
1097
|
+
test_payload = null;
|
|
1098
|
+
test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
|
|
1099
|
+
test_response_mode = .buffered;
|
|
1100
|
+
test_max_line_bytes = effects_mod.max_effect_line_bytes;
|
|
1101
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
1102
|
+
try std.testing.expectEqual(@as(usize, 1), fx.pendingFetchCount());
|
|
1103
|
+
|
|
1104
|
+
// The fed response queues the terminal and parks the slot in
|
|
1105
|
+
// `.draining` — posted but undelivered. A second fetch of the same
|
|
1106
|
+
// key inside that window must reject: under session replay the
|
|
1107
|
+
// first request is still a parked `.running` fake here (its
|
|
1108
|
+
// journaled response feeds at the recorded delivery position), so
|
|
1109
|
+
// a live accept would journal a Msg stream replay rejects.
|
|
1110
|
+
try fx.feedResponse(fetch_key, 200, "first");
|
|
1111
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
1112
|
+
try std.testing.expectEqual(@as(usize, 0), fx.pendingFetchCount());
|
|
1113
|
+
|
|
1114
|
+
// Delivery order: the staged rejection first (loop-side pending),
|
|
1115
|
+
// then the queued response.
|
|
1116
|
+
try h.drainWakes();
|
|
1117
|
+
try std.testing.expectEqual(@as(usize, 2), h.app_state.model.response_count);
|
|
1118
|
+
try std.testing.expectEqual(@as(usize, 1), h.app_state.model.rejected_count);
|
|
1119
|
+
try std.testing.expectEqual(effects_mod.EffectFetchOutcome.ok, h.app_state.model.outcome.?);
|
|
1120
|
+
|
|
1121
|
+
// The window ends at delivery: the same key fetches again.
|
|
1122
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
1123
|
+
try std.testing.expectEqual(@as(usize, 1), fx.pendingFetchCount());
|
|
1124
|
+
try fx.feedResponse(fetch_key, 201, "second");
|
|
1125
|
+
try h.drainWakes();
|
|
1126
|
+
try std.testing.expectEqual(@as(usize, 3), h.app_state.model.response_count);
|
|
1127
|
+
try std.testing.expectEqual(@as(u16, 201), h.app_state.model.status);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
test "an update that refetches the same key from its own response parks instead of rejecting" {
|
|
1131
|
+
var h = try Harness.create();
|
|
1132
|
+
defer h.destroy();
|
|
1133
|
+
const fx = &h.app_state.effects;
|
|
1134
|
+
fx.executor = .fake;
|
|
1135
|
+
|
|
1136
|
+
test_url = "https://api.example.com/v1/poll";
|
|
1137
|
+
test_method = .GET;
|
|
1138
|
+
test_headers = &.{};
|
|
1139
|
+
test_payload = null;
|
|
1140
|
+
test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
|
|
1141
|
+
test_response_mode = .buffered;
|
|
1142
|
+
test_max_line_bytes = effects_mod.max_effect_line_bytes;
|
|
1143
|
+
test_refetch_on_response = true;
|
|
1144
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
1145
|
+
try fx.feedResponse(fetch_key, 200, "first");
|
|
1146
|
+
|
|
1147
|
+
// The drain retires the slot BEFORE the terminal Msg reaches
|
|
1148
|
+
// update, so the handler's refetch of its own key is a fresh
|
|
1149
|
+
// accepted fetch — the poll idiom must not regress.
|
|
1150
|
+
try h.drainWakes();
|
|
1151
|
+
try std.testing.expectEqual(@as(usize, 1), h.app_state.model.response_count);
|
|
1152
|
+
try std.testing.expectEqual(@as(usize, 0), h.app_state.model.rejected_count);
|
|
1153
|
+
try std.testing.expectEqual(@as(usize, 1), fx.pendingFetchCount());
|
|
1154
|
+
|
|
1155
|
+
// The refetched occupancy is fully live: its own terminal delivers.
|
|
1156
|
+
try fx.feedResponse(fetch_key, 201, "second");
|
|
1157
|
+
try h.drainWakes();
|
|
1158
|
+
try std.testing.expectEqual(@as(usize, 2), h.app_state.model.response_count);
|
|
1159
|
+
try std.testing.expectEqual(@as(u16, 201), h.app_state.model.status);
|
|
1160
|
+
try std.testing.expectEqual(@as(usize, 0), h.app_state.model.rejected_count);
|
|
1161
|
+
}
|
|
@@ -73,6 +73,9 @@ const file_key: u64 = 77;
|
|
|
73
73
|
// Set by each test before dispatching `.save`/`.load`.
|
|
74
74
|
var test_path: []const u8 = "";
|
|
75
75
|
var test_bytes: []const u8 = "";
|
|
76
|
+
/// The reload idiom (one-shot): when set, the update reacts to a file
|
|
77
|
+
/// terminal by immediately reading the same key again.
|
|
78
|
+
var test_reread_on_result: bool = false;
|
|
76
79
|
|
|
77
80
|
fn fileUpdate(model: *FileModel, msg: FileMsg, fx: *FileEffects) void {
|
|
78
81
|
switch (msg) {
|
|
@@ -88,7 +91,17 @@ fn fileUpdate(model: *FileModel, msg: FileMsg, fx: *FileEffects) void {
|
|
|
88
91
|
.on_result = FileEffects.fileMsg(.file_result),
|
|
89
92
|
}),
|
|
90
93
|
.stop => fx.cancel(file_key),
|
|
91
|
-
.file_result => |result|
|
|
94
|
+
.file_result => |result| {
|
|
95
|
+
model.record(result);
|
|
96
|
+
if (test_reread_on_result) {
|
|
97
|
+
test_reread_on_result = false;
|
|
98
|
+
fx.readFile(.{
|
|
99
|
+
.key = file_key,
|
|
100
|
+
.path = test_path,
|
|
101
|
+
.on_result = FileEffects.fileMsg(.file_result),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
},
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
107
|
|
|
@@ -237,6 +250,33 @@ test "cancelling a fake file effect delivers one cancelled terminal" {
|
|
|
237
250
|
try std.testing.expectError(error.EffectNotFound, fx.feedFileResult(file_key, .ok, ""));
|
|
238
251
|
}
|
|
239
252
|
|
|
253
|
+
test "an update that rereads the same key from its own file result parks instead of rejecting" {
|
|
254
|
+
var h = try Harness.create();
|
|
255
|
+
defer h.destroy();
|
|
256
|
+
const fx = &h.app_state.effects;
|
|
257
|
+
fx.executor = .fake;
|
|
258
|
+
|
|
259
|
+
test_path = "sessions/state.json";
|
|
260
|
+
test_bytes = "";
|
|
261
|
+
test_reread_on_result = true;
|
|
262
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .load);
|
|
263
|
+
try fx.feedFileResult(file_key, .ok, "{\"stage\":\"one\"}");
|
|
264
|
+
|
|
265
|
+
// The drain retires the slot BEFORE the terminal Msg reaches
|
|
266
|
+
// update, so the handler's reread of its own key is a fresh
|
|
267
|
+
// accepted file effect — the reload idiom must not regress.
|
|
268
|
+
try h.drainWakes();
|
|
269
|
+
try std.testing.expectEqual(@as(usize, 1), h.app_state.model.result_count);
|
|
270
|
+
try std.testing.expectEqual(effects_mod.EffectFileOutcome.ok, h.app_state.model.last_outcome.?);
|
|
271
|
+
try std.testing.expectEqual(@as(usize, 1), fx.pendingFileCount());
|
|
272
|
+
|
|
273
|
+
// The reread occupancy is fully live: its own terminal delivers.
|
|
274
|
+
try fx.feedFileResult(file_key, .ok, "{\"stage\":\"two\"}");
|
|
275
|
+
try h.drainWakes();
|
|
276
|
+
try std.testing.expectEqual(@as(usize, 2), h.app_state.model.result_count);
|
|
277
|
+
try std.testing.expectEqualStrings("{\"stage\":\"two\"}", h.app_state.model.bytesPrefix());
|
|
278
|
+
}
|
|
279
|
+
|
|
240
280
|
test "file requests that cannot run are rejected loudly, never silently" {
|
|
241
281
|
var h = try Harness.create();
|
|
242
282
|
defer h.destroy();
|