@native-sdk/cli 0.10.1 → 0.11.1
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 +393 -97
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +2030 -83
- package/native-sdk.d.ts +5 -1
- package/package.json +20 -14
- package/packages/core/compile-surface/core.ts +164 -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 +68 -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 +332 -5
- package/packages/core/sdk/core.ts +371 -85
- package/packages/core/sdk/events.d.ts +252 -0
- package/packages/core/sdk/events.ts +240 -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 +186 -19
- package/packages/core/src/cli.ts +2 -11
- 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/context_menus.ts +76 -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/diagnostics.ts +7 -0
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/extent_program.ts +53 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/frontend.ts +12 -10
- 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_canonical.ts +140 -0
- package/packages/core/src/markup_construction.ts +189 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/markup_display.ts +43 -0
- package/packages/core/src/markup_document.ts +226 -0
- package/packages/core/src/markup_elements.ts +225 -0
- package/packages/core/src/markup_expressions.ts +79 -0
- package/packages/core/src/markup_imports.ts +146 -0
- package/packages/core/src/markup_parser.ts +228 -0
- package/packages/core/src/markup_runtime.ts +93 -0
- package/packages/core/src/markup_scalars.ts +143 -0
- package/packages/core/src/markup_shapes.ts +243 -0
- package/packages/core/src/markup_specialized.ts +242 -0
- package/packages/core/src/markup_text.ts +86 -0
- package/packages/core/src/markup_values.ts +336 -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 +98 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +92 -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 +3954 -0
- package/packages/core/src/scalar_text.ts +82 -0
- package/packages/core/src/scroll_mutation.ts +86 -0
- package/packages/core/src/scroll_tree.ts +86 -0
- package/packages/core/src/service_contract.ts +55 -3
- 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 +14 -46
- package/packages/core/src/sqlite_codegen.ts +84 -0
- package/packages/core/src/staged_rebuild.ts +60 -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_bridge.ts +161 -0
- package/packages/core/src/view_check.ts +145 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_evaluator.ts +823 -0
- package/packages/core/src/view_frontend.ts +1102 -0
- package/packages/core/src/view_program.ts +221 -0
- package/packages/core/src/view_reload.ts +166 -0
- package/packages/core/src/view_reload_watch.ts +98 -0
- package/packages/core/src/view_sources.ts +34 -0
- package/packages/core/src/virtual_windows.ts +88 -0
- package/packages/core/src/web_panes.ts +67 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_continuity.ts +37 -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_reconcile.ts +63 -0
- package/packages/core/src/widget_retention.ts +62 -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 +77 -18
- package/skill-data/ts-core/SKILL.md +117 -11
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +288 -144
- package/src/app_runner/root.zig +39 -12
- package/src/app_runner/ts_compiled_view.zig +1702 -0
- package/src/app_runner/ts_core_main.zig +185 -14
- package/src/app_runner/ts_core_mobile.zig +25 -13
- package/src/automation/server.zig +57 -6
- 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/embed/host.zig +2 -0
- package/src/embed/tests.zig +2 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/keyboard_input.zig +32 -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 +4 -0
- package/src/platform/macos/appkit_host.h +7 -2
- package/src/platform/macos/appkit_host.m +219 -39
- package/src/platform/macos/cef_host.mm +15 -1
- package/src/platform/macos/global_shortcuts.zig +138 -0
- package/src/platform/macos/key_codes.zig +102 -0
- package/src/platform/macos/keyboard_input.zig +81 -0
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/root.zig +25 -3
- 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/webview_inspection_test.m +106 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +130 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +15 -0
- package/src/platform/types.zig +115 -0
- package/src/platform/windows/global_shortcuts.zig +157 -0
- package/src/platform/windows/key_codes.zig +63 -0
- package/src/platform/windows/keyboard_input.zig +136 -0
- package/src/platform/windows/root.zig +17 -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/decision_reuse.zig +133 -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/font_ttf.zig +27 -3
- package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
- package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
- package/src/primitives/canvas/fonts/OFL.txt +93 -0
- package/src/primitives/canvas/fonts/README.md +15 -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 +131 -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/markdown_tests.zig +3 -3
- 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 +15 -11
- package/src/primitives/canvas/reference_tests.zig +58 -0
- 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 +107 -4
- 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 +53 -37
- package/src/primitives/canvas/text_metrics_tests.zig +52 -7
- package/src/primitives/canvas/text_query_policy.zig +295 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +234 -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 +47 -0
- package/src/primitives/canvas/ui.zig +251 -83
- package/src/primitives/canvas/ui_markup.zig +207 -46
- package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +1724 -80
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
- package/src/primitives/canvas/ui_markup_construction.zig +146 -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_display.zig +82 -0
- package/src/primitives/canvas/ui_markup_document.zig +196 -0
- package/src/primitives/canvas/ui_markup_elements.zig +163 -0
- package/src/primitives/canvas/ui_markup_expr.zig +192 -2
- package/src/primitives/canvas/ui_markup_imports.zig +262 -0
- package/src/primitives/canvas/ui_markup_parser.zig +117 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
- package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
- package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
- package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_text.zig +128 -0
- package/src/primitives/canvas/ui_markup_values.zig +368 -0
- package/src/primitives/canvas/ui_markup_view.zig +3026 -57
- 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 +350 -0
- package/src/primitives/canvas/virtual_extents.zig +113 -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 +129 -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 +21 -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 +26 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +29 -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/bridge_payload.zig +2 -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 +183 -4
- package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
- 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 +720 -150
- 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/context_menu_policy.zig +112 -0
- package/src/runtime/core.zig +170 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +638 -33
- package/src/runtime/effects_host_tests.zig +25 -0
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +419 -341
- package/src/runtime/flow_reference.zig +1427 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/global_shortcuts.zig +75 -0
- 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/keyboard_input.zig +86 -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 +16 -0
- package/src/runtime/scroll_mutation_policy.zig +130 -0
- package/src/runtime/scroll_mutation_runtime.zig +158 -0
- package/src/runtime/scroll_tree_policy.zig +99 -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 +231 -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/staged_rebuild_policy.zig +83 -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 +65 -36
- package/src/runtime/tests.zig +2 -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 +2451 -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 +1111 -45
- package/src/runtime/ui_app.zig +1381 -650
- 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 +667 -188
- package/src/runtime/ui_app_window_tests.zig +222 -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_reload.zig +226 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +46 -26
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +503 -69
- package/src/runtime/virtual_window_policy.zig +128 -0
- package/src/runtime/web_pane_policy.zig +111 -0
- package/src/runtime/web_pane_test_cases.zig +204 -0
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_continuity_policy.zig +73 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/widget_reconcile_policy.zig +81 -0
- package/src/runtime/widget_retention_policy.zig +75 -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 +179 -11
- package/src/security/root.zig +1 -0
- 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 +23 -3
- package/src/tooling/ts_core.zig +97 -4
- package/src/tooling/verbs.zig +87 -1
- 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 +188 -0
- package/tools/corewire/core_abi.zig +55 -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 +361 -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 +300 -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 +39 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +28 -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 +59 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +204 -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 +269 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const recipe = @import("surface_recipe_policy.zig");
|
|
2
3
|
const geometry = @import("geometry");
|
|
3
4
|
const canvas = @import("root.zig");
|
|
4
5
|
const text_model = @import("text.zig");
|
|
@@ -26,8 +27,8 @@ const Widget = widget_model.Widget;
|
|
|
26
27
|
const booleanControlSelected = widget_access.booleanControlSelected;
|
|
27
28
|
const widgetBodyTextSize = widget_metrics.widgetBodyTextSize;
|
|
28
29
|
const widgetLabelTextSize = widget_metrics.widgetLabelTextSize;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
30
|
+
const widgetLineHeightWithTokens = widget_metrics.widgetLineHeightWithTokens;
|
|
31
|
+
const widgetTypographySizeWithTokens = widget_metrics.widgetTypographySizeWithTokens;
|
|
31
32
|
const widgetControlInset = widget_metrics.widgetControlInset;
|
|
32
33
|
const widgetAlertInset = widget_metrics.widgetAlertInset;
|
|
33
34
|
const widgetSizedDensityValue = widget_metrics.widgetSizedDensityValue;
|
|
@@ -45,16 +46,11 @@ const controlStrokeWidth = widget_render_style.controlStrokeWidth;
|
|
|
45
46
|
const snapHairlineStrokeRect = widget_render_style.snapHairlineStrokeRect;
|
|
46
47
|
const washHovered = widget_render_style.washHovered;
|
|
47
48
|
const surfaceStateBackground = widget_render_style.surfaceStateBackground;
|
|
48
|
-
const disabledWash = widget_render_style.disabledWash;
|
|
49
|
-
const alertControlVisualTokens = widget_render_style.alertControlVisualTokens;
|
|
50
|
-
const cardControlVisualTokens = widget_render_style.cardControlVisualTokens;
|
|
51
|
-
const dialogControlVisualTokens = widget_render_style.dialogControlVisualTokens;
|
|
52
|
-
const drawerControlVisualTokens = widget_render_style.drawerControlVisualTokens;
|
|
53
|
-
const sheetControlVisualTokens = widget_render_style.sheetControlVisualTokens;
|
|
54
49
|
const surfaceControlVisualTokens = widget_render_style.surfaceControlVisualTokens;
|
|
55
50
|
|
|
56
51
|
pub fn emitAlertWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
57
|
-
|
|
52
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.alert, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg);
|
|
53
|
+
const visual = surfaceControlVisualTokens(widget, tokens);
|
|
58
54
|
const radius = controlRadius(widget, visual, tokens.radius.lg);
|
|
59
55
|
try builder.fillRoundedRect(.{
|
|
60
56
|
.id = widgetPartId(widget.id, 1),
|
|
@@ -78,7 +74,7 @@ pub fn emitAlertWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTo
|
|
|
78
74
|
// the icon column (`alertContentFrame` indents children the same
|
|
79
75
|
// way, so a description column lines up under the title).
|
|
80
76
|
const text_size = widgetBodyTextSize(widget, tokens);
|
|
81
|
-
const line_height =
|
|
77
|
+
const line_height = widgetLineHeightWithTokens(text_size, tokens);
|
|
82
78
|
const inset = widgetAlertInset(widget, tokens);
|
|
83
79
|
const icon_size = widgetSizedDensityValue(widget, tokens, 16);
|
|
84
80
|
const icon_frame = geometry.RectF.init(
|
|
@@ -119,30 +115,8 @@ pub fn emitAlertWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTo
|
|
|
119
115
|
/// The alert's identity color: destructive alerts read in the
|
|
120
116
|
/// destructive hue (the house style `text-destructive` treatment on a plain
|
|
121
117
|
/// card surface); every other variant keeps the plain foreground.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (widget.style.background) |color| return disabledWash(color, widget.state.disabled, tokens.states.disabled_alpha);
|
|
125
|
-
const hue = widget.style.accent orelse tokens.colors.destructive;
|
|
126
|
-
const wash = colorWithAlpha(hue, if (widget.state.pressed)
|
|
127
|
-
tokens.states.destructive_wash_pressed_alpha
|
|
128
|
-
else if (washHovered(widget))
|
|
129
|
-
tokens.states.destructive_wash_hover_alpha
|
|
130
|
-
else
|
|
131
|
-
tokens.states.destructive_wash_alpha);
|
|
132
|
-
return disabledWash(wash, widget.state.disabled, tokens.states.disabled_alpha);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
fn alertBorderColor(widget: Widget, visual: ControlVisualTokens, tokens: DesignTokens) Color {
|
|
136
|
-
const border = widget.style.border orelse if (widget.variant == .destructive)
|
|
137
|
-
// Destructive alerts use the callout edge from the house recipe:
|
|
138
|
-
// the destructive hue at half strength. ControlTokens has one
|
|
139
|
-
// shared alert table, not per-variant alert tables, so a flat
|
|
140
|
-
// neutral `alert.border` cannot masquerade as variant theming.
|
|
141
|
-
colorWithAlpha(widget.style.accent orelse tokens.colors.destructive, 0.5)
|
|
142
|
-
else
|
|
143
|
-
visual.border orelse tokens.colors.border;
|
|
144
|
-
return disabledWash(border, widget.state.disabled, tokens.states.disabled_alpha);
|
|
145
|
-
}
|
|
118
|
+
const alertBackgroundColor = widget_render_style.alertBackgroundColor;
|
|
119
|
+
const alertBorderColor = widget_render_style.alertBorderColor;
|
|
146
120
|
|
|
147
121
|
fn alertVariantForeground(widget: Widget, visual: ControlVisualTokens, tokens: DesignTokens) Color {
|
|
148
122
|
return switch (widget.variant) {
|
|
@@ -155,6 +129,14 @@ fn alertVariantForeground(widget: Widget, visual: ControlVisualTokens, tokens: D
|
|
|
155
129
|
}
|
|
156
130
|
|
|
157
131
|
pub fn emitAlertMark(builder: *Builder, widget: Widget, tokens: DesignTokens, frame: geometry.RectF, color_value: Color) Error!void {
|
|
132
|
+
if (tokens.control_geometry_policy != null) {
|
|
133
|
+
var copied = widget;
|
|
134
|
+
copied.frame = frame;
|
|
135
|
+
var request = recipe.Request.init(.alert_mark, copied, tokens, .{}, 0);
|
|
136
|
+
request.putColor(192, color_value);
|
|
137
|
+
const planned = request.run(copied, tokens);
|
|
138
|
+
return planned.emit(builder, copied, tokens);
|
|
139
|
+
}
|
|
158
140
|
const normalized = pixelSnapGeometryRect(tokens, frame.normalized());
|
|
159
141
|
if (normalized.isEmpty()) return;
|
|
160
142
|
// The registry icons the house alerts wear: `info` for the plain
|
|
@@ -164,11 +146,12 @@ pub fn emitAlertMark(builder: *Builder, widget: Widget, tokens: DesignTokens, fr
|
|
|
164
146
|
// blur 12. Slots are 4-bit (`widgetPartId` packs id*16+slot), so
|
|
165
147
|
// they must stay below 16.
|
|
166
148
|
const icon = icon_model.resolve(if (widget.variant == .destructive) "alert" else "info") orelse return;
|
|
167
|
-
try widget_render_controls.
|
|
149
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, 3, normalized, color_value, icon, tokens);
|
|
168
150
|
}
|
|
169
151
|
|
|
170
152
|
pub fn emitCardWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
171
|
-
|
|
153
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.card, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg);
|
|
154
|
+
const visual = surfaceControlVisualTokens(widget, tokens);
|
|
172
155
|
const radius = controlRadius(widget, visual, tokens.radius.lg);
|
|
173
156
|
try builder.fillRoundedRect(.{
|
|
174
157
|
.id = widgetPartId(widget.id, 1),
|
|
@@ -187,7 +170,7 @@ pub fn emitCardWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTok
|
|
|
187
170
|
}));
|
|
188
171
|
if (widget.text.len == 0) return;
|
|
189
172
|
|
|
190
|
-
const title_size =
|
|
173
|
+
const title_size = widgetTypographySizeWithTokens(widget, tokens.typography.body_size + 1, tokens);
|
|
191
174
|
const inset = widgetControlInset(widget, tokens, tokens.spacing.lg);
|
|
192
175
|
try builder.drawText(.{
|
|
193
176
|
.id = widgetPartId(widget.id, 3),
|
|
@@ -198,7 +181,7 @@ pub fn emitCardWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTok
|
|
|
198
181
|
.text = widget.text,
|
|
199
182
|
.text_layout = .{
|
|
200
183
|
.max_width = @max(1, widget.frame.width - inset * 2),
|
|
201
|
-
.line_height =
|
|
184
|
+
.line_height = widgetLineHeightWithTokens(title_size, tokens),
|
|
202
185
|
.wrap = .word,
|
|
203
186
|
.alignment = widget.text_alignment,
|
|
204
187
|
.measure = tokens.text_measure,
|
|
@@ -207,18 +190,19 @@ pub fn emitCardWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTok
|
|
|
207
190
|
}
|
|
208
191
|
|
|
209
192
|
pub fn emitDialogSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
210
|
-
try emitModalSurfaceWidgetChrome(builder, widget, tokens,
|
|
193
|
+
try emitModalSurfaceWidgetChrome(builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl);
|
|
211
194
|
}
|
|
212
195
|
|
|
213
196
|
pub fn emitDrawerSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
214
|
-
try emitModalSurfaceWidgetChrome(builder, widget, tokens,
|
|
197
|
+
try emitModalSurfaceWidgetChrome(builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl);
|
|
215
198
|
}
|
|
216
199
|
|
|
217
200
|
pub fn emitSheetSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
218
|
-
try emitModalSurfaceWidgetChrome(builder, widget, tokens,
|
|
201
|
+
try emitModalSurfaceWidgetChrome(builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg);
|
|
219
202
|
}
|
|
220
203
|
|
|
221
204
|
pub fn emitModalSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens, visual: ControlVisualTokens, fallback_radius: f32) Error!void {
|
|
205
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.modal, builder, widget, tokens, visual, fallback_radius);
|
|
222
206
|
const radius = controlRadius(widget, visual, fallback_radius);
|
|
223
207
|
const shadow_token = tokens.shadow.md;
|
|
224
208
|
if (shadow_token.y != 0 or shadow_token.blur != 0 or shadow_token.spread != 0) {
|
|
@@ -250,7 +234,7 @@ pub fn emitModalSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: D
|
|
|
250
234
|
}));
|
|
251
235
|
if (widget.text.len == 0) return;
|
|
252
236
|
|
|
253
|
-
const title_size =
|
|
237
|
+
const title_size = widgetTypographySizeWithTokens(widget, tokens.typography.title_size, tokens);
|
|
254
238
|
const inset = widgetControlInset(widget, tokens, tokens.spacing.xl);
|
|
255
239
|
try builder.drawText(.{
|
|
256
240
|
.id = widgetPartId(widget.id, 4),
|
|
@@ -261,7 +245,7 @@ pub fn emitModalSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: D
|
|
|
261
245
|
.text = widget.text,
|
|
262
246
|
.text_layout = .{
|
|
263
247
|
.max_width = @max(1, widget.frame.width - inset * 2),
|
|
264
|
-
.line_height =
|
|
248
|
+
.line_height = widgetLineHeightWithTokens(title_size, tokens),
|
|
265
249
|
.wrap = .word,
|
|
266
250
|
.alignment = widget.text_alignment,
|
|
267
251
|
.measure = tokens.text_measure,
|
|
@@ -270,6 +254,7 @@ pub fn emitModalSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: D
|
|
|
270
254
|
}
|
|
271
255
|
|
|
272
256
|
pub fn emitPanelWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
257
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.panel, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg);
|
|
273
258
|
const visual = surfaceControlVisualTokens(widget, tokens);
|
|
274
259
|
const radius = controlRadius(widget, visual, tokens.radius.lg);
|
|
275
260
|
const background = surfaceStateBackground(widget, visual, tokens);
|
|
@@ -316,6 +301,10 @@ pub fn emitPanelWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTo
|
|
|
316
301
|
/// instead of ballooning into a lozenge. Deriving from the lg token
|
|
317
302
|
/// keeps themed radius scales in step. An author `radius` wins.
|
|
318
303
|
pub fn bubbleWidgetRadius(widget: Widget, tokens: DesignTokens) Radius {
|
|
304
|
+
if (tokens.control_geometry_policy != null) {
|
|
305
|
+
const planned = recipe.plan(.bubble_radius, widget, tokens, .{}, 0);
|
|
306
|
+
return planned.bubbleRadius();
|
|
307
|
+
}
|
|
319
308
|
if (widget.style.radius) |radius| return Radius.all(@max(0, radius));
|
|
320
309
|
return Radius.all(@max(0, tokens.radius.lg) + 12);
|
|
321
310
|
}
|
|
@@ -342,6 +331,7 @@ pub fn bubbleWidgetRadius(widget: Widget, tokens: DesignTokens) Radius {
|
|
|
342
331
|
/// Themed apps may still pin `controls.bubble` background/border; those
|
|
343
332
|
/// land on the default variant, and author `style.*` always wins.
|
|
344
333
|
pub fn emitBubbleWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
334
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.bubble, builder, widget, tokens, tokens.controls.bubble, 0);
|
|
345
335
|
const radius = bubbleWidgetRadius(widget, tokens);
|
|
346
336
|
if (bubbleFillColor(widget, tokens)) |background| {
|
|
347
337
|
try builder.fillRoundedRect(.{
|
|
@@ -401,6 +391,10 @@ fn bubbleBorderColor(widget: Widget, tokens: DesignTokens) ?Color {
|
|
|
401
391
|
/// captions); an explicit `style.foreground` on a child still wins,
|
|
402
392
|
/// and the unfilled variants pass the palette through untouched.
|
|
403
393
|
pub fn bubbleContentTokens(widget: Widget, tokens: DesignTokens) DesignTokens {
|
|
394
|
+
if (tokens.control_geometry_policy != null) {
|
|
395
|
+
const planned = recipe.plan(.bubble_ink, widget, tokens, .{}, 0);
|
|
396
|
+
return planned.contentTokens(tokens);
|
|
397
|
+
}
|
|
404
398
|
var content = tokens;
|
|
405
399
|
switch (widget.variant) {
|
|
406
400
|
.primary => {
|
|
@@ -448,12 +442,16 @@ pub const bubble_reactions_ring: f32 = 3;
|
|
|
448
442
|
/// reference, the pill consumes no flow space, so a thread gives the
|
|
449
443
|
/// overlap breathing room with its own turn spacing.
|
|
450
444
|
pub fn bubbleWidgetReactionsPillRect(widget: Widget, tokens: DesignTokens) ?geometry.RectF {
|
|
445
|
+
if (tokens.control_geometry_policy != null) {
|
|
446
|
+
const planned = recipe.plan(.pill_rect, widget, tokens, .{}, 0);
|
|
447
|
+
return planned.pill();
|
|
448
|
+
}
|
|
451
449
|
if (widget.kind != .bubble or widget.text.len == 0) return null;
|
|
452
450
|
const frame = widget.frame.normalized();
|
|
453
451
|
if (frame.isEmpty()) return null;
|
|
454
452
|
const text_size = widgetLabelTextSize(widget, tokens);
|
|
455
|
-
const height =
|
|
456
|
-
const text_width = text_model.
|
|
453
|
+
const height = widgetLineHeightWithTokens(text_size, tokens) + bubble_reactions_pad_v * 2;
|
|
454
|
+
const text_width = text_model.measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, widget.text, text_size);
|
|
457
455
|
// The capsule floor: a one-glyph pill stays a circle-ish chip
|
|
458
456
|
// instead of collapsing narrower than it is tall.
|
|
459
457
|
const width = @max(height, @ceil(text_width) + bubble_reactions_pad_h * 2);
|
|
@@ -472,6 +470,7 @@ pub fn bubbleWidgetReactionsPillRect(widget: Widget, tokens: DesignTokens) ?geom
|
|
|
472
470
|
/// a primary bubble's knockout ink never applies — so it draws from the
|
|
473
471
|
/// page tokens regardless of variant.
|
|
474
472
|
pub fn emitBubbleWidgetReactions(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
473
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.reactions, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), 0);
|
|
475
474
|
const pill = bubbleWidgetReactionsPillRect(widget, tokens) orelse return;
|
|
476
475
|
const snapped = pixelSnapGeometryRect(tokens, pill);
|
|
477
476
|
const ring = snapped.inflate(geometry.InsetsF.all(bubble_reactions_ring));
|
|
@@ -488,7 +487,7 @@ pub fn emitBubbleWidgetReactions(builder: *Builder, widget: Widget, tokens: Desi
|
|
|
488
487
|
.fill = colorFill(tokens.colors.surface_subtle),
|
|
489
488
|
});
|
|
490
489
|
const text_size = widgetLabelTextSize(widget, tokens);
|
|
491
|
-
const line_height =
|
|
490
|
+
const line_height = widgetLineHeightWithTokens(text_size, tokens);
|
|
492
491
|
// Baseline centered in the pill, the single-line label convention.
|
|
493
492
|
const baseline = snapped.y + @max(text_size, (snapped.height - line_height) * 0.5 + text_size);
|
|
494
493
|
try builder.drawText(.{
|
|
@@ -514,10 +513,11 @@ pub fn emitBubbleWidgetReactions(builder: *Builder, widget: Widget, tokens: Desi
|
|
|
514
513
|
/// explicit background (author style or themed control tokens) still
|
|
515
514
|
/// paints.
|
|
516
515
|
pub fn emitAccordionWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
516
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.accordion, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), 0);
|
|
517
517
|
const frame = widget.frame.normalized();
|
|
518
518
|
if (frame.isEmpty()) return;
|
|
519
519
|
|
|
520
|
-
const visual =
|
|
520
|
+
const visual = surfaceControlVisualTokens(widget, tokens);
|
|
521
521
|
if (widget.style.background orelse visual.background) |background| {
|
|
522
522
|
try builder.fillRoundedRect(.{
|
|
523
523
|
.id = widgetPartId(widget.id, 1),
|
|
@@ -554,7 +554,7 @@ pub fn emitAccordionWidgetChrome(builder: *Builder, widget: Widget, tokens: Desi
|
|
|
554
554
|
.text = widget.text,
|
|
555
555
|
.text_layout = .{
|
|
556
556
|
.max_width = @max(1, content.width - chevron_size - chevron_gap),
|
|
557
|
-
.line_height =
|
|
557
|
+
.line_height = widgetLineHeightWithTokens(text_size, tokens),
|
|
558
558
|
.wrap = .none,
|
|
559
559
|
.alignment = widget.text_alignment,
|
|
560
560
|
.overflow = widget.text_overflow,
|
|
@@ -578,6 +578,13 @@ pub fn emitAccordionWidgetChrome(builder: *Builder, widget: Widget, tokens: Desi
|
|
|
578
578
|
/// at its endpoints). The icon takes slots 4/5 (single stroke shape),
|
|
579
579
|
/// clear of the chrome slots — slots are 4-bit, never 16 or above.
|
|
580
580
|
pub fn emitAccordionChevron(builder: *Builder, widget: Widget, tokens: DesignTokens, frame: geometry.RectF) Error!void {
|
|
581
|
+
if (tokens.control_geometry_policy != null) {
|
|
582
|
+
var copied = widget;
|
|
583
|
+
copied.frame = frame;
|
|
584
|
+
const request = recipe.Request.init(.chevron, copied, tokens, .{}, 0);
|
|
585
|
+
const planned = request.run(copied, tokens);
|
|
586
|
+
return planned.emit(builder, copied, tokens);
|
|
587
|
+
}
|
|
581
588
|
const icon = icon_model.resolve("chevron-down") orelse return;
|
|
582
589
|
const normalized = pixelSnapGeometryRect(tokens, frame.normalized());
|
|
583
590
|
if (normalized.isEmpty()) return;
|
|
@@ -594,10 +601,10 @@ pub fn emitAccordionChevron(builder: *Builder, widget: Widget, tokens: DesignTok
|
|
|
594
601
|
.ty = normalized.y * 2 + normalized.height,
|
|
595
602
|
};
|
|
596
603
|
try builder.transform(flip);
|
|
597
|
-
try widget_render_controls.
|
|
604
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, 4, normalized, color, icon, tokens);
|
|
598
605
|
try builder.transform(flip);
|
|
599
606
|
} else {
|
|
600
|
-
try widget_render_controls.
|
|
607
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, 4, normalized, color, icon, tokens);
|
|
601
608
|
}
|
|
602
609
|
}
|
|
603
610
|
|
|
@@ -614,6 +621,7 @@ pub fn emitAccordionChevron(builder: *Builder, widget: Widget, tokens: DesignTok
|
|
|
614
621
|
/// trigger's bar sinks to this same edge and covers the hairline
|
|
615
622
|
/// where they meet.
|
|
616
623
|
pub fn emitTabsListWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
624
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.tabs, builder, widget, tokens, tokens.controls.tabs, tokens.radius.lg);
|
|
617
625
|
// No children guard: the retained layout copy flattens children into
|
|
618
626
|
// sibling nodes, so the container paints purely from its own frame
|
|
619
627
|
// (an empty tabs list lays out to a sliver nothing meaningful paints
|
|
@@ -670,6 +678,7 @@ pub fn emitTabsListWidgetChrome(builder: *Builder, widget: Widget, tokens: Desig
|
|
|
670
678
|
}
|
|
671
679
|
|
|
672
680
|
pub fn emitResizableWidgetHandle(builder: *Builder, widget: Widget, tokens: DesignTokens, visual: ControlVisualTokens) Error!void {
|
|
681
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.grip, builder, widget, tokens, visual, 0);
|
|
673
682
|
const frame = widget.frame.normalized();
|
|
674
683
|
if (frame.isEmpty()) return;
|
|
675
684
|
|
|
@@ -702,6 +711,7 @@ pub fn emitResizableWidgetHandle(builder: *Builder, widget: Widget, tokens: Desi
|
|
|
702
711
|
}
|
|
703
712
|
|
|
704
713
|
pub fn emitPopoverWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
714
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.floating, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl);
|
|
705
715
|
const visual = surfaceControlVisualTokens(widget, tokens);
|
|
706
716
|
const radius = controlRadius(widget, visual, tokens.radius.xl);
|
|
707
717
|
const shadow_token = tokens.shadow.md;
|
|
@@ -735,6 +745,7 @@ pub fn emitPopoverWidgetChrome(builder: *Builder, widget: Widget, tokens: Design
|
|
|
735
745
|
}
|
|
736
746
|
|
|
737
747
|
pub fn emitMenuSurfaceWidgetChrome(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
748
|
+
if (tokens.control_geometry_policy != null) return recipe.emit(.floating, builder, widget, tokens, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg);
|
|
738
749
|
const visual = surfaceControlVisualTokens(widget, tokens);
|
|
739
750
|
const radius = controlRadius(widget, visual, tokens.radius.lg);
|
|
740
751
|
const shadow_token = tokens.shadow.md;
|
|
@@ -8,6 +8,7 @@ const event_model = @import("events.zig");
|
|
|
8
8
|
const equality_model = @import("equality.zig");
|
|
9
9
|
const widget_tree = @import("widget_tree.zig");
|
|
10
10
|
const widget_access = @import("widget_access.zig");
|
|
11
|
+
const portable = @import("widget_routing_policy.zig");
|
|
11
12
|
|
|
12
13
|
const Error = canvas.Error;
|
|
13
14
|
const ObjectId = canvas.ObjectId;
|
|
@@ -55,6 +56,10 @@ pub fn hitTestWidgetLayout(layout: anytype, point: geometry.PointF, tokens: Desi
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
pub fn hitTestWidgetLayoutWithPolicy(layout: anytype, point: geometry.PointF, tokens: DesignTokens, comptime policy: HitTestPolicy) ?WidgetHit {
|
|
59
|
+
if (tokens.widget_routing_policy orelse portable.owner(layout)) |owner| {
|
|
60
|
+
const result = portable.query(layout, owner, if (policy == .interactive) 0 else 1, 0, null, null, point, tokens, 0, {});
|
|
61
|
+
return hitFromPortableResult(layout, result.target);
|
|
62
|
+
}
|
|
58
63
|
// Window-level surfaces paint in the late z-pass — topmost — so they
|
|
59
64
|
// hit-test FIRST, in reverse window-surface paint order.
|
|
60
65
|
const surface_count = widget_tree.widgetLayoutWindowSurfaceCount(layout);
|
|
@@ -136,6 +141,7 @@ fn widgetHitFromNode(node: WidgetLayoutNode, index: usize) WidgetHit {
|
|
|
136
141
|
/// nothing on the path claims — the press dispatches to no one, exactly
|
|
137
142
|
/// like a click on dead space.
|
|
138
143
|
pub fn widgetPressTargetIndexFromNode(layout: anytype, node_index: usize) ?usize {
|
|
144
|
+
if (portable.owner(layout)) |owner| return portable.query(layout, owner, 2, 0, node_index, null, .{}, .{}, 0, {}).target;
|
|
139
145
|
var current: ?usize = node_index;
|
|
140
146
|
while (current) |index| {
|
|
141
147
|
if (index >= layout.nodes.len) return null;
|
|
@@ -160,6 +166,11 @@ pub fn widgetPressTargetForHit(layout: anytype, hit: WidgetHit) ?WidgetHit {
|
|
|
160
166
|
/// pressable ancestor), and a hit with no claiming ancestor keeps itself
|
|
161
167
|
/// (static text keeps its selection affordance).
|
|
162
168
|
pub fn widgetHoverTargetForHit(layout: anytype, hit: WidgetHit) WidgetHit {
|
|
169
|
+
if (portable.owner(layout)) |owner| {
|
|
170
|
+
const facts: u8 = @as(u8, @intFromBool(hit.role == .link)) | (@as(u8, @intFromBool(hit.state.disabled)) << 1) | (@as(u8, @intFromBool(hit.kind == .data_cell)) << 2);
|
|
171
|
+
const result = portable.query(layout, owner, 3, facts, hit.index, null, .{}, .{}, 0, {});
|
|
172
|
+
return if (result.keep_hit) hit else hitFromPortableResult(layout, result.target) orelse hit;
|
|
173
|
+
}
|
|
163
174
|
if (hit.role == .link and !hit.state.disabled) return hit;
|
|
164
175
|
const target = widgetPressTargetForHit(layout, hit) orelse hit;
|
|
165
176
|
// A table row hovers as ONE unit: a hit that resolves to a cell (a
|
|
@@ -185,6 +196,11 @@ pub fn widgetHoverTargetForHit(layout: anytype, hit: WidgetHit) WidgetHit {
|
|
|
185
196
|
/// exactly like the browser pair this models. The chain is empty for
|
|
186
197
|
/// apps that bind no hover handlers, so unbound trees pay nothing.
|
|
187
198
|
pub fn widgetHoverMsgChainFromNode(layout: anytype, node_index: usize, output: []ObjectId) []const ObjectId {
|
|
199
|
+
if (portable.owner(layout)) |owner| {
|
|
200
|
+
const result = portable.query(layout, owner, 4, 0, node_index, null, .{}, .{}, output.len, {});
|
|
201
|
+
for (0..result.len) |i| output[i] = layout.nodes[result.indices[i]].widget.id;
|
|
202
|
+
return output[0..result.len];
|
|
203
|
+
}
|
|
188
204
|
var chain: [max_widget_depth]ObjectId = undefined;
|
|
189
205
|
var chain_len: usize = 0;
|
|
190
206
|
var current: ?usize = node_index;
|
|
@@ -222,6 +238,7 @@ fn widgetAncestorHitOfKind(layout: anytype, node_index: usize, kind: WidgetKind)
|
|
|
222
238
|
/// walk. A widget that both claims presses and marks `window_drag`
|
|
223
239
|
/// keeps its press — authored handlers outrank the drag surface.
|
|
224
240
|
pub fn widgetWindowDragTargetIndexFromNode(layout: anytype, node_index: usize) ?usize {
|
|
241
|
+
if (portable.owner(layout)) |owner| return portable.query(layout, owner, 5, 0, node_index, null, .{}, .{}, 0, {}).target;
|
|
225
242
|
var current: ?usize = node_index;
|
|
226
243
|
while (current) |index| {
|
|
227
244
|
if (index >= layout.nodes.len) return null;
|
|
@@ -264,6 +281,19 @@ fn isWidgetFrameVisibleInWidgetAncestors(layout: anytype, node_index: usize) boo
|
|
|
264
281
|
}
|
|
265
282
|
|
|
266
283
|
pub fn routeWidgetPointerEvent(layout: anytype, event: WidgetPointerEvent, tokens: DesignTokens, output: []WidgetEventRouteEntry) Error!WidgetEventRoute {
|
|
284
|
+
if (tokens.widget_routing_policy orelse portable.owner(layout)) |owner| {
|
|
285
|
+
const phase: u8 = switch (event.phase) {
|
|
286
|
+
.hover => 0,
|
|
287
|
+
.down => 1,
|
|
288
|
+
.move => 2,
|
|
289
|
+
.up => 3,
|
|
290
|
+
.cancel => 4,
|
|
291
|
+
.wheel => 5,
|
|
292
|
+
};
|
|
293
|
+
const result = portable.query(layout, owner, 6, phase, null, event.captured_id, event.point, tokens, output.len, {});
|
|
294
|
+
const entries = try result.copy(layout, output);
|
|
295
|
+
return .{ .target = hitFromPortableResult(layout, result.target), .press_target = hitFromPortableResult(layout, result.press), .entries = entries };
|
|
296
|
+
}
|
|
267
297
|
const target = if (eventUsesPointerCapture(event)) blk: {
|
|
268
298
|
break :blk capturedWidgetPointerTarget(layout, event) orelse return .{ .entries = output[0..0] };
|
|
269
299
|
} else hitTestWidgetLayout(layout, event.point, tokens) orelse return .{ .entries = output[0..0] };
|
|
@@ -302,6 +332,11 @@ fn widgetPointerTargetById(layout: anytype, id: ObjectId) ?WidgetHit {
|
|
|
302
332
|
}
|
|
303
333
|
|
|
304
334
|
pub fn routeWidgetKeyboardEvent(layout: anytype, event: WidgetKeyboardEvent, output: []WidgetEventRouteEntry, scroll_semantics_fn: anytype) Error!WidgetKeyboardRoute {
|
|
335
|
+
if (portable.owner(layout)) |owner| {
|
|
336
|
+
const result = portable.query(layout, owner, 7, 0, null, event.focused_id, .{}, .{}, output.len, scroll_semantics_fn);
|
|
337
|
+
const entries = try result.copy(layout, output);
|
|
338
|
+
return .{ .target = focusFromPortableResult(layout, result.target), .entries = entries };
|
|
339
|
+
}
|
|
305
340
|
const focused_id = event.focused_id orelse return .{ .entries = output[0..0] };
|
|
306
341
|
const target_index = widgetIndexById(layout, focused_id) orelse return .{ .entries = output[0..0] };
|
|
307
342
|
const target = focusTargetFromLayoutNode(layout, target_index, scroll_semantics_fn) orelse return .{ .entries = output[0..0] };
|
|
@@ -310,6 +345,11 @@ pub fn routeWidgetKeyboardEvent(layout: anytype, event: WidgetKeyboardEvent, out
|
|
|
310
345
|
}
|
|
311
346
|
|
|
312
347
|
pub fn routeWidgetFileDropEvent(layout: anytype, event: WidgetFileDropEvent, output: []WidgetEventRouteEntry) Error!WidgetEventRoute {
|
|
348
|
+
if (portable.owner(layout)) |owner| {
|
|
349
|
+
const result = portable.query(layout, owner, 8, @intFromBool(event.paths.len != 0), null, null, event.point, .{}, output.len, {});
|
|
350
|
+
const entries = try result.copy(layout, output);
|
|
351
|
+
return .{ .target = hitFromPortableResult(layout, result.target), .entries = entries };
|
|
352
|
+
}
|
|
313
353
|
if (event.paths.len == 0) return .{ .entries = output[0..0] };
|
|
314
354
|
const target_index = widgetDropTargetIndexAtPoint(layout, event.point) orelse return .{ .entries = output[0..0] };
|
|
315
355
|
const entries = try routeWidgetEventPath(layout, target_index, output);
|
|
@@ -317,6 +357,11 @@ pub fn routeWidgetFileDropEvent(layout: anytype, event: WidgetFileDropEvent, out
|
|
|
317
357
|
}
|
|
318
358
|
|
|
319
359
|
pub fn routeWidgetDragEvent(layout: anytype, event: WidgetDragEvent, output: []WidgetEventRouteEntry) Error!WidgetEventRoute {
|
|
360
|
+
if (portable.owner(layout)) |owner| {
|
|
361
|
+
const result = portable.query(layout, owner, 9, 0, null, event.source_id, .{}, .{}, output.len, {});
|
|
362
|
+
const entries = try result.copy(layout, output);
|
|
363
|
+
return .{ .target = hitFromPortableResult(layout, result.target), .entries = entries };
|
|
364
|
+
}
|
|
320
365
|
const target_index = widgetDragSourceIndex(layout, event.source_id) orelse return .{ .entries = output[0..0] };
|
|
321
366
|
const entries = try routeWidgetEventPath(layout, target_index, output);
|
|
322
367
|
return .{ .target = widgetHitFromNode(layout.nodes[target_index], target_index), .entries = entries };
|
|
@@ -399,6 +444,17 @@ fn appendWidgetEventRouteEntry(
|
|
|
399
444
|
}
|
|
400
445
|
|
|
401
446
|
pub fn focusWidgetTarget(layout: anytype, current_id: ?ObjectId, direction: WidgetFocusDirection, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
447
|
+
if (portable.owner(layout)) |owner| {
|
|
448
|
+
const param: u8 = switch (direction) {
|
|
449
|
+
.forward => 0,
|
|
450
|
+
.backward => 1,
|
|
451
|
+
.left => 2,
|
|
452
|
+
.right => 3,
|
|
453
|
+
.up => 4,
|
|
454
|
+
.down => 5,
|
|
455
|
+
};
|
|
456
|
+
return focusFromPortableResult(layout, portable.query(layout, owner, 10, param, null, current_id, .{}, .{}, 0, scroll_semantics_fn).target);
|
|
457
|
+
}
|
|
402
458
|
if (layout.nodes.len == 0) return null;
|
|
403
459
|
const current_index = if (current_id) |id| widgetIndexById(layout, id) else null;
|
|
404
460
|
return switch (direction) {
|
|
@@ -409,7 +465,15 @@ pub fn focusWidgetTarget(layout: anytype, current_id: ?ObjectId, direction: Widg
|
|
|
409
465
|
}
|
|
410
466
|
|
|
411
467
|
pub fn focusWidgetTargetById(layout: anytype, id: ObjectId, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
468
|
+
if (portable.owner(layout)) |owner| return focusFromPortableResult(layout, portable.query(layout, owner, 11, 0, null, id, .{}, .{}, 0, scroll_semantics_fn).target);
|
|
412
469
|
const index = widgetIndexById(layout, id) orelse return null;
|
|
470
|
+
return focusWidgetTargetAtIndex(layout, index, scroll_semantics_fn);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/// Exact visible-focus capability for a retained index, without an ID scan.
|
|
474
|
+
pub fn focusWidgetTargetAtIndex(layout: anytype, index: usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
475
|
+
if (portable.owner(layout)) |owner| return focusFromPortableResult(layout, portable.query(layout, owner, 12, 0, index, null, .{}, .{}, 0, scroll_semantics_fn).target);
|
|
476
|
+
if (index >= layout.nodes.len) return null;
|
|
413
477
|
return focusTargetFromLayoutNode(layout, index, scroll_semantics_fn);
|
|
414
478
|
}
|
|
415
479
|
|
|
@@ -418,6 +482,7 @@ pub fn focusWidgetTargetById(layout: anytype, id: ObjectId, scroll_semantics_fn:
|
|
|
418
482
|
/// keeping the exact same hidden, disclosure, disabled, and scroll-semantic
|
|
419
483
|
/// eligibility as `focusWidgetTargetById`.
|
|
420
484
|
pub fn logicalFocusWidgetTargetAtIndex(layout: anytype, index: usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
485
|
+
if (portable.owner(layout)) |owner| return focusFromPortableResult(layout, portable.query(layout, owner, 13, 0, index, null, .{}, .{}, 0, scroll_semantics_fn).target);
|
|
421
486
|
if (index >= layout.nodes.len) return null;
|
|
422
487
|
if (isWidgetHiddenInAncestors(layout, index)) return null;
|
|
423
488
|
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) return null;
|
|
@@ -536,3 +601,13 @@ fn rectsOverlapX(a: geometry.RectF, b: geometry.RectF) bool {
|
|
|
536
601
|
fn rectsOverlapY(a: geometry.RectF, b: geometry.RectF) bool {
|
|
537
602
|
return @min(a.maxY(), b.maxY()) > @max(a.y, b.y);
|
|
538
603
|
}
|
|
604
|
+
|
|
605
|
+
fn hitFromPortableResult(layout: anytype, result: ?usize) ?WidgetHit {
|
|
606
|
+
const index = result orelse return null;
|
|
607
|
+
return widgetHitFromNode(layout.nodes[index], index);
|
|
608
|
+
}
|
|
609
|
+
fn focusFromPortableResult(layout: anytype, result: ?usize) ?WidgetFocusTarget {
|
|
610
|
+
const index = result orelse return null;
|
|
611
|
+
const node = layout.nodes[index];
|
|
612
|
+
return .{ .id = node.widget.id, .kind = node.widget.kind, .bounds = node.frame, .index = index, .state = node.widget.state };
|
|
613
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//! Copied routing boundary. Native owns request/result/caller storage and
|
|
2
|
+
//! reconstructs typed records; the portable owner selects every target/path.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const geometry = @import("geometry");
|
|
5
|
+
const widgets = @import("widgets.zig");
|
|
6
|
+
const events = @import("events.zig");
|
|
7
|
+
const tokens_model = @import("tokens.zig");
|
|
8
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
9
|
+
const missing = std.math.maxInt(u32);
|
|
10
|
+
const roles = [_]widgets.WidgetRole{ .none, .group, .text, .link, .image, .button, .textbox, .tooltip, .dialog, .menu, .menuitem, .list, .listitem, .row, .grid, .gridcell, .tab, .checkbox, .radio, .radiogroup, .switch_control, .slider, .progressbar, .chart, .tree, .treeitem, .separator };
|
|
11
|
+
comptime {
|
|
12
|
+
if (roles.len != @typeInfo(widgets.WidgetRole).@"enum".fields.len) @compileError("update routing role codes");
|
|
13
|
+
}
|
|
14
|
+
pub fn owner(layout: anytype) ?Policy {
|
|
15
|
+
const T = switch (@typeInfo(@TypeOf(layout))) {
|
|
16
|
+
.pointer => |p| p.child,
|
|
17
|
+
else => @TypeOf(layout),
|
|
18
|
+
};
|
|
19
|
+
if (comptime @hasField(T, "routing_policy")) return layout.routing_policy;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
fn roleCode(role: widgets.WidgetRole) u32 {
|
|
23
|
+
for (roles, 0..) |value, i| if (value == role) return @intCast(i);
|
|
24
|
+
unreachable;
|
|
25
|
+
}
|
|
26
|
+
fn put(bytes: []u8, at: usize, value: u32) void {
|
|
27
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
28
|
+
}
|
|
29
|
+
fn float(bytes: []u8, at: usize, value: f32) void {
|
|
30
|
+
put(bytes, at, @bitCast(value));
|
|
31
|
+
}
|
|
32
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
33
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
34
|
+
}
|
|
35
|
+
pub const Result = struct {
|
|
36
|
+
status: u8,
|
|
37
|
+
keep_hit: bool,
|
|
38
|
+
target: ?usize,
|
|
39
|
+
press: ?usize,
|
|
40
|
+
len: usize,
|
|
41
|
+
indices: [63]usize = undefined,
|
|
42
|
+
phases: [63]events.WidgetEventPhase = undefined,
|
|
43
|
+
|
|
44
|
+
pub fn copy(self: Result, layout: anytype, output: []events.WidgetEventRouteEntry) @import("root.zig").Error![]const events.WidgetEventRouteEntry {
|
|
45
|
+
for (0..self.len) |i| {
|
|
46
|
+
const index = self.indices[i];
|
|
47
|
+
const node = layout.nodes[index];
|
|
48
|
+
output[i] = .{ .phase = self.phases[i], .node_index = index, .id = node.widget.id, .kind = node.widget.kind, .bounds = node.frame };
|
|
49
|
+
}
|
|
50
|
+
// The reference preserves the already-written prefix on overflow.
|
|
51
|
+
if (self.status == 1) return error.WidgetDepthExceeded;
|
|
52
|
+
if (self.status == 2) return error.WidgetEventRouteListFull;
|
|
53
|
+
return output[0..self.len];
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
fn readIndex(value: u32, count: usize) ?usize {
|
|
57
|
+
if (value == missing) return null;
|
|
58
|
+
if (value >= count) @panic("invalid compiled routing index");
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
/// op is a protocol query, param is its phase/direction. The portable owner
|
|
62
|
+
/// requests scroll observations only when ordinary focus gates need them.
|
|
63
|
+
pub fn query(layout: anytype, policy: Policy, comptime op: u8, param: u8, subject: ?usize, id: ?u64, point: geometry.PointF, tokens: tokens_model.DesignTokens, capacity: usize, scroll_semantics_fn: anytype) Result {
|
|
64
|
+
const allocator = std.heap.page_allocator;
|
|
65
|
+
const count = std.math.cast(u32, layout.nodes.len) orelse @panic("routing node capacity");
|
|
66
|
+
const length = std.math.add(usize, 64, std.math.mul(usize, count, 96) catch @panic("routing byte capacity")) catch @panic("routing byte capacity");
|
|
67
|
+
const request = allocator.alloc(u8, length) catch @panic("routing request allocation");
|
|
68
|
+
defer allocator.free(request);
|
|
69
|
+
@memset(request, 0);
|
|
70
|
+
request[0..4].* = .{ 24, 1, op, param };
|
|
71
|
+
put(request, 4, count);
|
|
72
|
+
put(request, 8, if (subject) |i| (if (i < count) @as(u32, @intCast(i)) else missing) else missing);
|
|
73
|
+
put(request, 12, @intCast(@min(capacity, std.math.maxInt(u32))));
|
|
74
|
+
std.mem.writeInt(u64, request[16..24], id orelse 0, .little);
|
|
75
|
+
float(request, 24, point.x);
|
|
76
|
+
float(request, 28, point.y);
|
|
77
|
+
// Some(0) is a capture request that cannot resolve; it is not null.
|
|
78
|
+
put(request, 48, @intFromBool(id != null));
|
|
79
|
+
for ([_]i32{ tokens.layer.base, tokens.layer.overlay, tokens.layer.modal, tokens.layer.floating }, 0..) |layer, i| put(request, 32 + i * 4, @bitCast(layer));
|
|
80
|
+
for (layout.nodes, 0..) |node, i| {
|
|
81
|
+
const n = node.widget;
|
|
82
|
+
const bytes = request[64 + i * 96 ..][0..96];
|
|
83
|
+
put(bytes, 0, widgets.widgetKindCode(n.kind));
|
|
84
|
+
put(bytes, 4, roleCode(n.semantics.role));
|
|
85
|
+
put(bytes, 8, if (node.parent_index) |p| (std.math.cast(u32, p) orelse missing) else missing);
|
|
86
|
+
put(bytes, 12, std.math.cast(u32, node.depth) orelse @panic("routing depth capacity"));
|
|
87
|
+
std.mem.writeInt(u64, bytes[16..24], n.id, .little);
|
|
88
|
+
// Authored flags only: no native target/visibility/focus verdicts.
|
|
89
|
+
const flags: u32 = @intFromBool(n.semantics.hidden) | (@as(u32, @intFromBool(n.state.disabled)) << 1) |
|
|
90
|
+
(@as(u32, @intFromBool(n.state.selected)) << 2) | (@as(u32, @intFromBool(n.layout.anchor != null)) << 3) |
|
|
91
|
+
(@as(u32, @intFromBool(n.layout.clip_content)) << 4) | (@as(u32, @intFromBool(n.hover_msgs)) << 5) |
|
|
92
|
+
(@as(u32, @intFromBool(n.window_drag)) << 6) | (@as(u32, @intFromBool(n.semantics.focusable)) << 7) |
|
|
93
|
+
(@as(u32, @intFromBool(n.layer != null)) << 9) | (@as(u32, @intFromBool(n.chart.hover_details)) << 10);
|
|
94
|
+
put(bytes, 24, flags);
|
|
95
|
+
put(bytes, 28, events.semanticActionBits(n.semantics.actions));
|
|
96
|
+
float(bytes, 32, n.value);
|
|
97
|
+
put(bytes, 36, @bitCast(n.layer orelse 0));
|
|
98
|
+
const values = [_]f32{ node.frame.x, node.frame.y, node.frame.width, node.frame.height, n.transform.a, n.transform.b, n.transform.c, n.transform.d, n.transform.tx, n.transform.ty };
|
|
99
|
+
for (values, 0..) |value, v| float(bytes, 40 + v * 4, value);
|
|
100
|
+
}
|
|
101
|
+
// Path depth is 32, so the complete capture/target/bubble path is 63.
|
|
102
|
+
var output: [24 + 63 * 8]u8 = undefined;
|
|
103
|
+
var written: usize = undefined;
|
|
104
|
+
var observations: usize = 0;
|
|
105
|
+
while (true) {
|
|
106
|
+
written = policy(request, &output);
|
|
107
|
+
if (written < 24 or output[2] != 3) break;
|
|
108
|
+
if (comptime op == 7 or op >= 10) {
|
|
109
|
+
const index = word(&output, 4);
|
|
110
|
+
if (written != 24 or output[0] != 1 or output[1] != op or output[3] != 0 or index >= count or word(&output, 8) != missing or word(&output, 12) != 0 or word(&output, 16) != 0 or word(&output, 20) != 0 or observations >= count)
|
|
111
|
+
@panic("invalid compiled routing observation");
|
|
112
|
+
const at = 64 + @as(usize, index) * 96 + 24;
|
|
113
|
+
var flags = word(request, at);
|
|
114
|
+
if (flags & 2048 != 0) @panic("repeated compiled routing observation");
|
|
115
|
+
flags |= 2048;
|
|
116
|
+
if (scroll_semantics_fn(layout, index).scrollable) flags |= 256;
|
|
117
|
+
put(request, at, flags);
|
|
118
|
+
observations += 1;
|
|
119
|
+
} else @panic("unexpected compiled routing observation");
|
|
120
|
+
}
|
|
121
|
+
if (written < 24 or written > output.len or output[0] != 1 or output[1] != op or output[2] > 2 or (if (op == 3) output[3] > 1 else output[3] != 0) or word(&output, 16) != 0 or word(&output, 20) != 0) @panic("invalid compiled routing result");
|
|
122
|
+
const len = word(&output, 12);
|
|
123
|
+
if (len > 63 or len > capacity or written != 24 + @as(usize, len) * 8 or (op != 4 and (op < 6 or op > 9) and len != 0) or ((op < 6 or op > 9) and output[2] != 0)) @panic("invalid compiled routing path");
|
|
124
|
+
var result = Result{ .status = output[2], .keep_hit = output[3] == 1, .target = readIndex(word(&output, 4), count), .press = readIndex(word(&output, 8), count), .len = len };
|
|
125
|
+
for (0..len) |i| {
|
|
126
|
+
result.indices[i] = readIndex(word(&output, 24 + i * 8), count) orelse @panic("missing compiled route entry");
|
|
127
|
+
result.phases[i] = switch (word(&output, 28 + i * 8)) {
|
|
128
|
+
0 => .capture,
|
|
129
|
+
1 => .target,
|
|
130
|
+
2 => .bubble,
|
|
131
|
+
else => @panic("invalid compiled route phase"),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|