@native-sdk/cli 0.10.1 → 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 (462) 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 +1796 -83
  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/native-ui/SKILL.md +76 -17
  130. package/skill-data/ts-core/SKILL.md +113 -9
  131. package/skill-data/ts-services/SKILL.md +1 -1
  132. package/skill-data/ts-services/references/service-surface.md +264 -144
  133. package/src/app_runner/root.zig +25 -12
  134. package/src/app_runner/ts_compiled_view.zig +1631 -0
  135. package/src/app_runner/ts_core_main.zig +143 -10
  136. package/src/app_runner/ts_core_mobile.zig +24 -12
  137. package/src/automation/server.zig +1 -3
  138. package/src/automation/snapshot.zig +9 -637
  139. package/src/automation/snapshot_reference.zig +656 -0
  140. package/src/automation/snapshot_serialization.zig +566 -0
  141. package/src/platform/linux/gtk_host.c +36 -24
  142. package/src/platform/linux/gtk_pixels.h +118 -0
  143. package/src/platform/linux/gtk_pixels_test.c +241 -0
  144. package/src/platform/linux/root.zig +2 -0
  145. package/src/platform/macos/appkit_host.m +188 -30
  146. package/src/platform/macos/pointer_motion_test.m +96 -0
  147. package/src/platform/macos/scroll_driver_test.m +105 -0
  148. package/src/platform/macos/spectrum_bins.h +34 -0
  149. package/src/platform/macos/spectrum_bins_test.c +56 -0
  150. package/src/platform/macos/text_keyboard_test.m +80 -0
  151. package/src/platform/macos/widget_focus_test.m +66 -0
  152. package/src/platform/null_platform.zig +26 -2
  153. package/src/platform/null_platform_tests.zig +13 -0
  154. package/src/platform/root.zig +1 -0
  155. package/src/platform/types.zig +13 -0
  156. package/src/platform/windows/root.zig +2 -0
  157. package/src/platform/windows/webview2_host.cpp +7 -2
  158. package/src/primitives/app_manifest/comptime_scene.zig +1 -1
  159. package/src/primitives/app_manifest/root.zig +2 -0
  160. package/src/primitives/app_manifest/tests.zig +4 -1
  161. package/src/primitives/app_manifest/validation.zig +2 -0
  162. package/src/primitives/canvas/a11y_audit.zig +3 -1
  163. package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
  164. package/src/primitives/canvas/chart_content_policy.zig +75 -0
  165. package/src/primitives/canvas/chart_plan_policy.zig +196 -0
  166. package/src/primitives/canvas/code_content_policy.zig +162 -0
  167. package/src/primitives/canvas/commands.zig +29 -1
  168. package/src/primitives/canvas/component_composition.zig +125 -0
  169. package/src/primitives/canvas/component_composition_policy.zig +44 -0
  170. package/src/primitives/canvas/component_construction_policy.zig +187 -0
  171. package/src/primitives/canvas/container_layout_policy.zig +87 -0
  172. package/src/primitives/canvas/control_appearance_policy.zig +142 -0
  173. package/src/primitives/canvas/control_command_policy.zig +75 -0
  174. package/src/primitives/canvas/control_content_policy.zig +90 -0
  175. package/src/primitives/canvas/control_geometry_policy.zig +165 -0
  176. package/src/primitives/canvas/control_payload_policy.zig +48 -0
  177. package/src/primitives/canvas/control_primitive_policy.zig +129 -0
  178. package/src/primitives/canvas/effect_plan_policy.zig +96 -0
  179. package/src/primitives/canvas/events.zig +1027 -1
  180. package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
  181. package/src/primitives/canvas/frame.zig +92 -23
  182. package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
  183. package/src/primitives/canvas/gpu.zig +10 -0
  184. package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
  185. package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
  186. package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
  187. package/src/primitives/canvas/grid_layout_policy.zig +51 -0
  188. package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
  189. package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
  190. package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
  191. package/src/primitives/canvas/layout_audit.zig +5 -2
  192. package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
  193. package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
  194. package/src/primitives/canvas/markdown.zig +13 -3
  195. package/src/primitives/canvas/markdown_content_policy.zig +227 -0
  196. package/src/primitives/canvas/markdown_image_binding.zig +81 -0
  197. package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
  198. package/src/primitives/canvas/numeric_capabilities.zig +14 -0
  199. package/src/primitives/canvas/reference.zig +12 -6
  200. package/src/primitives/canvas/registered_font_policy.zig +152 -0
  201. package/src/primitives/canvas/render.zig +48 -0
  202. package/src/primitives/canvas/render_cache_policy.zig +184 -0
  203. package/src/primitives/canvas/render_coordination_policy.zig +163 -0
  204. package/src/primitives/canvas/render_damage_policy.zig +160 -0
  205. package/src/primitives/canvas/render_effects.zig +14 -0
  206. package/src/primitives/canvas/render_generic_resources.zig +14 -0
  207. package/src/primitives/canvas/render_images.zig +14 -0
  208. package/src/primitives/canvas/render_layers.zig +14 -0
  209. package/src/primitives/canvas/render_override_policy.zig +119 -0
  210. package/src/primitives/canvas/render_paths.zig +14 -0
  211. package/src/primitives/canvas/render_plan_policy.zig +199 -0
  212. package/src/primitives/canvas/render_resource_policy.zig +476 -0
  213. package/src/primitives/canvas/root.zig +100 -0
  214. package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
  215. package/src/primitives/canvas/serialization.zig +8 -1
  216. package/src/primitives/canvas/surface_layout_policy.zig +36 -0
  217. package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
  218. package/src/primitives/canvas/terminal_grid.zig +10 -696
  219. package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
  220. package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
  221. package/src/primitives/canvas/text.zig +1 -0
  222. package/src/primitives/canvas/text_atlas.zig +113 -0
  223. package/src/primitives/canvas/text_cache_policy.zig +94 -0
  224. package/src/primitives/canvas/text_document_policy.zig +120 -0
  225. package/src/primitives/canvas/text_layout.zig +51 -2
  226. package/src/primitives/canvas/text_layout_cache.zig +29 -0
  227. package/src/primitives/canvas/text_layout_hash.zig +1 -0
  228. package/src/primitives/canvas/text_layout_types.zig +3 -0
  229. package/src/primitives/canvas/text_measure_cache.zig +46 -0
  230. package/src/primitives/canvas/text_measurement_policy.zig +124 -0
  231. package/src/primitives/canvas/text_metrics.zig +23 -0
  232. package/src/primitives/canvas/text_query_policy.zig +156 -0
  233. package/src/primitives/canvas/text_run_policy.zig +252 -0
  234. package/src/primitives/canvas/text_scalar_policy.zig +156 -0
  235. package/src/primitives/canvas/text_span_query_policy.zig +232 -0
  236. package/src/primitives/canvas/text_spans.zig +280 -8
  237. package/src/primitives/canvas/text_tests.zig +10 -0
  238. package/src/primitives/canvas/tokens.zig +38 -0
  239. package/src/primitives/canvas/ui.zig +250 -83
  240. package/src/primitives/canvas/ui_markup.zig +139 -33
  241. package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
  242. package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
  243. package/src/primitives/canvas/ui_markup_contract.zig +146 -14
  244. package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
  245. package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
  246. package/src/primitives/canvas/ui_markup_tests.zig +116 -0
  247. package/src/primitives/canvas/ui_markup_view.zig +258 -32
  248. package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
  249. package/src/primitives/canvas/ui_schema.zig +13 -1
  250. package/src/primitives/canvas/ui_schema_tests.zig +11 -7
  251. package/src/primitives/canvas/ui_tests.zig +1 -0
  252. package/src/primitives/canvas/vector.zig +36 -2
  253. package/src/primitives/canvas/vector_effect_policy.zig +236 -0
  254. package/src/primitives/canvas/vector_raster_policy.zig +190 -0
  255. package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
  256. package/src/primitives/canvas/virtual_extents.zig +99 -3
  257. package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
  258. package/src/primitives/canvas/widget_audit_policy.zig +293 -0
  259. package/src/primitives/canvas/widget_change_policy.zig +298 -0
  260. package/src/primitives/canvas/widget_invalidation.zig +113 -2
  261. package/src/primitives/canvas/widget_layout.zig +673 -128
  262. package/src/primitives/canvas/widget_layout_tests.zig +4 -0
  263. package/src/primitives/canvas/widget_metric_policy.zig +126 -0
  264. package/src/primitives/canvas/widget_metrics.zig +45 -6
  265. package/src/primitives/canvas/widget_paint_policy.zig +166 -0
  266. package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
  267. package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
  268. package/src/primitives/canvas/widget_render.zig +744 -74
  269. package/src/primitives/canvas/widget_render_controls.zig +1217 -133
  270. package/src/primitives/canvas/widget_render_scroll.zig +11 -3
  271. package/src/primitives/canvas/widget_render_style.zig +94 -0
  272. package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
  273. package/src/primitives/canvas/widget_routing.zig +75 -0
  274. package/src/primitives/canvas/widget_routing_policy.zig +135 -0
  275. package/src/primitives/canvas/widget_runtime.zig +20 -1
  276. package/src/primitives/canvas/widget_semantics.zig +25 -0
  277. package/src/primitives/canvas/widget_text_input.zig +86 -23
  278. package/src/primitives/canvas/widget_text_select.zig +1 -0
  279. package/src/primitives/canvas/widget_tree.zig +8 -1
  280. package/src/primitives/canvas/widgets.zig +42 -12
  281. package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
  282. package/src/root.zig +21 -0
  283. package/src/runtime/accessibility_policy.zig +122 -0
  284. package/src/runtime/api.zig +28 -0
  285. package/src/runtime/app_dispatch_policy.zig +68 -0
  286. package/src/runtime/authorization_policy.zig +150 -0
  287. package/src/runtime/automation_command_policy.zig +241 -0
  288. package/src/runtime/automation_interaction_policy.zig +107 -0
  289. package/src/runtime/automation_snapshot.zig +52 -22
  290. package/src/runtime/automation_snapshot_reference.zig +290 -0
  291. package/src/runtime/automation_widget_dispatch.zig +267 -355
  292. package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
  293. package/src/runtime/blob_policy.zig +58 -0
  294. package/src/runtime/blob_reference.zig +64 -0
  295. package/src/runtime/bridge_descriptor_policy.zig +206 -0
  296. package/src/runtime/builtin_bridge.zig +180 -44
  297. package/src/runtime/builtin_coordination_policy.zig +121 -0
  298. package/src/runtime/callback_policy_test_reference.zig +97 -0
  299. package/src/runtime/canvas_drag_policy.zig +94 -0
  300. package/src/runtime/canvas_fonts.zig +38 -10
  301. package/src/runtime/canvas_frame.zig +590 -134
  302. package/src/runtime/canvas_frame_helpers.zig +1 -0
  303. package/src/runtime/canvas_hover_policy.zig +131 -0
  304. package/src/runtime/canvas_images.zig +59 -30
  305. package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
  306. package/src/runtime/canvas_limits.zig +1 -1
  307. package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
  308. package/src/runtime/canvas_scene_observation_policy.zig +181 -0
  309. package/src/runtime/canvas_widget_context_menu.zig +4 -4
  310. package/src/runtime/canvas_widget_display.zig +110 -9
  311. package/src/runtime/canvas_widget_events.zig +718 -328
  312. package/src/runtime/canvas_widget_runtime.zig +437 -81
  313. package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
  314. package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
  315. package/src/runtime/canvas_widget_state.zig +93 -56
  316. package/src/runtime/channel_sources.zig +80 -0
  317. package/src/runtime/command_policy.zig +161 -0
  318. package/src/runtime/component_policy.zig +83 -0
  319. package/src/runtime/core.zig +156 -6
  320. package/src/runtime/desktop_files.zig +189 -0
  321. package/src/runtime/effects.zig +466 -29
  322. package/src/runtime/effects_tests.zig +28 -0
  323. package/src/runtime/file_policy_test_reference.zig +113 -0
  324. package/src/runtime/flow.zig +418 -341
  325. package/src/runtime/flow_reference.zig +1426 -0
  326. package/src/runtime/font_registry_policy.zig +72 -0
  327. package/src/runtime/frame_profile.zig +24 -33
  328. package/src/runtime/gpu_surface_events.zig +97 -35
  329. package/src/runtime/host_event_pump.zig +303 -0
  330. package/src/runtime/host_event_pump_reference.zig +268 -0
  331. package/src/runtime/host_flow_policy.zig +155 -0
  332. package/src/runtime/host_input_regions_policy.zig +156 -0
  333. package/src/runtime/image_registry_policy.zig +94 -0
  334. package/src/runtime/input_composition_policy.zig +138 -0
  335. package/src/runtime/journal_policy.zig +66 -0
  336. package/src/runtime/journal_reference.zig +53 -0
  337. package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
  338. package/src/runtime/markup_development_policy.zig +91 -0
  339. package/src/runtime/media_surface.zig +40 -1
  340. package/src/runtime/motion_sampling_policy.zig +159 -0
  341. package/src/runtime/recording_policy.zig +42 -0
  342. package/src/runtime/render_animation_policy.zig +206 -0
  343. package/src/runtime/replay_policy.zig +66 -0
  344. package/src/runtime/replay_policy_reference.zig +326 -0
  345. package/src/runtime/replay_progress_policy.zig +64 -0
  346. package/src/runtime/replay_progress_reference.zig +34 -0
  347. package/src/runtime/request_policy_test_reference.zig +188 -0
  348. package/src/runtime/root.zig +13 -0
  349. package/src/runtime/session_blobs.zig +157 -58
  350. package/src/runtime/session_blobs_reference.zig +692 -0
  351. package/src/runtime/session_codec.zig +361 -0
  352. package/src/runtime/session_codec_reference.zig +1027 -0
  353. package/src/runtime/session_journal.zig +246 -983
  354. package/src/runtime/session_record.zig +224 -45
  355. package/src/runtime/session_replay.zig +157 -415
  356. package/src/runtime/session_tests.zig +552 -0
  357. package/src/runtime/shell_admission_policy.zig +225 -0
  358. package/src/runtime/shell_coordination_policy.zig +138 -0
  359. package/src/runtime/shell_layout.zig +126 -1
  360. package/src/runtime/snapshot_policy.zig +60 -0
  361. package/src/runtime/snapshot_reference.zig +64 -0
  362. package/src/runtime/state.zig +16 -0
  363. package/src/runtime/status_validation.zig +190 -0
  364. package/src/runtime/system_admission_policy.zig +140 -0
  365. package/src/runtime/system_services.zig +46 -36
  366. package/src/runtime/tests.zig +1 -0
  367. package/src/runtime/ts_canvas_hooks.zig +261 -0
  368. package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
  369. package/src/runtime/ts_canvas_icons.zig +234 -0
  370. package/src/runtime/ts_core_host.zig +2325 -411
  371. package/src/runtime/ts_core_host_tests.zig +1982 -0
  372. package/src/runtime/ts_test_host.zig +699 -0
  373. package/src/runtime/ts_ui_app.zig +1087 -45
  374. package/src/runtime/ui_app.zig +1117 -629
  375. package/src/runtime/ui_app_provenance.zig +147 -5
  376. package/src/runtime/ui_app_provenance_reference.zig +370 -0
  377. package/src/runtime/ui_app_tests.zig +619 -9
  378. package/src/runtime/ui_app_window_tests.zig +89 -0
  379. package/src/runtime/view.zig +25 -0
  380. package/src/runtime/view_canvas.zig +30 -6
  381. package/src/runtime/view_coordination_policy.zig +147 -0
  382. package/src/runtime/view_widget_control.zig +51 -14
  383. package/src/runtime/view_widget_scroll.zig +16 -5
  384. package/src/runtime/view_widget_text.zig +153 -68
  385. package/src/runtime/view_widget_tree.zig +460 -56
  386. package/src/runtime/webview_view_bridge_tests.zig +2 -0
  387. package/src/runtime/widget_motion_policy.zig +238 -0
  388. package/src/runtime/window_command_bridge_tests.zig +63 -0
  389. package/src/runtime/window_lifecycle_policy.zig +127 -0
  390. package/src/runtime/window_storage.zig +74 -8
  391. package/src/runtime/window_view_runtime.zig +148 -33
  392. package/src/runtime/window_views.zig +163 -10
  393. package/src/tooling/components/identity_tests.zig +62 -36
  394. package/src/tooling/components/stepper.native +24 -0
  395. package/src/tooling/components/stepper.zig +0 -19
  396. package/src/tooling/components/timeline-item.native +22 -0
  397. package/src/tooling/components/timeline.native +5 -3
  398. package/src/tooling/components/timeline_item.zig +0 -32
  399. package/src/tooling/eject_components.zig +76 -8
  400. package/src/tooling/ios.zig +66 -12
  401. package/src/tooling/manifest.zig +35 -0
  402. package/src/tooling/raw_manifest.zig +6 -0
  403. package/src/tooling/templates.zig +15 -3
  404. package/src/tooling/ts_core.zig +13 -3
  405. package/src/tooling/verbs.zig +22 -0
  406. package/tools/corewire/build_profile.mjs +54 -0
  407. package/tools/corewire/contract_intake.ts +303 -0
  408. package/tools/corewire/contract_intake.zig +82 -0
  409. package/tools/corewire/core.test.ts +166 -0
  410. package/tools/corewire/core_abi.zig +51 -0
  411. package/tools/corewire/core_cases.ts +233 -0
  412. package/tools/corewire/core_contract.ts +407 -0
  413. package/tools/corewire/core_emission.ts +136 -0
  414. package/tools/corewire/core_emission.zig +69 -0
  415. package/tools/corewire/core_goldens.json +3110 -0
  416. package/tools/corewire/core_policy.ts +14 -0
  417. package/tools/corewire/core_policy.zig +48 -0
  418. package/tools/corewire/core_projection.ts +360 -0
  419. package/tools/corewire/core_vocabulary.ts +6 -0
  420. package/tools/corewire/emit.zig +19 -1590
  421. package/tools/corewire/emit_facade.ts +714 -0
  422. package/tools/corewire/emit_facade.zig +10 -3752
  423. package/tools/corewire/emit_mirror.ts +290 -0
  424. package/tools/corewire/emit_profile.ts +50 -0
  425. package/tools/corewire/emit_service.ts +331 -0
  426. package/tools/corewire/emit_service.zig +23 -842
  427. package/tools/corewire/entry.test.ts +95 -0
  428. package/tools/corewire/entry_coordination.ts +127 -0
  429. package/tools/corewire/entry_coordination.zig +190 -0
  430. package/tools/corewire/facade_templates.ts +85 -0
  431. package/tools/corewire/filesystem.test.ts +166 -0
  432. package/tools/corewire/filesystem_coordination.ts +213 -0
  433. package/tools/corewire/filesystem_coordination.zig +245 -0
  434. package/tools/corewire/intake.test.ts +35 -0
  435. package/tools/corewire/intake_cases.ts +55 -0
  436. package/tools/corewire/intake_goldens.json +12237 -0
  437. package/tools/corewire/invocation.test.ts +24 -0
  438. package/tools/corewire/invocation.ts +175 -0
  439. package/tools/corewire/invocation.zig +136 -0
  440. package/tools/corewire/invocation_cases.ts +60 -0
  441. package/tools/corewire/invocation_fixture.ts +33 -0
  442. package/tools/corewire/invocation_goldens.json +1143 -0
  443. package/tools/corewire/invocation_tests.zig +111 -0
  444. package/tools/corewire/invocation_usage.ts +2 -0
  445. package/tools/corewire/lossless_projection.ts +96 -0
  446. package/tools/corewire/main.zig +7 -680
  447. package/tools/corewire/main_reference.zig +415 -0
  448. package/tools/corewire/mirror_templates.ts +55 -0
  449. package/tools/corewire/profile.test.ts +248 -0
  450. package/tools/corewire/profile.zig +56 -0
  451. package/tools/corewire/profile_emission.ts +202 -0
  452. package/tools/corewire/profile_library.json +29 -0
  453. package/tools/corewire/profile_tests.zig +136 -0
  454. package/tools/corewire/service.test.ts +75 -0
  455. package/tools/corewire/service_cases.ts +61 -0
  456. package/tools/corewire/service_contract.zig +40 -146
  457. package/tools/corewire/service_goldens.json +650 -0
  458. package/tools/corewire/service_projection.zig +52 -0
  459. package/tools/corewire/service_templates.ts +14 -0
  460. package/tools/corewire/shim_rt.zig +9 -0
  461. package/tools/corewire/sidecar.zig +267 -1438
  462. package/tools/corewire/emit_profile.zig +0 -521
