@native-sdk/cli 0.11.0 → 0.11.1

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.
Files changed (182) hide show
  1. package/build/app.zig +73 -37
  2. package/build.zig +239 -5
  3. package/native-sdk.d.ts +5 -1
  4. package/package.json +13 -12
  5. package/packages/core/compile-surface/core.ts +30 -0
  6. package/packages/core/package-lock.json +6 -6
  7. package/packages/core/package.json +3 -3
  8. package/packages/core/scripts/scriptc-toolchain.json +44 -44
  9. package/packages/core/scripts/stage_external_core.mjs +27 -16
  10. package/packages/core/sdk/core.d.ts +24 -1
  11. package/packages/core/sdk/core.ts +51 -1
  12. package/packages/core/sdk/events.d.ts +5 -0
  13. package/packages/core/sdk/events.ts +10 -0
  14. package/packages/core/src/bridge_descriptors.ts +3 -3
  15. package/packages/core/src/checker.ts +20 -0
  16. package/packages/core/src/cli.ts +2 -11
  17. package/packages/core/src/context_menus.ts +76 -0
  18. package/packages/core/src/diagnostics.ts +7 -0
  19. package/packages/core/src/extent_program.ts +53 -0
  20. package/packages/core/src/frontend.ts +12 -10
  21. package/packages/core/src/markup_canonical.ts +140 -0
  22. package/packages/core/src/markup_construction.ts +189 -0
  23. package/packages/core/src/markup_display.ts +43 -0
  24. package/packages/core/src/markup_document.ts +226 -0
  25. package/packages/core/src/markup_elements.ts +225 -0
  26. package/packages/core/src/markup_expressions.ts +79 -0
  27. package/packages/core/src/markup_imports.ts +146 -0
  28. package/packages/core/src/markup_parser.ts +228 -0
  29. package/packages/core/src/markup_runtime.ts +93 -0
  30. package/packages/core/src/markup_scalars.ts +143 -0
  31. package/packages/core/src/markup_shapes.ts +243 -0
  32. package/packages/core/src/markup_specialized.ts +242 -0
  33. package/packages/core/src/markup_text.ts +86 -0
  34. package/packages/core/src/markup_values.ts +336 -0
  35. package/packages/core/src/portable_sources.json +24 -0
  36. package/packages/core/src/registered_font.ts +2 -3
  37. package/packages/core/src/runtime_policy.ts +24 -0
  38. package/packages/core/src/scalar_text.ts +1 -3
  39. package/packages/core/src/scroll_mutation.ts +86 -0
  40. package/packages/core/src/scroll_tree.ts +86 -0
  41. package/packages/core/src/service_contract.ts +53 -2
  42. package/packages/core/src/sqlite_cli.ts +3 -46
  43. package/packages/core/src/sqlite_codegen.ts +84 -0
  44. package/packages/core/src/staged_rebuild.ts +60 -0
  45. package/packages/core/src/view_bridge.ts +161 -0
  46. package/packages/core/src/view_check.ts +145 -0
  47. package/packages/core/src/view_evaluator.ts +823 -0
  48. package/packages/core/src/view_frontend.ts +340 -218
  49. package/packages/core/src/view_program.ts +221 -0
  50. package/packages/core/src/view_reload.ts +166 -0
  51. package/packages/core/src/view_reload_watch.ts +98 -0
  52. package/packages/core/src/view_sources.ts +34 -0
  53. package/packages/core/src/virtual_windows.ts +88 -0
  54. package/packages/core/src/web_panes.ts +67 -0
  55. package/packages/core/src/widget_continuity.ts +37 -0
  56. package/packages/core/src/widget_reconcile.ts +63 -0
  57. package/packages/core/src/widget_retention.ts +62 -0
  58. package/skill-data/native-ui/SKILL.md +2 -2
  59. package/skill-data/ts-core/SKILL.md +5 -3
  60. package/skill-data/ts-services/references/service-surface.md +29 -5
  61. package/src/app_runner/root.zig +14 -0
  62. package/src/app_runner/ts_compiled_view.zig +88 -17
  63. package/src/app_runner/ts_core_main.zig +43 -5
  64. package/src/app_runner/ts_core_mobile.zig +1 -1
  65. package/src/automation/server.zig +56 -3
  66. package/src/embed/host.zig +2 -0
  67. package/src/embed/tests.zig +2 -0
  68. package/src/embed/ui_host.zig +2 -0
  69. package/src/platform/keyboard_input.zig +32 -0
  70. package/src/platform/linux/root.zig +2 -0
  71. package/src/platform/macos/appkit_host.h +7 -2
  72. package/src/platform/macos/appkit_host.m +31 -9
  73. package/src/platform/macos/cef_host.mm +15 -1
  74. package/src/platform/macos/global_shortcuts.zig +138 -0
  75. package/src/platform/macos/key_codes.zig +102 -0
  76. package/src/platform/macos/keyboard_input.zig +81 -0
  77. package/src/platform/macos/root.zig +25 -3
  78. package/src/platform/macos/webview_inspection_test.m +106 -0
  79. package/src/platform/null_platform.zig +104 -0
  80. package/src/platform/root.zig +14 -0
  81. package/src/platform/types.zig +102 -0
  82. package/src/platform/windows/global_shortcuts.zig +157 -0
  83. package/src/platform/windows/key_codes.zig +63 -0
  84. package/src/platform/windows/keyboard_input.zig +136 -0
  85. package/src/platform/windows/root.zig +15 -0
  86. package/src/primitives/canvas/decision_reuse.zig +133 -0
  87. package/src/primitives/canvas/font_ttf.zig +27 -3
  88. package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
  89. package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
  90. package/src/primitives/canvas/fonts/OFL.txt +93 -0
  91. package/src/primitives/canvas/fonts/README.md +15 -0
  92. package/src/primitives/canvas/intrinsic_measure_policy.zig +4 -1
  93. package/src/primitives/canvas/markdown_tests.zig +3 -3
  94. package/src/primitives/canvas/reference.zig +3 -5
  95. package/src/primitives/canvas/reference_tests.zig +58 -0
  96. package/src/primitives/canvas/registered_font_policy.zig +1 -1
  97. package/src/primitives/canvas/root.zig +7 -4
  98. package/src/primitives/canvas/text_metrics.zig +32 -39
  99. package/src/primitives/canvas/text_metrics_tests.zig +52 -7
  100. package/src/primitives/canvas/text_query_policy.zig +142 -3
  101. package/src/primitives/canvas/text_scalar_policy.zig +80 -2
  102. package/src/primitives/canvas/tokens.zig +9 -0
  103. package/src/primitives/canvas/ui.zig +1 -0
  104. package/src/primitives/canvas/ui_markup.zig +69 -14
  105. package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
  106. package/src/primitives/canvas/ui_markup_compiled.zig +1407 -23
  107. package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
  108. package/src/primitives/canvas/ui_markup_construction.zig +146 -0
  109. package/src/primitives/canvas/ui_markup_display.zig +82 -0
  110. package/src/primitives/canvas/ui_markup_document.zig +196 -0
  111. package/src/primitives/canvas/ui_markup_elements.zig +163 -0
  112. package/src/primitives/canvas/ui_markup_expr.zig +192 -2
  113. package/src/primitives/canvas/ui_markup_imports.zig +262 -0
  114. package/src/primitives/canvas/ui_markup_parser.zig +117 -0
  115. package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
  116. package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
  117. package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
  118. package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
  119. package/src/primitives/canvas/ui_markup_text.zig +128 -0
  120. package/src/primitives/canvas/ui_markup_values.zig +368 -0
  121. package/src/primitives/canvas/ui_markup_view.zig +2817 -74
  122. package/src/primitives/canvas/virtual_extent_policy.zig +58 -0
  123. package/src/primitives/canvas/virtual_extents.zig +47 -33
  124. package/src/primitives/canvas/widget_metric_policy.zig +4 -1
  125. package/src/primitives/canvas/widget_runtime.zig +2 -1
  126. package/src/root.zig +5 -0
  127. package/src/runtime/api.zig +1 -0
  128. package/src/runtime/bridge_descriptor_policy.zig +1 -1
  129. package/src/runtime/bridge_payload.zig +2 -0
  130. package/src/runtime/canvas_widget_context_menu.zig +179 -0
  131. package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
  132. package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
  133. package/src/runtime/canvas_widget_runtime.zig +306 -92
  134. package/src/runtime/context_menu_policy.zig +112 -0
  135. package/src/runtime/core.zig +14 -0
  136. package/src/runtime/effects.zig +172 -4
  137. package/src/runtime/effects_host_tests.zig +25 -0
  138. package/src/runtime/flow.zig +1 -0
  139. package/src/runtime/flow_reference.zig +1 -0
  140. package/src/runtime/global_shortcuts.zig +75 -0
  141. package/src/runtime/keyboard_input.zig +86 -0
  142. package/src/runtime/root.zig +3 -0
  143. package/src/runtime/scroll_mutation_policy.zig +130 -0
  144. package/src/runtime/scroll_mutation_runtime.zig +158 -0
  145. package/src/runtime/scroll_tree_policy.zig +99 -0
  146. package/src/runtime/session_record.zig +7 -0
  147. package/src/runtime/staged_rebuild_policy.zig +83 -0
  148. package/src/runtime/system_services.zig +19 -0
  149. package/src/runtime/tests.zig +1 -0
  150. package/src/runtime/ts_core_host.zig +126 -0
  151. package/src/runtime/ts_ui_app.zig +24 -0
  152. package/src/runtime/ui_app.zig +274 -31
  153. package/src/runtime/ui_app_tests.zig +48 -179
  154. package/src/runtime/ui_app_window_tests.zig +133 -0
  155. package/src/runtime/view_reload.zig +226 -0
  156. package/src/runtime/view_widget_scroll.zig +30 -21
  157. package/src/runtime/view_widget_tree.zig +43 -13
  158. package/src/runtime/virtual_window_policy.zig +128 -0
  159. package/src/runtime/web_pane_policy.zig +111 -0
  160. package/src/runtime/web_pane_test_cases.zig +204 -0
  161. package/src/runtime/widget_continuity_policy.zig +73 -0
  162. package/src/runtime/widget_reconcile_policy.zig +81 -0
  163. package/src/runtime/widget_retention_policy.zig +75 -0
  164. package/src/runtime/window_views.zig +19 -4
  165. package/src/security/root.zig +1 -0
  166. package/src/tooling/templates.zig +8 -0
  167. package/src/tooling/ts_core.zig +84 -1
  168. package/src/tooling/verbs.zig +79 -15
  169. package/tools/corewire/core.test.ts +25 -3
  170. package/tools/corewire/core_abi.zig +4 -0
  171. package/tools/corewire/core_contract.ts +1 -1
  172. package/tools/corewire/core_goldens.json +75 -75
  173. package/tools/corewire/core_projection.ts +3 -2
  174. package/tools/corewire/emit_mirror.ts +19 -9
  175. package/tools/corewire/facade_templates.ts +1 -1
  176. package/tools/corewire/intake.test.ts +4 -0
  177. package/tools/corewire/intake_goldens.json +50 -50
  178. package/tools/corewire/invocation.test.ts +4 -0
  179. package/tools/corewire/invocation_goldens.json +3 -3
  180. package/tools/corewire/mirror_templates.ts +4 -0
  181. package/tools/corewire/profile_emission.ts +2 -0
  182. package/tools/corewire/sidecar.zig +2 -0
