@native-sdk/cli 0.10.0 → 0.11.0

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 (465) hide show
  1. package/README.md +8 -6
  2. package/bin/native.js +2 -1
  3. package/build/app.zig +320 -60
  4. package/build/corewire.zig +53 -0
  5. package/build/test_shards.zig +49 -0
  6. package/build/ts_run.mjs +3 -3
  7. package/build.zig +1818 -87
  8. package/package.json +19 -14
  9. package/packages/core/compile-surface/core.ts +134 -72
  10. package/packages/core/package-lock.json +75 -357
  11. package/packages/core/package.json +25 -4
  12. package/packages/core/scripts/compiler_command.mjs +17 -12
  13. package/packages/core/scripts/compiler_typecheck.mjs +1 -0
  14. package/packages/core/scripts/gen_declarations.mjs +3 -2
  15. package/packages/core/scripts/gen_service_surface.mjs +22 -10
  16. package/packages/core/scripts/install_scriptc.mjs +182 -0
  17. package/packages/core/scripts/invoke_scriptc.mjs +18 -0
  18. package/packages/core/scripts/merge_static_archives.mjs +6 -1
  19. package/packages/core/scripts/npm_static_spike.mjs +2 -2
  20. package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
  21. package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
  22. package/packages/core/scripts/run_library_compiler.mjs +51 -0
  23. package/packages/core/scripts/run_native_tests.mjs +22 -0
  24. package/packages/core/scripts/scriptc-toolchain.json +101 -0
  25. package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
  26. package/packages/core/scripts/stage_external_core.mjs +57 -1
  27. package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
  28. package/packages/core/sdk/bytes.d.ts +2 -0
  29. package/packages/core/sdk/bytes.ts +86 -0
  30. package/packages/core/sdk/core.d.ts +308 -4
  31. package/packages/core/sdk/core.ts +320 -84
  32. package/packages/core/sdk/events.d.ts +247 -0
  33. package/packages/core/sdk/events.ts +230 -2
  34. package/packages/core/sdk/internal/image_identity.d.ts +7 -0
  35. package/packages/core/sdk/internal/image_identity.ts +71 -0
  36. package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
  37. package/packages/core/sdk/internal/markdown_policy.ts +878 -0
  38. package/packages/core/sdk/text.d.ts +27 -0
  39. package/packages/core/sdk/text.ts +206 -15
  40. package/packages/core/sdk/theme.d.ts +251 -0
  41. package/packages/core/sdk/theme.ts +267 -0
  42. package/packages/core/src/authorization.ts +137 -0
  43. package/packages/core/src/automation_commands.ts +201 -0
  44. package/packages/core/src/automation_interactions.ts +92 -0
  45. package/packages/core/src/bridge_descriptors.ts +104 -0
  46. package/packages/core/src/builtin_coordination.ts +172 -0
  47. package/packages/core/src/canvas_frame_coordination.ts +81 -0
  48. package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
  49. package/packages/core/src/canvas_scene_observation.ts +145 -0
  50. package/packages/core/src/chart_content.ts +161 -0
  51. package/packages/core/src/chart_plans.ts +432 -0
  52. package/packages/core/src/checker.ts +166 -19
  53. package/packages/core/src/code_content.ts +580 -0
  54. package/packages/core/src/command_coordination.ts +140 -0
  55. package/packages/core/src/component_composition.ts +94 -0
  56. package/packages/core/src/component_construction.ts +149 -0
  57. package/packages/core/src/contract.ts +25 -7
  58. package/packages/core/src/control_appearance.ts +232 -0
  59. package/packages/core/src/control_commands.ts +115 -0
  60. package/packages/core/src/control_content.ts +105 -0
  61. package/packages/core/src/control_geometry.ts +107 -0
  62. package/packages/core/src/control_payloads.ts +119 -0
  63. package/packages/core/src/control_primitives.ts +134 -0
  64. package/packages/core/src/devhost.ts +82 -7
  65. package/packages/core/src/devhost_journal.mjs +30 -7
  66. package/packages/core/src/effect_plans.ts +71 -0
  67. package/packages/core/src/flow_measurement.ts +121 -0
  68. package/packages/core/src/font_registry.ts +37 -0
  69. package/packages/core/src/glyph_atlas.ts +86 -0
  70. package/packages/core/src/gpu_packet_preparation.ts +130 -0
  71. package/packages/core/src/gpu_planning.ts +123 -0
  72. package/packages/core/src/gpu_presentation.ts +55 -0
  73. package/packages/core/src/host_flow.ts +89 -0
  74. package/packages/core/src/host_input_regions.ts +165 -0
  75. package/packages/core/src/image_registry.ts +66 -0
  76. package/packages/core/src/indicator_plans.ts +132 -0
  77. package/packages/core/src/infer.ts +150 -8
  78. package/packages/core/src/input_composition.ts +116 -0
  79. package/packages/core/src/intrinsic_measure.ts +100 -0
  80. package/packages/core/src/layout_coordination.ts +207 -0
  81. package/packages/core/src/leaf_plans.ts +134 -0
  82. package/packages/core/src/markup_development.ts +160 -0
  83. package/packages/core/src/measurement_coordination.ts +185 -0
  84. package/packages/core/src/modules.ts +1 -1
  85. package/packages/core/src/motion_sampling.ts +100 -0
  86. package/packages/core/src/paragraph_layout.ts +192 -0
  87. package/packages/core/src/portable_sources.json +74 -0
  88. package/packages/core/src/portable_sources.ts +17 -0
  89. package/packages/core/src/registered_font.ts +93 -0
  90. package/packages/core/src/render_animation_lifecycle.ts +128 -0
  91. package/packages/core/src/render_coordination.ts +170 -0
  92. package/packages/core/src/render_resources.ts +234 -0
  93. package/packages/core/src/runtime_policy.ts +3930 -0
  94. package/packages/core/src/scalar_text.ts +84 -0
  95. package/packages/core/src/service_contract.ts +2 -1
  96. package/packages/core/src/session_codecs.ts +309 -0
  97. package/packages/core/src/shell_admission.ts +126 -0
  98. package/packages/core/src/shell_coordination.ts +93 -0
  99. package/packages/core/src/sqlite_cli.ts +11 -0
  100. package/packages/core/src/status_validation.ts +232 -0
  101. package/packages/core/src/stream_policy.ts +63 -0
  102. package/packages/core/src/surface_recipes.ts +136 -0
  103. package/packages/core/src/system_admission.ts +60 -0
  104. package/packages/core/src/terminal_paint.ts +436 -0
  105. package/packages/core/src/text_document_width.ts +81 -0
  106. package/packages/core/src/text_measurement_cache.ts +69 -0
  107. package/packages/core/src/text_query_layout.ts +179 -0
  108. package/packages/core/src/text_run_layout.ts +410 -0
  109. package/packages/core/src/text_span_queries.ts +355 -0
  110. package/packages/core/src/typed_ast.ts +18 -1
  111. package/packages/core/src/types.ts +7 -5
  112. package/packages/core/src/vector_effects.ts +98 -0
  113. package/packages/core/src/vector_raster.ts +243 -0
  114. package/packages/core/src/view_components.ts +2415 -0
  115. package/packages/core/src/view_coordination.ts +198 -0
  116. package/packages/core/src/view_frontend.ts +980 -0
  117. package/packages/core/src/widget_audits.ts +202 -0
  118. package/packages/core/src/widget_changes.ts +258 -0
  119. package/packages/core/src/widget_metrics.ts +139 -0
  120. package/packages/core/src/widget_motion.ts +171 -0
  121. package/packages/core/src/widget_paint.ts +272 -0
  122. package/packages/core/src/widget_paint_walk.ts +203 -0
  123. package/packages/core/src/widget_presentation.ts +141 -0
  124. package/packages/core/src/widget_routing.ts +262 -0
  125. package/packages/core/src/window_lifecycle.ts +92 -0
  126. package/packages/core/testing/index.ts +430 -0
  127. package/schemas/app.schema.json +13 -0
  128. package/skill-data/core/SKILL.md +2 -2
  129. package/skill-data/core/references/web-engines-packaging-debugging.md +2 -1
  130. package/skill-data/native-ui/SKILL.md +76 -17
  131. package/skill-data/ts-core/SKILL.md +113 -9
  132. package/skill-data/ts-services/SKILL.md +1 -1
  133. package/skill-data/ts-services/references/service-surface.md +264 -144
  134. package/src/app_runner/root.zig +25 -12
  135. package/src/app_runner/ts_compiled_view.zig +1631 -0
  136. package/src/app_runner/ts_core_main.zig +143 -10
  137. package/src/app_runner/ts_core_mobile.zig +24 -12
  138. package/src/automation/server.zig +1 -3
  139. package/src/automation/snapshot.zig +9 -637
  140. package/src/automation/snapshot_reference.zig +656 -0
  141. package/src/automation/snapshot_serialization.zig +566 -0
  142. package/src/platform/linux/gtk_host.c +36 -24
  143. package/src/platform/linux/gtk_pixels.h +118 -0
  144. package/src/platform/linux/gtk_pixels_test.c +241 -0
  145. package/src/platform/linux/root.zig +2 -0
  146. package/src/platform/macos/appkit_host.m +188 -30
  147. package/src/platform/macos/pointer_motion_test.m +96 -0
  148. package/src/platform/macos/scroll_driver_test.m +105 -0
  149. package/src/platform/macos/spectrum_bins.h +34 -0
  150. package/src/platform/macos/spectrum_bins_test.c +56 -0
  151. package/src/platform/macos/text_keyboard_test.m +80 -0
  152. package/src/platform/macos/widget_focus_test.m +66 -0
  153. package/src/platform/null_platform.zig +26 -2
  154. package/src/platform/null_platform_tests.zig +13 -0
  155. package/src/platform/root.zig +1 -0
  156. package/src/platform/types.zig +13 -0
  157. package/src/platform/windows/root.zig +2 -0
  158. package/src/platform/windows/webview2_host.cpp +7 -2
  159. package/src/primitives/app_manifest/comptime_scene.zig +1 -1
  160. package/src/primitives/app_manifest/root.zig +2 -0
  161. package/src/primitives/app_manifest/tests.zig +4 -1
  162. package/src/primitives/app_manifest/validation.zig +2 -0
  163. package/src/primitives/canvas/a11y_audit.zig +3 -1
  164. package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
  165. package/src/primitives/canvas/chart_content_policy.zig +75 -0
  166. package/src/primitives/canvas/chart_plan_policy.zig +196 -0
  167. package/src/primitives/canvas/code_content_policy.zig +162 -0
  168. package/src/primitives/canvas/commands.zig +29 -1
  169. package/src/primitives/canvas/component_composition.zig +125 -0
  170. package/src/primitives/canvas/component_composition_policy.zig +44 -0
  171. package/src/primitives/canvas/component_construction_policy.zig +187 -0
  172. package/src/primitives/canvas/container_layout_policy.zig +87 -0
  173. package/src/primitives/canvas/control_appearance_policy.zig +142 -0
  174. package/src/primitives/canvas/control_command_policy.zig +75 -0
  175. package/src/primitives/canvas/control_content_policy.zig +90 -0
  176. package/src/primitives/canvas/control_geometry_policy.zig +165 -0
  177. package/src/primitives/canvas/control_payload_policy.zig +48 -0
  178. package/src/primitives/canvas/control_primitive_policy.zig +129 -0
  179. package/src/primitives/canvas/effect_plan_policy.zig +96 -0
  180. package/src/primitives/canvas/events.zig +1027 -1
  181. package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
  182. package/src/primitives/canvas/frame.zig +92 -23
  183. package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
  184. package/src/primitives/canvas/gpu.zig +10 -0
  185. package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
  186. package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
  187. package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
  188. package/src/primitives/canvas/grid_layout_policy.zig +51 -0
  189. package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
  190. package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
  191. package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
  192. package/src/primitives/canvas/layout_audit.zig +5 -2
  193. package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
  194. package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
  195. package/src/primitives/canvas/markdown.zig +13 -3
  196. package/src/primitives/canvas/markdown_content_policy.zig +227 -0
  197. package/src/primitives/canvas/markdown_image_binding.zig +81 -0
  198. package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
  199. package/src/primitives/canvas/numeric_capabilities.zig +14 -0
  200. package/src/primitives/canvas/reference.zig +12 -6
  201. package/src/primitives/canvas/registered_font_policy.zig +152 -0
  202. package/src/primitives/canvas/render.zig +48 -0
  203. package/src/primitives/canvas/render_cache_policy.zig +184 -0
  204. package/src/primitives/canvas/render_coordination_policy.zig +163 -0
  205. package/src/primitives/canvas/render_damage_policy.zig +160 -0
  206. package/src/primitives/canvas/render_effects.zig +14 -0
  207. package/src/primitives/canvas/render_generic_resources.zig +14 -0
  208. package/src/primitives/canvas/render_images.zig +14 -0
  209. package/src/primitives/canvas/render_layers.zig +14 -0
  210. package/src/primitives/canvas/render_override_policy.zig +119 -0
  211. package/src/primitives/canvas/render_paths.zig +14 -0
  212. package/src/primitives/canvas/render_plan_policy.zig +199 -0
  213. package/src/primitives/canvas/render_resource_policy.zig +476 -0
  214. package/src/primitives/canvas/root.zig +100 -0
  215. package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
  216. package/src/primitives/canvas/serialization.zig +8 -1
  217. package/src/primitives/canvas/surface_layout_policy.zig +36 -0
  218. package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
  219. package/src/primitives/canvas/terminal_grid.zig +10 -696
  220. package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
  221. package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
  222. package/src/primitives/canvas/text.zig +1 -0
  223. package/src/primitives/canvas/text_atlas.zig +113 -0
  224. package/src/primitives/canvas/text_cache_policy.zig +94 -0
  225. package/src/primitives/canvas/text_document_policy.zig +120 -0
  226. package/src/primitives/canvas/text_layout.zig +51 -2
  227. package/src/primitives/canvas/text_layout_cache.zig +29 -0
  228. package/src/primitives/canvas/text_layout_hash.zig +1 -0
  229. package/src/primitives/canvas/text_layout_types.zig +3 -0
  230. package/src/primitives/canvas/text_measure_cache.zig +46 -0
  231. package/src/primitives/canvas/text_measurement_policy.zig +124 -0
  232. package/src/primitives/canvas/text_metrics.zig +23 -0
  233. package/src/primitives/canvas/text_query_policy.zig +156 -0
  234. package/src/primitives/canvas/text_run_policy.zig +252 -0
  235. package/src/primitives/canvas/text_scalar_policy.zig +156 -0
  236. package/src/primitives/canvas/text_span_query_policy.zig +232 -0
  237. package/src/primitives/canvas/text_spans.zig +280 -8
  238. package/src/primitives/canvas/text_tests.zig +10 -0
  239. package/src/primitives/canvas/tokens.zig +38 -0
  240. package/src/primitives/canvas/ui.zig +250 -83
  241. package/src/primitives/canvas/ui_markup.zig +139 -33
  242. package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
  243. package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
  244. package/src/primitives/canvas/ui_markup_contract.zig +146 -14
  245. package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
  246. package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
  247. package/src/primitives/canvas/ui_markup_tests.zig +116 -0
  248. package/src/primitives/canvas/ui_markup_view.zig +258 -32
  249. package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
  250. package/src/primitives/canvas/ui_schema.zig +13 -1
  251. package/src/primitives/canvas/ui_schema_tests.zig +11 -7
  252. package/src/primitives/canvas/ui_tests.zig +1 -0
  253. package/src/primitives/canvas/vector.zig +36 -2
  254. package/src/primitives/canvas/vector_effect_policy.zig +236 -0
  255. package/src/primitives/canvas/vector_raster_policy.zig +190 -0
  256. package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
  257. package/src/primitives/canvas/virtual_extents.zig +99 -3
  258. package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
  259. package/src/primitives/canvas/widget_audit_policy.zig +293 -0
  260. package/src/primitives/canvas/widget_change_policy.zig +298 -0
  261. package/src/primitives/canvas/widget_invalidation.zig +113 -2
  262. package/src/primitives/canvas/widget_layout.zig +673 -128
  263. package/src/primitives/canvas/widget_layout_tests.zig +4 -0
  264. package/src/primitives/canvas/widget_metric_policy.zig +126 -0
  265. package/src/primitives/canvas/widget_metrics.zig +45 -6
  266. package/src/primitives/canvas/widget_paint_policy.zig +166 -0
  267. package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
  268. package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
  269. package/src/primitives/canvas/widget_render.zig +744 -74
  270. package/src/primitives/canvas/widget_render_controls.zig +1217 -133
  271. package/src/primitives/canvas/widget_render_scroll.zig +11 -3
  272. package/src/primitives/canvas/widget_render_style.zig +94 -0
  273. package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
  274. package/src/primitives/canvas/widget_routing.zig +75 -0
  275. package/src/primitives/canvas/widget_routing_policy.zig +135 -0
  276. package/src/primitives/canvas/widget_runtime.zig +20 -1
  277. package/src/primitives/canvas/widget_semantics.zig +25 -0
  278. package/src/primitives/canvas/widget_text_input.zig +86 -23
  279. package/src/primitives/canvas/widget_text_select.zig +1 -0
  280. package/src/primitives/canvas/widget_tree.zig +8 -1
  281. package/src/primitives/canvas/widgets.zig +42 -12
  282. package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
  283. package/src/root.zig +21 -0
  284. package/src/runtime/accessibility_policy.zig +122 -0
  285. package/src/runtime/api.zig +28 -0
  286. package/src/runtime/app_dispatch_policy.zig +68 -0
  287. package/src/runtime/authorization_policy.zig +150 -0
  288. package/src/runtime/automation_command_policy.zig +241 -0
  289. package/src/runtime/automation_interaction_policy.zig +107 -0
  290. package/src/runtime/automation_snapshot.zig +52 -22
  291. package/src/runtime/automation_snapshot_reference.zig +290 -0
  292. package/src/runtime/automation_widget_dispatch.zig +267 -355
  293. package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
  294. package/src/runtime/blob_policy.zig +58 -0
  295. package/src/runtime/blob_reference.zig +64 -0
  296. package/src/runtime/bridge_descriptor_policy.zig +206 -0
  297. package/src/runtime/builtin_bridge.zig +180 -44
  298. package/src/runtime/builtin_coordination_policy.zig +121 -0
  299. package/src/runtime/callback_policy_test_reference.zig +97 -0
  300. package/src/runtime/canvas_drag_policy.zig +94 -0
  301. package/src/runtime/canvas_fonts.zig +38 -10
  302. package/src/runtime/canvas_frame.zig +590 -134
  303. package/src/runtime/canvas_frame_helpers.zig +1 -0
  304. package/src/runtime/canvas_hover_policy.zig +131 -0
  305. package/src/runtime/canvas_images.zig +59 -30
  306. package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
  307. package/src/runtime/canvas_limits.zig +1 -1
  308. package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
  309. package/src/runtime/canvas_scene_observation_policy.zig +181 -0
  310. package/src/runtime/canvas_widget_context_menu.zig +4 -4
  311. package/src/runtime/canvas_widget_display.zig +110 -9
  312. package/src/runtime/canvas_widget_events.zig +718 -328
  313. package/src/runtime/canvas_widget_runtime.zig +437 -81
  314. package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
  315. package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
  316. package/src/runtime/canvas_widget_state.zig +93 -56
  317. package/src/runtime/channel_sources.zig +80 -0
  318. package/src/runtime/command_policy.zig +161 -0
  319. package/src/runtime/component_policy.zig +83 -0
  320. package/src/runtime/core.zig +156 -6
  321. package/src/runtime/desktop_files.zig +189 -0
  322. package/src/runtime/effects.zig +466 -29
  323. package/src/runtime/effects_tests.zig +28 -0
  324. package/src/runtime/file_policy_test_reference.zig +113 -0
  325. package/src/runtime/flow.zig +418 -341
  326. package/src/runtime/flow_reference.zig +1426 -0
  327. package/src/runtime/font_registry_policy.zig +72 -0
  328. package/src/runtime/frame_profile.zig +24 -33
  329. package/src/runtime/gpu_surface_events.zig +97 -35
  330. package/src/runtime/host_event_pump.zig +303 -0
  331. package/src/runtime/host_event_pump_reference.zig +268 -0
  332. package/src/runtime/host_flow_policy.zig +155 -0
  333. package/src/runtime/host_input_regions_policy.zig +156 -0
  334. package/src/runtime/image_registry_policy.zig +94 -0
  335. package/src/runtime/input_composition_policy.zig +138 -0
  336. package/src/runtime/journal_policy.zig +66 -0
  337. package/src/runtime/journal_reference.zig +53 -0
  338. package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
  339. package/src/runtime/markup_development_policy.zig +91 -0
  340. package/src/runtime/media_surface.zig +40 -1
  341. package/src/runtime/motion_sampling_policy.zig +159 -0
  342. package/src/runtime/recording_policy.zig +42 -0
  343. package/src/runtime/render_animation_policy.zig +206 -0
  344. package/src/runtime/replay_policy.zig +66 -0
  345. package/src/runtime/replay_policy_reference.zig +326 -0
  346. package/src/runtime/replay_progress_policy.zig +64 -0
  347. package/src/runtime/replay_progress_reference.zig +34 -0
  348. package/src/runtime/request_policy_test_reference.zig +188 -0
  349. package/src/runtime/root.zig +13 -0
  350. package/src/runtime/session_blobs.zig +157 -58
  351. package/src/runtime/session_blobs_reference.zig +692 -0
  352. package/src/runtime/session_codec.zig +361 -0
  353. package/src/runtime/session_codec_reference.zig +1027 -0
  354. package/src/runtime/session_journal.zig +246 -983
  355. package/src/runtime/session_record.zig +224 -45
  356. package/src/runtime/session_replay.zig +157 -415
  357. package/src/runtime/session_tests.zig +552 -0
  358. package/src/runtime/shell_admission_policy.zig +225 -0
  359. package/src/runtime/shell_coordination_policy.zig +138 -0
  360. package/src/runtime/shell_layout.zig +126 -1
  361. package/src/runtime/snapshot_policy.zig +60 -0
  362. package/src/runtime/snapshot_reference.zig +64 -0
  363. package/src/runtime/state.zig +16 -0
  364. package/src/runtime/status_validation.zig +190 -0
  365. package/src/runtime/system_admission_policy.zig +140 -0
  366. package/src/runtime/system_services.zig +46 -36
  367. package/src/runtime/tests.zig +1 -0
  368. package/src/runtime/ts_canvas_hooks.zig +261 -0
  369. package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
  370. package/src/runtime/ts_canvas_icons.zig +234 -0
  371. package/src/runtime/ts_core_host.zig +2325 -411
  372. package/src/runtime/ts_core_host_tests.zig +1982 -0
  373. package/src/runtime/ts_test_host.zig +699 -0
  374. package/src/runtime/ts_ui_app.zig +1087 -45
  375. package/src/runtime/ui_app.zig +1117 -629
  376. package/src/runtime/ui_app_provenance.zig +147 -5
  377. package/src/runtime/ui_app_provenance_reference.zig +370 -0
  378. package/src/runtime/ui_app_tests.zig +619 -9
  379. package/src/runtime/ui_app_window_tests.zig +89 -0
  380. package/src/runtime/view.zig +25 -0
  381. package/src/runtime/view_canvas.zig +30 -6
  382. package/src/runtime/view_coordination_policy.zig +147 -0
  383. package/src/runtime/view_widget_control.zig +51 -14
  384. package/src/runtime/view_widget_scroll.zig +16 -5
  385. package/src/runtime/view_widget_text.zig +153 -68
  386. package/src/runtime/view_widget_tree.zig +460 -56
  387. package/src/runtime/webview_view_bridge_tests.zig +2 -0
  388. package/src/runtime/widget_motion_policy.zig +238 -0
  389. package/src/runtime/window_command_bridge_tests.zig +63 -0
  390. package/src/runtime/window_lifecycle_policy.zig +127 -0
  391. package/src/runtime/window_storage.zig +74 -8
  392. package/src/runtime/window_view_runtime.zig +148 -33
  393. package/src/runtime/window_views.zig +163 -10
  394. package/src/tooling/codesign.zig +125 -74
  395. package/src/tooling/components/identity_tests.zig +62 -36
  396. package/src/tooling/components/stepper.native +24 -0
  397. package/src/tooling/components/stepper.zig +0 -19
  398. package/src/tooling/components/timeline-item.native +22 -0
  399. package/src/tooling/components/timeline.native +5 -3
  400. package/src/tooling/components/timeline_item.zig +0 -32
  401. package/src/tooling/eject_components.zig +76 -8
  402. package/src/tooling/ios.zig +66 -12
  403. package/src/tooling/manifest.zig +35 -0
  404. package/src/tooling/package.zig +85 -1
  405. package/src/tooling/raw_manifest.zig +6 -0
  406. package/src/tooling/templates.zig +15 -3
  407. package/src/tooling/ts_core.zig +13 -3
  408. package/src/tooling/verbs.zig +22 -0
  409. package/tools/corewire/build_profile.mjs +54 -0
  410. package/tools/corewire/contract_intake.ts +303 -0
  411. package/tools/corewire/contract_intake.zig +82 -0
  412. package/tools/corewire/core.test.ts +166 -0
  413. package/tools/corewire/core_abi.zig +51 -0
  414. package/tools/corewire/core_cases.ts +233 -0
  415. package/tools/corewire/core_contract.ts +407 -0
  416. package/tools/corewire/core_emission.ts +136 -0
  417. package/tools/corewire/core_emission.zig +69 -0
  418. package/tools/corewire/core_goldens.json +3110 -0
  419. package/tools/corewire/core_policy.ts +14 -0
  420. package/tools/corewire/core_policy.zig +48 -0
  421. package/tools/corewire/core_projection.ts +360 -0
  422. package/tools/corewire/core_vocabulary.ts +6 -0
  423. package/tools/corewire/emit.zig +19 -1590
  424. package/tools/corewire/emit_facade.ts +714 -0
  425. package/tools/corewire/emit_facade.zig +10 -3752
  426. package/tools/corewire/emit_mirror.ts +290 -0
  427. package/tools/corewire/emit_profile.ts +50 -0
  428. package/tools/corewire/emit_service.ts +331 -0
  429. package/tools/corewire/emit_service.zig +23 -842
  430. package/tools/corewire/entry.test.ts +95 -0
  431. package/tools/corewire/entry_coordination.ts +127 -0
  432. package/tools/corewire/entry_coordination.zig +190 -0
  433. package/tools/corewire/facade_templates.ts +85 -0
  434. package/tools/corewire/filesystem.test.ts +166 -0
  435. package/tools/corewire/filesystem_coordination.ts +213 -0
  436. package/tools/corewire/filesystem_coordination.zig +245 -0
  437. package/tools/corewire/intake.test.ts +35 -0
  438. package/tools/corewire/intake_cases.ts +55 -0
  439. package/tools/corewire/intake_goldens.json +12237 -0
  440. package/tools/corewire/invocation.test.ts +24 -0
  441. package/tools/corewire/invocation.ts +175 -0
  442. package/tools/corewire/invocation.zig +136 -0
  443. package/tools/corewire/invocation_cases.ts +60 -0
  444. package/tools/corewire/invocation_fixture.ts +33 -0
  445. package/tools/corewire/invocation_goldens.json +1143 -0
  446. package/tools/corewire/invocation_tests.zig +111 -0
  447. package/tools/corewire/invocation_usage.ts +2 -0
  448. package/tools/corewire/lossless_projection.ts +96 -0
  449. package/tools/corewire/main.zig +7 -680
  450. package/tools/corewire/main_reference.zig +415 -0
  451. package/tools/corewire/mirror_templates.ts +55 -0
  452. package/tools/corewire/profile.test.ts +248 -0
  453. package/tools/corewire/profile.zig +56 -0
  454. package/tools/corewire/profile_emission.ts +202 -0
  455. package/tools/corewire/profile_library.json +29 -0
  456. package/tools/corewire/profile_tests.zig +136 -0
  457. package/tools/corewire/service.test.ts +75 -0
  458. package/tools/corewire/service_cases.ts +61 -0
  459. package/tools/corewire/service_contract.zig +40 -146
  460. package/tools/corewire/service_goldens.json +650 -0
  461. package/tools/corewire/service_projection.zig +52 -0
  462. package/tools/corewire/service_templates.ts +14 -0
  463. package/tools/corewire/shim_rt.zig +9 -0
  464. package/tools/corewire/sidecar.zig +267 -1438
  465. package/tools/corewire/emit_profile.zig +0 -521