@@ -0,0 +1,44 @@
1
+ //! Copied composition plans. Native owns arenas, byte storage and typed Msg
2
+ //! routes; the compiled recipe owns structure, defaults and branch decisions.
3
+ const std = @import("std");
4
+ const widgets = @import("widgets.zig");
5
+ pub const Policy = *const fn ([]const u8, []u8) usize;
6
+ pub const Stage = enum(u8) { input_group, input_entry, input_actions, stepper, step, timeline_item, nav, timeline };
7
+ pub const Plan = struct {
8
+ bytes: [128]u8,
9
+ pub fn role(self: Plan) widgets.WidgetRole {
10
+ return @enumFromInt(self.bytes[0]);
11
+ }
12
+ pub fn flag(self: Plan, mask: u8) bool {
13
+ return self.bytes[1] & mask != 0;
14
+ }
15
+ pub fn float(self: Plan, slot: usize) f32 {
16
+ return @bitCast(std.mem.readInt(u32, self.bytes[32 + slot * 4 ..][0..4], .little));
17
+ }
18
+ pub fn count(self: Plan) usize {
19
+ return @intCast(std.mem.readInt(u64, self.bytes[16..24], .little));
20
+ }
21
+ pub fn active(self: Plan) usize {
22
+ return @intCast(std.mem.readInt(u64, self.bytes[8..16], .little));
23
+ }
24
+ pub fn stateName(self: *const Plan) []const u8 {
25
+ return self.bytes[104..][0..self.bytes[100]];
26
+ }
27
+ };
28
+
29
+ pub fn plan(policy: Policy, stage: Stage, facts: u8, role: widgets.WidgetRole, active: usize, index: usize, count: usize, grow: f32, gap: f32) Plan {
30
+ var input: [64]u8 = @splat(0);
31
+ input[0..4].* = .{ 19, @intFromEnum(stage), facts, @intCast(@intFromEnum(role)) };
32
+ std.mem.writeInt(u64, input[8..16], active, .little);
33
+ std.mem.writeInt(u64, input[16..24], index, .little);
34
+ std.mem.writeInt(u64, input[24..32], count, .little);
35
+ std.mem.writeInt(u32, input[32..36], @bitCast(grow), .little);
36
+ std.mem.writeInt(u32, input[36..40], @bitCast(gap), .little);
37
+ var result: Plan = undefined;
38
+ if (policy(&input, &result.bytes) != result.bytes.len or result.bytes[0] > 26 or result.bytes[1] > 15 or result.bytes[2] > 2 or result.bytes[3] > 3 or result.bytes[4] > 5 or result.bytes[100] > 9) @panic("invalid compiled composition plan");
39
+ for (result.bytes[5..8]) |byte| if (byte != 0) @panic("invalid compiled composition reserved bytes");
40
+ for (result.bytes[24..32]) |byte| if (byte != 0) @panic("invalid compiled composition reserved bytes");
41
+ for (result.bytes[101..104]) |byte| if (byte != 0) @panic("invalid compiled composition reserved bytes");
42
+ for (result.bytes[104 + @as(usize, result.bytes[100]) ..]) |byte| if (byte != 0) @panic("invalid compiled composition string capacity");
43
+ return result;
44
+ }
@@ -0,0 +1,187 @@
1
+ //! Owned packets for portable construction; IDs, routes, tokens and arenas
2
+ //! remain native capabilities. A malformed compiled result never falls back.
3
+ const std = @import("std");
4
+ const widgets = @import("widgets.zig");
5
+ const tokens = @import("tokens.zig");
6
+ const geometry = @import("geometry");
7
+ const Color = @import("drawing.zig").Color;
8
+ pub const Policy = *const fn ([]const u8, []u8) usize;
9
+ const Widget = widgets.Widget;
10
+ const color_fields = .{ "background", "foreground", "accent", "accent_foreground", "border", "focus_ring" };
11
+ const ref_fields = .{ "background", "foreground", "accent", "accent_foreground", "border_color", "focus_ring", "radius" };
12
+ const action_fields = .{ "focus", "press", "toggle", "increment", "decrement", "set_text", "set_selection", "select", "drag", "drop_files", "dismiss" };
13
+ comptime {
14
+ @setEvalBranchQuota(10000);
15
+ const names = .{ "stack", "row", "column", "grid", "data_grid", "table", "scroll_view", "list", "breadcrumb", "button_group", "pagination", "radio_group", "tabs", "toggle_group", "accordion", "bubble", "resizable", "alert", "card", "dialog", "drawer", "sheet", "panel", "popover", "menu_surface", "dropdown_menu", "text", "icon", "image", "avatar", "badge", "button", "toggle_button", "icon_button", "select", "input", "text_field", "search_field", "combobox", "textarea", "tooltip", "menu_item", "list_item", "data_row", "data_cell", "status_bar", "segmented_control", "checkbox", "radio", "switch_control", "toggle", "slider", "progress", "separator", "skeleton", "spinner", "chart", "split", "split_divider", "tree", "input_group", "media_surface", "terminal" };
16
+ const actual = @typeInfo(widgets.WidgetKind).@"enum".fields;
17
+ if (actual.len != names.len) @compileError("update construction kind wire");
18
+ for (names, actual) |name, field| if (!std.mem.eql(u8, name, field.name)) @compileError("construction kind wire changed");
19
+ const colors = .{ "background", "surface", "surface_subtle", "surface_pressed", "text", "text_muted", "syntax_plain", "syntax_comment", "syntax_keyword", "syntax_literal", "syntax_function", "syntax_property", "syntax_constant", "border", "accent", "accent_text", "destructive", "destructive_text", "success", "success_text", "warning", "warning_text", "info", "info_text", "focus_ring", "shadow", "scrim", "disabled" };
20
+ const color_actual = @typeInfo(tokens.ColorTokens).@"struct".fields;
21
+ if (color_actual.len != colors.len) @compileError("update construction token wire");
22
+ for (colors, color_actual) |name, field| if (!std.mem.eql(u8, name, field.name)) @compileError("construction color wire changed");
23
+ guardEnum(std.meta.FieldEnum(tokens.ColorTokens), colors);
24
+ const radii = .{ "sm", "md", "lg", "xl", "none" };
25
+ const radius_actual = @typeInfo(tokens.RadiusTokens).@"struct".fields;
26
+ if (radius_actual.len != radii.len) @compileError("update construction radius wire");
27
+ for (radii, radius_actual) |name, field| if (!std.mem.eql(u8, name, field.name)) @compileError("construction radius wire changed");
28
+ guardEnum(std.meta.FieldEnum(tokens.RadiusTokens), radii);
29
+ const builtins = .{ "accordion", "alert", "avatar", "badge", "breadcrumb", "bubble", "button", "button_group", "card", "checkbox", "combobox", "dialog", "drawer", "dropdown_menu", "input", "pagination", "progress", "radio_group", "resizable", "select", "separator", "sheet", "skeleton", "slider", "spinner", "switch_control", "table", "tabs", "textarea", "toggle", "toggle_group", "tooltip" };
30
+ const builtin_actual = @typeInfo(widgets.BuiltinComponentKind).@"enum".fields;
31
+ if (builtin_actual.len != builtins.len) @compileError("update construction builtin wire");
32
+ for (builtins, builtin_actual) |name, field| if (!std.mem.eql(u8, name, field.name)) @compileError("construction builtin wire changed");
33
+ guardEnum(widgets.WidgetSize, .{ "default", "sm", "lg", "icon", "heading", "display" });
34
+ guardEnum(widgets.WidgetVariant, .{ "default", "primary", "secondary", "outline", "ghost", "destructive" });
35
+ guardEnum(widgets.WidgetCrossAlignment, .{ "stretch", "start", "center", "end" });
36
+ guardEnum(widgets.WidgetAnchorPlacement, .{ "below", "above" });
37
+ guardEnum(widgets.WidgetAnchorAlignment, .{ "start", "end", "stretch" });
38
+ guardEnum(widgets.WidgetRole, .{ "none", "group", "text", "link", "image", "button", "textbox", "tooltip", "dialog", "menu", "menuitem", "list", "listitem", "row", "grid", "gridcell", "tab", "checkbox", "radio", "radiogroup", "switch_control", "slider", "progressbar", "chart", "tree", "treeitem", "separator" });
39
+ const action_actual = @typeInfo(widgets.WidgetActions).@"struct".fields;
40
+ if (action_actual.len != action_fields.len) @compileError("update construction action wire");
41
+ for (action_fields, action_actual) |name, field| if (!std.mem.eql(u8, name, field.name)) @compileError("construction action wire changed");
42
+ }
43
+
44
+ fn guardEnum(comptime T: type, comptime names: anytype) void {
45
+ const fields = @typeInfo(T).@"enum".fields;
46
+ if (fields.len != names.len) @compileError("update construction enum wire");
47
+ for (names, fields, 0..) |name, field, i| if (!std.mem.eql(u8, name, field.name) or field.value != i) @compileError("construction enum wire changed");
48
+ }
49
+
50
+ pub fn element(policy: Policy, widget: *Widget, options: anytype) void {
51
+ var input: [40]u8 = @splat(0);
52
+ input[0..6].* = .{ 17, 0, @intCast(@intFromEnum(widget.kind)), @intCast(@intFromEnum(options.size)), @as(u8, @intFromBool(options.checked)) | (@as(u8, @intFromBool(options.selected)) << 1) | (@as(u8, @intFromBool(options.padding != null)) << 2), @intCast(@intFromEnum(options.cross)) };
53
+ const values = [_]f32{ options.width, options.height, options.min_width, options.max_width, options.padding orelse 0, options.gap, options.value };
54
+ for (values, 0..) |value, i| putFloat(input[8 + i * 4 ..][0..4], value);
55
+ // These facts describe the target's max-number zero convention,
56
+ // independent of authored values; TS selects the result's source word.
57
+ var negative: f32 = -0.0;
58
+ var positive: f32 = 0.0;
59
+ std.mem.doNotOptimizeAway(&negative);
60
+ std.mem.doNotOptimizeAway(&positive);
61
+ const flags: u32 = @as(u32, @intFromBool(@as(u32, @bitCast(@max(negative, positive))) == 0x80000000)) | (@as(u32, @intFromBool(@as(u32, @bitCast(@max(positive, negative))) == 0x80000000)) << 1);
62
+ std.mem.writeInt(u32, input[36..40], flags, .little);
63
+ var out: [44]u8 = undefined;
64
+ if (policy(&input, &out) != out.len or out[0] > 1 or out[1] > 3 or out[2] > 1 or out[3] != 0) @panic("invalid compiled element construction");
65
+ widget.state.selected = out[0] == 1;
66
+ widget.layout.cross_alignment = @enumFromInt(out[1]);
67
+ widget.layout.padding_is_kind_default = out[2] == 1;
68
+ widget.layout.gap = readFloat(out[4..8]);
69
+ readPadding(&widget.layout, out[8..24]);
70
+ widget.layout.min_size = .{ .width = readFloat(out[24..28]), .height = readFloat(out[28..32]) };
71
+ widget.layout.max_size = .{ .width = readFloat(out[32..36]), .height = readFloat(out[36..40]) };
72
+ widget.value = readFloat(out[40..44]);
73
+ }
74
+
75
+ pub const FinalPlan = struct { make_span: bool, split: bool };
76
+ pub fn finalize(policy: Policy, widget: *Widget, refs: anytype, live_tokens: tokens.DesignTokens, wrap: ?bool, two_children: bool, handlers: u16) FinalPlan {
77
+ var input: [592]u8 = @splat(0);
78
+ input[0..5].* = .{ 17, 1, @intCast(@intFromEnum(widget.kind)), if (wrap) |v| if (v) 2 else 1 else 0, @as(u8, @intFromBool(widget.spans.len > 0)) | (@as(u8, @intFromBool(widget.text.len > 0)) << 1) | (@as(u8, @intFromBool(two_children)) << 2) | (@as(u8, @intFromBool(widget.hover_msgs)) << 3) | (@as(u8, @intFromBool(widget.text_no_wrap)) << 4) };
79
+ inline for (ref_fields, 0..) |name, i| input[8 + i] = if (@field(refs, name)) |v| @intCast(@intFromEnum(v)) else 255;
80
+ std.mem.writeInt(u16, input[16..18], actionsMask(widget.semantics.actions), .little);
81
+ std.mem.writeInt(u16, input[18..20], handlers, .little);
82
+ var mask: u32 = 0;
83
+ inline for (color_fields, 0..) |name, i| if (@field(widget.style, name)) |v| {
84
+ mask |= @as(u32, 1) << @intCast(i);
85
+ putColor(input[24 + i * 16 ..][0..16], v);
86
+ };
87
+ if (widget.style.radius) |v| {
88
+ mask |= 64;
89
+ putFloat(input[120..124], v);
90
+ }
91
+ std.mem.writeInt(u32, input[20..24], mask, .little);
92
+ inline for (@typeInfo(tokens.ColorTokens).@"struct".fields, 0..) |field, i| putColor(input[124 + i * 16 ..][0..16], @field(live_tokens.colors, field.name));
93
+ inline for (@typeInfo(tokens.RadiusTokens).@"struct".fields, 0..) |field, i| putFloat(input[572 + i * 4 ..][0..4], @field(live_tokens.radius, field.name));
94
+ var out: [108]u8 = undefined;
95
+ if (policy(&input, &out) != out.len or std.mem.readInt(u16, out[0..2], .little) > 2047 or out[2] > 15 or out[3] != 0) @panic("invalid compiled final construction");
96
+ mask = std.mem.readInt(u32, out[4..8], .little);
97
+ if (mask > 127) @panic("invalid compiled construction style presence");
98
+ widget.semantics.actions = readActions(std.mem.readInt(u16, out[0..2], .little));
99
+ widget.text_no_wrap = out[2] & 2 != 0;
100
+ widget.hover_msgs = out[2] & 8 != 0;
101
+ inline for (color_fields, 0..) |name, i| @field(widget.style, name) = if (mask & (@as(u32, 1) << @intCast(i)) != 0) readColor(out[8 + i * 16 ..][0..16]) else null;
102
+ widget.style.radius = if (mask & 64 != 0) readFloat(out[104..108]) else null;
103
+ if (out[2] & 4 != 0 and (widget.kind != .split or !two_children)) @panic("invalid compiled split child capacity");
104
+ if (out[2] & 1 != 0 and (widget.kind != .text or widget.spans.len != 0 or widget.text.len == 0)) @panic("invalid compiled span ownership");
105
+ return .{ .make_span = out[2] & 1 != 0, .split = out[2] & 4 != 0 };
106
+ }
107
+
108
+ pub const Synthesized = struct { widget: Widget, item_identity: bool };
109
+ pub fn synthesize(policy: Policy, stage: u8, disabled: bool, separator: bool, enabled: bool, value: f32, point: ?geometry.PointF, arena: std.mem.Allocator) error{OutOfMemory}!Synthesized {
110
+ var input: [24]u8 = @splat(0);
111
+ input[0..4].* = .{ 17, 2, stage, @as(u8, @intFromBool(disabled)) | (@as(u8, @intFromBool(separator)) << 1) | (@as(u8, @intFromBool(enabled)) << 2) | (@as(u8, @intFromBool(point != null)) << 3) };
112
+ putFloat(input[8..12], value);
113
+ if (point) |v| {
114
+ putFloat(input[12..16], v.x);
115
+ putFloat(input[16..20], v.y);
116
+ }
117
+ var out: [64]u8 = undefined;
118
+ const len = policy(&input, &out);
119
+ if (len < 24 or len > out.len or out[0] > 62 or out[1] > 1 or out[2] > 1 or out[3] > 1 or out[20] > 1 or out[21] > 2 or out[22] > 1 or out[23] > 1) @panic("invalid compiled synthesized construction");
120
+ var widget: Widget = .{
121
+ .kind = @enumFromInt(out[0]),
122
+ .state = .{ .disabled = out[1] == 1 },
123
+ .value = readFloat(out[4..8]),
124
+ .semantics = .{ .label = try arena.dupe(u8, out[24..len]), .actions = .{ .press = out[2] == 1 } },
125
+ };
126
+ if (out[23] == 1) widget.layout.anchor = .{
127
+ .placement = @enumFromInt(out[20]),
128
+ .alignment = @enumFromInt(out[21]),
129
+ .offset = readFloat(out[8..12]),
130
+ .point = if (out[3] == 1) .{ .x = readFloat(out[12..16]), .y = readFloat(out[16..20]) } else null,
131
+ };
132
+ return .{ .widget = widget, .item_identity = out[22] == 1 };
133
+ }
134
+
135
+ pub fn builtin(policy: Policy, component: widgets.BuiltinComponentKind, widget: *Widget, options: widgets.BuiltinComponentOptions) void {
136
+ var input: [36]u8 = @splat(0);
137
+ input[0..8].* = .{ 17, 3, @intCast(@intFromEnum(component)), if (options.variant) |v| @intCast(@intFromEnum(v)) else 255, if (options.size) |v| @intCast(@intFromEnum(v)) else 255, @intCast(@intFromEnum(options.semantics.role)), @intCast(@intFromEnum(options.layout.cross_alignment)), @as(u8, @intFromBool(options.layout.clip_content)) | (@as(u8, @intFromBool(options.layout.padding_is_kind_default)) << 1) };
138
+ putPadding(input[8..24], options.layout);
139
+ putFloat(input[24..28], options.layout.gap);
140
+ putFloat(input[28..32], options.layout.min_size.width);
141
+ putFloat(input[32..36], options.layout.min_size.height);
142
+ var out: [36]u8 = undefined;
143
+ if (policy(&input, &out) != out.len or out[0] > 62 or out[1] > 5 or out[2] > 5 or out[3] >= @typeInfo(widgets.WidgetRole).@"enum".fields.len or out[4] > 3 or out[5] > 1 or out[6] > 1 or out[7] != 0) @panic("invalid compiled builtin construction");
144
+ widget.kind = @enumFromInt(out[0]);
145
+ widget.variant = @enumFromInt(out[1]);
146
+ widget.size = @enumFromInt(out[2]);
147
+ widget.semantics.role = @enumFromInt(out[3]);
148
+ widget.layout.cross_alignment = @enumFromInt(out[4]);
149
+ widget.layout.clip_content = out[5] == 1;
150
+ widget.layout.padding_is_kind_default = out[6] == 1;
151
+ readPadding(&widget.layout, out[8..24]);
152
+ widget.layout.gap = readFloat(out[24..28]);
153
+ widget.layout.min_size = .{ .width = readFloat(out[28..32]), .height = readFloat(out[32..36]) };
154
+ }
155
+
156
+ fn actionsMask(value: widgets.WidgetActions) u16 {
157
+ var result: u16 = 0;
158
+ inline for (action_fields, 0..) |name, i| if (@field(value, name)) {
159
+ result |= @as(u16, 1) << @intCast(i);
160
+ };
161
+ return result;
162
+ }
163
+ fn readActions(mask: u16) widgets.WidgetActions {
164
+ var result: widgets.WidgetActions = .{};
165
+ inline for (action_fields, 0..) |name, i| @field(result, name) = mask & (@as(u16, 1) << @intCast(i)) != 0;
166
+ return result;
167
+ }
168
+ fn putPadding(bytes: []u8, value: widgets.WidgetLayoutStyle) void {
169
+ inline for (.{ "top", "right", "bottom", "left" }, 0..) |name, i| putFloat(bytes[i * 4 ..][0..4], @field(value.padding, name));
170
+ }
171
+ fn readPadding(value: *widgets.WidgetLayoutStyle, bytes: []const u8) void {
172
+ inline for (.{ "top", "right", "bottom", "left" }, 0..) |name, i| @field(value.padding, name) = readFloat(bytes[i * 4 ..][0..4]);
173
+ }
174
+ fn putFloat(bytes: []u8, value: f32) void {
175
+ std.mem.writeInt(u32, bytes[0..4], @bitCast(value), .little);
176
+ }
177
+ fn readFloat(bytes: []const u8) f32 {
178
+ return @bitCast(std.mem.readInt(u32, bytes[0..4], .little));
179
+ }
180
+ fn putColor(bytes: []u8, value: Color) void {
181
+ inline for (.{ "r", "g", "b", "a" }, 0..) |name, i| putFloat(bytes[i * 4 ..][0..4], @field(value, name));
182
+ }
183
+ fn readColor(bytes: []const u8) Color {
184
+ var value: Color = undefined;
185
+ inline for (.{ "r", "g", "b", "a" }, 0..) |name, i| @field(value, name) = readFloat(bytes[i * 4 ..][0..4]);
186
+ return value;
187
+ }
@@ -0,0 +1,87 @@
1
+ const std = @import("std");
2
+ const geometry = @import("geometry");
3
+
4
+ pub const Policy = @import("surface_layout_policy.zig").Policy;
5
+
6
+ /// Only authored facts, native measurements and semantic kind/theme facts
7
+ /// cross this boundary. Native owns all buffers; results are copied before
8
+ /// traversal, and only the enclosing app cycle collects the compiled arena.
9
+ pub const Child = struct {
10
+ flags: u32 = 0,
11
+ grow: f32 = 0,
12
+ main: f32 = 0,
13
+ cross: f32 = 0,
14
+ offset_main: f32 = 0,
15
+ offset_cross: f32 = 0,
16
+ min_main: f32 = 0,
17
+ max_main: f32 = 0,
18
+ min_cross: f32 = 0,
19
+ max_cross: f32 = 0,
20
+ measured_main: f32 = 0,
21
+ measured_cross: f32 = 0,
22
+ };
23
+
24
+ pub const Plan = struct {
25
+ allocator: std.mem.Allocator,
26
+ policy: Policy,
27
+ request: []u8,
28
+ result: []u8,
29
+ count: usize,
30
+
31
+ pub fn init(allocator: std.mem.Allocator, policy: Policy, count: usize, content: geometry.RectF, axis: u8, main_alignment: u8, cross_alignment: u8, gap: f32) !Plan {
32
+ const request = try allocator.alloc(u8, 36 + count * 48);
33
+ errdefer allocator.free(request);
34
+ const result = try allocator.alloc(u8, 12 + count * 16);
35
+ @memset(request, 0);
36
+ request[0..8].* = .{ 5, 0, axis, main_alignment, cross_alignment, 0, 0, 0 };
37
+ std.mem.writeInt(u32, request[8..12], std.math.cast(u32, count) orelse @panic("container child count exceeds wire range"), .little);
38
+ for ([_]f32{ content.x, content.y, content.width, content.height, gap }, 0..) |value, i| put(request[12 + i * 4 ..][0..4], value);
39
+ return .{ .allocator = allocator, .policy = policy, .request = request, .result = result, .count = count };
40
+ }
41
+
42
+ pub fn deinit(self: Plan) void {
43
+ self.allocator.free(self.result);
44
+ self.allocator.free(self.request);
45
+ }
46
+
47
+ pub fn setChild(self: Plan, index: usize, child: Child) void {
48
+ const bytes = self.request[36 + index * 48 ..][0..48];
49
+ std.mem.writeInt(u32, bytes[0..4], child.flags, .little);
50
+ const values = [_]f32{ child.grow, child.main, child.cross, child.offset_main, child.offset_cross, child.min_main, child.max_main, child.min_cross, child.max_cross, child.measured_main, child.measured_cross };
51
+ for (values, 0..) |value, i| put(bytes[4 + i * 4 ..][0..4], value);
52
+ }
53
+
54
+ pub fn setMeasuredMain(self: Plan, index: usize, value: f32) void {
55
+ put(self.request[36 + index * 48 + 40 ..][0..4], value);
56
+ }
57
+
58
+ pub fn run(self: Plan, operation: u8) void {
59
+ self.request[1] = operation;
60
+ const expected = 12 + self.count * @as(usize, if (operation == 0) 4 else 16);
61
+ if (self.policy(self.request, self.result) != expected or std.mem.readInt(u32, self.result[0..4], .little) != self.count) @panic("invalid compiled container plan");
62
+ }
63
+
64
+ pub fn cross(self: Plan, index: usize) f32 {
65
+ return get(self.result[12 + index * 4 ..][0..4]);
66
+ }
67
+
68
+ pub fn frame(self: Plan, index: usize) geometry.RectF {
69
+ const bytes = self.result[12 + index * 16 ..][0..16];
70
+ return .init(get(bytes[0..4]), get(bytes[4..8]), get(bytes[8..12]), get(bytes[12..16]));
71
+ }
72
+
73
+ pub fn used(self: Plan) f32 {
74
+ return get(self.result[4..8]);
75
+ }
76
+
77
+ pub fn overflow(self: Plan) f32 {
78
+ return get(self.result[8..12]);
79
+ }
80
+ };
81
+
82
+ fn put(bytes: *[4]u8, value: f32) void {
83
+ std.mem.writeInt(u32, bytes, @bitCast(value), .little);
84
+ }
85
+ fn get(bytes: *const [4]u8) f32 {
86
+ return @bitCast(std.mem.readInt(u32, bytes, .little));
87
+ }
@@ -0,0 +1,142 @@
1
+ //! Copied numeric boundary for compiled portable control appearance.
2
+ const std = @import("std");
3
+ const widget_model = @import("widgets.zig");
4
+ const token_model = @import("tokens.zig");
5
+ const drawing = @import("drawing.zig");
6
+ const Widget = widget_model.Widget;
7
+ const Tokens = token_model.DesignTokens;
8
+ const Visual = token_model.ControlVisualTokens;
9
+ const Color = drawing.Color;
10
+ pub const Policy = *const fn ([]const u8, []u8) usize;
11
+ pub const Family = enum(u8) { button, text_input, selection, surface, component, list, select };
12
+ const table_names = .{ "button_default", "button_primary", "button_secondary", "button_outline", "button_ghost", "button_destructive", "toggle_button", "accordion", "alert", "bubble", "card", "dialog", "drawer", "sheet", "select", "input", "text_field", "search_field", "combobox", "textarea", "list_item", "menu_item", "data_cell", "tabs", "segmented_control", "button_group", "checkbox", "radio", "switch_control", "slider", "progress", "scrollbar", "panel", "resizable", "popover", "menu_surface", "dropdown_menu", "tooltip", "avatar", "badge", "separator", "skeleton", "spinner" };
13
+ comptime {
14
+ const names = .{ "stack", "row", "column", "grid", "data_grid", "table", "scroll_view", "list", "breadcrumb", "button_group", "pagination", "radio_group", "tabs", "toggle_group", "accordion", "bubble", "resizable", "alert", "card", "dialog", "drawer", "sheet", "panel", "popover", "menu_surface", "dropdown_menu", "text", "icon", "image", "avatar", "badge", "button", "toggle_button", "icon_button", "select", "input", "text_field", "search_field", "combobox", "textarea", "tooltip", "menu_item", "list_item", "data_row", "data_cell", "status_bar", "segmented_control", "checkbox", "radio", "switch_control", "toggle", "slider", "progress", "separator", "skeleton", "spinner", "chart", "split", "split_divider", "tree", "input_group", "media_surface", "terminal" };
15
+ const actual = @typeInfo(widget_model.WidgetKind).@"enum".fields;
16
+ if (actual.len != names.len) @compileError("update control appearance kind wire");
17
+ for (names, actual) |name, field| if (!std.mem.eql(u8, name, field.name)) @compileError("control appearance kind wire changed");
18
+ }
19
+ fn header(out: []u8, widget: Widget, tokens: Tokens, op: u8, family: u8) void {
20
+ @memset(out, 0);
21
+ out[0..8].* = .{ 16, op, family, @intCast(@intFromEnum(widget.kind)), @intCast(@intFromEnum(widget.variant)), @intCast(@intFromEnum(widget.size)), @as(u8, @intFromBool(widget.state.disabled)) | (@as(u8, @intFromBool(widget.state.pressed)) << 1) | (@as(u8, @intFromBool(widget.state.selected)) << 2) | (@as(u8, @intFromBool(widget.state.hovered)) << 3) | (@as(u8, @intFromBool(widget.style.quiet_hover)) << 4), @as(u8, @intFromBool(widget.group_segment != .none)) | (@as(u8, @intFromBool(tokens.controls.button_group_style == .detached)) << 1) };
22
+ }
23
+ fn table(tokens: Tokens, index: u8) Visual {
24
+ if (index == 255) return .{};
25
+ inline for (table_names, 0..) |name, i| if (index == i) return @field(tokens.controls, name);
26
+ @panic("invalid compiled appearance table");
27
+ }
28
+ pub fn visual(widget: Widget, tokens: Tokens, family: Family) Visual {
29
+ var input: [8]u8 = undefined;
30
+ header(&input, widget, tokens, 0, @intFromEnum(family));
31
+ var output: [4]u8 = undefined;
32
+ if (widget.appearance_policy.?(&input, &output) != 4 or output[2] > 1 or output[3] != 0 or (output[2] == 1 and output[1] == 255)) @panic("invalid compiled appearance family");
33
+ const primary = table(tokens, output[0]);
34
+ if (output[2] == 0) return primary;
35
+ var request: [320]u8 = undefined;
36
+ header(&request, widget, tokens, 1, 0);
37
+ putVisual(request[8..164], primary);
38
+ putVisual(request[164..320], table(tokens, output[1]));
39
+ var merged: [156]u8 = undefined;
40
+ if (widget.appearance_policy.?(&request, &merged) != merged.len) @panic("invalid compiled appearance fallback");
41
+ return readVisual(&merged);
42
+ }
43
+ pub fn context(widget: Widget, tokens: Tokens, op: u8, value: Visual, fallback: Color, scalar_value: f32) [496]u8 {
44
+ var out: [496]u8 = undefined;
45
+ header(&out, widget, tokens, op, 0);
46
+ putVisual(out[8..164], value);
47
+ var style_mask: u32 = 0;
48
+ inline for (.{ "background", "foreground", "accent", "accent_foreground", "border", "focus_ring" }, 0..) |name, i| if (@field(widget.style, name)) |color_value| {
49
+ style_mask |= @as(u32, 1) << @intCast(i);
50
+ putColor(out[168 + i * 16 ..][0..16], color_value);
51
+ };
52
+ if (widget.style.radius) |v| {
53
+ style_mask |= 64;
54
+ putFloat(out[264..268], v);
55
+ }
56
+ if (widget.style.stroke_width) |v| {
57
+ style_mask |= 128;
58
+ putFloat(out[268..272], v);
59
+ }
60
+ std.mem.writeInt(u32, out[164..168], style_mask, .little);
61
+ inline for (.{ "surface", "surface_subtle", "surface_pressed", "accent", "accent_text", "destructive", "text", "background" }, 0..) |name, i| putColor(out[272 + i * 16 ..][0..16], @field(tokens.colors, name));
62
+ inline for (.{ "disabled_alpha", "hover_fill_alpha", "pressed_fill_alpha", "secondary_hover_alpha", "destructive_wash_alpha", "destructive_wash_hover_alpha", "destructive_wash_pressed_alpha", "badge_destructive_wash_alpha", "selection_wash_alpha" }, 0..) |name, i| putFloat(out[400 + i * 4 ..][0..4], @field(tokens.states, name));
63
+ putFloat(out[436..440], tokens.radius.md);
64
+ putFloat(out[440..444], tokens.radius.lg);
65
+ putFloat(out[444..448], tokens.stroke.hairline);
66
+ putFloat(out[448..452], tokens.stroke.regular);
67
+ if (tokens.controls.button_disabled_border) |v| {
68
+ std.mem.writeInt(u32, out[452..456], 1, .little);
69
+ putColor(out[456..472], v);
70
+ }
71
+ putColor(out[472..488], fallback);
72
+ putFloat(out[488..492], scalar_value);
73
+ std.mem.writeInt(u32, out[492..496], numericFlags(), .little);
74
+ return out;
75
+ }
76
+ pub fn color(widget: Widget, tokens: Tokens, op: u8, value: Visual, fallback: Color) Color {
77
+ const request = context(widget, tokens, op, value, fallback, 0);
78
+ var out: [16]u8 = undefined;
79
+ if (widget.appearance_policy.?(&request, &out) != out.len) @panic("invalid compiled appearance color");
80
+ return readColor(&out);
81
+ }
82
+ pub fn scalar(widget: Widget, tokens: Tokens, op: u8, value: Visual, fallback: f32) f32 {
83
+ const request = context(widget, tokens, op, value, .{}, fallback);
84
+ var out: [4]u8 = undefined;
85
+ if (widget.appearance_policy.?(&request, &out) != out.len) @panic("invalid compiled appearance scalar");
86
+ return readFloat(&out);
87
+ }
88
+ pub fn detached(widget: Widget, tokens: Tokens) bool {
89
+ const request = context(widget, tokens, 31, .{}, .{}, 0);
90
+ var out: [1]u8 = undefined;
91
+ if (widget.appearance_policy.?(&request, &out) != 1 or out[0] > 1) @panic("invalid compiled appearance group");
92
+ return out[0] == 1;
93
+ }
94
+ const visual_colors = .{ "background", "hover_background", "active_background", "pressed_background", "disabled_background", "disabled_foreground", "foreground", "active_foreground", "border" };
95
+ fn putVisual(out: []u8, value: Visual) void {
96
+ @memset(out, 0);
97
+ var mask: u32 = 0;
98
+ inline for (visual_colors, 0..) |name, i| if (@field(value, name)) |v| {
99
+ mask |= @as(u32, 1) << @intCast(i);
100
+ putColor(out[4 + i * 16 ..][0..16], v);
101
+ };
102
+ if (value.radius) |v| {
103
+ mask |= 512;
104
+ putFloat(out[148..152], v);
105
+ }
106
+ if (value.stroke_width) |v| {
107
+ mask |= 1024;
108
+ putFloat(out[152..156], v);
109
+ }
110
+ std.mem.writeInt(u32, out[0..4], mask, .little);
111
+ }
112
+ fn readVisual(bytes: []const u8) Visual {
113
+ const mask = std.mem.readInt(u32, bytes[0..4], .little);
114
+ if (mask > 2047) @panic("invalid compiled visual presence");
115
+ var value: Visual = .{};
116
+ inline for (visual_colors, 0..) |name, i| if (mask & (@as(u32, 1) << @intCast(i)) != 0) {
117
+ @field(value, name) = readColor(bytes[4 + i * 16 ..][0..16]);
118
+ };
119
+ if (mask & 512 != 0) value.radius = readFloat(bytes[148..152]);
120
+ if (mask & 1024 != 0) value.stroke_width = readFloat(bytes[152..156]);
121
+ return value;
122
+ }
123
+ fn putFloat(bytes: []u8, v: f32) void {
124
+ std.mem.writeInt(u32, bytes[0..4], @bitCast(v), .little);
125
+ }
126
+ fn readFloat(bytes: []const u8) f32 {
127
+ return @bitCast(std.mem.readInt(u32, bytes[0..4], .little));
128
+ }
129
+ fn putColor(bytes: []u8, v: Color) void {
130
+ inline for (.{ "r", "g", "b", "a" }, 0..) |name, i| putFloat(bytes[i * 4 ..][0..4], @field(v, name));
131
+ }
132
+ fn readColor(bytes: []const u8) Color {
133
+ var v: Color = undefined;
134
+ inline for (.{ "r", "g", "b", "a" }, 0..) |name, i| @field(v, name) = readFloat(bytes[i * 4 ..][0..4]);
135
+ return v;
136
+ }
137
+
138
+ fn numericFlags() u32 {
139
+ var negative_zero: f32 = -0.0;
140
+ std.mem.doNotOptimizeAway(&negative_zero);
141
+ return if (@as(u32, @bitCast(@max(0, negative_zero))) == 0x80000000) 4 else 0;
142
+ }
@@ -0,0 +1,75 @@
1
+ //! Copied control command programs. The drawing host owns all emitted storage.
2
+ const std = @import("std");
3
+ pub const Policy = @import("surface_layout_policy.zig").Policy;
4
+ pub const Family = enum(u8) { button, icon_button, select, text_field, input_group, search, tooltip, menu_item, list_item, cell_chrome, cell, segmented, checkbox, radio, toggle, slider, progress };
5
+ pub const Opcode = enum(u32) { fill, stroke, focus, icon, text, selection, selected_glyphs, composition, caret, clip, unclip, mark, seam_clip, seam_unclip, shadow };
6
+ pub const Facts = struct {
7
+ focused: bool = false,
8
+ text: bool = false,
9
+ placeholder: bool = false,
10
+ icon: bool = false,
11
+ selected: bool = false,
12
+ background: bool = false,
13
+ border: bool = false,
14
+ clip: bool = false,
15
+ selection: bool = false,
16
+ selection_range: bool = false,
17
+ composition: bool = false,
18
+ composition_range: bool = false,
19
+ underline: bool = false,
20
+ bar: bool = false,
21
+ clear: bool = false,
22
+ chevron: bool = false,
23
+ check: bool = false,
24
+ seam: bool = false,
25
+ combobox: bool = false,
26
+ search_icon: bool = false,
27
+ value: f32 = 0,
28
+ stroke_width: f32 = 0,
29
+ wash_alpha: f32 = 0,
30
+ shadow_y: f32 = 0,
31
+ shadow_blur: f32 = 0,
32
+ shadow_spread: f32 = 0,
33
+ };
34
+ pub const Command = struct { opcode: Opcode, slot: u32, variant: u32 };
35
+ pub const Program = struct {
36
+ count: usize,
37
+ commands: [16]Command,
38
+ pub fn init(policy: Policy, family: Family, facts: Facts) Program {
39
+ var request: [32]u8 = @splat(0);
40
+ request[0..4].* = .{ 45, 1, @intFromEnum(family), 0 };
41
+ var flags: u32 = 0;
42
+ inline for (std.meta.fields(Facts), 0..) |field, i| {
43
+ if (field.type == bool) flags |= @as(u32, @intFromBool(@field(facts, field.name))) << @intCast(i);
44
+ }
45
+ std.mem.writeInt(u32, request[4..8], flags, .little);
46
+ for ([_]f32{ facts.value, facts.stroke_width, facts.wash_alpha, facts.shadow_y, facts.shadow_blur, facts.shadow_spread }, 0..) |value, i|
47
+ std.mem.writeInt(u32, request[8 + i * 4 ..][0..4], @bitCast(value), .little);
48
+ var result: [200]u8 = @splat(0xa5);
49
+ if (policy(&request, &result) != result.len or read(&result, 0) != 1 or read(&result, 4) > 16) @panic("invalid control command result");
50
+ const count = read(&result, 4);
51
+ if (!std.mem.allEqual(u8, result[8 + count * 12 ..], 0)) @panic("invalid control command tail");
52
+ var program: Program = .{ .count = count, .commands = undefined };
53
+ for (program.commands[0..count], 0..) |*command, i| {
54
+ const at = 8 + i * 12;
55
+ const op = read(&result, at);
56
+ const slot = read(&result, at + 4);
57
+ const variant = read(&result, at + 8);
58
+ if (op > @intFromEnum(Opcode.shadow) or slot > 16) @panic("invalid control command capability");
59
+ const valid = switch (@as(Opcode, @enumFromInt(op))) {
60
+ .selection, .composition => variant == 256 or variant == 1034 or variant == 1037,
61
+ .selected_glyphs => variant == 1 or variant == 4,
62
+ .icon => variant <= 6,
63
+ .fill => variant <= 5,
64
+ .stroke, .text, .focus, .mark => variant <= 2,
65
+ else => variant == 0,
66
+ };
67
+ if (!valid) @panic("invalid control command operands");
68
+ command.* = .{ .opcode = @enumFromInt(op), .slot = slot, .variant = variant };
69
+ }
70
+ return program;
71
+ }
72
+ };
73
+ fn read(bytes: []const u8, at: usize) u32 {
74
+ return std.mem.readInt(u32, bytes[at..][0..4], .little);
75
+ }
@@ -0,0 +1,90 @@
1
+ //! Copied presentation facts; font shaping, identities and drawing stay native.
2
+ const std = @import("std");
3
+ const geometry = @import("geometry");
4
+ const tokens_model = @import("tokens.zig");
5
+ const drawing = @import("drawing.zig");
6
+ pub const reference_controls = @import("widget_render_controls.zig");
7
+ pub const reference_style = @import("widget_render_style.zig");
8
+ pub const reference_input = @import("widget_text_input.zig");
9
+ pub const Operation = enum(u8) { snap_rect, geometry_point, text_point, origin, layout, label_frame, aligned_origin, glyph_size, focus_rect, focus_radius, hairline, icon_label, composition, input_clip, input_origin, input_layout, clear_icon, clear_hit, trailing_inset };
10
+ pub const Result = struct { rects: [2]geometry.RectF, radius: drawing.Radius, point: geometry.PointF, scalar: f32, auxiliary: f32, wrap: @import("text.zig").TextWrap };
11
+ fn word(b: []u8, at: usize, v: u32) void {
12
+ std.mem.writeInt(u32, b[at..][0..4], v, .little);
13
+ }
14
+ fn read(b: []const u8, at: usize) u32 {
15
+ return std.mem.readInt(u32, b[at..][0..4], .little);
16
+ }
17
+ fn getFloat(b: []const u8, at: usize) f32 {
18
+ return @bitCast(read(b, at));
19
+ }
20
+ fn getRect(b: []const u8, at: usize) geometry.RectF {
21
+ return .init(getFloat(b, at), getFloat(b, at + 4), getFloat(b, at + 8), getFloat(b, at + 12));
22
+ }
23
+ pub const Request = struct {
24
+ bytes: [128]u8 = @splat(0),
25
+ pub fn init(op: Operation, frame: geometry.RectF, tokens: tokens_model.DesignTokens) Request {
26
+ var self: Request = .{};
27
+ self.bytes[0..4].* = .{ 30, 1, @intFromEnum(op), @import("render_plan_policy.zig").numericFlags() };
28
+ self.bytes[9] = @import("control_geometry_policy.zig").signalingFlags();
29
+ self.flags(@as(u32, @intFromBool(tokens.pixel_snap.geometry)) | (@as(u32, @intFromBool(tokens.pixel_snap.text)) << 1));
30
+ inline for (.{ "x", "y", "width", "height" }, 0..) |name, i| self.float(16 + i * 4, @field(frame, name));
31
+ self.float(48, tokens.pixel_snap.scale);
32
+ self.float(84, tokens.stroke.focus_offset);
33
+ self.float(88, tokens.stroke.regular);
34
+ return self;
35
+ }
36
+ pub fn flags(self: *Request, bits: u32) void {
37
+ word(&self.bytes, 4, read(&self.bytes, 4) | bits);
38
+ }
39
+ pub fn float(self: *Request, at: usize, value: f32) void {
40
+ word(&self.bytes, at, @bitCast(value));
41
+ }
42
+ pub fn radius(self: *Request, value: drawing.Radius) void {
43
+ inline for (.{ "top_left", "top_right", "bottom_right", "bottom_left" }, 0..) |name, i| self.float(32 + i * 4, @field(value, name));
44
+ }
45
+ pub fn run(self: Request, tokens: tokens_model.DesignTokens) Result {
46
+ var out: [80]u8 = @splat(0xa5);
47
+ const policy = tokens.control_geometry_policy orelse @panic("missing control content owner");
48
+ if (policy(&self.bytes, &out) != out.len or read(&out, 0) != 1 or read(&out, 4) > 63 or read(&out, 72) > 1 or (self.bytes[2] != @intFromEnum(Operation.input_layout) and read(&out, 72) != 0) or !std.mem.allEqual(u8, out[76..], 0)) @panic("invalid compiled control content result");
49
+ const flags_ = read(&out, 4);
50
+ const expected: u32 = switch (@as(Operation, @enumFromInt(self.bytes[2]))) {
51
+ .snap_rect, .label_frame, .focus_rect, .composition, .input_clip, .clear_icon, .clear_hit => 1,
52
+ .geometry_point, .text_point, .origin, .aligned_origin, .input_origin => 8,
53
+ .layout, .input_layout => 48,
54
+ .glyph_size, .trailing_inset => 16,
55
+ .focus_radius => 4,
56
+ .hairline => 21,
57
+ .icon_label => if (read(&self.bytes, 4) & 8 != 0) 3 else 1,
58
+ };
59
+ if (flags_ != expected) @panic("invalid compiled control content presence");
60
+ inline for (.{ .{ @as(u32, 1), @as(usize, 8), @as(usize, 16) }, .{ 2, 24, 16 }, .{ 4, 40, 16 }, .{ 8, 56, 8 }, .{ 16, 64, 4 }, .{ 32, 68, 4 } }) |field| {
61
+ if (flags_ & field[0] == 0 and !std.mem.allEqual(u8, out[field[1]..][0..field[2]], 0)) @panic("invalid compiled absent control content");
62
+ }
63
+ return .{ .rects = .{ getRect(&out, 8), getRect(&out, 24) }, .radius = .{ .top_left = getFloat(&out, 40), .top_right = getFloat(&out, 44), .bottom_right = getFloat(&out, 48), .bottom_left = getFloat(&out, 52) }, .point = .init(getFloat(&out, 56), getFloat(&out, 60)), .scalar = getFloat(&out, 64), .auxiliary = getFloat(&out, 68), .wrap = @enumFromInt(read(&out, 72)) };
64
+ }
65
+ };
66
+ pub fn rect(op: Operation, frame: geometry.RectF, tokens: tokens_model.DesignTokens) geometry.RectF {
67
+ return Request.init(op, frame, tokens).run(tokens).rects[0];
68
+ }
69
+ pub fn point(op: Operation, value: geometry.PointF, tokens: tokens_model.DesignTokens) geometry.PointF {
70
+ return Request.init(op, .init(value.x, value.y, 0, 0), tokens).run(tokens).point;
71
+ }
72
+ pub fn text(op: Operation, frame: geometry.RectF, size: f32, inset: f32, measured: f32, alignment: u8, tokens: tokens_model.DesignTokens) Result {
73
+ var r = Request.init(op, frame, tokens);
74
+ r.float(52, size);
75
+ r.float(56, inset);
76
+ r.float(60, measured);
77
+ r.bytes[8] = alignment;
78
+ return r.run(tokens);
79
+ }
80
+ pub fn hairline(value: drawing.StrokeRect, tokens: tokens_model.DesignTokens) drawing.StrokeRect {
81
+ var r = Request.init(.hairline, value.rect, tokens);
82
+ r.radius(value.radius);
83
+ r.float(88, value.stroke.width);
84
+ const out = r.run(tokens);
85
+ var copied = value;
86
+ copied.rect = out.rects[0];
87
+ copied.radius = out.radius;
88
+ copied.stroke.width = out.scalar;
89
+ return copied;
90
+ }