@native-sdk/cli 0.0.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +50 -1
  3. package/app.zon +30 -0
  4. package/assets/icon.icns +0 -0
  5. package/assets/icon.ico +0 -0
  6. package/assets/icon.png +0 -0
  7. package/assets/icon.svg +15 -0
  8. package/assets/native-sdk.entitlements +10 -0
  9. package/assets/native-sdk.manifest +12 -0
  10. package/bin/native.js +156 -0
  11. package/build/app.zig +716 -0
  12. package/build.zig +2593 -0
  13. package/build.zig.zon +24 -0
  14. package/native-sdk.d.ts +615 -0
  15. package/package.json +45 -8
  16. package/skill-data/automation/SKILL.md +248 -0
  17. package/skill-data/core/SKILL.md +249 -0
  18. package/skill-data/core/references/app-model-runtime.md +141 -0
  19. package/skill-data/core/references/bridge-security-native-capabilities.md +230 -0
  20. package/skill-data/core/references/frontend-assets.md +124 -0
  21. package/skill-data/core/references/project-anatomy.md +108 -0
  22. package/skill-data/core/references/web-engines-packaging-debugging.md +199 -0
  23. package/skill-data/native-ui/SKILL.md +1080 -0
  24. package/skills/native-sdk/SKILL.md +33 -0
  25. package/src/app_runner/root.zig +740 -0
  26. package/src/assets/root.zig +20 -0
  27. package/src/automation/protocol.zig +285 -0
  28. package/src/automation/root.zig +13 -0
  29. package/src/automation/server.zig +506 -0
  30. package/src/automation/snapshot.zig +1202 -0
  31. package/src/automation/watcher.zig +165 -0
  32. package/src/bridge/root.zig +507 -0
  33. package/src/debug/root.zig +246 -0
  34. package/src/embed/app_exports.zig +11 -0
  35. package/src/embed/c_api.zig +793 -0
  36. package/src/embed/c_exports.zig +10 -0
  37. package/src/embed/chrome.zig +168 -0
  38. package/src/embed/conversions.zig +359 -0
  39. package/src/embed/host.zig +960 -0
  40. package/src/embed/root.zig +81 -0
  41. package/src/embed/tests.zig +2552 -0
  42. package/src/embed/types.zig +382 -0
  43. package/src/embed/ui_host.zig +289 -0
  44. package/src/extensions/root.zig +197 -0
  45. package/src/frontend/root.zig +48 -0
  46. package/src/js/root.zig +65 -0
  47. package/src/platform/android/NativeSdkActivity.java +1370 -0
  48. package/src/platform/android/android_host.c +696 -0
  49. package/src/platform/android/files.zig +9 -0
  50. package/src/platform/android/native_sdk_app.h +237 -0
  51. package/src/platform/ios/files.zig +8 -0
  52. package/src/platform/ios/native_sdk_app.h +289 -0
  53. package/src/platform/ios/uikit_host.m +2739 -0
  54. package/src/platform/linux/cef_host.cpp +599 -0
  55. package/src/platform/linux/gtk_host.c +5362 -0
  56. package/src/platform/linux/gtk_host.h +265 -0
  57. package/src/platform/linux/root.zig +1519 -0
  58. package/src/platform/macos/appkit_host.h +604 -0
  59. package/src/platform/macos/appkit_host.m +10392 -0
  60. package/src/platform/macos/automation_host.h +14 -0
  61. package/src/platform/macos/automation_host.m +12 -0
  62. package/src/platform/macos/cef_host.mm +3028 -0
  63. package/src/platform/macos/root.zig +2260 -0
  64. package/src/platform/null_platform.zig +2232 -0
  65. package/src/platform/null_platform_tests.zig +670 -0
  66. package/src/platform/policy_values.zig +14 -0
  67. package/src/platform/root.zig +181 -0
  68. package/src/platform/types.zig +2681 -0
  69. package/src/platform/windows/cef_host.cpp +3 -0
  70. package/src/platform/windows/root.zig +1521 -0
  71. package/src/platform/windows/webview2_host.cpp +6230 -0
  72. package/src/primitives/app_dirs/root.zig +440 -0
  73. package/src/primitives/app_manifest/root.zig +109 -0
  74. package/src/primitives/app_manifest/tests.zig +758 -0
  75. package/src/primitives/app_manifest/types.zig +587 -0
  76. package/src/primitives/app_manifest/validation.zig +828 -0
  77. package/src/primitives/assets/root.zig +520 -0
  78. package/src/primitives/canvas/a11y_audit.zig +390 -0
  79. package/src/primitives/canvas/a11y_audit_tests.zig +225 -0
  80. package/src/primitives/canvas/app_icon.zig +1590 -0
  81. package/src/primitives/canvas/chart.zig +392 -0
  82. package/src/primitives/canvas/chart_tests.zig +751 -0
  83. package/src/primitives/canvas/commands.zig +446 -0
  84. package/src/primitives/canvas/drawing.zig +309 -0
  85. package/src/primitives/canvas/equality.zig +316 -0
  86. package/src/primitives/canvas/events.zig +696 -0
  87. package/src/primitives/canvas/font_coverage.zig +118 -0
  88. package/src/primitives/canvas/font_ttf.zig +510 -0
  89. package/src/primitives/canvas/font_ttf_tests.zig +280 -0
  90. package/src/primitives/canvas/fonts/Geist-Regular.ttf +0 -0
  91. package/src/primitives/canvas/fonts/GeistMono-Regular.ttf +0 -0
  92. package/src/primitives/canvas/frame.zig +679 -0
  93. package/src/primitives/canvas/frame_metrics.zig +462 -0
  94. package/src/primitives/canvas/gpu.zig +639 -0
  95. package/src/primitives/canvas/hash.zig +112 -0
  96. package/src/primitives/canvas/icons/alert.svg +1 -0
  97. package/src/primitives/canvas/icons/archive.svg +1 -0
  98. package/src/primitives/canvas/icons/arrow-down.svg +1 -0
  99. package/src/primitives/canvas/icons/arrow-right.svg +1 -0
  100. package/src/primitives/canvas/icons/arrow-up.svg +1 -0
  101. package/src/primitives/canvas/icons/check-circle.svg +1 -0
  102. package/src/primitives/canvas/icons/check.svg +1 -0
  103. package/src/primitives/canvas/icons/chevron-down.svg +1 -0
  104. package/src/primitives/canvas/icons/chevron-left.svg +1 -0
  105. package/src/primitives/canvas/icons/chevron-right.svg +1 -0
  106. package/src/primitives/canvas/icons/chevron-up.svg +1 -0
  107. package/src/primitives/canvas/icons/circle-dot.svg +1 -0
  108. package/src/primitives/canvas/icons/clock.svg +1 -0
  109. package/src/primitives/canvas/icons/copy.svg +1 -0
  110. package/src/primitives/canvas/icons/download.svg +1 -0
  111. package/src/primitives/canvas/icons/edit.svg +1 -0
  112. package/src/primitives/canvas/icons/ellipsis.svg +1 -0
  113. package/src/primitives/canvas/icons/external-link.svg +1 -0
  114. package/src/primitives/canvas/icons/eye.svg +1 -0
  115. package/src/primitives/canvas/icons/file-text.svg +1 -0
  116. package/src/primitives/canvas/icons/folder-open.svg +1 -0
  117. package/src/primitives/canvas/icons/folder.svg +1 -0
  118. package/src/primitives/canvas/icons/git-branch.svg +1 -0
  119. package/src/primitives/canvas/icons/git-merge.svg +1 -0
  120. package/src/primitives/canvas/icons/git-pull-request.svg +1 -0
  121. package/src/primitives/canvas/icons/info.svg +1 -0
  122. package/src/primitives/canvas/icons/menu.svg +1 -0
  123. package/src/primitives/canvas/icons/missing.svg +1 -0
  124. package/src/primitives/canvas/icons/moon.svg +1 -0
  125. package/src/primitives/canvas/icons/music.svg +1 -0
  126. package/src/primitives/canvas/icons/panel-left.svg +1 -0
  127. package/src/primitives/canvas/icons/panel-right.svg +1 -0
  128. package/src/primitives/canvas/icons/pause.svg +1 -0
  129. package/src/primitives/canvas/icons/play.svg +1 -0
  130. package/src/primitives/canvas/icons/plus.svg +1 -0
  131. package/src/primitives/canvas/icons/refresh-cw.svg +1 -0
  132. package/src/primitives/canvas/icons/repeat.svg +1 -0
  133. package/src/primitives/canvas/icons/save.svg +1 -0
  134. package/src/primitives/canvas/icons/search.svg +1 -0
  135. package/src/primitives/canvas/icons/send.svg +1 -0
  136. package/src/primitives/canvas/icons/settings.svg +1 -0
  137. package/src/primitives/canvas/icons/shuffle.svg +1 -0
  138. package/src/primitives/canvas/icons/skip-back.svg +1 -0
  139. package/src/primitives/canvas/icons/skip-forward.svg +1 -0
  140. package/src/primitives/canvas/icons/sun.svg +1 -0
  141. package/src/primitives/canvas/icons/terminal.svg +1 -0
  142. package/src/primitives/canvas/icons/trash.svg +1 -0
  143. package/src/primitives/canvas/icons/volume.svg +1 -0
  144. package/src/primitives/canvas/icons/wrench.svg +1 -0
  145. package/src/primitives/canvas/icons/x-circle.svg +1 -0
  146. package/src/primitives/canvas/icons/x.svg +1 -0
  147. package/src/primitives/canvas/icons.zig +249 -0
  148. package/src/primitives/canvas/layout_audit.zig +744 -0
  149. package/src/primitives/canvas/layout_audit_tests.zig +426 -0
  150. package/src/primitives/canvas/markdown.zig +1031 -0
  151. package/src/primitives/canvas/markdown_hostile_tests.zig +471 -0
  152. package/src/primitives/canvas/markdown_tests.zig +538 -0
  153. package/src/primitives/canvas/plan_key_index.zig +120 -0
  154. package/src/primitives/canvas/png.zig +355 -0
  155. package/src/primitives/canvas/reference.zig +1457 -0
  156. package/src/primitives/canvas/reference_blur.zig +104 -0
  157. package/src/primitives/canvas/reference_memo.zig +322 -0
  158. package/src/primitives/canvas/reference_paths.zig +184 -0
  159. package/src/primitives/canvas/reference_tests.zig +1650 -0
  160. package/src/primitives/canvas/render.zig +747 -0
  161. package/src/primitives/canvas/render_effects.zig +255 -0
  162. package/src/primitives/canvas/render_fingerprints.zig +256 -0
  163. package/src/primitives/canvas/render_generic_resources.zig +376 -0
  164. package/src/primitives/canvas/render_images.zig +247 -0
  165. package/src/primitives/canvas/render_layers.zig +260 -0
  166. package/src/primitives/canvas/render_paths.zig +347 -0
  167. package/src/primitives/canvas/render_resources.zig +51 -0
  168. package/src/primitives/canvas/render_tests.zig +3186 -0
  169. package/src/primitives/canvas/root.zig +744 -0
  170. package/src/primitives/canvas/serialization.zig +1528 -0
  171. package/src/primitives/canvas/svg_icon.zig +636 -0
  172. package/src/primitives/canvas/svg_icon_tests.zig +312 -0
  173. package/src/primitives/canvas/test_support.zig +422 -0
  174. package/src/primitives/canvas/testdata/markdown_document.md +83 -0
  175. package/src/primitives/canvas/tests.zig +30 -0
  176. package/src/primitives/canvas/text.zig +82 -0
  177. package/src/primitives/canvas/text_atlas.zig +408 -0
  178. package/src/primitives/canvas/text_batch_tests.zig +431 -0
  179. package/src/primitives/canvas/text_interaction.zig +615 -0
  180. package/src/primitives/canvas/text_layout.zig +1069 -0
  181. package/src/primitives/canvas/text_layout_cache.zig +281 -0
  182. package/src/primitives/canvas/text_layout_hash.zig +113 -0
  183. package/src/primitives/canvas/text_layout_types.zig +128 -0
  184. package/src/primitives/canvas/text_measure_cache.zig +279 -0
  185. package/src/primitives/canvas/text_metrics.zig +309 -0
  186. package/src/primitives/canvas/text_metrics_tests.zig +262 -0
  187. package/src/primitives/canvas/text_span_tests.zig +608 -0
  188. package/src/primitives/canvas/text_spans.zig +1010 -0
  189. package/src/primitives/canvas/text_tests.zig +1949 -0
  190. package/src/primitives/canvas/themes/geist.zig +470 -0
  191. package/src/primitives/canvas/tokens.zig +1522 -0
  192. package/src/primitives/canvas/ui.zig +2686 -0
  193. package/src/primitives/canvas/ui_markup.zig +3791 -0
  194. package/src/primitives/canvas/ui_markup_binary.zig +522 -0
  195. package/src/primitives/canvas/ui_markup_binary_tests.zig +591 -0
  196. package/src/primitives/canvas/ui_markup_compiled.zig +2565 -0
  197. package/src/primitives/canvas/ui_markup_compiled_tests.zig +1669 -0
  198. package/src/primitives/canvas/ui_markup_contract.zig +1620 -0
  199. package/src/primitives/canvas/ui_markup_contract_tests.zig +953 -0
  200. package/src/primitives/canvas/ui_markup_edit.zig +416 -0
  201. package/src/primitives/canvas/ui_markup_edit_tests.zig +341 -0
  202. package/src/primitives/canvas/ui_markup_expr.zig +1152 -0
  203. package/src/primitives/canvas/ui_markup_expr_tests.zig +779 -0
  204. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +505 -0
  205. package/src/primitives/canvas/ui_markup_reflect.zig +127 -0
  206. package/src/primitives/canvas/ui_markup_tests.zig +1545 -0
  207. package/src/primitives/canvas/ui_markup_view.zig +2352 -0
  208. package/src/primitives/canvas/ui_markup_view_tests.zig +3709 -0
  209. package/src/primitives/canvas/ui_provenance.zig +96 -0
  210. package/src/primitives/canvas/ui_provenance_tests.zig +186 -0
  211. package/src/primitives/canvas/ui_schema.zig +825 -0
  212. package/src/primitives/canvas/ui_schema_tests.zig +128 -0
  213. package/src/primitives/canvas/ui_tests.zig +1432 -0
  214. package/src/primitives/canvas/vector.zig +919 -0
  215. package/src/primitives/canvas/vector_tests.zig +547 -0
  216. package/src/primitives/canvas/virtual_extent_tests.zig +317 -0
  217. package/src/primitives/canvas/virtual_extents.zig +540 -0
  218. package/src/primitives/canvas/widget_access.zig +208 -0
  219. package/src/primitives/canvas/widget_anchored_tests.zig +264 -0
  220. package/src/primitives/canvas/widget_builtin_tests.zig +3160 -0
  221. package/src/primitives/canvas/widget_invalidation.zig +748 -0
  222. package/src/primitives/canvas/widget_layout.zig +2055 -0
  223. package/src/primitives/canvas/widget_layout_tests.zig +2691 -0
  224. package/src/primitives/canvas/widget_metrics.zig +228 -0
  225. package/src/primitives/canvas/widget_render.zig +2534 -0
  226. package/src/primitives/canvas/widget_render_controls.zig +1563 -0
  227. package/src/primitives/canvas/widget_render_scroll.zig +136 -0
  228. package/src/primitives/canvas/widget_render_style.zig +626 -0
  229. package/src/primitives/canvas/widget_render_surfaces.zig +794 -0
  230. package/src/primitives/canvas/widget_routing.zig +475 -0
  231. package/src/primitives/canvas/widget_runtime.zig +307 -0
  232. package/src/primitives/canvas/widget_runtime_tests.zig +3015 -0
  233. package/src/primitives/canvas/widget_semantics.zig +480 -0
  234. package/src/primitives/canvas/widget_semantics_tests.zig +2129 -0
  235. package/src/primitives/canvas/widget_tests.zig +8 -0
  236. package/src/primitives/canvas/widget_text_input.zig +351 -0
  237. package/src/primitives/canvas/widget_text_select.zig +147 -0
  238. package/src/primitives/canvas/widget_tree.zig +232 -0
  239. package/src/primitives/canvas/widgets.zig +1319 -0
  240. package/src/primitives/diagnostics/root.zig +445 -0
  241. package/src/primitives/geometry/root.zig +889 -0
  242. package/src/primitives/json/root.zig +272 -0
  243. package/src/primitives/platform_info/root.zig +450 -0
  244. package/src/primitives/trace/root.zig +569 -0
  245. package/src/root.zig +165 -0
  246. package/src/runtime/api.zig +431 -0
  247. package/src/runtime/async_bridge.zig +49 -0
  248. package/src/runtime/automation_commands.zig +686 -0
  249. package/src/runtime/automation_liveness_tests.zig +140 -0
  250. package/src/runtime/automation_snapshot.zig +246 -0
  251. package/src/runtime/automation_widget_dispatch.zig +617 -0
  252. package/src/runtime/bridge_dispatch_tests.zig +202 -0
  253. package/src/runtime/bridge_payload.zig +194 -0
  254. package/src/runtime/bridge_permission_tests.zig +551 -0
  255. package/src/runtime/bridge_responses.zig +414 -0
  256. package/src/runtime/builtin_bridge.zig +554 -0
  257. package/src/runtime/canvas_budget_edge_tests.zig +415 -0
  258. package/src/runtime/canvas_font_tests.zig +410 -0
  259. package/src/runtime/canvas_fonts.zig +229 -0
  260. package/src/runtime/canvas_frame.zig +1734 -0
  261. package/src/runtime/canvas_frame_animation_tests.zig +609 -0
  262. package/src/runtime/canvas_frame_cache_tests.zig +333 -0
  263. package/src/runtime/canvas_frame_helpers.zig +414 -0
  264. package/src/runtime/canvas_frame_invalidation_tests.zig +544 -0
  265. package/src/runtime/canvas_frame_packet_tests.zig +1353 -0
  266. package/src/runtime/canvas_frame_patch_tests.zig +1051 -0
  267. package/src/runtime/canvas_frame_retained_tests.zig +753 -0
  268. package/src/runtime/canvas_frame_tests.zig +9 -0
  269. package/src/runtime/canvas_frame_text_layout_budget_tests.zig +149 -0
  270. package/src/runtime/canvas_image_tests.zig +362 -0
  271. package/src/runtime/canvas_images.zig +224 -0
  272. package/src/runtime/canvas_limits.zig +317 -0
  273. package/src/runtime/canvas_screenshot_tests.zig +289 -0
  274. package/src/runtime/canvas_widget_accessibility_tests.zig +1494 -0
  275. package/src/runtime/canvas_widget_anchored_tests.zig +678 -0
  276. package/src/runtime/canvas_widget_chart_tests.zig +249 -0
  277. package/src/runtime/canvas_widget_clipboard_tests.zig +399 -0
  278. package/src/runtime/canvas_widget_context_menu.zig +318 -0
  279. package/src/runtime/canvas_widget_context_menu_tests.zig +462 -0
  280. package/src/runtime/canvas_widget_control_tests.zig +2164 -0
  281. package/src/runtime/canvas_widget_disclosure_tests.zig +440 -0
  282. package/src/runtime/canvas_widget_display.zig +677 -0
  283. package/src/runtime/canvas_widget_event_tests.zig +1779 -0
  284. package/src/runtime/canvas_widget_events.zig +1098 -0
  285. package/src/runtime/canvas_widget_floating_tests.zig +695 -0
  286. package/src/runtime/canvas_widget_layout_tests.zig +26 -0
  287. package/src/runtime/canvas_widget_runtime.zig +1335 -0
  288. package/src/runtime/canvas_widget_scroll_driver_tests.zig +582 -0
  289. package/src/runtime/canvas_widget_scroll_drivers.zig +202 -0
  290. package/src/runtime/canvas_widget_scroll_tests.zig +1549 -0
  291. package/src/runtime/canvas_widget_semantics_tests.zig +810 -0
  292. package/src/runtime/canvas_widget_split_tree_tests.zig +1031 -0
  293. package/src/runtime/canvas_widget_state.zig +798 -0
  294. package/src/runtime/canvas_widget_text_tests.zig +2104 -0
  295. package/src/runtime/canvas_widget_window_drag_tests.zig +284 -0
  296. package/src/runtime/clock.zig +231 -0
  297. package/src/runtime/core.zig +927 -0
  298. package/src/runtime/effects.zig +4197 -0
  299. package/src/runtime/effects_audio_tests.zig +690 -0
  300. package/src/runtime/effects_clipboard_tests.zig +317 -0
  301. package/src/runtime/effects_fetch_tests.zig +1031 -0
  302. package/src/runtime/effects_file_tests.zig +407 -0
  303. package/src/runtime/effects_tests.zig +1251 -0
  304. package/src/runtime/flow.zig +1175 -0
  305. package/src/runtime/frame_profile.zig +221 -0
  306. package/src/runtime/gpu_surface_events.zig +639 -0
  307. package/src/runtime/launch_timing.zig +59 -0
  308. package/src/runtime/markdown_app_tests.zig +224 -0
  309. package/src/runtime/native_command_event_tests.zig +431 -0
  310. package/src/runtime/platform_bridge_tests.zig +8 -0
  311. package/src/runtime/platform_config_tests.zig +392 -0
  312. package/src/runtime/root.zig +150 -0
  313. package/src/runtime/runtime_event_tests.zig +1079 -0
  314. package/src/runtime/session_journal.zig +1522 -0
  315. package/src/runtime/session_record.zig +332 -0
  316. package/src/runtime/session_replay.zig +274 -0
  317. package/src/runtime/session_state.zig +30 -0
  318. package/src/runtime/session_tests.zig +399 -0
  319. package/src/runtime/shell_layout.zig +472 -0
  320. package/src/runtime/shell_layout_tests.zig +1246 -0
  321. package/src/runtime/shell_view_tests.zig +604 -0
  322. package/src/runtime/state.zig +110 -0
  323. package/src/runtime/system_services.zig +392 -0
  324. package/src/runtime/test_support.zig +79 -0
  325. package/src/runtime/tests.zig +30 -0
  326. package/src/runtime/ui_app.zig +3290 -0
  327. package/src/runtime/ui_app_huge_model_tests.zig +351 -0
  328. package/src/runtime/ui_app_provenance.zig +370 -0
  329. package/src/runtime/ui_app_tests.zig +3254 -0
  330. package/src/runtime/ui_app_virtual_variable_tests.zig +485 -0
  331. package/src/runtime/ui_app_window_tests.zig +442 -0
  332. package/src/runtime/validation.zig +206 -0
  333. package/src/runtime/view.zig +908 -0
  334. package/src/runtime/view_canvas.zig +850 -0
  335. package/src/runtime/view_widget_control.zig +433 -0
  336. package/src/runtime/view_widget_scroll.zig +360 -0
  337. package/src/runtime/view_widget_text.zig +275 -0
  338. package/src/runtime/view_widget_tree.zig +843 -0
  339. package/src/runtime/webview_view_bridge_tests.zig +664 -0
  340. package/src/runtime/widget_bridge.zig +231 -0
  341. package/src/runtime/window_command_bridge_tests.zig +403 -0
  342. package/src/runtime/window_storage.zig +255 -0
  343. package/src/runtime/window_view_runtime.zig +727 -0
  344. package/src/runtime/window_views.zig +334 -0
  345. package/src/security/root.zig +118 -0
  346. package/src/tooling/android.zig +1172 -0
  347. package/src/tooling/assets.zig +128 -0
  348. package/src/tooling/buildgraph.zig +379 -0
  349. package/src/tooling/cef.zig +671 -0
  350. package/src/tooling/codesign.zig +172 -0
  351. package/src/tooling/components/identity_tests.zig +185 -0
  352. package/src/tooling/components/stepper.zig +113 -0
  353. package/src/tooling/components/timeline.native +27 -0
  354. package/src/tooling/components/timeline_item.zig +131 -0
  355. package/src/tooling/default_icon.icns +0 -0
  356. package/src/tooling/default_icon.png +0 -0
  357. package/src/tooling/dev.zig +172 -0
  358. package/src/tooling/doctor.zig +349 -0
  359. package/src/tooling/eject_components.zig +170 -0
  360. package/src/tooling/embedlib.zig +290 -0
  361. package/src/tooling/ios.zig +528 -0
  362. package/src/tooling/manifest.zig +1939 -0
  363. package/src/tooling/package.zig +2388 -0
  364. package/src/tooling/process_tree.zig +114 -0
  365. package/src/tooling/raw_manifest.zig +193 -0
  366. package/src/tooling/root.zig +22 -0
  367. package/src/tooling/templates.zig +3191 -0
  368. package/src/tooling/toolchain.zig +371 -0
  369. package/src/tooling/verbs.zig +204 -0
  370. package/src/tooling/web_engine.zig +135 -0
  371. package/src/tooling/xcodeproj.zig +462 -0
  372. package/src/window_state/root.zig +507 -0
  373. package/index.js +0 -2