@@ -31,6 +31,8 @@
31
31
 
32
32
  const authorization = @import("authorization_policy.zig");
33
33
  const std = @import("std");
34
+ pub const web_pane_policy = @import("web_pane_policy.zig");
35
+ pub const virtual_window_policy = @import("virtual_window_policy.zig");
34
36
  const builtin = @import("builtin");
35
37
  const geometry = @import("geometry");
36
38
  const canvas = @import("canvas");
@@ -39,6 +41,7 @@ const security = @import("../security/root.zig");
39
41
  const platform = @import("../platform/root.zig");
40
42
  const core = @import("core.zig");
41
43
  const canvas_frame = @import("canvas_frame.zig");
44
+ const view_reload = @import("view_reload.zig");
42
45
  const canvas_limits = @import("canvas_limits.zig");
43
46
  const canvas_widget_events = @import("canvas_widget_events.zig");
44
47
  const drag_policy = @import("canvas_drag_policy.zig");
@@ -105,6 +108,11 @@ pub const UiAppFeatures = struct {
105
108
  /// Generated TypeScript views observe compiled state directly. This
106
109
  /// selects their stateless host handle instead of a decoded model mirror.
107
110
  compiled_model: bool = false,
111
+ /// Debug builds of compiled views that reload markup edits
112
+ /// (view_reload.zig). Their views report where each widget was
113
+ /// authored, so `provenance` and write-back work without the
114
+ /// runtime markup engine.
115
+ view_reload: bool = false,
108
116
  };
109
117
 
