@native-sdk/cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +1796 -83
- 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/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/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/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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const std = @import("std");
|
|
1
2
|
const geometry = @import("geometry");
|
|
2
3
|
const canvas = @import("canvas");
|
|
3
4
|
const validation = @import("validation.zig");
|
|
@@ -98,6 +99,14 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
98
99
|
return .{
|
|
99
100
|
.nodes = self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
100
101
|
.root_bounds = self.widget_layout_root_bounds,
|
|
102
|
+
.semantic_policy = self.widget_tokens.intrinsic_layout_policy,
|
|
103
|
+
.audit_policy = self.widget_tokens.widget_audit_policy,
|
|
104
|
+
.routing_policy = self.widget_tokens.widget_routing_policy,
|
|
105
|
+
.change_policy = self.widget_tokens.widget_change_policy,
|
|
106
|
+
.text_run_policy = self.widget_tokens.text_run_policy,
|
|
107
|
+
.paint_policy = self.widget_tokens.widget_paint_policy,
|
|
108
|
+
.presentation_policy = self.widget_tokens.widget_presentation_policy,
|
|
109
|
+
.paint_walk_policy = self.widget_tokens.widget_paint_walk_policy,
|
|
101
110
|
};
|
|
102
111
|
}
|
|
103
112
|
|
|
@@ -197,6 +206,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
197
206
|
}
|
|
198
207
|
if (anchored_count > canvas_limits.max_canvas_widget_anchored_per_view) return error.WidgetAnchoredSurfaceLimitReached;
|
|
199
208
|
if (layout.nodes.len > 0 and layout.nodes.ptr == self.widget_layout_nodes[0..].ptr) {
|
|
209
|
+
self.widget_tokens.text_run_policy = layout.text_run_policy orelse self.widget_tokens.text_run_policy;
|
|
200
210
|
self.widget_layout_root_bounds = layout.root_bounds;
|
|
201
211
|
self.widget_revision += 1;
|
|
202
212
|
self.canvas_widget_layout_adoptions +%= 1;
|
|
@@ -262,14 +272,18 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
262
272
|
var focus_return_id: canvas.ObjectId = 0;
|
|
263
273
|
if (self.canvas_widget_focused_id != 0) {
|
|
264
274
|
if (self.canvasWidgetNodeIndexById(self.canvas_widget_focused_id)) |focused_index| {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
275
|
+
if (self.canvas_widget_focus_return_policy) |policy| {
|
|
276
|
+
focus_return_id = compiledCanvasWidgetFocusReturn(self, policy, focused_index, true) orelse 0;
|
|
277
|
+
} else {
|
|
278
|
+
var current: ?usize = self.widget_layout_nodes[focused_index].parent_index;
|
|
279
|
+
while (current) |ancestor_index| {
|
|
280
|
+
const ancestor = self.widget_layout_nodes[ancestor_index].widget;
|
|
281
|
+
if (canvas.widgetIsAnchored(ancestor) and canvasWidgetDismissibleSurfaceKind(ancestor.kind)) {
|
|
282
|
+
focus_return_id = self.canvasWidgetAnchorTriggerFocusId(ancestor_index) orelse 0;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
current = self.widget_layout_nodes[ancestor_index].parent_index;
|
|
271
286
|
}
|
|
272
|
-
current = self.widget_layout_nodes[ancestor_index].parent_index;
|
|
273
287
|
}
|
|
274
288
|
}
|
|
275
289
|
}
|
|
@@ -287,6 +301,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
287
301
|
// the failure's own drain instead of waiting for the next
|
|
288
302
|
// pointer move.
|
|
289
303
|
self.canvas_widget_layout_adoptions +%= 1;
|
|
304
|
+
self.widget_tokens.text_run_policy = layout.text_run_policy orelse self.widget_tokens.text_run_policy;
|
|
290
305
|
errdefer self.pruneCanvasWidgetHoverMsgChain();
|
|
291
306
|
self.widget_layout_node_count = 0;
|
|
292
307
|
self.widget_layout_root_bounds = layout.root_bounds;
|
|
@@ -574,6 +589,18 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
574
589
|
// tooltip intent machine keeps owning tooltip dismissal.
|
|
575
590
|
const surface_index = focused_surface_index orelse
|
|
576
591
|
canvasWidgetTopmostAnchoredSurfaceIndexInScope(self, .interactive) orelse return null;
|
|
592
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
593
|
+
const anchor = if (canvas.widgetIsAnchored(self.widget_layout_nodes[surface_index].widget))
|
|
594
|
+
self.widget_layout_nodes[surface_index].parent_index
|
|
595
|
+
else
|
|
596
|
+
null;
|
|
597
|
+
const facts = @as(u8, @intFromBool(self.canvasWidgetRouteDescendsFromIndex(route, surface_index))) |
|
|
598
|
+
(@as(u8, @intFromBool(canvas.widgetIsAnchored(self.widget_layout_nodes[surface_index].widget))) << 1) |
|
|
599
|
+
(@as(u8, @intFromBool(anchor != null)) << 2) |
|
|
600
|
+
(@as(u8, @intFromBool(if (anchor) |index| self.canvasWidgetRouteDescendsFromIndex(route, index) else false)) << 3);
|
|
601
|
+
if (compiledCanvasSurfaceDismissalAction(policy, 1, facts) == 0) return null;
|
|
602
|
+
return self.dismissCanvasWidgetSurfaceAtIndex(surface_index);
|
|
603
|
+
}
|
|
577
604
|
if (self.canvasWidgetRouteDescendsFromIndex(route, surface_index)) return null;
|
|
578
605
|
// Clicking the ANCHOR region of an anchored surface (the
|
|
579
606
|
// trigger, or the stack that wraps trigger + surface) is the
|
|
@@ -589,6 +616,12 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
589
616
|
}
|
|
590
617
|
|
|
591
618
|
pub fn dismissCanvasWidgetSurfaceAtIndex(self: *RuntimeView, surface_index: usize) anyerror!?CanvasWidgetSurfaceDismissal {
|
|
619
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
620
|
+
const present = surface_index < self.widget_layout_node_count;
|
|
621
|
+
const facts = @as(u8, @intFromBool(present)) |
|
|
622
|
+
(@as(u8, @intFromBool(present and self.widget_layout_nodes[surface_index].widget.semantics.hidden)) << 1);
|
|
623
|
+
if (compiledCanvasSurfaceDismissalAction(policy, 0, facts) == 0) return null;
|
|
624
|
+
}
|
|
592
625
|
if (surface_index >= self.widget_layout_node_count) return null;
|
|
593
626
|
const surface = self.widget_layout_nodes[surface_index].widget;
|
|
594
627
|
if (surface.semantics.hidden) return null;
|
|
@@ -599,42 +632,49 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
599
632
|
// warm window: Escape is a deliberate dismissal, not the
|
|
600
633
|
// pointer moving on to the next trigger.
|
|
601
634
|
if (surface.kind == .tooltip) {
|
|
602
|
-
if (self.
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
self.canvas_widget_focus_visible_id
|
|
623
|
-
|
|
624
|
-
|
|
635
|
+
if (self.applyCompiledCanvasTooltipIntent(.dismissal, surface.id, self.canvas_tooltip_shown_owner_id, false) == null) {
|
|
636
|
+
if (self.canvas_tooltip_shown_id == surface.id) {
|
|
637
|
+
// Covers the focus-shown path too: Escape on the
|
|
638
|
+
// focused trigger clears the reason flag with the
|
|
639
|
+
// slot, and focus (still on the trigger) does not
|
|
640
|
+
// re-reveal — reveals fire only on focus-visible
|
|
641
|
+
// TRANSITIONS, so tabbing away and back re-earns it.
|
|
642
|
+
// The one non-transition reveal — the adoption
|
|
643
|
+
// binding-reconcile, which honors a STANDING
|
|
644
|
+
// keyboard ring when a rebuild swaps the tooltip it
|
|
645
|
+
// owns — is blocked by consuming that standing
|
|
646
|
+
// intent here: when the ring rests on the dismissed
|
|
647
|
+
// tooltip's owner, the dismissal spends
|
|
648
|
+
// `canvas_widget_focus_visible_keyboard` (its only
|
|
649
|
+
// readers are the tooltip reveal gates; the ring
|
|
650
|
+
// itself renders from `canvas_widget_focus_visible_id`
|
|
651
|
+
// and stays painted), so a rebuild that rekeys the
|
|
652
|
+
// tooltip cannot resurrect it one frame after
|
|
653
|
+
// Escape. Same design as the keyboard-activation
|
|
654
|
+
// dismissal seam in canvas_widget_events.zig.
|
|
655
|
+
if (self.canvas_widget_focus_visible_id != 0 and
|
|
656
|
+
self.canvas_widget_focus_visible_id == self.canvas_tooltip_shown_owner_id)
|
|
657
|
+
{
|
|
658
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
659
|
+
}
|
|
660
|
+
self.canvas_tooltip_shown_id = 0;
|
|
661
|
+
self.canvas_tooltip_shown_owner_id = 0;
|
|
662
|
+
self.canvas_tooltip_transit_deadline_ns = 0;
|
|
663
|
+
self.canvas_tooltip_shown_from_focus = false;
|
|
664
|
+
}
|
|
665
|
+
if (self.canvas_tooltip_armed_id == surface.id) {
|
|
666
|
+
self.canvas_tooltip_armed_id = 0;
|
|
667
|
+
self.canvas_tooltip_armed_owner_id = 0;
|
|
668
|
+
self.canvas_tooltip_deadline_ns = 0;
|
|
625
669
|
}
|
|
626
|
-
self.canvas_tooltip_shown_id = 0;
|
|
627
|
-
self.canvas_tooltip_shown_owner_id = 0;
|
|
628
|
-
self.canvas_tooltip_transit_deadline_ns = 0;
|
|
629
|
-
self.canvas_tooltip_shown_from_focus = false;
|
|
630
|
-
}
|
|
631
|
-
if (self.canvas_tooltip_armed_id == surface.id) {
|
|
632
|
-
self.canvas_tooltip_armed_id = 0;
|
|
633
|
-
self.canvas_tooltip_armed_owner_id = 0;
|
|
634
|
-
self.canvas_tooltip_deadline_ns = 0;
|
|
635
670
|
}
|
|
636
671
|
}
|
|
637
|
-
|
|
672
|
+
const focus_descends = self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_focused_id, surface_index);
|
|
673
|
+
const return_focus = if (self.canvas_widget_surface_scope_policy) |policy|
|
|
674
|
+
compiledCanvasSurfaceDismissalAction(policy, 2, @intFromBool(focus_descends)) != 0
|
|
675
|
+
else
|
|
676
|
+
focus_descends;
|
|
677
|
+
if (return_focus) {
|
|
638
678
|
// A dismissal that swallows the focus returns it to the
|
|
639
679
|
// surface's own trigger when the surface is anchored (the
|
|
640
680
|
// Escape-closes-the-picker flow keeps the keyboard on the
|
|
@@ -647,22 +687,48 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
647
687
|
// reveal — here or at a later layout adoption.
|
|
648
688
|
self.canvas_widget_focus_visible_keyboard = false;
|
|
649
689
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
self.
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
690
|
+
// Query the current ring only AFTER focus return. The returned
|
|
691
|
+
// anchor can live outside the hidden surface; an earlier fact
|
|
692
|
+
// would erase its newly returned ring.
|
|
693
|
+
const cleanup_facts = @as(u8, @intFromBool(self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_focus_visible_id, surface_index))) |
|
|
694
|
+
(@as(u8, @intFromBool(self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_hovered_id, surface_index))) << 1) |
|
|
695
|
+
(@as(u8, @intFromBool(self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_pressed_id, surface_index))) << 2);
|
|
696
|
+
const cleanup = if (self.canvas_widget_surface_scope_policy) |policy|
|
|
697
|
+
compiledCanvasSurfaceDismissalAction(policy, 3, cleanup_facts)
|
|
698
|
+
else
|
|
699
|
+
@as(u8, if ((cleanup_facts & 1) != 0) 3 else 0) |
|
|
700
|
+
@as(u8, if ((cleanup_facts & 2) != 0) 12 else 0) |
|
|
701
|
+
@as(u8, if ((cleanup_facts & 4) != 0) 16 else 0);
|
|
702
|
+
if ((cleanup & 1) != 0) self.canvas_widget_focus_visible_id = 0;
|
|
703
|
+
if ((cleanup & 2) != 0) self.canvas_widget_focus_visible_keyboard = false;
|
|
704
|
+
if ((cleanup & 4) != 0) self.canvas_widget_hovered_id = 0;
|
|
705
|
+
if ((cleanup & 8) != 0) self.canvas_widget_cursor = .arrow;
|
|
706
|
+
if ((cleanup & 16) != 0) self.canvas_widget_pressed_id = 0;
|
|
659
707
|
// Hover-Msg listeners inside the dismissed surface owe their
|
|
660
708
|
// leave edge — the surface is gone from under the pointer;
|
|
661
709
|
// listeners outside it keep standing (the wash rule).
|
|
662
710
|
{
|
|
711
|
+
var listener_actions: [canvas.max_widget_depth]u8 = undefined;
|
|
712
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
713
|
+
const count = self.canvas_widget_hover_msg_chain_len;
|
|
714
|
+
var request: [4 + canvas.max_widget_depth]u8 = undefined;
|
|
715
|
+
request[0..2].* = .{ 28, 4 };
|
|
716
|
+
std.mem.writeInt(u16, request[2..4], @intCast(count), .little);
|
|
717
|
+
for (self.canvas_widget_hover_msg_chain[0..count], 0..) |id, index|
|
|
718
|
+
request[4 + index] = @intFromBool(self.canvasWidgetIdDescendsFromIndex(id, surface_index));
|
|
719
|
+
if (policy(request[0 .. 4 + count], listener_actions[0..count]) != count)
|
|
720
|
+
@panic("invalid compiled surface listener result");
|
|
721
|
+
for (listener_actions[0..count]) |action| {
|
|
722
|
+
if (action > 1) @panic("invalid compiled surface listener action");
|
|
723
|
+
}
|
|
724
|
+
}
|
|
663
725
|
var kept: usize = 0;
|
|
664
|
-
for (self.canvas_widget_hover_msg_chain[0..self.canvas_widget_hover_msg_chain_len]) |id| {
|
|
665
|
-
if (self.
|
|
726
|
+
for (self.canvas_widget_hover_msg_chain[0..self.canvas_widget_hover_msg_chain_len], 0..) |id, index| {
|
|
727
|
+
const keep = if (self.canvas_widget_surface_scope_policy != null)
|
|
728
|
+
listener_actions[index] != 0
|
|
729
|
+
else
|
|
730
|
+
!self.canvasWidgetIdDescendsFromIndex(id, surface_index);
|
|
731
|
+
if (!keep) continue;
|
|
666
732
|
self.canvas_widget_hover_msg_chain[kept] = id;
|
|
667
733
|
kept += 1;
|
|
668
734
|
}
|
|
@@ -674,6 +740,14 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
674
740
|
return .{ .id = surface.id, .dirty = dirty };
|
|
675
741
|
}
|
|
676
742
|
|
|
743
|
+
fn compiledCanvasSurfaceDismissalAction(policy: *const fn ([]const u8, []u8) usize, stage: u8, facts: u8) u8 {
|
|
744
|
+
const request = [3]u8{ 28, stage, facts };
|
|
745
|
+
var output: [1]u8 = undefined;
|
|
746
|
+
if (policy(&request, &output) != output.len or output[0] > @as(u8, if (stage == 3) 31 else 1))
|
|
747
|
+
@panic("invalid compiled surface dismissal result");
|
|
748
|
+
return output[0];
|
|
749
|
+
}
|
|
750
|
+
|
|
677
751
|
/// Which anchored dismissible surfaces a lookup means to see. A
|
|
678
752
|
/// widget stack can anchor SEVERAL surfaces at once (a select
|
|
679
753
|
/// trigger with both its dropdown-menu and a tooltip), so every
|
|
@@ -719,6 +793,10 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
719
793
|
/// it to a menu further out.
|
|
720
794
|
fn canvasWidgetSurfaceIndexForTargetInScope(self: *const RuntimeView, target_index: usize, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
721
795
|
if (target_index >= self.widget_layout_node_count) return null;
|
|
796
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
797
|
+
const plan = compiledCanvasWidgetSurfacePlan(self, policy, scope);
|
|
798
|
+
return surfacePlanIndex(&plan, 2 + target_index * 6 + 2);
|
|
799
|
+
}
|
|
722
800
|
var current: ?usize = target_index;
|
|
723
801
|
while (current) |index| {
|
|
724
802
|
if (index >= self.widget_layout_node_count) return null;
|
|
@@ -743,6 +821,11 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
743
821
|
/// out-of-scope sibling mounted later (the tooltip above the
|
|
744
822
|
/// menu) never masks the surface the caller asked for.
|
|
745
823
|
fn canvasWidgetAnchoredChildIndexInScope(self: *const RuntimeView, anchor_index: usize, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
824
|
+
if (anchor_index >= self.widget_layout_node_count) return null;
|
|
825
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
826
|
+
const plan = compiledCanvasWidgetSurfacePlan(self, policy, scope);
|
|
827
|
+
return surfacePlanIndex(&plan, 2 + anchor_index * 6);
|
|
828
|
+
}
|
|
746
829
|
var found: ?usize = null;
|
|
747
830
|
var found_order: ?canvas.WidgetPaintOrder = null;
|
|
748
831
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
@@ -765,6 +848,10 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
765
848
|
/// in the composed select/combobox pattern.
|
|
766
849
|
pub fn canvasWidgetOwnedMenuSurfaceIndex(self: *const RuntimeView, trigger_index: usize) ?usize {
|
|
767
850
|
if (trigger_index >= self.widget_layout_node_count) return null;
|
|
851
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
852
|
+
const plan = compiledCanvasWidgetSurfacePlan(self, policy, .menu);
|
|
853
|
+
return surfacePlanIndex(&plan, 2 + trigger_index * 6 + 4);
|
|
854
|
+
}
|
|
768
855
|
if (canvasWidgetAnchoredMenuChildIndex(self, trigger_index)) |surface_index| return surface_index;
|
|
769
856
|
const parent_index = self.widget_layout_nodes[trigger_index].parent_index orelse return null;
|
|
770
857
|
const surface_index = canvasWidgetAnchoredMenuChildIndex(self, parent_index) orelse return null;
|
|
@@ -782,6 +869,9 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
782
869
|
/// runtime itself stamps non-shown anchored tooltips hidden, and
|
|
783
870
|
/// arming must find them to show them.
|
|
784
871
|
pub fn canvasWidgetOwnedTooltipIndex(self: *const RuntimeView, trigger_index: usize) ?usize {
|
|
872
|
+
if (trigger_index >= self.widget_layout_node_count) return null;
|
|
873
|
+
if (self.canvas_widget_tooltip_policy) |policy|
|
|
874
|
+
return compiledCanvasTooltipBinding(policy, self.widgetLayoutTree(), trigger_index, null, 0, 0);
|
|
785
875
|
return canvasWidgetOwnedTooltipIndexInNodes(self.widget_layout_nodes[0..self.widget_layout_node_count], trigger_index);
|
|
786
876
|
}
|
|
787
877
|
|
|
@@ -832,7 +922,30 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
832
922
|
/// tree stamped visible and cleared registers (an unhideable
|
|
833
923
|
/// tooltip).
|
|
834
924
|
pub fn applyCanvasTooltipVisibilityToNodesForShownId(self: *const RuntimeView, nodes: []canvas.WidgetLayoutNode, shown_id: canvas.ObjectId) void {
|
|
835
|
-
|
|
925
|
+
if (self.canvas_widget_tooltip_policy) |policy| {
|
|
926
|
+
if (nodes.len > max_canvas_widget_nodes_per_view) @panic("tooltip presentation exceeds native view budget");
|
|
927
|
+
var request: [4 + max_canvas_widget_nodes_per_view]u8 = undefined;
|
|
928
|
+
request[0] = 27;
|
|
929
|
+
request[1] = 0;
|
|
930
|
+
std.mem.writeInt(u16, request[2..4], @intCast(nodes.len), .little);
|
|
931
|
+
for (nodes, 0..) |node, index| {
|
|
932
|
+
request[4 + index] = @as(u8, @intFromBool(node.widget.kind == .tooltip)) |
|
|
933
|
+
(@as(u8, @intFromBool(canvas.widgetIsAnchored(node.widget))) << 1) |
|
|
934
|
+
(@as(u8, @intFromBool(node.widget.id != 0)) << 2) |
|
|
935
|
+
(@as(u8, @intFromBool(node.widget.id == shown_id)) << 3);
|
|
936
|
+
}
|
|
937
|
+
var output: [max_canvas_widget_nodes_per_view]u8 = undefined;
|
|
938
|
+
const actions = output[0..nodes.len];
|
|
939
|
+
if (policy(request[0 .. 4 + nodes.len], actions) != actions.len)
|
|
940
|
+
@panic("invalid compiled tooltip presentation result");
|
|
941
|
+
for (actions) |action| {
|
|
942
|
+
if (action > 2) @panic("invalid compiled tooltip visibility action");
|
|
943
|
+
}
|
|
944
|
+
for (nodes, actions) |*node, action| {
|
|
945
|
+
if (action != 0) node.widget.semantics.hidden = action == 2;
|
|
946
|
+
}
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
836
949
|
for (nodes) |*node| {
|
|
837
950
|
if (node.widget.kind != .tooltip) continue;
|
|
838
951
|
if (!canvas.widgetIsAnchored(node.widget)) continue;
|
|
@@ -868,13 +981,30 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
868
981
|
/// leaves both the old tree and the registers that can hide its
|
|
869
982
|
/// tooltip intact.
|
|
870
983
|
pub fn pruneCanvasTooltipIntentForLayout(self: *RuntimeView, layout: canvas.WidgetLayoutTree) void {
|
|
871
|
-
if (self
|
|
984
|
+
if (compiledCanvasTooltipPrune(self, layout, .armed)) |armed| {
|
|
985
|
+
if ((armed & 1) != 0) {
|
|
986
|
+
self.canvas_tooltip_armed_id = 0;
|
|
987
|
+
self.canvas_tooltip_armed_owner_id = 0;
|
|
988
|
+
self.canvas_tooltip_deadline_ns = 0;
|
|
989
|
+
}
|
|
990
|
+
if ((armed & 4) != 0) self.canvas_tooltip_warm_until_ns = 0;
|
|
991
|
+
const shown = compiledCanvasTooltipPrune(self, layout, .shown).?;
|
|
992
|
+
if ((shown & 2) != 0) {
|
|
993
|
+
self.canvas_tooltip_shown_id = 0;
|
|
994
|
+
self.canvas_tooltip_shown_owner_id = 0;
|
|
995
|
+
self.canvas_tooltip_shown_from_focus = false;
|
|
996
|
+
}
|
|
997
|
+
if ((shown & 4) != 0) self.canvas_tooltip_warm_until_ns = 0;
|
|
998
|
+
if ((shown & 8) != 0) self.canvas_tooltip_transit_deadline_ns = 0;
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (self.canvas_tooltip_armed_id != 0 and !canvasTooltipIntentBindingAlive(self, layout, self.canvas_tooltip_armed_id, self.canvas_tooltip_armed_owner_id, false)) {
|
|
872
1002
|
self.canvas_tooltip_armed_id = 0;
|
|
873
1003
|
self.canvas_tooltip_armed_owner_id = 0;
|
|
874
1004
|
self.canvas_tooltip_deadline_ns = 0;
|
|
875
1005
|
self.canvas_tooltip_warm_until_ns = 0;
|
|
876
1006
|
}
|
|
877
|
-
if (self.canvas_tooltip_shown_id != 0 and !canvasTooltipIntentBindingAlive(layout, self.canvas_tooltip_shown_id, self.canvas_tooltip_shown_owner_id, self.canvas_tooltip_shown_from_focus)) {
|
|
1007
|
+
if (self.canvas_tooltip_shown_id != 0 and !canvasTooltipIntentBindingAlive(self, layout, self.canvas_tooltip_shown_id, self.canvas_tooltip_shown_owner_id, self.canvas_tooltip_shown_from_focus)) {
|
|
878
1008
|
self.canvas_tooltip_shown_id = 0;
|
|
879
1009
|
self.canvas_tooltip_shown_owner_id = 0;
|
|
880
1010
|
self.canvas_tooltip_shown_from_focus = false;
|
|
@@ -897,11 +1027,29 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
897
1027
|
/// the OLD tree with the registers that own its stamps: the
|
|
898
1028
|
/// tooltip that is still painted is still hideable.
|
|
899
1029
|
pub fn canvasTooltipShownIdSurvivingLayout(self: *const RuntimeView, layout: canvas.WidgetLayoutTree) canvas.ObjectId {
|
|
1030
|
+
if (compiledCanvasTooltipPrune(self, layout, .shown)) |actions|
|
|
1031
|
+
return if ((actions & 2) != 0) 0 else self.canvas_tooltip_shown_id;
|
|
900
1032
|
if (self.canvas_tooltip_shown_id == 0) return 0;
|
|
901
|
-
if (!canvasTooltipIntentBindingAlive(layout, self.canvas_tooltip_shown_id, self.canvas_tooltip_shown_owner_id, self.canvas_tooltip_shown_from_focus)) return 0;
|
|
1033
|
+
if (!canvasTooltipIntentBindingAlive(self, layout, self.canvas_tooltip_shown_id, self.canvas_tooltip_shown_owner_id, self.canvas_tooltip_shown_from_focus)) return 0;
|
|
902
1034
|
return self.canvas_tooltip_shown_id;
|
|
903
1035
|
}
|
|
904
1036
|
|
|
1037
|
+
const CanvasTooltipPruneSlot = enum(u8) { armed = 1, shown = 2 };
|
|
1038
|
+
|
|
1039
|
+
fn compiledCanvasTooltipPrune(self: *const RuntimeView, layout: canvas.WidgetLayoutTree, slot: CanvasTooltipPruneSlot) ?u8 {
|
|
1040
|
+
const policy = self.canvas_widget_tooltip_policy orelse return null;
|
|
1041
|
+
const id = if (slot == .armed) self.canvas_tooltip_armed_id else self.canvas_tooltip_shown_id;
|
|
1042
|
+
const owner = if (slot == .armed) self.canvas_tooltip_armed_owner_id else self.canvas_tooltip_shown_owner_id;
|
|
1043
|
+
const present = id != 0;
|
|
1044
|
+
const alive = present and canvasTooltipIntentBindingAlive(self, layout, id, owner, slot == .shown and self.canvas_tooltip_shown_from_focus);
|
|
1045
|
+
const facts = @as(u8, @intFromBool(present)) | (@as(u8, @intFromBool(alive)) << 1);
|
|
1046
|
+
const request = [3]u8{ 27, @intFromEnum(slot), facts };
|
|
1047
|
+
var output: [1]u8 = undefined;
|
|
1048
|
+
if (policy(&request, &output) != output.len or (output[0] != 0 and output[0] != @as(u8, if (slot == .armed) 5 else 14)))
|
|
1049
|
+
@panic("invalid compiled tooltip pruning result");
|
|
1050
|
+
return output[0];
|
|
1051
|
+
}
|
|
1052
|
+
|
|
905
1053
|
/// Both ends of a tooltip intent slot are still live: the
|
|
906
1054
|
/// tooltip node exists and is anchored, its recorded owner
|
|
907
1055
|
/// still exists AND still resolves to this very tooltip
|
|
@@ -912,8 +1060,13 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
912
1060
|
/// predicates already reject disabled and hidden widgets, so
|
|
913
1061
|
/// "the trigger can no longer be left" implies "the tooltip
|
|
914
1062
|
/// must not stay".
|
|
915
|
-
fn canvasTooltipIntentBindingAlive(layout: canvas.WidgetLayoutTree, tooltip_id: canvas.ObjectId, owner_id: canvas.ObjectId, from_focus: bool) bool {
|
|
1063
|
+
fn canvasTooltipIntentBindingAlive(self: *const RuntimeView, layout: canvas.WidgetLayoutTree, tooltip_id: canvas.ObjectId, owner_id: canvas.ObjectId, from_focus: bool) bool {
|
|
916
1064
|
const tooltip_index = canvasWidgetNodeIndexByIdInNodes(layout.nodes, tooltip_id) orelse return false;
|
|
1065
|
+
if (self.canvas_widget_tooltip_policy) |policy| {
|
|
1066
|
+
const owner_index = canvasWidgetNodeIndexByIdInNodes(layout.nodes, owner_id) orelse return false;
|
|
1067
|
+
const eligible = if (from_focus) layout.focusTargetById(owner_id) != null else canvasWidgetInteractionTargetExists(layout, owner_id);
|
|
1068
|
+
return compiledCanvasTooltipBinding(policy, layout, owner_index, tooltip_index, if (from_focus) 2 else 1, if (eligible) (if (from_focus) @as(u8, 2) else 1) else 0) != null;
|
|
1069
|
+
}
|
|
917
1070
|
const tooltip_widget = layout.nodes[tooltip_index].widget;
|
|
918
1071
|
if (tooltip_widget.kind != .tooltip or !canvas.widgetIsAnchored(tooltip_widget)) return false;
|
|
919
1072
|
const owner_index = canvasWidgetNodeIndexByIdInNodes(layout.nodes, owner_id) orelse return false;
|
|
@@ -923,6 +1076,97 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
923
1076
|
return canvasWidgetInteractionTargetExists(layout, owner_id);
|
|
924
1077
|
}
|
|
925
1078
|
|
|
1079
|
+
fn compiledCanvasTooltipBinding(
|
|
1080
|
+
policy: *const fn ([]const u8, []u8) usize,
|
|
1081
|
+
layout: canvas.WidgetLayoutTree,
|
|
1082
|
+
owner: usize,
|
|
1083
|
+
tooltip: ?usize,
|
|
1084
|
+
mode: u8,
|
|
1085
|
+
eligibility: u8,
|
|
1086
|
+
) ?usize {
|
|
1087
|
+
if (layout.nodes.len > max_canvas_widget_nodes_per_view) @panic("tooltip policy tree exceeds native view budget");
|
|
1088
|
+
var request: [9 + max_canvas_widget_nodes_per_view * 3]u8 = undefined;
|
|
1089
|
+
request[0] = 23;
|
|
1090
|
+
request[1] = mode;
|
|
1091
|
+
std.mem.writeInt(u16, request[2..4], @intCast(layout.nodes.len), .little);
|
|
1092
|
+
std.mem.writeInt(u16, request[4..6], @intCast(owner), .little);
|
|
1093
|
+
std.mem.writeInt(u16, request[6..8], if (tooltip) |index| @intCast(index) else std.math.maxInt(u16), .little);
|
|
1094
|
+
request[8] = eligibility;
|
|
1095
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1096
|
+
const at = 9 + index * 3;
|
|
1097
|
+
request[at] = @intFromBool(node.widget.kind == .tooltip and canvas.widgetIsAnchored(node.widget));
|
|
1098
|
+
std.mem.writeInt(u16, request[at + 1 ..][0..2], if (node.parent_index) |parent| @intCast(parent) else std.math.maxInt(u16), .little);
|
|
1099
|
+
}
|
|
1100
|
+
var output: [2]u8 = undefined;
|
|
1101
|
+
if (policy(request[0 .. 9 + layout.nodes.len * 3], &output) != output.len)
|
|
1102
|
+
@panic("invalid compiled tooltip policy result");
|
|
1103
|
+
const selected = std.mem.readInt(u16, &output, .little);
|
|
1104
|
+
if (selected == std.math.maxInt(u16)) return null;
|
|
1105
|
+
if (selected >= layout.nodes.len or (mode != 0 and selected != tooltip.?))
|
|
1106
|
+
@panic("invalid compiled tooltip binding index");
|
|
1107
|
+
const widget = layout.nodes[selected].widget;
|
|
1108
|
+
if (widget.kind != .tooltip or !canvas.widgetIsAnchored(widget))
|
|
1109
|
+
@panic("ineligible compiled tooltip binding target");
|
|
1110
|
+
return selected;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
pub const CanvasTooltipIntentCause = enum(u8) {
|
|
1114
|
+
focus,
|
|
1115
|
+
press,
|
|
1116
|
+
activation,
|
|
1117
|
+
programmatic_focus,
|
|
1118
|
+
blur,
|
|
1119
|
+
pointer_close,
|
|
1120
|
+
dismissal,
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
/// Ask the compiled policy for a transition over native facts, then
|
|
1124
|
+
/// apply it to native registers. Null selects the native reference.
|
|
1125
|
+
/// The callback copies its borrowed result without resetting the app
|
|
1126
|
+
/// cycle arena; opaque IDs and nanosecond clocks never cross the wire.
|
|
1127
|
+
pub fn applyCompiledCanvasTooltipIntent(
|
|
1128
|
+
self: *RuntimeView,
|
|
1129
|
+
cause: CanvasTooltipIntentCause,
|
|
1130
|
+
target_id: canvas.ObjectId,
|
|
1131
|
+
owner_id: canvas.ObjectId,
|
|
1132
|
+
reveal_allowed: bool,
|
|
1133
|
+
) ?bool {
|
|
1134
|
+
const policy = self.canvas_widget_tooltip_policy orelse return null;
|
|
1135
|
+
const facts: u8 = @as(u8, @intFromBool(self.canvas_tooltip_shown_id != 0)) |
|
|
1136
|
+
(@as(u8, @intFromBool(self.canvas_tooltip_shown_from_focus)) << 1) |
|
|
1137
|
+
(@as(u8, @intFromBool(target_id != 0)) << 2) |
|
|
1138
|
+
(@as(u8, @intFromBool(self.canvas_tooltip_shown_id == target_id)) << 3) |
|
|
1139
|
+
(@as(u8, @intFromBool(self.canvas_tooltip_armed_id == target_id)) << 4) |
|
|
1140
|
+
(@as(u8, @intFromBool(owner_id != 0 and self.canvas_widget_focus_visible_id == owner_id)) << 5) |
|
|
1141
|
+
(@as(u8, @intFromBool(reveal_allowed)) << 6);
|
|
1142
|
+
const request = [3]u8{ 24, @intFromEnum(cause), facts };
|
|
1143
|
+
var output: [1]u8 = undefined;
|
|
1144
|
+
if (policy(&request, &output) != output.len or output[0] > 127)
|
|
1145
|
+
@panic("invalid compiled tooltip intent result");
|
|
1146
|
+
const flags = output[0];
|
|
1147
|
+
if ((flags & 4) != 0 and (cause != .focus or target_id == 0 or !reveal_allowed))
|
|
1148
|
+
@panic("ineligible compiled tooltip focus reveal");
|
|
1149
|
+
if ((flags & 1) != 0) {
|
|
1150
|
+
self.canvas_tooltip_armed_id = 0;
|
|
1151
|
+
self.canvas_tooltip_armed_owner_id = 0;
|
|
1152
|
+
self.canvas_tooltip_deadline_ns = 0;
|
|
1153
|
+
}
|
|
1154
|
+
if ((flags & 2) != 0) {
|
|
1155
|
+
self.canvas_tooltip_shown_id = 0;
|
|
1156
|
+
self.canvas_tooltip_shown_owner_id = 0;
|
|
1157
|
+
self.canvas_tooltip_shown_from_focus = false;
|
|
1158
|
+
}
|
|
1159
|
+
if ((flags & 4) != 0) {
|
|
1160
|
+
self.canvas_tooltip_shown_id = target_id;
|
|
1161
|
+
self.canvas_tooltip_shown_owner_id = owner_id;
|
|
1162
|
+
self.canvas_tooltip_shown_from_focus = true;
|
|
1163
|
+
}
|
|
1164
|
+
if ((flags & 8) != 0) self.canvas_tooltip_warm_until_ns = 0;
|
|
1165
|
+
if ((flags & 16) != 0) self.canvas_tooltip_transit_deadline_ns = 0;
|
|
1166
|
+
if ((flags & 32) != 0) self.canvas_widget_focus_visible_keyboard = false;
|
|
1167
|
+
return (flags & 64) != 0;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
926
1170
|
/// True while the intent machine needs presented frames to keep
|
|
927
1171
|
/// coming: an armed show delay and a running transit grace both
|
|
928
1172
|
/// fire only on a frame timestamp, so the frame pump
|
|
@@ -937,6 +1181,10 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
937
1181
|
/// focusable row for an ArrowDown entry or the last for ArrowUp —
|
|
938
1182
|
/// the open-menu keymap shared by picker and menu-button triggers.
|
|
939
1183
|
pub fn canvasWidgetMenuSurfaceEntryId(self: *const RuntimeView, surface_index: usize, from_end: bool) ?canvas.ObjectId {
|
|
1184
|
+
if (surface_index < self.widget_layout_node_count and self.widget_layout_nodes[surface_index].widget.interaction_policy != null) {
|
|
1185
|
+
const target = canvas_widget_runtime.canvasWidgetCompiledMenuFocus(self.widgetLayoutTree(), surface_index, if (from_end) 3 else 2) orelse return null;
|
|
1186
|
+
return target.id;
|
|
1187
|
+
}
|
|
940
1188
|
var first: ?canvas.ObjectId = null;
|
|
941
1189
|
var last: ?canvas.ObjectId = null;
|
|
942
1190
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, node_index| {
|
|
@@ -956,6 +1204,8 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
956
1204
|
/// OUTSIDE the surface (the select trigger in the stack pattern).
|
|
957
1205
|
pub fn canvasWidgetAnchorTriggerFocusId(self: *const RuntimeView, surface_index: usize) ?canvas.ObjectId {
|
|
958
1206
|
if (surface_index >= self.widget_layout_node_count) return null;
|
|
1207
|
+
if (self.canvas_widget_focus_return_policy) |policy|
|
|
1208
|
+
return compiledCanvasWidgetFocusReturn(self, policy, surface_index, false);
|
|
959
1209
|
if (!canvas.widgetIsAnchored(self.widget_layout_nodes[surface_index].widget)) return null;
|
|
960
1210
|
const anchor_index = self.widget_layout_nodes[surface_index].parent_index orelse return null;
|
|
961
1211
|
const anchor_id = self.widget_layout_nodes[anchor_index].widget.id;
|
|
@@ -978,6 +1228,10 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
978
1228
|
}
|
|
979
1229
|
|
|
980
1230
|
fn canvasWidgetTopmostAnchoredSurfaceIndexInScope(self: *const RuntimeView, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
1231
|
+
if (self.canvas_widget_surface_scope_policy) |policy| {
|
|
1232
|
+
const plan = compiledCanvasWidgetSurfacePlan(self, policy, scope);
|
|
1233
|
+
return surfacePlanIndex(&plan, 0);
|
|
1234
|
+
}
|
|
981
1235
|
var found: ?usize = null;
|
|
982
1236
|
var found_order: ?canvas.WidgetPaintOrder = null;
|
|
983
1237
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
@@ -1036,6 +1290,9 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
1036
1290
|
current_id: ?canvas.ObjectId,
|
|
1037
1291
|
direction: canvas.WidgetFocusDirection,
|
|
1038
1292
|
) ?canvas.WidgetFocusTarget {
|
|
1293
|
+
if (direction == .forward or direction == .backward) {
|
|
1294
|
+
if (self.canvas_widget_tab_focus_policy) |policy| return compiledCanvasWidgetTabTarget(self, policy, current_id, direction);
|
|
1295
|
+
}
|
|
1039
1296
|
const layout = self.widgetLayoutTree();
|
|
1040
1297
|
const current_scope = if (current_id) |id|
|
|
1041
1298
|
if (self.canvasWidgetNodeIndexById(id)) |index|
|
|
@@ -1088,6 +1345,153 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
1088
1345
|
return null;
|
|
1089
1346
|
}
|
|
1090
1347
|
|
|
1348
|
+
fn compiledCanvasWidgetTabTarget(
|
|
1349
|
+
self: *const RuntimeView,
|
|
1350
|
+
policy: *const fn ([]const u8, []u8) usize,
|
|
1351
|
+
current_id: ?canvas.ObjectId,
|
|
1352
|
+
direction: canvas.WidgetFocusDirection,
|
|
1353
|
+
) ?canvas.WidgetFocusTarget {
|
|
1354
|
+
const layout = self.widgetLayoutTree();
|
|
1355
|
+
var request: [6 + max_canvas_widget_nodes_per_view * 7]u8 = undefined;
|
|
1356
|
+
const absent = std.math.maxInt(u16);
|
|
1357
|
+
const current_index = if (current_id) |id| self.canvasWidgetNodeIndexById(id) else null;
|
|
1358
|
+
request[0] = 20;
|
|
1359
|
+
request[1] = @intFromBool(direction == .backward);
|
|
1360
|
+
std.mem.writeInt(u16, request[2..4], @intCast(layout.nodes.len), .little);
|
|
1361
|
+
std.mem.writeInt(u16, request[4..6], if (current_index) |index| @intCast(index) else absent, .little);
|
|
1362
|
+
// A single surface plan supplies every node's scope. Do not
|
|
1363
|
+
// call the compiled whole-tree policy once for each node.
|
|
1364
|
+
const surface_plan = if (self.canvas_widget_surface_scope_policy) |surface_policy|
|
|
1365
|
+
compiledCanvasWidgetSurfacePlan(self, surface_policy, .interactive)
|
|
1366
|
+
else
|
|
1367
|
+
null;
|
|
1368
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1369
|
+
const at = 6 + index * 7;
|
|
1370
|
+
const visible = layout.focusTargetById(node.widget.id) != null;
|
|
1371
|
+
const logical = layout.logicalFocusTargetAtIndex(index) != null;
|
|
1372
|
+
request[at] = @as(u8, @intFromBool(visible)) |
|
|
1373
|
+
(@as(u8, @intFromBool(logical)) << 1) |
|
|
1374
|
+
(@as(u8, @intFromBool(node.widget.kind == .radio)) << 2) |
|
|
1375
|
+
(@as(u8, @intFromBool(node.widget.kind == .radio_group)) << 3) |
|
|
1376
|
+
(@as(u8, @intFromBool(canvas_widget_runtime.canvasWidgetSelectableSelected(node.widget))) << 4);
|
|
1377
|
+
std.mem.writeInt(u16, request[at + 1 ..][0..2], @intCast(node.depth), .little);
|
|
1378
|
+
std.mem.writeInt(u16, request[at + 3 ..][0..2], if (node.parent_index) |parent| @intCast(parent) else absent, .little);
|
|
1379
|
+
const surface = if (surface_plan) |*plan|
|
|
1380
|
+
surfacePlanIndex(plan, 2 + index * 6 + 2)
|
|
1381
|
+
else
|
|
1382
|
+
canvasWidgetSurfaceIndexForTargetInScope(self, index, .interactive);
|
|
1383
|
+
std.mem.writeInt(u16, request[at + 5 ..][0..2], if (surface) |owner| @intCast(owner) else absent, .little);
|
|
1384
|
+
}
|
|
1385
|
+
var result: [2]u8 = undefined;
|
|
1386
|
+
if (policy(request[0 .. 6 + layout.nodes.len * 7], &result) != result.len) @panic("invalid compiled Tab focus result");
|
|
1387
|
+
const selected = std.mem.readInt(u16, &result, .little);
|
|
1388
|
+
if (selected == absent) return null;
|
|
1389
|
+
if (selected >= layout.nodes.len) @panic("invalid compiled Tab focus index");
|
|
1390
|
+
// A group's logical entry may need native scroll reveal;
|
|
1391
|
+
// every other target must already satisfy visible focus gates.
|
|
1392
|
+
const target = if (layout.nodes[selected].widget.kind == .radio)
|
|
1393
|
+
layout.logicalFocusTargetAtIndex(selected)
|
|
1394
|
+
else
|
|
1395
|
+
layout.focusTargetById(layout.nodes[selected].widget.id);
|
|
1396
|
+
return target orelse @panic("ineligible compiled Tab focus target");
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
const SurfacePlan = [2 + max_canvas_widget_nodes_per_view * 6]u8;
|
|
1400
|
+
|
|
1401
|
+
fn surfacePlanIndex(plan: *const SurfacePlan, at: usize) ?usize {
|
|
1402
|
+
const index = std.mem.readInt(u16, plan[at..][0..2], .little);
|
|
1403
|
+
return if (index == std.math.maxInt(u16)) null else index;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
fn compiledCanvasWidgetSurfacePlan(
|
|
1407
|
+
self: *const RuntimeView,
|
|
1408
|
+
policy: *const fn ([]const u8, []u8) usize,
|
|
1409
|
+
comptime scope: CanvasWidgetAnchoredSurfaceScope,
|
|
1410
|
+
) SurfacePlan {
|
|
1411
|
+
const layout = self.widgetLayoutTree();
|
|
1412
|
+
var request: [4 + max_canvas_widget_nodes_per_view * 7]u8 = undefined;
|
|
1413
|
+
request[0] = 21;
|
|
1414
|
+
request[1] = switch (scope) {
|
|
1415
|
+
.any => 0,
|
|
1416
|
+
.interactive => 1,
|
|
1417
|
+
.menu => 2,
|
|
1418
|
+
};
|
|
1419
|
+
std.mem.writeInt(u16, request[2..4], @intCast(layout.nodes.len), .little);
|
|
1420
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1421
|
+
const at = 4 + index * 7;
|
|
1422
|
+
const kind: u8 = if (!canvasWidgetDismissibleSurfaceKind(node.widget.kind)) 0 else switch (node.widget.kind) {
|
|
1423
|
+
.tooltip => 3,
|
|
1424
|
+
.menu_surface, .dropdown_menu => 2,
|
|
1425
|
+
else => 1,
|
|
1426
|
+
};
|
|
1427
|
+
const anchored = canvas.widgetIsAnchored(node.widget);
|
|
1428
|
+
request[at] = kind | (@as(u8, @intFromBool(node.widget.semantics.hidden)) << 2) |
|
|
1429
|
+
(@as(u8, @intFromBool(anchored)) << 3);
|
|
1430
|
+
std.mem.writeInt(u16, request[at + 1 ..][0..2], if (node.parent_index) |parent| @intCast(parent) else std.math.maxInt(u16), .little);
|
|
1431
|
+
// Only anchored surfaces participate in paint-order
|
|
1432
|
+
// comparisons; ordinary nodes need no ancestor layer walk.
|
|
1433
|
+
const layer = if (kind != 0 and anchored) canvas.widgetLayoutWindowSurfaceOrder(layout, index, self.widget_tokens).layer else 0;
|
|
1434
|
+
std.mem.writeInt(i32, request[at + 3 ..][0..4], layer, .little);
|
|
1435
|
+
}
|
|
1436
|
+
var result: SurfacePlan = undefined;
|
|
1437
|
+
const length = 2 + layout.nodes.len * 6;
|
|
1438
|
+
if (policy(request[0 .. 4 + layout.nodes.len * 7], result[0..length]) != length)
|
|
1439
|
+
@panic("invalid compiled surface scope result");
|
|
1440
|
+
// Every selected index is copied and checked before native
|
|
1441
|
+
// consumers dereference it. No ABI pointer outlives this call.
|
|
1442
|
+
var at: usize = 0;
|
|
1443
|
+
while (at < length) : (at += 2) {
|
|
1444
|
+
if (surfacePlanIndex(&result, at)) |index| {
|
|
1445
|
+
if (index >= layout.nodes.len) @panic("invalid compiled surface scope index");
|
|
1446
|
+
const widget = layout.nodes[index].widget;
|
|
1447
|
+
if (!canvasWidgetAnchoredSurfaceKindInScope(widget.kind, scope) or widget.semantics.hidden)
|
|
1448
|
+
@panic("ineligible compiled surface scope index");
|
|
1449
|
+
if (at == 0 or (at - 2) % 6 != 2) {
|
|
1450
|
+
if (!canvas.widgetIsAnchored(widget)) @panic("unanchored compiled surface scope index");
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return result;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
fn compiledCanvasWidgetFocusReturn(
|
|
1458
|
+
self: *const RuntimeView,
|
|
1459
|
+
policy: *const fn ([]const u8, []u8) usize,
|
|
1460
|
+
subject: usize,
|
|
1461
|
+
from_focused: bool,
|
|
1462
|
+
) ?canvas.ObjectId {
|
|
1463
|
+
const layout = self.widgetLayoutTree();
|
|
1464
|
+
var request: [6 + max_canvas_widget_nodes_per_view * 3]u8 = undefined;
|
|
1465
|
+
request[0] = 22;
|
|
1466
|
+
request[1] = @intFromBool(from_focused);
|
|
1467
|
+
std.mem.writeInt(u16, request[2..4], @intCast(layout.nodes.len), .little);
|
|
1468
|
+
std.mem.writeInt(u16, request[4..6], @intCast(subject), .little);
|
|
1469
|
+
// Reuse the native ID index so facts keep first-match ID
|
|
1470
|
+
// semantics without a full ID scan for every retained node.
|
|
1471
|
+
const Entry = struct { id: canvas.ObjectId, index: usize };
|
|
1472
|
+
var entries: [max_canvas_widget_nodes_per_view]Entry = undefined;
|
|
1473
|
+
for (layout.nodes, 0..) |node, index| entries[index] = .{ .id = node.widget.id, .index = index };
|
|
1474
|
+
var ids: canvas_widget_runtime.CanvasWidgetIdIndex(Entry) = .{};
|
|
1475
|
+
ids.build(entries[0..layout.nodes.len]);
|
|
1476
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1477
|
+
const at = 6 + index * 3;
|
|
1478
|
+
const eligible = if (ids.first(node.widget.id)) |first| layout.focusTargetAtIndex(first.index) != null else false;
|
|
1479
|
+
request[at] = @as(u8, @intFromBool(eligible)) |
|
|
1480
|
+
(@as(u8, @intFromBool(canvas.widgetIsAnchored(node.widget))) << 1) |
|
|
1481
|
+
(@as(u8, @intFromBool(canvasWidgetDismissibleSurfaceKind(node.widget.kind))) << 2);
|
|
1482
|
+
std.mem.writeInt(u16, request[at + 1 ..][0..2], if (node.parent_index) |parent| @intCast(parent) else std.math.maxInt(u16), .little);
|
|
1483
|
+
}
|
|
1484
|
+
var result: [2]u8 = undefined;
|
|
1485
|
+
if (policy(request[0 .. 6 + layout.nodes.len * 3], &result) != result.len)
|
|
1486
|
+
@panic("invalid compiled focus return result");
|
|
1487
|
+
const selected = std.mem.readInt(u16, &result, .little);
|
|
1488
|
+
if (selected == std.math.maxInt(u16)) return null;
|
|
1489
|
+
if (selected >= layout.nodes.len) @panic("invalid compiled focus return index");
|
|
1490
|
+
const id = layout.nodes[selected].widget.id;
|
|
1491
|
+
if (layout.focusTargetById(id) == null) @panic("ineligible compiled focus return target");
|
|
1492
|
+
return id;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1091
1495
|
pub fn canvasWidgetFocusTargetInScope(
|
|
1092
1496
|
self: *const RuntimeView,
|
|
1093
1497
|
surface_index: usize,
|