@@ -0,0 +1,309 @@
1
+ const geometry = @import("geometry");
2
+
3
+ const ObjectId = u64;
4
+ const ImageId = u64;
5
+
6
+ pub const Color = struct {
7
+ r: f32 = 0,
8
+ g: f32 = 0,
9
+ b: f32 = 0,
10
+ a: f32 = 1,
11
+
12
+ pub fn rgba(r: f32, g: f32, b: f32, a: f32) Color {
13
+ return .{ .r = r, .g = g, .b = b, .a = a };
14
+ }
15
+
16
+ pub fn rgb8(r: u8, g: u8, b: u8) Color {
17
+ return rgba8(r, g, b, 255);
18
+ }
19
+
20
+ pub fn rgba8(r: u8, g: u8, b: u8, a: u8) Color {
21
+ return .{
22
+ .r = @as(f32, @floatFromInt(r)) / 255.0,
23
+ .g = @as(f32, @floatFromInt(g)) / 255.0,
24
+ .b = @as(f32, @floatFromInt(b)) / 255.0,
25
+ .a = @as(f32, @floatFromInt(a)) / 255.0,
26
+ };
27
+ }
28
+ };
29
+
30
+ pub const Affine = struct {
31
+ a: f32 = 1,
32
+ b: f32 = 0,
33
+ c: f32 = 0,
34
+ d: f32 = 1,
35
+ tx: f32 = 0,
36
+ ty: f32 = 0,
37
+
38
+ pub fn identity() Affine {
39
+ return .{};
40
+ }
41
+
42
+ pub fn translate(x: f32, y: f32) Affine {
43
+ return .{ .tx = x, .ty = y };
44
+ }
45
+
46
+ pub fn scale(x: f32, y: f32) Affine {
47
+ return .{ .a = x, .d = y };
48
+ }
49
+
50
+ pub fn multiply(self: Affine, other: Affine) Affine {
51
+ return .{
52
+ .a = self.a * other.a + self.c * other.b,
53
+ .b = self.b * other.a + self.d * other.b,
54
+ .c = self.a * other.c + self.c * other.d,
55
+ .d = self.b * other.c + self.d * other.d,
56
+ .tx = self.a * other.tx + self.c * other.ty + self.tx,
57
+ .ty = self.b * other.tx + self.d * other.ty + self.ty,
58
+ };
59
+ }
60
+
61
+ pub fn transformPoint(self: Affine, point: geometry.PointF) geometry.PointF {
62
+ return .{
63
+ .x = self.a * point.x + self.c * point.y + self.tx,
64
+ .y = self.b * point.x + self.d * point.y + self.ty,
65
+ };
66
+ }
67
+
68
+ pub fn transformRect(self: Affine, rect: geometry.RectF) geometry.RectF {
69
+ const normalized = rect.normalized();
70
+ return boundsFromPoints(&.{
71
+ self.transformPoint(normalized.topLeft()),
72
+ self.transformPoint(normalized.topRight()),
73
+ self.transformPoint(normalized.bottomLeft()),
74
+ self.transformPoint(normalized.bottomRight()),
75
+ }) orelse geometry.RectF.zero();
76
+ }
77
+
78
+ pub fn inverse(self: Affine) ?Affine {
79
+ const determinant = self.a * self.d - self.b * self.c;
80
+ if (@abs(determinant) <= 0.000001) return null;
81
+ const inv = 1 / determinant;
82
+ return .{
83
+ .a = self.d * inv,
84
+ .b = -self.b * inv,
85
+ .c = -self.c * inv,
86
+ .d = self.a * inv,
87
+ .tx = (self.c * self.ty - self.d * self.tx) * inv,
88
+ .ty = (self.b * self.tx - self.a * self.ty) * inv,
89
+ };
90
+ }
91
+ };
92
+
93
+ pub const Radius = struct {
94
+ top_left: f32 = 0,
95
+ top_right: f32 = 0,
96
+ bottom_right: f32 = 0,
97
+ bottom_left: f32 = 0,
98
+
99
+ pub fn all(value: f32) Radius {
100
+ return .{
101
+ .top_left = value,
102
+ .top_right = value,
103
+ .bottom_right = value,
104
+ .bottom_left = value,
105
+ };
106
+ }
107
+ };
108
+
109
+ pub const GradientStop = struct {
110
+ offset: f32,
111
+ color: Color,
112
+ };
113
+
114
+ pub const LinearGradient = struct {
115
+ start: geometry.PointF,
116
+ end: geometry.PointF,
117
+ stops: []const GradientStop = &.{},
118
+ };
119
+
120
+ pub const Fill = union(enum) {
121
+ color: Color,
122
+ linear_gradient: LinearGradient,
123
+ };
124
+
125
+ pub const Stroke = struct {
126
+ fill: Fill,
127
+ width: f32 = 1,
128
+ };
129
+
130
+ pub const Clip = struct {
131
+ id: ObjectId = 0,
132
+ rect: geometry.RectF,
133
+ radius: Radius = .{},
134
+ };
135
+
136
+ pub const FillRect = struct {
137
+ id: ObjectId = 0,
138
+ rect: geometry.RectF,
139
+ fill: Fill,
140
+ };
141
+
142
+ pub const StrokeRect = struct {
143
+ id: ObjectId = 0,
144
+ rect: geometry.RectF,
145
+ radius: Radius = .{},
146
+ stroke: Stroke,
147
+ };
148
+
149
+ pub const FillRoundedRect = struct {
150
+ id: ObjectId = 0,
151
+ rect: geometry.RectF,
152
+ radius: Radius,
153
+ fill: Fill,
154
+ };
155
+
156
+ pub const Line = struct {
157
+ id: ObjectId = 0,
158
+ from: geometry.PointF,
159
+ to: geometry.PointF,
160
+ stroke: Stroke,
161
+ };
162
+
163
+ pub const PathVerb = enum {
164
+ move_to,
165
+ line_to,
166
+ quad_to,
167
+ cubic_to,
168
+ close,
169
+ };
170
+
171
+ pub const PathElement = struct {
172
+ verb: PathVerb,
173
+ points: [3]geometry.PointF = [_]geometry.PointF{geometry.PointF.zero()} ** 3,
174
+ };
175
+
176
+ pub const FillPath = struct {
177
+ id: ObjectId = 0,
178
+ elements: []const PathElement = &.{},
179
+ fill: Fill,
180
+ };
181
+
182
+ /// Stroke end-cap shape for open subpaths. `butt` ends the stroke
183
+ /// exactly at the endpoint (the SVG default and what the packet hosts
184
+ /// draw when no cap is specified); `round` extends it with a
185
+ /// half-stroke-width semicircle — the stroke-icon dialect and the house
186
+ /// spinner arc are authored for round caps. Closed subpaths have no
187
+ /// ends, so the cap never affects them.
188
+ pub const LineCap = enum {
189
+ butt,
190
+ round,
191
+ };
192
+
193
+ pub const StrokePath = struct {
194
+ id: ObjectId = 0,
195
+ elements: []const PathElement = &.{},
196
+ stroke: Stroke,
197
+ /// End-cap shape for the path's open subpaths. Lives on the command
198
+ /// (not on `Stroke`) because caps are a property of path stroking:
199
+ /// rect strokes are closed contours and `draw_line` keeps its
200
+ /// historical semantics, so a cap field there would be ignored.
201
+ cap: LineCap = .butt,
202
+ };
203
+
204
+ pub const ImageFit = enum {
205
+ stretch,
206
+ contain,
207
+ cover,
208
+ };
209
+
210
+ pub const ImageSampling = enum {
211
+ nearest,
212
+ linear,
213
+ };
214
+
215
+ pub const DrawImage = struct {
216
+ id: ObjectId = 0,
217
+ image_id: ImageId,
218
+ src: ?geometry.RectF = null,
219
+ dst: geometry.RectF,
220
+ opacity: f32 = 1,
221
+ fit: ImageFit = .stretch,
222
+ sampling: ImageSampling = .linear,
223
+ /// Rounded-corner mask in destination space: pixels outside the
224
+ /// rounded `dst` rect are not drawn (the avatar circle clip). Zero —
225
+ /// the default — keeps the plain rectangular draw. Carried on the
226
+ /// draw itself because the render plan flattens clip stacks to
227
+ /// rectangles, which would drop a rounded clip's corners.
228
+ radius: Radius = .{},
229
+ };
230
+
231
+ pub const Shadow = struct {
232
+ id: ObjectId = 0,
233
+ rect: geometry.RectF,
234
+ radius: Radius = .{},
235
+ offset: geometry.OffsetF = .{},
236
+ blur: f32 = 0,
237
+ spread: f32 = 0,
238
+ color: Color,
239
+ };
240
+
241
+ pub const Blur = struct {
242
+ id: ObjectId = 0,
243
+ rect: geometry.RectF,
244
+ radius: f32 = 0,
245
+ };
246
+
247
+ pub fn strokeBounds(rect: geometry.RectF, width: f32) geometry.RectF {
248
+ return rect.normalized().inflate(geometry.InsetsF.all(nonNegative(width) * 0.5));
249
+ }
250
+
251
+ pub fn shadowBounds(value: Shadow) geometry.RectF {
252
+ const spread = nonNegative(@abs(value.spread));
253
+ const blur_radius = nonNegative(value.blur);
254
+ return value.rect
255
+ .normalized()
256
+ .translate(value.offset)
257
+ .inflate(geometry.InsetsF.all(spread + blur_radius));
258
+ }
259
+
260
+ pub fn pathBounds(elements: []const PathElement) ?geometry.RectF {
261
+ var has_point = false;
262
+ var min_x: f32 = 0;
263
+ var min_y: f32 = 0;
264
+ var max_x: f32 = 0;
265
+ var max_y: f32 = 0;
266
+ for (elements) |element| {
267
+ const point_count: usize = switch (element.verb) {
268
+ .move_to, .line_to => 1,
269
+ .quad_to => 2,
270
+ .cubic_to => 3,
271
+ .close => 0,
272
+ };
273
+ for (element.points[0..point_count]) |point| {
274
+ if (!has_point) {
275
+ has_point = true;
276
+ min_x = point.x;
277
+ min_y = point.y;
278
+ max_x = point.x;
279
+ max_y = point.y;
280
+ } else {
281
+ min_x = @min(min_x, point.x);
282
+ min_y = @min(min_y, point.y);
283
+ max_x = @max(max_x, point.x);
284
+ max_y = @max(max_y, point.y);
285
+ }
286
+ }
287
+ }
288
+ if (!has_point) return null;
289
+ return geometry.RectF.init(min_x, min_y, max_x - min_x, max_y - min_y);
290
+ }
291
+
292
+ fn boundsFromPoints(points: []const geometry.PointF) ?geometry.RectF {
293
+ if (points.len == 0) return null;
294
+ var min_x = points[0].x;
295
+ var min_y = points[0].y;
296
+ var max_x = points[0].x;
297
+ var max_y = points[0].y;
298
+ for (points[1..]) |point| {
299
+ min_x = @min(min_x, point.x);
300
+ min_y = @min(min_y, point.y);
301
+ max_x = @max(max_x, point.x);
302
+ max_y = @max(max_y, point.y);
303
+ }
304
+ return geometry.RectF.init(min_x, min_y, max_x - min_x, max_y - min_y);
305
+ }
306
+
307
+ fn nonNegative(value: f32) f32 {
308
+ return @max(0, value);
309
+ }
@@ -0,0 +1,316 @@
1
+ const std = @import("std");
2
+ const geometry = @import("geometry");
3
+ const command_model = @import("commands.zig");
4
+ const drawing_model = @import("drawing.zig");
5
+ const text_model = @import("text.zig");
6
+
7
+ const CanvasCommand = command_model.CanvasCommand;
8
+ const Color = drawing_model.Color;
9
+ const Affine = drawing_model.Affine;
10
+ const Radius = drawing_model.Radius;
11
+ const GradientStop = drawing_model.GradientStop;
12
+ const LinearGradient = drawing_model.LinearGradient;
13
+ const Fill = drawing_model.Fill;
14
+ const Stroke = drawing_model.Stroke;
15
+ const Clip = drawing_model.Clip;
16
+ const FillRect = drawing_model.FillRect;
17
+ const StrokeRect = drawing_model.StrokeRect;
18
+ const FillRoundedRect = drawing_model.FillRoundedRect;
19
+ const Line = drawing_model.Line;
20
+ const PathElement = drawing_model.PathElement;
21
+ const FillPath = drawing_model.FillPath;
22
+ const StrokePath = drawing_model.StrokePath;
23
+ const DrawImage = drawing_model.DrawImage;
24
+ const Shadow = drawing_model.Shadow;
25
+ const Blur = drawing_model.Blur;
26
+ const Glyph = text_model.Glyph;
27
+ const DrawText = text_model.DrawText;
28
+ const TextLayoutOptions = text_model.TextLayoutOptions;
29
+ const TextSelection = text_model.TextSelection;
30
+ const TextRange = text_model.TextRange;
31
+
32
+ pub fn commandsEqual(a: CanvasCommand, b: CanvasCommand) bool {
33
+ return switch (a) {
34
+ .push_clip => |value| switch (b) {
35
+ .push_clip => |other| clipsEqual(value, other),
36
+ else => false,
37
+ },
38
+ .pop_clip => switch (b) {
39
+ .pop_clip => true,
40
+ else => false,
41
+ },
42
+ .push_opacity => |value| switch (b) {
43
+ .push_opacity => |other| value == other,
44
+ else => false,
45
+ },
46
+ .pop_opacity => switch (b) {
47
+ .pop_opacity => true,
48
+ else => false,
49
+ },
50
+ .transform => |value| switch (b) {
51
+ .transform => |other| affinesEqual(value, other),
52
+ else => false,
53
+ },
54
+ .fill_rect => |value| switch (b) {
55
+ .fill_rect => |other| fillRectsEqual(value, other),
56
+ else => false,
57
+ },
58
+ .stroke_rect => |value| switch (b) {
59
+ .stroke_rect => |other| strokeRectsEqual(value, other),
60
+ else => false,
61
+ },
62
+ .fill_rounded_rect => |value| switch (b) {
63
+ .fill_rounded_rect => |other| fillRoundedRectsEqual(value, other),
64
+ else => false,
65
+ },
66
+ .draw_line => |value| switch (b) {
67
+ .draw_line => |other| linesEqual(value, other),
68
+ else => false,
69
+ },
70
+ .fill_path => |value| switch (b) {
71
+ .fill_path => |other| fillPathsEqual(value, other),
72
+ else => false,
73
+ },
74
+ .stroke_path => |value| switch (b) {
75
+ .stroke_path => |other| strokePathsEqual(value, other),
76
+ else => false,
77
+ },
78
+ .draw_image => |value| switch (b) {
79
+ .draw_image => |other| drawImagesEqual(value, other),
80
+ else => false,
81
+ },
82
+ .draw_text => |value| switch (b) {
83
+ .draw_text => |other| drawTextsEqual(value, other),
84
+ else => false,
85
+ },
86
+ .shadow => |value| switch (b) {
87
+ .shadow => |other| shadowsEqual(value, other),
88
+ else => false,
89
+ },
90
+ .blur => |value| switch (b) {
91
+ .blur => |other| blursEqual(value, other),
92
+ else => false,
93
+ },
94
+ };
95
+ }
96
+
97
+ pub fn clipsEqual(a: Clip, b: Clip) bool {
98
+ return a.id == b.id and rectsEqual(a.rect, b.rect) and radiiEqual(a.radius, b.radius);
99
+ }
100
+
101
+ pub fn fillRectsEqual(a: FillRect, b: FillRect) bool {
102
+ return a.id == b.id and rectsEqual(a.rect, b.rect) and fillsEqual(a.fill, b.fill);
103
+ }
104
+
105
+ pub fn strokeRectsEqual(a: StrokeRect, b: StrokeRect) bool {
106
+ return a.id == b.id and rectsEqual(a.rect, b.rect) and radiiEqual(a.radius, b.radius) and strokesEqual(a.stroke, b.stroke);
107
+ }
108
+
109
+ pub fn fillRoundedRectsEqual(a: FillRoundedRect, b: FillRoundedRect) bool {
110
+ return a.id == b.id and rectsEqual(a.rect, b.rect) and radiiEqual(a.radius, b.radius) and fillsEqual(a.fill, b.fill);
111
+ }
112
+
113
+ pub fn linesEqual(a: Line, b: Line) bool {
114
+ return a.id == b.id and pointsEqual(a.from, b.from) and pointsEqual(a.to, b.to) and strokesEqual(a.stroke, b.stroke);
115
+ }
116
+
117
+ pub fn fillPathsEqual(a: FillPath, b: FillPath) bool {
118
+ return a.id == b.id and pathElementsEqual(a.elements, b.elements) and fillsEqual(a.fill, b.fill);
119
+ }
120
+
121
+ pub fn strokePathsEqual(a: StrokePath, b: StrokePath) bool {
122
+ return a.id == b.id and a.cap == b.cap and pathElementsEqual(a.elements, b.elements) and strokesEqual(a.stroke, b.stroke);
123
+ }
124
+
125
+ pub fn drawImagesEqual(a: DrawImage, b: DrawImage) bool {
126
+ return a.id == b.id and
127
+ a.image_id == b.image_id and
128
+ optionalRectsEqual(a.src, b.src) and
129
+ rectsEqual(a.dst, b.dst) and
130
+ a.opacity == b.opacity and
131
+ a.fit == b.fit and
132
+ a.sampling == b.sampling and
133
+ radiiEqual(a.radius, b.radius);
134
+ }
135
+
136
+ pub fn drawTextsEqual(a: DrawText, b: DrawText) bool {
137
+ return a.id == b.id and
138
+ a.font_id == b.font_id and
139
+ a.size == b.size and
140
+ pointsEqual(a.origin, b.origin) and
141
+ colorsEqual(a.color, b.color) and
142
+ std.mem.eql(u8, a.text, b.text) and
143
+ glyphsEqual(a.glyphs, b.glyphs) and
144
+ optionalTextLayoutOptionsEqual(a.text_layout, b.text_layout);
145
+ }
146
+
147
+ pub fn optionalTextLayoutOptionsEqual(a: ?TextLayoutOptions, b: ?TextLayoutOptions) bool {
148
+ if (a) |left| {
149
+ if (b) |right| return textLayoutOptionsEqual(left, right);
150
+ return false;
151
+ }
152
+ return b == null;
153
+ }
154
+
155
+ pub fn textLayoutOptionsEqual(a: TextLayoutOptions, b: TextLayoutOptions) bool {
156
+ return nonNegative(a.max_width) == nonNegative(b.max_width) and
157
+ nonNegative(a.line_height) == nonNegative(b.line_height) and
158
+ a.wrap == b.wrap and
159
+ a.alignment == b.alignment and
160
+ a.overflow == b.overflow;
161
+ }
162
+
163
+ pub fn shadowsEqual(a: Shadow, b: Shadow) bool {
164
+ return a.id == b.id and
165
+ rectsEqual(a.rect, b.rect) and
166
+ radiiEqual(a.radius, b.radius) and
167
+ offsetsEqual(a.offset, b.offset) and
168
+ a.blur == b.blur and
169
+ a.spread == b.spread and
170
+ colorsEqual(a.color, b.color);
171
+ }
172
+
173
+ pub fn blursEqual(a: Blur, b: Blur) bool {
174
+ return a.id == b.id and rectsEqual(a.rect, b.rect) and a.radius == b.radius;
175
+ }
176
+
177
+ pub fn fillsEqual(a: Fill, b: Fill) bool {
178
+ return switch (a) {
179
+ .color => |value| switch (b) {
180
+ .color => |other| colorsEqual(value, other),
181
+ else => false,
182
+ },
183
+ .linear_gradient => |value| switch (b) {
184
+ .linear_gradient => |other| linearGradientsEqual(value, other),
185
+ else => false,
186
+ },
187
+ };
188
+ }
189
+
190
+ pub fn strokesEqual(a: Stroke, b: Stroke) bool {
191
+ return a.width == b.width and fillsEqual(a.fill, b.fill);
192
+ }
193
+
194
+ pub fn linearGradientsEqual(a: LinearGradient, b: LinearGradient) bool {
195
+ return pointsEqual(a.start, b.start) and pointsEqual(a.end, b.end) and gradientStopsEqual(a.stops, b.stops);
196
+ }
197
+
198
+ pub fn gradientStopsEqual(a: []const GradientStop, b: []const GradientStop) bool {
199
+ if (a.len != b.len) return false;
200
+ for (a, b) |left, right| {
201
+ if (left.offset != right.offset or !colorsEqual(left.color, right.color)) return false;
202
+ }
203
+ return true;
204
+ }
205
+
206
+ pub fn pathElementsEqual(a: []const PathElement, b: []const PathElement) bool {
207
+ if (a.len != b.len) return false;
208
+ for (a, b) |left, right| {
209
+ if (left.verb != right.verb) return false;
210
+ if (!pointsEqual(left.points[0], right.points[0])) return false;
211
+ if (!pointsEqual(left.points[1], right.points[1])) return false;
212
+ if (!pointsEqual(left.points[2], right.points[2])) return false;
213
+ }
214
+ return true;
215
+ }
216
+
217
+ pub fn glyphsEqual(a: []const Glyph, b: []const Glyph) bool {
218
+ if (a.len != b.len) return false;
219
+ for (a, b) |left, right| {
220
+ if (left.id != right.id or
221
+ left.font_id != right.font_id or
222
+ left.x != right.x or
223
+ left.y != right.y or
224
+ left.advance != right.advance or
225
+ left.text_start != right.text_start or
226
+ left.text_len != right.text_len) return false;
227
+ }
228
+ return true;
229
+ }
230
+
231
+ pub fn rectsEqual(a: geometry.RectF, b: geometry.RectF) bool {
232
+ return a.x == b.x and a.y == b.y and a.width == b.width and a.height == b.height;
233
+ }
234
+
235
+ pub fn optionalRectsEqual(a: ?geometry.RectF, b: ?geometry.RectF) bool {
236
+ if (a) |left| {
237
+ if (b) |right| return rectsEqual(left, right);
238
+ return false;
239
+ }
240
+ return b == null;
241
+ }
242
+
243
+ pub fn sizesEqual(a: geometry.SizeF, b: geometry.SizeF) bool {
244
+ return a.width == b.width and a.height == b.height;
245
+ }
246
+
247
+ pub fn insetsEqual(a: geometry.InsetsF, b: geometry.InsetsF) bool {
248
+ return a.top == b.top and
249
+ a.right == b.right and
250
+ a.bottom == b.bottom and
251
+ a.left == b.left;
252
+ }
253
+
254
+ pub fn pointsEqual(a: geometry.PointF, b: geometry.PointF) bool {
255
+ return a.x == b.x and a.y == b.y;
256
+ }
257
+
258
+ pub fn offsetsEqual(a: geometry.OffsetF, b: geometry.OffsetF) bool {
259
+ return a.dx == b.dx and a.dy == b.dy;
260
+ }
261
+
262
+ pub fn colorsEqual(a: Color, b: Color) bool {
263
+ return a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a;
264
+ }
265
+
266
+ pub fn optionalColorsEqual(a: ?Color, b: ?Color) bool {
267
+ if (a) |left| {
268
+ if (b) |right| return colorsEqual(left, right);
269
+ return false;
270
+ }
271
+ return b == null;
272
+ }
273
+
274
+ pub fn radiiEqual(a: Radius, b: Radius) bool {
275
+ return a.top_left == b.top_left and
276
+ a.top_right == b.top_right and
277
+ a.bottom_right == b.bottom_right and
278
+ a.bottom_left == b.bottom_left;
279
+ }
280
+
281
+ pub fn affinesEqual(a: Affine, b: Affine) bool {
282
+ return a.a == b.a and
283
+ a.b == b.b and
284
+ a.c == b.c and
285
+ a.d == b.d and
286
+ a.tx == b.tx and
287
+ a.ty == b.ty;
288
+ }
289
+
290
+ pub fn optionalF32Equal(a: ?f32, b: ?f32) bool {
291
+ if (a) |left| {
292
+ if (b) |right| return left == right;
293
+ return false;
294
+ }
295
+ return b == null;
296
+ }
297
+
298
+ pub fn optionalTextSelectionsEqual(a: ?TextSelection, b: ?TextSelection) bool {
299
+ if (a) |left| {
300
+ if (b) |right| return left.anchor == right.anchor and left.focus == right.focus;
301
+ return false;
302
+ }
303
+ return b == null;
304
+ }
305
+
306
+ pub fn optionalTextRangesEqual(a: ?TextRange, b: ?TextRange) bool {
307
+ if (a) |left| {
308
+ if (b) |right| return left.start == right.start and left.end == right.end;
309
+ return false;
310
+ }
311
+ return b == null;
312
+ }
313
+
314
+ fn nonNegative(value: f32) f32 {
315
+ return @max(0, value);
316
+ }