110
118
  pub fn UiApp(comptime ModelT: type, comptime MsgT: type) type {
@@ -125,6 +133,16 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
125
133
  /// state, polling, and registration collapse to nothing.
126
134
  const fragment_watch_enabled = features.runtime_markup and builtin.mode == .Debug;
127
135
 
136
+ /// A compiled view's own development reload (Debug only; see
137
+ /// view_reload.zig). When the app wiring installs a hook, the
138
+ /// markup watch timer polls it; this app rebuilds every open window
139
+ /// from the reloaded view and reports failures through the markup
140
+ /// diagnostic, keeping the last good view.
141
+ const view_reload_enabled = builtin.mode == .Debug;
142
+ /// The widget provenance table: the markup interpreter's, or a
143
+ /// reloading compiled view's (Debug).
144
+ const provenance_enabled = features.runtime_markup or (features.view_reload and view_reload_enabled);
145
+
128
146
  /// Fixed budget of watched fragments per app. Registrations past
129
147
  /// it are not watched (a teaching warning names the budget when
130
148
  /// the watch arms) — a view embedding more compiled fragments
@@ -517,6 +535,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
517
535
  chart_content_policy: ?canvas.ChartContentPolicy.Policy = null,
518
536
  markdown_content_policy: ?canvas.MarkdownContentPolicy.Policy = null,
519
537
  construction_policy: ?canvas.ComponentConstructionPolicy.Policy = null,
538
+ expression_policy: ?*const fn ([]const u8, []u8) usize = null,
520
539
  shell_layout_policy: ?*const fn ([]const u8, []u8) usize = null,
521
540
  view_coordination_policy: ?*const fn ([]const u8, []u8) usize = null,
522
541
  window_lifecycle_policy: ?*const fn ([]const u8, []u8) usize = null,
@@ -536,6 +555,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
536
555
  markup_development_policy: markup_development.Policy = null,
537
556
  /// Installed by TsUiApp for compiled command and status policy.
538
557
  command_policy: ?*const fn ([]const u8, []u8) usize = null,
558
+ context_menu_policy: ?*const fn ([]const u8, []u8) usize = null,
539
559
  text_cache_policy: ?*const fn ([]const u8, []u8) usize = null,
540
560
  render_cache_policy: ?*const fn ([]const u8, []u8) usize = null,
541
561
  render_plan_policy: ?*const fn ([]const u8, []u8) usize = null,
@@ -570,6 +590,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
570
590
  accessibility_policy: ?*const fn ([]const u8, []u8) usize = null,
571
591
  widget_routing_policy: ?*const fn ([]const u8, []u8) usize = null,
572
592
  widget_change_policy: ?*const fn ([]const u8, []u8) usize = null,
593
+ widget_retention_policy: ?*const fn ([]const u8, []u8) usize = null,
594
+ widget_reconcile_policy: ?*const fn ([]const u8, []u8) usize = null,
595
+ scroll_tree_policy: ?*const fn ([]const u8, []u8) usize = null,
596
+ scroll_mutation_policy: ?*const fn ([]const u8, []u8) usize = null,
597
+ widget_continuity_policy: ?*const fn ([]const u8, []u8) usize = null,
598
+ staged_rebuild_policy: ?*const fn ([]const u8, []u8) usize = null,
599
+ virtual_window_policy: ?virtual_window_policy.Policy = null,
573
600
  widget_paint_policy: ?*const fn ([]const u8, []u8) usize = null,
574
601
  widget_presentation_policy: ?*const fn ([]const u8, []u8) usize = null,
575
602
  terminal_paint_policy: ?*const fn ([]const u8, []u8) usize = null,
@@ -872,6 +899,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
872
899
  /// selected (`-Dweb-engine=system|cef`); platforms without
873
900
  /// child webviews log a warning and continue.
874
901
  web_panes: ?*const fn (model: *const ModelT, out: []WebViewPane) usize = null,
902
+ web_pane_policy: ?web_pane_policy.Policy = null,
875
903
  /// Menu-bar extra installed once, on the installing frame.
876
904
  /// macOS-proven (`NSStatusItem`); platforms without a
877
905
  /// status-bar service log a warning and continue.
@@ -1129,16 +1157,17 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1129
1157
  markup_fragment_slots: if (fragment_watch_enabled) [max_watched_fragments]MarkupFragmentSlot else void,
1130
1158
  /// Widget provenance (write-back's read half): the retained
1131
1159
  /// structural-id -> authored-markup table the `provenance`
1132
- /// automation verb answers from. Exists only in markup-interpreter
1133
- /// builds; filled only while automation is enabled.
1134
- provenance: if (features.runtime_markup) ui_app_provenance.ProvenanceTable else void =
1135
- if (features.runtime_markup) .{} else {},
1160
+ /// automation verb answers from. Exists in markup-interpreter builds
1161
+ /// and in reloading compiled-view builds (Debug); filled only while
1162
+ /// automation is enabled.
1163
+ provenance: if (provenance_enabled) ui_app_provenance.ProvenanceTable else void =
1164
+ if (provenance_enabled) .{} else {},
1136
1165
  /// Import-closure staging for the file table: filled by the
1137
1166
  /// hashing loader during a resolve, committed on adopt so a failed
1138
1167
  /// mid-edit reload can never re-anchor spans to bytes the running
1139
1168
  /// view was not built from.
1140
- provenance_closure: if (features.runtime_markup) ui_app_provenance.ClosureFiles else void =
1141
- if (features.runtime_markup) .{} else {},
1169
+ provenance_closure: if (provenance_enabled) ui_app_provenance.ClosureFiles else void =
1170
+ if (provenance_enabled) .{} else {},
1142
1171
  layout_nodes: [canvas_limits.max_canvas_widget_nodes_per_view]canvas.WidgetLayoutNode = undefined,
1143
1172
  gpu_commands: [canvas_limits.max_canvas_commands_per_view]canvas.CanvasGpuCommand = undefined,
1144
1173
  /// Packet transport buffer, sized for the larger of the two wire
@@ -1453,8 +1482,8 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1453
1482
  return .{
1454
1483
  .model = model,
1455
1484
  .options = options,
1456
- .provenance = if (comptime features.runtime_markup) .{ .policy = options.markup_development_policy, .allocator = backing } else {},
1457
- .provenance_closure = if (comptime features.runtime_markup) .{ .policy = options.markup_development_policy } else {},
1485
+ .provenance = if (comptime provenance_enabled) .{ .policy = options.markup_development_policy, .allocator = backing } else {},
1486
+ .provenance_closure = if (comptime provenance_enabled) .{ .policy = options.markup_development_policy } else {},
1458
1487
  .backing = backing,
1459
1488
  .arenas = .{
1460
1489
  std.heap.ArenaAllocator.init(backing),
@@ -1521,8 +1550,8 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1521
1550
  self.* = .{
1522
1551
  .model = undefined,
1523
1552
  .options = options,
1524
- .provenance = if (comptime features.runtime_markup) .{ .policy = options.markup_development_policy, .allocator = backing } else {},
1525
- .provenance_closure = if (comptime features.runtime_markup) .{ .policy = options.markup_development_policy } else {},
1553
+ .provenance = if (comptime provenance_enabled) .{ .policy = options.markup_development_policy, .allocator = backing } else {},
1554
+ .provenance_closure = if (comptime provenance_enabled) .{ .policy = options.markup_development_policy } else {},
1526
1555
  .backing = backing,
1527
1556
  .arenas = .{
1528
1557
  std.heap.ArenaAllocator.init(backing),
@@ -1603,6 +1632,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1603
1632
  .snapshot_policy = self.options.snapshot_policy,
1604
1633
  .host_flow_policy = self.options.host_flow_policy,
1605
1634
  .command_policy = self.options.command_policy,
1635
+ .context_menu_policy = self.options.context_menu_policy,
1606
1636
  .text_cache_policy = self.options.text_cache_policy,
1607
1637
  .render_cache_policy = self.options.render_cache_policy,
1608
1638
  .render_plan_policy = self.options.render_plan_policy,
@@ -1675,6 +1705,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1675
1705
  .minimize_fn = effectsMinimizeWindowByLabel,
1676
1706
  .hide_fn = effectsHideWindowByLabel,
1677
1707
  .show_fn = effectsShowWindowByLabel,
1708
+ .replay_show_fn = effectsReplayShowWindowByLabel,
1678
1709
  .dock_presence_fn = effectsSetDockPresence,
1679
1710
  .quit_fn = effectsQuitApp,
1680
1711
  });
@@ -1685,6 +1716,11 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1685
1716
  .format_local_time_fn = effectsFormatLocalTime,
1686
1717
  .execute_capability_fn = effectsExecuteCapability,
1687
1718
  .replay_window_result_fn = effectsRestoreWindowResult,
1719
+ .keyboard_input = .{
1720
+ .context = runtime,
1721
+ .send_key_chord_fn = effectsSendKeyChord,
1722
+ .access_fn = effectsKeyboardInputAccess,
1723
+ },
1688
1724
  });
1689
1725
  if (runtime.options.session_recorder) |recorder| {
1690
1726
  if (self.options.recording_policy) |policy| recorder.recording_policy = policy;
@@ -2105,6 +2141,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2105
2141
  tokens.accessibility_policy = self.options.accessibility_policy;
2106
2142
  tokens.widget_routing_policy = self.options.widget_routing_policy;
2107
2143
  tokens.widget_change_policy = self.options.widget_change_policy;
2144
+ tokens.widget_retention_policy = self.options.widget_retention_policy;
2145
+ tokens.widget_reconcile_policy = self.options.widget_reconcile_policy;
2146
+ tokens.scroll_tree_policy = self.options.scroll_tree_policy;
2147
+ tokens.scroll_mutation_policy = self.options.scroll_mutation_policy;
2148
+ tokens.widget_continuity_policy = self.options.widget_continuity_policy;
2149
+ tokens.staged_rebuild_policy = self.options.staged_rebuild_policy;
2108
2150
  tokens.widget_paint_policy = self.options.widget_paint_policy;
2109
2151
  tokens.widget_presentation_policy = self.options.widget_presentation_policy;
2110
2152
  tokens.widget_paint_walk_policy = self.options.widget_paint_walk_policy;
@@ -2174,6 +2216,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2174
2216
  tokens.accessibility_policy = self.options.accessibility_policy;
2175
2217
  tokens.widget_routing_policy = self.options.widget_routing_policy;
2176
2218
  tokens.widget_change_policy = self.options.widget_change_policy;
2219
+ tokens.widget_retention_policy = self.options.widget_retention_policy;
2220
+ tokens.widget_reconcile_policy = self.options.widget_reconcile_policy;
2221
+ tokens.scroll_tree_policy = self.options.scroll_tree_policy;
2222
+ tokens.scroll_mutation_policy = self.options.scroll_mutation_policy;
2223
+ tokens.widget_continuity_policy = self.options.widget_continuity_policy;
2224
+ tokens.staged_rebuild_policy = self.options.staged_rebuild_policy;
2177
2225
  tokens.widget_paint_policy = self.options.widget_paint_policy;
2178
2226
  tokens.widget_presentation_policy = self.options.widget_presentation_policy;
2179
2227
  tokens.widget_paint_walk_policy = self.options.widget_paint_walk_policy;
@@ -2193,13 +2241,14 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2193
2241
  /// Re-derive once per rebuild and reject malformed adapter input at
2194
2242
  /// the declaration boundary. A valid retained state contains no
2195
2243
  /// borrowed accent text, so it remains safe between dispatches.
2196
- fn refreshThemeState(self: *Self) error{InvalidThemeAccent}!void {
2244
+ fn refreshThemeState(self: *Self, runtime: *Runtime) anyerror!void {
2197
2245
  // Complete-token paths outrank the stock-theme helper entirely.
2198
2246
  // Do not even validate an unused model accent: the app has
2199
2247
  // explicitly claimed the whole DesignTokens register.
2200
2248
  if (self.themeControl(.system).mode != 0) {
2201
2249
  self.theme_state = .{};
2202
2250
  self.theme_state_known = true;
2251
+ try self.applyWindowColorSchemes(runtime);
2203
2252
  return;
2204
2253
  }
2205
2254
  const next = if (self.options.theme_state_fn) |theme_state_fn| theme_state_fn(&self.model) else ThemeState{};
@@ -2214,6 +2263,24 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2214
2263
  self.theme_state = next;
2215
2264
  self.theme_state_known = true;
2216
2265
  }
2266
+ try self.applyWindowColorSchemes(runtime);
2267
+ }
2268
+
2269
+ fn windowColorScheme(self: *const Self) platform.WindowColorScheme {
2270
+ return switch (self.theme_state.color_scheme) {
2271
+ .system => .system,
2272
+ .light => .light,
2273
+ .dark => .dark,
2274
+ };
2275
+ }
2276
+
2277
+ /// Forward the model-owned declaration, not the resolved OS scheme:
2278
+ /// `system` must remove the native override. Hidden and not-yet-rendered
2279
+ /// windows participate too; no canvas installation is required.
2280
+ fn applyWindowColorSchemes(self: *const Self, runtime: *Runtime) anyerror!void {
2281
+ for (runtime.windows[0..runtime.window_count]) |window| {
2282
+ if (window.info.open) try runtime.options.platform.services.setWindowColorScheme(window.info.id, self.windowColorScheme());
2283
+ }
2217
2284
  }
2218
2285
 
2219
2286
  /// The design tokens for a secondary window's rebuild: the same
@@ -2300,14 +2367,14 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2300
2367
  self.tree = null;
2301
2368
  self.main_tree_current = false;
2302
2369
  self.releaseContextMenuSnapshotForWindow(window_id);
2303
- try self.refreshThemeState();
2370
+ try self.refreshThemeState(runtime);
2304
2371
  self.applyStatusItem(runtime);
2305
2372
  self.applyWindows(runtime);
2306
2373
  return;
2307
2374
  }
2308
2375
  }
