@native-sdk/cli 0.5.2 → 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 +264 -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/sdk/events.ts +39 -2
- package/packages/core/src/checker.ts +1 -1
- package/packages/core/src/emitter.ts +2625 -262
- package/packages/core/src/infer.ts +53 -7
- package/skill-data/automation/SKILL.md +7 -4
- package/skill-data/core/references/app-model-runtime.md +3 -0
- package/skill-data/native-ui/SKILL.md +4 -2
- package/skill-data/ts-core/SKILL.md +9 -1
- package/src/app_runner/root.zig +106 -1
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/protocol.zig +20 -1
- package/src/embed/host.zig +27 -0
- package/src/embed/tests.zig +187 -0
- package/src/embed/ui_host.zig +4 -0
- package/src/platform/linux/gtk_host.c +112 -3
- package/src/platform/linux/root.zig +71 -0
- package/src/platform/macos/appkit_host.h +59 -2
- package/src/platform/macos/appkit_host.m +663 -34
- package/src/platform/macos/cef_host.mm +262 -10
- package/src/platform/macos/root.zig +126 -4
- package/src/platform/null_platform.zig +298 -5
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +36 -0
- package/src/platform/types.zig +247 -8
- 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/chart.zig +7 -7
- package/src/primitives/canvas/chart_tests.zig +66 -0
- package/src/primitives/canvas/commands.zig +48 -0
- package/src/primitives/canvas/events.zig +161 -0
- package/src/primitives/canvas/font_ttf.zig +155 -8
- package/src/primitives/canvas/font_ttf_tests.zig +686 -0
- package/src/primitives/canvas/reference.zig +67 -8
- package/src/primitives/canvas/render_fingerprints.zig +8 -0
- package/src/primitives/canvas/root.zig +25 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/ui.zig +46 -9
- package/src/primitives/canvas/ui_markup.zig +82 -34
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +63 -11
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +88 -0
- package/src/primitives/canvas/ui_markup_contract.zig +10 -1
- package/src/primitives/canvas/ui_markup_contract_tests.zig +50 -0
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_tests.zig +55 -9
- package/src/primitives/canvas/ui_markup_view.zig +81 -14
- package/src/primitives/canvas/ui_markup_view_tests.zig +219 -7
- package/src/primitives/canvas/ui_schema.zig +29 -0
- package/src/primitives/canvas/ui_schema_tests.zig +11 -11
- package/src/primitives/canvas/ui_tests.zig +31 -0
- package/src/primitives/canvas/vector.zig +258 -141
- package/src/primitives/canvas/widget_access.zig +1 -1
- package/src/primitives/canvas/widget_builtin_tests.zig +129 -0
- package/src/primitives/canvas/widget_layout.zig +9 -4
- package/src/primitives/canvas/widget_render.zig +78 -40
- package/src/primitives/canvas/widget_render_controls.zig +15 -4
- package/src/primitives/canvas/widget_semantics.zig +6 -1
- package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
- package/src/primitives/canvas/widget_text_input.zig +118 -10
- package/src/primitives/canvas/widgets.zig +16 -0
- package/src/root.zig +12 -0
- package/src/runtime/api.zig +15 -0
- package/src/runtime/automation_commands.zig +33 -0
- package/src/runtime/automation_widget_dispatch.zig +64 -0
- 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 +711 -5
- package/src/runtime/canvas_fonts.zig +120 -25
- package/src/runtime/canvas_frame_helpers.zig +15 -0
- package/src/runtime/canvas_image_tests.zig +221 -0
- package/src/runtime/canvas_images.zig +78 -19
- package/src/runtime/canvas_limits.zig +44 -8
- package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
- package/src/runtime/canvas_widget_events.zig +24 -4
- package/src/runtime/canvas_widget_runtime.zig +24 -7
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +277 -0
- package/src/runtime/core.zig +148 -9
- 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 +44 -0
- package/src/runtime/gpu_surface_events.zig +7 -0
- package/src/runtime/media_surface.zig +726 -0
- package/src/runtime/media_surface_tests.zig +1476 -0
- package/src/runtime/root.zig +20 -0
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +111 -20
- package/src/runtime/session_record.zig +27 -2
- package/src/runtime/session_replay.zig +168 -16
- package/src/runtime/session_tests.zig +2118 -4
- 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 +3 -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 +63 -0
- package/src/runtime/ui_app.zig +169 -6
- package/src/runtime/ui_app_tests.zig +334 -0
- 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
|
@@ -111,6 +111,12 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
111
111
|
/// read from the environment inside update). Empty disables
|
|
112
112
|
/// derivation: URL playback still works, it just re-streams.
|
|
113
113
|
audio_cache_dir: []const u8 = "",
|
|
114
|
+
/// Platform caches directory for URL image loads —
|
|
115
|
+
/// `audio_cache_dir`'s twin for `Cmd.imageLoad`: a URL
|
|
116
|
+
/// record with no cachePath loads under the conventional
|
|
117
|
+
/// content-addressed path in this directory. Empty disables
|
|
118
|
+
/// derivation: URL loads still work, they just re-fetch.
|
|
119
|
+
image_cache_dir: []const u8 = "",
|
|
114
120
|
/// Images registered at install, before the first view build
|
|
115
121
|
/// (see `BootImage`). The slices must outlive install (the
|
|
116
122
|
/// wiring reads them into launch-lifetime buffers).
|
|
@@ -156,6 +162,7 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
156
162
|
|
|
157
163
|
fn applyCoreOptions(core_options: CoreOptions) void {
|
|
158
164
|
Host.setAudioCacheDir(core_options.audio_cache_dir);
|
|
165
|
+
Host.setImageCacheDir(core_options.image_cache_dir);
|
|
159
166
|
boot_images_store = core_options.boot_images;
|
|
160
167
|
env_values_store = core_options.env_values;
|
|
161
168
|
if (core_options.env_values.len > 0 and comptime !@hasDecl(core, "envMsgs")) {
|
|
@@ -193,6 +200,12 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
193
200
|
}
|
|
194
201
|
stamped.on_key = keyMsgAdapter;
|
|
195
202
|
}
|
|
203
|
+
if (comptime @hasDecl(core, "pinchMsg")) {
|
|
204
|
+
if (options.on_pinch != null) {
|
|
205
|
+
@panic("TsUiApp wires on_pinch from the core's pinchMsg export - remove the wiring's on_pinch");
|
|
206
|
+
}
|
|
207
|
+
stamped.on_pinch = pinchMsgAdapter;
|
|
208
|
+
}
|
|
196
209
|
if (comptime @hasDecl(core, "appearanceMsg")) {
|
|
197
210
|
if (options.on_appearance != null) {
|
|
198
211
|
@panic("TsUiApp wires on_appearance from the core's appearanceMsg export - remove the wiring's on_appearance");
|
|
@@ -360,6 +373,56 @@ pub fn TsUiApp(comptime core: type) type {
|
|
|
360
373
|
return core.keyMsg(arg);
|
|
361
374
|
}
|
|
362
375
|
|
|
376
|
+
/// `Options.on_pinch` over the core's `pinchMsg(pinch)` export:
|
|
377
|
+
/// the emitted PinchEvent record — `windowId`/`label` (the
|
|
378
|
+
/// source identity: `x`/`y` are view-local, so a coordinate
|
|
379
|
+
/// without its view is not a position; multi-window cores tell
|
|
380
|
+
/// pinches apart by these), `phase` (the declared
|
|
381
|
+
/// begin/change/end alias, matched by member name), `scale` (the
|
|
382
|
+
/// magnification DELTA on "change" — multiplicative, so the
|
|
383
|
+
/// cumulative gesture scale is the product of `1 + scale`,
|
|
384
|
+
/// applied memorylessly), and the `x`/`y` pointer anchor
|
|
385
|
+
/// in view-local canvas points. The core's return gates the channel
|
|
386
|
+
/// exactly like a Zig `on_pinch` (null drops the event).
|
|
387
|
+
fn pinchMsgAdapter(pinch: platform.PinchEvent) ?Msg {
|
|
388
|
+
const params = @typeInfo(@TypeOf(core.pinchMsg)).@"fn".params;
|
|
389
|
+
if (comptime params.len != 1) {
|
|
390
|
+
@compileError("TsUiApp: pinchMsg must take one PinchEvent parameter - regenerate the core");
|
|
391
|
+
}
|
|
392
|
+
const PinchArg = params[0].type.?;
|
|
393
|
+
comptime {
|
|
394
|
+
const fields = @typeInfo(PinchArg).@"struct".fields;
|
|
395
|
+
if (fields.len != 6 or !@hasField(PinchArg, "windowId") or !@hasField(PinchArg, "label") or
|
|
396
|
+
!@hasField(PinchArg, "phase") or !@hasField(PinchArg, "scale") or
|
|
397
|
+
!@hasField(PinchArg, "x") or !@hasField(PinchArg, "y"))
|
|
398
|
+
{
|
|
399
|
+
@compileError("TsUiApp: pinchMsg's PinchEvent must be exactly { windowId: number; label: string; phase: \"begin\" | \"change\" | \"end\"; scale: number; x: number; y: number }");
|
|
400
|
+
}
|
|
401
|
+
const Phase = @FieldType(PinchArg, "phase");
|
|
402
|
+
const phase_info = @typeInfo(Phase);
|
|
403
|
+
if (phase_info != .@"enum" or phase_info.@"enum".fields.len != 3 or
|
|
404
|
+
!@hasField(Phase, "begin") or !@hasField(Phase, "change") or !@hasField(Phase, "end"))
|
|
405
|
+
{
|
|
406
|
+
@compileError("TsUiApp: pinchMsg's PinchEvent.phase must be the named \"begin\" | \"change\" | \"end\" alias");
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
var arg: PinchArg = undefined;
|
|
410
|
+
const Phase = @FieldType(PinchArg, "phase");
|
|
411
|
+
arg.phase = switch (pinch.phase) {
|
|
412
|
+
inline else => |phase| @field(Phase, @tagName(phase)),
|
|
413
|
+
};
|
|
414
|
+
// The label slice stays borrowed exactly through the core
|
|
415
|
+
// call, like the Zig channel's contract: a Msg built from it
|
|
416
|
+
// commits (copies) on dispatch like every routed bytes
|
|
417
|
+
// payload.
|
|
418
|
+
arg.windowId = channelNum(@FieldType(PinchArg, "windowId"), @floatFromInt(pinch.window_id));
|
|
419
|
+
arg.label = pinch.label;
|
|
420
|
+
arg.scale = channelNum(@FieldType(PinchArg, "scale"), pinch.scale);
|
|
421
|
+
arg.x = channelNum(@FieldType(PinchArg, "x"), pinch.x);
|
|
422
|
+
arg.y = channelNum(@FieldType(PinchArg, "y"), pinch.y);
|
|
423
|
+
return core.pinchMsg(arg);
|
|
424
|
+
}
|
|
425
|
+
|
|
363
426
|
/// `Options.on_appearance` over the core's `appearanceMsg` arm
|
|
364
427
|
/// export: the appearance record — `colorScheme` (a declared
|
|
365
428
|
/// light/dark enum, matched by member name), `reduceMotion`,
|
package/src/runtime/ui_app.zig
CHANGED
|
@@ -537,6 +537,26 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
537
537
|
/// can never steal typing — a fallback that yields to every
|
|
538
538
|
/// consuming widget can carry them safely.
|
|
539
539
|
on_key: ?*const fn (keyboard: canvas.WidgetKeyboardEvent) ?MsgT = null,
|
|
540
|
+
/// Optional mapping from trackpad pinch gestures into
|
|
541
|
+
/// messages — the app-level gesture channel (the `on_key`
|
|
542
|
+
/// shape). Pinch deliberately bypasses the widget pipeline:
|
|
543
|
+
/// it is a view-global gesture (timeline/canvas zoom is an
|
|
544
|
+
/// app-level concern), delivered phase-explicit (`begin`,
|
|
545
|
+
/// `change`, `end`) with the per-event magnification DELTA
|
|
546
|
+
/// on `change` — a MULTIPLICATIVE delta: the cumulative
|
|
547
|
+
/// gesture scale is the running product of `(1 + scale)`,
|
|
548
|
+
/// applied memorylessly (`zoom *= 1 + scale`); on macOS the
|
|
549
|
+
/// host forwards AppKit's raw `NSEvent.magnification`,
|
|
550
|
+
/// which IS that delta per the browser-engine convention
|
|
551
|
+
/// — and the pointer anchor in
|
|
552
|
+
/// view-local canvas points (`x`/`y`, the zoom-at-cursor
|
|
553
|
+
/// anchor). Every event names its source window and view
|
|
554
|
+
/// (`window_id`/`label`, the `on_frame` identity shape) —
|
|
555
|
+
/// view-local coordinates mean nothing without their view,
|
|
556
|
+
/// so multi-window apps tell pinches apart. Only hosts with
|
|
557
|
+
/// a pinch source emit these (macOS today); everywhere else
|
|
558
|
+
/// the channel simply never fires.
|
|
559
|
+
on_pinch: ?*const fn (pinch: platform.PinchEvent) ?MsgT = null,
|
|
540
560
|
/// Optional mapping from runtime timer events (started via
|
|
541
561
|
/// `runtime.startTimer`) into messages. Framework-reserved timer
|
|
542
562
|
/// ids (>= `platform.reserved_timer_id_base`) are handled
|
|
@@ -719,6 +739,16 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
719
739
|
/// register would then fail `FontIdInUse` and bury the real
|
|
720
740
|
/// error).
|
|
721
741
|
fonts_registered: bool = false,
|
|
742
|
+
/// The runtime's registered-font count the installed trees last
|
|
743
|
+
/// measured against. Registration is permanent with no
|
|
744
|
+
/// unregister, so the count IS the runtime's fonts generation:
|
|
745
|
+
/// a mismatch on a presented frame means a face joined the
|
|
746
|
+
/// registry AFTER the trees were built (late registration
|
|
747
|
+
/// through `runtime.registerCanvasFont` — `Options.fonts` lands
|
|
748
|
+
/// before the installing build), and every installed surface
|
|
749
|
+
/// must rebuild so layout re-measures with the new face
|
|
750
|
+
/// (`rebuildForRegisteredFonts`).
|
|
751
|
+
fonts_built_count: usize = 0,
|
|
722
752
|
/// Exactly-once guard for `Options.init_fx`, independent of
|
|
723
753
|
/// `installed` so a failed install rebuild cannot rerun it.
|
|
724
754
|
init_fx_ran: bool = false,
|
|
@@ -1033,6 +1063,8 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1033
1063
|
.context = runtime,
|
|
1034
1064
|
.close_fn = effectsCloseWindowByLabel,
|
|
1035
1065
|
.minimize_fn = effectsMinimizeWindowByLabel,
|
|
1066
|
+
.show_fn = effectsShowWindowByLabel,
|
|
1067
|
+
.quit_fn = effectsQuitApp,
|
|
1036
1068
|
});
|
|
1037
1069
|
if (runtime.options.session_recorder) |recorder| {
|
|
1038
1070
|
self.effects.bindJournal(recorder.effectJournal());
|
|
@@ -1070,6 +1102,23 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1070
1102
|
// envMsgs dispatch consumes the queue on the
|
|
1071
1103
|
// replayed installing frame (zero env reads).
|
|
1072
1104
|
.env => try self.effects.pushReplayEnv(record.stderr_tail, record.payload),
|
|
1105
|
+
// `.image` records deliver the RECORDED terminal
|
|
1106
|
+
// verbatim (byte-identical Msg stream on any host)
|
|
1107
|
+
// and re-register the journaled source bytes —
|
|
1108
|
+
// resolved from the blob store into `payload` by
|
|
1109
|
+
// the replayer — best-effort for presentation.
|
|
1110
|
+
// Loop-side validation rejections never reach here
|
|
1111
|
+
// (marked by `exit_reason == .rejected`, they
|
|
1112
|
+
// regenerate and are skipped); a worker-origin
|
|
1113
|
+
// `.rejected` terminal feeds like any failure class.
|
|
1114
|
+
.image => try self.effects.feedImageResult(
|
|
1115
|
+
record.key,
|
|
1116
|
+
record.image_outcome,
|
|
1117
|
+
record.image_width,
|
|
1118
|
+
record.image_height,
|
|
1119
|
+
record.status,
|
|
1120
|
+
record.payload,
|
|
1121
|
+
),
|
|
1073
1122
|
// Spectrum records feed through the band-carrying
|
|
1074
1123
|
// helper so replay repaints identical bars; every
|
|
1075
1124
|
// other audio kind rides the plain shape.
|
|
@@ -1129,7 +1178,16 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1129
1178
|
self.bindEffectsChannel(runtime);
|
|
1130
1179
|
self.syncModel(runtime, self.canvas_window_id);
|
|
1131
1180
|
var dispatched = false;
|
|
1132
|
-
|
|
1181
|
+
// One pass consumes only completions that existed when it
|
|
1182
|
+
// began: a load started by an update handler in THIS pass
|
|
1183
|
+
// that finishes while the pass still runs waits for the wake
|
|
1184
|
+
// its producer already nudged. That keeps the session
|
|
1185
|
+
// journal's event boundaries causal — every result recorded
|
|
1186
|
+
// ahead of this wake's event record answers a request from
|
|
1187
|
+
// an earlier dispatch, so replay's file-order feed always
|
|
1188
|
+
// finds the parked request (see Effects.DrainBoundary).
|
|
1189
|
+
var boundary = self.effects.drainBoundary();
|
|
1190
|
+
while (self.effects.takeMsgWithin(&boundary)) |msg| {
|
|
1133
1191
|
self.applyMsg(msg);
|
|
1134
1192
|
dispatched = true;
|
|
1135
1193
|
}
|
|
@@ -1230,14 +1288,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1230
1288
|
/// Whether a rebuild must push its tokens into the runtime's
|
|
1231
1289
|
/// stored copy. Derived tokens can change with any model or
|
|
1232
1290
|
/// appearance input, so they always re-emit. Static tokens are
|
|
1233
|
-
/// fixed by the app, but the runtime stamps
|
|
1234
|
-
///
|
|
1235
|
-
/// stale scale re-emits
|
|
1236
|
-
/// between monitors
|
|
1237
|
-
///
|
|
1291
|
+
/// fixed by the app, but the runtime stamps two live values onto
|
|
1292
|
+
/// them: the surface scale (`effectiveTokens` — a stored copy
|
|
1293
|
+
/// holding a stale scale re-emits so hairlines re-snap after a
|
|
1294
|
+
/// move between monitors) and the text-measure provider
|
|
1295
|
+
/// (`tokensWithTextMeasure` — the FIRST font registration binds
|
|
1296
|
+
/// the runtime's font-aware provider on platforms without host
|
|
1297
|
+
/// measurement, and a stored copy still measuring with the
|
|
1298
|
+
/// estimator would keep display-list text layout on
|
|
1299
|
+
/// pre-registration metrics). Ordinary rebuilds keep skipping
|
|
1300
|
+
/// the redundant emission.
|
|
1238
1301
|
fn rebuildEmitsTokens(self: *const Self, runtime: *Runtime, window_id: platform.WindowId, canvas_label: []const u8, tokens: canvas.DesignTokens) bool {
|
|
1239
1302
|
if (self.derivesTokens()) return true;
|
|
1240
1303
|
const stored = runtime.canvasWidgetDesignTokens(window_id, canvas_label) catch return true;
|
|
1304
|
+
if (!std.meta.eql(stored.text_measure, tokens.text_measure)) return true;
|
|
1241
1305
|
return stored.pixel_snap.scale != tokens.pixel_snap.scale;
|
|
1242
1306
|
}
|
|
1243
1307
|
|
|
@@ -2770,6 +2834,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2770
2834
|
.canvas_widget_change => |change_event| try self.handleWidgetChange(runtime, change_event),
|
|
2771
2835
|
.window_closed => |closed| try self.handleWindowClosed(runtime, closed),
|
|
2772
2836
|
.automation_provenance => |query| try self.handleProvenanceQuery(runtime, query),
|
|
2837
|
+
// Raw gpu-surface input stays runtime-internal EXCEPT the
|
|
2838
|
+
// pinch kinds, which surface through the app-level pinch
|
|
2839
|
+
// channel (widget routing never claims a pinch).
|
|
2840
|
+
.gpu_surface_input => |input_event| try self.handlePinch(runtime, input_event),
|
|
2773
2841
|
else => {},
|
|
2774
2842
|
}
|
|
2775
2843
|
}
|
|
@@ -2835,6 +2903,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2835
2903
|
"font \"{s}\" (id {d}) failed to register: {s}",
|
|
2836
2904
|
.{ font.name, font.id, canvas.font_ttf.parseFailureReason(font.ttf) orelse "not a parseable TrueType face" },
|
|
2837
2905
|
),
|
|
2906
|
+
error.FontExceedsGlyphBudgets => if (canvas.font_ttf.declaredGlyphMaxima(font.ttf)) |maxima| ui_app_log.warn(
|
|
2907
|
+
"font \"{s}\" (id {d}) failed to register: its 'maxp' declares glyphs up to {d} points / {d} contours, flattened composites up to {d} points / {d} contours, with composites {d} deep of {d} components, beyond the outline budgets ({d} points, {d} contours, {d} composite points, {d} composite contours, {d} deep, {d} components — canvas.font_ttf); past-budget glyphs would render as block fallbacks, so registration refuses the face whole",
|
|
2908
|
+
.{ font.name, font.id, maxima.points, maxima.contours, maxima.composite_points, maxima.composite_contours, maxima.component_depth, maxima.component_elements, canvas.font_ttf.max_glyph_points, canvas.font_ttf.max_glyph_contours, canvas.font_ttf.max_composite_points, canvas.font_ttf.max_composite_contours, canvas.font_ttf.max_composite_depth, canvas.font_ttf.max_composite_components },
|
|
2909
|
+
) else ui_app_log.warn(
|
|
2910
|
+
"font \"{s}\" (id {d}) failed to register: it declares glyph outlines denser than the renderer's budgets ({d} points / {d} contours per glyph — canvas.font_ttf), so its densest glyphs could not render as outlines",
|
|
2911
|
+
.{ font.name, font.id, canvas.font_ttf.max_glyph_points, canvas.font_ttf.max_glyph_contours },
|
|
2912
|
+
),
|
|
2838
2913
|
error.FontTooLarge => ui_app_log.warn(
|
|
2839
2914
|
"font \"{s}\" (id {d}) failed to register: the file is {d} bytes but the per-font budget is {d} bytes (canvas_limits.max_registered_canvas_font_bytes)",
|
|
2840
2915
|
.{ font.name, font.id, font.ttf.len, canvas_limits.max_registered_canvas_font_bytes },
|
|
@@ -2918,6 +2993,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2918
2993
|
_ = try runtime.emitCanvasWidgetDisplayList(frame_event.window_id, self.options.canvas_label, runtime.tokensWithTextMeasure(self.effectiveTokens()));
|
|
2919
2994
|
}
|
|
2920
2995
|
self.installed = true;
|
|
2996
|
+
// The installing rebuild measured with everything the
|
|
2997
|
+
// registry holds right now (declared fonts registered
|
|
2998
|
+
// above, embedder registrations before install): adopt
|
|
2999
|
+
// the count so only faces joining AFTER this build
|
|
3000
|
+
// trigger the late-registration rebuild.
|
|
3001
|
+
self.fonts_built_count = runtime.registeredCanvasFontCount();
|
|
2921
3002
|
self.startMarkupWatch(runtime);
|
|
2922
3003
|
self.installStatusItem(runtime);
|
|
2923
3004
|
} else if (@abs(self.pixel_snap_scale - scale) > 0.001) {
|
|
@@ -2946,6 +3027,17 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2946
3027
|
// job.
|
|
2947
3028
|
self.canvas_size = frame_event.size;
|
|
2948
3029
|
try self.rebuild(runtime, frame_event.window_id);
|
|
3030
|
+
} else if (runtime.registeredCanvasFontCount() != self.fonts_built_count) {
|
|
3031
|
+
// A face joined the registry after install (late
|
|
3032
|
+
// registration through the runtime seam). The runtime
|
|
3033
|
+
// already invalidated measurement caches and requested
|
|
3034
|
+
// frames for every open surface (noteCanvasFontsChanged),
|
|
3035
|
+
// but repainting retained geometry only re-inks text
|
|
3036
|
+
// measured with the OLD seam answers: honoring the fonts
|
|
3037
|
+
// doc's promise — every open surface re-measures — means
|
|
3038
|
+
// rebuilding so layout and the re-emitted display lists
|
|
3039
|
+
// charge the registered face's advances.
|
|
3040
|
+
try self.rebuildForRegisteredFonts(runtime);
|
|
2949
3041
|
} else if (self.options.web_panes != null) {
|
|
2950
3042
|
// Re-snap the webview panes each presented frame: a shell
|
|
2951
3043
|
// relayout that stomped a pane frame also invalidated the
|
|
@@ -3000,10 +3092,39 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
3000
3092
|
// stale bounds.
|
|
3001
3093
|
slot.canvas_size = frame_event.size;
|
|
3002
3094
|
try self.rebuildWindowSlot(runtime, slot);
|
|
3095
|
+
} else if (runtime.registeredCanvasFontCount() != self.fonts_built_count) {
|
|
3096
|
+
// Late registration, first observed on a secondary
|
|
3097
|
+
// window's frame (registration requests frames for every
|
|
3098
|
+
// open surface, and arrival order is the platform's):
|
|
3099
|
+
// the same all-surfaces rebuild as the main canvas —
|
|
3100
|
+
// the count is app-level, so whichever surface's frame
|
|
3101
|
+
// lands first re-measures all of them.
|
|
3102
|
+
try self.rebuildForRegisteredFonts(runtime);
|
|
3003
3103
|
}
|
|
3004
3104
|
try self.presentFrame(runtime, frame_event, slot.canvasLabel(), installing);
|
|
3005
3105
|
}
|
|
3006
3106
|
|
|
3107
|
+
/// A face joined the runtime's font registry after this app's
|
|
3108
|
+
/// trees were built: rebuild EVERY installed surface — main
|
|
3109
|
+
/// canvas and declared secondary windows — so widget frames and
|
|
3110
|
+
/// baked text runs re-measure against the registered face, then
|
|
3111
|
+
/// adopt the count. Rebuild re-emits each surface's display list
|
|
3112
|
+
/// (`rebuildEmitsTokens` treats a text-measure provider change
|
|
3113
|
+
/// as an emit reason), so the repaint the runtime already
|
|
3114
|
+
/// requested draws re-measured geometry, not re-inked stale
|
|
3115
|
+
/// frames.
|
|
3116
|
+
fn rebuildForRegisteredFonts(self: *Self, runtime: *Runtime) anyerror!void {
|
|
3117
|
+
try self.rebuildAllViews(runtime);
|
|
3118
|
+
// Adopt the count only AFTER the rebuild succeeded:
|
|
3119
|
+
// production dispatch degrades errors, so a failed rebuild
|
|
3120
|
+
// (widget budget, allocator pressure, a secondary window's
|
|
3121
|
+
// emit) that had already adopted the count would mark stale
|
|
3122
|
+
// layouts as font-current and never retry. Left unadopted,
|
|
3123
|
+
// the error leaves the count mismatched and the next
|
|
3124
|
+
// presented frame retries the rebuild.
|
|
3125
|
+
self.fonts_built_count = runtime.registeredCanvasFontCount();
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3007
3128
|
/// Present the planned canvas frame: GPU packet when the platform
|
|
3008
3129
|
/// has a packet presenter (macOS/Metal — unchanged), otherwise the
|
|
3009
3130
|
/// CPU reference-rendered pixel path (`presentGpuSurfacePixels`,
|
|
@@ -3343,6 +3464,33 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
3343
3464
|
}
|
|
3344
3465
|
}
|
|
3345
3466
|
|
|
3467
|
+
/// Trackpad pinch reaches the app as the view-global gesture
|
|
3468
|
+
/// channel (`Options.on_pinch`): only the pinch kinds of the raw
|
|
3469
|
+
/// gpu-surface input surface here — every other raw input kind
|
|
3470
|
+
/// stays runtime-internal (widgets and the semantic Msg surface
|
|
3471
|
+
/// already carry it). The Msg dispatch rides the same journaled
|
|
3472
|
+
/// input event, so a recorded pinch replays to the identical
|
|
3473
|
+
/// model.
|
|
3474
|
+
fn handlePinch(self: *Self, runtime: *Runtime, input_event: platform.GpuSurfaceInputEvent) anyerror!void {
|
|
3475
|
+
const map = self.options.on_pinch orelse return;
|
|
3476
|
+
const phase: platform.PinchPhase = switch (input_event.kind) {
|
|
3477
|
+
.pinch_begin => .begin,
|
|
3478
|
+
.pinch_change => .change,
|
|
3479
|
+
.pinch_end => .end,
|
|
3480
|
+
else => return,
|
|
3481
|
+
};
|
|
3482
|
+
if (map(.{
|
|
3483
|
+
.window_id = input_event.window_id,
|
|
3484
|
+
.label = input_event.label,
|
|
3485
|
+
.phase = phase,
|
|
3486
|
+
.scale = input_event.scale,
|
|
3487
|
+
.x = input_event.x,
|
|
3488
|
+
.y = input_event.y,
|
|
3489
|
+
})) |msg| {
|
|
3490
|
+
try self.dispatch(runtime, input_event.window_id, msg);
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3346
3494
|
/// Split-fraction changes route through the split's `on_resize`
|
|
3347
3495
|
/// constructor. The payload is the fraction the runtime already
|
|
3348
3496
|
/// applied, so a model that stores it and echoes it back into
|
|
@@ -3512,3 +3660,18 @@ fn effectsMinimizeWindowByLabel(context: *anyopaque, window_label: []const u8) b
|
|
|
3512
3660
|
runtime.minimizeWindow(window_id) catch return false;
|
|
3513
3661
|
return true;
|
|
3514
3662
|
}
|
|
3663
|
+
|
|
3664
|
+
fn effectsShowWindowByLabel(context: *anyopaque, window_label: []const u8) bool {
|
|
3665
|
+
const runtime: *Runtime = @ptrCast(@alignCast(context));
|
|
3666
|
+
// A policy-hidden window keeps `open` true, so the same live-window
|
|
3667
|
+
// resolution close/minimize use finds it.
|
|
3668
|
+
const window_id = effectsWindowIdByLabel(runtime, window_label) orelse return false;
|
|
3669
|
+
runtime.showWindow(window_id) catch return false;
|
|
3670
|
+
return true;
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
fn effectsQuitApp(context: *anyopaque) bool {
|
|
3674
|
+
const runtime: *Runtime = @ptrCast(@alignCast(context));
|
|
3675
|
+
runtime.quitApp() catch return false;
|
|
3676
|
+
return true;
|
|
3677
|
+
}
|