@native-sdk/cli 0.8.0 → 0.8.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/README.md +4 -4
- package/build.zig +49 -23
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +16 -0
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.d.ts +11 -0
- package/packages/core/sdk/core.ts +29 -2
- package/packages/core/sdk/events.d.ts +10 -0
- package/packages/core/sdk/events.ts +24 -4
- package/packages/core/src/checker.ts +1 -1
- package/packages/core/src/contract.ts +4 -1
- package/packages/core/src/devhost.ts +10 -1
- package/packages/core/src/diagnostics.ts +1 -1
- package/skill-data/core/SKILL.md +48 -20
- package/skill-data/core/references/app-model-runtime.md +2 -2
- package/skill-data/core/references/project-anatomy.md +22 -6
- package/skill-data/native-ui/SKILL.md +71 -29
- package/skill-data/ts-core/SKILL.md +13 -8
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +6 -5
- package/src/app_runner/ts_core_main.zig +2 -1
- package/src/embed/tests.zig +3 -1
- package/src/platform/macos/appkit_host.h +4 -4
- package/src/platform/macos/appkit_host.m +24 -4
- package/src/platform/macos/cef_host.mm +22 -6
- package/src/platform/macos/root.zig +2 -2
- package/src/primitives/canvas/events.zig +8 -0
- package/src/primitives/canvas/markdown.zig +2010 -57
- package/src/primitives/canvas/markdown_hostile_tests.zig +40 -0
- package/src/primitives/canvas/markdown_tests.zig +778 -3
- package/src/primitives/canvas/root.zig +2 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/ui.zig +53 -8
- package/src/primitives/canvas/ui_markup.zig +10 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +61 -3
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +27 -0
- package/src/primitives/canvas/ui_markup_contract.zig +31 -3
- package/src/primitives/canvas/ui_markup_reflect.zig +41 -0
- package/src/primitives/canvas/ui_markup_view.zig +49 -3
- package/src/primitives/canvas/ui_markup_view_tests.zig +61 -2
- package/src/primitives/canvas/ui_schema.zig +8 -1
- package/src/primitives/canvas/ui_schema_tests.zig +7 -6
- package/src/primitives/canvas/ui_tests.zig +14 -0
- package/src/primitives/canvas/widget_access.zig +4 -3
- package/src/primitives/canvas/widget_invalidation.zig +11 -0
- package/src/primitives/canvas/widget_layout.zig +26 -3
- package/src/primitives/canvas/widget_metrics.zig +21 -3
- package/src/primitives/canvas/widget_render.zig +87 -1
- package/src/primitives/canvas/widget_routing.zig +12 -7
- package/src/primitives/canvas/widget_runtime_tests.zig +132 -0
- package/src/primitives/canvas/widgets.zig +40 -0
- package/src/root.zig +1 -0
- package/src/runtime/automation_widget_dispatch.zig +19 -0
- package/src/runtime/canvas_limits.zig +5 -0
- package/src/runtime/canvas_widget_event_tests.zig +424 -8
- package/src/runtime/canvas_widget_events.zig +254 -7
- package/src/runtime/canvas_widget_state.zig +123 -1
- package/src/runtime/core.zig +6 -0
- package/src/runtime/effects.zig +36 -1
- package/src/runtime/effects_fetch_tests.zig +21 -0
- package/src/runtime/effects_notification_tests.zig +65 -0
- package/src/runtime/gpu_surface_events.zig +60 -14
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_core_host.zig +16 -0
- package/src/runtime/ts_ui_app.zig +55 -2
- package/src/runtime/ui_app.zig +112 -0
- package/src/runtime/ui_app_tests.zig +356 -0
- package/src/runtime/view.zig +35 -0
- package/src/runtime/view_widget_tree.zig +12 -0
- package/tools/corewire/core_abi.zig +1 -0
- package/tools/corewire/emit.zig +55 -8
- package/tools/corewire/emit_facade.zig +63 -2
- package/tools/corewire/emit_profile.zig +4 -1
- package/tools/corewire/sidecar.zig +36 -6
|
@@ -51,6 +51,16 @@ const canvas_widget_multi_click_interval_ns: u64 = 500 * std.time.ns_per_ms;
|
|
|
51
51
|
/// hand tremor keeps the chain, a click somewhere else breaks it.
|
|
52
52
|
const canvas_widget_multi_click_slop: f32 = 4.0;
|
|
53
53
|
|
|
54
|
+
/// Movement per axis (canvas points) that promotes a pressed draggable
|
|
55
|
+
/// candidate into a live drag. Below this threshold pointer motion remains
|
|
56
|
+
/// observable to the low-level drag channel, but it owns no floating preview,
|
|
57
|
+
/// terminal phase, or landing animation — the release is still a click.
|
|
58
|
+
pub const canvas_widget_drag_slop: f32 = 6.0;
|
|
59
|
+
|
|
60
|
+
pub fn canvasWidgetDragCrossedSlop(delta: geometry.OffsetF) bool {
|
|
61
|
+
return @abs(delta.dx) >= canvas_widget_drag_slop or @abs(delta.dy) >= canvas_widget_drag_slop;
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
55
65
|
return struct {
|
|
56
66
|
pub fn routeCanvasWidgetPointerInput(self: *const Runtime, input_event: GpuSurfaceInputEvent, output: []canvas.WidgetEventRouteEntry) anyerror!?CanvasWidgetPointerEvent {
|
|
@@ -268,22 +278,251 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
268
278
|
};
|
|
269
279
|
}
|
|
270
280
|
|
|
271
|
-
pub fn routeCanvasWidgetDragInput(self: *
|
|
281
|
+
pub fn routeCanvasWidgetDragInput(self: *Runtime, input_event: GpuSurfaceInputEvent, output: []canvas.WidgetEventRouteEntry) anyerror!?CanvasWidgetDragEvent {
|
|
272
282
|
try validateRuntimeViewParent(self, input_event.window_id);
|
|
273
|
-
if (input_event.kind != .pointer_drag) return null;
|
|
274
283
|
try validateViewLabel(input_event.label);
|
|
275
284
|
const index = runtimeFindViewIndex(self, input_event.window_id, input_event.label) orelse return error.ViewNotFound;
|
|
276
285
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
277
|
-
const
|
|
286
|
+
const previous_render_state = self.views[index].canvasWidgetRenderState();
|
|
287
|
+
|
|
288
|
+
if (input_event.kind == .pointer_down) {
|
|
289
|
+
// A live drag belongs to the pointer that crossed slop. A
|
|
290
|
+
// second contact may still run the ordinary pointer pipeline,
|
|
291
|
+
// but it cannot silently erase the first contact's preview or
|
|
292
|
+
// strand the app after its phase-0 Msg.
|
|
293
|
+
if (self.views[index].canvas_widget_drag_source_id != 0) return null;
|
|
294
|
+
self.views[index].canvas_widget_drag_source_id = 0;
|
|
295
|
+
self.views[index].canvas_widget_drag_source_attached = false;
|
|
296
|
+
self.views[index].canvas_widget_drag_pointer_id = input_event.pointer_id;
|
|
297
|
+
self.views[index].canvas_widget_drag_start_point = geometry.PointF.init(input_event.x, input_event.y);
|
|
298
|
+
self.views[index].canvas_widget_drag_source_origin = .{};
|
|
299
|
+
self.views[index].canvas_widget_drag_delta = .{};
|
|
300
|
+
self.views[index].canvas_widget_drag_source_hit = null;
|
|
301
|
+
self.views[index].canvas_widget_drag_route_len = 0;
|
|
302
|
+
self.views[index].canvas_widget_drag_layout_motion_armed = false;
|
|
303
|
+
self.views[index].canvas_widget_drag_landing_source_id = 0;
|
|
304
|
+
self.views[index].canvas_widget_drag_landing_origin = .{};
|
|
305
|
+
const next_render_state = self.views[index].canvasWidgetRenderState();
|
|
306
|
+
if (!canvasWidgetRenderStatesEqual(previous_render_state, next_render_state)) {
|
|
307
|
+
try invalidateForCanvasWidgetRenderStateChange(self, index, previous_render_state, next_render_state);
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
if (input_event.kind != .pointer_drag and input_event.kind != .pointer_up and input_event.kind != .pointer_cancel) return null;
|
|
312
|
+
// Pointer capture is per sequence. An unrelated touch/pen/mouse
|
|
313
|
+
// edge must not move or terminate the candidate/live drag.
|
|
314
|
+
if (input_event.pointer_id != self.views[index].canvas_widget_drag_pointer_id) return null;
|
|
315
|
+
|
|
316
|
+
const active_source = self.views[index].canvas_widget_drag_source_id;
|
|
317
|
+
// A release/cancel belongs to the drag channel only after motion
|
|
318
|
+
// crossed the slop and installed an active source. Until then it
|
|
319
|
+
// is the terminal edge of an ordinary click (or an abandoned
|
|
320
|
+
// press), so it must not arm a landing from the zero origin.
|
|
321
|
+
if (active_source == 0 and input_event.kind != .pointer_drag) {
|
|
322
|
+
self.views[index].canvas_widget_drag_pointer_id = 0;
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
const candidate_source = if (active_source != 0) active_source else self.views[index].canvas_widget_pressed_id;
|
|
326
|
+
if (candidate_source == 0) return null;
|
|
327
|
+
|
|
328
|
+
const point = geometry.PointF.init(input_event.x, input_event.y);
|
|
329
|
+
const phase: canvas.WidgetDragPhase = switch (input_event.kind) {
|
|
330
|
+
.pointer_drag => .change,
|
|
331
|
+
.pointer_up => .end,
|
|
332
|
+
.pointer_cancel => .cancel,
|
|
333
|
+
else => unreachable,
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
var drag = canvas.WidgetDragEvent{
|
|
337
|
+
.source_id = candidate_source,
|
|
338
|
+
.phase = phase,
|
|
339
|
+
.point = point,
|
|
340
|
+
.delta = geometry.OffsetF.init(
|
|
341
|
+
point.x - self.views[index].canvas_widget_drag_start_point.x,
|
|
342
|
+
point.y - self.views[index].canvas_widget_drag_start_point.y,
|
|
343
|
+
),
|
|
344
|
+
};
|
|
345
|
+
const route = try self.views[index].widgetLayoutTree().routeDragEvent(drag, output);
|
|
346
|
+
if (route.target == null) {
|
|
347
|
+
// A source removed, hidden, or disabled after a live change
|
|
348
|
+
// still owes the consumer one terminal phase. Its last valid
|
|
349
|
+
// hit/route are POD snapshots owned by the view, so they stay
|
|
350
|
+
// usable after the retained layout was replaced.
|
|
351
|
+
const captured_source = self.views[index].canvas_widget_drag_source_hit;
|
|
352
|
+
const captured_route = self.views[index].canvas_widget_drag_route_entries[0..self.views[index].canvas_widget_drag_route_len];
|
|
353
|
+
self.views[index].canvas_widget_drag_source_id = 0;
|
|
354
|
+
self.views[index].canvas_widget_drag_source_attached = false;
|
|
355
|
+
self.views[index].canvas_widget_drag_pointer_id = 0;
|
|
356
|
+
self.views[index].canvas_widget_drag_source_origin = .{};
|
|
357
|
+
self.views[index].canvas_widget_drag_delta = .{};
|
|
358
|
+
self.views[index].canvas_widget_drag_source_hit = null;
|
|
359
|
+
self.views[index].canvas_widget_drag_route_len = 0;
|
|
360
|
+
if (active_source != 0) self.views[index].canvas_widget_pressed_id = 0;
|
|
361
|
+
self.views[index].canvas_widget_drag_landing_source_id = 0;
|
|
362
|
+
self.views[index].canvas_widget_drag_landing_origin = .{};
|
|
363
|
+
const next_render_state = self.views[index].canvasWidgetRenderState();
|
|
364
|
+
if (!canvasWidgetRenderStatesEqual(previous_render_state, next_render_state)) {
|
|
365
|
+
try invalidateForCanvasWidgetRenderStateChange(self, index, previous_render_state, next_render_state);
|
|
366
|
+
}
|
|
367
|
+
if (active_source != 0 and captured_source != null) {
|
|
368
|
+
drag.source_id = captured_source.?.id;
|
|
369
|
+
drag.phase = .cancel;
|
|
370
|
+
return .{
|
|
371
|
+
.window_id = input_event.window_id,
|
|
372
|
+
.view_label = self.views[index].label,
|
|
373
|
+
.drag = drag,
|
|
374
|
+
.source = captured_source,
|
|
375
|
+
.route = captured_route,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
drag.source_id = route.target.?.id;
|
|
381
|
+
// Keep sub-slop motion on the low-level channel so draggable text
|
|
382
|
+
// still owns its selection gesture and existing observers retain
|
|
383
|
+
// pointer-drag fidelity. Do not promote it into runtime drag state:
|
|
384
|
+
// UiApp filters these change messages, and a matching release
|
|
385
|
+
// remains a press because no active source was installed.
|
|
386
|
+
if (active_source == 0 and !canvasWidgetDragCrossedSlop(drag.delta)) {
|
|
387
|
+
return .{
|
|
388
|
+
.window_id = input_event.window_id,
|
|
389
|
+
.view_label = self.views[index].label,
|
|
390
|
+
.drag = drag,
|
|
391
|
+
.source = route.target,
|
|
392
|
+
.route = route.entries,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
self.views[index].canvas_widget_drag_source_hit = route.target;
|
|
396
|
+
self.views[index].canvas_widget_drag_route_len = @min(route.entries.len, self.views[index].canvas_widget_drag_route_entries.len);
|
|
397
|
+
@memcpy(
|
|
398
|
+
self.views[index].canvas_widget_drag_route_entries[0..self.views[index].canvas_widget_drag_route_len],
|
|
399
|
+
route.entries[0..self.views[index].canvas_widget_drag_route_len],
|
|
400
|
+
);
|
|
401
|
+
// The app's Msg may rebuild into a different insertion pose.
|
|
402
|
+
// Arm exactly that adoption for FLIP motion, including terminal
|
|
403
|
+
// phases where the source itself moves into (or back from) the
|
|
404
|
+
// reserved slot.
|
|
405
|
+
self.views[index].canvas_widget_drag_layout_motion_armed = true;
|
|
406
|
+
if (phase == .change) {
|
|
407
|
+
self.views[index].canvas_widget_drag_landing_source_id = 0;
|
|
408
|
+
self.views[index].canvas_widget_drag_landing_origin = .{};
|
|
409
|
+
if (active_source == 0) {
|
|
410
|
+
const source_bounds = route.target.?.bounds.normalized();
|
|
411
|
+
self.views[index].canvas_widget_drag_source_origin = geometry.PointF.init(source_bounds.x, source_bounds.y);
|
|
412
|
+
}
|
|
413
|
+
self.views[index].canvas_widget_drag_source_id = drag.source_id;
|
|
414
|
+
self.views[index].canvas_widget_drag_source_attached = true;
|
|
415
|
+
self.views[index].canvas_widget_drag_delta = drag.delta;
|
|
416
|
+
} else {
|
|
417
|
+
const source_origin = self.views[index].canvas_widget_drag_source_origin;
|
|
418
|
+
self.views[index].canvas_widget_drag_landing_source_id = drag.source_id;
|
|
419
|
+
self.views[index].canvas_widget_drag_landing_origin = geometry.PointF.init(
|
|
420
|
+
source_origin.x + drag.delta.dx,
|
|
421
|
+
source_origin.y + drag.delta.dy,
|
|
422
|
+
);
|
|
423
|
+
self.views[index].canvas_widget_drag_source_id = 0;
|
|
424
|
+
self.views[index].canvas_widget_drag_source_attached = false;
|
|
425
|
+
self.views[index].canvas_widget_drag_pointer_id = 0;
|
|
426
|
+
self.views[index].canvas_widget_drag_source_origin = .{};
|
|
427
|
+
self.views[index].canvas_widget_drag_delta = .{};
|
|
428
|
+
self.views[index].canvas_widget_drag_source_hit = null;
|
|
429
|
+
self.views[index].canvas_widget_drag_route_len = 0;
|
|
430
|
+
}
|
|
431
|
+
const next_render_state = self.views[index].canvasWidgetRenderState();
|
|
432
|
+
if (!canvasWidgetRenderStatesEqual(previous_render_state, next_render_state)) {
|
|
433
|
+
try invalidateForCanvasWidgetRenderStateChange(self, index, previous_render_state, next_render_state);
|
|
434
|
+
}
|
|
435
|
+
return .{
|
|
436
|
+
.window_id = input_event.window_id,
|
|
437
|
+
.view_label = self.views[index].label,
|
|
438
|
+
.drag = drag,
|
|
439
|
+
.source = route.target,
|
|
440
|
+
.route = route.entries,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/// Plain Escape owns an active widget drag before the ordinary
|
|
445
|
+
/// keyboard pipeline can dismiss a surface or route the key. The
|
|
446
|
+
/// cancel carries the last pointer geometry, clears the physical
|
|
447
|
+
/// press latch so later motion/release cannot revive the gesture,
|
|
448
|
+
/// and hands the floating origin to the normal landing FLIP. The
|
|
449
|
+
/// app's phase-2 rebuild can therefore restore the source slot while
|
|
450
|
+
/// the card under the pointer eases back into it.
|
|
451
|
+
pub fn routeCanvasWidgetDragCancelFromKeyboardInput(self: *Runtime, input_event: GpuSurfaceInputEvent, output: []canvas.WidgetEventRouteEntry) anyerror!?CanvasWidgetDragEvent {
|
|
452
|
+
if (input_event.kind != .key_down or !canvasWidgetEscapeKey(input_event.key)) return null;
|
|
453
|
+
const modifiers = canvasWidgetKeyboardModifiers(input_event.modifiers);
|
|
454
|
+
if (modifiers.shift or modifiers.hasNavigationModifier()) return null;
|
|
455
|
+
|
|
456
|
+
try validateRuntimeViewParent(self, input_event.window_id);
|
|
457
|
+
try validateViewLabel(input_event.label);
|
|
458
|
+
const index = runtimeFindViewIndex(self, input_event.window_id, input_event.label) orelse return error.ViewNotFound;
|
|
459
|
+
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
460
|
+
const source_id = self.views[index].canvas_widget_drag_source_id;
|
|
278
461
|
if (source_id == 0) return null;
|
|
279
462
|
|
|
280
|
-
const
|
|
463
|
+
const previous_render_state = self.views[index].canvasWidgetRenderState();
|
|
464
|
+
const delta = self.views[index].canvas_widget_drag_delta;
|
|
465
|
+
const point = geometry.PointF.init(
|
|
466
|
+
self.views[index].canvas_widget_drag_start_point.x + delta.dx,
|
|
467
|
+
self.views[index].canvas_widget_drag_start_point.y + delta.dy,
|
|
468
|
+
);
|
|
469
|
+
var drag = canvas.WidgetDragEvent{
|
|
281
470
|
.source_id = source_id,
|
|
282
|
-
.
|
|
283
|
-
.
|
|
471
|
+
.phase = .cancel,
|
|
472
|
+
.point = point,
|
|
473
|
+
.delta = delta,
|
|
284
474
|
};
|
|
285
475
|
const route = try self.views[index].widgetLayoutTree().routeDragEvent(drag, output);
|
|
286
|
-
if (route.target == null)
|
|
476
|
+
if (route.target == null) {
|
|
477
|
+
const captured_source = self.views[index].canvas_widget_drag_source_hit;
|
|
478
|
+
const captured_route = self.views[index].canvas_widget_drag_route_entries[0..self.views[index].canvas_widget_drag_route_len];
|
|
479
|
+
self.views[index].canvas_widget_drag_source_id = 0;
|
|
480
|
+
self.views[index].canvas_widget_drag_source_attached = false;
|
|
481
|
+
self.views[index].canvas_widget_drag_pointer_id = 0;
|
|
482
|
+
self.views[index].canvas_widget_drag_source_origin = .{};
|
|
483
|
+
self.views[index].canvas_widget_drag_delta = .{};
|
|
484
|
+
self.views[index].canvas_widget_drag_source_hit = null;
|
|
485
|
+
self.views[index].canvas_widget_drag_route_len = 0;
|
|
486
|
+
self.views[index].canvas_widget_pressed_id = 0;
|
|
487
|
+
self.views[index].canvas_widget_drag_landing_source_id = 0;
|
|
488
|
+
self.views[index].canvas_widget_drag_landing_origin = .{};
|
|
489
|
+
const next_render_state = self.views[index].canvasWidgetRenderState();
|
|
490
|
+
if (!canvasWidgetRenderStatesEqual(previous_render_state, next_render_state)) {
|
|
491
|
+
try invalidateForCanvasWidgetRenderStateChange(self, index, previous_render_state, next_render_state);
|
|
492
|
+
}
|
|
493
|
+
if (captured_source) |source| {
|
|
494
|
+
drag.source_id = source.id;
|
|
495
|
+
return .{
|
|
496
|
+
.window_id = input_event.window_id,
|
|
497
|
+
.view_label = self.views[index].label,
|
|
498
|
+
.drag = drag,
|
|
499
|
+
.source = source,
|
|
500
|
+
.route = captured_route,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
drag.source_id = route.target.?.id;
|
|
507
|
+
const source_origin = self.views[index].canvas_widget_drag_source_origin;
|
|
508
|
+
self.views[index].canvas_widget_drag_layout_motion_armed = true;
|
|
509
|
+
self.views[index].canvas_widget_drag_landing_source_id = drag.source_id;
|
|
510
|
+
self.views[index].canvas_widget_drag_landing_origin = geometry.PointF.init(
|
|
511
|
+
source_origin.x + delta.dx,
|
|
512
|
+
source_origin.y + delta.dy,
|
|
513
|
+
);
|
|
514
|
+
self.views[index].canvas_widget_drag_source_id = 0;
|
|
515
|
+
self.views[index].canvas_widget_drag_source_attached = false;
|
|
516
|
+
self.views[index].canvas_widget_drag_pointer_id = 0;
|
|
517
|
+
self.views[index].canvas_widget_drag_source_origin = .{};
|
|
518
|
+
self.views[index].canvas_widget_drag_delta = .{};
|
|
519
|
+
self.views[index].canvas_widget_drag_source_hit = null;
|
|
520
|
+
self.views[index].canvas_widget_drag_route_len = 0;
|
|
521
|
+
self.views[index].canvas_widget_pressed_id = 0;
|
|
522
|
+
const next_render_state = self.views[index].canvasWidgetRenderState();
|
|
523
|
+
if (!canvasWidgetRenderStatesEqual(previous_render_state, next_render_state)) {
|
|
524
|
+
try invalidateForCanvasWidgetRenderStateChange(self, index, previous_render_state, next_render_state);
|
|
525
|
+
}
|
|
287
526
|
return .{
|
|
288
527
|
.window_id = input_event.window_id,
|
|
289
528
|
.view_label = self.views[index].label,
|
|
@@ -1817,6 +2056,10 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1817
2056
|
.focus_visible_id = if (previous.focus_visible_id) |id| if (next_focused_id != null and next_focused_id.? == id and layout.focusTargetById(id) != null) id else null else null,
|
|
1818
2057
|
.hovered_id = if (previous.hovered_id) |id| if (canvasWidgetInteractionTargetExists(layout, id)) id else null else null,
|
|
1819
2058
|
.pressed_id = if (previous.pressed_id) |id| if (canvasWidgetInteractionTargetExists(layout, id)) id else null else null,
|
|
2059
|
+
.drag_preview_id = if (previous.drag_preview_id) |id| if (canvasWidgetInteractionTargetExists(layout, id)) id else null else null,
|
|
2060
|
+
.drag_preview_origin = if (previous.drag_preview_id) |id| if (canvasWidgetInteractionTargetExists(layout, id)) previous.drag_preview_origin else null else null,
|
|
2061
|
+
.drag_preview_offset = previous.drag_preview_offset,
|
|
2062
|
+
.layout_motions = previous.layout_motions,
|
|
1820
2063
|
// The hover point rides with the hovered widget: it
|
|
1821
2064
|
// survives exactly when the hover survives.
|
|
1822
2065
|
.hover_point = if (previous.hovered_id) |id| if (canvasWidgetInteractionTargetExists(layout, id)) previous.hover_point else null else null,
|
|
@@ -1829,6 +2072,10 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1829
2072
|
a.focus_visible_id == b.focus_visible_id and
|
|
1830
2073
|
a.hovered_id == b.hovered_id and
|
|
1831
2074
|
a.pressed_id == b.pressed_id and
|
|
2075
|
+
a.drag_preview_id == b.drag_preview_id and
|
|
2076
|
+
canvasOptionalPointsEqual(a.drag_preview_origin, b.drag_preview_origin) and
|
|
2077
|
+
a.drag_preview_offset.dx == b.drag_preview_offset.dx and
|
|
2078
|
+
a.drag_preview_offset.dy == b.drag_preview_offset.dy and
|
|
1832
2079
|
canvasOptionalPointsEqual(a.hover_point, b.hover_point);
|
|
1833
2080
|
}
|
|
1834
2081
|
|
|
@@ -169,6 +169,10 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
169
169
|
// where it can restore the previous pose onto the freshly
|
|
170
170
|
// retained nodes.
|
|
171
171
|
const disclosure_plan = planCanvasWidgetDisclosureTween(self, index, previous_layout, reconciled_layout);
|
|
172
|
+
// Drag reflow uses the same two-pose planning seam, but keeps
|
|
173
|
+
// the adopted layout at its truthful final geometry and records
|
|
174
|
+
// presentation-only offsets for keyed draggable widgets.
|
|
175
|
+
const drag_layout_motion_plan = planCanvasWidgetDragLayoutMotion(self, index, previous_layout, reconciled_layout);
|
|
172
176
|
const previous_cursor = self.views[index].canvas_widget_cursor;
|
|
173
177
|
const previous_widget_revision = self.views[index].widget_revision;
|
|
174
178
|
// The adoption witness (`canvas_widget_layout_adoptions`)
|
|
@@ -216,6 +220,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
216
220
|
// the user was looking at, and the tween walks it to the
|
|
217
221
|
// declared pose one presented frame at a time.
|
|
218
222
|
try applyCanvasWidgetDisclosureTweenPlan(self, index, disclosure_plan);
|
|
223
|
+
const drag_layout_motion_changed = applyCanvasWidgetDragLayoutMotionPlan(self, index, drag_layout_motion_plan);
|
|
219
224
|
// Re-hit-test the stationary pointer against the ADOPTED
|
|
220
225
|
// tree, after every pose restore above settles the frames
|
|
221
226
|
// the user actually sees and BEFORE the display refresh
|
|
@@ -227,7 +232,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
227
232
|
// point-blind scroll paths do.
|
|
228
233
|
try CanvasWidgetEventMethods(Runtime).reconcileCanvasWidgetInteractionAfterLayoutAdoption(self, index, adoption_tooltip_bindings);
|
|
229
234
|
const requested_frame = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
|
|
230
|
-
if ((layout_dirty or widget_revision_changed) and !requested_frame) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
|
|
235
|
+
if ((layout_dirty or widget_revision_changed or drag_layout_motion_changed) and !requested_frame) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
|
|
231
236
|
return self.views[index].info();
|
|
232
237
|
}
|
|
233
238
|
|
|
@@ -504,6 +509,94 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
504
509
|
/// - `none`: nothing armed, nothing to arm.
|
|
505
510
|
const CanvasWidgetDisclosureAction = enum { none, arm, refresh, retire };
|
|
506
511
|
|
|
512
|
+
const CanvasWidgetDragLayoutMotionPlan = struct {
|
|
513
|
+
apply: bool = false,
|
|
514
|
+
motions: [canvas_limits.max_canvas_widget_drag_layout_motions_per_view]canvas.WidgetLayoutMotion = undefined,
|
|
515
|
+
motion_count: usize = 0,
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/// FLIP planning for drag-driven list/board reflow. Each keyed
|
|
519
|
+
/// draggable begins at its CURRENTLY PRESENTED origin (including an
|
|
520
|
+
/// in-flight offset) and eases toward the newly declared frame. New
|
|
521
|
+
/// placeholders have no previous pose and therefore appear as the
|
|
522
|
+
/// honest blank destination immediately.
|
|
523
|
+
fn planCanvasWidgetDragLayoutMotion(self: *Runtime, view_index: usize, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree) CanvasWidgetDragLayoutMotionPlan {
|
|
524
|
+
const view = &self.views[view_index];
|
|
525
|
+
var plan = CanvasWidgetDragLayoutMotionPlan{};
|
|
526
|
+
if (!view.canvas_widget_drag_layout_motion_armed) return plan;
|
|
527
|
+
plan.apply = true;
|
|
528
|
+
|
|
529
|
+
const duration_ms = view.widget_tokens.motion.durationMs(.normal);
|
|
530
|
+
if (self.appearance.reduce_motion or duration_ms == 0) return plan;
|
|
531
|
+
|
|
532
|
+
for (next.nodes) |next_node| {
|
|
533
|
+
const id = next_node.widget.id;
|
|
534
|
+
if (id == 0 or !next_node.widget.semantics.actions.drag) continue;
|
|
535
|
+
const previous_node = previous.findById(id) orelse continue;
|
|
536
|
+
const old_motion = findCanvasWidgetDragLayoutMotion(view.canvas_widget_drag_layout_motions[0..view.canvas_widget_drag_layout_motion_count], id);
|
|
537
|
+
const previous_frame = previous_node.frame.normalized();
|
|
538
|
+
const next_frame = next_node.frame.normalized();
|
|
539
|
+
const old_offset = if (old_motion) |motion| motion.offset else geometry.OffsetF{};
|
|
540
|
+
const landing_origin = if (view.canvas_widget_drag_landing_source_id == id)
|
|
541
|
+
view.canvas_widget_drag_landing_origin
|
|
542
|
+
else
|
|
543
|
+
geometry.PointF.init(previous_frame.x + old_offset.dx, previous_frame.y + old_offset.dy);
|
|
544
|
+
const offset = geometry.OffsetF.init(
|
|
545
|
+
landing_origin.x - next_frame.x,
|
|
546
|
+
landing_origin.y - next_frame.y,
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
// An unchanged target keeps its existing clock and pose;
|
|
550
|
+
// changing the insertion point retargets from the exact
|
|
551
|
+
// pixels currently on screen, with no pop between gestures.
|
|
552
|
+
const target_unchanged = view.canvas_widget_drag_landing_source_id != id and previous_frame.x == next_frame.x and previous_frame.y == next_frame.y;
|
|
553
|
+
if (target_unchanged) {
|
|
554
|
+
if (old_motion) |motion| {
|
|
555
|
+
if (plan.motion_count >= plan.motions.len) break;
|
|
556
|
+
plan.motions[plan.motion_count] = motion;
|
|
557
|
+
plan.motion_count += 1;
|
|
558
|
+
}
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (offset.dx == 0 and offset.dy == 0) continue;
|
|
562
|
+
if (plan.motion_count >= plan.motions.len) break;
|
|
563
|
+
plan.motions[plan.motion_count] = .{
|
|
564
|
+
.id = id,
|
|
565
|
+
.from_offset = offset,
|
|
566
|
+
.offset = offset,
|
|
567
|
+
.duration_ms = duration_ms,
|
|
568
|
+
.easing = .emphasized,
|
|
569
|
+
.spring = view.widget_tokens.motion.spring,
|
|
570
|
+
};
|
|
571
|
+
plan.motion_count += 1;
|
|
572
|
+
}
|
|
573
|
+
return plan;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
fn findCanvasWidgetDragLayoutMotion(motions: []const canvas.WidgetLayoutMotion, id: canvas.ObjectId) ?canvas.WidgetLayoutMotion {
|
|
577
|
+
for (motions) |motion| {
|
|
578
|
+
if (motion.id == id) return motion;
|
|
579
|
+
}
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/// Applies only after the fallible retained-tree copy succeeds, so a
|
|
584
|
+
/// rejected adoption cannot consume the drag arm or mutate the pose
|
|
585
|
+
/// of the still-current tree.
|
|
586
|
+
fn applyCanvasWidgetDragLayoutMotionPlan(self: *Runtime, view_index: usize, plan: CanvasWidgetDragLayoutMotionPlan) bool {
|
|
587
|
+
if (!plan.apply) return false;
|
|
588
|
+
const view = &self.views[view_index];
|
|
589
|
+
view.canvas_widget_drag_layout_motion_armed = false;
|
|
590
|
+
view.canvas_widget_drag_landing_source_id = 0;
|
|
591
|
+
view.canvas_widget_drag_landing_origin = .{};
|
|
592
|
+
const previous_count = view.canvas_widget_drag_layout_motion_count;
|
|
593
|
+
if (plan.motion_count > 0) {
|
|
594
|
+
@memcpy(view.canvas_widget_drag_layout_motions[0..plan.motion_count], plan.motions[0..plan.motion_count]);
|
|
595
|
+
}
|
|
596
|
+
view.canvas_widget_drag_layout_motion_count = plan.motion_count;
|
|
597
|
+
return previous_count > 0 or plan.motion_count > 0;
|
|
598
|
+
}
|
|
599
|
+
|
|
507
600
|
const CanvasWidgetDisclosurePlan = struct {
|
|
508
601
|
action: CanvasWidgetDisclosureAction = .none,
|
|
509
602
|
duration_ms: u32 = 0,
|
|
@@ -737,6 +830,35 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
737
830
|
if (!done) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, view_index);
|
|
738
831
|
}
|
|
739
832
|
|
|
833
|
+
/// Advances presentation-only drag reflow. The retained layout is
|
|
834
|
+
/// already final, so each frame only changes renderer transforms;
|
|
835
|
+
/// hit testing, accessibility, and the eventual zero-offset settle
|
|
836
|
+
/// always agree with the model.
|
|
837
|
+
pub fn advanceCanvasWidgetDragLayoutMotionForFrame(self: *Runtime, view_index: usize, timestamp_ns: u64) anyerror!void {
|
|
838
|
+
if (view_index >= self.view_count) return;
|
|
839
|
+
if (self.views[view_index].kind != .gpu_surface) return;
|
|
840
|
+
const view = &self.views[view_index];
|
|
841
|
+
if (view.canvas_widget_drag_layout_motion_count == 0) return;
|
|
842
|
+
|
|
843
|
+
var write_index: usize = 0;
|
|
844
|
+
for (view.canvas_widget_drag_layout_motions[0..view.canvas_widget_drag_layout_motion_count]) |motion_value| {
|
|
845
|
+
if (view.canvasWidgetNodeIndexById(motion_value.id) == null) continue;
|
|
846
|
+
var motion = motion_value;
|
|
847
|
+
if (motion.start_ns == 0 or timestamp_ns < motion.start_ns) motion.start_ns = timestamp_ns;
|
|
848
|
+
const progress = canvas.layoutTweenProgress(motion.easing, motion.spring, motion.start_ns, motion.duration_ms, timestamp_ns);
|
|
849
|
+
if (progress >= 1) continue;
|
|
850
|
+
motion.offset = geometry.OffsetF.init(
|
|
851
|
+
motion.from_offset.dx * (1 - progress),
|
|
852
|
+
motion.from_offset.dy * (1 - progress),
|
|
853
|
+
);
|
|
854
|
+
view.canvas_widget_drag_layout_motions[write_index] = motion;
|
|
855
|
+
write_index += 1;
|
|
856
|
+
}
|
|
857
|
+
view.canvas_widget_drag_layout_motion_count = write_index;
|
|
858
|
+
_ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwnedSkippingAccessibility(self, view_index);
|
|
859
|
+
if (write_index > 0) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, view_index);
|
|
860
|
+
}
|
|
861
|
+
|
|
740
862
|
/// One presented frame's worth of layout-tween motion for a
|
|
741
863
|
/// view, called from the frame event dispatch (the kinetic
|
|
742
864
|
/// scroll's sibling). Each active tween samples its eased
|
package/src/runtime/core.zig
CHANGED
|
@@ -330,6 +330,11 @@ pub const Runtime = struct {
|
|
|
330
330
|
/// provenance table exists (builder-only apps, release engines).
|
|
331
331
|
automation_provenance_published: bool = false,
|
|
332
332
|
widget_event_route_entries: [canvas.max_widget_depth * 2]canvas.WidgetEventRouteEntry = undefined,
|
|
333
|
+
/// Pointer and drag events from one physical input are dispatched
|
|
334
|
+
/// separately, so both routed paths must stay live until their dispatch.
|
|
335
|
+
/// In particular, the drag source can be an ancestor of the raw pointer
|
|
336
|
+
/// target and therefore has a different capture/target/bubble route.
|
|
337
|
+
widget_drag_event_route_entries: [canvas.max_widget_depth * 2]canvas.WidgetEventRouteEntry = undefined,
|
|
333
338
|
/// The in-flight IME preedit for the TARGETLESS text path (an app
|
|
334
339
|
/// consuming committed text with no focused text widget — a terminal
|
|
335
340
|
/// grid): updated by `ime_set_composition`, delivered as committed
|
|
@@ -933,6 +938,7 @@ pub const Runtime = struct {
|
|
|
933
938
|
pub const startCanvasWidgetLayoutTween = CanvasWidgetStateMethods.startCanvasWidgetLayoutTween;
|
|
934
939
|
pub const advanceCanvasWidgetLayoutTweensForFrame = CanvasWidgetStateMethods.advanceCanvasWidgetLayoutTweensForFrame;
|
|
935
940
|
pub const advanceCanvasWidgetDisclosureTweenForFrame = CanvasWidgetStateMethods.advanceCanvasWidgetDisclosureTweenForFrame;
|
|
941
|
+
pub const advanceCanvasWidgetDragLayoutMotionForFrame = CanvasWidgetStateMethods.advanceCanvasWidgetDragLayoutMotionForFrame;
|
|
936
942
|
pub const setCanvasWidgetDesignTokens = CanvasWidgetStateMethods.setCanvasWidgetDesignTokens;
|
|
937
943
|
pub const canvasWidgetDesignTokens = CanvasWidgetStateMethods.canvasWidgetDesignTokens;
|
|
938
944
|
pub const canvasWidgetTextGeometry = CanvasWidgetStateMethods.canvasWidgetTextGeometry;
|
package/src/runtime/effects.zig
CHANGED
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
//! operation, one terminal Msg with an explicit outcome
|
|
14
14
|
//! (ok / not_found / io_failed / truncated / rejected / cancelled) —
|
|
15
15
|
//! TEA-friendly persistence without smuggling an `Io` handle into
|
|
16
|
-
//! `update`.
|
|
16
|
+
//! `update`. Desktop notifications (`showNotification`) are the
|
|
17
|
+
//! fire-and-forget exception: the OS owns delivery after the one
|
|
18
|
+
//! loop-thread platform call, so there is no meaningful terminal Msg.
|
|
19
|
+
//! Invalid requests and unavailable services fail closed; fake execution
|
|
20
|
+
//! and session replay never emit a real notification. Clipboard effects
|
|
21
|
+
//! (`writeClipboard`/`readClipboard`) keep
|
|
17
22
|
//! the same shape over the platform pasteboard — the seam the
|
|
18
23
|
//! runtime's cmd+C copy uses — executed synchronously on the loop
|
|
19
24
|
//! thread (pasteboards are main-thread services), so apps stop
|
|
@@ -67,6 +72,7 @@ const builtin = @import("builtin");
|
|
|
67
72
|
const canvas = @import("canvas");
|
|
68
73
|
const canvas_limits = @import("canvas_limits.zig");
|
|
69
74
|
const platform = @import("../platform/root.zig");
|
|
75
|
+
const validation = @import("validation.zig");
|
|
70
76
|
const runtime_clock = @import("clock.zig");
|
|
71
77
|
const pty_transport = @import("pty.zig");
|
|
72
78
|
|
|
@@ -7150,6 +7156,26 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
7150
7156
|
pty_transport.nudge(slot.wake_pipe[1]);
|
|
7151
7157
|
}
|
|
7152
7158
|
|
|
7159
|
+
/// Ask the desktop host to show a system notification. This is
|
|
7160
|
+
/// deliberately fire-and-forget: platform acceptance does not
|
|
7161
|
+
/// mean the OS displayed it (Focus / Do Not Disturb and user
|
|
7162
|
+
/// notification settings remain authoritative), so no success
|
|
7163
|
+
/// Msg would be truthful. Invalid or over-bound fields, an
|
|
7164
|
+
/// unavailable notification service, and a host refusal all
|
|
7165
|
+
/// fail closed.
|
|
7166
|
+
///
|
|
7167
|
+
/// The call runs synchronously on the loop thread, where every
|
|
7168
|
+
/// supported desktop notification API expects to be entered.
|
|
7169
|
+
/// Fake execution and session replay suppress the platform call
|
|
7170
|
+
/// so tests stay hermetic and a replay never repeats an external
|
|
7171
|
+
/// user-visible side effect.
|
|
7172
|
+
pub fn showNotification(self: *Self, options: platform.NotificationOptions) void {
|
|
7173
|
+
if (self.executor == .fake or self.replay) return;
|
|
7174
|
+
validation.validateNotificationOptions(options) catch return;
|
|
7175
|
+
const services = self.services orelse return;
|
|
7176
|
+
services.showNotification(options) catch {};
|
|
7177
|
+
}
|
|
7178
|
+
|
|
7153
7179
|
/// Put text on the system clipboard through the platform
|
|
7154
7180
|
/// pasteboard — the same seam the runtime's cmd+C copy uses —
|
|
7155
7181
|
/// and deliver exactly one terminal Msg with an explicit
|
|
@@ -12860,6 +12886,15 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
12860
12886
|
try body.writer.writeAll(slot.fetchPayload());
|
|
12861
12887
|
try body.end();
|
|
12862
12888
|
try request.connection.?.flush();
|
|
12889
|
+
} else if (slot.method.requestHasBody()) {
|
|
12890
|
+
// POST, PUT and PATCH carry a body by definition, so
|
|
12891
|
+
// `sendBodiless` asserts against them. A payload-free
|
|
12892
|
+
// request of one of those methods is still valid HTTP;
|
|
12893
|
+
// send an explicit zero-length body instead.
|
|
12894
|
+
request.transfer_encoding = .{ .content_length = 0 };
|
|
12895
|
+
var body = try request.sendBodyUnflushed(&.{});
|
|
12896
|
+
try body.end();
|
|
12897
|
+
try request.connection.?.flush();
|
|
12863
12898
|
} else {
|
|
12864
12899
|
try request.sendBodiless();
|
|
12865
12900
|
}
|
|
@@ -923,6 +923,27 @@ test "real fetch round-trips a POST payload through the echo route" {
|
|
|
923
923
|
try std.testing.expectEqualStrings("the payload rides in the fetch buffer", h.app_state.model.body());
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
+
test "real fetch sends a payload-free POST as an explicit zero-length body" {
|
|
927
|
+
var h = try Harness.create();
|
|
928
|
+
defer h.destroy();
|
|
929
|
+
const fixture = try Fixture.start(std.testing.allocator);
|
|
930
|
+
defer fixture.stop();
|
|
931
|
+
|
|
932
|
+
var url_buffer: [128]u8 = undefined;
|
|
933
|
+
test_url = fixture.url(&url_buffer, "/echo");
|
|
934
|
+
test_method = .POST;
|
|
935
|
+
test_headers = &.{};
|
|
936
|
+
test_payload = null;
|
|
937
|
+
test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
|
|
938
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
939
|
+
try waitForResponse(&h);
|
|
940
|
+
|
|
941
|
+
try std.testing.expectEqual(effects_mod.EffectFetchOutcome.ok, h.app_state.model.outcome.?);
|
|
942
|
+
try std.testing.expectEqual(@as(u16, 200), h.app_state.model.status);
|
|
943
|
+
try std.testing.expectEqual(@as(usize, 0), h.app_state.model.body_len);
|
|
944
|
+
try std.testing.expect(fixture.headContains("content-length: 0"));
|
|
945
|
+
}
|
|
946
|
+
|
|
926
947
|
test "real fetch preserves binary bodies byte for byte" {
|
|
927
948
|
var h = try Harness.create();
|
|
928
949
|
defer h.destroy();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//! Desktop-notification effect coverage: `fx.showNotification` reaches
|
|
2
|
+
//! the existing platform notification service on the loop thread, rejects
|
|
3
|
+
//! malformed input before dispatch, and stays inert under fake execution
|
|
4
|
+
//! and session replay so tests/replays never produce user-visible alerts.
|
|
5
|
+
|
|
6
|
+
const std = @import("std");
|
|
7
|
+
const platform = @import("../platform/root.zig");
|
|
8
|
+
const effects_mod = @import("effects.zig");
|
|
9
|
+
|
|
10
|
+
const Msg = enum { unused };
|
|
11
|
+
const TestEffects = effects_mod.Effects(Msg);
|
|
12
|
+
|
|
13
|
+
test "notification effect delivers validated fields to the platform service" {
|
|
14
|
+
var null_platform = platform.NullPlatform.init(.{});
|
|
15
|
+
var host = null_platform.platform();
|
|
16
|
+
var fx = TestEffects.init(std.testing.allocator);
|
|
17
|
+
defer fx.deinit();
|
|
18
|
+
fx.bindServices(&host.services);
|
|
19
|
+
|
|
20
|
+
fx.showNotification(.{
|
|
21
|
+
.title = "Build finished",
|
|
22
|
+
.subtitle = "native-sdk",
|
|
23
|
+
.body = "All checks passed.",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
try std.testing.expectEqual(@as(usize, 1), null_platform.notificationCount());
|
|
27
|
+
try std.testing.expectEqualStrings("Build finished", null_platform.lastNotificationTitle());
|
|
28
|
+
try std.testing.expectEqualStrings("native-sdk", null_platform.lastNotificationSubtitle());
|
|
29
|
+
try std.testing.expectEqualStrings("All checks passed.", null_platform.lastNotificationBody());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test "notification effect rejects malformed and over-bound requests" {
|
|
33
|
+
var null_platform = platform.NullPlatform.init(.{});
|
|
34
|
+
var host = null_platform.platform();
|
|
35
|
+
var fx = TestEffects.init(std.testing.allocator);
|
|
36
|
+
defer fx.deinit();
|
|
37
|
+
fx.bindServices(&host.services);
|
|
38
|
+
|
|
39
|
+
const long_title = [_]u8{'x'} ** (platform.max_notification_title_bytes + 1);
|
|
40
|
+
fx.showNotification(.{ .title = "" });
|
|
41
|
+
fx.showNotification(.{ .title = "bad\x00title" });
|
|
42
|
+
fx.showNotification(.{ .title = &long_title });
|
|
43
|
+
|
|
44
|
+
try std.testing.expectEqual(@as(usize, 0), null_platform.notificationCount());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test "notification effect is inert without a service and during fake execution or replay" {
|
|
48
|
+
var unbound = TestEffects.init(std.testing.allocator);
|
|
49
|
+
defer unbound.deinit();
|
|
50
|
+
unbound.showNotification(.{ .title = "No host" });
|
|
51
|
+
|
|
52
|
+
var null_platform = platform.NullPlatform.init(.{});
|
|
53
|
+
var host = null_platform.platform();
|
|
54
|
+
var fx = TestEffects.init(std.testing.allocator);
|
|
55
|
+
defer fx.deinit();
|
|
56
|
+
fx.bindServices(&host.services);
|
|
57
|
+
|
|
58
|
+
fx.executor = .fake;
|
|
59
|
+
fx.showNotification(.{ .title = "Fake" });
|
|
60
|
+
try std.testing.expectEqual(@as(usize, 0), null_platform.notificationCount());
|
|
61
|
+
|
|
62
|
+
fx.armReplay();
|
|
63
|
+
fx.showNotification(.{ .title = "Replay" });
|
|
64
|
+
try std.testing.expectEqual(@as(usize, 0), null_platform.notificationCount());
|
|
65
|
+
}
|