2309
2376
  self.syncModel(runtime, window_id);
2310
- try self.refreshThemeState();
2377
+ try self.refreshThemeState(runtime);
2311
2378
  if (comptime features.runtime_markup) {
2312
2379
  // Under automation, drive the interpreter from the first
2313
2380
  // frame even when a compiled view is present: provenance
@@ -2588,6 +2655,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2588
2655
  ui.chart_content_policy = self.options.chart_content_policy;
2589
2656
  ui.markdown_content_policy = self.options.markdown_content_policy;
2590
2657
  ui.construction_policy = self.options.construction_policy;
2658
+ ui.expression_policy = self.options.expression_policy;
2591
2659
  // The house video chrome renders the channel's honest
2592
2660
  // snapshot, stamped before the view fn runs — the model
2593
2661
  // carries none of it.
@@ -2613,6 +2681,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2613
2681
  ui.provenance_sink = self.provenance.sink();
2614
2682
  }
2615
2683
  }
2684
+ if (comptime features.view_reload and view_reload_enabled) {
2685
+ if (view_reload.installed != null and runtime.options.automation != null) {
2686
+ self.provenance.resetRecords();
2687
+ view_reload.view_files_len = 0;
2688
+ ui.provenance_sink = self.provenance.sink();
2689
+ }
2690
+ }
2616
2691
  // Frame-profile stamps (no-ops unless profiling is on): the
