@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const keyboard_focus = @import("canvas_keyboard_focus_policy.zig");
|
|
1
2
|
const std = @import("std");
|
|
2
3
|
const geometry = @import("geometry");
|
|
3
4
|
const canvas = @import("canvas");
|
|
@@ -224,7 +225,7 @@ pub fn restoreCanvasWidgetLayoutScrollOffsets(
|
|
|
224
225
|
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
225
226
|
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
226
227
|
) void {
|
|
227
|
-
restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(nodes, previous_runtime_offsets, previous_source_offsets, null);
|
|
228
|
+
restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(nodes, previous_runtime_offsets, previous_source_offsets, null, null);
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
fn restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
|
|
@@ -232,14 +233,15 @@ fn restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
|
|
|
232
233
|
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
233
234
|
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
234
235
|
anchored_depth: ?usize,
|
|
236
|
+
strata: ?canvas.layout_coordination_policy.RetainedPlan,
|
|
235
237
|
) void {
|
|
236
238
|
for (nodes, 0..) |node, index| {
|
|
237
239
|
if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
|
|
238
240
|
if (anchored_depth) |depth| {
|
|
239
|
-
if (canvas.anchoredNestingDepth(nodes, index) != depth) continue;
|
|
241
|
+
if ((if (strata) |plan| plan.nesting(index) else canvas.anchoredNestingDepth(nodes, index)) != depth) continue;
|
|
240
242
|
}
|
|
241
243
|
const previous_runtime = canvasWidgetSourceScrollEntryById(previous_runtime_offsets, node.widget.id) orelse continue;
|
|
242
|
-
const previous_source = canvasWidgetSourceScrollEntryById(previous_source_offsets, node.widget.id)
|
|
244
|
+
const previous_source = canvasWidgetSourceScrollEntryById(previous_source_offsets, node.widget.id);
|
|
243
245
|
// Each axis reconciles on its own: a programmatic vertical
|
|
244
246
|
// scroll (source-side `value` change) must not snap a
|
|
245
247
|
// user-scrolled horizontal offset back, and vice versa. Only
|
|
@@ -248,17 +250,15 @@ fn restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
|
|
|
248
250
|
// would translate content that never moved (the clamp pass
|
|
249
251
|
// pins the stale value home instead).
|
|
250
252
|
var restore = geometry.OffsetF{};
|
|
251
|
-
if (canvas.widgetScrollsAxis(node.widget, .vertical) and
|
|
252
|
-
|
|
253
|
-
{
|
|
254
|
-
restore.dy =
|
|
255
|
-
nodes[index].widget.value =
|
|
253
|
+
const next_y = if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 2, .current = node.widget.value, .previous_source = if (previous_source) |entry| entry.value else null, .retained = previous_runtime.value, .granted = canvas.widgetScrollsAxis(node.widget, .vertical) })) |result| result.dx else if (previous_source != null and canvas.widgetScrollsAxis(node.widget, .vertical) and node.widget.value == previous_source.?.value) previous_runtime.value else node.widget.value;
|
|
254
|
+
const next_x = if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 2, .current = node.widget.value_x, .previous_source = if (previous_source) |entry| entry.value_x else null, .retained = previous_runtime.value_x, .granted = canvas.widgetScrollsAxis(node.widget, .horizontal) })) |result| result.dx else if (previous_source != null and canvas.widgetScrollsAxis(node.widget, .horizontal) and node.widget.value_x == previous_source.?.value_x) previous_runtime.value_x else node.widget.value_x;
|
|
255
|
+
if (next_y != node.widget.value) {
|
|
256
|
+
restore.dy = next_y - node.widget.value;
|
|
257
|
+
nodes[index].widget.value = next_y;
|
|
256
258
|
}
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
restore.dx = previous_runtime.value_x - node.widget.value_x;
|
|
261
|
-
nodes[index].widget.value_x = previous_runtime.value_x;
|
|
259
|
+
if (next_x != node.widget.value_x) {
|
|
260
|
+
restore.dx = next_x - node.widget.value_x;
|
|
261
|
+
nodes[index].widget.value_x = next_x;
|
|
262
262
|
}
|
|
263
263
|
if (restore.dx == 0 and restore.dy == 0) continue;
|
|
264
264
|
translateCanvasWidgetLayoutScrollDescendants(nodes, index, .{ .dx = -restore.dx, .dy = -restore.dy });
|
|
@@ -281,12 +281,13 @@ fn clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
|
281
281
|
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
282
282
|
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
283
283
|
anchored_depth: ?usize,
|
|
284
|
+
strata: ?canvas.layout_coordination_policy.RetainedPlan,
|
|
284
285
|
) void {
|
|
285
286
|
for (nodes, 0..) |node, index| {
|
|
286
287
|
if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
|
|
287
288
|
if (node.widget.layout.virtualized and !canvas.widgetVirtualRuntimeScrolled(node.widget)) continue;
|
|
288
289
|
if (anchored_depth) |depth| {
|
|
289
|
-
if (canvas.anchoredNestingDepth(nodes, index) != depth) continue;
|
|
290
|
+
if ((if (strata) |plan| plan.nesting(index) else canvas.anchoredNestingDepth(nodes, index)) != depth) continue;
|
|
290
291
|
}
|
|
291
292
|
|
|
292
293
|
const source_node = source.findById(node.widget.id) orelse continue;
|
|
@@ -299,21 +300,21 @@ fn clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
|
299
300
|
const runtime_echo_x = previous_runtime != null and source_node.widget.value_x == previous_runtime.?.value_x;
|
|
300
301
|
const clamp_y = source_moved_y and !runtime_echo_y;
|
|
301
302
|
const clamp_x = source_moved_x and !runtime_echo_x;
|
|
302
|
-
if (!clamp_y and !clamp_x) continue;
|
|
303
|
+
if (!node.widget.runtime_flags.compiled_scroll_policy and !clamp_y and !clamp_x) continue;
|
|
303
304
|
|
|
304
305
|
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
305
306
|
if (viewport.isEmpty()) continue;
|
|
306
307
|
|
|
307
308
|
const current_y = node.widget.value;
|
|
308
309
|
const current_x = node.widget.value_x;
|
|
309
|
-
const next_y = if (clamp_y)
|
|
310
|
+
const next_y = if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 3, .current = current_y, .viewport = viewport.height, .content = canvasWidgetLayoutScrollContentExtent(nodes, index, viewport), .delta = source_node.widget.value, .previous_source = if (previous_source) |entry| entry.value else null, .retained = if (previous_runtime) |entry| entry.value else null, .granted = canvas.widgetScrollsAxis(node.widget, .vertical) })) |result| result.dx else if (clamp_y)
|
|
310
311
|
if (canvas.widgetScrollsAxis(node.widget, .vertical))
|
|
311
312
|
std.math.clamp(@max(0, current_y), 0, @max(0, canvasWidgetLayoutScrollContentExtent(nodes, index, viewport) - viewport.height))
|
|
312
313
|
else
|
|
313
314
|
0
|
|
314
315
|
else
|
|
315
316
|
current_y;
|
|
316
|
-
const next_x = if (clamp_x)
|
|
317
|
+
const next_x = if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 3, .current = current_x, .viewport = viewport.width, .content = canvasWidgetLayoutScrollContentExtentX(nodes, index, viewport), .delta = source_node.widget.value_x, .previous_source = if (previous_source) |entry| entry.value_x else null, .retained = if (previous_runtime) |entry| entry.value_x else null, .granted = canvas.widgetScrollsAxis(node.widget, .horizontal) })) |result| result.dx else if (clamp_x)
|
|
317
318
|
if (canvas.widgetScrollsAxis(node.widget, .horizontal))
|
|
318
319
|
std.math.clamp(@max(0, current_x), 0, @max(0, canvasWidgetLayoutScrollContentExtentX(nodes, index, viewport) - viewport.width))
|
|
319
320
|
else
|
|
@@ -342,13 +343,13 @@ fn previousLayoutHasSelectedTab(previous: canvas.WidgetLayoutTree, id: canvas.Ob
|
|
|
342
343
|
/// viewport. This runs after retained scroll restoration, against final layout
|
|
343
344
|
/// frames, so an already-visible tab preserves the exact offset and a newly
|
|
344
345
|
/// mounted native scroll driver never paints a speculative leading-edge jump.
|
|
345
|
-
fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode, anchored_depth: ?usize) void {
|
|
346
|
+
fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode, anchored_depth: ?usize, strata: ?canvas.layout_coordination_policy.RetainedPlan) void {
|
|
346
347
|
for (nodes, 0..) |tab_node, tab_index| {
|
|
347
348
|
const tab = tab_node.widget;
|
|
348
349
|
if (tab.semantics.role != .tab or !tab.state.selected) continue;
|
|
349
350
|
if (tab.id != 0 and previousLayoutHasSelectedTab(previous, tab.id)) continue;
|
|
350
351
|
if (anchored_depth) |depth| {
|
|
351
|
-
if (canvas.anchoredNestingDepth(nodes, tab_index) != depth) continue;
|
|
352
|
+
if ((if (strata) |plan| plan.nesting(tab_index) else canvas.anchoredNestingDepth(nodes, tab_index)) != depth) continue;
|
|
352
353
|
}
|
|
353
354
|
|
|
354
355
|
var ancestor = tab_node.parent_index;
|
|
@@ -597,6 +598,17 @@ pub const CanvasWidgetPasteClamp = struct {
|
|
|
597
598
|
};
|
|
598
599
|
|
|
599
600
|
pub fn clampCanvasWidgetPasteText(widget: canvas.Widget, view_text_len: usize, text: []const u8) CanvasWidgetPasteClamp {
|
|
601
|
+
const capacity = @import("canvas_limits.zig").max_canvas_widget_text_bytes_per_view;
|
|
602
|
+
const replaced_len = blk: {
|
|
603
|
+
if (widget.text_composition) |composition| break :blk composition.byteLen(widget.text.len);
|
|
604
|
+
if (canvas.widgetTextSelectionRange(widget)) |range| break :blk range.byteLen(widget.text.len);
|
|
605
|
+
break :blk 0;
|
|
606
|
+
};
|
|
607
|
+
const available = capacity -| (view_text_len -| replaced_len);
|
|
608
|
+
if (widget.interaction_policy != null and (widget.kind == .textarea or canvas.widgetKindSingleLineTextEntry(widget.kind)) and text.len <= capacity) {
|
|
609
|
+
const prepared = canvas.widgetCompiledTextInput(widget, text, 2, null, available) orelse return .{};
|
|
610
|
+
return .{ .text = prepared.text, .truncated = prepared.truncated };
|
|
611
|
+
}
|
|
600
612
|
// Sanitize BEFORE clamping — the shared step for BOTH paste entry
|
|
601
613
|
// points (the cmd+V shortcut and the context-menu Paste). A
|
|
602
614
|
// single-line target strips \r/\n at the edit-derivation seam
|
|
@@ -613,14 +625,6 @@ pub fn clampCanvasWidgetPasteText(widget: canvas.Widget, view_text_len: usize, t
|
|
|
613
625
|
event.insert_text
|
|
614
626
|
else
|
|
615
627
|
return .{};
|
|
616
|
-
const capacity = @import("canvas_limits.zig").max_canvas_widget_text_bytes_per_view;
|
|
617
|
-
const replaced_len = blk: {
|
|
618
|
-
if (widget.text_composition) |composition| break :blk composition.byteLen(widget.text.len);
|
|
619
|
-
if (canvas.widgetTextSelectionRange(widget)) |range| break :blk range.byteLen(widget.text.len);
|
|
620
|
-
break :blk 0;
|
|
621
|
-
};
|
|
622
|
-
const used = view_text_len -| replaced_len;
|
|
623
|
-
const available = capacity -| used;
|
|
624
628
|
if (sanitized.len <= available) return .{ .text = sanitized };
|
|
625
629
|
const clamped = canvas.snapTextOffset(sanitized, available);
|
|
626
630
|
return .{ .text = sanitized[0..clamped], .truncated = true };
|
|
@@ -832,15 +836,14 @@ pub fn canvasWidgetLayoutNodeWithControlReconcileState(
|
|
|
832
836
|
source_entry.selected
|
|
833
837
|
else
|
|
834
838
|
false;
|
|
835
|
-
const selected =
|
|
836
|
-
source_selected
|
|
837
|
-
else
|
|
838
|
-
entry.state.selected or entry.value >= 0.5;
|
|
839
|
+
const selected = canvasWidgetCompiledToggleSelected(copy.widget, 9, previously_selected, entry.state.selected or entry.value >= 0.5) orelse
|
|
840
|
+
if (source_selected or previously_selected) source_selected else entry.state.selected or entry.value >= 0.5;
|
|
839
841
|
copy.widget.state.selected = selected;
|
|
840
842
|
copy.widget.value = if (selected) 1 else 0;
|
|
841
843
|
},
|
|
842
844
|
.checkbox, .switch_control, .toggle => {
|
|
843
|
-
const selected = entry.state.selected or entry.value >= 0.5
|
|
845
|
+
const selected = canvasWidgetCompiledToggleSelected(copy.widget, 10, false, entry.state.selected or entry.value >= 0.5) orelse
|
|
846
|
+
entry.state.selected or entry.value >= 0.5;
|
|
844
847
|
copy.widget.state.selected = selected;
|
|
845
848
|
copy.widget.value = if (selected) 1 else 0;
|
|
846
849
|
},
|
|
@@ -857,10 +860,8 @@ pub fn canvasWidgetLayoutNodeWithControlReconcileState(
|
|
|
857
860
|
const source_selected = canvasWidgetBooleanSelected(copy.widget);
|
|
858
861
|
const previous_source = previous_source_controls.firstWithKind(copy.widget.id, copy.widget.kind);
|
|
859
862
|
const source_moved = if (previous_source) |source_entry| source_selected != source_entry.selected else false;
|
|
860
|
-
const selected = if (
|
|
861
|
-
source_selected
|
|
862
|
-
else
|
|
863
|
-
entry.state.selected or entry.value >= 0.5;
|
|
863
|
+
const selected = canvasWidgetCompiledAccordionSelected(copy.widget, 9, if (previous_source) |source_entry| source_entry.selected else null, entry.state.selected or entry.value >= 0.5) orelse
|
|
864
|
+
if (source_moved) source_selected else entry.state.selected or entry.value >= 0.5;
|
|
864
865
|
copy.widget.state.selected = selected;
|
|
865
866
|
copy.widget.value = if (selected) 1 else 0;
|
|
866
867
|
},
|
|
@@ -878,11 +879,12 @@ pub fn canvasWidgetLayoutNodeWithControlReconcileState(
|
|
|
878
879
|
copy.widget.value != source_entry.value
|
|
879
880
|
else
|
|
880
881
|
false;
|
|
881
|
-
|
|
882
|
-
|
|
882
|
+
copy.widget.value = canvas.widgetCompiledSliderValue(copy.widget, 1, if (previous_source) |source_entry| source_entry.value else null, entry.value, entry.state.pressed) orelse
|
|
883
|
+
std.math.clamp(if (!source_moved or entry.state.pressed) entry.value else copy.widget.value, 0, 1);
|
|
883
884
|
},
|
|
884
885
|
.resizable => {
|
|
885
|
-
const width =
|
|
886
|
+
const width = canvas.widgetCompiledResizableWidth(copy.widget, 1, entry.value, 0) orelse
|
|
887
|
+
@max(canvasWidgetResizableMinWidth(copy.widget), entry.value);
|
|
886
888
|
copy.frame.width = width;
|
|
887
889
|
copy.widget.frame.width = width;
|
|
888
890
|
},
|
|
@@ -948,10 +950,16 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
948
950
|
const next_source_text = canvasWidgetSourceTextFingerprint(copy.widget.text);
|
|
949
951
|
const source_unchanged = entry.source_text_len == next_source_text.len and entry.source_text_hash == next_source_text.hash;
|
|
950
952
|
const source_matches_runtime_text = std.mem.eql(u8, entry.text, copy.widget.text);
|
|
951
|
-
|
|
953
|
+
const reconcile = canvas.widgetCompiledTextReconcile(copy.widget, .{
|
|
954
|
+
.source_unchanged = source_unchanged,
|
|
955
|
+
.source_matches_runtime = source_matches_runtime_text,
|
|
956
|
+
.previous_source_selection = entry.source_text_selection,
|
|
957
|
+
.retained_selection = entry.text_selection,
|
|
958
|
+
}) orelse referenceTextReconcilePolicy(copy.widget, entry, source_unchanged, source_matches_runtime_text);
|
|
959
|
+
if (!reconcile.retain_state) {
|
|
952
960
|
return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
953
961
|
}
|
|
954
|
-
if (
|
|
962
|
+
if (reconcile.retain_text) copy.widget.text = entry.text;
|
|
955
963
|
// The retained scroll offset rides `value` for every editable
|
|
956
964
|
// text kind: the textarea's vertical offset and the single-line
|
|
957
965
|
// field's horizontal one both survive rebuilds through this
|
|
@@ -968,37 +976,34 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
968
976
|
copy.widget.code_content_width_size_bits = entry.code_content_width_size_bits;
|
|
969
977
|
}
|
|
970
978
|
}
|
|
971
|
-
if (
|
|
979
|
+
if (reconcile.retain_selection_composition) {
|
|
972
980
|
copy.widget.text_selection = entry.text_selection;
|
|
973
981
|
copy.widget.text_composition = entry.text_composition;
|
|
974
|
-
} else if (
|
|
975
|
-
|
|
976
|
-
// and C-ABI controlled models historically echo only
|
|
977
|
-
// anchor/focus, so the bridge materializes `.upstream` on
|
|
978
|
-
// every rebuild. When those offsets faithfully echo the
|
|
979
|
-
// retained selection, keep the retained visual-line owner;
|
|
980
|
-
// changing either offset remains the source-authoritative
|
|
981
|
-
// way to move the selection.
|
|
982
|
-
if (entry.text_selection) |retained_selection| {
|
|
983
|
-
if (source_selection.anchor == retained_selection.anchor and
|
|
984
|
-
source_selection.focus == retained_selection.focus)
|
|
985
|
-
{
|
|
986
|
-
const source_affinity_changed = if (entry.source_text_selection) |previous_source_selection|
|
|
987
|
-
source_selection.affinity != previous_source_selection.affinity
|
|
988
|
-
else
|
|
989
|
-
// The legacy shape can only materialize upstream;
|
|
990
|
-
// a first downstream value is therefore explicit.
|
|
991
|
-
source_selection.affinity != .upstream;
|
|
992
|
-
if (!source_affinity_changed) {
|
|
993
|
-
source_selection.affinity = retained_selection.affinity;
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
982
|
+
} else if (reconcile.retain_affinity) {
|
|
983
|
+
copy.widget.text_selection.?.affinity = entry.text_selection.?.affinity;
|
|
997
984
|
}
|
|
998
985
|
}
|
|
999
986
|
return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
1000
987
|
}
|
|
1001
988
|
|
|
989
|
+
fn referenceTextReconcilePolicy(widget: canvas.Widget, entry: *const CanvasWidgetTextReconcileEntry, source_unchanged: bool, source_matches_runtime: bool) canvas.TextReconcilePolicyResult {
|
|
990
|
+
var retain_affinity = false;
|
|
991
|
+
if (widget.text_selection) |source| {
|
|
992
|
+
if (entry.text_selection) |retained| {
|
|
993
|
+
// Byte-identical legacy source echoes carry upstream affinity;
|
|
994
|
+
// preserve the runtime's painted stop unless the source changed it.
|
|
995
|
+
const affinity_changed = if (entry.source_text_selection) |previous| source.affinity != previous.affinity else source.affinity != .upstream;
|
|
996
|
+
retain_affinity = source.anchor == retained.anchor and source.focus == retained.focus and !affinity_changed;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return .{
|
|
1000
|
+
.retain_text = source_unchanged,
|
|
1001
|
+
.retain_state = source_unchanged or source_matches_runtime,
|
|
1002
|
+
.retain_selection_composition = widget.text_selection == null and widget.text_composition == null,
|
|
1003
|
+
.retain_affinity = retain_affinity,
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1002
1007
|
fn canvasWidgetLayoutNodeWithCaretSafeSelection(node: canvas.WidgetLayoutNode) canvas.WidgetLayoutNode {
|
|
1003
1008
|
var copy = node;
|
|
1004
1009
|
if (!canvasWidgetEditableTextKind(copy.widget.kind)) return copy;
|
|
@@ -1076,12 +1081,18 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1076
1081
|
const staged_nodes = node_buffer[0..next.nodes.len];
|
|
1077
1082
|
@memcpy(staged_nodes, next.nodes);
|
|
1078
1083
|
const staged_root_bounds = next.root_bounds orelse if (staged_nodes.len > 0) staged_nodes[0].frame else geometry.RectF.init(0, 0, 0, 0);
|
|
1079
|
-
|
|
1084
|
+
var strata_scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
1085
|
+
const strata = if (tokens.layout_coordination_policy) |policy|
|
|
1086
|
+
canvas.layout_coordination_policy.RetainedPlan.init(strata_scratch.get(), policy, staged_nodes) catch @panic("reconcile strata allocation failed")
|
|
1087
|
+
else
|
|
1088
|
+
null;
|
|
1089
|
+
defer if (strata) |plan| plan.deinit();
|
|
1090
|
+
const max_anchored_depth = if (strata) |plan| plan.maximum() else canvas.maxAnchoredNestingDepth(staged_nodes);
|
|
1080
1091
|
var anchored_depth: usize = 0;
|
|
1081
1092
|
while (anchored_depth <= max_anchored_depth) : (anchored_depth += 1) {
|
|
1082
1093
|
for (staged_nodes, 0..) |node, index| {
|
|
1083
1094
|
if (node.widget.kind != .split or node.widget.id == 0) continue;
|
|
1084
|
-
if (canvas.anchoredNestingDepth(staged_nodes, index) != anchored_depth) continue;
|
|
1095
|
+
if ((if (strata) |plan| plan.nesting(index) else canvas.anchoredNestingDepth(staged_nodes, index)) != anchored_depth) continue;
|
|
1085
1096
|
const tween_armed = objectIdInList(armed_split_tween_ids, node.widget.id);
|
|
1086
1097
|
const previous_runtime = canvasWidgetSourceScrollById(previous_runtime_offsets, node.widget.id) orelse {
|
|
1087
1098
|
// A FRESH split (no retained fraction): a declared enter
|
|
@@ -1090,11 +1101,11 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1090
1101
|
// so the tween armed right after this reconcile eases it in
|
|
1091
1102
|
// instead of the mount popping to its value.
|
|
1092
1103
|
if (node.widget.resize_duration_ms != 0 and node.widget.resize_origin >= 0 and node.widget.children.len != 0) {
|
|
1093
|
-
canvas.
|
|
1104
|
+
canvas.slideSplitChildrenWithTokens(node.frame, node.widget.resize_origin, index, staged_nodes, tokens);
|
|
1094
1105
|
}
|
|
1095
1106
|
continue;
|
|
1096
1107
|
};
|
|
1097
|
-
const previous_source = canvasWidgetSourceScrollById(previous_source_scroll_entries, node.widget.id)
|
|
1108
|
+
const previous_source = canvasWidgetSourceScrollById(previous_source_scroll_entries, node.widget.id);
|
|
1098
1109
|
// Source-wins: the runtime-owned fraction survives rebuilds only
|
|
1099
1110
|
// while the SOURCE fraction is unchanged; a source-side change
|
|
1100
1111
|
// (the model echoing or driving the fraction) wins — UNLESS the
|
|
@@ -1106,10 +1117,17 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1106
1117
|
// frame at a time. Reduced motion still snaps: the tween
|
|
1107
1118
|
// lowering's snap path applies the target through this same
|
|
1108
1119
|
// mutation family in the same rebuild.
|
|
1109
|
-
const source_moved = node.widget.value !=
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1120
|
+
const source_moved = if (previous_source) |source| node.widget.value != source else false;
|
|
1121
|
+
const retained_fraction = canvas.widgetCompiledSplitValue(node.widget, .{
|
|
1122
|
+
.operation = 2,
|
|
1123
|
+
.value = node.widget.value,
|
|
1124
|
+
.previous_source = previous_source,
|
|
1125
|
+
.retained = previous_runtime,
|
|
1126
|
+
.declared_tween = node.widget.resize_duration_ms != 0,
|
|
1127
|
+
.armed_tween = tween_armed,
|
|
1128
|
+
}) orelse if (previous_source == null or (source_moved and node.widget.resize_duration_ms == 0 and !tween_armed)) node.widget.value else previous_runtime;
|
|
1129
|
+
if (node.widget.value == retained_fraction) continue;
|
|
1130
|
+
staged_nodes[index].widget.value = retained_fraction;
|
|
1113
1131
|
// Retained trees clear children; a split without them keeps the
|
|
1114
1132
|
// value restore only (frames follow on the next full layout).
|
|
1115
1133
|
if (node.widget.children.len == 0) continue;
|
|
@@ -1118,7 +1136,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1118
1136
|
// so the slide shape only applies to tween-owned motion.
|
|
1119
1137
|
const dragging = pressed_split_id != 0 and node.widget.id == pressed_split_id;
|
|
1120
1138
|
if (!dragging and (tween_armed or (source_moved and node.widget.resize_duration_ms != 0))) {
|
|
1121
|
-
canvas.
|
|
1139
|
+
canvas.slideSplitChildrenWithTokens(node.frame, retained_fraction, index, staged_nodes, tokens);
|
|
1122
1140
|
} else {
|
|
1123
1141
|
try canvas.relayoutSplitChildren(staged_nodes[index].widget, node.frame, index, node.depth, node_buffer, staged_root_bounds, tokens);
|
|
1124
1142
|
}
|
|
@@ -1134,6 +1152,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1134
1152
|
previous_runtime_offsets,
|
|
1135
1153
|
previous_source_scroll_entries,
|
|
1136
1154
|
anchored_depth,
|
|
1155
|
+
strata,
|
|
1137
1156
|
);
|
|
1138
1157
|
clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
1139
1158
|
staged_nodes,
|
|
@@ -1141,10 +1160,12 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1141
1160
|
previous_runtime_offsets,
|
|
1142
1161
|
previous_source_scroll_entries,
|
|
1143
1162
|
anchored_depth,
|
|
1163
|
+
strata,
|
|
1144
1164
|
);
|
|
1145
|
-
revealNewlySelectedTabs(previous, staged_nodes, anchored_depth);
|
|
1165
|
+
revealNewlySelectedTabs(previous, staged_nodes, anchored_depth, strata);
|
|
1146
1166
|
if (anchored_depth < max_anchored_depth) {
|
|
1147
1167
|
try canvas.relayoutAnchoredChildrenAtDepth(staged_nodes, staged_root_bounds, tokens, anchored_depth);
|
|
1168
|
+
if (strata) |plan| for (staged_nodes, 0..) |node, i| plan.setNode(i, node);
|
|
1148
1169
|
}
|
|
1149
1170
|
}
|
|
1150
1171
|
|
|
@@ -1162,7 +1183,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1162
1183
|
}
|
|
1163
1184
|
const reconciled = node_buffer[0..next.nodes.len];
|
|
1164
1185
|
clampCanvasWidgetLayoutTextOffsets(reconciled, tokens);
|
|
1165
|
-
return .{ .nodes = reconciled, .root_bounds = next.root_bounds };
|
|
1186
|
+
return .{ .nodes = reconciled, .root_bounds = next.root_bounds, .change_policy = next.change_policy, .text_run_policy = next.text_run_policy };
|
|
1166
1187
|
}
|
|
1167
1188
|
|
|
1168
1189
|
pub fn canvasWidgetLayoutNodeWithSourceSemantics(
|
|
@@ -1257,7 +1278,7 @@ fn clampCanvasWidgetLayoutScrollOffsetsImpl(
|
|
|
1257
1278
|
// An offset on an axis the region does not grant pins home: a
|
|
1258
1279
|
// rebuild that flips the axis (or virtualizes the region) must
|
|
1259
1280
|
// not leave content displaced along the revoked axis.
|
|
1260
|
-
const next_offset = if (canvas.widgetScrollsAxis(node.widget, .vertical))
|
|
1281
|
+
const next_offset = if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 0, .current = current_offset, .viewport = viewport.height, .content = content_extent, .granted = canvas.widgetScrollsAxis(node.widget, .vertical) })) |result| result.dx else if (canvas.widgetScrollsAxis(node.widget, .vertical))
|
|
1261
1282
|
std.math.clamp(@max(0, current_offset), 0, max_offset)
|
|
1262
1283
|
else
|
|
1263
1284
|
0;
|
|
@@ -1265,7 +1286,7 @@ fn clampCanvasWidgetLayoutScrollOffsetsImpl(
|
|
|
1265
1286
|
const content_extent_x = canvasWidgetLayoutScrollContentExtentX(nodes, index, viewport);
|
|
1266
1287
|
const max_offset_x = @max(0, content_extent_x - viewport.width);
|
|
1267
1288
|
const current_offset_x = node.widget.value_x;
|
|
1268
|
-
const next_offset_x = if (canvas.widgetScrollsAxis(node.widget, .horizontal))
|
|
1289
|
+
const next_offset_x = if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 0, .current = current_offset_x, .viewport = viewport.width, .content = content_extent_x, .granted = canvas.widgetScrollsAxis(node.widget, .horizontal) })) |result| result.dx else if (canvas.widgetScrollsAxis(node.widget, .horizontal))
|
|
1269
1290
|
std.math.clamp(@max(0, current_offset_x), 0, max_offset_x)
|
|
1270
1291
|
else
|
|
1271
1292
|
0;
|
|
@@ -1555,6 +1576,15 @@ pub fn canvasWidgetSpatialFocusAllowed(layout: canvas.WidgetLayoutTree, focused:
|
|
|
1555
1576
|
};
|
|
1556
1577
|
}
|
|
1557
1578
|
|
|
1579
|
+
pub fn canvasWidgetSpatialFocusAllowedWithPolicy(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, target: canvas.WidgetFocusTarget, direction: canvas.WidgetFocusDirection, policy: keyboard_focus.Policy) bool {
|
|
1580
|
+
const focused_scope = canvasWidgetRadioGroupScopeIndex(layout, focused.index);
|
|
1581
|
+
const target_scope = canvasWidgetRadioGroupScopeIndex(layout, target.index);
|
|
1582
|
+
const facts: u16 = @as(u16, if (canvasWidgetFocusTargetsShareParent(layout, focused, target)) 1 else 0) |
|
|
1583
|
+
@as(u16, if (focused_scope != null) 2 else 0) | @as(u16, if (target_scope != null) 4 else 0) |
|
|
1584
|
+
@as(u16, if (focused_scope != null and focused_scope == target_scope) 8 else 0);
|
|
1585
|
+
return keyboard_focus.decide(policy, .{ .stage = .spatial, .a = keyboard_focus.directionCode(direction), .kind = focused.kind, .target = target.kind, .parent = canvasWidgetFocusParentKind(layout, focused), .facts = facts }) != 0;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1558
1588
|
pub fn canvasWidgetFocusTargetsShareParent(layout: canvas.WidgetLayoutTree, a: canvas.WidgetFocusTarget, b: canvas.WidgetFocusTarget) bool {
|
|
1559
1589
|
if (a.index >= layout.nodes.len or b.index >= layout.nodes.len) return false;
|
|
1560
1590
|
return layout.nodes[a.index].parent_index == layout.nodes[b.index].parent_index;
|
|
@@ -1597,12 +1627,30 @@ pub const CanvasWidgetGroupDirection = enum {
|
|
|
1597
1627
|
};
|
|
1598
1628
|
|
|
1599
1629
|
pub fn canvasWidgetGroupDirectionalFocusTarget(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, direction: canvas.WidgetFocusDirection) ?canvas.WidgetFocusTarget {
|
|
1630
|
+
return canvasWidgetGroupDirectionalFocusTargetWithPolicy(layout, focused, direction, null);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
pub fn canvasWidgetGroupDirectionalFocusTargetWithPolicy(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, direction: canvas.WidgetFocusDirection, policy: keyboard_focus.Policy) ?canvas.WidgetFocusTarget {
|
|
1600
1634
|
if (canvasWidgetRadioGroupDirectionalFocusTarget(layout, focused, direction)) |target| return target;
|
|
1601
1635
|
if (focused.index >= layout.nodes.len) return null;
|
|
1602
1636
|
const parent_index = layout.nodes[focused.index].parent_index orelse return null;
|
|
1603
1637
|
if (parent_index >= layout.nodes.len) return null;
|
|
1604
1638
|
const parent_kind = layout.nodes[parent_index].widget.kind;
|
|
1605
|
-
const
|
|
1639
|
+
const decision = keyboard_focus.decide(policy, .{ .stage = .group, .a = keyboard_focus.directionCode(direction), .kind = focused.kind, .parent = parent_kind });
|
|
1640
|
+
const group_direction: CanvasWidgetGroupDirection = switch (decision) {
|
|
1641
|
+
1 => .previous,
|
|
1642
|
+
2 => .next,
|
|
1643
|
+
else => return null,
|
|
1644
|
+
};
|
|
1645
|
+
if (parent_kind == .tabs and focused.kind == .segmented_control and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
1646
|
+
return compiledTabsFocus(layout, focused.index, if (group_direction == .previous) 4 else 5);
|
|
1647
|
+
if (parent_kind == .list and focused.kind == .list_item and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
1648
|
+
return compiledListFocus(layout, focused.index, if (group_direction == .previous) 4 else 5);
|
|
1649
|
+
if ((parent_kind == .menu_surface or parent_kind == .dropdown_menu) and focused.kind == .menu_item and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
1650
|
+
return canvasWidgetCompiledMenuFocus(layout, focused.index, if (group_direction == .previous) 4 else 5);
|
|
1651
|
+
if (parent_kind == .toggle_group and focused.kind == .toggle_button and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
1652
|
+
return canvasWidgetCompiledToggleFocus(layout, focused.index, if (group_direction == .previous) 4 else 5);
|
|
1653
|
+
if (policy != null) return canvasWidgetCompiledGroupFocus(layout, focused, if (group_direction == .previous) 0 else 1, policy.?) orelse focused;
|
|
1606
1654
|
return canvasWidgetAdjacentGroupFocusTarget(layout, parent_index, focused, group_direction) orelse focused;
|
|
1607
1655
|
}
|
|
1608
1656
|
|
|
@@ -1639,10 +1687,216 @@ pub fn canvasWidgetGroupDirectionForFocus(parent_kind: canvas.WidgetKind, child_
|
|
|
1639
1687
|
// logical targets intentionally omit only scroll clipping so keyboard
|
|
1640
1688
|
// focus can reveal an offscreen radio before committing to it.
|
|
1641
1689
|
|
|
1690
|
+
/// Retained geometry is native; selection scope and traversal are portable.
|
|
1691
|
+
/// Wire v1 uses preorder indices rather than ids (ids can exceed JS integers).
|
|
1692
|
+
pub fn canvasWidgetRadioPolicy(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8, output: []u8) ?usize {
|
|
1693
|
+
if (subject >= layout.nodes.len) return null;
|
|
1694
|
+
const policy = layout.nodes[subject].widget.interaction_policy orelse return null;
|
|
1695
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("radio policy tree exceeds native view budget");
|
|
1696
|
+
var request: [5 + canvas_limits.max_canvas_widget_nodes_per_view * 4]u8 = undefined;
|
|
1697
|
+
request[0] = operation;
|
|
1698
|
+
std.mem.writeInt(u16, request[1..3], @intCast(subject), .little);
|
|
1699
|
+
std.mem.writeInt(u16, request[3..5], @intCast(layout.nodes.len), .little);
|
|
1700
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1701
|
+
const at = 5 + index * 4;
|
|
1702
|
+
std.mem.writeInt(u16, request[at..][0..2], if (node.parent_index) |parent| @intCast(parent) else 65535, .little);
|
|
1703
|
+
request[at + 2] = switch (node.widget.kind) {
|
|
1704
|
+
.radio => 1,
|
|
1705
|
+
.radio_group => 2,
|
|
1706
|
+
else => 0,
|
|
1707
|
+
};
|
|
1708
|
+
request[at + 3] = @as(u8, if (operation != 0 and operation != 8 and node.widget.kind == .radio and layout.logicalFocusTargetAtIndex(index) != null) 1 else 0) |
|
|
1709
|
+
@as(u8, if ((operation == 2 or operation == 3) and node.widget.kind == .radio and layout.focusTargetById(node.widget.id) != null) 2 else 0) |
|
|
1710
|
+
@as(u8, if (canvasWidgetSelectableSelected(node.widget)) 4 else 0);
|
|
1711
|
+
}
|
|
1712
|
+
return policy(request[0 .. 5 + layout.nodes.len * 4], output);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
pub fn canvasWidgetTabsPolicy(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8, output: []u8) ?usize {
|
|
1716
|
+
if (subject >= layout.nodes.len) return null;
|
|
1717
|
+
const policy = layout.nodes[subject].widget.interaction_policy orelse return null;
|
|
1718
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("tabs policy tree exceeds native view budget");
|
|
1719
|
+
var request: [5 + canvas_limits.max_canvas_widget_nodes_per_view * 4]u8 = undefined;
|
|
1720
|
+
request[0] = operation;
|
|
1721
|
+
std.mem.writeInt(u16, request[1..3], @intCast(subject), .little);
|
|
1722
|
+
std.mem.writeInt(u16, request[3..5], @intCast(layout.nodes.len), .little);
|
|
1723
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1724
|
+
const at = 5 + index * 4;
|
|
1725
|
+
std.mem.writeInt(u16, request[at..][0..2], if (node.parent_index) |parent| @intCast(parent) else 65535, .little);
|
|
1726
|
+
request[at + 2] = switch (node.widget.kind) {
|
|
1727
|
+
.segmented_control => 1,
|
|
1728
|
+
.tabs => 2,
|
|
1729
|
+
else => 0,
|
|
1730
|
+
};
|
|
1731
|
+
request[at + 3] = @as(u8, if (operation != 0 and operation != 8 and node.widget.kind == .segmented_control and layout.focusTargetById(node.widget.id) != null) 2 else 0) |
|
|
1732
|
+
@as(u8, if (canvasWidgetSelectableSelected(node.widget)) 4 else 0);
|
|
1733
|
+
}
|
|
1734
|
+
return policy(request[0 .. 5 + layout.nodes.len * 4], output);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
fn compiledTabsFocus(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?canvas.WidgetFocusTarget {
|
|
1738
|
+
var output: [2]u8 = undefined;
|
|
1739
|
+
const len = canvasWidgetTabsPolicy(layout, subject, operation, &output) orelse return null;
|
|
1740
|
+
if (len != 2) @panic("invalid tabs policy target");
|
|
1741
|
+
const index = std.mem.readInt(u16, &output, .little);
|
|
1742
|
+
if (index == 65535) return null;
|
|
1743
|
+
if (index >= layout.nodes.len) @panic("tabs policy target outside tree");
|
|
1744
|
+
return layout.focusTargetById(layout.nodes[index].widget.id);
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/// Direct-sibling list policy receives both logical and visible eligibility:
|
|
1748
|
+
/// arrows admit scroll-clipped rows; Home/End preserves visible-only edges.
|
|
1749
|
+
pub fn canvasWidgetListPolicy(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8, output: []u8) ?usize {
|
|
1750
|
+
if (subject >= layout.nodes.len) return null;
|
|
1751
|
+
const policy = layout.nodes[subject].widget.interaction_policy orelse return null;
|
|
1752
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("list policy tree exceeds native view budget");
|
|
1753
|
+
var request: [5 + canvas_limits.max_canvas_widget_nodes_per_view * 4]u8 = undefined;
|
|
1754
|
+
request[0] = operation;
|
|
1755
|
+
std.mem.writeInt(u16, request[1..3], @intCast(subject), .little);
|
|
1756
|
+
std.mem.writeInt(u16, request[3..5], @intCast(layout.nodes.len), .little);
|
|
1757
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1758
|
+
const at = 5 + index * 4;
|
|
1759
|
+
std.mem.writeInt(u16, request[at..][0..2], if (node.parent_index) |parent| @intCast(parent) else 65535, .little);
|
|
1760
|
+
request[at + 2] = switch (node.widget.kind) {
|
|
1761
|
+
.list_item => 1,
|
|
1762
|
+
.list => 2,
|
|
1763
|
+
else => 0,
|
|
1764
|
+
};
|
|
1765
|
+
request[at + 3] = @as(u8, if ((operation == 4 or operation == 5) and node.widget.kind == .list_item and layout.logicalFocusTargetAtIndex(index) != null) 1 else 0) |
|
|
1766
|
+
@as(u8, if ((operation == 6 or operation == 7) and node.widget.kind == .list_item and layout.focusTargetById(node.widget.id) != null) 2 else 0) |
|
|
1767
|
+
@as(u8, if (canvasWidgetSelectableSelected(node.widget)) 4 else 0);
|
|
1768
|
+
}
|
|
1769
|
+
return policy(request[0 .. 5 + layout.nodes.len * 4], output);
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
fn compiledListFocus(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?canvas.WidgetFocusTarget {
|
|
1773
|
+
var output: [2]u8 = undefined;
|
|
1774
|
+
const len = canvasWidgetListPolicy(layout, subject, operation, &output) orelse return null;
|
|
1775
|
+
if (len != 2) @panic("invalid list policy target");
|
|
1776
|
+
const index = std.mem.readInt(u16, &output, .little);
|
|
1777
|
+
if (index == 65535) return null;
|
|
1778
|
+
if (index >= layout.nodes.len) @panic("list policy target outside tree");
|
|
1779
|
+
return if (operation == 4 or operation == 5) layout.logicalFocusTargetAtIndex(index) else layout.focusTargetById(layout.nodes[index].widget.id);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
/// Geometry and eligibility remain native. The compiled menu policy chooses
|
|
1783
|
+
/// entry, traversal and committed-choice selection from the retained tree.
|
|
1784
|
+
pub fn canvasWidgetMenuPolicy(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8, output: []u8) ?usize {
|
|
1785
|
+
if (subject >= layout.nodes.len) return null;
|
|
1786
|
+
const policy = layout.nodes[subject].widget.interaction_policy orelse return null;
|
|
1787
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("menu policy tree exceeds native view budget");
|
|
1788
|
+
var request: [5 + canvas_limits.max_canvas_widget_nodes_per_view * 4]u8 = undefined;
|
|
1789
|
+
request[0] = operation;
|
|
1790
|
+
std.mem.writeInt(u16, request[1..3], @intCast(subject), .little);
|
|
1791
|
+
std.mem.writeInt(u16, request[3..5], @intCast(layout.nodes.len), .little);
|
|
1792
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1793
|
+
const at = 5 + index * 4;
|
|
1794
|
+
std.mem.writeInt(u16, request[at..][0..2], if (node.parent_index) |parent| @intCast(parent) else 65535, .little);
|
|
1795
|
+
const item = node.widget.kind == .menu_item or node.widget.kind == .list_item;
|
|
1796
|
+
request[at + 2] = switch (node.widget.kind) {
|
|
1797
|
+
.menu_item => 1,
|
|
1798
|
+
.menu_surface, .dropdown_menu => 2,
|
|
1799
|
+
.list_item => 3,
|
|
1800
|
+
else => 0,
|
|
1801
|
+
};
|
|
1802
|
+
request[at + 3] = @as(u8, if (operation != 8 and item and layout.focusTargetById(node.widget.id) != null) 2 else 0) |
|
|
1803
|
+
@as(u8, if (canvasWidgetSelectableSelected(node.widget)) 4 else 0) |
|
|
1804
|
+
@as(u8, if (node.widget.state.selected) 8 else 0);
|
|
1805
|
+
}
|
|
1806
|
+
return policy(request[0 .. 5 + layout.nodes.len * 4], output);
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
/// Toggle transitions and source/retained reconciliation run without a tree
|
|
1810
|
+
/// scan. The native caller applies the returned selected state and value.
|
|
1811
|
+
pub fn canvasWidgetCompiledToggleSelected(widget: canvas.Widget, operation: u8, previously_selected: bool, retained_selected: bool) ?bool {
|
|
1812
|
+
if (widget.kind != .toggle_button and widget.kind != .checkbox and widget.kind != .switch_control and widget.kind != .toggle) return null;
|
|
1813
|
+
const policy = widget.interaction_policy orelse return null;
|
|
1814
|
+
const request = [_]u8{
|
|
1815
|
+
operation,
|
|
1816
|
+
@as(u8, if (canvasWidgetBooleanSelected(widget)) 1 else 0) |
|
|
1817
|
+
@as(u8, if (previously_selected) 2 else 0) |
|
|
1818
|
+
@as(u8, if (retained_selected) 4 else 0),
|
|
1819
|
+
};
|
|
1820
|
+
var output: [1]u8 = undefined;
|
|
1821
|
+
const len = policy(&request, &output);
|
|
1822
|
+
if (len != 1 or output[0] > 1) @panic("invalid toggle state policy result");
|
|
1823
|
+
return output[0] == 1;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
pub fn canvasWidgetCompiledAccordionSelected(widget: canvas.Widget, operation: u8, previous_source: ?bool, retained_selected: bool) ?bool {
|
|
1827
|
+
if (widget.kind != .accordion) return null;
|
|
1828
|
+
const policy = widget.interaction_policy orelse return null;
|
|
1829
|
+
const request = [_]u8{
|
|
1830
|
+
operation,
|
|
1831
|
+
@as(u8, if (canvasWidgetBooleanSelected(widget)) 1 else 0) |
|
|
1832
|
+
@as(u8, if (previous_source orelse false) 2 else 0) |
|
|
1833
|
+
@as(u8, if (retained_selected) 4 else 0) |
|
|
1834
|
+
@as(u8, if (previous_source != null) 8 else 0),
|
|
1835
|
+
};
|
|
1836
|
+
var output: [1]u8 = undefined;
|
|
1837
|
+
const len = policy(&request, &output);
|
|
1838
|
+
if (len != 1 or output[0] > 1) @panic("invalid accordion state policy result");
|
|
1839
|
+
return output[0] == 1;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
pub fn canvasWidgetCompiledToggleFocus(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?canvas.WidgetFocusTarget {
|
|
1843
|
+
if (subject >= layout.nodes.len) return null;
|
|
1844
|
+
const policy = layout.nodes[subject].widget.interaction_policy orelse return null;
|
|
1845
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("toggle policy tree exceeds native view budget");
|
|
1846
|
+
var request: [5 + canvas_limits.max_canvas_widget_nodes_per_view * 4]u8 = undefined;
|
|
1847
|
+
request[0] = operation;
|
|
1848
|
+
std.mem.writeInt(u16, request[1..3], @intCast(subject), .little);
|
|
1849
|
+
std.mem.writeInt(u16, request[3..5], @intCast(layout.nodes.len), .little);
|
|
1850
|
+
for (layout.nodes, 0..) |node, index| {
|
|
1851
|
+
const at = 5 + index * 4;
|
|
1852
|
+
std.mem.writeInt(u16, request[at..][0..2], if (node.parent_index) |parent| @intCast(parent) else 65535, .little);
|
|
1853
|
+
request[at + 2] = switch (node.widget.kind) {
|
|
1854
|
+
.toggle_button => 1,
|
|
1855
|
+
.toggle_group => 2,
|
|
1856
|
+
.button_group => 3,
|
|
1857
|
+
else => 0,
|
|
1858
|
+
};
|
|
1859
|
+
request[at + 3] = if (node.widget.kind == .toggle_button and layout.focusTargetById(node.widget.id) != null) 2 else 0;
|
|
1860
|
+
}
|
|
1861
|
+
var output: [2]u8 = undefined;
|
|
1862
|
+
const len = policy(request[0 .. 5 + layout.nodes.len * 4], &output);
|
|
1863
|
+
if (len != 2) @panic("invalid toggle focus policy result");
|
|
1864
|
+
const index = std.mem.readInt(u16, &output, .little);
|
|
1865
|
+
if (index == 65535) return null;
|
|
1866
|
+
if (index >= layout.nodes.len) @panic("toggle policy target outside tree");
|
|
1867
|
+
return layout.focusTargetById(layout.nodes[index].widget.id);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
pub fn canvasWidgetCompiledMenuFocus(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?canvas.WidgetFocusTarget {
|
|
1871
|
+
var output: [2]u8 = undefined;
|
|
1872
|
+
const len = canvasWidgetMenuPolicy(layout, subject, operation, &output) orelse return null;
|
|
1873
|
+
if (len != 2) @panic("invalid menu policy target");
|
|
1874
|
+
const index = std.mem.readInt(u16, &output, .little);
|
|
1875
|
+
if (index == 65535) return null;
|
|
1876
|
+
if (index >= layout.nodes.len) @panic("menu policy target outside tree");
|
|
1877
|
+
return layout.focusTargetById(layout.nodes[index].widget.id);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
fn compiledRadioIndex(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?usize {
|
|
1881
|
+
var output: [2]u8 = undefined;
|
|
1882
|
+
const len = canvasWidgetRadioPolicy(layout, subject, operation, &output) orelse return null;
|
|
1883
|
+
if (len != 2) @panic("invalid radio policy target");
|
|
1884
|
+
const index = std.mem.readInt(u16, &output, .little);
|
|
1885
|
+
if (index == 65535) return null;
|
|
1886
|
+
if (index >= layout.nodes.len) @panic("radio policy target outside tree");
|
|
1887
|
+
return index;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
fn compiledRadioFocus(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?canvas.WidgetFocusTarget {
|
|
1891
|
+
const index = compiledRadioIndex(layout, subject, operation) orelse return null;
|
|
1892
|
+
return if (operation == 2 or operation == 3) layout.focusTargetById(layout.nodes[index].widget.id) else layout.logicalFocusTargetAtIndex(index);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1642
1895
|
/// Index of the nearest `.radio_group` ancestor, or null for a bare
|
|
1643
1896
|
/// radio (and for any other node outside a radio group).
|
|
1644
1897
|
pub fn canvasWidgetRadioGroupScopeIndex(layout: canvas.WidgetLayoutTree, node_index: usize) ?usize {
|
|
1645
1898
|
if (node_index >= layout.nodes.len) return null;
|
|
1899
|
+
if ((layout.nodes[node_index].widget.kind == .radio or layout.nodes[node_index].widget.kind == .radio_group) and layout.nodes[node_index].widget.interaction_policy != null) return compiledRadioIndex(layout, node_index, 0);
|
|
1646
1900
|
var current = layout.nodes[node_index].parent_index;
|
|
1647
1901
|
while (current) |index| {
|
|
1648
1902
|
if (index >= layout.nodes.len) return null;
|
|
@@ -1679,6 +1933,7 @@ fn canvasWidgetRadioGroupFocusTarget(
|
|
|
1679
1933
|
/// focusable radio. Selection may be represented by state or value.
|
|
1680
1934
|
pub fn canvasWidgetRovingTabEntryTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
|
|
1681
1935
|
if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
|
|
1936
|
+
if (layout.nodes[scope.index].widget.interaction_policy != null) return compiledRadioFocus(layout, scope.index, 1);
|
|
1682
1937
|
const scope_depth = layout.nodes[scope.index].depth;
|
|
1683
1938
|
var first: ?canvas.WidgetFocusTarget = null;
|
|
1684
1939
|
var index = scope.index + 1;
|
|
@@ -1697,6 +1952,7 @@ pub fn canvasWidgetRovingTabEntryTarget(layout: canvas.WidgetLayoutTree, scope:
|
|
|
1697
1952
|
/// composite's position around those intervening Tab stops.
|
|
1698
1953
|
pub fn canvasWidgetRovingTabStopTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
|
|
1699
1954
|
if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
|
|
1955
|
+
if (layout.nodes[scope.index].widget.interaction_policy != null) return compiledRadioFocus(layout, scope.index, 2);
|
|
1700
1956
|
const scope_depth = layout.nodes[scope.index].depth;
|
|
1701
1957
|
var index = scope.index + 1;
|
|
1702
1958
|
while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
|
|
@@ -1715,6 +1971,7 @@ pub fn canvasWidgetRovingTabStopTarget(layout: canvas.WidgetLayoutTree, scope: C
|
|
|
1715
1971
|
/// an invisible focus id.
|
|
1716
1972
|
pub fn canvasWidgetRovingTabVisibleEntryTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
|
|
1717
1973
|
if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
|
|
1974
|
+
if (layout.nodes[scope.index].widget.interaction_policy != null) return compiledRadioFocus(layout, scope.index, 3);
|
|
1718
1975
|
const scope_depth = layout.nodes[scope.index].depth;
|
|
1719
1976
|
var first: ?canvas.WidgetFocusTarget = null;
|
|
1720
1977
|
var index = scope.index + 1;
|
|
@@ -1734,8 +1991,9 @@ pub fn canvasWidgetRadioGroupDirectionalFocusTarget(
|
|
|
1734
1991
|
direction: canvas.WidgetFocusDirection,
|
|
1735
1992
|
) ?canvas.WidgetFocusTarget {
|
|
1736
1993
|
if (focused.kind != .radio or focused.index >= layout.nodes.len) return null;
|
|
1737
|
-
const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
|
|
1738
1994
|
const group_direction = canvasWidgetAnyAxisGroupDirection(direction) orelse return null;
|
|
1995
|
+
if (layout.nodes[focused.index].widget.interaction_policy != null) return compiledRadioFocus(layout, focused.index, if (group_direction == .previous) 4 else 5);
|
|
1996
|
+
const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
|
|
1739
1997
|
return canvasWidgetRadioGroupAdjacentRadio(layout, scope_index, focused.index, group_direction) orelse focused;
|
|
1740
1998
|
}
|
|
1741
1999
|
|
|
@@ -1745,6 +2003,7 @@ pub fn canvasWidgetRadioGroupFocusEdgeTarget(
|
|
|
1745
2003
|
edge: CanvasWidgetGroupFocusEdge,
|
|
1746
2004
|
) ?canvas.WidgetFocusTarget {
|
|
1747
2005
|
if (focused.kind != .radio or focused.index >= layout.nodes.len) return null;
|
|
2006
|
+
if (layout.nodes[focused.index].widget.interaction_policy != null) return compiledRadioFocus(layout, focused.index, if (edge == .first) 6 else 7);
|
|
1748
2007
|
const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
|
|
1749
2008
|
if (scope_index >= layout.nodes.len) return null;
|
|
1750
2009
|
const scope_depth = layout.nodes[scope_index].depth;
|
|
@@ -1853,6 +2112,9 @@ pub fn canvasWidgetAdjacentGroupFocusTarget(
|
|
|
1853
2112
|
/// the node sits outside any tree.
|
|
1854
2113
|
pub fn canvasWidgetTreeScopeIndex(layout: canvas.WidgetLayoutTree, node_index: usize) ?usize {
|
|
1855
2114
|
if (node_index >= layout.nodes.len) return null;
|
|
2115
|
+
const widget = layout.nodes[node_index].widget;
|
|
2116
|
+
if ((widget.kind == .tree or widget.semantics.role == .tree or widget.semantics.role == .treeitem) and widget.interaction_policy != null)
|
|
2117
|
+
return compiledTreeIndex(layout, node_index, 0);
|
|
1856
2118
|
var current = layout.nodes[node_index].parent_index;
|
|
1857
2119
|
while (current) |index| {
|
|
1858
2120
|
if (index >= layout.nodes.len) return null;
|
|
@@ -1867,6 +2129,46 @@ pub fn canvasWidgetTreeScopeIndex(layout: canvas.WidgetLayoutTree, node_index: u
|
|
|
1867
2129
|
return null;
|
|
1868
2130
|
}
|
|
1869
2131
|
|
|
2132
|
+
/// Geometry stays native; the compiled policy receives retained topology,
|
|
2133
|
+
/// logical focus eligibility, selection, expansion, and flat row levels.
|
|
2134
|
+
pub fn canvasWidgetTreePolicy(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8, output: []u8) ?usize {
|
|
2135
|
+
if (subject >= layout.nodes.len) return null;
|
|
2136
|
+
const widget = layout.nodes[subject].widget;
|
|
2137
|
+
if (widget.kind != .tree and widget.semantics.role != .tree and widget.semantics.role != .treeitem) return null;
|
|
2138
|
+
const policy = widget.interaction_policy orelse return null;
|
|
2139
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("tree policy exceeds native view budget");
|
|
2140
|
+
var request: [5 + canvas_limits.max_canvas_widget_nodes_per_view * 6]u8 = undefined;
|
|
2141
|
+
request[0] = operation;
|
|
2142
|
+
std.mem.writeInt(u16, request[1..3], @intCast(subject), .little);
|
|
2143
|
+
std.mem.writeInt(u16, request[3..5], @intCast(layout.nodes.len), .little);
|
|
2144
|
+
for (layout.nodes, 0..) |node, index| {
|
|
2145
|
+
const at = 5 + index * 6;
|
|
2146
|
+
std.mem.writeInt(u16, request[at..][0..2], if (node.parent_index) |parent| @intCast(parent) else 65535, .little);
|
|
2147
|
+
request[at + 2] = @as(u8, if (node.widget.semantics.role == .treeitem) 1 else 0) |
|
|
2148
|
+
@as(u8, if (node.widget.kind == .tree or node.widget.semantics.role == .tree) 2 else 0);
|
|
2149
|
+
request[at + 3] = @as(u8, if (operation != 0 and operation != 8 and node.widget.semantics.role == .treeitem and layout.logicalFocusTargetAtIndex(index) != null) 1 else 0) |
|
|
2150
|
+
@as(u8, if (canvasWidgetSelectableSelected(node.widget)) 4 else 0) |
|
|
2151
|
+
@as(u8, if (node.widget.state.expanded orelse false) 8 else 0);
|
|
2152
|
+
std.mem.writeInt(u16, request[at + 4 ..][0..2], node.widget.tree_level, .little);
|
|
2153
|
+
}
|
|
2154
|
+
return policy(request[0 .. 5 + layout.nodes.len * 6], output);
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
fn compiledTreeIndex(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?usize {
|
|
2158
|
+
var output: [2]u8 = undefined;
|
|
2159
|
+
const len = canvasWidgetTreePolicy(layout, subject, operation, &output) orelse return null;
|
|
2160
|
+
if (len != 2) @panic("invalid tree policy target");
|
|
2161
|
+
const index = std.mem.readInt(u16, &output, .little);
|
|
2162
|
+
if (index == 65535) return null;
|
|
2163
|
+
if (index >= layout.nodes.len) @panic("tree policy target outside tree");
|
|
2164
|
+
return index;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
fn compiledTreeFocus(layout: canvas.WidgetLayoutTree, subject: usize, operation: u8) ?canvas.WidgetFocusTarget {
|
|
2168
|
+
const index = compiledTreeIndex(layout, subject, operation) orelse return null;
|
|
2169
|
+
return layout.logicalFocusTargetAtIndex(index);
|
|
2170
|
+
}
|
|
2171
|
+
|
|
1870
2172
|
fn canvasWidgetTreeRowFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
|
|
1871
2173
|
if (layout.nodes[node_index].widget.semantics.role != .treeitem) return null;
|
|
1872
2174
|
return canvasWidgetLogicalFocusTarget(layout, node_index);
|
|
@@ -1899,6 +2201,16 @@ pub fn canvasWidgetTreeDirectionalFocusTarget(
|
|
|
1899
2201
|
if (focused.index >= layout.nodes.len) return null;
|
|
1900
2202
|
if (layout.nodes[focused.index].widget.semantics.role != .treeitem) return null;
|
|
1901
2203
|
const tree_index = canvasWidgetTreeScopeIndex(layout, focused.index) orelse return null;
|
|
2204
|
+
if (layout.nodes[focused.index].widget.interaction_policy != null) {
|
|
2205
|
+
const operation: u8 = switch (direction) {
|
|
2206
|
+
.up => 4,
|
|
2207
|
+
.down => 5,
|
|
2208
|
+
.left => 9,
|
|
2209
|
+
.right => 10,
|
|
2210
|
+
.forward, .backward => return null,
|
|
2211
|
+
};
|
|
2212
|
+
return compiledTreeFocus(layout, focused.index, operation);
|
|
2213
|
+
}
|
|
1902
2214
|
return switch (direction) {
|
|
1903
2215
|
.up => canvasWidgetTreeAdjacentRow(layout, tree_index, focused.index, .previous) orelse focused,
|
|
1904
2216
|
.down => canvasWidgetTreeAdjacentRow(layout, tree_index, focused.index, .next) orelse focused,
|
|
@@ -1925,6 +2237,8 @@ pub fn canvasWidgetTreeFocusEdgeTarget(
|
|
|
1925
2237
|
if (focused.index >= layout.nodes.len) return null;
|
|
1926
2238
|
if (layout.nodes[focused.index].widget.semantics.role != .treeitem) return null;
|
|
1927
2239
|
const tree_index = canvasWidgetTreeScopeIndex(layout, focused.index) orelse return null;
|
|
2240
|
+
if (layout.nodes[focused.index].widget.interaction_policy != null)
|
|
2241
|
+
return compiledTreeFocus(layout, focused.index, if (edge == .first) 6 else 7);
|
|
1928
2242
|
switch (edge) {
|
|
1929
2243
|
.first => {
|
|
1930
2244
|
var index = tree_index + 1;
|
|
@@ -2015,10 +2329,23 @@ fn canvasWidgetTreeFirstChildRow(layout: canvas.WidgetLayoutTree, tree_index: us
|
|
|
2015
2329
|
}
|
|
2016
2330
|
|
|
2017
2331
|
pub fn canvasWidgetGroupFocusEdgeTarget(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, edge: CanvasWidgetGroupFocusEdge) ?canvas.WidgetFocusTarget {
|
|
2332
|
+
return canvasWidgetGroupFocusEdgeTargetWithPolicy(layout, focused, edge, null);
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
pub fn canvasWidgetGroupFocusEdgeTargetWithPolicy(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, edge: CanvasWidgetGroupFocusEdge, policy: keyboard_focus.Policy) ?canvas.WidgetFocusTarget {
|
|
2018
2336
|
if (canvasWidgetRadioGroupFocusEdgeTarget(layout, focused, edge)) |target| return target;
|
|
2019
|
-
if (
|
|
2337
|
+
if (keyboard_focus.decide(policy, .{ .stage = .edge, .kind = focused.kind, .parent = canvasWidgetFocusParentKind(layout, focused) }) == 0) return null;
|
|
2020
2338
|
if (focused.index >= layout.nodes.len) return null;
|
|
2021
2339
|
const parent_index = layout.nodes[focused.index].parent_index;
|
|
2340
|
+
if (focused.kind == .segmented_control and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
2341
|
+
return compiledTabsFocus(layout, focused.index, if (edge == .first) 6 else 7);
|
|
2342
|
+
if (focused.kind == .list_item and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
2343
|
+
return compiledListFocus(layout, focused.index, if (edge == .first) 6 else 7);
|
|
2344
|
+
if (focused.kind == .menu_item and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
2345
|
+
return canvasWidgetCompiledMenuFocus(layout, focused.index, if (edge == .first) 6 else 7);
|
|
2346
|
+
if (focused.kind == .toggle_button and layout.nodes[focused.index].widget.interaction_policy != null)
|
|
2347
|
+
return canvasWidgetCompiledToggleFocus(layout, focused.index, if (edge == .first) 6 else 7);
|
|
2348
|
+
if (policy != null) return canvasWidgetCompiledGroupFocus(layout, focused, if (edge == .first) 2 else 3, policy.?);
|
|
2022
2349
|
switch (edge) {
|
|
2023
2350
|
.first => {
|
|
2024
2351
|
for (layout.nodes) |node| {
|
|
@@ -2038,3 +2365,32 @@ pub fn canvasWidgetGroupFocusEdgeTarget(layout: canvas.WidgetLayoutTree, focused
|
|
|
2038
2365
|
}
|
|
2039
2366
|
return null;
|
|
2040
2367
|
}
|
|
2368
|
+
|
|
2369
|
+
/// Exact identities remain native. Only bounded indices and native focus
|
|
2370
|
+
/// capability outcomes cross the copied-byte group traversal boundary.
|
|
2371
|
+
fn canvasWidgetCompiledGroupFocus(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, operation: u8, policy: *const fn ([]const u8, []u8) usize) ?canvas.WidgetFocusTarget {
|
|
2372
|
+
if (focused.index >= layout.nodes.len) return null;
|
|
2373
|
+
if (layout.nodes.len > canvas_limits.max_canvas_widget_nodes_per_view) @panic("keyboard group exceeds native view budget");
|
|
2374
|
+
const parent = layout.nodes[focused.index].parent_index;
|
|
2375
|
+
const parent_kind = canvasWidgetFocusParentKind(layout, focused);
|
|
2376
|
+
var request: [9 + canvas_limits.max_canvas_widget_nodes_per_view * 4]u8 = undefined;
|
|
2377
|
+
request[0..5].* = .{ 34, 10, operation, @intCast(canvas.widgetKindCode(focused.kind)), if (parent_kind) |kind| @intCast(canvas.widgetKindCode(kind)) else 63 };
|
|
2378
|
+
std.mem.writeInt(u16, request[5..7], if (parent) |index| @intCast(index) else 65535, .little);
|
|
2379
|
+
std.mem.writeInt(u16, request[7..9], @intCast(layout.nodes.len), .little);
|
|
2380
|
+
for (layout.nodes, 0..) |node, index| {
|
|
2381
|
+
const record = request[9 + index * 4 ..][0..4];
|
|
2382
|
+
std.mem.writeInt(u16, record[0..2], if (node.parent_index) |parent_index| @intCast(parent_index) else 65535, .little);
|
|
2383
|
+
record[2] = @intCast(canvas.widgetKindCode(node.widget.kind));
|
|
2384
|
+
record[3] = @as(u8, if (layout.focusTargetById(node.widget.id) != null) 1 else 0) |
|
|
2385
|
+
@as(u8, if (node.widget.id == focused.id) 2 else 0) | @as(u8, if (canvasWidgetLogicalFocusTarget(layout, index) != null) 4 else 0);
|
|
2386
|
+
}
|
|
2387
|
+
var response: [2]u8 = undefined;
|
|
2388
|
+
if (policy(request[0 .. 9 + layout.nodes.len * 4], &response) != response.len) @panic("invalid compiled keyboard group result");
|
|
2389
|
+
const index = std.mem.readInt(u16, &response, .little);
|
|
2390
|
+
if (index == 65535) return null;
|
|
2391
|
+
if (index >= layout.nodes.len) @panic("compiled keyboard group index out of bounds");
|
|
2392
|
+
return if (operation < 2 and focused.kind == .list_item and parent_kind == .list)
|
|
2393
|
+
canvasWidgetLogicalFocusTarget(layout, index)
|
|
2394
|
+
else
|
|
2395
|
+
layout.focusTargetById(layout.nodes[index].widget.id);
|
|
2396
|
+
}
|