@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
|
@@ -398,6 +398,23 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
398
398
|
}
|
|
399
399
|
if (pane_count != 2) return self.failNode(node, markup.split_children_message);
|
|
400
400
|
}
|
|
401
|
+
// The image leaf's static shape, mirroring the validator and
|
|
402
|
+
// the compiled engine's compile error. Without its id binding
|
|
403
|
+
// the leaf can never draw - statically dead markup, refused
|
|
404
|
+
// here too so markup that skipped validation (hot reload)
|
|
405
|
+
// fails the build instead of silently rendering nothing. And
|
|
406
|
+
// it takes no children at all (icon's leaf policy): checked
|
|
407
|
+
// on the ORIGINAL node, so an extracted context-menu still
|
|
408
|
+
// counts as a child exactly like the validator's raw-node
|
|
409
|
+
// check.
|
|
410
|
+
if (kind == .image) {
|
|
411
|
+
if (node.attr("image") == null) {
|
|
412
|
+
return self.failNode(node, markup.image_missing_image_message);
|
|
413
|
+
}
|
|
414
|
+
if (node.children.len > 0) {
|
|
415
|
+
return self.failNode(node, markup.image_children_message);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
401
418
|
// The a11y lint's error half: an unnamed interactive control
|
|
402
419
|
// or a misused role ships a view a screen reader user cannot
|
|
403
420
|
// operate, so it fails the build like any other markup
|
|
@@ -1567,28 +1584,29 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1567
1584
|
};
|
|
1568
1585
|
}
|
|
1569
1586
|
|
|
1570
|
-
/// `image="{binding}"` on avatar: one binding
|
|
1571
|
-
/// `canvas.ImageId` the app registered at
|
|
1572
|
-
/// (`fx.
|
|
1573
|
-
///
|
|
1574
|
-
///
|
|
1575
|
-
///
|
|
1587
|
+
/// `image="{binding}"` on avatar and image: one binding
|
|
1588
|
+
/// producing a `u64` `canvas.ImageId` the app registered at
|
|
1589
|
+
/// runtime (`Cmd.imageLoad`, `fx.loadImage`,
|
|
1590
|
+
/// `fx.registerImageBytes`) — the id is model data, never a
|
|
1591
|
+
/// markup literal, and 0 draws nothing (an avatar keeps its
|
|
1592
|
+
/// initials fallback). The remaining image-bearing widget
|
|
1593
|
+
/// (icon-button) stays a Zig view.
|
|
1576
1594
|
fn applyImageAttr(self: *Self, scope: *Scope, node: markup.MarkupNode, options: *Ui.ElementOptions, attribute: markup.MarkupAttr) BuildError!void {
|
|
1577
|
-
if (!std.mem.eql(u8, node.name, "avatar")) {
|
|
1578
|
-
return self.failVoid(node, markup.
|
|
1595
|
+
if (!std.mem.eql(u8, node.name, "avatar") and !std.mem.eql(u8, node.name, "image")) {
|
|
1596
|
+
return self.failVoid(node, markup.image_binding_element_message);
|
|
1579
1597
|
}
|
|
1580
1598
|
const typed = markup.attrTyped(attribute);
|
|
1581
|
-
if (typed != .binding) return self.failVoid(node, markup.
|
|
1599
|
+
if (typed != .binding) return self.failVoid(node, markup.image_binding_message);
|
|
1582
1600
|
const value = try self.evalBinding(scope, node, typed.binding, true);
|
|
1583
1601
|
// Range-checked before the u64 cast: expression values are
|
|
1584
1602
|
// i64, so a signed model field (`image: i64 = -1`) can
|
|
1585
1603
|
// deliver a negative — the teaching failure, never a trap.
|
|
1586
1604
|
options.image = switch (value) {
|
|
1587
1605
|
.integer => |int| if (int < 0)
|
|
1588
|
-
return self.failVoid(node, markup.
|
|
1606
|
+
return self.failVoid(node, markup.image_binding_message)
|
|
1589
1607
|
else
|
|
1590
1608
|
@intCast(int),
|
|
1591
|
-
else => return self.failVoid(node, markup.
|
|
1609
|
+
else => return self.failVoid(node, markup.image_binding_message),
|
|
1592
1610
|
};
|
|
1593
1611
|
}
|
|
1594
1612
|
|
|
@@ -1322,10 +1322,10 @@ test "the registry's a11y name classes match the engine's control predicates" {
|
|
|
1322
1322
|
try testing.expect(canvas.widgetKindClaimsPress(kind));
|
|
1323
1323
|
}
|
|
1324
1324
|
// Image-class elements are announced under the image role:
|
|
1325
|
-
// avatar
|
|
1326
|
-
// label degrades but never blocks).
|
|
1325
|
+
// avatar, the media surface, and the image leaf (pictorial
|
|
1326
|
+
// content whose missing label degrades but never blocks).
|
|
1327
1327
|
if (entry.a11y_name == .image) {
|
|
1328
|
-
try testing.expect(kind == .avatar or kind == .media_surface);
|
|
1328
|
+
try testing.expect(kind == .avatar or kind == .media_surface or kind == .image);
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
@@ -1408,7 +1408,7 @@ test "the registry's takes-children predicate matches the interpreter's takes-ch
|
|
|
1408
1408
|
/// lowered through `Ui.inputGroup`), so no plain element maps to the
|
|
1409
1409
|
/// kind here — like chart, the bespoke builder is the channel.
|
|
1410
1410
|
const markup_excluded_widget_kinds = [_]canvas.WidgetKind{
|
|
1411
|
-
.
|
|
1411
|
+
.icon_button, .data_grid, .popover, .menu_surface, .segmented_control, .chart, .split_divider, .input_group,
|
|
1412
1412
|
};
|
|
1413
1413
|
|
|
1414
1414
|
fn kindExpressible(kind: canvas.WidgetKind) bool {
|
|
@@ -2457,23 +2457,23 @@ test "avatar image misuse fails the build with the teaching messages" {
|
|
|
2457
2457
|
.{
|
|
2458
2458
|
// A literal id is not model data.
|
|
2459
2459
|
.source = "<row>\n <avatar image=\"7\">CT</avatar>\n</row>",
|
|
2460
|
-
.message = canvas.ui_markup.
|
|
2460
|
+
.message = canvas.ui_markup.image_binding_message,
|
|
2461
2461
|
},
|
|
2462
2462
|
.{
|
|
2463
2463
|
// The binding must produce an integer ImageId (user_name is text).
|
|
2464
2464
|
.source = "<row>\n <avatar image=\"{user_name}\">CT</avatar>\n</row>",
|
|
2465
|
-
.message = canvas.ui_markup.
|
|
2465
|
+
.message = canvas.ui_markup.image_binding_message,
|
|
2466
2466
|
},
|
|
2467
2467
|
.{
|
|
2468
2468
|
// A negative integer can never be a u64 ImageId: the
|
|
2469
2469
|
// teaching failure, not an @intCast trap.
|
|
2470
2470
|
.source = avatar_negative_markup_source,
|
|
2471
|
-
.message = canvas.ui_markup.
|
|
2471
|
+
.message = canvas.ui_markup.image_binding_message,
|
|
2472
2472
|
},
|
|
2473
2473
|
.{
|
|
2474
2474
|
// Scoped to avatar: the other image elements stay Zig views.
|
|
2475
2475
|
.source = "<row>\n <badge image=\"{user_image}\">3</badge>\n</row>",
|
|
2476
|
-
.message = canvas.ui_markup.
|
|
2476
|
+
.message = canvas.ui_markup.image_binding_element_message,
|
|
2477
2477
|
},
|
|
2478
2478
|
};
|
|
2479
2479
|
for (cases) |case| {
|
|
@@ -2537,6 +2537,146 @@ test "the media-surface surface binding resolves the model id; negatives fail th
|
|
|
2537
2537
|
try testing.expect(negative_view.diagnostic.line > 0);
|
|
2538
2538
|
}
|
|
2539
2539
|
|
|
2540
|
+
// ------------------------------------------------ image leaf id binding
|
|
2541
|
+
|
|
2542
|
+
pub const ImageLeafMsg = union(enum) { refresh };
|
|
2543
|
+
|
|
2544
|
+
pub const ImageLeafModel = struct {
|
|
2545
|
+
/// Runtime-registered ImageId kept in the model (0 = no image, the
|
|
2546
|
+
/// leaf draws nothing) — the id lands here from `Cmd.imageLoad`'s
|
|
2547
|
+
/// loaded result (or `fx.registerImageBytes` on the Zig tier).
|
|
2548
|
+
cover: canvas.ImageId = 0,
|
|
2549
|
+
/// A signed id field: bindings evaluate as i64, so a negative must
|
|
2550
|
+
/// reach the image seam as a value, never trap in the u64 cast.
|
|
2551
|
+
stale_image: i64 = -2,
|
|
2552
|
+
|
|
2553
|
+
/// A pub fn producing an ImageId binds like a field.
|
|
2554
|
+
pub fn thumbnail(model: *const ImageLeafModel) canvas.ImageId {
|
|
2555
|
+
return model.cover + 1;
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2559
|
+
pub const image_markup_source =
|
|
2560
|
+
\\<row gap="8">
|
|
2561
|
+
\\ <image image="{cover}" width="120" height="80" label="Cover art" />
|
|
2562
|
+
\\ <image image="{thumbnail}" width="48" height="48" label="" />
|
|
2563
|
+
\\</row>
|
|
2564
|
+
;
|
|
2565
|
+
|
|
2566
|
+
/// A negative model value into the image leaf's u64 id seam: both
|
|
2567
|
+
/// engines must fail the build with the image teaching, never trap.
|
|
2568
|
+
pub const image_negative_markup_source =
|
|
2569
|
+
\\<row>
|
|
2570
|
+
\\ <image image="{stale_image}" label="Cover art" />
|
|
2571
|
+
\\</row>
|
|
2572
|
+
;
|
|
2573
|
+
|
|
2574
|
+
pub const ImageLeafUi = canvas.Ui(ImageLeafMsg);
|
|
2575
|
+
|
|
2576
|
+
/// The hand-written equivalent of the image markup: `ui.image` with
|
|
2577
|
+
/// `ElementOptions.image`, the parity baseline the compiled suite
|
|
2578
|
+
/// shares.
|
|
2579
|
+
pub fn handImageLeafView(ui: *ImageLeafUi, model: *const ImageLeafModel) ImageLeafUi.Node {
|
|
2580
|
+
return ui.row(.{ .gap = 8 }, .{
|
|
2581
|
+
ui.image(.{ .image = model.cover, .width = 120, .height = 80, .semantics = .{ .label = "Cover art" } }),
|
|
2582
|
+
ui.image(.{ .image = model.thumbnail(), .width = 48, .height = 48, .semantics = .{ .label = "" } }),
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
test "the image leaf binds a dynamic ImageId from model fields and fns" {
|
|
2587
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
2588
|
+
defer arena_state.deinit();
|
|
2589
|
+
const arena = arena_state.allocator();
|
|
2590
|
+
const ImageMarkup = markup_view.MarkupView(ImageLeafModel, ImageLeafMsg);
|
|
2591
|
+
const model = ImageLeafModel{ .cover = 42 };
|
|
2592
|
+
|
|
2593
|
+
var view = try ImageMarkup.init(arena, image_markup_source);
|
|
2594
|
+
var markup_ui = ImageLeafUi.init(arena);
|
|
2595
|
+
const markup_tree = try markup_ui.finalize(try view.build(&markup_ui, &model));
|
|
2596
|
+
|
|
2597
|
+
var hand_ui = ImageLeafUi.init(arena);
|
|
2598
|
+
const hand_tree = try hand_ui.finalize(handImageLeafView(&hand_ui, &model));
|
|
2599
|
+
|
|
2600
|
+
var markup_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
|
|
2601
|
+
defer markup_ids.deinit(testing.allocator);
|
|
2602
|
+
var hand_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
|
|
2603
|
+
defer hand_ids.deinit(testing.allocator);
|
|
2604
|
+
try collectIds(markup_tree.root, &markup_ids, testing.allocator);
|
|
2605
|
+
try collectIds(hand_tree.root, &hand_ids, testing.allocator);
|
|
2606
|
+
try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
|
|
2607
|
+
|
|
2608
|
+
// The field binding and the fn binding both land in image_id.
|
|
2609
|
+
const cover = markup_tree.root.children[0];
|
|
2610
|
+
try testing.expectEqual(canvas.WidgetKind.image, cover.kind);
|
|
2611
|
+
try testing.expectEqual(@as(canvas.ImageId, 42), cover.image_id);
|
|
2612
|
+
try testing.expectEqualStrings("Cover art", cover.semantics.label);
|
|
2613
|
+
const thumbnail = markup_tree.root.children[1];
|
|
2614
|
+
try testing.expectEqual(@as(canvas.ImageId, 43), thumbnail.image_id);
|
|
2615
|
+
|
|
2616
|
+
// 0 is the "no image" sentinel: the leaf renders nothing (the
|
|
2617
|
+
// model simply has not loaded the image yet).
|
|
2618
|
+
const empty_model = ImageLeafModel{};
|
|
2619
|
+
var empty_ui = ImageLeafUi.init(arena);
|
|
2620
|
+
const empty_tree = try empty_ui.finalize(try view.build(&empty_ui, &empty_model));
|
|
2621
|
+
try testing.expectEqual(@as(canvas.ImageId, 0), empty_tree.root.children[0].image_id);
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
test "image leaf misuse fails the build with the teaching messages" {
|
|
2625
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
2626
|
+
defer arena_state.deinit();
|
|
2627
|
+
const arena = arena_state.allocator();
|
|
2628
|
+
const model = ImageLeafModel{};
|
|
2629
|
+
const ImageMarkup = markup_view.MarkupView(ImageLeafModel, ImageLeafMsg);
|
|
2630
|
+
|
|
2631
|
+
const cases = [_]struct { source: []const u8, message: []const u8 }{
|
|
2632
|
+
.{
|
|
2633
|
+
// A literal id is not model data.
|
|
2634
|
+
.source = "<row>\n <image image=\"7\" label=\"Art\" />\n</row>",
|
|
2635
|
+
.message = canvas.ui_markup.image_binding_message,
|
|
2636
|
+
},
|
|
2637
|
+
.{
|
|
2638
|
+
// A negative integer can never be a u64 ImageId: the
|
|
2639
|
+
// teaching failure, not an @intCast trap.
|
|
2640
|
+
.source = image_negative_markup_source,
|
|
2641
|
+
.message = canvas.ui_markup.image_binding_message,
|
|
2642
|
+
},
|
|
2643
|
+
.{
|
|
2644
|
+
// A leaf like icon: widget layout gives an image no child
|
|
2645
|
+
// slots, so a nested caption would silently vanish - the
|
|
2646
|
+
// build refuses it instead (the compiled engine rejects
|
|
2647
|
+
// the same construct as a compile error).
|
|
2648
|
+
.source = "<row>\n <image image=\"{cover}\" label=\"Art\"><text>Caption</text></image>\n</row>",
|
|
2649
|
+
.message = canvas.ui_markup.image_children_message,
|
|
2650
|
+
},
|
|
2651
|
+
.{
|
|
2652
|
+
// Markup that skipped validation (hot reload) can reach the
|
|
2653
|
+
// engine without the binding: the leaf could only ever
|
|
2654
|
+
// render nothing, so the build refuses it exactly like the
|
|
2655
|
+
// validator (the compiled engine rejects the same construct
|
|
2656
|
+
// as a compile error).
|
|
2657
|
+
.source = "<row>\n <image label=\"Art\" />\n</row>",
|
|
2658
|
+
.message = canvas.ui_markup.image_missing_image_message,
|
|
2659
|
+
},
|
|
2660
|
+
.{
|
|
2661
|
+
// The children check reads the ORIGINAL node: a context-menu
|
|
2662
|
+
// child is extracted as host metadata before the content
|
|
2663
|
+
// rules, but the validator rejects it on the raw node - the
|
|
2664
|
+
// build agrees instead of quietly accepting a menu-bearing
|
|
2665
|
+
// leaf the validator refuses (the compiled engine rejects
|
|
2666
|
+
// the same construct as a compile error).
|
|
2667
|
+
.source = "<row>\n <image image=\"{cover}\" label=\"Art\" on-press=\"refresh\"><context-menu><menu-item on-press=\"refresh\">Reload</menu-item></context-menu></image>\n</row>",
|
|
2668
|
+
.message = canvas.ui_markup.image_children_message,
|
|
2669
|
+
},
|
|
2670
|
+
};
|
|
2671
|
+
for (cases) |case| {
|
|
2672
|
+
var view = try ImageMarkup.init(arena, case.source);
|
|
2673
|
+
var ui = ImageLeafUi.init(arena);
|
|
2674
|
+
try testing.expectError(error.MarkupBuild, view.build(&ui, &model));
|
|
2675
|
+
try testing.expectEqualStrings(case.message, view.diagnostic.message);
|
|
2676
|
+
try testing.expect(view.diagnostic.line > 0);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2540
2680
|
// ------------------------------------- text alignment and grid columns
|
|
2541
2681
|
|
|
2542
2682
|
pub const AlignMsg = union(enum) { refresh };
|
|
@@ -3907,7 +4047,8 @@ test "reactions misuse fails the build with the pinned teaching messages" {
|
|
|
3907
4047
|
|
|
3908
4048
|
// The pill's literal run rides the tofu guard: a codepoint outside
|
|
3909
4049
|
// the bundled face renders as a tofu box on the reference path, so
|
|
3910
|
-
// the validator teaches
|
|
4050
|
+
// the validator teaches the real paths — a registered covering
|
|
4051
|
+
// font behind a binding, a vector icon, or plain words.
|
|
3911
4052
|
const emoji = "<column>\n <bubble><text>hi</text><reactions>\u{1F44D}</reactions></bubble>\n</column>";
|
|
3912
4053
|
var parser = canvas.ui_markup.Parser.init(arena, emoji);
|
|
3913
4054
|
const document = try parser.parse();
|
|
@@ -320,6 +320,15 @@ pub const elements = [_]ElementInfo{
|
|
|
320
320
|
// binding shape, never a markup literal. Display-only like image
|
|
321
321
|
// and chart (presses fall through); pictorial for the a11y lint.
|
|
322
322
|
.{ .code = 66, .name = "media-surface", .widget_kind = "media_surface", .hit_target = false, .a11y_name = .image },
|
|
323
|
+
// The image leaf: draws a RUNTIME-REGISTERED image by its
|
|
324
|
+
// model-owned u64 ImageId — the id `Cmd.imageLoad` /
|
|
325
|
+
// `fx.loadImage` / `fx.registerImageBytes` registered pixels
|
|
326
|
+
// under. Its `image` attribute is the avatar binding shape exactly
|
|
327
|
+
// (attr 38, scope broadened): one {binding}, never a markup
|
|
328
|
+
// literal; 0 draws nothing (the image-leaf convention — an avatar
|
|
329
|
+
// falls back to initials instead). Display-only like media-surface
|
|
330
|
+
// and chart (presses fall through); pictorial for the a11y lint.
|
|
331
|
+
.{ .code = 67, .name = "image", .widget_kind = "image", .hit_target = false, .a11y_name = .image },
|
|
323
332
|
};
|
|
324
333
|
|
|
325
334
|
// ------------------------------------------------------------- attributes
|
|
@@ -371,6 +380,10 @@ pub const attrs = [_]AttrInfo{
|
|
|
371
380
|
// Element-scoped specials.
|
|
372
381
|
.{ .code = 36, .name = "name", .class = .icon, .group = .element },
|
|
373
382
|
.{ .code = 37, .name = "icon", .class = .icon, .group = .element },
|
|
383
|
+
// The runtime-image binding (avatar and image; the validator
|
|
384
|
+
// scopes it): one {binding} to the model-owned u64 ImageId the app
|
|
385
|
+
// registered at runtime — ids are model data, never markup
|
|
386
|
+
// literals; 0 is the no-image sentinel.
|
|
374
387
|
.{ .code = 38, .name = "image", .class = .binding_only, .group = .element },
|
|
375
388
|
.{ .code = 39, .name = "anchor", .class = .option, .group = .element },
|
|
376
389
|
.{ .code = 40, .name = "anchor-alignment", .class = .option, .group = .element },
|
|
@@ -21,13 +21,14 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
21
21
|
// (append or slot them anywhere — order carries no meaning) and pin
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
|
-
try testing.expectEqual(@as(usize,
|
|
24
|
+
try testing.expectEqual(@as(usize, 67), schema.elements.len);
|
|
25
25
|
try testing.expectEqual(@as(usize, 81), schema.attrs.len);
|
|
26
26
|
try testing.expectEqual(@as(usize, 10), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64), the
|
|
28
|
-
// bubble-reactions composite (65),
|
|
28
|
+
// bubble-reactions composite (65), the media surface (66), and the
|
|
29
|
+
// runtime-image leaf (67).
|
|
29
30
|
try testing.expectEqual(
|
|
30
|
-
@as(u64,
|
|
31
|
+
@as(u64, 0x2a68661a562f0565),
|
|
31
32
|
tableFingerprint(schema.ElementInfo, &schema.elements),
|
|
32
33
|
);
|
|
33
34
|
// The attr table runs through the split layout-tween attributes
|
|
@@ -90,7 +91,7 @@ test "registry event scoping names registry elements" {
|
|
|
90
91
|
test "derived name lists mirror the registry" {
|
|
91
92
|
// The derivations are the vocabulary every consumer reads; hold them
|
|
92
93
|
// to the registry's own predicates.
|
|
93
|
-
try testing.expectEqual(@as(usize,
|
|
94
|
+
try testing.expectEqual(@as(usize, 55), schema.element_names.len);
|
|
94
95
|
for (schema.element_names) |name| {
|
|
95
96
|
try testing.expect(schema.elementByName(name).?.rule_hook == null);
|
|
96
97
|
}
|
package/src/root.zig
CHANGED
|
@@ -76,6 +76,12 @@ pub const EffectAudioEventKind = runtime.EffectAudioEventKind;
|
|
|
76
76
|
pub const EffectAudioSource = runtime.EffectAudioSource;
|
|
77
77
|
pub const audioCachePath = runtime.audioCachePath;
|
|
78
78
|
pub const max_effect_audio_path_bytes = runtime.max_effect_audio_path_bytes;
|
|
79
|
+
pub const EffectImageResult = runtime.EffectImageResult;
|
|
80
|
+
pub const EffectImageOutcome = runtime.EffectImageOutcome;
|
|
81
|
+
pub const imageCachePath = runtime.imageCachePath;
|
|
82
|
+
pub const max_effect_image_path_bytes = runtime.max_effect_image_path_bytes;
|
|
83
|
+
pub const max_effect_image_bytes = runtime.max_effect_image_bytes;
|
|
84
|
+
pub const effect_image_blob_hash_len = runtime.effect_image_blob_hash_len;
|
|
79
85
|
pub const EffectHostResult = runtime.EffectHostResult;
|
|
80
86
|
pub const HostCallBinding = runtime.HostCallBinding;
|
|
81
87
|
pub const max_effect_host_name_bytes = runtime.max_effect_host_name_bytes;
|
|
@@ -137,6 +143,7 @@ pub const WindowChrome = platform.WindowChrome;
|
|
|
137
143
|
pub const FormFactor = platform.FormFactor;
|
|
138
144
|
pub const WindowDragRegion = platform.WindowDragRegion;
|
|
139
145
|
pub const WindowShowMode = platform.WindowShowMode;
|
|
146
|
+
pub const WindowClosePolicy = platform.WindowClosePolicy;
|
|
140
147
|
pub const Menu = platform.Menu;
|
|
141
148
|
pub const MenuItem = platform.MenuItem;
|
|
142
149
|
pub const Shortcut = platform.Shortcut;
|
package/src/runtime/api.zig
CHANGED
|
@@ -385,12 +385,14 @@ pub fn App(comptime Runtime: type) type {
|
|
|
385
385
|
pub const Options = struct {
|
|
386
386
|
platform: platform.Platform,
|
|
387
387
|
/// Allocator for the runtime's on-demand storage (registered
|
|
388
|
-
/// canvas font bytes, sized per file at registration
|
|
388
|
+
/// canvas font bytes, sized per file at registration; registered
|
|
389
|
+
/// canvas image slot buffers, one slot-budget buffer per used slot
|
|
390
|
+
/// allocated at the slot's first registration; and adopted
|
|
389
391
|
/// media-surface texture buffers, one frame-budget buffer per
|
|
390
392
|
/// texture entry allocated at first adoption — a runtime with no
|
|
391
|
-
/// registered fonts and no media producers
|
|
392
|
-
/// fixed-capacity per-view storage stays
|
|
393
|
-
/// struct). The default suits process-lifetime runtimes; embedders
|
|
393
|
+
/// registered fonts, no registered images, and no media producers
|
|
394
|
+
/// allocates nothing; the fixed-capacity per-view storage stays
|
|
395
|
+
/// embedded in the Runtime struct). The default suits process-lifetime runtimes; embedders
|
|
394
396
|
/// that create and destroy runtimes in one process (tests, the docs
|
|
395
397
|
/// wasm preview host) pass their own and call `Runtime.deinit`. The
|
|
396
398
|
/// runtime captures this into its `owned_allocator` at init:
|
|
@@ -110,6 +110,13 @@ pub fn platformFeatureFromString(value: []const u8) ?platform.PlatformFeature {
|
|
|
110
110
|
if (std.mem.eql(u8, value, "fileDrops")) return .file_drops;
|
|
111
111
|
if (std.mem.eql(u8, value, "appActivationEvents")) return .app_activation_events;
|
|
112
112
|
if (std.mem.eql(u8, value, "gpuSurfaces")) return .gpu_surfaces;
|
|
113
|
+
if (std.mem.eql(u8, value, "gpuSurfaceScrollDrivers")) return .gpu_surface_scroll_drivers;
|
|
114
|
+
if (std.mem.eql(u8, value, "contextMenus")) return .context_menus;
|
|
115
|
+
if (std.mem.eql(u8, value, "viewSurfaceAdoption")) return .view_surface_adoption;
|
|
116
|
+
if (std.mem.eql(u8, value, "audioPlayback")) return .audio_playback;
|
|
117
|
+
if (std.mem.eql(u8, value, "audioStreaming")) return .audio_streaming;
|
|
118
|
+
if (std.mem.eql(u8, value, "audioSpectrum")) return .audio_spectrum;
|
|
119
|
+
if (std.mem.eql(u8, value, "windowHideOnClose")) return .window_hide_on_close;
|
|
113
120
|
return null;
|
|
114
121
|
}
|
|
115
122
|
|
|
@@ -275,6 +275,11 @@ pub fn writeWindowJsonToWriter(window: platform.WindowInfo, writer: anytype) !vo
|
|
|
275
275
|
try writer.writeAll(if (window.open) "true" else "false");
|
|
276
276
|
try writer.writeAll(",\"focused\":");
|
|
277
277
|
try writer.writeAll(if (window.focused) "true" else "false");
|
|
278
|
+
// Alive-but-policy-hidden rides beside open/focused: without it a JS
|
|
279
|
+
// consumer cannot tell a close_policy = "hide" window (open:true,
|
|
280
|
+
// focused:false) from a visible unfocused one.
|
|
281
|
+
try writer.writeAll(",\"hidden\":");
|
|
282
|
+
try writer.writeAll(if (window.hidden) "true" else "false");
|
|
278
283
|
try writer.print(",\"x\":{d},\"y\":{d},\"width\":{d},\"height\":{d},\"scale\":{d}", .{
|
|
279
284
|
window.frame.x,
|
|
280
285
|
window.frame.y,
|
|
@@ -530,11 +530,16 @@ pub fn RuntimeBuiltinBridge(comptime Runtime: type) type {
|
|
|
530
530
|
var storage = json.StringStorage.init(output);
|
|
531
531
|
const window_id = try Self.resolveWindowSelector(self, payload, &storage);
|
|
532
532
|
const index = WindowViewMethods.findWindowIndexById(self, window_id) orelse return error.WindowNotFound;
|
|
533
|
-
var info = self.windows[index].info;
|
|
534
|
-
info.open = false;
|
|
535
|
-
info.focused = false;
|
|
536
533
|
try self.closeWindow(window_id);
|
|
537
|
-
|
|
534
|
+
// The response serializes the TABLE state after the close,
|
|
535
|
+
// never a hand-cleared copy: closeWindow owns which flags a
|
|
536
|
+
// close clears (open, focused, AND hidden — a closed
|
|
537
|
+
// policy-hidden window is gone, not "hidden"), and a copy
|
|
538
|
+
// maintained here field-by-field silently drifts every time
|
|
539
|
+
// that set grows. The index stays valid: a closed window
|
|
540
|
+
// keeps its table slot — slots only compact inside window
|
|
541
|
+
// create, when a dead slot's id or label is re-used.
|
|
542
|
+
return writeWindowJson(self.windows[index].info, output);
|
|
538
543
|
}
|
|
539
544
|
|
|
540
545
|
pub fn resolveWindowSelector(self: *Runtime, payload: []const u8, storage: *json.StringStorage) !platform.WindowId {
|