@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,243 @@
1
+ /** Copied vector geometry and coverage programs. Native retains the edge,
2
+ * crossing and pixel buffers; no address or sink crosses this boundary. */
3
+ interface NscRasterPoint { x: number; y: number }
4
+ interface NscRasterEdge { x0: number; y0: number; x1: number; y1: number; dir: number }
5
+
6
+ function nscvRasterPoint(x: number, y: number): NscRasterPoint { return { x, y }; }
7
+ function nscvRasterNormalize(p: NscRasterPoint): NscRasterPoint | null {
8
+ const f = Math.fround, length = f(Math.sqrt(f(f(p.x * p.x) + f(p.y * p.y))));
9
+ return length <= f(0.000001) ? null : { x: f(p.x / length), y: f(p.y / length) };
10
+ }
11
+ function nscvRasterSegments(a: NscRasterPoint, b: NscRasterPoint, c: NscRasterPoint, d: NscRasterPoint | null, tolerance: number, limit: number, rules: number): number {
12
+ const f = Math.fround;
13
+ let deviation = nscvResourceExtremum(Math.abs(f(f(a.x - f(2 * b.x)) + c.x)), Math.abs(f(f(a.y - f(2 * b.y)) + c.y)), true, rules);
14
+ if (d !== null) deviation = f(nscvResourceExtremum(deviation, nscvResourceExtremum(Math.abs(f(f(b.x - f(2 * c.x)) + d.x)), Math.abs(f(f(b.y - f(2 * c.y)) + d.y)), true, rules), true, rules) * 0.75);
15
+ else deviation = f(deviation * 0.25);
16
+ const tol = nscvResourceExtremum(f(0.01), tolerance, true, rules);
17
+ if (!(deviation > tol)) return 1;
18
+ const count = Math.ceil(f(Math.sqrt(f(deviation / tol))));
19
+ return !(count > 1) ? 1 : count >= limit ? limit : count;
20
+ }
21
+ function nscvRasterCurve(a: NscRasterPoint, b: NscRasterPoint, c: NscRasterPoint, d: NscRasterPoint | null, t: number): NscRasterPoint {
22
+ const f = Math.fround, u = f(1 - t);
23
+ if (d === null) return {
24
+ x: f(f(f(f(u * u) * a.x) + f(f(f(2 * u) * t) * b.x)) + f(f(t * t) * c.x)),
25
+ y: f(f(f(f(u * u) * a.y) + f(f(f(2 * u) * t) * b.y)) + f(f(t * t) * c.y)),
26
+ };
27
+ return {
28
+ x: f(f(f(f(f(f(u * u) * u) * a.x) + f(f(f(f(3 * u) * u) * t) * b.x)) + f(f(f(f(3 * u) * t) * t) * c.x)) + f(f(f(t * t) * t) * d.x)),
29
+ y: f(f(f(f(f(f(u * u) * u) * a.y) + f(f(f(f(3 * u) * u) * t) * b.y)) + f(f(f(f(3 * u) * t) * t) * c.y)) + f(f(f(t * t) * t) * d.y)),
30
+ };
31
+ }
32
+
33
+ class NscVectorRaster {
34
+ edges: NscRasterEdge[] = [];
35
+ status = 0;
36
+ minX = 0; minY = 0; maxX = 0; maxY = 0;
37
+ capacity: number; rules: number;
38
+ constructor(capacity: number, rules: number) { this.capacity = capacity; this.rules = rules; }
39
+ edge(a: NscRasterPoint, b: NscRasterPoint): void {
40
+ if (this.status !== 0 || a.y === b.y || !Number.isFinite(a.x) || !Number.isFinite(a.y) || !Number.isFinite(b.x) || !Number.isFinite(b.y)) return;
41
+ if (this.edges.length >= this.capacity) { this.status = 1; return; }
42
+ const x = nscvResourceExtremum(a.x, b.x, false, this.rules), right = nscvResourceExtremum(a.x, b.x, true, this.rules);
43
+ const y = nscvResourceExtremum(a.y, b.y, false, this.rules), bottom = nscvResourceExtremum(a.y, b.y, true, this.rules);
44
+ if (this.edges.length === 0) { this.minX = x; this.maxX = right; this.minY = y; this.maxY = bottom; }
45
+ else {
46
+ this.minX = nscvResourceExtremum(this.minX, x, false, this.rules); this.maxX = nscvResourceExtremum(this.maxX, right, true, this.rules);
47
+ this.minY = nscvResourceExtremum(this.minY, y, false, this.rules); this.maxY = nscvResourceExtremum(this.maxY, bottom, true, this.rules);
48
+ }
49
+ this.edges.push({ x0: a.x, y0: a.y, x1: b.x, y1: b.y, dir: b.y > a.y ? 1 : -1 });
50
+ }
51
+ polygon(points: readonly NscRasterPoint[]): void {
52
+ if (points.length < 3 || this.status !== 0) return;
53
+ const f = Math.fround;
54
+ let area = 0;
55
+ for (let i = 0; i < points.length; i++) {
56
+ const a = points[i]!, b = points[(i + 1) % points.length]!;
57
+ area = f(area + f(f(a.x * b.y) - f(b.x * a.y)));
58
+ }
59
+ if (Math.abs(area) <= f(0.000000001)) return;
60
+ if (area >= 0) for (let i = 0; i < points.length && this.status === 0; i++) this.edge(points[i]!, points[(i + 1) % points.length]!);
61
+ else for (let i = points.length; i > 0 && this.status === 0; i--) this.edge(points[i % points.length]!, points[i - 1]!);
62
+ }
63
+ disc(center: NscRasterPoint, radius: number, tolerance: number): void {
64
+ if (radius <= 0 || this.status !== 0) return;
65
+ const f = Math.fround, k = f(f(0.5522847498307936) * radius), x = center.x, y = center.y;
66
+ const anchors = [{ x: f(x + radius), y }, { x, y: f(y + radius) }, { x: f(x - radius), y }, { x, y: f(y - radius) }, { x: f(x + radius), y }];
67
+ const first = [{ x: f(x + radius), y: f(y + k) }, { x: f(x - k), y: f(y + radius) }, { x: f(x - radius), y: f(y - k) }, { x: f(x + k), y: f(y - radius) }];
68
+ const second = [{ x: f(x + k), y: f(y + radius) }, { x: f(x - radius), y: f(y + k) }, { x: f(x - k), y: f(y - radius) }, { x: f(x + radius), y: f(y - k) }];
69
+ const points: NscRasterPoint[] = [anchors[0]!];
70
+ for (let q = 0; q < 4; q++) {
71
+ const a = anchors[q]!, b = first[q]!, c = second[q]!, d = anchors[q + 1]!;
72
+ const count = nscvRasterSegments(a, b, c, d, tolerance, 48, this.rules);
73
+ for (let i = 1; i <= count; i++) points.push(nscvRasterCurve(a, b, c, d, f(i / count)));
74
+ }
75
+ points.pop(); this.polygon(points);
76
+ }
77
+ segment(a: NscRasterPoint, b: NscRasterPoint, half: number): void {
78
+ const f = Math.fround, dx = f(b.x - a.x), dy = f(b.y - a.y), length = f(Math.sqrt(f(f(dx * dx) + f(dy * dy))));
79
+ if (length <= f(0.000001)) return;
80
+ const nx = f(f(dy / length) * half), ny = f(f(-dx / length) * half);
81
+ this.polygon([{ x: f(a.x + nx), y: f(a.y + ny) }, { x: f(b.x + nx), y: f(b.y + ny) }, { x: f(b.x - nx), y: f(b.y - ny) }, { x: f(a.x - nx), y: f(a.y - ny) }]);
82
+ }
83
+ join(prev: NscRasterPoint, vertex: NscRasterPoint, next: NscRasterPoint, half: number, round: boolean, miter: number, tolerance: number): void {
84
+ const f = Math.fround, din = nscvRasterNormalize({ x: f(vertex.x - prev.x), y: f(vertex.y - prev.y) }), dout = nscvRasterNormalize({ x: f(next.x - vertex.x), y: f(next.y - vertex.y) });
85
+ if (din === null || dout === null) return;
86
+ const cross = f(f(din.x * dout.y) - f(din.y * dout.x)), dot = f(f(din.x * dout.x) + f(din.y * dout.y));
87
+ if (dot > 0 && f(half * f(1 - dot)) < f(tolerance * 0.25)) return;
88
+ if (round) { this.disc(vertex, half, tolerance); return; }
89
+ if (Math.abs(cross) <= f(0.000001)) return;
90
+ const sign = cross > 0 ? 1 : -1;
91
+ const na = { x: f(f(din.y * sign) * half), y: f(f(-din.x * sign) * half) }, nb = { x: f(f(dout.y * sign) * half), y: f(f(-dout.x * sign) * half) };
92
+ const a = { x: f(vertex.x + na.x), y: f(vertex.y + na.y) }, b = { x: f(vertex.x + nb.x), y: f(vertex.y + nb.y) };
93
+ const mid = nscvRasterNormalize({ x: f(na.x + nb.x), y: f(na.y + nb.y) });
94
+ if (mid === null) return;
95
+ const cosine = f(f(f(mid.x * na.x) + f(mid.y * na.y)) / half);
96
+ if (cosine <= f(0.000001)) return;
97
+ const ratio = f(1 / cosine);
98
+ if (ratio <= nscvResourceExtremum(1, miter, true, this.rules)) {
99
+ const length = f(half * ratio), tip = { x: f(vertex.x + f(mid.x * length)), y: f(vertex.y + f(mid.y * length)) };
100
+ this.polygon([vertex, a, tip, b]);
101
+ } else this.polygon([vertex, a, b]);
102
+ }
103
+ stroke(points: readonly NscRasterPoint[], closed: boolean, half: number, cap: number, join: number, miter: number, tolerance: number): void {
104
+ if (points.length === 0) return;
105
+ if (points.length === 1) { if (cap === 1) this.disc(points[0]!, half, tolerance); return; }
106
+ const count = closed ? points.length : points.length - 1;
107
+ for (let i = 0; i < count && this.status === 0; i++) this.segment(points[i]!, points[(i + 1) % points.length]!, half);
108
+ if (closed) for (let i = 0; i < points.length && this.status === 0; i++) this.join(points[(i + points.length - 1) % points.length]!, points[i]!, points[(i + 1) % points.length]!, half, join === 1, miter, tolerance);
109
+ else {
110
+ for (let i = 1; i + 1 <= points.length - 1 && this.status === 0; i++) this.join(points[i - 1]!, points[i]!, points[i + 1]!, half, join === 1, miter, tolerance);
111
+ if (cap === 1 && this.status === 0) { this.disc(points[0]!, half, tolerance); this.disc(points[points.length - 1]!, half, tolerance); }
112
+ }
113
+ }
114
+ }
115
+
116
+ function nscvVectorRaster(request: Uint8Array): Uint8Array {
117
+ if (request.length < 4 || request[0] !== 66 || request[1] !== 1 || request[2]! > 3 || request[3]! > 15) throw new Error("invalid vector raster header");
118
+ const mode = request[2]!, rules = request[3]!, w = new DataView(request.buffer, request.byteOffset, request.byteLength);
119
+ if (mode >= 2) return nscvRasterSweep(request, w, mode, rules);
120
+ if (request.length < 96) throw new Error("truncated vector geometry facts");
121
+ const count = w.getUint32(4, true), capacity = w.getUint32(8, true), initial = w.getUint32(12, true), limit = w.getUint32(16, true);
122
+ if (capacity > 18560 || initial > capacity || (limit !== 16 && limit !== 48) || request.length !== 96 + count * 28 + initial * 20 || w.getUint32(36, true) > 1 || w.getUint32(40, true) > 1) throw new Error("invalid vector geometry bounds");
123
+ for (const at of [20, 44, 88, 92]) if (w.getUint32(at, true) !== 0) throw new Error("invalid vector geometry tail");
124
+ for (let i = 0; i < count; i++) if (w.getUint32(96 + i * 28, true) > 4) throw new Error("invalid vector path verb");
125
+ const f = Math.fround, tolerance = w.getFloat32(24, true), width = w.getFloat32(28, true), miter = w.getFloat32(32, true), cap = w.getUint32(36, true), join = w.getUint32(40, true);
126
+ const raster = new NscVectorRaster(capacity, rules);
127
+ raster.minX = w.getFloat32(72, true); raster.minY = w.getFloat32(76, true); raster.maxX = w.getFloat32(80, true); raster.maxY = w.getFloat32(84, true);
128
+ for (let i = 0; i < initial; i++) {
129
+ const at = 96 + count * 28 + i * 20;
130
+ raster.edges.push({ x0: w.getFloat32(at, true), y0: w.getFloat32(at + 4, true), x1: w.getFloat32(at + 8, true), y1: w.getFloat32(at + 12, true), dir: w.getFloat32(at + 16, true) });
131
+ }
132
+ const transform = (at: number): NscRasterPoint => {
133
+ const x = w.getFloat32(at, true), y = w.getFloat32(at + 4, true);
134
+ return { x: f(f(f(w.getFloat32(48, true) * x) + f(w.getFloat32(56, true) * y)) + w.getFloat32(64, true)), y: f(f(f(w.getFloat32(52, true) * x) + f(w.getFloat32(60, true) * y)) + w.getFloat32(68, true)) };
135
+ };
136
+ let active = false, has = false, current = nscvRasterPoint(0, 0), start = nscvRasterPoint(0, 0), fillStart = start, fillCurrent = start;
137
+ let points: NscRasterPoint[] = [];
138
+ const begin = (p: NscRasterPoint): void => { active = true; fillStart = p; fillCurrent = p; points = [p]; };
139
+ const point = (p: NscRasterPoint): void => {
140
+ if (mode === 0) { raster.edge(fillCurrent, p); fillCurrent = p; return; }
141
+ const last = points[points.length - 1]!, dx = f(p.x - last.x), dy = f(p.y - last.y);
142
+ if (f(f(dx * dx) + f(dy * dy)) <= f(0.000000000001)) return;
143
+ if (points.length >= 512) { raster.status = 1; return; }
144
+ points.push(p);
145
+ };
146
+ const end = (closed: boolean): void => {
147
+ if (mode === 0) raster.edge(fillCurrent, fillStart);
148
+ else {
149
+ let use = points;
150
+ if (closed && points.length >= 2) {
151
+ const a = points[0]!, b = points[points.length - 1]!, dx = f(a.x - b.x), dy = f(a.y - b.y);
152
+ if (f(f(dx * dx) + f(dy * dy)) <= f(0.000000000001)) use = points.slice(0, points.length - 1);
153
+ }
154
+ raster.stroke(use, closed && use.length >= 2, f(width * 0.5), cap, join, miter, nscvResourceExtremum(f(0.01), tolerance, true, rules));
155
+ }
156
+ active = false;
157
+ };
158
+ if (mode === 0 || width > 0) for (let i = 0; i < count && raster.status === 0; i++) {
159
+ const at = 96 + i * 28, verb = w.getUint32(at, true);
160
+ if (verb === 0) {
161
+ if (active) end(false);
162
+ current = transform(at + 4); start = current; has = true;
163
+ } else if (verb === 1) {
164
+ const next = transform(at + 4);
165
+ if (!has) { current = next; start = next; has = true; continue; }
166
+ if (!active) begin(current);
167
+ point(next); current = next;
168
+ } else if (verb === 2 || verb === 3) {
169
+ if (!has) continue;
170
+ const b = transform(at + 4), c = transform(at + 12), d = verb === 3 ? transform(at + 20) : null;
171
+ if (!active) begin(current);
172
+ const segments = nscvRasterSegments(current, b, c, d, tolerance, limit, rules);
173
+ for (let n = 1; n <= segments && raster.status === 0; n++) point(nscvRasterCurve(current, b, c, d, f(n / segments)));
174
+ current = d === null ? c : d;
175
+ } else { if (active) end(true); if (has) current = start; }
176
+ }
177
+ if (active && raster.status === 0) end(false);
178
+ const output = new Uint8Array(32 + raster.edges.length * 20), out = new DataView(output.buffer);
179
+ out.setUint32(0, raster.status, true); out.setUint32(4, raster.edges.length, true);
180
+ out.setFloat32(8, raster.minX, true); out.setFloat32(12, raster.minY, true); out.setFloat32(16, raster.maxX, true); out.setFloat32(20, raster.maxY, true);
181
+ for (let i = 0; i < raster.edges.length; i++) {
182
+ const e = raster.edges[i]!, at = 32 + i * 20;
183
+ out.setFloat32(at, e.x0, true); out.setFloat32(at + 4, e.y0, true); out.setFloat32(at + 8, e.x1, true); out.setFloat32(at + 12, e.y1, true); out.setFloat32(at + 16, e.dir, true);
184
+ }
185
+ return output;
186
+ }
187
+
188
+ function nscvRasterSweep(request: Uint8Array, w: DataView, mode: number, rules: number): Uint8Array {
189
+ if (request.length < 80) throw new Error("truncated vector sweep facts");
190
+ const count = w.getUint32(4, true), capacity = w.getUint32(8, true), rule = w.getUint32(12, true);
191
+ if (count > 18560 || capacity > 18560 || rule > 1 || request.length !== 80 + count * 20) throw new Error("invalid vector sweep bounds");
192
+ for (let at = 56; at < 80; at += 4) if (w.getUint32(at, true) !== 0) throw new Error("invalid vector sweep tail");
193
+ const f = Math.fround;
194
+ const floor = (v: number): number => Number.isFinite(v) ? Math.floor(v) : 0;
195
+ const ceil = (v: number): number => Number.isFinite(v) ? Math.ceil(v) : 0;
196
+ let x0 = Math.max(w.getInt32(32, true), floor(w.getFloat32(16, true))), y0 = Math.max(w.getInt32(36, true), floor(w.getFloat32(20, true)));
197
+ let x1 = Math.min(w.getInt32(40, true), ceil(w.getFloat32(24, true))), y1 = Math.min(w.getInt32(44, true), ceil(w.getFloat32(28, true)));
198
+ if (count === 0 || x1 <= x0 || y1 <= y0) { x0 = 0; x1 = 0; y0 = 0; y1 = 0; }
199
+ if (x0 < -2147483648 || x1 > 2147483647 || y0 < -2147483648 || y1 > 2147483647) throw new Error("vector sweep coordinates exceed wire range");
200
+ const width = x1 - x0, first = w.getInt32(48, true), rows = w.getUint32(52, true);
201
+ if (mode === 2 && (first !== 0 || rows !== 0) || mode === 3 && (rows === 0 || rows > 16 || first < y0 || first > y1 || rows > y1 - first)) throw new Error("invalid vector coverage band");
202
+ const output = new Uint8Array(32 + (mode === 3 && width <= 8192 ? width * rows * 4 : 0)), out = new DataView(output.buffer);
203
+ out.setInt32(8, x0, true); out.setInt32(12, y0, true); out.setInt32(16, x1, true); out.setInt32(20, y1, true);
204
+ if (width > 8192) { out.setUint32(0, 2, true); return output; }
205
+ if (mode === 2) return output;
206
+ for (let n = 0; n < rows; n++) {
207
+ const row: number[] = [];
208
+ for (let i = 0; i < width; i++) row.push(0);
209
+ for (let sub = 0; sub < 4; sub++) {
210
+ const sy = f(f(first + n) + f(f(sub + 0.5) / 4)), crossings: NscRasterPoint[] = [];
211
+ for (let i = 0; i < count; i++) {
212
+ const at = 80 + i * 20, ax = w.getFloat32(at, true), ay = w.getFloat32(at + 4, true), bx = w.getFloat32(at + 8, true), by = w.getFloat32(at + 12, true);
213
+ if (!(sy >= nscvResourceExtremum(ay, by, false, rules) && sy < nscvResourceExtremum(ay, by, true, rules))) continue;
214
+ if (crossings.length >= capacity) { out.setUint32(0, 1, true); return output.slice(0, 32 + n * width * 4); }
215
+ const value = { x: f(ax + f(f(f(sy - ay) * f(bx - ax)) / f(by - ay))), y: w.getFloat32(at + 16, true) };
216
+ crossings.push(value);
217
+ let j = crossings.length - 1;
218
+ while (j > 0 && crossings[j - 1]!.x > value.x) { crossings[j] = crossings[j - 1]!; j--; }
219
+ crossings[j] = value;
220
+ }
221
+ let winding = 0, parity = false, inside = false, start = 0;
222
+ for (const cross of crossings) {
223
+ const was = inside;
224
+ if (rule === 0) { winding = f(winding + cross.y); inside = winding !== 0; }
225
+ else { parity = !parity; inside = parity; }
226
+ if (!was && inside) start = cross.x;
227
+ else if (was && !inside) {
228
+ const a = nscvResourceExtremum(nscvResourceExtremum(f(start - f(x0)), 0, true, rules), width, false, rules);
229
+ const b = nscvResourceExtremum(nscvResourceExtremum(f(cross.x - f(x0)), 0, true, rules), width, false, rules);
230
+ if (b <= a) continue;
231
+ for (let px = Math.floor(a); px < width; px++) {
232
+ const left = nscvResourceExtremum(a, f(px), true, rules), right = nscvResourceExtremum(b, f(px + 1), false, rules);
233
+ if (right <= left) break;
234
+ row[px] = f(row[px]! + f(f(right - left) * 0.25));
235
+ }
236
+ }
237
+ }
238
+ }
239
+ for (let i = 0; i < width; i++) out.setFloat32(32 + (n * width + i) * 4, row[i]! > f(0.0009) ? nscvResourceExtremum(1, row[i]!, false, rules) : 0, true);
240
+ out.setUint32(4, n + 1, true);
241
+ }
242
+ return output;
243
+ }