2617
2692
  // view build fn + tree finalize is the `rebuild` stage, the
2618
2693
  // flex pass below is `layout`; reconcile/emit are stamped at
@@ -2620,6 +2695,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2620
2695
  // are attributed too.
2621
2696
  const rebuild_begin = runtime.frame_profile.begin();
2622
2697
  const node = try self.buildViewNode(&ui);
2698
+ // A compiled view names its markup files as it decodes;
2699
+ // they must be in the table before finalize appends the
2700
+ // records that point at them.
2701
+ if (comptime features.view_reload and view_reload_enabled) {
2702
+ if (ui.provenance_sink != null) self.commitViewSourceFiles();
2703
+ }
2623
2704
  tree = try ui.finalizeWithTokens(node, tokens);
2624
2705
  runtime.frame_profile.end(.rebuild, rebuild_begin);
2625
2706
 
@@ -2669,9 +2750,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2669
2750
  // coverage miss does, so the installed frame already
2670
2751
  // consumed it; a residual delta rides to the next
2671
2752
  // rebuild, atomically with the geometry either way.
2672
- const corrected = self.measureVirtualWindows(layout);
2753
+ var virtual_plan: ?virtual_window_policy.Layout = null;
2754
+ if (self.virtual_window_count != 0) {
2755
+ if (self.options.virtual_window_policy) |policy| virtual_plan =
2756
+ virtual_window_policy.Layout.init(policy, self.virtual_windows[0..self.virtual_window_count], layout.nodes);
2757
+ }
2758
+ const plan = if (virtual_plan) |*value| value else null;
2759
+ const corrected = self.measureVirtualWindows(layout, plan);
2673
2760
  pass += 1;
2674
- if (pass >= 2 or (!corrected and !self.virtualWindowsUndercovered(layout))) break;
2761
+ if (self.options.virtual_window_policy) |policy| {
2762
+ var decision = virtual_window_policy.retry(policy, pass, corrected, null);
2763
+ if (decision == .probe) decision = virtual_window_policy.retry(policy, pass, corrected, self.virtualWindowsUndercovered(layout, plan));
2764
+ if (decision == .stop) break;
2765
+ if (decision != .rebuild) @panic("nonprogressing virtual window retry");
2766
+ } else if (pass >= 2 or (!corrected and !self.virtualWindowsUndercovered(layout, null))) break;
2675
2767
  window_source.fresh = layout;
2676
2768
  }
2677
2769
  return .{ .tree = tree, .layout = layout };
@@ -2799,7 +2891,25 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2799
2891
  /// Whether any declared virtual window fails to cover the visible
2800
2892
  /// range its FRESH geometry implies (first-build viewport guess,
2801
2893
  /// resize growth): the trigger for the one coverage-retry build.
