@native-sdk/cli 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/README.md +8 -6
  2. package/bin/native.js +2 -1
  3. package/build/app.zig +320 -60
  4. package/build/corewire.zig +53 -0
  5. package/build/test_shards.zig +49 -0
  6. package/build/ts_run.mjs +3 -3
  7. package/build.zig +1818 -87
  8. package/package.json +19 -14
  9. package/packages/core/compile-surface/core.ts +134 -72
  10. package/packages/core/package-lock.json +75 -357
  11. package/packages/core/package.json +25 -4
  12. package/packages/core/scripts/compiler_command.mjs +17 -12
  13. package/packages/core/scripts/compiler_typecheck.mjs +1 -0
  14. package/packages/core/scripts/gen_declarations.mjs +3 -2
  15. package/packages/core/scripts/gen_service_surface.mjs +22 -10
  16. package/packages/core/scripts/install_scriptc.mjs +182 -0
  17. package/packages/core/scripts/invoke_scriptc.mjs +18 -0
  18. package/packages/core/scripts/merge_static_archives.mjs +6 -1
  19. package/packages/core/scripts/npm_static_spike.mjs +2 -2
  20. package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
  21. package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
  22. package/packages/core/scripts/run_library_compiler.mjs +51 -0
  23. package/packages/core/scripts/run_native_tests.mjs +22 -0
  24. package/packages/core/scripts/scriptc-toolchain.json +101 -0
  25. package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
  26. package/packages/core/scripts/stage_external_core.mjs +57 -1
  27. package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
  28. package/packages/core/sdk/bytes.d.ts +2 -0
  29. package/packages/core/sdk/bytes.ts +86 -0
  30. package/packages/core/sdk/core.d.ts +308 -4
  31. package/packages/core/sdk/core.ts +320 -84
  32. package/packages/core/sdk/events.d.ts +247 -0
  33. package/packages/core/sdk/events.ts +230 -2
  34. package/packages/core/sdk/internal/image_identity.d.ts +7 -0
  35. package/packages/core/sdk/internal/image_identity.ts +71 -0
  36. package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
  37. package/packages/core/sdk/internal/markdown_policy.ts +878 -0
  38. package/packages/core/sdk/text.d.ts +27 -0
  39. package/packages/core/sdk/text.ts +206 -15
  40. package/packages/core/sdk/theme.d.ts +251 -0
  41. package/packages/core/sdk/theme.ts +267 -0
  42. package/packages/core/src/authorization.ts +137 -0
  43. package/packages/core/src/automation_commands.ts +201 -0
  44. package/packages/core/src/automation_interactions.ts +92 -0
  45. package/packages/core/src/bridge_descriptors.ts +104 -0
  46. package/packages/core/src/builtin_coordination.ts +172 -0
  47. package/packages/core/src/canvas_frame_coordination.ts +81 -0
  48. package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
  49. package/packages/core/src/canvas_scene_observation.ts +145 -0
  50. package/packages/core/src/chart_content.ts +161 -0
  51. package/packages/core/src/chart_plans.ts +432 -0
  52. package/packages/core/src/checker.ts +166 -19
  53. package/packages/core/src/code_content.ts +580 -0
  54. package/packages/core/src/command_coordination.ts +140 -0
  55. package/packages/core/src/component_composition.ts +94 -0
  56. package/packages/core/src/component_construction.ts +149 -0
  57. package/packages/core/src/contract.ts +25 -7
  58. package/packages/core/src/control_appearance.ts +232 -0
  59. package/packages/core/src/control_commands.ts +115 -0
  60. package/packages/core/src/control_content.ts +105 -0
  61. package/packages/core/src/control_geometry.ts +107 -0
  62. package/packages/core/src/control_payloads.ts +119 -0
  63. package/packages/core/src/control_primitives.ts +134 -0
  64. package/packages/core/src/devhost.ts +82 -7
  65. package/packages/core/src/devhost_journal.mjs +30 -7
  66. package/packages/core/src/effect_plans.ts +71 -0
  67. package/packages/core/src/flow_measurement.ts +121 -0
  68. package/packages/core/src/font_registry.ts +37 -0
  69. package/packages/core/src/glyph_atlas.ts +86 -0
  70. package/packages/core/src/gpu_packet_preparation.ts +130 -0
  71. package/packages/core/src/gpu_planning.ts +123 -0
  72. package/packages/core/src/gpu_presentation.ts +55 -0
  73. package/packages/core/src/host_flow.ts +89 -0
  74. package/packages/core/src/host_input_regions.ts +165 -0
  75. package/packages/core/src/image_registry.ts +66 -0
  76. package/packages/core/src/indicator_plans.ts +132 -0
  77. package/packages/core/src/infer.ts +150 -8
  78. package/packages/core/src/input_composition.ts +116 -0
  79. package/packages/core/src/intrinsic_measure.ts +100 -0
  80. package/packages/core/src/layout_coordination.ts +207 -0
  81. package/packages/core/src/leaf_plans.ts +134 -0
  82. package/packages/core/src/markup_development.ts +160 -0
  83. package/packages/core/src/measurement_coordination.ts +185 -0
  84. package/packages/core/src/modules.ts +1 -1
  85. package/packages/core/src/motion_sampling.ts +100 -0
  86. package/packages/core/src/paragraph_layout.ts +192 -0
  87. package/packages/core/src/portable_sources.json +74 -0
  88. package/packages/core/src/portable_sources.ts +17 -0
  89. package/packages/core/src/registered_font.ts +93 -0
  90. package/packages/core/src/render_animation_lifecycle.ts +128 -0
  91. package/packages/core/src/render_coordination.ts +170 -0
  92. package/packages/core/src/render_resources.ts +234 -0
  93. package/packages/core/src/runtime_policy.ts +3930 -0
  94. package/packages/core/src/scalar_text.ts +84 -0
  95. package/packages/core/src/service_contract.ts +2 -1
  96. package/packages/core/src/session_codecs.ts +309 -0
  97. package/packages/core/src/shell_admission.ts +126 -0
  98. package/packages/core/src/shell_coordination.ts +93 -0
  99. package/packages/core/src/sqlite_cli.ts +11 -0
  100. package/packages/core/src/status_validation.ts +232 -0
  101. package/packages/core/src/stream_policy.ts +63 -0
  102. package/packages/core/src/surface_recipes.ts +136 -0
  103. package/packages/core/src/system_admission.ts +60 -0
  104. package/packages/core/src/terminal_paint.ts +436 -0
  105. package/packages/core/src/text_document_width.ts +81 -0
  106. package/packages/core/src/text_measurement_cache.ts +69 -0
  107. package/packages/core/src/text_query_layout.ts +179 -0
  108. package/packages/core/src/text_run_layout.ts +410 -0
  109. package/packages/core/src/text_span_queries.ts +355 -0
  110. package/packages/core/src/typed_ast.ts +18 -1
  111. package/packages/core/src/types.ts +7 -5
  112. package/packages/core/src/vector_effects.ts +98 -0
  113. package/packages/core/src/vector_raster.ts +243 -0
  114. package/packages/core/src/view_components.ts +2415 -0
  115. package/packages/core/src/view_coordination.ts +198 -0
  116. package/packages/core/src/view_frontend.ts +980 -0
  117. package/packages/core/src/widget_audits.ts +202 -0
  118. package/packages/core/src/widget_changes.ts +258 -0
  119. package/packages/core/src/widget_metrics.ts +139 -0
  120. package/packages/core/src/widget_motion.ts +171 -0
  121. package/packages/core/src/widget_paint.ts +272 -0
  122. package/packages/core/src/widget_paint_walk.ts +203 -0
  123. package/packages/core/src/widget_presentation.ts +141 -0
  124. package/packages/core/src/widget_routing.ts +262 -0
  125. package/packages/core/src/window_lifecycle.ts +92 -0
  126. package/packages/core/testing/index.ts +430 -0
  127. package/schemas/app.schema.json +13 -0
  128. package/skill-data/core/SKILL.md +2 -2
  129. package/skill-data/core/references/web-engines-packaging-debugging.md +2 -1
  130. package/skill-data/native-ui/SKILL.md +76 -17
  131. package/skill-data/ts-core/SKILL.md +113 -9
  132. package/skill-data/ts-services/SKILL.md +1 -1
  133. package/skill-data/ts-services/references/service-surface.md +264 -144
  134. package/src/app_runner/root.zig +25 -12
  135. package/src/app_runner/ts_compiled_view.zig +1631 -0
  136. package/src/app_runner/ts_core_main.zig +143 -10
  137. package/src/app_runner/ts_core_mobile.zig +24 -12
  138. package/src/automation/server.zig +1 -3
  139. package/src/automation/snapshot.zig +9 -637
  140. package/src/automation/snapshot_reference.zig +656 -0
  141. package/src/automation/snapshot_serialization.zig +566 -0
  142. package/src/platform/linux/gtk_host.c +36 -24
  143. package/src/platform/linux/gtk_pixels.h +118 -0
  144. package/src/platform/linux/gtk_pixels_test.c +241 -0
  145. package/src/platform/linux/root.zig +2 -0
  146. package/src/platform/macos/appkit_host.m +188 -30
  147. package/src/platform/macos/pointer_motion_test.m +96 -0
  148. package/src/platform/macos/scroll_driver_test.m +105 -0
  149. package/src/platform/macos/spectrum_bins.h +34 -0
  150. package/src/platform/macos/spectrum_bins_test.c +56 -0
  151. package/src/platform/macos/text_keyboard_test.m +80 -0
  152. package/src/platform/macos/widget_focus_test.m +66 -0
  153. package/src/platform/null_platform.zig +26 -2
  154. package/src/platform/null_platform_tests.zig +13 -0
  155. package/src/platform/root.zig +1 -0
  156. package/src/platform/types.zig +13 -0
  157. package/src/platform/windows/root.zig +2 -0
  158. package/src/platform/windows/webview2_host.cpp +7 -2
  159. package/src/primitives/app_manifest/comptime_scene.zig +1 -1
  160. package/src/primitives/app_manifest/root.zig +2 -0
  161. package/src/primitives/app_manifest/tests.zig +4 -1
  162. package/src/primitives/app_manifest/validation.zig +2 -0
  163. package/src/primitives/canvas/a11y_audit.zig +3 -1
  164. package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
  165. package/src/primitives/canvas/chart_content_policy.zig +75 -0
  166. package/src/primitives/canvas/chart_plan_policy.zig +196 -0
  167. package/src/primitives/canvas/code_content_policy.zig +162 -0
  168. package/src/primitives/canvas/commands.zig +29 -1
  169. package/src/primitives/canvas/component_composition.zig +125 -0
  170. package/src/primitives/canvas/component_composition_policy.zig +44 -0
  171. package/src/primitives/canvas/component_construction_policy.zig +187 -0
  172. package/src/primitives/canvas/container_layout_policy.zig +87 -0
  173. package/src/primitives/canvas/control_appearance_policy.zig +142 -0
  174. package/src/primitives/canvas/control_command_policy.zig +75 -0
  175. package/src/primitives/canvas/control_content_policy.zig +90 -0
  176. package/src/primitives/canvas/control_geometry_policy.zig +165 -0
  177. package/src/primitives/canvas/control_payload_policy.zig +48 -0
  178. package/src/primitives/canvas/control_primitive_policy.zig +129 -0
  179. package/src/primitives/canvas/effect_plan_policy.zig +96 -0
  180. package/src/primitives/canvas/events.zig +1027 -1
  181. package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
  182. package/src/primitives/canvas/frame.zig +92 -23
  183. package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
  184. package/src/primitives/canvas/gpu.zig +10 -0
  185. package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
  186. package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
  187. package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
  188. package/src/primitives/canvas/grid_layout_policy.zig +51 -0
  189. package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
  190. package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
  191. package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
  192. package/src/primitives/canvas/layout_audit.zig +5 -2
  193. package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
  194. package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
  195. package/src/primitives/canvas/markdown.zig +13 -3
  196. package/src/primitives/canvas/markdown_content_policy.zig +227 -0
  197. package/src/primitives/canvas/markdown_image_binding.zig +81 -0
  198. package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
  199. package/src/primitives/canvas/numeric_capabilities.zig +14 -0
  200. package/src/primitives/canvas/reference.zig +12 -6
  201. package/src/primitives/canvas/registered_font_policy.zig +152 -0
  202. package/src/primitives/canvas/render.zig +48 -0
  203. package/src/primitives/canvas/render_cache_policy.zig +184 -0
  204. package/src/primitives/canvas/render_coordination_policy.zig +163 -0
  205. package/src/primitives/canvas/render_damage_policy.zig +160 -0
  206. package/src/primitives/canvas/render_effects.zig +14 -0
  207. package/src/primitives/canvas/render_generic_resources.zig +14 -0
  208. package/src/primitives/canvas/render_images.zig +14 -0
  209. package/src/primitives/canvas/render_layers.zig +14 -0
  210. package/src/primitives/canvas/render_override_policy.zig +119 -0
  211. package/src/primitives/canvas/render_paths.zig +14 -0
  212. package/src/primitives/canvas/render_plan_policy.zig +199 -0
  213. package/src/primitives/canvas/render_resource_policy.zig +476 -0
  214. package/src/primitives/canvas/root.zig +100 -0
  215. package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
  216. package/src/primitives/canvas/serialization.zig +8 -1
  217. package/src/primitives/canvas/surface_layout_policy.zig +36 -0
  218. package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
  219. package/src/primitives/canvas/terminal_grid.zig +10 -696
  220. package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
  221. package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
  222. package/src/primitives/canvas/text.zig +1 -0
  223. package/src/primitives/canvas/text_atlas.zig +113 -0
  224. package/src/primitives/canvas/text_cache_policy.zig +94 -0
  225. package/src/primitives/canvas/text_document_policy.zig +120 -0
  226. package/src/primitives/canvas/text_layout.zig +51 -2
  227. package/src/primitives/canvas/text_layout_cache.zig +29 -0
  228. package/src/primitives/canvas/text_layout_hash.zig +1 -0
  229. package/src/primitives/canvas/text_layout_types.zig +3 -0
  230. package/src/primitives/canvas/text_measure_cache.zig +46 -0
  231. package/src/primitives/canvas/text_measurement_policy.zig +124 -0
  232. package/src/primitives/canvas/text_metrics.zig +23 -0
  233. package/src/primitives/canvas/text_query_policy.zig +156 -0
  234. package/src/primitives/canvas/text_run_policy.zig +252 -0
  235. package/src/primitives/canvas/text_scalar_policy.zig +156 -0
  236. package/src/primitives/canvas/text_span_query_policy.zig +232 -0
  237. package/src/primitives/canvas/text_spans.zig +280 -8
  238. package/src/primitives/canvas/text_tests.zig +10 -0
  239. package/src/primitives/canvas/tokens.zig +38 -0
  240. package/src/primitives/canvas/ui.zig +250 -83
  241. package/src/primitives/canvas/ui_markup.zig +139 -33
  242. package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
  243. package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
  244. package/src/primitives/canvas/ui_markup_contract.zig +146 -14
  245. package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
  246. package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
  247. package/src/primitives/canvas/ui_markup_tests.zig +116 -0
  248. package/src/primitives/canvas/ui_markup_view.zig +258 -32
  249. package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
  250. package/src/primitives/canvas/ui_schema.zig +13 -1
  251. package/src/primitives/canvas/ui_schema_tests.zig +11 -7
  252. package/src/primitives/canvas/ui_tests.zig +1 -0
  253. package/src/primitives/canvas/vector.zig +36 -2
  254. package/src/primitives/canvas/vector_effect_policy.zig +236 -0
  255. package/src/primitives/canvas/vector_raster_policy.zig +190 -0
  256. package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
  257. package/src/primitives/canvas/virtual_extents.zig +99 -3
  258. package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
  259. package/src/primitives/canvas/widget_audit_policy.zig +293 -0
  260. package/src/primitives/canvas/widget_change_policy.zig +298 -0
  261. package/src/primitives/canvas/widget_invalidation.zig +113 -2
  262. package/src/primitives/canvas/widget_layout.zig +673 -128
  263. package/src/primitives/canvas/widget_layout_tests.zig +4 -0
  264. package/src/primitives/canvas/widget_metric_policy.zig +126 -0
  265. package/src/primitives/canvas/widget_metrics.zig +45 -6
  266. package/src/primitives/canvas/widget_paint_policy.zig +166 -0
  267. package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
  268. package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
  269. package/src/primitives/canvas/widget_render.zig +744 -74
  270. package/src/primitives/canvas/widget_render_controls.zig +1217 -133
  271. package/src/primitives/canvas/widget_render_scroll.zig +11 -3
  272. package/src/primitives/canvas/widget_render_style.zig +94 -0
  273. package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
  274. package/src/primitives/canvas/widget_routing.zig +75 -0
  275. package/src/primitives/canvas/widget_routing_policy.zig +135 -0
  276. package/src/primitives/canvas/widget_runtime.zig +20 -1
  277. package/src/primitives/canvas/widget_semantics.zig +25 -0
  278. package/src/primitives/canvas/widget_text_input.zig +86 -23
  279. package/src/primitives/canvas/widget_text_select.zig +1 -0
  280. package/src/primitives/canvas/widget_tree.zig +8 -1
  281. package/src/primitives/canvas/widgets.zig +42 -12
  282. package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
  283. package/src/root.zig +21 -0
  284. package/src/runtime/accessibility_policy.zig +122 -0
  285. package/src/runtime/api.zig +28 -0
  286. package/src/runtime/app_dispatch_policy.zig +68 -0
  287. package/src/runtime/authorization_policy.zig +150 -0
  288. package/src/runtime/automation_command_policy.zig +241 -0
  289. package/src/runtime/automation_interaction_policy.zig +107 -0
  290. package/src/runtime/automation_snapshot.zig +52 -22
  291. package/src/runtime/automation_snapshot_reference.zig +290 -0
  292. package/src/runtime/automation_widget_dispatch.zig +267 -355
  293. package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
  294. package/src/runtime/blob_policy.zig +58 -0
  295. package/src/runtime/blob_reference.zig +64 -0
  296. package/src/runtime/bridge_descriptor_policy.zig +206 -0
  297. package/src/runtime/builtin_bridge.zig +180 -44
  298. package/src/runtime/builtin_coordination_policy.zig +121 -0
  299. package/src/runtime/callback_policy_test_reference.zig +97 -0
  300. package/src/runtime/canvas_drag_policy.zig +94 -0
  301. package/src/runtime/canvas_fonts.zig +38 -10
  302. package/src/runtime/canvas_frame.zig +590 -134
  303. package/src/runtime/canvas_frame_helpers.zig +1 -0
  304. package/src/runtime/canvas_hover_policy.zig +131 -0
  305. package/src/runtime/canvas_images.zig +59 -30
  306. package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
  307. package/src/runtime/canvas_limits.zig +1 -1
  308. package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
  309. package/src/runtime/canvas_scene_observation_policy.zig +181 -0
  310. package/src/runtime/canvas_widget_context_menu.zig +4 -4
  311. package/src/runtime/canvas_widget_display.zig +110 -9
  312. package/src/runtime/canvas_widget_events.zig +718 -328
  313. package/src/runtime/canvas_widget_runtime.zig +437 -81
  314. package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
  315. package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
  316. package/src/runtime/canvas_widget_state.zig +93 -56
  317. package/src/runtime/channel_sources.zig +80 -0
  318. package/src/runtime/command_policy.zig +161 -0
  319. package/src/runtime/component_policy.zig +83 -0
  320. package/src/runtime/core.zig +156 -6
  321. package/src/runtime/desktop_files.zig +189 -0
  322. package/src/runtime/effects.zig +466 -29
  323. package/src/runtime/effects_tests.zig +28 -0
  324. package/src/runtime/file_policy_test_reference.zig +113 -0
  325. package/src/runtime/flow.zig +418 -341
  326. package/src/runtime/flow_reference.zig +1426 -0
  327. package/src/runtime/font_registry_policy.zig +72 -0
  328. package/src/runtime/frame_profile.zig +24 -33
  329. package/src/runtime/gpu_surface_events.zig +97 -35
  330. package/src/runtime/host_event_pump.zig +303 -0
  331. package/src/runtime/host_event_pump_reference.zig +268 -0
  332. package/src/runtime/host_flow_policy.zig +155 -0
  333. package/src/runtime/host_input_regions_policy.zig +156 -0
  334. package/src/runtime/image_registry_policy.zig +94 -0
  335. package/src/runtime/input_composition_policy.zig +138 -0
  336. package/src/runtime/journal_policy.zig +66 -0
  337. package/src/runtime/journal_reference.zig +53 -0
  338. package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
  339. package/src/runtime/markup_development_policy.zig +91 -0
  340. package/src/runtime/media_surface.zig +40 -1
  341. package/src/runtime/motion_sampling_policy.zig +159 -0
  342. package/src/runtime/recording_policy.zig +42 -0
  343. package/src/runtime/render_animation_policy.zig +206 -0
  344. package/src/runtime/replay_policy.zig +66 -0
  345. package/src/runtime/replay_policy_reference.zig +326 -0
  346. package/src/runtime/replay_progress_policy.zig +64 -0
  347. package/src/runtime/replay_progress_reference.zig +34 -0
  348. package/src/runtime/request_policy_test_reference.zig +188 -0
  349. package/src/runtime/root.zig +13 -0
  350. package/src/runtime/session_blobs.zig +157 -58
  351. package/src/runtime/session_blobs_reference.zig +692 -0
  352. package/src/runtime/session_codec.zig +361 -0
  353. package/src/runtime/session_codec_reference.zig +1027 -0
  354. package/src/runtime/session_journal.zig +246 -983
  355. package/src/runtime/session_record.zig +224 -45
  356. package/src/runtime/session_replay.zig +157 -415
  357. package/src/runtime/session_tests.zig +552 -0
  358. package/src/runtime/shell_admission_policy.zig +225 -0
  359. package/src/runtime/shell_coordination_policy.zig +138 -0
  360. package/src/runtime/shell_layout.zig +126 -1
  361. package/src/runtime/snapshot_policy.zig +60 -0
  362. package/src/runtime/snapshot_reference.zig +64 -0
  363. package/src/runtime/state.zig +16 -0
  364. package/src/runtime/status_validation.zig +190 -0
  365. package/src/runtime/system_admission_policy.zig +140 -0
  366. package/src/runtime/system_services.zig +46 -36
  367. package/src/runtime/tests.zig +1 -0
  368. package/src/runtime/ts_canvas_hooks.zig +261 -0
  369. package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
  370. package/src/runtime/ts_canvas_icons.zig +234 -0
  371. package/src/runtime/ts_core_host.zig +2325 -411
  372. package/src/runtime/ts_core_host_tests.zig +1982 -0
  373. package/src/runtime/ts_test_host.zig +699 -0
  374. package/src/runtime/ts_ui_app.zig +1087 -45
  375. package/src/runtime/ui_app.zig +1117 -629
  376. package/src/runtime/ui_app_provenance.zig +147 -5
  377. package/src/runtime/ui_app_provenance_reference.zig +370 -0
  378. package/src/runtime/ui_app_tests.zig +619 -9
  379. package/src/runtime/ui_app_window_tests.zig +89 -0
  380. package/src/runtime/view.zig +25 -0
  381. package/src/runtime/view_canvas.zig +30 -6
  382. package/src/runtime/view_coordination_policy.zig +147 -0
  383. package/src/runtime/view_widget_control.zig +51 -14
  384. package/src/runtime/view_widget_scroll.zig +16 -5
  385. package/src/runtime/view_widget_text.zig +153 -68
  386. package/src/runtime/view_widget_tree.zig +460 -56
  387. package/src/runtime/webview_view_bridge_tests.zig +2 -0
  388. package/src/runtime/widget_motion_policy.zig +238 -0
  389. package/src/runtime/window_command_bridge_tests.zig +63 -0
  390. package/src/runtime/window_lifecycle_policy.zig +127 -0
  391. package/src/runtime/window_storage.zig +74 -8
  392. package/src/runtime/window_view_runtime.zig +148 -33
  393. package/src/runtime/window_views.zig +163 -10
  394. package/src/tooling/codesign.zig +125 -74
  395. package/src/tooling/components/identity_tests.zig +62 -36
  396. package/src/tooling/components/stepper.native +24 -0
  397. package/src/tooling/components/stepper.zig +0 -19
  398. package/src/tooling/components/timeline-item.native +22 -0
  399. package/src/tooling/components/timeline.native +5 -3
  400. package/src/tooling/components/timeline_item.zig +0 -32
  401. package/src/tooling/eject_components.zig +76 -8
  402. package/src/tooling/ios.zig +66 -12
  403. package/src/tooling/manifest.zig +35 -0
  404. package/src/tooling/package.zig +85 -1
  405. package/src/tooling/raw_manifest.zig +6 -0
  406. package/src/tooling/templates.zig +15 -3
  407. package/src/tooling/ts_core.zig +13 -3
  408. package/src/tooling/verbs.zig +22 -0
  409. package/tools/corewire/build_profile.mjs +54 -0
  410. package/tools/corewire/contract_intake.ts +303 -0
  411. package/tools/corewire/contract_intake.zig +82 -0
  412. package/tools/corewire/core.test.ts +166 -0
  413. package/tools/corewire/core_abi.zig +51 -0
  414. package/tools/corewire/core_cases.ts +233 -0
  415. package/tools/corewire/core_contract.ts +407 -0
  416. package/tools/corewire/core_emission.ts +136 -0
  417. package/tools/corewire/core_emission.zig +69 -0
  418. package/tools/corewire/core_goldens.json +3110 -0
  419. package/tools/corewire/core_policy.ts +14 -0
  420. package/tools/corewire/core_policy.zig +48 -0
  421. package/tools/corewire/core_projection.ts +360 -0
  422. package/tools/corewire/core_vocabulary.ts +6 -0
  423. package/tools/corewire/emit.zig +19 -1590
  424. package/tools/corewire/emit_facade.ts +714 -0
  425. package/tools/corewire/emit_facade.zig +10 -3752
  426. package/tools/corewire/emit_mirror.ts +290 -0
  427. package/tools/corewire/emit_profile.ts +50 -0
  428. package/tools/corewire/emit_service.ts +331 -0
  429. package/tools/corewire/emit_service.zig +23 -842
  430. package/tools/corewire/entry.test.ts +95 -0
  431. package/tools/corewire/entry_coordination.ts +127 -0
  432. package/tools/corewire/entry_coordination.zig +190 -0
  433. package/tools/corewire/facade_templates.ts +85 -0
  434. package/tools/corewire/filesystem.test.ts +166 -0
  435. package/tools/corewire/filesystem_coordination.ts +213 -0
  436. package/tools/corewire/filesystem_coordination.zig +245 -0
  437. package/tools/corewire/intake.test.ts +35 -0
  438. package/tools/corewire/intake_cases.ts +55 -0
  439. package/tools/corewire/intake_goldens.json +12237 -0
  440. package/tools/corewire/invocation.test.ts +24 -0
  441. package/tools/corewire/invocation.ts +175 -0
  442. package/tools/corewire/invocation.zig +136 -0
  443. package/tools/corewire/invocation_cases.ts +60 -0
  444. package/tools/corewire/invocation_fixture.ts +33 -0
  445. package/tools/corewire/invocation_goldens.json +1143 -0
  446. package/tools/corewire/invocation_tests.zig +111 -0
  447. package/tools/corewire/invocation_usage.ts +2 -0
  448. package/tools/corewire/lossless_projection.ts +96 -0
  449. package/tools/corewire/main.zig +7 -680
  450. package/tools/corewire/main_reference.zig +415 -0
  451. package/tools/corewire/mirror_templates.ts +55 -0
  452. package/tools/corewire/profile.test.ts +248 -0
  453. package/tools/corewire/profile.zig +56 -0
  454. package/tools/corewire/profile_emission.ts +202 -0
  455. package/tools/corewire/profile_library.json +29 -0
  456. package/tools/corewire/profile_tests.zig +136 -0
  457. package/tools/corewire/service.test.ts +75 -0
  458. package/tools/corewire/service_cases.ts +61 -0
  459. package/tools/corewire/service_contract.zig +40 -146
  460. package/tools/corewire/service_goldens.json +650 -0
  461. package/tools/corewire/service_projection.zig +52 -0
  462. package/tools/corewire/service_templates.ts +14 -0
  463. package/tools/corewire/shim_rt.zig +9 -0
  464. package/tools/corewire/sidecar.zig +267 -1438
  465. package/tools/corewire/emit_profile.zig +0 -521