@@ -216,6 +216,24 @@ test "markup view builds the same tree as the hand-written view" {
216
216
  );
217
217
  }
218
218
 
219
+ test "digit-only text attributes stay text while numeric attributes stay numeric" {
220
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
221
+ defer arena_state.deinit();
222
+ const arena = arena_state.allocator();
223
+
224
+ var view = try InboxMarkup.init(
225
+ arena,
226
+ "<column padding=\"8\">\n <text-field placeholder=\"123\" label=\"456\" />\n</column>",
227
+ );
228
+ var ui = InboxUi.init(arena);
229
+ const tree = try ui.finalize(try view.build(&ui, &Model{}));
230
+ const field = findByKind(tree.root, .text_field).?;
231
+
232
+ try testing.expectEqualStrings("123", field.placeholder);
233
+ try testing.expectEqualStrings("456", field.semantics.label);
234
+ try testing.expectEqual(@as(f32, 8), tree.root.layout.padding.top);
235
+ }
236
+
219
237
  test "markup keyed rows keep ids across model changes and filters dispatch" {
220
238
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
221
239
  defer arena_state.deinit();
@@ -421,6 +439,85 @@ test "style token references resolve against tokens at finalize time" {
421
439
  try testing.expectEqual(light_badge.id, dark_badge.id);
422
440
  }
423
441
 
442
+ test "markup radius none resolves to square button corners" {
443
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
444
+ defer arena_state.deinit();
445
+ const arena = arena_state.allocator();
446
+ const model = Model{};
447
+
448
+ var view = try InboxMarkup.init(arena, "<button radius=\"none\" on-press=\"add\">Square</button>");
449
+ var ui = InboxUi.init(arena);
450
+ const custom_tokens = canvas.DesignTokens{ .radius = .{ .none = 8 } };
451
+ const tree = try ui.finalizeWithTokens(try view.build(&ui, &model), custom_tokens);
452
+ try testing.expectEqual(@as(f32, 0), tree.root.style.radius.?);
453
+
454
+ var button = tree.root;
455
+ button.frame = geometry.RectF.init(0, 0, 120, 36);
456
+ button.state.focused = true;
457
+ var commands: [4]canvas.CanvasCommand = undefined;
458
+ var builder = canvas.Builder.init(&commands);
459
+ try canvas.emitWidgetTree(&builder, button, .{});
460
+ switch (builder.displayList().commands[0]) {
461
+ .fill_rounded_rect => |fill| try testing.expectEqualDeep(canvas.Radius.all(0), fill.radius),
462
+ else => return error.TestUnexpectedResult,
463
+ }
464
+ switch (builder.displayList().commands[2]) {
465
+ .stroke_rect => |ring| try testing.expectEqualDeep(canvas.Radius.all(2), ring.radius),
466
+ else => return error.TestUnexpectedResult,
467
+ }
468
+ }
469
+
470
+ test "markup radius none keeps a surface content clip square" {
471
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
472
+ defer arena_state.deinit();
473
+ const arena = arena_state.allocator();
474
+ const model = Model{};
475
+
476
+ var view = try InboxMarkup.init(arena, "<panel radius=\"none\"><row background=\"accent\" /></panel>");
477
+ var ui = InboxUi.init(arena);
478
+ const tree = try ui.finalize(try view.build(&ui, &model));
479
+ try testing.expectEqual(@as(f32, 0), tree.root.style.radius.?);
480
+
481
+ // Give the child the entire panel frame: this is the full-bleed case
482
+ // where the content clip, rather than layout padding, owns the corners.
483
+ var panel = tree.root;
484
+ panel.frame = geometry.RectF.init(0, 0, 120, 72);
485
+ panel.layout.clip_content = true;
486
+ var children = [_]canvas.Widget{panel.children[0]};
487
+ children[0].frame = panel.frame;
488
+ panel.children = &children;
489
+
490
+ var commands: [8]canvas.CanvasCommand = undefined;
491
+ var builder = canvas.Builder.init(&commands);
492
+ try canvas.emitWidgetTree(&builder, panel, .{});
493
+
494
+ var saw_panel_chrome = false;
495
+ var saw_content_clip = false;
496
+ var saw_full_bleed_child = false;
497
+ for (builder.displayList().commands) |command| {
498
+ switch (command) {
499
+ .fill_rounded_rect => |fill| {
500
+ if (fill.id == canvas.widgetPartId(panel.id, 2)) {
501
+ try testing.expectEqualDeep(canvas.Radius.all(0), fill.radius);
502
+ saw_panel_chrome = true;
503
+ }
504
+ if (fill.id == canvas.widgetPartId(children[0].id, 1)) {
505
+ try testing.expectEqualDeep(panel.frame, fill.rect);
506
+ saw_full_bleed_child = true;
507
+ }
508
+ },
509
+ .push_clip => |clip| if (clip.id == canvas.widgetPartId(panel.id, 9)) {
510
+ try testing.expectEqualDeep(canvas.Radius.all(0), clip.radius);
511
+ saw_content_clip = true;
512
+ },
513
+ else => {},
514
+ }
515
+ }
516
+ try testing.expect(saw_panel_chrome);
517
+ try testing.expect(saw_content_clip);
518
+ try testing.expect(saw_full_bleed_child);
519
+ }
520
+
424
521
  test "explicit style values win over token references" {
425
522
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
426
523
  defer arena_state.deinit();
@@ -1354,6 +1451,7 @@ test "the registry's attr value classes match the ElementOptions field types" {
1354
1451
  .optional => |optional| switch (@typeInfo(optional.child)) {
1355
1452
  .bool => .truthy,
1356
1453
  .float => .number,
1454
+ .@"enum" => .option,
1357
1455
  else => unreachable,
1358
1456
  },
1359
1457
  .@"enum" => .option,
@@ -1518,20 +1616,13 @@ test "the registry's takes-children predicate matches the interpreter's takes-ch
1518
1616
  }
1519
1617
  }
1520
1618
 
1521
- /// Widget kinds deliberately NOT expressible in markup v1 — each needs
1522
- /// something the closed grammar cannot carry, so these are written as Zig
1523
- /// view functions instead of forcing a bad markup shape:
1524
- /// - image, icon_button: reference image assets by runtime ImageId,
1525
- /// which markup's literal/binding attribute values cannot express.
1526
- /// (icon IS expressible: the built-in vector set is a closed literal
1527
- /// vocabulary, comptime-validated.)
1619
+ /// Widget kinds deliberately NOT expressible as direct markup leaves —
1620
+ /// each is either a composite form or awaits a separate admission:
1528
1621
  /// - data_grid: a virtualized data grid needs per-column cell templates
1529
1622
  /// (arbitrary render callbacks).
1530
1623
  /// - popover, menu_surface: floating surfaces anchored to runtime geometry
1531
1624
  /// the static tree cannot express (dropdown-menu covers the declarative
1532
1625
  /// menu case).
1533
- /// - segmented_control: engine kind for shell chrome segments; tabs and
1534
- /// toggle-group cover the component catalog's use cases.
1535
1626
  /// - chart: expressible as the `<chart>` COMPOSITE (series children whose
1536
1627
  /// values bind model f32 iterables, lowered through `Ui.chart`), so no
1537
1628
  /// plain element maps to the kind here — like the other composites, the
@@ -1544,9 +1635,24 @@ test "the registry's takes-children predicate matches the interpreter's takes-ch
1544
1635
  /// lowered through `Ui.inputGroup`), so no plain element maps to the
1545
1636
  /// kind here — like chart, the bespoke builder is the channel.
1546
1637
  const markup_excluded_widget_kinds = [_]canvas.WidgetKind{
1547
- .icon_button, .data_grid, .popover, .menu_surface, .segmented_control, .chart, .split_divider, .input_group,
1638
+ .icon_button, .chart, .split_divider, .input_group,
1548
1639
  };
1549
1640
 
1641
+ pub const SegmentedModel = struct {
1642
+ mode: u8 = 1,
1643
+ };
1644
+ pub const SegmentedMsg = union(enum) { choose };
1645
+ pub const SegmentedUi = canvas.Ui(SegmentedMsg);
1646
+ const SegmentedMarkup = markup_view.MarkupView(SegmentedModel, SegmentedMsg);
1647
+
1648
+ pub const segmented_markup_source =
1649
+ \\<column gap="8">
1650
+ \\ <segmented-control selected="{mode == 0}" on-press="choose">List</segmented-control>
1651
+ \\ <segmented-control selected="{mode == 1}" icon="settings" on-press="choose">Grid</segmented-control>
1652
+ \\ <button size="icon" icon="settings" label="Preview" on-press="choose" />
1653
+ \\</column>
1654
+ ;
1655
+
1550
1656
  fn kindExpressible(kind: canvas.WidgetKind) bool {
1551
1657
  for (canvas.ui_markup.known_element_names) |name| {
1552
1658
  if (markup_view.elementKind(name) == kind) return true;
@@ -1563,6 +1669,32 @@ test "known_element_names covers every markup-expressible widget kind" {
1563
1669
  }
1564
1670
  }
1565
1671
 
1672
+ test "segmented-control and vector icon button build and dispatch" {
1673
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
1674
+ defer arena_state.deinit();
1675
+ const arena = arena_state.allocator();
1676
+ var parser = canvas.ui_markup.Parser.init(arena, segmented_markup_source);
1677
+ try testing.expectEqual(@as(?canvas.ui_markup.MarkupErrorInfo, null), canvas.ui_markup.validate(try parser.parse()));
1678
+
1679
+ const model = SegmentedModel{};
1680
+ var view = try SegmentedMarkup.init(arena, segmented_markup_source);
1681
+ var ui = SegmentedUi.init(arena);
1682
+ const tree = try ui.finalize(try view.build(&ui, &model));
1683
+ const list = tree.root.children[0];
1684
+ const grid = tree.root.children[1];
1685
+ const preview = tree.root.children[2];
1686
+ try testing.expectEqual(canvas.WidgetKind.segmented_control, list.kind);
1687
+ try testing.expectEqual(canvas.WidgetKind.segmented_control, grid.kind);
1688
+ try testing.expect(!list.state.selected);
1689
+ try testing.expect(grid.state.selected);
1690
+ try testing.expectEqualStrings("settings", grid.icon);
1691
+ try testing.expectEqual(SegmentedMsg.choose, tree.msgForPointer(list.id, .up).?);
1692
+ try testing.expectEqual(SegmentedMsg.choose, tree.msgForPointer(grid.id, .up).?);
1693
+ try testing.expectEqual(canvas.WidgetKind.button, preview.kind);
1694
+ try testing.expectEqualStrings("settings", preview.icon);
1695
+ try testing.expectEqual(SegmentedMsg.choose, tree.msgForPointer(preview.id, .up).?);
1696
+ }
1697
+
1566
1698
  test "every built-in component is expressible in markup" {
1567
1699
  for (canvas.builtin_component_kinds) |component| {
1568
1700
  const descriptor = canvas.builtinComponentDescriptor(component);
@@ -362,6 +362,14 @@ pub const elements = [_]ElementInfo{
362
362
  // line numbers or one horizontal scroll region for unwrapped lines.
363
363
  // Markdown fences use the same builder component.
364
364
  .{ .code = 70, .name = "code", .rule_hook = "code", .hit_target = false },
365
+ // Standalone exclusive-choice trigger. Its item collection is ordinary
366
+ // markup structure around these text-bearing leaves.
367
+ .{ .code = 71, .name = "segmented-control", .widget_kind = "segmented_control", .takes_text = true, .icon_attr = true, .a11y_name = .control },
368
+ .{ .code = 72, .name = "virtual-window", .rule_hook = "virtual-window" },
369
+ .{ .code = 73, .name = "virtual-list", .rule_hook = "virtual-list" },
370
+ .{ .code = 74, .name = "data-grid", .widget_kind = "data_grid", .hit_target = false, .takes_text = true, .takes_children = true },
371
+ .{ .code = 75, .name = "popover", .widget_kind = "popover", .stacks_children = true, .dismissible = true, .anchorable = true },
372
+ .{ .code = 76, .name = "menu-surface", .widget_kind = "menu_surface", .dismissible = true, .anchorable = true },
365
373
  };
366
374
 
367
375
  // ------------------------------------------------------------- attributes
@@ -600,6 +608,10 @@ pub const attrs = [_]AttrInfo{
600
608
  .{ .code = 100, .name = "source-y", .class = .number, .group = .element },
601
609
  .{ .code = 101, .name = "source-width", .class = .number, .group = .element },
602
610
  .{ .code = 102, .name = "source-height", .class = .number, .group = .element },
611
+ // A command name is data, retained with the widget until activation.
612
+ .{ .code = 103, .name = "command", .class = .text, .group = .option, .field = "command" },
613
+ .{ .code = 104, .name = "focusable", .class = .flag, .group = .option },
614
+ .{ .code = 105, .name = "backdrop-blur", .class = .option, .group = .option, .field = "backdrop_blur_token" },
603
615
  };
604
616
 
605
617
  // ----------------------------------------------------------------- events
@@ -662,7 +674,7 @@ pub const color_token_names = [_][]const u8{
662
674
  "focus_ring", "shadow", "scrim", "disabled",
663
675
  };
664
676
 
665
- pub const radius_token_names = [_][]const u8{ "sm", "md", "lg", "xl" };
677
+ pub const radius_token_names = [_][]const u8{ "sm", "md", "lg", "xl", "none" };
666
678
 
667
679
  /// The `size` attribute's CONTROL-scale values, accepted on every sized
668
680
  /// element: the control register of `canvas.WidgetSize`, mirrored as data
@@ -21,15 +21,18 @@ 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, 70), schema.elements.len);
25
- try testing.expectEqual(@as(usize, 102), schema.attrs.len);
24
+ try testing.expectEqual(@as(usize, 76), schema.elements.len);
25
+ try testing.expectEqual(@as(usize, 105), schema.attrs.len);
26
26
  try testing.expectEqual(@as(usize, 15), schema.events.len);
27
27
  // The element table runs through the span composite (64), the
28
28
  // bubble-reactions composite (65), the media surface (66), the
29
29
  // runtime-image leaf (67), the video playback composite (68), and
30
- // the terminal leaf (69), and the reusable code composite (70).
30
+ // the terminal leaf (69), reusable code composite (70), standalone
31
+ // segmented control (71), and the retained virtual-window (72) and
32
+ // virtual-list (73) authoring composites, plus data-grid (74),
33
+ // popover (75), and menu-surface (76).
31
34
  try testing.expectEqual(
32
- @as(u64, 0x180108eb2382ba60),
35
+ @as(u64, 0xfbb7ecf41ba92cd0),
33
36
  tableFingerprint(schema.ElementInfo, &schema.elements),
34
37
  );
35
38
  // The attr table runs through the split layout-tween attributes
@@ -50,9 +53,10 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
50
53
  // textarea Enter policy submit-on-enter (97), and the responsive
51
54
  // layout ceiling max-width (98), and the registered-image source
52
55
  // rectangle source-x (99), source-y (100), source-width (101), and
53
- // source-height (102).
56
+ // source-height (102), retained command name (103), and explicit
57
+ // keyboard eligibility focusable (104), and token backdrop-blur (105).
54
58
  try testing.expectEqual(
55
- @as(u64, 0x3614b1510b48dcf4),
59
+ @as(u64, 0x3406ee8d72535970),
56
60
  tableFingerprint(schema.AttrInfo, &schema.attrs),
57
61
  );
58
62
  // The event table runs through the pointer-hover containment pair
@@ -107,7 +111,7 @@ test "registry event scoping names registry elements" {
107
111
  test "derived name lists mirror the registry" {
108
112
  // The derivations are the vocabulary every consumer reads; hold them
109
113
  // to the registry's own predicates.
110
- try testing.expectEqual(@as(usize, 56), schema.element_names.len);
114
+ try testing.expectEqual(@as(usize, 60), schema.element_names.len);
111
115
  for (schema.element_names) |name| {
112
116
  try testing.expect(schema.elementByName(name).?.rule_hook == null);
113
117
  }
@@ -427,6 +427,7 @@ test "radio selection dispatches change then toggle then press on every input pa
427
427
  const toggle_radio = tree.root.children[1];
428
428
  const press_radio = tree.root.children[2];
429
429
  const selected_radio = tree.root.children[3];
430
+ try testing.expectEqual(@as(f32, 1), selected_radio.value);
430
431
 
431
432
  try testing.expectEqual(Msg.add, tree.msgForPointer(change_radio.id, .up).?);
432
433
  try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{ .phase = .key_down, .key = "space" }).?);
@@ -27,6 +27,7 @@
27
27
  const std = @import("std");
28
28
  const geometry = @import("geometry");
29
29
  const drawing_model = @import("drawing.zig");
30
+ const raster_policy = @import("vector_raster_policy.zig");
30
31
 
31
32
  const PointF = geometry.PointF;
32
33
  const Affine = drawing_model.Affine;
@@ -545,6 +546,8 @@ pub fn RasterizerType(comptime edge_capacity: usize, comptime crossing_capacity:
545
546
  /// stack frame so the glyph instantiation's 145 KiB rides the
546
547
  /// same per-thread heap slot as its edges.
547
548
  crossings: [crossing_capacity]Crossing = undefined,
549
+ /// Static process-local owner. Buffers and pixel sinks remain native.
550
+ policy: ?raster_policy.Policy = null,
548
551
 
549
552
  const Self = @This();
550
553
 
@@ -600,6 +603,7 @@ pub fn RasterizerType(comptime edge_capacity: usize, comptime crossing_capacity:
600
603
  /// for every pixel inside `clip` with coverage > 0. Coverage is in
601
604
  /// (0, 1]; `sub_samples` vertical subsamples, exact horizontal spans.
602
605
  pub fn sweep(self: *Self, rule: FillRule, clip: ClipRect, sink: anytype) Error!void {
606
+ if (self.policy) |policy| return raster_policy.sweep(self, rule, clip, sink, policy);
603
607
  if (self.edge_count == 0) return;
604
608
  const y_begin = @max(clip.y0, floorI(self.min_y));
605
609
  const y_end = @min(clip.y1, ceilI(self.max_y));
@@ -731,7 +735,11 @@ pub fn fillPath(
731
735
  clip: ClipRect,
732
736
  sink: anytype,
733
737
  ) Error!void {
734
- var raster: Rasterizer = .{};
738
+ return fillPathWithPolicy(elements, transform, rule, tolerance, clip, sink, null);
739
+ }
740
+
741
+ pub fn fillPathWithPolicy(elements: []const PathElement, transform: Affine, rule: FillRule, tolerance: f32, clip: ClipRect, sink: anytype, policy: ?raster_policy.Policy) Error!void {
742
+ var raster: Rasterizer = .{ .policy = policy };
735
743
  try accumulateFillEdges(&raster, elements, transform, tolerance);
736
744
  try raster.sweep(rule, clip, sink);
737
745
  }
@@ -755,7 +763,27 @@ pub fn fillGlyphPath(
755
763
  clip: ClipRect,
756
764
  sink: anytype,
757
765
  ) Error!void {
766
+ return fillGlyphPathWithPolicy(raster, elements, transform, rule, tolerance, clip, sink, null);
767
+ }
768
+
769
+ /// Explicit static owner for a caller's glyph storage. Set it on every entry,
770
+ /// preserving the native API's support for initially uninitialized scratch.
771
+ pub fn fillGlyphPathWithPolicy(
772
+ raster: *GlyphRasterizer,
773
+ elements: []const PathElement,
774
+ transform: Affine,
775
+ rule: FillRule,
776
+ tolerance: f32,
777
+ clip: ClipRect,
778
+ sink: anytype,
779
+ owner: ?raster_policy.Policy,
780
+ ) Error!void {
781
+ raster.policy = owner;
758
782
  raster.resetEdges();
783
+ if (raster.policy) |policy| {
784
+ try raster_policy.accumulate(raster, elements, transform, tolerance, max_glyph_curve_segments, null, policy);
785
+ return raster.sweep(rule, clip, sink);
786
+ }
759
787
  var edge_sink = FillEdgeSink(GlyphRasterizer){ .raster = raster };
760
788
  try walkPath(elements, transform, tolerance, max_glyph_curve_segments, &edge_sink);
761
789
  try raster.sweep(rule, clip, sink);
@@ -770,6 +798,7 @@ pub fn accumulateFillEdges(
770
798
  transform: Affine,
771
799
  tolerance: f32,
772
800
  ) Error!void {
801
+ if (raster.policy) |policy| return raster_policy.accumulate(raster, elements, transform, tolerance, max_curve_segments, null, policy);
773
802
  var sink = FillEdgeSink(Rasterizer){ .raster = raster };
774
803
  try walkPath(elements, transform, tolerance, max_curve_segments, &sink);
775
804
  }
@@ -815,8 +844,12 @@ pub fn strokePath(
815
844
  clip: ClipRect,
816
845
  sink: anytype,
817
846
  ) Error!void {
847
+ return strokePathWithPolicy(elements, transform, style, tolerance, clip, sink, null);
848
+ }
849
+
850
+ pub fn strokePathWithPolicy(elements: []const PathElement, transform: Affine, style: StrokeStyle, tolerance: f32, clip: ClipRect, sink: anytype, policy: ?raster_policy.Policy) Error!void {
818
851
  if (!(style.width > 0)) return;
819
- var raster: Rasterizer = .{};
852
+ var raster: Rasterizer = .{ .policy = policy };
820
853
  try accumulateStrokeEdges(&raster, elements, transform, style, tolerance);
821
854
  try raster.sweep(.nonzero, clip, sink);
822
855
  }
@@ -829,6 +862,7 @@ pub fn accumulateStrokeEdges(
829
862
  style: StrokeStyle,
830
863
  tolerance: f32,
831
864
  ) Error!void {
865
+ if (raster.policy) |policy| return raster_policy.accumulate(raster, elements, transform, tolerance, max_curve_segments, style, policy);
832
866
  if (!(style.width > 0)) return;
833
867
  var sink = StrokeSink{
834
868
  .raster = raster,
@@ -0,0 +1,236 @@
1
+ //! Copied vector/effect facts and checked result ownership. Source commands,
2
+ //! buffers and GPU resources stay native; portable planning uses operation 63.
3
+ const std = @import("std");
4
+ const wire = @import("glyph_atlas_policy.zig");
5
+ pub const Policy = wire.Policy;
6
+ const word = wire.word;
7
+ const put = wire.put;
8
+ const float = wire.float;
9
+ const integer = wire.integer;
10
+ const readFloat = wire.readFloat;
11
+ const builtin = @import("builtin");
12
+ // Zig 0.16 optimized x86 preserves the shadow output's zero operand. The
13
+ // separately lowered backdrop-blur output canonicalizes that clamp to +0.
14
+ const nonnegative_zero: u8 = if ((builtin.cpu.arch == .x86_64 or builtin.cpu.arch == .x86) and builtin.mode != .Debug) 16 else 0;
15
+ const zero_rules: u8 = nonnegative_zero | switch (builtin.cpu.arch) {
16
+ .aarch64, .aarch64_be => 3,
17
+ else => 5,
18
+ };
19
+
20
+ fn bytes(base: usize, count: usize, stride: usize) usize {
21
+ return std.math.add(usize, base, std.math.mul(usize, count, stride) catch @panic("vector resource size overflow")) catch @panic("vector resource size overflow");
22
+ }
23
+ fn alloc(size: usize) []u8 {
24
+ return std.heap.page_allocator.alloc(u8, size) catch @panic("vector resource allocation failed");
25
+ }
26
+ fn header(request: []u8, mode: u8, count: usize, capacity: usize) void {
27
+ @memset(request, 0);
28
+ request[0..4].* = .{ 63, 1, mode, zero_rules };
29
+ put(request, 4, count);
30
+ put(request, 8, capacity);
31
+ }
32
+ fn rect(out: []u8, at: usize, value: anytype) void {
33
+ inline for (.{ "x", "y", "width", "height" }, 0..) |field, i| float(out, at + i * 4, @field(value, field));
34
+ }
35
+ fn readRect(raw: []const u8, at: usize) @import("geometry").RectF {
36
+ return .{ .x = readFloat(raw, at), .y = readFloat(raw, at + 4), .width = readFloat(raw, at + 8), .height = readFloat(raw, at + 12) };
37
+ }
38
+
39
+ pub fn resultValid(request: []const u8, result: []const u8, capacity: usize) bool {
40
+ if (request.len < 16 or result.len < 16 or request[2] > 1) return false;
41
+ const mode = request[2];
42
+ const request_stride: usize = if (mode == 0) 72 else 80;
43
+ const stride: usize = if (mode == 0) 88 else 80;
44
+ const facts: usize = word(request, 4);
45
+ const count: usize = word(result, 0);
46
+ if (facts > (request.len - 16) / request_stride or count > facts or count > capacity or
47
+ count > (result.len - 16) / stride or result.len != 16 + count * stride or
48
+ word(result, 4) > 1 or word(result, 8) != 0 or word(result, 12) != 0 or
49
+ (word(result, 4) == 1 and count != capacity)) return false;
50
+ var source: usize = 0;
51
+ for (0..count) |i| {
52
+ const at = 16 + i * stride;
53
+ const index = word(result, at);
54
+ while (source < facts and word(request, 16 + source * request_stride) < index) source += 1;
55
+ if (source >= facts) return false;
56
+ const origin = 16 + source * request_stride;
57
+ const prefix: usize = if (mode == 0) 40 else 16;
58
+ if (!std.mem.eql(u8, request[origin..][0..prefix], result[at..][0..prefix])) return false;
59
+ if (mode == 0) {
60
+ const elements: u64 = word(request, origin + 68);
61
+ if (elements == 0 or word(result, at + 40) != elements or word(result, at + 64) == 0 or word(result, at + 68) == 0 or word(result, at + 76) != 0) return false;
62
+ // Check conservative storage ceilings, without deriving the plan.
63
+ // Each source verb contributes at most twelve reference segments.
64
+ for (0..4) |field| if (word(result, at + 44 + field * 4) > elements) return false;
65
+ if (word(result, at + 60) > elements * 12 or word(result, at + 64) > elements * 48 or word(result, at + 68) > elements * 72) return false;
66
+ } else if (word(result, at + 72) != 0 or word(result, at + 76) != 0) return false;
67
+ source += 1;
68
+ }
69
+ return true;
70
+ }
71
+
72
+ pub fn paths(planner: anytype, plan: anytype, policy: Policy) @import("root.zig").Error!@import("render_paths.zig").RenderPathGeometryPlan {
73
+ planner.reset();
74
+ var count: usize = 0;
75
+ var elements: usize = 0;
76
+ for (plan.commands) |command| switch (command.command) {
77
+ inline .fill_path, .stroke_path => |value| {
78
+ count += 1;
79
+ elements = bytes(elements, value.elements.len, 28);
80
+ },
81
+ else => {},
82
+ };
83
+ const start = bytes(16, count, 72);
84
+ const request = alloc(bytes(start, elements, 1));
85
+ defer std.heap.page_allocator.free(request);
86
+ const result = alloc(bytes(16, @min(count, planner.geometries.len), 88));
87
+ defer std.heap.page_allocator.free(result);
88
+ header(request, 0, count, planner.geometries.len);
89
+ var fact: usize = 0;
90
+ var payload = start;
91
+ for (plan.commands, 0..) |command, index| switch (command.command) {
92
+ inline .fill_path, .stroke_path => |value| {
93
+ const at = 16 + fact * 72;
94
+ const stroke = command.command == .stroke_path;
95
+ put(request, at, index);
96
+ put(request, at + 4, @intFromBool(stroke));
97
+ put(request, at + 8, @intFromBool(command.id != null));
98
+ integer(request, at + 16, command.id orelse 0);
99
+ rect(request, at + 24, command.bounds);
100
+ inline for (.{ "a", "b", "c", "d", "tx", "ty" }, 0..) |field, i| float(request, at + 40 + i * 4, @field(command.transform, field));
101
+ float(request, at + 64, if (stroke) command.command.stroke_path.stroke.width else 0);
102
+ put(request, at + 68, value.elements.len);
103
+ for (value.elements) |element| {
104
+ put(request, payload, @intFromEnum(element.verb));
105
+ for (element.points, 0..) |point, i| {
106
+ float(request, payload + 4 + i * 8, point.x);
107
+ float(request, payload + 8 + i * 8, point.y);
108
+ }
109
+ payload += 28;
110
+ }
111
+ fact += 1;
112
+ },
113
+ else => {},
114
+ };
115
+ const length = policy(request, result);
116
+ if (length > result.len or !resultValid(request, result[0..length], planner.geometries.len)) @panic("invalid compiled vector geometry result");
117
+ planner.len = word(result, 0);
118
+ for (planner.geometries[0..planner.len], 0..) |*item, i| {
119
+ const at = 16 + i * 88;
120
+ item.* = .{
121
+ .kind = @enumFromInt(word(result, at + 4)),
122
+ .command_index = word(result, at),
123
+ .id = if (word(result, at + 8) != 0) std.mem.readInt(u64, result[at + 16 ..][0..8], .little) else null,
124
+ .bounds = readRect(result, at + 24),
125
+ .element_count = word(result, at + 40),
126
+ .contour_count = word(result, at + 44),
127
+ .line_segment_count = word(result, at + 48),
128
+ .quadratic_segment_count = word(result, at + 52),
129
+ .cubic_segment_count = word(result, at + 56),
130
+ .flattened_segment_count = word(result, at + 60),
131
+ .vertex_count = word(result, at + 64),
132
+ .index_count = word(result, at + 68),
133
+ .stroke_width = readFloat(result, at + 72),
134
+ .fingerprint = std.mem.readInt(u64, result[at + 80 ..][0..8], .little),
135
+ };
136
+ }
137
+ if (word(result, 4) != 0) return error.PathGeometryListFull;
138
+ return .{ .geometries = planner.geometries[0..planner.len] };
139
+ }
140
+
141
+ pub fn effects(planner: anytype, list: anytype, policy: Policy) @import("root.zig").Error!@import("render_effects.zig").VisualEffectPlan {
142
+ planner.reset();
143
+ var count: usize = 0;
144
+ for (list.commands) |command| switch (command) {
145
+ .shadow, .blur => count += 1,
146
+ else => {},
147
+ };
148
+ const request = alloc(bytes(16, count, 80));
149
+ defer std.heap.page_allocator.free(request);
150
+ const result = alloc(bytes(16, @min(count, planner.effects.len), 80));
151
+ defer std.heap.page_allocator.free(result);
152
+ header(request, 1, count, planner.effects.len);
153
+ var fact: usize = 0;
154
+ for (list.commands, 0..) |command, index| switch (command) {
155
+ inline .shadow, .blur => |value| {
156
+ const at = 16 + fact * 80;
157
+ put(request, at, index);
158
+ put(request, at + 4, @intFromBool(command == .blur));
159
+ integer(request, at + 8, value.id);
160
+ rect(request, at + 16, value.rect);
161
+ switch (command) {
162
+ .shadow => |shadow| {
163
+ inline for (.{ "top_left", "top_right", "bottom_right", "bottom_left" }, 0..) |field, i| float(request, at + 32 + i * 4, @field(shadow.radius, field));
164
+ float(request, at + 48, shadow.offset.dx);
165
+ float(request, at + 52, shadow.offset.dy);
166
+ float(request, at + 56, shadow.blur);
167
+ float(request, at + 60, shadow.spread);
168
+ inline for (.{ "r", "g", "b", "a" }, 0..) |field, i| float(request, at + 64 + i * 4, @field(shadow.color, field));
169
+ },
170
+ .blur => |blur| float(request, at + 56, blur.radius),
171
+ else => unreachable,
172
+ }
173
+ fact += 1;
174
+ },
175
+ else => {},
176
+ };
177
+ const length = policy(request, result);
178
+ if (length > result.len or !resultValid(request, result[0..length], planner.effects.len)) @panic("invalid compiled vector effect result");
179
+ planner.len = word(result, 0);
180
+ for (planner.effects[0..planner.len], 0..) |*item, i| {
181
+ const at = 16 + i * 80;
182
+ const id = std.mem.readInt(u64, result[at + 8 ..][0..8], .little);
183
+ item.* = .{
184
+ .kind = @enumFromInt(word(result, at + 4)),
185
+ .command_index = word(result, at),
186
+ .id = if (id == 0) null else id,
187
+ .bounds = readRect(result, at + 16),
188
+ .radius = .{ .top_left = readFloat(result, at + 32), .top_right = readFloat(result, at + 36), .bottom_right = readFloat(result, at + 40), .bottom_left = readFloat(result, at + 44) },
189
+ .offset = .{ .dx = readFloat(result, at + 48), .dy = readFloat(result, at + 52) },
190
+ .blur = readFloat(result, at + 56),
191
+ .spread = readFloat(result, at + 60),
192
+ .fingerprint = std.mem.readInt(u64, result[at + 64 ..][0..8], .little),
193
+ };
194
+ }
195
+ if (word(result, 4) != 0) return error.VisualEffectListFull;
196
+ return .{ .effects = planner.effects[0..planner.len] };
197
+ }
198
+
199
+ test "vector resource copied transport bounds counts sources padding and complete failure prefixes" {
200
+ var request: [160]u8 = undefined;
201
+ header(&request, 0, 2, 2);
202
+ put(&request, 16, 3);
203
+ put(&request, 88, 9);
204
+ put(&request, 84, 3);
205
+ put(&request, 156, 3);
206
+ var result: [192]u8 = @splat(0);
207
+ put(&result, 0, 2);
208
+ @memcpy(result[16..56], request[16..56]);
209
+ @memcpy(result[104..144], request[88..128]);
210
+ for ([_]usize{ 16, 104 }) |at| {
211
+ put(&result, at + 40, 3);
212
+ put(&result, at + 64, 3);
213
+ put(&result, at + 68, 3);
214
+ }
215
+ try std.testing.expect(resultValid(&request, &result, 2));
216
+ try std.testing.expect(!resultValid(&request, &result, 1));
217
+ for ([_]usize{ 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 80, 84, 92, 104, 180 }) |at| {
218
+ const saved = word(&result, at);
219
+ put(&result, at, 0xffffffff);
220
+ try std.testing.expect(!resultValid(&request, &result, 2));
221
+ put(&result, at, saved);
222
+ }
223
+ for (0..192) |length| try std.testing.expect(!resultValid(&request, result[0..length], 2));
224
+ put(&result, 0, 1);
225
+ put(&result, 4, 1);
226
+ try std.testing.expect(resultValid(&request, result[0..104], 1));
227
+ try std.testing.expect(!resultValid(&request, result[0..104], 2));
228
+ header(&request, 1, 1, 1);
229
+ put(&request, 16, 7);
230
+ @memset(&result, 0);
231
+ put(&result, 0, 1);
232
+ @memcpy(result[16..32], request[16..32]);
233
+ try std.testing.expect(resultValid(request[0..96], result[0..96], 1));
234
+ put(&result, 88, 1);
235
+ try std.testing.expect(!resultValid(request[0..96], result[0..96], 1));
236
+ }