@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.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1818 -87
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +2 -1
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/codesign.zig +125 -74
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/package.zig +85 -1
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/** Retained paint scheduling over copied layout, state and command identities.
|
|
2
|
+
* Native executes drawing capabilities; this plan owns traversal decisions. */
|
|
3
|
+
interface NscWalkNode {
|
|
4
|
+
readonly walk_kind: number; readonly walk_flags: number;
|
|
5
|
+
readonly walk_parent: number; readonly walk_parent_high: number;
|
|
6
|
+
readonly walk_id: number; readonly walk_id_high: number;
|
|
7
|
+
readonly walk_preview_id: number; readonly walk_preview_id_high: number;
|
|
8
|
+
readonly walk_depth: number; readonly walk_depth_high: number; readonly walk_layer: number;
|
|
9
|
+
readonly walk_frame: NscSurfaceRect; readonly walk_transform: NscRenderAffine;
|
|
10
|
+
readonly walk_opacity: number; readonly walk_opacity_word: number; readonly walk_value: number; readonly walk_gap: number;
|
|
11
|
+
}
|
|
12
|
+
interface NscWalkMotion extends NscPresentationMotion { readonly walk_dx_word: number; readonly walk_dy_word: number; }
|
|
13
|
+
interface NscWalkOrder { readonly walk_slot: number; readonly walk_layer: number; }
|
|
14
|
+
interface NscWalkContext {
|
|
15
|
+
readonly walk_nodes: readonly NscWalkNode[]; readonly walk_motions: readonly NscWalkMotion[];
|
|
16
|
+
readonly walk_reveals: readonly number[]; readonly walk_ids: readonly number[];
|
|
17
|
+
readonly walk_flags: number; readonly walk_scalar: number; readonly walk_numeric: number; readonly walk_nan: number; readonly walk_layers: readonly number[];
|
|
18
|
+
}
|
|
19
|
+
function nscvWalkHoisted(n: NscWalkNode): boolean { return (n.walk_flags & 2) !== 0 || n.walk_kind === 19 || n.walk_kind === 20 || n.walk_kind === 21; }
|
|
20
|
+
function nscvWalkParent(c: NscWalkContext, n: NscWalkNode): number {
|
|
21
|
+
return (n.walk_flags & 1) === 0 ? -1 : n.walk_parent_high !== 0 || n.walk_parent >= c.walk_nodes.length ? c.walk_nodes.length : n.walk_parent;
|
|
22
|
+
}
|
|
23
|
+
function nscvWalkSameParent(a: NscWalkNode, b: NscWalkNode): boolean {
|
|
24
|
+
return (a.walk_flags & 1) === (b.walk_flags & 1) && ((a.walk_flags & 1) === 0 || (a.walk_parent === b.walk_parent && a.walk_parent_high === b.walk_parent_high));
|
|
25
|
+
}
|
|
26
|
+
function nscvWalkId(n: NscWalkNode, ids: readonly number[], at: number): boolean { return n.walk_id === ids[at] && n.walk_id_high === ids[at + 1]; }
|
|
27
|
+
function nscvWalkNonzero(n: NscWalkNode): boolean { return n.walk_id !== 0 || n.walk_id_high !== 0; }
|
|
28
|
+
function nscvWalkLayer(c: NscWalkContext, n: NscWalkNode, surface: boolean): number {
|
|
29
|
+
if ((n.walk_flags & 8) !== 0) return n.walk_layer;
|
|
30
|
+
if (n.walk_kind === 19 || n.walk_kind === 20 || n.walk_kind === 21) return c.walk_layers[3]!;
|
|
31
|
+
if ((surface && (n.walk_flags & 2) !== 0) || n.walk_kind === 23 || n.walk_kind === 24 || n.walk_kind === 25) return c.walk_layers[1]!;
|
|
32
|
+
return c.walk_layers[n.walk_kind === 40 ? 2 : 0]!;
|
|
33
|
+
}
|
|
34
|
+
function nscvWalkSurfaceLayer(c: NscWalkContext, slot: number): number {
|
|
35
|
+
const n = c.walk_nodes[slot]!;
|
|
36
|
+
let layer = nscvWalkLayer(c, n, true);
|
|
37
|
+
if ((n.walk_flags & 8) !== 0) return layer;
|
|
38
|
+
let parent = nscvWalkParent(c, n);
|
|
39
|
+
while (parent >= 0 && parent < c.walk_nodes.length) {
|
|
40
|
+
const ancestor = c.walk_nodes[parent]!;
|
|
41
|
+
if (nscvWalkHoisted(ancestor)) layer = Math.max(layer, nscvWalkLayer(c, ancestor, true));
|
|
42
|
+
parent = nscvWalkParent(c, ancestor);
|
|
43
|
+
}
|
|
44
|
+
return layer;
|
|
45
|
+
}
|
|
46
|
+
function nscvWalkCompare(a: NscWalkOrder, b: NscWalkOrder): number { return a.walk_layer === b.walk_layer ? a.walk_slot - b.walk_slot : a.walk_layer - b.walk_layer; }
|
|
47
|
+
function nscvWalkDeeper(a: NscWalkNode, b: NscWalkNode): boolean { return a.walk_depth_high > b.walk_depth_high || (a.walk_depth_high === b.walk_depth_high && a.walk_depth > b.walk_depth); }
|
|
48
|
+
function nscvWalkSelected(n: NscWalkNode): boolean { return (n.walk_flags & 128) !== 0 || n.walk_value >= 0.5; }
|
|
49
|
+
function nscvWalkSettled(c: NscWalkContext, slot: number): boolean {
|
|
50
|
+
const n = c.walk_nodes[slot]!;
|
|
51
|
+
if (!nscvWalkSelected(n)) return false;
|
|
52
|
+
let bottom = -Infinity, i = slot + 1;
|
|
53
|
+
while (i < c.walk_nodes.length && nscvWalkDeeper(c.walk_nodes[i]!, n)) {
|
|
54
|
+
const child = c.walk_nodes[i]!;
|
|
55
|
+
if (!nscvWalkHoisted(child)) bottom = nscvRenderExtreme(bottom, nscvSurfaceBottom(nscvSurfaceNormalize(child.walk_frame)), c.walk_numeric, true);
|
|
56
|
+
i++;
|
|
57
|
+
if (nscvWalkHoisted(child) || child.walk_kind === 14) while (i < c.walk_nodes.length && nscvWalkDeeper(c.walk_nodes[i]!, child)) i++;
|
|
58
|
+
}
|
|
59
|
+
return bottom === -Infinity || bottom <= Math.fround(nscvSurfaceBottom(nscvSurfaceNormalize(n.walk_frame)) + 0.5);
|
|
60
|
+
}
|
|
61
|
+
function nscvWalkVisible(c: NscWalkContext, slot: number): boolean {
|
|
62
|
+
let current = slot;
|
|
63
|
+
while (current >= 0 && current < c.walk_nodes.length) {
|
|
64
|
+
const n = c.walk_nodes[current]!;
|
|
65
|
+
if ((n.walk_flags & 4) !== 0 || (current !== slot && n.walk_kind === 14 && !nscvWalkSettled(c, current))) return false;
|
|
66
|
+
current = nscvWalkParent(c, n);
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
function nscvWalkMotion(c: NscWalkContext, n: NscWalkNode, preview: boolean): NscWalkMotion | null {
|
|
71
|
+
if (preview || (c.walk_flags & 64) !== 0 || !nscvWalkNonzero(n)) return null;
|
|
72
|
+
for (const m of c.walk_motions) if (m.presentation_id === n.walk_id && m.presentation_id_high === n.walk_id_high) return m;
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function nscvWalkWithin(c: NscWalkContext, slot: number, target: number): boolean {
|
|
76
|
+
let current = slot;
|
|
77
|
+
while (current >= 0 && current < c.walk_nodes.length) {
|
|
78
|
+
if (current === target) return true;
|
|
79
|
+
current = nscvWalkParent(c, c.walk_nodes[current]!);
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function nscvWalkGroupFocus(c: NscWalkContext, slot: number, preview: boolean, focused: boolean): boolean {
|
|
84
|
+
if (focused) return true;
|
|
85
|
+
if (!preview && (c.walk_flags & 6) !== 0) {
|
|
86
|
+
if ((c.walk_flags & 4) === 0 || (c.walk_ids[2] === 0 && c.walk_ids[3] === 0)) return false;
|
|
87
|
+
for (let i = 0; i < c.walk_nodes.length; i++) if (nscvWalkId(c.walk_nodes[i]!, c.walk_ids, 2)) return nscvWalkWithin(c, i, slot);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
for (let i = 0; i < c.walk_nodes.length; i++) if (i !== slot && (c.walk_nodes[i]!.walk_flags & 16) !== 0 && nscvWalkWithin(c, i, slot)) return true;
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
function nscvWalkDisclosure(c: NscWalkContext, slot: number, preview: boolean): number {
|
|
94
|
+
const n = c.walk_nodes[slot]!;
|
|
95
|
+
if (n.walk_kind !== 14 || nscvWalkSelected(n)) return nscvWalkSettled(c, slot) || n.walk_kind !== 14 ? 2 : 1;
|
|
96
|
+
const remapped = preview || (c.walk_flags & 64) !== 0, low = remapped ? n.walk_preview_id : n.walk_id, high = remapped ? n.walk_preview_id_high : n.walk_id_high;
|
|
97
|
+
if (low === 0 && high === 0) return 0;
|
|
98
|
+
for (let i = 0; i < c.walk_reveals.length; i += 2) if (low === c.walk_reveals[i] && high === c.walk_reveals[i + 1]) return 1;
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
// The target supplies the invalid-operation NaN word. JavaScript does not
|
|
102
|
+
// specify its sign; transferred NaN operands retain their own payload/sign.
|
|
103
|
+
function nscvWalkMultiply(c: NscWalkContext, a: number, b: number): number {
|
|
104
|
+
if (Number.isNaN(a)) return a;
|
|
105
|
+
if (Number.isNaN(b)) return b;
|
|
106
|
+
if ((a === 0 && !Number.isFinite(b)) || (b === 0 && !Number.isFinite(a))) return c.walk_nan;
|
|
107
|
+
return Math.fround(a * b);
|
|
108
|
+
}
|
|
109
|
+
function nscvWalkSubtract(c: NscWalkContext, a: number, b: number): number {
|
|
110
|
+
if (Number.isNaN(a)) return a;
|
|
111
|
+
if (Number.isNaN(b)) return b;
|
|
112
|
+
return !Number.isFinite(a) && a === b ? c.walk_nan : Math.fround(a - b);
|
|
113
|
+
}
|
|
114
|
+
function nscvWalkDivide(c: NscWalkContext, a: number, b: number): number {
|
|
115
|
+
if (Number.isNaN(a)) return a;
|
|
116
|
+
if (Number.isNaN(b)) return b;
|
|
117
|
+
return (a === 0 && b === 0) || (!Number.isFinite(a) && !Number.isFinite(b)) ? c.walk_nan : Math.fround(a / b);
|
|
118
|
+
}
|
|
119
|
+
function nscvWalkNegativeMultiply(c: NscWalkContext, a: number, b: number): number {
|
|
120
|
+
return (c.walk_scalar & 2) !== 0 ? -nscvWalkMultiply(c, a, b) : nscvWalkMultiply(c, -a, b);
|
|
121
|
+
}
|
|
122
|
+
function nscvWalkInverse(c: NscWalkContext, t: NscRenderAffine): NscRenderAffine | null {
|
|
123
|
+
const det = nscvWalkSubtract(c, nscvWalkMultiply(c, t.a, t.d), nscvWalkMultiply(c, t.b, t.c));
|
|
124
|
+
if (Math.abs(det) <= Math.fround(0.000001)) return null;
|
|
125
|
+
const inv = nscvWalkDivide(c, 1, det);
|
|
126
|
+
return { a: nscvWalkMultiply(c, t.d, inv), b: nscvWalkNegativeMultiply(c, t.b, inv), c: nscvWalkNegativeMultiply(c, t.c, inv), d: nscvWalkMultiply(c, t.a, inv), tx: nscvWalkMultiply(c, nscvWalkSubtract(c, nscvWalkMultiply(c, t.c, t.ty), nscvWalkMultiply(c, t.d, t.tx)), inv), ty: nscvWalkMultiply(c, nscvWalkSubtract(c, nscvWalkMultiply(c, t.b, t.tx), nscvWalkMultiply(c, t.a, t.ty)), inv) };
|
|
127
|
+
}
|
|
128
|
+
function nscvWalkPutLane(out: DataView, at: number, c: NscWalkContext, slot: number, preview: boolean): void {
|
|
129
|
+
const n = c.walk_nodes[slot]!, nonzero = nscvWalkNonzero(n), runtimeFocus = !preview && (c.walk_flags & 6) !== 0;
|
|
130
|
+
const focusMask = n.walk_kind === 41 ? 2 : 4, focusAt = n.walk_kind === 41 ? 0 : 2;
|
|
131
|
+
const focused = runtimeFocus ? nonzero && (c.walk_flags & focusMask) !== 0 && nscvWalkId(n, c.walk_ids, focusAt) : (n.walk_flags & 16) !== 0;
|
|
132
|
+
const hovered = !preview && (c.walk_flags & 8) !== 0 ? nonzero && nscvWalkId(n, c.walk_ids, 4) : (n.walk_flags & 32) !== 0;
|
|
133
|
+
const pressed = !preview && (c.walk_flags & 16) !== 0 ? nonzero && nscvWalkId(n, c.walk_ids, 6) : (n.walk_flags & 64) !== 0;
|
|
134
|
+
const logicalId = (c.walk_flags & 64) !== 0 ? n.walk_preview_id === c.walk_ids[0] && n.walk_preview_id_high === c.walk_ids[1] : nscvWalkId(n, c.walk_ids, 0);
|
|
135
|
+
const logical = (preview || (c.walk_flags & 1) !== 0) && (runtimeFocus ? nonzero && (c.walk_flags & 2) !== 0 && logicalId : (n.walk_flags & 16) !== 0);
|
|
136
|
+
const skip = (n.walk_flags & 4) !== 0 || (!preview && (c.walk_flags & 64) === 0 && (c.walk_flags & 32) !== 0 && nscvWalkId(n, c.walk_ids, 8) && n.walk_kind !== 16 && n.walk_kind !== 58);
|
|
137
|
+
const signaling = (n.walk_opacity_word & 0x7f800000) === 0x7f800000 && (n.walk_opacity_word & 0x7fffff) !== 0 && (n.walk_opacity_word & 0x400000) === 0;
|
|
138
|
+
const opacity = signaling && (c.walk_scalar & 1) !== 0 ? 0 : nscvRenderExtreme(0, nscvRenderExtreme(n.walk_opacity, 1, c.walk_numeric, false), c.walk_numeric, true), m = nscvWalkMotion(c, n, preview), t = n.walk_transform;
|
|
139
|
+
const wrapTransform = t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || t.tx !== 0 || t.ty !== 0;
|
|
140
|
+
const inverse = wrapTransform ? nscvWalkInverse(c, t) : nscvPresentationIdentity();
|
|
141
|
+
const flags = (focused ? 1 : 0) | (hovered ? 2 : 0) | (pressed ? 4 : 0) | (logical ? 8 : 0) | ((n.walk_kind === 60 ? nscvWalkGroupFocus(c, slot, preview, focused) : focused) ? 16 : 0) | (skip ? 32 : 0) | (opacity < 1 ? 64 : 0) | (m !== null && (m.presentation_dx !== 0 || m.presentation_dy !== 0) ? 128 : 0) | (wrapTransform ? 256 : 0) | (nscvWalkHoisted(n) || (m !== null && m.presentation_escape) ? 512 : 0) | (nscvWalkDisclosure(c, slot, preview) << 10);
|
|
142
|
+
out.setUint32(at, flags, true); if (Number.isNaN(opacity)) out.setUint32(at + 4, n.walk_opacity_word, true); else out.setFloat32(at + 4, opacity, true); out.setUint32(at + 8, m === null ? 0 : m.walk_dx_word, true); out.setUint32(at + 12, m === null ? 0 : m.walk_dy_word, true);
|
|
143
|
+
nscvPresentationPutTransform(out, at + 16, inverse);
|
|
144
|
+
}
|
|
145
|
+
function nscvWidgetPaintWalk(request: Uint8Array): Uint8Array {
|
|
146
|
+
if (request.length < 80 || request[1] !== 1 || request[2]! > 15 || request[3]! > 3) throw new Error("invalid paint walk header");
|
|
147
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(4, true), motionCount = w.getUint32(8, true), revealCount = w.getUint32(12, true), flags = w.getUint32(16, true);
|
|
148
|
+
if (flags > 255 || !Number.isNaN(w.getFloat32(76, true)) || request.length !== 80 + count * 96 + motionCount * 24 + revealCount * 8) throw new Error("invalid paint walk shape");
|
|
149
|
+
const nodes: NscWalkNode[] = [], motions: NscWalkMotion[] = [], reveals: number[] = [], ids: number[] = [], layers: number[] = [];
|
|
150
|
+
for (let i = 0; i < 4; i++) layers.push(w.getInt32(20 + i * 4, true));
|
|
151
|
+
for (let i = 0; i < 10; i++) ids.push(w.getUint32(36 + i * 4, true));
|
|
152
|
+
for (let i = 0; i < count; i++) {
|
|
153
|
+
const at = 80 + i * 96, kind = w.getUint32(at, true), nodeFlags = w.getUint32(at + 4, true);
|
|
154
|
+
if (kind > 62 || nodeFlags > 255) throw new Error("invalid paint walk node");
|
|
155
|
+
nodes.push({ walk_kind: kind, walk_flags: nodeFlags, walk_parent: w.getUint32(at + 8, true), walk_parent_high: w.getUint32(at + 12, true), walk_id: w.getUint32(at + 16, true), walk_id_high: w.getUint32(at + 20, true), walk_preview_id: w.getUint32(at + 24, true), walk_preview_id_high: w.getUint32(at + 28, true), walk_depth: w.getUint32(at + 32, true), walk_depth_high: w.getUint32(at + 36, true), walk_layer: w.getInt32(at + 40, true), walk_frame: nscvRenderRect(w, at + 44), walk_transform: nscvRenderAffine(w, at + 60), walk_opacity: w.getFloat32(at + 84, true), walk_opacity_word: w.getUint32(at + 84, true), walk_value: w.getFloat32(at + 88, true), walk_gap: w.getFloat32(at + 92, true) });
|
|
156
|
+
}
|
|
157
|
+
for (let i = 0; i < motionCount; i++) {
|
|
158
|
+
const at = 80 + count * 96 + i * 24;
|
|
159
|
+
if (w.getUint32(at + 16, true) > 1 || w.getUint32(at + 20, true) !== 0) throw new Error("invalid paint walk motion");
|
|
160
|
+
motions.push({ presentation_id: w.getUint32(at, true), presentation_id_high: w.getUint32(at + 4, true), presentation_dx: w.getFloat32(at + 8, true), presentation_dy: w.getFloat32(at + 12, true), presentation_escape: w.getUint32(at + 16, true) === 1, walk_dx_word: w.getUint32(at + 8, true), walk_dy_word: w.getUint32(at + 12, true) });
|
|
161
|
+
}
|
|
162
|
+
for (let i = 0; i < revealCount * 2; i++) reveals.push(w.getUint32(80 + count * 96 + motionCount * 24 + i * 4, true));
|
|
163
|
+
const c: NscWalkContext = { walk_nodes: nodes, walk_motions: motions, walk_reveals: reveals, walk_ids: ids, walk_flags: flags, walk_scalar: request[3]!, walk_numeric: request[2]!, walk_nan: w.getFloat32(76, true), walk_layers: layers };
|
|
164
|
+
// Retained parent links may point forward or be present but out of range.
|
|
165
|
+
// Cycles cannot be traversed by the native renderer; reject them explicitly.
|
|
166
|
+
for (let i = 0; i < count; i++) { let p = i, steps = 0; while (p >= 0 && p < count) { if (steps++ >= count) throw new Error("invalid paint walk cycle"); p = nscvWalkParent(c, nodes[p]!); } }
|
|
167
|
+
const orders: NscWalkOrder[] = [], surfaces: NscWalkOrder[] = [], escaping: number[] = [];
|
|
168
|
+
let preview = -1;
|
|
169
|
+
for (let i = 0; i < count; i++) {
|
|
170
|
+
const n = nodes[i]!, visible = nscvWalkVisible(c, i), m = nscvWalkMotion(c, n, false);
|
|
171
|
+
orders.push({ walk_slot: i, walk_layer: nscvWalkLayer(c, n, false) });
|
|
172
|
+
if (nscvWalkHoisted(n) && visible) surfaces.push({ walk_slot: i, walk_layer: nscvWalkSurfaceLayer(c, i) });
|
|
173
|
+
if (!nscvWalkHoisted(n) && m !== null && m.presentation_escape && visible) escaping.push(i);
|
|
174
|
+
if (preview === -1 && (flags & 32) !== 0 && nscvWalkNonzero(n) && nscvWalkId(n, ids, 8)) preview = i;
|
|
175
|
+
}
|
|
176
|
+
if (preview !== -1 && (nodes[preview]!.walk_kind === 16 || nodes[preview]!.walk_kind === 58 || !nscvWalkVisible(c, preview))) preview = -1;
|
|
177
|
+
const ordered = orders.toSorted(nscvWalkCompare), sortedSurfaces = surfaces.toSorted(nscvWalkCompare), result = new Uint8Array(24 + count * 120), out = new DataView(result.buffer);
|
|
178
|
+
result[0] = 1; out.setUint32(4, count, true);
|
|
179
|
+
for (let at = 8; at < result.length; at += 4) out.setUint32(at, 0xffffffff, true);
|
|
180
|
+
out.setUint32(12, sortedSurfaces.length === 0 ? 0xffffffff : sortedSurfaces[0]!.walk_slot, true); out.setUint32(16, escaping.length === 0 ? 0xffffffff : escaping[0]!, true); out.setUint32(20, preview === -1 ? 0xffffffff : preview, true);
|
|
181
|
+
for (const o of ordered) if ((nodes[o.walk_slot]!.walk_flags & 1) === 0) { out.setUint32(8, o.walk_slot, true); break; }
|
|
182
|
+
for (let i = 0; i < count; i++) {
|
|
183
|
+
const at = 24 + i * 120, n = nodes[i]!;
|
|
184
|
+
out.setInt32(at, nscvWalkLayer(c, n, false), true); out.setInt32(at + 4, nscvWalkSurfaceLayer(c, i), true);
|
|
185
|
+
let next = -1, first = -1, childCount = 0;
|
|
186
|
+
for (const o of ordered) {
|
|
187
|
+
const child = nodes[o.walk_slot]!;
|
|
188
|
+
if (nscvWalkSameParent(n, child) && nscvWalkCompare(orders[i]!, o) < 0 && next === -1) next = o.walk_slot;
|
|
189
|
+
if ((child.walk_flags & 1) !== 0 && child.walk_parent_high === 0 && child.walk_parent === i) { if (first === -1) first = o.walk_slot; childCount++; }
|
|
190
|
+
}
|
|
191
|
+
out.setUint32(at + 8, next === -1 ? 0xffffffff : next, true); out.setUint32(at + 12, first === -1 ? 0xffffffff : first, true); out.setUint32(at + 24, childCount, true);
|
|
192
|
+
let segment = 0, total = 0, ordinal = 0;
|
|
193
|
+
const parent = nscvWalkParent(c, n);
|
|
194
|
+
if (parent >= 0 && parent < count && nodes[parent]!.walk_kind === 9 && ((flags & 128) !== 0 || nodes[parent]!.walk_gap <= 0)) {
|
|
195
|
+
for (let j = 0; j < count; j++) if (nscvWalkSameParent(n, nodes[j]!) && (nodes[j]!.walk_flags & 4) === 0) { if (j === i) ordinal = total; total++; }
|
|
196
|
+
if (total > 1) segment = ordinal === 0 ? 1 : ordinal === total - 1 ? 3 : 2;
|
|
197
|
+
}
|
|
198
|
+
out.setUint32(at + 28, segment, true); nscvWalkPutLane(out, at + 32, c, i, false); nscvWalkPutLane(out, at + 76, c, i, true);
|
|
199
|
+
}
|
|
200
|
+
for (let i = 0; i < sortedSurfaces.length; i++) out.setUint32(24 + sortedSurfaces[i]!.walk_slot * 120 + 16, i + 1 < sortedSurfaces.length ? sortedSurfaces[i + 1]!.walk_slot : 0xffffffff, true);
|
|
201
|
+
for (let i = 0; i < escaping.length; i++) out.setUint32(24 + escaping[i]! * 120 + 20, i + 1 < escaping.length ? escaping[i + 1]! : 0xffffffff, true);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/** Retained presentation geometry over copied layout and motion facts. */
|
|
2
|
+
interface NscPresentationNode {
|
|
3
|
+
readonly presentation_kind: number; readonly presentation_flags: number;
|
|
4
|
+
readonly presentation_parent: number; readonly presentation_parent_high: number;
|
|
5
|
+
readonly presentation_id: number; readonly presentation_id_high: number;
|
|
6
|
+
readonly presentation_frame: NscSurfaceRect; readonly presentation_transform: NscRenderAffine;
|
|
7
|
+
}
|
|
8
|
+
interface NscPresentationMotion {
|
|
9
|
+
readonly presentation_id: number; readonly presentation_id_high: number;
|
|
10
|
+
readonly presentation_dx: number; readonly presentation_dy: number; readonly presentation_escape: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface NscPresentationContext {
|
|
13
|
+
readonly presentation_nodes: readonly NscPresentationNode[]; readonly presentation_motions: readonly NscPresentationMotion[];
|
|
14
|
+
readonly presentation_numeric: number; readonly presentation_flags: number; readonly presentation_root: NscSurfaceRect | null;
|
|
15
|
+
readonly presentation_drag: number; readonly presentation_drag_high: number;
|
|
16
|
+
readonly presentation_origin_x: number; readonly presentation_origin_y: number;
|
|
17
|
+
readonly presentation_offset_x: number; readonly presentation_offset_y: number; readonly presentation_scale: number;
|
|
18
|
+
}
|
|
19
|
+
function nscvPresentationIdentity(): NscRenderAffine { return { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; }
|
|
20
|
+
function nscvPresentationHoisted(n: NscPresentationNode): boolean { return (n.presentation_flags & 2) !== 0 || n.presentation_kind === 19 || n.presentation_kind === 20 || n.presentation_kind === 21; }
|
|
21
|
+
function nscvPresentationParent(c: NscPresentationContext, n: NscPresentationNode): number {
|
|
22
|
+
return (n.presentation_flags & 1) === 0 ? -1 : n.presentation_parent_high !== 0 || n.presentation_parent >= c.presentation_nodes.length ? c.presentation_nodes.length : n.presentation_parent;
|
|
23
|
+
}
|
|
24
|
+
function nscvPresentationMotion(c: NscPresentationContext, n: NscPresentationNode, preview: boolean): NscPresentationMotion | null {
|
|
25
|
+
if (preview || (n.presentation_id === 0 && n.presentation_id_high === 0)) return null;
|
|
26
|
+
for (const m of c.presentation_motions) if (m.presentation_id === n.presentation_id && m.presentation_id_high === n.presentation_id_high) return m;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function nscvPresentationTransform(c: NscPresentationContext, slot: number, motion: boolean, preview: boolean, outer: NscRenderAffine): NscRenderAffine | null {
|
|
30
|
+
const indices: number[] = [];
|
|
31
|
+
let current = slot;
|
|
32
|
+
while (current !== -1) {
|
|
33
|
+
if (current >= c.presentation_nodes.length || indices.length >= 32) return null;
|
|
34
|
+
indices.push(current);
|
|
35
|
+
const n = c.presentation_nodes[current]!;
|
|
36
|
+
if (nscvPresentationHoisted(n)) break;
|
|
37
|
+
current = nscvPresentationParent(c, n);
|
|
38
|
+
}
|
|
39
|
+
let t = outer;
|
|
40
|
+
for (let i = indices.length - 1; i >= 0; i--) {
|
|
41
|
+
const n = c.presentation_nodes[indices[i]!]!, m = motion ? nscvPresentationMotion(c, n, preview) : null;
|
|
42
|
+
if (m !== null && (m.presentation_dx !== 0 || m.presentation_dy !== 0)) t = nscvRenderMultiply(t, { ...nscvPresentationIdentity(), tx: m.presentation_dx, ty: m.presentation_dy });
|
|
43
|
+
t = nscvRenderMultiply(t, n.presentation_transform);
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
function nscvPresentationAncestor(c: NscPresentationContext, slot: number): NscRenderAffine | null {
|
|
48
|
+
if (slot >= c.presentation_nodes.length) return null;
|
|
49
|
+
const n = c.presentation_nodes[slot]!;
|
|
50
|
+
if (nscvPresentationHoisted(n)) return nscvPresentationIdentity();
|
|
51
|
+
const p = nscvPresentationParent(c, n);
|
|
52
|
+
return p === -1 ? nscvPresentationIdentity() : nscvPresentationTransform(c, p, false, false, nscvPresentationIdentity());
|
|
53
|
+
}
|
|
54
|
+
function nscvPresentationDrag(c: NscPresentationContext): NscRenderAffine | null {
|
|
55
|
+
if ((c.presentation_flags & 2) === 0 || (c.presentation_drag === 0 && c.presentation_drag_high === 0)) return null;
|
|
56
|
+
for (let i = 0; i < c.presentation_nodes.length; i++) {
|
|
57
|
+
const n = c.presentation_nodes[i]!;
|
|
58
|
+
if (n.presentation_id !== c.presentation_drag || n.presentation_id_high !== c.presentation_drag_high) continue;
|
|
59
|
+
const t = nscvPresentationAncestor(c, i); if (t === null) return null;
|
|
60
|
+
const r = nscvSurfaceNormalize(n.presentation_frame), f = Math.fround;
|
|
61
|
+
const x = (c.presentation_flags & 4) !== 0 ? c.presentation_origin_x : r.x, y = (c.presentation_flags & 4) !== 0 ? c.presentation_origin_y : r.y;
|
|
62
|
+
const currentX = f(f(f(t.a * r.x) + f(t.c * r.y)) + t.tx), currentY = f(f(f(t.b * r.x) + f(t.d * r.y)) + t.ty);
|
|
63
|
+
const sourceX = f(f(f(t.a * x) + f(t.c * y)) + t.tx), sourceY = f(f(f(t.b * x) + f(t.d * y)) + t.ty);
|
|
64
|
+
return { ...nscvPresentationIdentity(), tx: f(f(sourceX + c.presentation_offset_x) - currentX), ty: f(f(sourceY + c.presentation_offset_y) - currentY) };
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function nscvPresentationInverse(t: NscRenderAffine): NscRenderAffine | null {
|
|
69
|
+
const f = Math.fround, determinant = f(f(t.a * t.d) - f(t.b * t.c));
|
|
70
|
+
if (Math.abs(determinant) <= Math.fround(0.000001)) return null;
|
|
71
|
+
const inv = f(1 / determinant);
|
|
72
|
+
return { a: f(t.d * inv), b: f(-t.b * inv), c: f(-t.c * inv), d: f(t.a * inv), tx: f(f(f(t.c * t.ty) - f(t.d * t.tx)) * inv), ty: f(f(f(t.b * t.tx) - f(t.a * t.ty)) * inv) };
|
|
73
|
+
}
|
|
74
|
+
function nscvPresentationSnap(c: NscPresentationContext, raw: NscSurfaceRect): NscSurfaceRect {
|
|
75
|
+
const scale = c.presentation_scale;
|
|
76
|
+
if ((c.presentation_flags & 8) === 0 || !Number.isFinite(scale) || scale <= 0) return raw;
|
|
77
|
+
const f = Math.fround, r = nscvSurfaceNormalize(raw);
|
|
78
|
+
const snap = (v: number): number => { const x = f(v * scale); return f((x < 0 || 1 / x < 0 ? -Math.floor(-x + 0.5) : Math.floor(x + 0.5)) / scale); };
|
|
79
|
+
const x = snap(r.x), y = snap(r.y);
|
|
80
|
+
return { x, y, width: nscvRenderExtreme(0, f(snap(nscvSurfaceRight(r)) - x), c.presentation_numeric, true), height: nscvRenderExtreme(0, f(snap(nscvSurfaceBottom(r)) - y), c.presentation_numeric, true) };
|
|
81
|
+
}
|
|
82
|
+
function nscvPresentationVisible(c: NscPresentationContext, slot: number, preview: boolean, outer: NscRenderAffine | null): NscSurfaceRect | null {
|
|
83
|
+
if (c.presentation_root === null || outer === null) return null;
|
|
84
|
+
let visible = nscvSurfaceNormalize(c.presentation_root), current = slot;
|
|
85
|
+
for (let guard = 0; guard <= c.presentation_nodes.length; guard++) {
|
|
86
|
+
const n = c.presentation_nodes[current]!;
|
|
87
|
+
const dragRoot = preview && (c.presentation_flags & 2) !== 0 && c.presentation_drag === n.presentation_id && c.presentation_drag_high === n.presentation_id_high;
|
|
88
|
+
const m = nscvPresentationMotion(c, n, preview);
|
|
89
|
+
if (nscvPresentationHoisted(n) || dragRoot || (m !== null && m.presentation_escape)) break;
|
|
90
|
+
const parent = nscvPresentationParent(c, n);
|
|
91
|
+
if (parent === -1) break;
|
|
92
|
+
if (parent >= c.presentation_nodes.length || guard === c.presentation_nodes.length) return null;
|
|
93
|
+
const p = c.presentation_nodes[parent]!;
|
|
94
|
+
if (p.presentation_kind === 6 || (p.presentation_flags & 4) !== 0) {
|
|
95
|
+
const transform = nscvPresentationTransform(c, parent, true, preview, outer); if (transform === null) return null;
|
|
96
|
+
visible = nscvRenderIntersection(visible, nscvRenderTransform(transform, nscvSurfaceNormalize(p.presentation_frame), c.presentation_numeric), c.presentation_numeric);
|
|
97
|
+
if (nscvRenderEmpty(visible)) return null;
|
|
98
|
+
}
|
|
99
|
+
current = parent;
|
|
100
|
+
}
|
|
101
|
+
const transform = nscvPresentationTransform(c, slot, true, preview, outer); if (transform === null) return null;
|
|
102
|
+
const inverse = nscvPresentationInverse(transform); if (inverse === null) return null;
|
|
103
|
+
const local = nscvRenderTransform(inverse, visible, c.presentation_numeric);
|
|
104
|
+
const clipped = nscvRenderIntersection(nscvSurfaceNormalize(nscvPresentationSnap(c, c.presentation_nodes[slot]!.presentation_frame)), nscvSurfaceNormalize(local), c.presentation_numeric);
|
|
105
|
+
return nscvRenderEmpty(clipped) ? null : clipped;
|
|
106
|
+
}
|
|
107
|
+
function nscvPresentationPutTransform(w: DataView, at: number, t: NscRenderAffine | null): void {
|
|
108
|
+
w.setUint32(at, t === null ? 0 : 1, true);
|
|
109
|
+
nscvRenderPutAffine(w, at + 4, t ?? { a: 0, b: 0, c: 0, d: 0, tx: 0, ty: 0 });
|
|
110
|
+
}
|
|
111
|
+
function nscvWidgetPresentation(request: Uint8Array): Uint8Array {
|
|
112
|
+
if (request.length < 64 || request[1]! > 1 || request[2] !== 1 || request[3]! > 15) throw new Error("invalid presentation header");
|
|
113
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(4, true), motionCount = w.getUint32(8, true), flags = w.getUint32(12, true);
|
|
114
|
+
if (flags > 31 || request.length !== 64 + count * 64 + motionCount * 24 || w.getUint32(60, true) !== 0 || (request[1] === 0 && motionCount !== 0)) throw new Error("invalid presentation shape");
|
|
115
|
+
const nodes: NscPresentationNode[] = [], motions: NscPresentationMotion[] = [];
|
|
116
|
+
for (let i = 0; i < count; i++) {
|
|
117
|
+
const at = 64 + i * 64, kind = w.getUint32(at, true), nodeFlags = w.getUint32(at + 4, true);
|
|
118
|
+
if (kind > 62 || nodeFlags > 15) throw new Error("invalid presentation node");
|
|
119
|
+
nodes.push({ presentation_kind: kind, presentation_flags: nodeFlags, presentation_parent: w.getUint32(at + 8, true), presentation_parent_high: w.getUint32(at + 12, true), presentation_id: w.getUint32(at + 16, true), presentation_id_high: w.getUint32(at + 20, true), presentation_frame: nscvRenderRect(w, at + 24), presentation_transform: nscvRenderAffine(w, at + 40) });
|
|
120
|
+
}
|
|
121
|
+
for (let i = 0; i < motionCount; i++) {
|
|
122
|
+
const at = 64 + count * 64 + i * 24;
|
|
123
|
+
if (w.getUint32(at + 16, true) > 1 || w.getUint32(at + 20, true) !== 0) throw new Error("invalid presentation motion");
|
|
124
|
+
motions.push({ presentation_id: w.getUint32(at, true), presentation_id_high: w.getUint32(at + 4, true), presentation_dx: w.getFloat32(at + 8, true), presentation_dy: w.getFloat32(at + 12, true), presentation_escape: w.getUint32(at + 16, true) === 1 });
|
|
125
|
+
}
|
|
126
|
+
let root: NscSurfaceRect | null = (flags & 1) !== 0 ? nscvSurfaceNormalize(nscvRenderRect(w, 16)) : null;
|
|
127
|
+
if ((flags & 1) === 0) for (const n of nodes) if ((n.presentation_flags & 1) === 0) { const r = nscvSurfaceNormalize(n.presentation_frame); root = root === null ? r : nscvRenderUnion(root, r, request[3]!); }
|
|
128
|
+
const c: NscPresentationContext = { presentation_nodes: nodes, presentation_motions: motions, presentation_numeric: request[3]!, presentation_flags: flags, presentation_root: root, presentation_drag: w.getUint32(32, true), presentation_drag_high: w.getUint32(36, true), presentation_origin_x: w.getFloat32(40, true), presentation_origin_y: w.getFloat32(44, true), presentation_offset_x: w.getFloat32(48, true), presentation_offset_y: w.getFloat32(52, true), presentation_scale: w.getFloat32(56, true) };
|
|
129
|
+
const resultCount = request[1] === 0 ? 0 : count, result = new Uint8Array(56 + resultCount * 152), out = new DataView(result.buffer), drag = request[1] === 0 ? null : nscvPresentationDrag(c), preview = (flags & 16) !== 0;
|
|
130
|
+
result.set([1, request[1]!, 0, 0]); out.setUint32(4, resultCount, true); nscvRenderPutOptional(out, 8, root); nscvPresentationPutTransform(out, 28, drag);
|
|
131
|
+
for (let i = 0; i < resultCount; i++) {
|
|
132
|
+
const at = 56 + i * 152, ordinary = nscvPresentationTransform(c, i, false, false, nscvPresentationIdentity()), outer = preview ? drag : nscvPresentationIdentity();
|
|
133
|
+
nscvPresentationPutTransform(out, at, ordinary); nscvPresentationPutTransform(out, at + 28, nscvPresentationAncestor(c, i));
|
|
134
|
+
nscvPresentationPutTransform(out, at + 56, !preview && motionCount === 0 ? ordinary : outer === null ? null : nscvPresentationTransform(c, i, true, preview, outer));
|
|
135
|
+
nscvPresentationPutTransform(out, at + 84, drag === null ? null : nscvPresentationTransform(c, i, true, true, drag));
|
|
136
|
+
const text = (nodes[i]!.presentation_flags & 8) !== 0;
|
|
137
|
+
nscvRenderPutOptional(out, at + 112, text ? nscvPresentationVisible(c, i, preview, outer) : null);
|
|
138
|
+
nscvRenderPutOptional(out, at + 132, text ? nscvPresentationVisible(c, i, true, drag) : null);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/** Routing over copied, solved widget facts. Identities remain two raw words;
|
|
2
|
+
* this owner chooses hit targets, containment, capture/bubble paths and focus.
|
|
3
|
+
* Scroll range is supplied by the separate portable semantic observation owner.
|
|
4
|
+
* Every geometric operation retains the reference's f32 evaluation order. */
|
|
5
|
+
interface NscRouteNode {
|
|
6
|
+
kind: number; role: number; parent: number; depth: number; lo: number; hi: number;
|
|
7
|
+
flags: number; actions: number; value: number; layer: number;
|
|
8
|
+
frame: NscSurfaceRect; transform: number[];
|
|
9
|
+
}
|
|
10
|
+
interface NscRouteEntry { index: number; phase: number }
|
|
11
|
+
interface NscRouteObservation { routing_observation_slot: number }
|
|
12
|
+
function nscvRouteModal(n: NscRouteNode): boolean { return n.kind >= 19 && n.kind <= 21; }
|
|
13
|
+
function nscvRouteEscapes(n: NscRouteNode): boolean { return (n.flags & 8) !== 0 || nscvRouteModal(n); }
|
|
14
|
+
function nscvRouteClips(n: NscRouteNode): boolean { return n.kind === 6 || (n.flags & 16) !== 0; }
|
|
15
|
+
function nscvRouteLive(n: NscRouteNode): boolean { return (n.lo !== 0 || n.hi !== 0) && (n.flags & 2) === 0; }
|
|
16
|
+
function nscvRouteClaims(n: NscRouteNode): boolean {
|
|
17
|
+
const k = n.kind;
|
|
18
|
+
return nscvRouteLive(n) && ((n.actions & 262) !== 0 || k >= 31 && k <= 39 || k === 41 || k === 42 || k === 44 || k >= 46 && k <= 51 || k === 6 || k === 14 || k === 16 || k >= 19 && k <= 21 || k >= 23 && k <= 25 || k === 58 || k === 62);
|
|
19
|
+
}
|
|
20
|
+
function nscvRouteHit(n: NscRouteNode, hover: boolean): boolean {
|
|
21
|
+
if (!nscvRouteLive(n)) return false;
|
|
22
|
+
if ((n.actions & 262) !== 0 || (n.flags & 64) !== 0 || hover && (n.flags & 32) !== 0) return true;
|
|
23
|
+
const k = n.kind;
|
|
24
|
+
if (k === 56) return (n.flags & 1024) !== 0;
|
|
25
|
+
return k === 6 || k >= 14 && k <= 26 || k >= 31 && k <= 39 || k === 41 || k === 42 || k >= 44 && k <= 52 || k === 58 || k === 62;
|
|
26
|
+
}
|
|
27
|
+
function nscvRouteDefaultFocus(n: NscRouteNode): boolean {
|
|
28
|
+
const k = n.kind;
|
|
29
|
+
return n.role === 25 || k === 6 || k === 14 || k >= 31 && k <= 39 || k === 41 || k === 42 || k === 44 || k >= 46 && k <= 51 || k === 58 || k === 62;
|
|
30
|
+
}
|
|
31
|
+
function nscvRouteContains(r: NscSurfaceRect, x: number, y: number): boolean {
|
|
32
|
+
return !(r.width <= 0 || r.height <= 0) && x >= r.x && y >= r.y && x < Math.fround(r.x + r.width) && y < Math.fround(r.y + r.height);
|
|
33
|
+
}
|
|
34
|
+
function nscvRouteLocal(n: NscRouteNode, x: number, y: number): { x: number; y: number; valid: boolean } {
|
|
35
|
+
const t = n.transform, a = t[0]!, b = t[1]!, c = t[2]!, d = t[3]!, tx = t[4]!, ty = t[5]!, f = Math.fround;
|
|
36
|
+
if (a === 1 && b === 0 && c === 0 && d === 1 && tx === 0 && ty === 0) return { x, y, valid: true };
|
|
37
|
+
const det = f(f(a * d) - f(b * c));
|
|
38
|
+
if (Math.abs(det) <= f(0.000001)) return { x: 0, y: 0, valid: false };
|
|
39
|
+
const inv = f(1 / det);
|
|
40
|
+
return { x: f(f(f(f(d * inv) * x) + f(f(-c * inv) * y)) + f(f(f(c * ty) - f(d * tx)) * inv)),
|
|
41
|
+
y: f(f(f(f(-b * inv) * x) + f(f(a * inv) * y)) + f(f(f(b * tx) - f(a * ty)) * inv)), valid: true };
|
|
42
|
+
}
|
|
43
|
+
function nscvRouteSettled(nodes: NscRouteNode[], index: number): boolean {
|
|
44
|
+
const n = nodes[index]!, f = Math.fround;
|
|
45
|
+
if ((n.flags & 4) === 0 && !(n.value >= 0.5)) return false;
|
|
46
|
+
let bottom = -Infinity, i = index + 1;
|
|
47
|
+
while (i < nodes.length && nodes[i]!.depth > n.depth) {
|
|
48
|
+
const child = nodes[i]!;
|
|
49
|
+
if (!nscvRouteEscapes(child)) bottom = nscvSurfaceMax(bottom, f(child.frame.y + child.frame.height));
|
|
50
|
+
if (nscvRouteEscapes(child) || child.kind === 14) {
|
|
51
|
+
i++; while (i < nodes.length && nodes[i]!.depth > child.depth) i++;
|
|
52
|
+
} else i++;
|
|
53
|
+
}
|
|
54
|
+
return bottom === -Infinity || bottom <= f(f(n.frame.y + n.frame.height) + 0.5);
|
|
55
|
+
}
|
|
56
|
+
function nscvRouteHidden(nodes: NscRouteNode[], index: number): boolean {
|
|
57
|
+
let i = index;
|
|
58
|
+
while (i < nodes.length) { const n = nodes[i]!; if ((n.flags & 1) !== 0) return true; i = n.parent; }
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function nscvRouteConcealed(nodes: NscRouteNode[], index: number): boolean {
|
|
62
|
+
let i = nodes[index]!.parent;
|
|
63
|
+
while (i < nodes.length) { const n = nodes[i]!; if (n.kind === 14 && !nscvRouteSettled(nodes, i)) return true; i = n.parent; }
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
function nscvRouteVisible(nodes: NscRouteNode[], index: number, point: boolean, x: number, y: number): boolean {
|
|
67
|
+
const r = nodes[index]!.frame, f = Math.fround;
|
|
68
|
+
if (!point && (r.width <= 0 || r.height <= 0)) return false;
|
|
69
|
+
let i = index;
|
|
70
|
+
while (i < nodes.length) {
|
|
71
|
+
if (nscvRouteEscapes(nodes[i]!)) return true;
|
|
72
|
+
i = nodes[i]!.parent; if (i >= nodes.length) return true;
|
|
73
|
+
const p = nodes[i]!;
|
|
74
|
+
if (nscvRouteClips(p)) {
|
|
75
|
+
if (point) { if (!nscvRouteContains(p.frame, x, y)) return false; }
|
|
76
|
+
else {
|
|
77
|
+
const a = nscvSurfaceMax(r.x, p.frame.x), b = nscvSurfaceMax(r.y, p.frame.y);
|
|
78
|
+
const c = nscvSurfaceMin(f(r.x + r.width), f(p.frame.x + p.frame.width)), d = nscvSurfaceMin(f(r.y + r.height), f(p.frame.y + p.frame.height));
|
|
79
|
+
if (c <= a || d <= b || f(c - a) <= 0 || f(d - b) <= 0) return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
function nscvRouteLayer(n: NscRouteNode, layers: number[], surface: boolean): number {
|
|
86
|
+
if ((n.flags & 512) !== 0) return n.layer;
|
|
87
|
+
return nscvRouteModal(n) ? layers[2]! : surface && (n.flags & 8) !== 0 || n.kind >= 23 && n.kind <= 25 ? layers[1]! : n.kind === 40 ? layers[3]! : layers[0]!;
|
|
88
|
+
}
|
|
89
|
+
function nscvRouteSurfaceLayer(nodes: NscRouteNode[], index: number, layers: number[]): number {
|
|
90
|
+
const n = nodes[index]!;
|
|
91
|
+
let layer = nscvRouteLayer(n, layers, true), p = n.parent;
|
|
92
|
+
if ((n.flags & 512) !== 0) return layer;
|
|
93
|
+
while (p < nodes.length) { const ancestor = nodes[p]!; if (nscvRouteEscapes(ancestor)) layer = Math.max(layer, nscvRouteLayer(ancestor, layers, true)); p = ancestor.parent; }
|
|
94
|
+
return layer;
|
|
95
|
+
}
|
|
96
|
+
function nscvRouteHitChildren(nodes: NscRouteNode[], parent: number, x: number, y: number, layers: number[], hover: boolean): number {
|
|
97
|
+
const missing = 4294967295;
|
|
98
|
+
let previous = missing, previousLayer = 0;
|
|
99
|
+
for (let tested = 0; tested < nodes.length; tested++) {
|
|
100
|
+
let best = missing, layer = 0;
|
|
101
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
102
|
+
const n = nodes[i]!; if (n.parent !== parent) continue;
|
|
103
|
+
const l = nscvRouteLayer(n, layers, false);
|
|
104
|
+
if (previous !== missing && (l > previousLayer || l === previousLayer && i >= previous)) continue;
|
|
105
|
+
if (best === missing || l > layer || l === layer && i > best) { best = i; layer = l; }
|
|
106
|
+
}
|
|
107
|
+
if (best === missing) return missing;
|
|
108
|
+
previous = best; previousLayer = layer;
|
|
109
|
+
if (!nscvRouteEscapes(nodes[best]!)) { const hit = nscvRouteHitNode(nodes, best, x, y, layers, hover); if (hit !== missing) return hit; }
|
|
110
|
+
}
|
|
111
|
+
return missing;
|
|
112
|
+
}
|
|
113
|
+
function nscvRouteHitNode(nodes: NscRouteNode[], index: number, x: number, y: number, layers: number[], hover: boolean): number {
|
|
114
|
+
const n = nodes[index]!, missing = 4294967295;
|
|
115
|
+
if ((n.flags & 1) !== 0) return missing;
|
|
116
|
+
const p = nscvRouteLocal(n, x, y);
|
|
117
|
+
if (!p.valid || nscvRouteClips(n) && !nscvRouteContains(n.frame, p.x, p.y)) return missing;
|
|
118
|
+
if (n.kind !== 14 || nscvRouteSettled(nodes, index)) { const hit = nscvRouteHitChildren(nodes, index, p.x, p.y, layers, hover); if (hit !== missing) return hit; }
|
|
119
|
+
return nscvRouteHit(n, hover) && nscvRouteContains(n.frame, p.x, p.y) ? index : missing;
|
|
120
|
+
}
|
|
121
|
+
function nscvRouteHitTree(nodes: NscRouteNode[], x: number, y: number, layers: number[], hover: boolean): number {
|
|
122
|
+
const missing = 4294967295;
|
|
123
|
+
let previous = missing, previousLayer = 0;
|
|
124
|
+
for (let tested = 0; tested < nodes.length; tested++) {
|
|
125
|
+
let best = missing, layer = 0;
|
|
126
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
127
|
+
if (!nscvRouteEscapes(nodes[i]!)) continue;
|
|
128
|
+
const l = nscvRouteSurfaceLayer(nodes, i, layers);
|
|
129
|
+
if (previous !== missing && (l > previousLayer || l === previousLayer && i >= previous)) continue;
|
|
130
|
+
if (best === missing || l > layer || l === layer && i > best) { best = i; layer = l; }
|
|
131
|
+
}
|
|
132
|
+
if (best === missing) break;
|
|
133
|
+
previous = best; previousLayer = layer;
|
|
134
|
+
if (nscvRouteHidden(nodes, best) || nscvRouteConcealed(nodes, best)) continue;
|
|
135
|
+
const hit = nscvRouteHitNode(nodes, best, x, y, layers, hover); if (hit !== missing) return hit;
|
|
136
|
+
}
|
|
137
|
+
return nscvRouteHitChildren(nodes, missing, x, y, layers, hover);
|
|
138
|
+
}
|
|
139
|
+
function nscvRoutePress(nodes: NscRouteNode[], index: number): number {
|
|
140
|
+
let i = index; while (i < nodes.length) { if (nscvRouteClaims(nodes[i]!)) return i; i = nodes[i]!.parent; } return 4294967295;
|
|
141
|
+
}
|
|
142
|
+
function nscvRouteFocus(nodes: NscRouteNode[], index: number, logical: boolean, observation: NscRouteObservation): boolean {
|
|
143
|
+
const n = nodes[index]!;
|
|
144
|
+
if (!nscvRouteLive(n) || nscvRouteHidden(nodes, index) || nscvRouteConcealed(nodes, index)) return false;
|
|
145
|
+
if ((n.flags & 128) === 0 && (n.actions & 1) === 0 && !nscvRouteDefaultFocus(n)) {
|
|
146
|
+
// Ask for a semantic observation only at the same eligibility gate as
|
|
147
|
+
// the reference. Native copies that fact, then resumes this query.
|
|
148
|
+
if ((n.flags & 2048) === 0) {
|
|
149
|
+
if (observation.routing_observation_slot === 4294967295) observation.routing_observation_slot = index;
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
if ((n.flags & 256) === 0) return false;
|
|
153
|
+
}
|
|
154
|
+
return logical || nscvRouteVisible(nodes, index, false, 0, 0);
|
|
155
|
+
}
|
|
156
|
+
function nscvRouteGap(a: number, sizeA: number, b: number, sizeB: number): number {
|
|
157
|
+
const f = Math.fround, endA = f(a + sizeA), endB = f(b + sizeB);
|
|
158
|
+
if (nscvSurfaceMin(endA, endB) > nscvSurfaceMax(a, b)) return 0;
|
|
159
|
+
return b >= endA ? f(b - endA) : f(a - endB);
|
|
160
|
+
}
|
|
161
|
+
function nscvRouteSpatial(nodes: NscRouteNode[], current: number, direction: number, observation: NscRouteObservation): number {
|
|
162
|
+
const missing = 4294967295, f = Math.fround;
|
|
163
|
+
if (!nscvRouteFocus(nodes, current, false, observation)) return missing;
|
|
164
|
+
const a = nodes[current]!.frame, ax = f(a.x + f(a.width / 2)), ay = f(a.y + f(a.height / 2));
|
|
165
|
+
let best = missing, bestScore = Infinity;
|
|
166
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
167
|
+
if (i === current || !nscvRouteFocus(nodes, i, false, observation)) continue;
|
|
168
|
+
const b = nodes[i]!.frame;
|
|
169
|
+
if (!(direction === 2 ? f(b.x + b.width) <= ax : direction === 3 ? b.x >= ax : direction === 4 ? f(b.y + b.height) <= ay : b.y >= ay)) continue;
|
|
170
|
+
const bx = f(b.x + f(b.width / 2)), by = f(b.y + f(b.height / 2)), dx = Math.abs(f(bx - ax)), dy = Math.abs(f(by - ay));
|
|
171
|
+
const score = direction === 2 || direction === 3 ? f(f(f(dx * 4096) + f(nscvRouteGap(a.y, a.height, b.y, b.height) * 4096)) + dy) : f(f(f(dy * 4096) + f(nscvRouteGap(a.x, a.width, b.x, b.width) * 4096)) + dx);
|
|
172
|
+
if (score < bestScore || score === bestScore && (best === missing || i < best)) { best = i; bestScore = score; }
|
|
173
|
+
}
|
|
174
|
+
return best;
|
|
175
|
+
}
|
|
176
|
+
function nscvWidgetRouting(request: Uint8Array): Uint8Array {
|
|
177
|
+
if (request.length < 64 || request[0] !== 24 || request[1] !== 1 || request[2]! > 13) throw new Error("invalid widget routing header");
|
|
178
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength), op = request[2]!, param = request[3]!;
|
|
179
|
+
const count = wire.getUint32(4, true), subject = wire.getUint32(8, true), capacity = wire.getUint32(12, true), missing = 4294967295;
|
|
180
|
+
if (request.length !== 64 + count * 96 || (op >= 2 && op <= 5 || op >= 12) && subject !== missing && subject >= count ||
|
|
181
|
+
(op === 6 || op === 10 ? param > 5 : op === 8 ? param > 1 : op === 3 ? param > 7 : param !== 0)) throw new Error("invalid widget routing query");
|
|
182
|
+
if (wire.getUint32(48, true) > 1) throw new Error("invalid routing identity presence");
|
|
183
|
+
for (let at = 52; at < 64; at += 4) if (wire.getUint32(at, true) !== 0) throw new Error("invalid widget routing reserved bytes");
|
|
184
|
+
const nodes: NscRouteNode[] = [], layers: number[] = [];
|
|
185
|
+
for (let i = 0; i < 4; i++) layers.push(wire.getInt32(32 + i * 4, true));
|
|
186
|
+
for (let i = 0; i < count; i++) {
|
|
187
|
+
const at = 64 + i * 96, kind = wire.getUint32(at, true), role = wire.getUint32(at + 4, true), parent = wire.getUint32(at + 8, true), flags = wire.getUint32(at + 24, true), actions = wire.getUint32(at + 28, true);
|
|
188
|
+
// Solved trees are preorder. Requiring an earlier parent also excludes
|
|
189
|
+
// cycles before any recursive or ancestor walk can begin.
|
|
190
|
+
if (kind > 62 || role > 26 || parent !== missing && parent >= i || flags > 4095 || actions > 2047) throw new Error("invalid widget routing node facts");
|
|
191
|
+
for (let r = 80; r < 96; r += 4) if (wire.getUint32(at + r, true) !== 0) throw new Error("invalid widget routing node reserved bytes");
|
|
192
|
+
const transform: number[] = []; for (let t = 0; t < 6; t++) transform.push(wire.getFloat32(at + 56 + t * 4, true));
|
|
193
|
+
nodes.push({ kind, role, parent, depth: wire.getUint32(at + 12, true), lo: wire.getUint32(at + 16, true), hi: wire.getUint32(at + 20, true), flags, actions,
|
|
194
|
+
value: wire.getFloat32(at + 32, true), layer: wire.getInt32(at + 36, true), transform,
|
|
195
|
+
frame: nscvSurfaceNormalize({ x: wire.getFloat32(at + 40, true), y: wire.getFloat32(at + 44, true), width: wire.getFloat32(at + 48, true), height: wire.getFloat32(at + 52, true) }) });
|
|
196
|
+
}
|
|
197
|
+
const lo = wire.getUint32(16, true), hi = wire.getUint32(20, true), x = wire.getFloat32(24, true), y = wire.getFloat32(28, true);
|
|
198
|
+
const lookup = (): number => { if (lo === 0 && hi === 0) return missing; for (let i = 0; i < count; i++) if (nodes[i]!.lo === lo && nodes[i]!.hi === hi) return i; return missing; };
|
|
199
|
+
let target = missing, press = missing, status = 0, keepHit = false;
|
|
200
|
+
const observation: NscRouteObservation = { routing_observation_slot: missing };
|
|
201
|
+
const entries: NscRouteEntry[] = [];
|
|
202
|
+
if (op <= 1) target = nscvRouteHitTree(nodes, x, y, layers, op === 1);
|
|
203
|
+
else if (op === 2) target = nscvRoutePress(nodes, subject);
|
|
204
|
+
else if (op === 3 && subject < count) {
|
|
205
|
+
// Hover receives a typed hit which may carry caller-supplied role,
|
|
206
|
+
// state and geometry. Preserve that complete record when the reference
|
|
207
|
+
// keeps it, rather than reconstructing it from a different node record.
|
|
208
|
+
if ((param & 1) !== 0 && (param & 2) === 0) { target = subject; keepHit = true; }
|
|
209
|
+
else { const claimed = nscvRoutePress(nodes, subject); keepHit = claimed === missing; target = keepHit ? subject : claimed;
|
|
210
|
+
const cell = keepHit ? (param & 4) !== 0 : nodes[target]!.kind === 44;
|
|
211
|
+
if (cell) { let p = nodes[target]!.parent; while (p < count) { if (nodes[p]!.kind === 43) { target = p; keepHit = false; break; } p = nodes[p]!.parent; } }
|
|
212
|
+
}
|
|
213
|
+
} else if (op === 4) {
|
|
214
|
+
const chain: number[] = []; let i = subject;
|
|
215
|
+
while (i < count) { const n = nodes[i]!; if (nscvRouteLive(n) && (n.flags & 32) !== 0 && chain.length < 32) chain.push(i); i = n.parent; }
|
|
216
|
+
for (let c = 0; c < Math.min(chain.length, capacity); c++) entries.push({ index: chain[chain.length - 1 - c]!, phase: 0 });
|
|
217
|
+
} else if (op === 5) {
|
|
218
|
+
let i = subject; while (i < count) { const n = nodes[i]!; if (nscvRouteClaims(n)) break; if (nscvRouteLive(n) && (n.flags & 64) !== 0) { target = i; break; } i = n.parent; }
|
|
219
|
+
} else if (op === 6) {
|
|
220
|
+
if (wire.getUint32(48, true) === 1 && (param === 2 || param === 3 || param === 4)) {
|
|
221
|
+
const i = lookup(); if (i < count && nscvRouteHit(nodes[i]!, false) && !nscvRouteHidden(nodes, i) && !nscvRouteConcealed(nodes, i) && nscvRouteVisible(nodes, i, false, 0, 0)) target = i;
|
|
222
|
+
} else target = nscvRouteHitTree(nodes, x, y, layers, false);
|
|
223
|
+
press = nscvRoutePress(nodes, target);
|
|
224
|
+
} else if (op === 7 || op === 11) { const i = lookup(); if (i < count && nscvRouteFocus(nodes, i, false, observation)) target = i; }
|
|
225
|
+
else if (op === 8 && param === 1) {
|
|
226
|
+
for (let i = count - 1; i >= 0; i--) { const n = nodes[i]!; if (nscvRouteLive(n) && (n.flags & 1) === 0 && (n.actions & 512) !== 0 && !nscvRouteHidden(nodes, i) && !nscvRouteConcealed(nodes, i) && nscvRouteContains(n.frame, x, y) && nscvRouteVisible(nodes, i, true, x, y)) { target = i; break; } }
|
|
227
|
+
} else if (op === 9) {
|
|
228
|
+
let i = lookup(); while (i < count) { const n = nodes[i]!;
|
|
229
|
+
if (nscvRouteLive(n) && (n.flags & 1) === 0 && ((n.actions & 256) !== 0 || n.kind === 16 || n.kind === 58)) { if (!nscvRouteHidden(nodes, i) && !nscvRouteConcealed(nodes, i) && nscvRouteVisible(nodes, i, false, 0, 0)) target = i; break; } i = n.parent;
|
|
230
|
+
}
|
|
231
|
+
} else if (op === 10) {
|
|
232
|
+
const current = lookup();
|
|
233
|
+
if (param >= 2) { if (current < count) target = nscvRouteSpatial(nodes, current, param, observation); }
|
|
234
|
+
else if (param === 0) {
|
|
235
|
+
for (let i = current === missing ? 0 : current + 1; i < count; i++) if (nscvRouteFocus(nodes, i, false, observation)) { target = i; break; }
|
|
236
|
+
if (target === missing) for (let i = 0; i < (current === missing ? count : current); i++) if (nscvRouteFocus(nodes, i, false, observation)) { target = i; break; }
|
|
237
|
+
} else {
|
|
238
|
+
for (let i = (current === missing ? count : current) - 1; i >= 0; i--) if (nscvRouteFocus(nodes, i, false, observation)) { target = i; break; }
|
|
239
|
+
if (target === missing) for (let i = count - 1; i >= (current === missing ? 0 : current + 1); i--) if (nscvRouteFocus(nodes, i, false, observation)) { target = i; break; }
|
|
240
|
+
}
|
|
241
|
+
} else if ((op === 12 || op === 13) && subject < count && nscvRouteFocus(nodes, subject, op === 13, observation)) target = subject;
|
|
242
|
+
if (observation.routing_observation_slot !== missing) {
|
|
243
|
+
const pending = new Uint8Array(24), out = new DataView(pending.buffer);
|
|
244
|
+
pending.set([1, op, 3, 0]); out.setUint32(4, observation.routing_observation_slot, true); out.setUint32(8, missing, true);
|
|
245
|
+
return pending;
|
|
246
|
+
}
|
|
247
|
+
if (op >= 6 && op <= 9 && target < count) {
|
|
248
|
+
const path: number[] = []; let i = target;
|
|
249
|
+
while (i < count) { if (path.length >= 32) { status = 1; break; } path.push(i); i = nodes[i]!.parent; }
|
|
250
|
+
if (status === 0) {
|
|
251
|
+
const route: NscRouteEntry[] = [];
|
|
252
|
+
for (let p = path.length - 1; p > 0; p--) route.push({ index: path[p]!, phase: 0 });
|
|
253
|
+
route.push({ index: target, phase: 1 });
|
|
254
|
+
for (let p = 1; p < path.length; p++) route.push({ index: path[p]!, phase: 2 });
|
|
255
|
+
for (const e of route) { if (entries.length >= capacity) { status = 2; break; } entries.push(e); }
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const result = new Uint8Array(24 + entries.length * 8), out = new DataView(result.buffer);
|
|
259
|
+
result.set([1, op, status, keepHit ? 1 : 0]); out.setUint32(4, target, true); out.setUint32(8, press, true); out.setUint32(12, entries.length, true);
|
|
260
|
+
for (let i = 0; i < entries.length; i++) { out.setUint32(24 + i * 8, entries[i]!.index, true); out.setUint32(28 + i * 8, entries[i]!.phase, true); }
|
|
261
|
+
return result;
|
|
262
|
+
}
|