2802
- fn virtualWindowsUndercovered(self: *const Self, layout: canvas.WidgetLayoutTree) bool {
2894
+ fn virtualWindowsUndercovered(self: *const Self, layout: canvas.WidgetLayoutTree, plan: ?*const virtual_window_policy.Layout) bool {
2895
+ if (plan) |program| {
2896
+ for (self.virtual_windows[0..self.virtual_window_count], 0..) |record, i| {
2897
+ const step = program.list(i);
2898
+ if (step.coverage == .skip) continue;
2899
+ const node = layout.nodes[step.node.?];
2900
+ const viewport = node.frame.inset(node.widget.layout.padding).normalized();
2901
+ switch (step.coverage) {
2902
+ .skip => unreachable,
2903
+ .variable => {
2904
+ const table = self.virtualExtentTableForId(record.id) orelse continue;
2905
+ const offset = @max(0, node.widget.value);
2906
+ if (canvas.virtual_extent_policy.undercovered(self.options.virtual_window_policy.?, record.item_count, table.indexAtOffset(offset), table.indexAtOffset(offset + viewport.height), record.overscan, record.start_index, record.end_index)) return true;
2907
+ },
2908
+ .fixed => if (virtual_window_policy.fixedUndercovered(self.options.virtual_window_policy.?, record, node)) return true,
2909
+ }
2910
+ }
2911
+ return false;
2912
+ }
2803
2913
  for (self.virtual_windows[0..self.virtual_window_count]) |record| {
2804
2914
  const node = layout.findById(record.id) orelse continue;
2805
2915
  const viewport = node.frame.inset(node.widget.layout.padding).normalized();
@@ -2898,7 +3008,27 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2898
3008
  /// the pending offset delta keeps it visually fixed. Returns
2899
3009
  /// whether any table accumulated a correction worth the retry
2900
3010
  /// pass.
2901
- fn measureVirtualWindows(self: *Self, layout: canvas.WidgetLayoutTree) bool {
3011
+ fn measureVirtualWindows(self: *Self, layout: canvas.WidgetLayoutTree, plan: ?*const virtual_window_policy.Layout) bool {
3012
+ if (plan) |program| {
3013
+ var deltas: [canvas.max_virtual_windows]f32 = @splat(0);
3014
+ for (self.virtual_windows[0..self.virtual_window_count], 0..) |record, i| {
3015
+ const step = program.list(i);
3016
+ // Empty measurement batches are significant: the table
3017
+ // refreshes its anchor even when no eligible row exists.
3018
+ if (!step.measure) continue;
3019
+ const table = self.virtualExtentTableForId(record.id) orelse continue;
3020
+ const list_node = layout.nodes[step.node.?];
3021
+ var measurements: std.ArrayList(canvas.VirtualExtentMeasurement) = .empty;
3022
+ defer measurements.deinit(std.heap.page_allocator);
3023
+ for (0..step.rows.len / 4) |j| {
3024
+ const node = layout.nodes[virtual_window_policy.row(step.rows, j)];
3025
+ measurements.append(std.heap.page_allocator, .{ .physical = @intCast(node.widget.semantics.list_item_index.?), .extent = node.frame.normalized().height }) catch @panic("virtual row measurement allocation failed");
3026
+ }
3027
+ table.applyMeasurements(list_node.widget.layout.virtual_anchor_index, null, measurements.items);
3028
+ deltas[i] = table.pending_offset_delta;
3029
+ }
3030
+ return virtual_window_policy.corrected(self.options.virtual_window_policy.?, deltas[0..self.virtual_window_count]);
3031
+ }
2902
3032
  var corrected = false;
2903
3033
  for (self.virtual_windows[0..self.virtual_window_count]) |record| {
2904
3034
  if (!record.variable or record.item_count == 0) continue;
@@ -2939,6 +3069,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2939
3069
  }
2940
3070
 
2941
3071
  fn isVirtualWindowId(self: *const Self, id: canvas.ObjectId) bool {
3072
+ if (self.options.virtual_window_policy) |policy| return virtual_window_policy.contains(policy, id, self.virtual_windows[0..self.virtual_window_count]);
2942
3073
  if (id == 0) return false;
2943
3074
  for (self.virtual_windows[0..self.virtual_window_count]) |record| {
2944
3075
  if (record.id == id) return true;
@@ -3260,6 +3391,11 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3260
3391
  slot.tree = null;
3261
3392
  slot.arena_index = 0;
3262
3393
  self.window_slot_count += 1;
3394
+ // A deferred secondary window has not presented its first canvas
3395
+ // yet. Apply the retained theme before it can become visible.
3396
+ runtime.options.platform.services.setWindowColorScheme(info.id, self.windowColorScheme()) catch |err| {
3397
+ ui_app_log.warn("declared window '{s}' appearance failed: {s}", .{ descriptor.label, @errorName(err) });
3398
+ };
3263
3399
  }
3264
3400
 
3265
3401
  fn setWindowSlotOnClose(self: *Self, slot: *WindowSlot, msg: ?MsgT) void {
@@ -3362,7 +3498,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3362
3498
 
3363
3499
  fn rebuildWindowSlot(self: *Self, runtime: *Runtime, slot: *WindowSlot) anyerror!void {
3364
3500
  if (self.options.window_view == null) return;
3365
- try self.refreshThemeState();
3501
+ try self.refreshThemeState(runtime);
3366
3502
  var tokens = runtime.tokensWithTextMeasure(self.slotEffectiveTokens(slot));
3367
3503
  const next_index = self.contextMenuRebuildIndex(slot.window_id, slot.arena_index);
3368
3504
  const bounds = geometry.RectF.fromSize(slot.canvas_size).deflate(runtime.viewportInsetsForWindow(slot.window_id));
@@ -3509,6 +3645,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3509
3645
  ui.chart_content_policy = self.options.chart_content_policy;
3510
3646
  ui.markdown_content_policy = self.options.markdown_content_policy;
3511
3647
  ui.construction_policy = self.options.construction_policy;
3648
+ ui.expression_policy = self.options.expression_policy;
3512
3649
  // Window views render the same honest video chrome state,
3513
3650
  // and their `<video src>` declarations reconcile the channel
3514
3651
  // too — `Ui.video` promises that declaring the element IS
@@ -3558,6 +3695,52 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3558
3695
  }
3559
3696
 
3560
3697
  fn applyWebPane(self: *Self, runtime: *Runtime, window_id: platform.WindowId, layout: canvas.WidgetLayoutTree, pane: WebViewPane) void {
3698
+ if (self.options.web_pane_policy) |policy| return self.applyCompiledWebPane(runtime, window_id, layout, pane, policy);
3699
+ self.applyNativeWebPane(runtime, window_id, layout, pane);
3700
+ }
3701
+
3702
+ fn applyCompiledWebPane(self: *Self, runtime: *Runtime, window_id: platform.WindowId, layout: canvas.WidgetLayoutTree, pane: WebViewPane, policy: web_pane_policy.Policy) void {
3703
+ const planned = web_pane_policy.frame(policy, layout.nodes, pane.frame, pane.anchor);
3704
+ switch (planned.kind) {
3705
+ .missing_anchor => {
3706
+ ui_app_log.warn(
3707
+ "webview pane '{s}': no canvas widget carries semantics label '{s}' - mark the region's widget with .semantics = .{{ .label = \"{s}\" }}",
3708
+ .{ pane.label, pane.anchor.?, pane.anchor.? },
3709
+ );
3710
+ return;
3711
+ },
3712
+ .collapsed => return,
3713
+ .apply => {},
3714
+ }
3715
+ const claimed = web_pane_policy.slot(policy, self.web_pane_states[0..self.web_pane_state_count], pane.label, app_manifest.max_view_label_bytes) orelse {
3716
+ ui_app_log.warn("webview pane '{s}' ignored: more than {d} distinct pane labels", .{ pane.label, max_web_panes });
3717
+ return;
3718
+ };
3719
+ const state = &self.web_pane_states[claimed.index];
3720
+ if (claimed.create) {
3721
+ state.* = .{};
3722
+ @memcpy(state.label_storage[0..claimed.label_bytes], pane.label[0..claimed.label_bytes]);
3723
+ state.label_len = claimed.label_bytes;
3724
+ self.web_pane_state_count += 1;
3725
+ }
3726
+ const actual = runtime.webViewLocalFrame(window_id, pane.label) orelse {
3727
+ ui_app_log.warn("webview pane '{s}': the scene declares no .webview shell view with this label", .{pane.label});
3728
+ return;
3729
+ };
3730
+ const planned_patch = web_pane_policy.patch(policy, actual, planned.value, state.url(), pane.url, state.reload_token, pane.reload_token);
3731
+ if (!planned_patch.frame and !planned_patch.url) return;
3732
+ const patch: platform.ViewPatch = .{ .frame = if (planned_patch.frame) planned.value else null, .url = if (planned_patch.url) pane.url else null };
3733
+ const success = if (runtime.updateView(window_id, pane.label, patch)) |_| true else |err| failed: {
3734
+ ui_app_log.warn("webview pane '{s}' update failed: {s} - the scene must declare a .webview shell view with this label and the URL's origin must be in security.navigation.allowed_origins", .{ pane.label, @errorName(err) });
3735
+ break :failed false;
3736
+ };
3737
+ const bytes = web_pane_policy.commit(policy, success, pane.url.len, state.url_storage.len) orelse return;
3738
+ @memcpy(state.url_storage[0..bytes], pane.url[0..bytes]);
3739
+ state.url_len = bytes;
3740
+ state.reload_token = pane.reload_token;
3741
+ }
3742
+
3743
+ fn applyNativeWebPane(self: *Self, runtime: *Runtime, window_id: platform.WindowId, layout: canvas.WidgetLayoutTree, pane: WebViewPane) void {
3561
3744
  var frame = pane.frame;
3562
3745
  if (pane.anchor) |anchor| {
3563
3746
  frame = webPaneAnchorFrame(layout, anchor) orelse {
@@ -3773,7 +3956,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3773
3956
  const arena = self.markup_arenas[next_index].allocator();
3774
3957
  const owned_source = try arena.dupe(u8, source);
3775
3958
  var diagnostic: canvas.ui_markup.MarkupErrorInfo = .{};
3776
- const document = canvas.ui_markup.resolveImports(arena, "", owned_source, hashing.loader(), &diagnostic) catch |err| {
3959
+ const document = canvas.ui_markup.resolveImportsWithPolicy(self.options.expression_policy, arena, "", owned_source, hashing.loader(), &diagnostic) catch |err| {
3777
3960
  if (self.options.markup_development_policy) |callback| {
3778
3961
  const program = markup_development.reload(callback, 0, true, true, err == error.MarkupSyntax or err == error.MarkupImport, false, self.installed);
3779
3962
  for (program) |byte| switch (@as(markup_development.Action, @enumFromInt(byte))) {
@@ -3790,7 +3973,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3790
3973
  try self.applyRootMarkupProgram(callback, 0, document, arena, next_index, hashing.hasher.final(), "", owned_source, null, 0);
3791
3974
  return;
3792
3975
  }
3793
- const canonical = try canvas.ui_markup.canonicalize(arena, document);
3976
+ const canonical = try canvas.ui_markup.canonicalizeWithPolicy(self.options.expression_policy, arena, document);
3794
3977
  self.adoptMarkupDocument(canonical, next_index, hashing.hasher.final());
3795
3978
  // Embedded resolve: root nodes carry an empty src_path, and
3796
3979
  // imported entries are markup-root-relative (joined onto the
@@ -3803,7 +3986,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3803
3986
  var canonical = document;
3804
3987
  for (program) |byte| switch (@as(markup_development.Action, @enumFromInt(byte))) {
3805
3988
  .end => break,
3806
- .canonicalize => canonical = if (kind == 0) try canvas.ui_markup.canonicalize(arena, document) else canvas.ui_markup.canonicalize(arena, document) catch document,
3989
+ .canonicalize => canonical = if (kind == 0) try canvas.ui_markup.canonicalizeWithPolicy(self.options.expression_policy, arena, document) else canvas.ui_markup.canonicalizeWithPolicy(self.options.expression_policy, arena, document) catch document,
3807
3990
  .adopt_root => self.adoptMarkupDocument(canonical, next_index, hash),
3808
3991
  .provenance => self.commitProvenanceFiles(path, source, kind == 1),
3809
3992
  .rebuild_root => if (runtime) |value| {
@@ -3912,8 +4095,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3912
4095
  /// from the retained table and publish the response artifact.
3913
4096
  /// Setting the runtime's handshake flag tells the dispatcher an
3914
4097
  /// answer landed (its fallback teaches when no app responds).
4098
+ /// The markup files the compiled view just decoded, with the hashes
4099
+ /// of the bytes it was compiled from; edits refuse a file that has
4100
+ /// changed since. The watcher reloads every edit, so the table is
4101
+ /// always watching.
4102
+ fn commitViewSourceFiles(self: *Self) void {
4103
+ self.provenance.resetFiles();
4104
+ self.provenance.watching = true;
4105
+ for (view_reload.view_files[0..view_reload.view_files_len]) |file| {
4106
+ self.provenance.addFile(file.stamped, file.disk, file.hash) catch break;
4107
+ }
4108
+ }
4109
+
3915
4110
  fn handleProvenanceQuery(self: *Self, runtime: *Runtime, query: core.AutomationProvenanceEvent) anyerror!void {
3916
- if (comptime !features.runtime_markup) return;
4111
+ if (comptime !provenance_enabled) return;
3917
4112
  if (!std.mem.eql(u8, query.view_label, self.options.canvas_label)) return;
3918
4113
  const server = runtime.options.automation orelse return;
3919
4114
  var buffer: [4096]u8 = undefined;
@@ -3968,6 +4163,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3968
4163
  // on purpose. Direct stderr is visible in both.
3969
4164
  if (info.path.len > 0) {
3970
4165
  std.debug.print("markup view failed to build ({s}:{d}:{d}): {s}\n", .{ info.path, info.line, info.column, info.message });
4166
+ } else if (view_reload_enabled and info.line == 0 and info.column == 0) {
4167
+ // A view reload refusal has no source location (a
4168
+ // program for another build, for example).
4169
+ std.debug.print("markup view failed to build: {s}\n", .{info.message});
3971
4170
  } else {
3972
4171
  std.debug.print("markup view failed to build ({d}:{d}): {s}\n", .{ info.line, info.column, info.message });
3973
4172
  }
@@ -3987,6 +4186,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3987
4186
  /// once, on first install, and only when something is watchable —
3988
4187
  /// a root watch path with io, or (Debug only) registered fragments.
3989
4188
  fn startMarkupWatch(self: *Self, runtime: *Runtime) void {
4189
+ if (comptime view_reload_enabled) {
4190
+ if (view_reload.installed != null) {
4191
+ runtime.startTimer(markup_watch_timer_id, markup_watch_interval_ns, true) catch {};
4192
+ if (comptime @hasDecl(Runtime, "setMarkupWatchArmed")) runtime.setMarkupWatchArmed(true);
4193
+ return;
4194
+ }
4195
+ }
3990
4196
  if (comptime !features.runtime_markup) return;
3991
4197
  const root_armed = if (self.options.markup) |markup_options|
3992
4198
  markup_options.watch_path != null and markup_options.io != null
@@ -4039,7 +4245,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4039
4245
  // next reload attempt, so this costs nothing durable.
4040
4246
  const scratch_index = slot.arena_index ^ 1;
4041
4247
  _ = slot.arenas[scratch_index].reset(.retain_capacity);
4042
- slot.baseline_hash = embeddedClosureHash(slot.arenas[scratch_index].allocator(), spec.source, spec.sources, self.options.markup_development_policy);
4248
+ slot.baseline_hash = embeddedClosureHash(slot.arenas[scratch_index].allocator(), spec.source, spec.sources, self.options.markup_development_policy, self.options.expression_policy);
4043
4249
  slot.hash = slot.baseline_hash;
4044
4250
  }
4045
4251
  return count > 0;
@@ -4050,13 +4256,13 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4050
4256
  // hashing side effect; the arena resets on the next reload.
4051
4257
  const scratch_index = self.markup_arena_index ^ 1;
4052
4258
  _ = self.markup_arenas[scratch_index].reset(.retain_capacity);
4053
- return embeddedClosureHash(self.markup_arenas[scratch_index].allocator(), markup_options.source, markup_options.sources, self.options.markup_development_policy);
4259
+ return embeddedClosureHash(self.markup_arenas[scratch_index].allocator(), markup_options.source, markup_options.sources, self.options.markup_development_policy, self.options.expression_policy);
4054
4260
  }
4055
4261
 
4056
4262
  /// Hash an embedded source closure exactly like the disk poll
4057
4263
  /// hashes the on-disk one: root bytes plus every loaded file's
4058
4264
  /// root-relative path and bytes, in resolution order.
4059
- fn embeddedClosureHash(arena: std.mem.Allocator, source: []const u8, sources: []const canvas.ui_markup.SourceFile, policy: markup_development.Policy) u64 {
4265
+ fn embeddedClosureHash(arena: std.mem.Allocator, source: []const u8, sources: []const canvas.ui_markup.SourceFile, policy: markup_development.Policy, parser_policy: ?canvas.ui_markup.expr.Policy) u64 {
4060
4266
  if (sources.len == 0) {
4061
4267
  return std.hash.Wyhash.hash(0, source);
4062
4268
  }
@@ -4064,7 +4270,8 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4064
4270
  var hashing = HashingLoader.init(set_loader.loader(), source, "");
4065
4271
  hashing.policy = policy;
4066
4272
  var diagnostic: canvas.ui_markup.MarkupErrorInfo = .{};
4067
- _ = canvas.ui_markup.resolveImports(
4273
+ _ = canvas.ui_markup.resolveImportsWithPolicy(
4274
+ parser_policy,
4068
4275
  arena,
4069
4276
  "",
4070
4277
  source,
@@ -4099,7 +4306,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4099
4306
  hashing.closure = &self.provenance_closure;
4100
4307
  }
4101
4308
  var diagnostic: canvas.ui_markup.MarkupErrorInfo = .{};
4102
- const document = canvas.ui_markup.resolveImports(arena, watch_path, source, hashing.loader(), &diagnostic) catch |err| {
4309
+ const document = canvas.ui_markup.resolveImportsWithPolicy(self.options.expression_policy, arena, watch_path, source, hashing.loader(), &diagnostic) catch |err| {
4103
4310
  const hash = hashing.hasher.final();
4104
4311
  if (self.options.markup_development_policy) |callback| {
4105
4312
  const program = markup_development.reload(callback, 1, hash != self.markup_source_hash, true, err == error.MarkupSyntax or err == error.MarkupImport, false, self.installed);
@@ -4126,7 +4333,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4126
4333
  if (hash == self.markup_source_hash) return;
4127
4334
  // Canonicalize for per-frame cost only; on OOM the raw
4128
4335
  // document builds identically through attrTyped's fallback.
4129
- const canonical = canvas.ui_markup.canonicalize(arena, document) catch document;
4336
+ const canonical = canvas.ui_markup.canonicalizeWithPolicy(self.options.expression_policy, arena, document) catch document;
4130
4337
  self.adoptMarkupDocument(canonical, next_index, hash);
4131
4338
  // Disk resolve: root nodes carry the watch path, and imported
4132
4339
  // entries are already cwd-relative disk paths.
@@ -4134,6 +4341,24 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4134
4341
  if (self.installed) self.rebuild(runtime, window_id) catch {};
4135
4342
  }
4136
4343
 
4344
+ fn pollViewReload(self: *Self, runtime: *Runtime, reload: view_reload.Hook) anyerror!void {
4345
+ var diagnostic: canvas.ui_markup.MarkupErrorInfo = .{};
4346
+ switch (reload.poll(reload.context, &diagnostic)) {
4347
+ .unchanged => {},
4348
+ .failed => self.recordMarkupDiagnostic(diagnostic),
4349
+ .reloaded => {
4350
+ self.markup_diagnostic = null;
4351
+ // A sealed replay starts from the markup the session
4352
+ // launched with, so a session that changed its view
4353
+ // can no longer replay faithfully.
4354
+ if (runtime.options.session_recorder) |recorder| recorder.abandon("the view's markup was reloaded during the session; record again without editing markup to replay it");
4355
+ if (!self.installed) return;
4356
+ try self.rebuild(runtime, self.canvas_window_id);
4357
+ try self.rebuildWindowSlots(runtime);
4358
+ },
4359
+ }
4360
+ }
4361
+
4137
4362
  /// Timer-driven poll of every registered fragment (Debug dev runs
4138
4363
  /// only), riding the same reserved timer as the root watch. Each
4139
4364
  /// fragment's whole import closure is re-resolved and hashed per
@@ -4158,7 +4383,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4158
4383
  var hashing = HashingLoader.init(disk_loader.loader(), source, watch_dir);
4159
4384
  hashing.policy = self.options.markup_development_policy;
4160
4385
  var diagnostic: canvas.ui_markup.MarkupErrorInfo = .{};
4161
- const document = canvas.ui_markup.resolveImports(arena, spec.path, source, hashing.loader(), &diagnostic) catch |err| {
4386
+ const document = canvas.ui_markup.resolveImportsWithPolicy(self.options.expression_policy, arena, spec.path, source, hashing.loader(), &diagnostic) catch |err| {
4162
4387
  const hash = hashing.hasher.final();
4163
4388
  if (self.options.markup_development_policy) |callback| {
4164
4389
  const program = markup_development.reload(callback, 2, hash != slot.hash, true, err == error.MarkupSyntax or err == error.MarkupImport, false, self.installed);
@@ -4184,7 +4409,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4184
4409
  for (program) |byte| switch (@as(markup_development.Action, @enumFromInt(byte))) {
4185
4410
  .end => break,
4186
4411
  .observed_hash => slot.hash = hash,
4187
- .canonicalize => canonical = canvas.ui_markup.canonicalize(arena, document) catch document,
4412
+ .canonicalize => canonical = canvas.ui_markup.canonicalizeWithPolicy(self.options.expression_policy, arena, document) catch document,
4188
4413
  .restore_fragment => slot.document = null,
4189
4414
  .adopt_fragment => slot.document = canonical,
4190
4415
  .switch_arena => slot.arena_index = next_index,
@@ -4204,7 +4429,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4204
4429
  // Canonicalize for per-frame cost only; on OOM the raw
4205
4430
  // document builds identically through attrTyped's
4206
4431
  // fallback.
4207
- slot.document = canvas.ui_markup.canonicalize(arena, document) catch document;
4432
+ slot.document = canvas.ui_markup.canonicalizeWithPolicy(self.options.expression_policy, arena, document) catch document;
4208
4433
  }
4209
4434
  slot.arena_index = next_index;
4210
4435
  // One diagnostic channel, adopt clears it — the root
@@ -4946,6 +5171,9 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4946
5171
 
4947
5172
  fn handleTimer(self: *Self, runtime: *Runtime, timer_event: platform.TimerEvent) anyerror!void {
4948
5173
  if (timer_event.id == markup_watch_timer_id) {
5174
+ if (comptime view_reload_enabled) {
5175
+ if (view_reload.installed) |reload| return self.pollViewReload(runtime, reload);
5176
+ }
4949
5177
  self.pollMarkupWatch(runtime, self.canvas_window_id);
4950
5178
  self.pollFragmentWatch(runtime);
4951
5179
  return;
@@ -6976,6 +7204,11 @@ fn effectsShowWindowByLabel(context: *anyopaque, window_label: []const u8) bool
6976
7204
  return true;
6977
7205
  }
6978
7206
 
7207
+ fn effectsReplayShowWindowByLabel(context: *anyopaque, window_label: []const u8) void {
7208
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
7209
+ runtime.restoreWindowShow(window_label);
7210
+ }
7211
+
6979
7212
  fn effectsSetDockPresence(context: *anyopaque, visible: bool) bool {
6980
7213
  const runtime: *Runtime = @ptrCast(@alignCast(context));
6981
7214
  runtime.options.platform.services.setDockPresence(visible) catch return false;
@@ -7003,6 +7236,16 @@ fn effectsFormatLocalTime(context: *anyopaque, timestamp_ms: i64, style: platfor
7003
7236
  return runtime.formatLocalTime(timestamp_ms, style, buffer);
7004
7237
  }
7005
7238
 
7239
+ fn effectsSendKeyChord(context: *anyopaque, chord: platform.KeyChord) anyerror!void {
7240
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
7241
+ return runtime.sendKeyChord(chord);
7242
+ }
7243
+
7244
+ fn effectsKeyboardInputAccess(context: *anyopaque, prompt: bool) anyerror!platform.KeyboardInputAccess {
7245
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
7246
+ return runtime.keyboardInputAccess(prompt);
7247
+ }
7248
+
7006
7249
  /// The build storage pinned under a presented native context menu:
7007
7250
  /// which canvas's arena pair and which generation (index) of that pair
7008
7251
  /// built the presented tree. The canvas is named by STABLE window