@@ -0,0 +1,84 @@
1
+ // Scalar text decisions over copied font facts. Font table lookup and OS
2
+ // measurement are explicit capabilities; no host pointer crosses this seam.
3
+ function nscvScalarTextSequence(byte: number): nscContracts.NoThrow<nscContracts.Int32> { return (byte & 128) === 0 ? 1 : (byte & 224) === 192 ? 2 : (byte & 240) === 224 ? 3 : (byte & 248) === 240 ? 4 : 1; }
4
+ // The reserved mono estimator has no font capability. Keep every f32 add,
5
+ // including the distinction between a cluster's -0 and a run's initial +0.
6
+ function nscvScalarTextMonoWidth(text: Uint8Array, first: number, last: number, size: number, cluster: boolean): number {
7
+ if (first === last) return 0;
8
+ const advance = Math.fround(size * Math.fround(0.6));
9
+ if (cluster) return advance;
10
+ let width = 0;
11
+ while (first < last) { width = Math.fround(width + advance); first = Math.min(last, first + nscvScalarTextSequence(text[first]!)); }
12
+ return width;
13
+ }
14
+ function nscvScalarTextCodepoint(text: Uint8Array, first: number, last: number): number {
15
+ const length = last - first, lead = text[first]!;
16
+ if (length === 1) return lead >= 32 && lead < 127 ? lead : -1;
17
+ if (length !== nscvScalarTextSequence(lead)) return -1;
18
+ let cp = lead & (length === 2 ? 31 : length === 3 ? 15 : 7);
19
+ for (let i = first + 1; i < last; i++) { const byte = text[i]!; if ((byte & 192) !== 128) return -1; cp = cp * 64 + (byte & 63); }
20
+ if (cp < (length === 2 ? 128 : length === 3 ? 2048 : 65536) || cp > 1114111 || cp >= 55296 && cp <= 57343) return -1;
21
+ return cp;
22
+ }
23
+ function nscvScalarTextWide(cp: number): nscContracts.NoThrow<boolean> {
24
+ return cp >= 0x1100 && cp <= 0x115f || cp >= 0x2e80 && cp <= 0x303e || cp >= 0x3041 && cp <= 0x33ff ||
25
+ cp >= 0x3400 && cp <= 0x4dbf || cp >= 0x4e00 && cp <= 0x9fff || cp >= 0xa000 && cp <= 0xa4cf ||
26
+ cp >= 0xa960 && cp <= 0xa97f || cp >= 0xac00 && cp <= 0xd7a3 || cp >= 0xf900 && cp <= 0xfaff ||
27
+ cp >= 0xfe10 && cp <= 0xfe19 || cp >= 0xfe30 && cp <= 0xfe6f || cp >= 0xff00 && cp <= 0xff60 ||
28
+ cp >= 0xffe0 && cp <= 0xffe6 || cp >= 0x1f300 && cp <= 0x1faff || cp >= 0x20000 && cp <= 0x3fffd;
29
+ }
30
+ function nscvScalarText(request: Uint8Array): Uint8Array {
31
+ if (request.length < 64 || request[0] !== 60 || request[1] !== 1 || request[2]! > 3 || request[3]! > 1)
32
+ throw new Error("invalid scalar text header");
33
+ const mode = request[2]!, phase = request[3]!, facts = mode === 1 || mode === 2;
34
+ const out = request.slice(), w = new DataView(out.buffer), length = w.getUint32(8, true), slots = w.getUint32(12, true);
35
+ if (w.getUint32(4, true) > 1 || slots !== (facts ? length : 0) || request.length !== 64 + slots * 8 + (facts ? length : 0) || w.getUint32(60, true) !== 0)
36
+ throw new Error("invalid scalar text storage");
37
+ const size = w.getFloat32(24, true), notdef = w.getFloat32(28, true);
38
+ if (phase === 0) {
39
+ for (let at = 32; at < 60; at += 4) if (w.getUint32(at, true) !== 0) throw new Error("invalid initial scalar text state");
40
+ if (facts) for (let at = 64; at < 64 + slots * 8; at += 4) if (w.getUint32(at, true) !== 0) throw new Error("invalid initial scalar text facts");
41
+ } else if (w.getUint32(56, true) !== (facts ? 3 : 2) || w.getUint32(36, true) > slots || !facts && w.getUint32(36, true) !== 0) {
42
+ throw new Error("invalid scalar text continuation");
43
+ }
44
+ if (!facts) {
45
+ if (length === 0 || w.getUint32(4, true) === 0 && mode === 3) { out[3] = 2; w.setUint32(56, 0, true); return out; }
46
+ if (phase === 0 && w.getUint32(4, true) === 1) { out[3] = 1; w.setUint32(56, 2, true); return out; }
47
+ out[3] = 2;
48
+ if (mode === 0) { const value = w.getFloat32(32, true); w.setUint32(56, phase === 1 && value >= 0 && Number.isFinite(value) ? 0 : 1, true); }
49
+ else {
50
+ const a = w.getFloat32(40, true), b = w.getFloat32(44, true), c = w.getFloat32(48, true), d = w.getFloat32(52, true);
51
+ w.setUint32(56, w.getUint32(32, true) === 1 && Number.isFinite(a) && Number.isFinite(b) && Number.isFinite(c) && Number.isFinite(d) && b >= a && d >= c ? 1 : 0, true);
52
+ }
53
+ return out;
54
+ }
55
+ const text = out.subarray(64 + slots * 8), mono = w.getUint32(16, true) === 2 && w.getUint32(20, true) === 0;
56
+ if (mono) {
57
+ // No glyph facts are requested or populated for the reserved mono face.
58
+ // Scan the source directly instead of writing one unused fact per byte.
59
+ out[3] = 2; w.setUint32(56, 0, true);
60
+ w.setFloat32(32, nscvScalarTextMonoWidth(text, 0, length, size, mode === 2), true);
61
+ return out;
62
+ }
63
+ const font = w.getUint32(20, true) === 0 ? w.getUint32(16, true) : 0;
64
+ const factor = Math.fround(font === 3 ? 1.02 : font === 4 || font === 6 ? 1.04 : 1);
65
+ let count = w.getUint32(36, true);
66
+ if (phase === 0) {
67
+ count = 0; let first = 0;
68
+ while (first < length) {
69
+ const last = mode === 2 ? length : Math.min(length, first + nscvScalarTextSequence(text[first]!));
70
+ const cp = nscvScalarTextCodepoint(text, first, last), at = 64 + count * 8;
71
+ w.setUint32(at, cp < 0 ? 0xffffffff : cp, true);
72
+ w.setFloat32(at + 4, cp >= 0 && nscvScalarTextWide(cp) ? 1 : cp >= 0x2190 && cp <= 0x2bff ? Math.fround(0.8) : notdef, true);
73
+ count++; first = last;
74
+ }
75
+ w.setUint32(36, count, true);
76
+ if (count > 0) { out[3] = 1; w.setUint32(56, 3, true); return out; }
77
+ }
78
+ let width = 0;
79
+ for (let i = 0; i < count; i++) {
80
+ const advance = Math.fround(Math.fround(size * w.getFloat32(64 + i * 8 + 4, true)) * factor);
81
+ width = mode === 2 ? advance : Math.fround(width + advance);
82
+ }
83
+ out[3] = 2; w.setUint32(56, 0, true); w.setFloat32(32, width, true); return out;
84
+ }
@@ -141,9 +141,10 @@ function throwIsLexicallyCaught(node: ts.ThrowStatement): boolean {
141
141
  function pinnedScriptcVersion(): string {
142
142
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
143
143
  const manifest = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8")) as {
144
+ nativeToolchain?: { scriptc?: unknown };
144
145
  dependencies?: { scriptc?: unknown };
145
146
  };
146
- const pin = manifest.dependencies?.scriptc;
147
+ const pin = manifest.nativeToolchain?.scriptc ?? manifest.dependencies?.scriptc;
147
148
  if (typeof pin !== "string" || !/^\d+\.\d+\.\d+$/.test(pin)) {
148
149
  throw new Error("packages/core/package.json carries no exact scriptc pin");
149
150
  }
@@ -0,0 +1,309 @@
1
+ /** Complete session payload layouts. Native supplies raw typed storage slots;
2
+ * TypeScript owns tags, field order, optional suffixes, bounds and byte validation.
3
+ * Scalar payloads are copied as bytes to retain all integer and floating bits.
4
+ */
5
+ type NscJournalField = { path: string; kind: string; domain: string };
6
+ type NscJournalSlot = { path: string; bytes: Uint8Array };
7
+ function nscjFields(rows: readonly (readonly string[])[]): NscJournalField[] {
8
+ return rows.map(row => ({ path: row[0]!, kind: row[1]!, domain: row[2]! }));
9
+ }
10
+ function nscjEventTag(name: string): number {
11
+ switch (name) {
12
+ case "app_start": return 1;
13
+ case "app_activated": return 2;
14
+ case "app_deactivated": return 3;
15
+ case "appearance_changed": return 4;
16
+ case "frame_requested": return 5;
17
+ case "app_shutdown": return 6;
18
+ case "surface_resized": return 7;
19
+ case "window_frame_changed": return 8;
20
+ case "window_focused": return 9;
21
+ case "bridge_message": return 10;
22
+ case "tray_action": return 11;
23
+ case "shortcut": return 12;
24
+ case "native_command": return 13;
25
+ case "menu_command": return 14;
26
+ case "timer": return 15;
27
+ case "wake": return 16;
28
+ case "files_dropped": return 17;
29
+ case "gpu_surface_frame": return 18;
30
+ case "gpu_surface_resized": return 19;
31
+ case "gpu_surface_input": return 20;
32
+ case "gpu_surface_scroll_driver": return 21;
33
+ case "context_menu_action": return 22;
34
+ case "widget_accessibility_action": return 23;
35
+ case "audio": return 24;
36
+ case "video": return 25;
37
+ case "view_focused": return 26;
38
+ case "tray_command": return 27;
39
+ case "notification_command": return 28;
40
+ case "widget_context_menu_action": return 29;
41
+ default: throw new Error("unknown native event storage");
42
+ }
43
+ }
44
+ function nscjEventName(tag: number): string {
45
+ switch (tag) {
46
+ case 1: return "app_start";
47
+ case 2: return "app_activated";
48
+ case 3: return "app_deactivated";
49
+ case 4: return "appearance_changed";
50
+ case 5: return "frame_requested";
51
+ case 6: return "app_shutdown";
52
+ case 7: return "surface_resized";
53
+ case 8: return "window_frame_changed";
54
+ case 9: return "window_focused";
55
+ case 10: return "bridge_message";
56
+ case 11: return "tray_action";
57
+ case 12: return "shortcut";
58
+ case 13: return "native_command";
59
+ case 14: return "menu_command";
60
+ case 15: return "timer";
61
+ case 16: return "wake";
62
+ case 17: return "files_dropped";
63
+ case 18: return "gpu_surface_frame";
64
+ case 19: return "gpu_surface_resized";
65
+ case 20: return "gpu_surface_input";
66
+ case 21: return "gpu_surface_scroll_driver";
67
+ case 22: return "context_menu_action";
68
+ case 23: return "widget_accessibility_action";
69
+ case 24: return "audio";
70
+ case 25: return "video";
71
+ case 26: return "view_focused";
72
+ case 27: return "tray_command";
73
+ case 28: return "notification_command";
74
+ case 29: return "widget_context_menu_action";
75
+ default: return "";
76
+ }
77
+ }
78
+ function nscjSchema(record: number, name: string): NscJournalField[] {
79
+ if (record === 2) switch (name) {
80
+ case "appearance_changed": return nscjFields([["color_scheme", "enum", "ColorScheme"], ["reduce_motion", "bool", ""], ["high_contrast", "bool", ""]]);
81
+ case "surface_resized": return nscjFields([["id", "u64", ""], ["size.width", "f32", ""], ["size.height", "f32", ""], ["scale_factor", "f32", ""], ["safe_area_insets.top", "f32", ""], ["safe_area_insets.right", "f32", ""], ["safe_area_insets.bottom", "f32", ""], ["safe_area_insets.left", "f32", ""], ["keyboard_insets.top", "f32", ""], ["keyboard_insets.right", "f32", ""], ["keyboard_insets.bottom", "f32", ""], ["keyboard_insets.left", "f32", ""]]);
82
+ case "window_frame_changed": return nscjFields([["id", "u64", ""], ["label", "str", ""], ["title", "str", ""], ["frame.x", "f32", ""], ["frame.y", "f32", ""], ["frame.width", "f32", ""], ["frame.height", "f32", ""], ["scale_factor", "f32", ""], ["open", "bool", ""], ["focused", "bool", ""], ["maximized", "bool", ""], ["fullscreen", "bool", ""], ["hidden", "bool", ""]]);
83
+ case "window_focused": return nscjFields([["", "u64", ""]]);
84
+ case "view_focused": return nscjFields([["window_id", "u64", ""], ["label", "str", ""]]);
85
+ case "bridge_message": return nscjFields([["bytes", "str", ""], ["origin", "str", ""], ["window_id", "u64", ""], ["webview_label", "str", ""]]);
86
+ case "tray_action": return nscjFields([["status_item_id", "u32", ""], ["item_id", "u32", ""]]);
87
+ case "shortcut": return nscjFields([["id", "str", ""], ["key", "str", ""], ["modifiers", "modifiers", ""], ["window_id", "u64", ""]]);
88
+ case "native_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""], ["view_label", "str", ""]]);
89
+ case "menu_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""]]);
90
+ case "tray_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""], ["status_item_id", "u32", ""]]);
91
+ case "notification_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""]]);
92
+ case "timer": return nscjFields([["id", "u64", ""], ["timestamp_ns", "u64", ""]]);
93
+ case "audio": return nscjFields([["kind", "enum", "AudioEventKind"], ["position_ms", "u64", ""], ["duration_ms", "u64", ""], ["playing", "bool", ""], ["buffering", "bool", ""], ["bands", "bytes32", ""]]);
94
+ case "video": return nscjFields([["kind", "enum", "VideoEventKind"], ["token", "u64", ""], ["position_ms", "u64", ""], ["duration_ms", "u64", ""], ["playing", "bool", ""], ["buffering", "bool", ""], ["width", "u64", ""], ["height", "u64", ""]]);
95
+ case "files_dropped": return nscjFields([["window_id", "u64", ""], ["view_label", "str", ""], ["point", "optional-point", ""], ["paths", "paths", ""]]);
96
+ case "gpu_surface_frame": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["size.width", "f32", ""], ["size.height", "f32", ""], ["scale_factor", "f32", ""], ["frame_index", "u64", ""], ["timestamp_ns", "u64", ""], ["frame_interval_ns", "u64", ""], ["input_timestamp_ns", "u64", ""], ["canvas_frame_full_repaint", "bool", ""]]);
97
+ case "gpu_surface_resized": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["frame.x", "f32", ""], ["frame.y", "f32", ""], ["frame.width", "f32", ""], ["frame.height", "f32", ""], ["scale_factor", "f32", ""]]);
98
+ case "gpu_surface_input": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["kind", "enum", "GpuSurfaceInputKind"], ["timestamp_ns", "u64", ""], ["pointer_id", "u64", ""], ["x", "f32", ""], ["y", "f32", ""], ["button", "i32", ""], ["pressure", "f32", ""], ["delta_x", "f32", ""], ["delta_y", "f32", ""], ["scroll_is_detented", "bool", ""], ["key", "str", ""], ["text", "str", ""], ["composition_cursor", "optional-usize", ""], ["modifiers", "modifiers", ""], ["scale", "f32", ""]]);
99
+ case "gpu_surface_scroll_driver": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["driver_id", "u64", ""], ["offset_x", "f32", ""], ["offset_y", "f32", ""], ["timestamp_ns", "u64", ""]]);
100
+ case "context_menu_action": return nscjFields([["window_id", "u64", ""], ["view_label", "str", ""], ["token", "u64", ""], ["item_id", "u32", ""]]);
101
+ case "widget_context_menu_action": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["id", "u64", ""], ["item_index", "u32", ""]]);
102
+ case "widget_accessibility_action": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["id", "u64", ""], ["action", "enum32", "WidgetAccessibilityActionKind"], ["text", "str", ""], ["selection", "optional-range", ""]]);
103
+ case "app_start": return nscjFields([]);
104
+ case "app_activated": return nscjFields([]);
105
+ case "app_deactivated": return nscjFields([]);
106
+ case "frame_requested": return nscjFields([]);
107
+ case "app_shutdown": return nscjFields([]);
108
+ case "wake": return nscjFields([]);
109
+ default: throw new Error("unknown journal event schema");
110
+ }
111
+ switch (record) {
112
+ case 1: return nscjFields([["protocol_fingerprint", "u64", ""], ["platform_name", "str", ""], ["app_name", "str", ""], ["recorded_at_wall_ms", "i64", ""], ["window_width", "f32", ""], ["window_height", "f32", ""], ["window_chrome_source", "enum", "WindowChromeSource"]]);
113
+ case 4: return nscjFields([["event_ordinal", "u64", ""], ["frame_index", "u64", ""], ["fingerprint", "u64", ""]]);
114
+ case 5: return nscjFields([["event_ordinal", "u64", ""], ["view_label", "str", ""], ["scale", "f32", ""], ["png_hash", "u64", ""], ["png_len", "u64", ""]]);
115
+ case 6: return nscjFields([["event_count", "u64", ""], ["effect_count", "u64", ""], ["checkpoint_count", "u64", ""], ["screenshot_count", "u64", ""], ["window_chrome_count", "u64", ""]]);
116
+ case 7: return nscjFields([["window_id", "u64", ""], ["chrome.insets.top", "f32", ""], ["chrome.insets.right", "f32", ""], ["chrome.insets.bottom", "f32", ""], ["chrome.insets.left", "f32", ""], ["chrome.buttons.x", "f32", ""], ["chrome.buttons.y", "f32", ""], ["chrome.buttons.width", "f32", ""], ["chrome.buttons.height", "f32", ""], ["chrome.form_factor", "enum", "FormFactor"], ["chrome.tabs_projected", "bool", ""]]);
117
+ case 3: return nscjFields([["kind", "enum", "EffectResultKind"], ["key", "u64", ""], ["payload", "str", ""], ["stderr_tail", "str", ""], ["truncated", "bool", ""], ["dropped", "u32", ""], ["code", "i32", ""], ["exit_reason", "enum", "EffectExitReason"], ["output_truncated", "bool", ""], ["stderr_truncated", "bool", ""], ["status", "u16", ""], ["fetch_outcome", "enum", "EffectFetchOutcome"], ["file_op", "enum", "EffectFileOp"], ["file_event", "enum", "EffectFileEvent"], ["file_outcome", "enum", "EffectFileOutcome"], ["file_total", "u64", ""], ["file_mtime_ms", "i64", ""], ["file_exists", "bool", ""], ["file_rejected_admission", "bool", ""], ["clipboard_op", "enum", "EffectClipboardOp"], ["clipboard_outcome", "enum", "EffectClipboardOutcome"], ["timer_timestamp_ns", "u64", ""], ["timer_outcome", "enum", "EffectTimerOutcome"], ["clock_wall_ms", "i64", ""], ["audio_kind", "enum", "EffectAudioEventKind"], ["audio_position_ms", "u64", ""], ["audio_duration_ms", "u64", ""], ["audio_playing", "bool", ""], ["audio_buffering", "bool", ""], ["file_blob_hash", "bytes16", ""], ["file_blob_len", "u64", ""], ["audio_bands", "bytes32", ""], ["image_outcome", "enum", "EffectImageOutcome"], ["image_width", "u64", ""], ["image_height", "u64", ""], ["image_blob_hash", "bytes16", ""], ["image_blob_len", "u64", ""], ["channel_kind", "enum", "EffectChannelEventKind"], ["channel_dropped_total", "u32", ""], ["video_kind", "enum", "EffectVideoEventKind"], ["video_position_ms", "u64", ""], ["video_duration_ms", "u64", ""], ["video_playing", "bool", ""], ["video_buffering", "bool", ""], ["video_width", "u64", ""], ["video_height", "u64", ""], ["video_token", "u64", ""], ["video_source", "enum", "EffectVideoSource"], ["video_handled", "bool", ""], ["pty_kind", "enum", "EffectPtyEventKind"], ["pty_signal", "i32", ""], ["pty_dropped_writes", "u32", ""], ["pty_blob_hash", "bytes16", ""], ["pty_blob_len", "u64", ""], ["persist_outcome", "enum", "EffectPersistOutcome"], ["persist_blob_hash", "bytes16", ""], ["persist_blob_len", "u64", ""], ["db_blob_hash", "bytes16", ""], ["db_blob_len", "u64", ""], ["credentials_operation", "enum", "EffectCredentialsOperation"], ["credentials_outcome", "enum", "EffectCredentialsOutcome"], ["credentials_secret_len", "u64", ""], ["credentials_salt", "bytes16", ""], ["credentials_digest", "bytes32", ""]]);
118
+ default: throw new Error("invalid journal record schema");
119
+ }
120
+ }
121
+ function nscjEnumValid(domain: string, value: number): boolean {
122
+ switch (domain) {
123
+ case "ColorScheme": return value >= 0 && value <= 1;
124
+ case "AudioEventKind": return value >= 0 && value <= 4;
125
+ case "VideoEventKind": return value >= 0 && value <= 3;
126
+ case "GpuSurfaceInputKind": return value >= 0 && value <= 14;
127
+ case "EffectResultKind": return value >= 1 && value <= 20;
128
+ case "EffectExitReason": return value >= 0 && value <= 4;
129
+ case "EffectFetchOutcome": return value >= 0 && value <= 6;
130
+ case "EffectFileOp": return value >= 0 && value <= 8;
131
+ case "EffectFileEvent": return value >= 0 && value <= 2;
132
+ case "EffectFileOutcome": return value >= 0 && value <= 8;
133
+ case "EffectClipboardOp": return value >= 0 && value <= 1;
134
+ case "EffectClipboardOutcome": return value >= 0 && value <= 3;
135
+ case "EffectTimerOutcome": return value >= 0 && value <= 1;
136
+ case "EffectAudioEventKind": return value >= 0 && value <= 5;
137
+ case "EffectImageOutcome": return value >= 0 && value <= 14;
138
+ case "EffectChannelEventKind": return value >= 0 && value <= 2;
139
+ case "EffectVideoEventKind": return value >= 0 && value <= 4;
140
+ case "EffectVideoSource": return value >= 0 && value <= 1;
141
+ case "EffectPtyEventKind": return value >= 0 && value <= 2;
142
+ case "EffectPersistOutcome": return value >= 0 && value <= 6;
143
+ case "EffectCredentialsOperation": return value >= 0 && value <= 2;
144
+ case "EffectCredentialsOutcome": return value >= 0 && value <= 6;
145
+ case "WindowChromeSource": return value >= 0 && value <= 1;
146
+ case "FormFactor": return value >= 0 && value <= 2;
147
+ case "WidgetAccessibilityActionKind": return value >= 0 && value <= 13;
148
+ default: throw new Error("unknown journal enum domain");
149
+ }
150
+ }
151
+ function nscjWidth(kind: string): number {
152
+ if (kind === "enum" || kind === "bool") return 1;
153
+ if (kind === "u16") return 2;
154
+ if (kind === "f32" || kind === "u32" || kind === "i32" || kind === "enum32") return 4;
155
+ if (kind === "u64" || kind === "i64" || kind === "usize") return 8;
156
+ if (kind === "bytes16") return 16;
157
+ if (kind === "bytes32") return 32;
158
+ throw new Error("invalid journal scalar storage");
159
+ }
160
+ class NscJournalCursor implements nscContracts.Acyclic {
161
+ input: Uint8Array; slots: NscJournalSlot[]; chunks: Uint8Array[] = []; written: number = 0; entries: NscJournalSlot[] = [];
162
+ at: number = 0; status: number = 0; decode: boolean; capacity: number; usizeBits: number;
163
+ constructor(input: Uint8Array, slots: NscJournalSlot[], decode: boolean, capacity: number, usizeBits: number) {
164
+ this.input = input; this.slots = slots; this.decode = decode; this.capacity = capacity; this.usizeBits = usizeBits;
165
+ }
166
+ slot(path: string): Uint8Array {
167
+ for (const slot of this.slots) if (slot.path === path) return slot.bytes;
168
+ throw new Error("missing native journal storage slot");
169
+ }
170
+ write(bytes: Uint8Array): void {
171
+ if (this.status !== 0) return;
172
+ if (bytes.length > this.capacity - this.written) { this.status = 2; return; }
173
+ this.chunks.push(bytes); this.written += bytes.length;
174
+ }
175
+ read(length: number): Uint8Array {
176
+ if (this.status !== 0) return new Uint8Array(0);
177
+ if (length > this.input.length - this.at) { this.status = 1; return new Uint8Array(0); }
178
+ const bytes = this.input.subarray(this.at, this.at + length); this.at += length; return bytes;
179
+ }
180
+ emit(path: string, source: Uint8Array): void {
181
+ // The span descriptor borrows the original payload; no decoded text is retained.
182
+ const bytes = new Uint8Array(8), w = new DataView(bytes.buffer);
183
+ w.setUint32(0, source.byteOffset - this.input.byteOffset, true); w.setUint32(4, source.length, true);
184
+ this.entries.push({ path, bytes });
185
+ }
186
+ scalar(path: string, kind: string, domain: string): number {
187
+ if (this.status !== 0) return 0;
188
+ const length = nscjWidth(kind);
189
+ let bytes = this.decode ? this.read(length) : this.slot(path);
190
+ if (!this.decode && kind === "usize" && bytes.length === 4) { const wide = new Uint8Array(8); wide.set(bytes); bytes = wide; }
191
+ if (this.status !== 0) return 0;
192
+ if (bytes.length !== length) throw new Error("invalid native journal scalar width");
193
+ const w = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
194
+ let value = kind === "enum32" ? w.getInt32(0, true) : length === 1 ? bytes[0]! : length === 2 ? w.getUint16(0, true) : w.getUint32(0, true);
195
+ if (this.decode && (kind === "bool" && value > 1 || (kind === "enum" || kind === "enum32") && !nscjEnumValid(domain, value) || kind === "usize" && this.usizeBits === 32 && w.getUint32(4, true) !== 0)) {
196
+ this.status = 1; return 0;
197
+ }
198
+ if (this.decode) this.emit(path, bytes); else this.write(bytes);
199
+ return value;
200
+ }
201
+ string(path: string): void {
202
+ if (this.status !== 0) return;
203
+ if (this.decode) {
204
+ const prefix = this.read(4); if (this.status !== 0) return;
205
+ const count = new DataView(prefix.buffer, prefix.byteOffset, 4).getUint32(0, true), bytes = this.read(count);
206
+ if (this.status === 0) this.emit(path, bytes);
207
+ } else {
208
+ const bytes = this.slot(path), prefix = new Uint8Array(4);
209
+ if (bytes.length > 4294967295) { this.status = 2; return; }
210
+ new DataView(prefix.buffer).setUint32(0, bytes.length, true); this.write(prefix); this.write(bytes);
211
+ }
212
+ }
213
+ field(field: NscJournalField): void {
214
+ if (this.status !== 0) return;
215
+ const path = field.path, kind = field.kind;
216
+ if (kind === "str") this.string(path);
217
+ else if (kind === "modifiers") {
218
+ if (this.decode) {
219
+ const bits = this.read(1); if (this.status !== 0) return;
220
+ if (bits[0]! > 31) { this.status = 1; return; }
221
+ this.emit(path, bits);
222
+ } else {
223
+ const names = ["primary", "command", "control", "option", "shift"]; let mask = 0;
224
+ for (let i = 0; i < names.length; i++) if (this.slot(path + "." + names[i]!)[0] === 1) mask |= 1 << i;
225
+ const bits = new Uint8Array(1); bits[0] = mask; this.write(bits);
226
+ }
227
+ } else if (kind === "optional-point" || kind === "optional-usize" || kind === "optional-range") {
228
+ if (this.scalar(path, "bool", "") !== 0) {
229
+ if (kind === "optional-point") { this.scalar(path + ".x", "f32", ""); this.scalar(path + ".y", "f32", ""); }
230
+ else if (kind === "optional-range") { this.scalar(path + ".start", "usize", ""); this.scalar(path + ".end", "usize", ""); }
231
+ else this.scalar(path + ".value", "usize", "");
232
+ }
233
+ } else if (kind === "paths") {
234
+ let count = 0;
235
+ if (this.decode) {
236
+ const raw = this.read(2); if (this.status !== 0) return;
237
+ count = new DataView(raw.buffer, raw.byteOffset, 2).getUint16(0, true);
238
+ if (count > 32) { this.status = 1; return; }
239
+ this.emit(path, raw);
240
+ } else {
241
+ const raw = this.slot(path), w = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);
242
+ count = w.getUint32(0, true);
243
+ if (w.getUint32(4, true) !== 0 || count > 32) { this.status = 2; return; }
244
+ const bytes = new Uint8Array(2); new DataView(bytes.buffer).setUint16(0, count, true); this.write(bytes);
245
+ }
246
+ for (let i = 0; i < count && this.status === 0; i++) this.string(path + "/" + i);
247
+ } else this.scalar(path, kind, field.domain);
248
+ }
249
+ }
250
+ /** Opcode 30, version 1: encode raw native slots or decode borrowed wire spans.
251
+ * Result status 1 is corrupt input; 2 is output budget. Failed operations retain
252
+ * their exact written prefix and all already-decoded dropped-path spans.
253
+ */
254
+ export function sessionCodecPolicy(request: Uint8Array): Uint8Array {
255
+ if (request.length < 24 || request[0] !== 30 || request[1] !== 1 || request[2]! > 1 || request[3]! < 1 || request[3]! > 7)
256
+ throw new Error("invalid journal codec request");
257
+ const w = new DataView(request.buffer, request.byteOffset, request.byteLength), decode = request[2] === 1, record = request[3]!;
258
+ const capacity = w.getUint32(4, true), usizeBits = w.getUint32(8, true), nameLength = w.getUint32(12, true), count = w.getUint32(16, true), payloadLength = w.getUint32(20, true);
259
+ if (usizeBits !== 32 && usizeBits !== 64 || nameLength > 64 || count > 512 || decode && (nameLength !== 0 || count !== 0) || !decode && payloadLength !== 0 || 24 + nameLength > request.length)
260
+ throw new Error("invalid journal codec storage bounds");
261
+ let at = 24 + nameLength; const slots: NscJournalSlot[] = [];
262
+ const text = new TextDecoder("utf-8", { ignoreBOM: true });
263
+ let name = text.decode(request.subarray(24, at));
264
+ for (let i = 0; i < count; i++) {
265
+ if (at + 8 > request.length) throw new Error("truncated journal slot");
266
+ const n = w.getUint32(at, true), length = w.getUint32(at + 4, true); at += 8;
267
+ if (n > 256 || n > request.length - at || length > request.length - at - n) throw new Error("invalid journal slot extent");
268
+ const path = text.decode(request.subarray(at, at + n)); at += n;
269
+ for (const slot of slots) if (slot.path === path) throw new Error("duplicate journal slot");
270
+ slots.push({ path, bytes: request.subarray(at, at + length) }); at += length;
271
+ }
272
+ if (payloadLength !== request.length - at) throw new Error("invalid journal payload extent");
273
+ const input = request.subarray(at), cursor = new NscJournalCursor(input, slots, decode, capacity, usizeBits);
274
+ let tag = 0;
275
+ if (record === 2) {
276
+ if (decode) {
277
+ const value = cursor.read(1);
278
+ if (cursor.status === 0) { tag = value[0]!; name = nscjEventName(tag); if (name === "") cursor.status = 1; }
279
+ } else { tag = nscjEventTag(name); const value = new Uint8Array(1); value[0] = tag; cursor.write(value); }
280
+ }
281
+ let effectKind = 0;
282
+ if (cursor.status === 0) {
283
+ for (const field of nscjSchema(record, name)) {
284
+ // The effect's kind-local suffixes preserve all earlier byte layouts.
285
+ if (record === 3 && field.path.startsWith("persist_") && effectKind !== 16 || record === 3 && field.path.startsWith("db_") && effectKind !== 17 || record === 3 && field.path.startsWith("credentials_") && effectKind !== 18) continue;
286
+ if (record === 3 && field.path === "kind") effectKind = cursor.scalar(field.path, field.kind, field.domain);
287
+ else cursor.field(field);
288
+ if (cursor.status !== 0) break;
289
+ }
290
+ }
291
+ if (decode && cursor.status === 0 && cursor.at !== input.length) cursor.status = 1;
292
+ const paths: Uint8Array[] = [];
293
+ let bodyLength = decode ? 0 : cursor.written;
294
+ if (decode) for (const entry of cursor.entries) {
295
+ const path = new TextEncoder().encode(entry.path); paths.push(path); bodyLength += 12 + path.length;
296
+ }
297
+ const eventName = decode && record === 2 ? new TextEncoder().encode(name) : new Uint8Array(0);
298
+ const result = new Uint8Array(16 + eventName.length + bodyLength), out = new DataView(result.buffer);
299
+ out.setUint32(0, 1, true); out.setUint32(4, cursor.status, true); out.setUint32(8, decode ? cursor.entries.length : cursor.written, true); out.setUint32(12, eventName.length, true);
300
+ result.set(eventName, 16);
301
+ let outputAt = 16 + eventName.length;
302
+ if (decode) for (let i = 0; i < cursor.entries.length; i++) {
303
+ const entry = cursor.entries[i]!, path = paths[i]!;
304
+ out.setUint32(outputAt, path.length, true); outputAt += 4;
305
+ result.set(path, outputAt); outputAt += path.length;
306
+ result.set(entry.bytes, outputAt); outputAt += 8;
307
+ } else for (const chunk of cursor.chunks) { result.set(chunk, outputAt); outputAt += chunk.length; }
308
+ return result;
309
+ }
@@ -0,0 +1,126 @@
1
+ /** Portable scene and runtime descriptor admission over copied raw facts. */
2
+ function nscvShellAdmission(request: Uint8Array): Uint8Array {
3
+ if (request.length < 64 || request[0] !== 85 || request[1] !== 1 || request[2]! > 11 || request[3] !== 0)
4
+ throw new Error("invalid shell admission header");
5
+ const w = new DataView(request.buffer, request.byteOffset, request.byteLength), mode = request[2]!;
6
+ const word = (at: number): number => w.getUint32(at, true);
7
+ const over = (at: number, limit: number): boolean => word(at + 4) !== 0 || word(at) > limit;
8
+ const empty = (at: number): boolean => word(at) === 0 && word(at + 4) === 0;
9
+ let status = 0, state = 0;
10
+ if (mode === 0) {
11
+ const field = word(4), prior = word(12), count = word(32), final = word(36);
12
+ if (field > 9 || prior > 15 || final > 1 || count > 256 || request.length !== 64 + count)
13
+ throw new Error("invalid shell field bounds");
14
+ const endLow = word(24) + count, carry = endLow > 4294967295 ? 1 : 0, endHigh = word(28) + carry;
15
+ if (endHigh > word(20) || endHigh === word(20) && endLow - carry * 4294967296 > word(16) || final === 1 && (endHigh !== word(20) || endLow - carry * 4294967296 !== word(16)))
16
+ throw new Error("invalid shell field extent");
17
+ for (let i = 56; i < 64; i++) if (request[i] !== 0) throw new Error("invalid shell field padding");
18
+ state = prior;
19
+ const dot = word(20) === 0 && (word(16) === 1 && request[48] === 46 || word(16) === 2 && request[48] === 46 && request[49] === 46);
20
+ let prefix = 0, web = false;
21
+ if (field === 6) {
22
+ if (request[48] === 104 && request[49] === 116 && request[50] === 116 && request[51] === 112) {
23
+ if (request[52] === 58 && request[53] === 47 && request[54] === 47) { prefix = 7; web = true; }
24
+ else if (request[52] === 115 && request[53] === 58 && request[54] === 47 && request[55] === 47) { prefix = 8; web = true; }
25
+ } else if ((request[48] === 102 && request[49] === 105 && request[50] === 108 && request[51] === 101 || request[48] === 122 && request[49] === 101 && request[50] === 114 && request[51] === 111) && request[52] === 58 && request[53] === 47 && request[54] === 47) prefix = 7;
26
+ if (prefix === 0 || word(20) === 0 && word(16) <= prefix) state |= 1;
27
+ }
28
+ const appIcon = field === 8 && request[48] === 97 && request[49] === 112 && request[50] === 112 && request[51] === 58;
29
+ for (let i = 0; i < count; i++) {
30
+ const ch = request[64 + i]!, position = word(24) + i, leading = word(28) === 0;
31
+ if (field <= 2 || field === 5 || field === 9) {
32
+ if (ch === 0 || ch === 47 || ch === 92) state |= 1;
33
+ if (ch === 9 || ch === 10 || ch === 13) state |= 2;
34
+ } else if (field === 3 || field === 4) {
35
+ if (ch === 0) state |= 1;
36
+ } else if (field === 6) {
37
+ if (leading && position < prefix) continue;
38
+ if (web && (state & 8) !== 0) continue;
39
+ if (web && ch === 47) { state |= 8; continue; }
40
+ state |= 4;
41
+ if (ch === 0 || ch === 32 || ch === 9 || ch === 10 || ch === 13) state |= 1;
42
+ } else if (field === 7) {
43
+ if (ch < 32 || ch === 127) state |= 1;
44
+ } else if (field === 8) {
45
+ if (appIcon && leading && position < 4) continue;
46
+ if (!(ch >= 97 && ch <= 122 || ch >= 48 && ch <= 57 || ch === 45 || ch === 95)) state |= 1;
47
+ }
48
+ }
49
+ if (field <= 2) status = empty(16) || dot || (state & 1) !== 0 || field > 0 && over(16, 64) ? 1 : 0;
50
+ else if (field <= 4) status = (state & 1) !== 0 || field === 3 && over(16, 256) ? 1 : 0;
51
+ else if (field === 5) status = empty(16) || over(16, 128) ? 6 : dot || (state & 1) !== 0 ? 1 : (state & 2) !== 0 ? 6 : 0;
52
+ else if (field === 6) status = (state & 1) !== 0 || final === 1 && (state & 4) === 0 ? 8 : 0;
53
+ else if (field === 7) status = empty(16) || over(16, 128) || (state & 1) !== 0 ? 1 : 0;
54
+ else if (field === 8) status = over(16, 64) || (state & 1) !== 0 || appIcon && word(20) === 0 && word(16) === 4 ? 1 : 0;
55
+ else status = empty(16) || over(16, 128) || dot || (state & 3) !== 0 ? 6 : 0;
56
+ } else if (mode === 3) {
57
+ const count = word(16);
58
+ if (over(16, 128) || request.length !== 64 + count * 4) throw new Error("invalid shell hierarchy bounds");
59
+ const visits: number[] = [];
60
+ for (let i = 0; i < count; i++) visits.push(0);
61
+ for (let i = 0; i < count; i++) {
62
+ let at = i;
63
+ while (at !== 4294967295 && visits[at] === 0) {
64
+ visits[at] = 1;
65
+ at = word(64 + at * 4);
66
+ if (at !== 4294967295 && at >= count) throw new Error("invalid shell parent slot");
67
+ }
68
+ if (at !== 4294967295 && visits[at] === 1) { status = 2; break; }
69
+ at = i;
70
+ while (at !== 4294967295 && visits[at] === 1) { visits[at] = 2; at = word(64 + at * 4); }
71
+ }
72
+ } else {
73
+ if (request.length !== (mode === 2 || mode === 8 || mode === 9 ? 160 : 64)) throw new Error("invalid shell admission tail");
74
+ if (mode === 1) {
75
+ status = word(4) || word(8);
76
+ if (status === 0 && (w.getFloat32(32, true) <= 0 || w.getFloat32(36, true) <= 0)) status = 5;
77
+ if (status === 0 && over(16, 128)) status = 2;
78
+ } else if (mode === 2) {
79
+ const flags = word(4), duplicate = word(8), parent = word(12), kind = word(80);
80
+ if (flags > 1023 || duplicate > 1 || kind > 18 || word(84) > 63) throw new Error("invalid shell descriptor facts");
81
+ status = word(16);
82
+ if (status === 0 && duplicate) status = 3;
83
+ if (status === 0 && (flags & 64) !== 0) status = word(20) || (parent === 4294967295 || parent === word(88) ? 2 : 0);
84
+ if (status === 0) {
85
+ for (let i = 0; i < 6; i++) if ((flags & (1 << i)) !== 0) {
86
+ const value = w.getFloat32(48 + i * 4, true);
87
+ if (i === 2 || i === 3 ? value < 0 : value <= 0) status = 5;
88
+ }
89
+ if ((flags & 20) === 20 && w.getFloat32(56, true) > w.getFloat32(64, true) || (flags & 40) === 40 && w.getFloat32(60, true) > w.getFloat32(68, true)) status = 5;
90
+ }
91
+ for (let i = 0; i < 4 && status === 0; i++) status = word(24 + i * 4);
92
+ if (status === 0) status = (flags & 128) !== 0 ? kind !== 0 ? 8 : word(40) : kind === 0 ? 9 : 0;
93
+ if (status === 0 && kind !== 17 && word(84) !== 0) status = 10;
94
+ } else if (mode === 4) status = over(16, 16) ? 2 : 0;
95
+ else if (mode === 5) status = over(16, 5) || word(16) === 1 ? 2 : 0;
96
+ else if (mode === 6) status = word(16) || word(20) || word(24) || (word(4) !== 0 ? 7 : 0);
97
+ else if (mode === 7) status = word(4) !== 0 ? 4 : 0;
98
+ else if (mode === 8 || mode === 9) {
99
+ const flags = word(8), kind = word(4), patch = mode === 9;
100
+ if (kind > 18 || flags > 63) throw new Error("invalid runtime descriptor facts");
101
+ status = empty(64) ? 11 : over(64, 64) ? 12 : 0;
102
+ if (status === 0 && (!patch || (flags & 1) !== 0)) for (let i = 0; i < 4; i++) if (w.getFloat32(32 + i * 4, true) < 0) status = 11;
103
+ if (status === 0 && !patch && (flags & 1) !== 0 && (empty(72) || over(72, 64))) status = 11;
104
+ if (status === 0 && over(80, 64)) status = 13;
105
+ if (status === 0 && over(88, 256)) status = 14;
106
+ if (status === 0 && over(96, 1024)) status = 15;
107
+ if (status === 0 && !empty(104)) status = word(120);
108
+ if (status === 0 && !patch && kind !== 0 && !empty(112)) status = 11;
109
+ if (status === 0 && !patch && kind === 17 && !((request[16] === 1 || request[16] === 3) && request[17] === 1 && request[18] === 1 && (request[19] === 1 || request[19] === 2) && request[20] === 1 && request[21] === 1)) status = 16;
110
+ } else if (mode === 10) {
111
+ const category = word(4);
112
+ if (category > 2) throw new Error("invalid runtime label category");
113
+ status = empty(16) ? category === 0 ? 11 : 18 : over(16, 64) ? category === 0 ? 12 : 19 : 0;
114
+ if (status === 0 && category === 2 && word(20) === 0 && word(16) === 4 && request[40] === 109 && request[41] === 97 && request[42] === 105 && request[43] === 110) status = 20;
115
+ } else if (mode === 11) {
116
+ const category = word(4);
117
+ if (category > 2) throw new Error("invalid runtime frame category");
118
+ const x = w.getFloat32(16, true), y = w.getFloat32(20, true), width = w.getFloat32(24, true), height = w.getFloat32(28, true);
119
+ status = category === 0 ? x < 0 || y < 0 || width < 0 || height < 0 ? 11 : 0 : category === 1 ? !Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0 ? 17 : 0 : x >= 0 && y >= 0 && width > 0 && height > 0 ? 0 : 18;
120
+ }
121
+ }
122
+ if (status > 20) throw new Error("invalid shell field verdict");
123
+ const result = new Uint8Array(16), out = new DataView(result.buffer);
124
+ out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true); out.setUint32(12, state, true);
125
+ return result;
126
+ }