@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
|
@@ -24,6 +24,9 @@ const code_model = @import("code.zig");
|
|
|
24
24
|
const font_coverage = @import("font_coverage.zig");
|
|
25
25
|
const geometry = @import("geometry");
|
|
26
26
|
const canvas = @import("root.zig");
|
|
27
|
+
const composition_recipes = @import("component_composition_policy.zig");
|
|
28
|
+
const composer = @import("component_composition.zig");
|
|
29
|
+
const construction = @import("component_construction_policy.zig");
|
|
27
30
|
const reflect = @import("ui_markup_reflect.zig");
|
|
28
31
|
const ui_provenance = @import("ui_provenance.zig");
|
|
29
32
|
|
|
@@ -393,6 +396,7 @@ fn colorTokenValue(colors: canvas.ColorTokens, ref: ColorTokenName) canvas.Color
|
|
|
393
396
|
|
|
394
397
|
fn radiusTokenValue(radius: canvas.RadiusTokens, ref: RadiusTokenName) f32 {
|
|
395
398
|
return switch (ref) {
|
|
399
|
+
.none => 0,
|
|
396
400
|
inline else => |tag| @field(radius, @tagName(tag)),
|
|
397
401
|
};
|
|
398
402
|
}
|
|
@@ -429,6 +433,14 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
429
433
|
|
|
430
434
|
arena: std.mem.Allocator,
|
|
431
435
|
failed: bool = false,
|
|
436
|
+
/// Compiled apps own portable recipes and construction. Native
|
|
437
|
+
/// extensions retain the reference when the corresponding owner is absent.
|
|
438
|
+
composition_policy: ?composition_recipes.Policy = null,
|
|
439
|
+
code_content_policy: ?canvas.CodeContentPolicy.Policy = null,
|
|
440
|
+
chart_content_policy: ?canvas.ChartContentPolicy.Policy = null,
|
|
441
|
+
markdown_content_policy: ?canvas.MarkdownContentPolicy.Policy = null,
|
|
442
|
+
construction_policy: ?construction.Policy = null,
|
|
443
|
+
expression_policy: ?@import("ui_markup_expr.zig").Policy = null,
|
|
432
444
|
/// Window source for `virtualWindow` (see `VirtualWindowSourceFn`):
|
|
433
445
|
/// null outside an app loop, where builds fall back to each
|
|
434
446
|
/// request's `viewport_fallback` at offset 0.
|
|
@@ -439,6 +451,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
439
451
|
/// variable windows compute from estimates alone.
|
|
440
452
|
virtual_extent_context: ?*anyopaque = null,
|
|
441
453
|
virtual_extent_source: ?VirtualExtentSourceFn = null,
|
|
454
|
+
virtual_extent_policy: ?@import("virtual_extent_policy.zig").Policy = null,
|
|
442
455
|
/// The windowed virtual lists this build declared (`virtualList`),
|
|
443
456
|
/// for the app loop's coverage check and scroll re-derivation.
|
|
444
457
|
virtual_window_records: [max_virtual_windows]VirtualWindowRecord = [_]VirtualWindowRecord{.{}} ** max_virtual_windows,
|
|
@@ -494,6 +507,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
494
507
|
/// Null outside an app loop (bare builders, tests that stamp
|
|
495
508
|
/// grids by hand), where terminals render unbound.
|
|
496
509
|
terminal_lookup: ?TerminalGridLookup = null,
|
|
510
|
+
pty_key_resolver: ?*const fn ([]const u8) u64 = null,
|
|
497
511
|
/// The `<video src>` declaration this build recorded (see
|
|
498
512
|
/// `video`): last-wins, mirroring `loadVideo`'s replace
|
|
499
513
|
/// semantics — one player is the whole playback surface. The
|
|
@@ -534,6 +548,8 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
534
548
|
/// this with their content argument.
|
|
535
549
|
text: []const u8 = "",
|
|
536
550
|
placeholder: []const u8 = "",
|
|
551
|
+
/// Command dispatched by the runtime on eligible activation.
|
|
552
|
+
command: []const u8 = "",
|
|
537
553
|
value: f32 = 0,
|
|
538
554
|
/// HORIZONTAL scroll offset for a horizontal-capable
|
|
539
555
|
/// `scroll` container (markup `value-x`) — the sideways
|
|
@@ -621,6 +637,8 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
621
637
|
submit_on_enter: bool = false,
|
|
622
638
|
variant: canvas.WidgetVariant = .default,
|
|
623
639
|
size: canvas.WidgetSize = .default,
|
|
640
|
+
/// Resolve backdrop blur against the live design-token register.
|
|
641
|
+
backdrop_blur_token: @FieldType(Widget, "backdrop_blur_token") = null,
|
|
624
642
|
/// Definite width: the widget is exactly this wide (the value
|
|
625
643
|
/// becomes both the min and max bound), so intrinsic content
|
|
626
644
|
/// can neither shrink nor silently overflow the box. 0 keeps
|
|
@@ -780,6 +798,8 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
780
798
|
/// paints the honest empty surface. Meaningless on every
|
|
781
799
|
/// other element.
|
|
782
800
|
pty: u64 = 0,
|
|
801
|
+
/// Byte-named PTY capability. Resolution stays in the native host.
|
|
802
|
+
pty_name: []const u8 = "",
|
|
783
803
|
/// The `.terminal` element's scrollback offset in rows
|
|
784
804
|
/// above the live screen (markup `scrollback=`), following
|
|
785
805
|
/// the scroll `value` source-wins reconcile rule: echo the
|
|
@@ -1525,7 +1545,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1525
1545
|
if (locally_derived) |text_edit| {
|
|
1526
1546
|
// Direct Tree consumers still sanitize locally:
|
|
1527
1547
|
// these bytes have not crossed the runtime seam.
|
|
1528
|
-
if (canvas.
|
|
1548
|
+
if (canvas.sanitizedTextInputEventForWidget(widget, text_edit)) |sanitized| {
|
|
1529
1549
|
if (self.msgForTextEdit(target_id, sanitized)) |msg| return msg;
|
|
1530
1550
|
}
|
|
1531
1551
|
}
|
|
@@ -1581,7 +1601,10 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1581
1601
|
pub fn el(self: *Self, kind: WidgetKind, options: ElementOptions, children: anytype) Node {
|
|
1582
1602
|
if (options.on_dismiss != null) warnDismissHandlerKind(kind);
|
|
1583
1603
|
if (options.on_resize != null) warnResizeHandlerKind(kind);
|
|
1584
|
-
var widget = widgetFromOptions(kind, options);
|
|
1604
|
+
var widget = self.widgetFromOptions(kind, options);
|
|
1605
|
+
if (kind == .terminal and options.pty_name.len > 0) {
|
|
1606
|
+
widget.terminal.pty = if (self.pty_key_resolver) |resolve| resolve(options.pty_name) else 0;
|
|
1607
|
+
}
|
|
1585
1608
|
if (kind == .media_surface) self.stampVideoSurfaceFit(&widget);
|
|
1586
1609
|
return .{
|
|
1587
1610
|
.widget = widget,
|
|
@@ -1829,6 +1852,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1829
1852
|
break :blk null;
|
|
1830
1853
|
};
|
|
1831
1854
|
var range_options = canvas.VirtualVariableRangeOptions{
|
|
1855
|
+
.policy = self.virtual_extent_policy,
|
|
1832
1856
|
.item_count = options.item_count,
|
|
1833
1857
|
.gap = options.gap,
|
|
1834
1858
|
.viewport_extent = viewport,
|
|
@@ -1840,6 +1864,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1840
1864
|
.uniform_estimate = options.item_extent,
|
|
1841
1865
|
};
|
|
1842
1866
|
if (table) |retained| {
|
|
1867
|
+
retained.policy = self.virtual_extent_policy;
|
|
1843
1868
|
_ = retained.sync(.{
|
|
1844
1869
|
.id = id,
|
|
1845
1870
|
.item_count = options.item_count,
|
|
@@ -1851,20 +1876,25 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1851
1876
|
});
|
|
1852
1877
|
// Corrections and prepends land here, together with the
|
|
1853
1878
|
// patched offsets below — the anchoring invariant.
|
|
1854
|
-
|
|
1879
|
+
const pending = retained.takePendingOffsetDelta();
|
|
1855
1880
|
const total = retained.totalExtent();
|
|
1856
|
-
if (
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1881
|
+
if (self.virtual_extent_policy) |policy| {
|
|
1882
|
+
offset = @import("virtual_extent_policy.zig").windowOffset(policy, state.offset, pending, total, viewport, retained.last_build_total, retained.last_build_viewport, options.anchor == .trailing, state.mounted, true);
|
|
1883
|
+
} else {
|
|
1884
|
+
offset += pending;
|
|
1885
|
+
if (options.anchor == .trailing) {
|
|
1886
|
+
if (!state.mounted) {
|
|
1887
|
+
offset = @max(0, total - viewport);
|
|
1888
|
+
} else if (retained.last_build_total >= 0) {
|
|
1889
|
+
// Was-at-the-bottom re-pin: the RETAINED offset
|
|
1890
|
+
// is compared against the geometry it was
|
|
1891
|
+
// scrolled under (last build's total), so both
|
|
1892
|
+
// appends and measured corrections keep a
|
|
1893
|
+
// pinned transcript pinned — while a viewport
|
|
1894
|
+
// scrolled away is never yanked.
|
|
1895
|
+
const old_max = @max(0, retained.last_build_total - retained.last_build_viewport);
|
|
1896
|
+
if (state.offset >= old_max - trailing_stick_slop) offset = @max(0, total - viewport);
|
|
1897
|
+
}
|
|
1868
1898
|
}
|
|
1869
1899
|
}
|
|
1870
1900
|
retained.last_build_total = total;
|
|
@@ -1874,7 +1904,10 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1874
1904
|
// estimated bottom (one extra estimate pass — bare-build
|
|
1875
1905
|
// pricing only; app loops always install a table).
|
|
1876
1906
|
const probe = canvas.virtualVariableListRange(range_options, null);
|
|
1877
|
-
offset =
|
|
1907
|
+
offset = if (self.virtual_extent_policy) |policy|
|
|
1908
|
+
@import("virtual_extent_policy.zig").windowOffset(policy, state.offset, 0, probe.content_extent, viewport, -1, 0, true, false, false)
|
|
1909
|
+
else
|
|
1910
|
+
@max(0, probe.content_extent - viewport);
|
|
1878
1911
|
}
|
|
1879
1912
|
range_options.scroll_offset = offset;
|
|
1880
1913
|
const variable = canvas.virtualVariableListRange(range_options, table);
|
|
@@ -2467,6 +2500,10 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
2467
2500
|
/// in a panel or card when those presentation choices are wanted.
|
|
2468
2501
|
/// Markdown fences lower through this same component.
|
|
2469
2502
|
pub fn code(self: *Self, options: CodeOptions, source: []const u8) Node {
|
|
2503
|
+
if (self.code_content_policy) |policy| return self.codeOwned(policy, options, source) catch {
|
|
2504
|
+
self.failed = true;
|
|
2505
|
+
return self.column(.{}, .{});
|
|
2506
|
+
};
|
|
2470
2507
|
const line_count = codeLineCount(source, options.editable);
|
|
2471
2508
|
const terminal_editor_line = options.editable and source.len > 0 and source[source.len - 1] == '\n';
|
|
2472
2509
|
const numbered = options.line_numbers and line_count - @intFromBool(terminal_editor_line) <=
|
|
@@ -2585,6 +2622,66 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
2585
2622
|
return root;
|
|
2586
2623
|
}
|
|
2587
2624
|
|
|
2625
|
+
// Assemble the copied portable recipe in the host arena. Identity,
|
|
2626
|
+
// owned text/spans and typed input routes remain native capabilities.
|
|
2627
|
+
fn codeOwned(self: *Self, policy: canvas.CodeContentPolicy.Policy, options: CodeOptions, source: []const u8) !Node {
|
|
2628
|
+
const plan = try canvas.CodeContentPolicy.recipe(policy, self.arena, source, @as(u8, @intFromBool(options.editable)) | (@as(u8, @intFromBool(options.wrap)) << 1) |
|
|
2629
|
+
(@as(u8, @intFromBool(options.line_numbers)) << 2) | (@as(u8, @intFromBool(options.height > 0)) << 3), options.added_lines, options.removed_lines);
|
|
2630
|
+
if (plan.flags & 4 != 0) self.failed = true;
|
|
2631
|
+
const diff: ?canvas.CodeDiffLines = if (plan.flags & 2 != 0) .{ .added = plan.added, .removed = plan.removed } else null;
|
|
2632
|
+
if (plan.content == 2) {
|
|
2633
|
+
const retained = if (options.wrap) blk: {
|
|
2634
|
+
var state: code_model.HighlightState = .{};
|
|
2635
|
+
break :blk self.codeParagraphWithState(source, options.language, true, options.grow, &state, null);
|
|
2636
|
+
} else blk: {
|
|
2637
|
+
const span = [_]canvas.TextSpan{.{ .text = source, .monospace = true, .color = .syntax_plain }};
|
|
2638
|
+
break :blk self.paragraph(.{ .wrap = false, .grow = options.grow }, &span);
|
|
2639
|
+
};
|
|
2640
|
+
var editor = self.el(.textarea, .{ .key = options.key, .global_key = options.global_key, .width = options.width, .height = options.height, .min_width = options.min_width, .grow = options.grow, .semantics = options.semantics, .on_input = options.on_input }, .{});
|
|
2641
|
+
editor.widget.text = retained.widget.text;
|
|
2642
|
+
editor.widget.spans = retained.widget.spans;
|
|
2643
|
+
editor.widget.text_no_wrap = !options.wrap;
|
|
2644
|
+
editor.widget.code_line_number_digits = plan.digits;
|
|
2645
|
+
if (diff) |lines| editor.widget.setCodeDiffLines(lines);
|
|
2646
|
+
editor.widget.runtime_flags.code_editor = true;
|
|
2647
|
+
editor.widget.code_language = options.language;
|
|
2648
|
+
editor.widget.layout.clip_content = true;
|
|
2649
|
+
return editor;
|
|
2650
|
+
}
|
|
2651
|
+
const content = if (plan.content == 1)
|
|
2652
|
+
self.decoratedCodeParagraph(source, options.language, options.wrap, plan.digits, diff)
|
|
2653
|
+
else blk: {
|
|
2654
|
+
const ends = try canvas.CodeContentPolicy.chunks(policy, self.arena, source, options.wrap, plan.chunk_count);
|
|
2655
|
+
var state: code_model.HighlightState = .{};
|
|
2656
|
+
var budget: CodeSpanBudget = .{ .remaining_chunks = ends.len };
|
|
2657
|
+
const grow: f32 = if (options.wrap) 1 else 0;
|
|
2658
|
+
if (ends.len == 1) break :blk self.codeParagraphWithState(source, options.language, options.wrap, grow, &state, &budget);
|
|
2659
|
+
const nodes = try self.arena.alloc(Node, ends.len);
|
|
2660
|
+
const fingerprint = std.hash.Wyhash.hash(0, source) | 1;
|
|
2661
|
+
var start: usize = 0;
|
|
2662
|
+
for (ends, nodes) |end, *item| {
|
|
2663
|
+
item.* = self.codeParagraphWithState(source[start..end], options.language, options.wrap, 0, &state, &budget);
|
|
2664
|
+
item.static_text_group_fingerprint = fingerprint;
|
|
2665
|
+
item.widget.static_text_group_offset = @intCast(start);
|
|
2666
|
+
start = end;
|
|
2667
|
+
}
|
|
2668
|
+
break :blk self.column(.{ .grow = grow }, .{nodes});
|
|
2669
|
+
};
|
|
2670
|
+
const body = switch (plan.axes) {
|
|
2671
|
+
0 => content,
|
|
2672
|
+
1 => blk: {
|
|
2673
|
+
var tracked = content;
|
|
2674
|
+
tracked.widget.layout.grow = 0;
|
|
2675
|
+
break :blk self.scroll(.{ .axis = .vertical, .grow = 1 }, .{self.column(.{}, .{tracked})});
|
|
2676
|
+
},
|
|
2677
|
+
2, 3 => self.scroll(.{ .axis = if (plan.axes == 2) .horizontal else .both, .grow = 1 }, .{self.column(.{}, .{ content, self.el(.stack, .{ .height = 8 }, .{}) })}),
|
|
2678
|
+
else => unreachable,
|
|
2679
|
+
};
|
|
2680
|
+
var root = self.el(.column, .{ .key = options.key, .global_key = options.global_key, .width = options.width, .height = options.height, .min_width = options.min_width, .grow = options.grow, .semantics = options.semantics }, .{body});
|
|
2681
|
+
root.widget.layout.clip_content = true;
|
|
2682
|
+
return root;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2588
2685
|
/// Keep numbered source in one selectable paragraph. The renderer
|
|
2589
2686
|
/// owns its muted gutter, so marker digits never enter retained
|
|
2590
2687
|
/// text or clipboard bytes; it derives each marker baseline from
|
|
@@ -2705,8 +2802,18 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
2705
2802
|
var highlighted = if (source.len == 0) blk: {
|
|
2706
2803
|
storage[0] = .{ .text = source, .monospace = true, .color = .syntax_plain };
|
|
2707
2804
|
break :blk storage[0..1];
|
|
2708
|
-
} else
|
|
2805
|
+
} else canvas.CodeContentPolicy.highlight(self.code_content_policy, source, language, &storage, state);
|
|
2709
2806
|
if (budget) |span_budget| {
|
|
2807
|
+
if (self.code_content_policy) |policy| {
|
|
2808
|
+
const plan = canvas.CodeContentPolicy.spanBudget(policy, span_budget.used, span_budget.remaining_chunks, highlighted.len);
|
|
2809
|
+
span_budget.used = plan.used;
|
|
2810
|
+
span_budget.remaining_chunks = plan.remaining;
|
|
2811
|
+
if (plan.plain) {
|
|
2812
|
+
storage[0] = .{ .text = source, .monospace = true, .color = .syntax_plain };
|
|
2813
|
+
highlighted = storage[0..1];
|
|
2814
|
+
}
|
|
2815
|
+
return self.paragraph(.{ .wrap = wrap, .grow = grow }, highlighted);
|
|
2816
|
+
}
|
|
2710
2817
|
std.debug.assert(span_budget.remaining_chunks > 0);
|
|
2711
2818
|
span_budget.remaining_chunks -= 1;
|
|
2712
2819
|
const highlighted_total = span_budget.used +
|
|
@@ -2887,6 +2994,24 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
2887
2994
|
.style = .{ .stroke_width = options.stroke_width },
|
|
2888
2995
|
.semantics = options.semantics,
|
|
2889
2996
|
}, .{});
|
|
2997
|
+
if (self.chart_content_policy) |policy| {
|
|
2998
|
+
const prepared = canvas.ChartContentPolicy.prepare(self.arena, policy, series) catch {
|
|
2999
|
+
self.failed = true;
|
|
3000
|
+
return node;
|
|
3001
|
+
};
|
|
3002
|
+
node.widget.chart = .{
|
|
3003
|
+
.series = prepared.series,
|
|
3004
|
+
.y_min = options.y_min,
|
|
3005
|
+
.y_max = options.y_max,
|
|
3006
|
+
.grid_lines = options.grid_lines,
|
|
3007
|
+
.baseline = options.baseline,
|
|
3008
|
+
.x_labels = if (prepared.downsampled) &.{} else options.x_labels,
|
|
3009
|
+
.y_labels = options.y_labels,
|
|
3010
|
+
.hover_details = options.hover_details,
|
|
3011
|
+
};
|
|
3012
|
+
if (node.widget.semantics.label.len == 0) node.widget.semantics.label = prepared.summary;
|
|
3013
|
+
return node;
|
|
3014
|
+
}
|
|
2890
3015
|
const stored = self.arena.alloc(canvas.ChartSeries, series.len) catch {
|
|
2891
3016
|
self.failed = true;
|
|
2892
3017
|
return node;
|
|
@@ -2976,6 +3101,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
2976
3101
|
/// FIRST (document order is focus order); build the accessory
|
|
2977
3102
|
/// row with `inputGroupActions`.
|
|
2978
3103
|
pub fn inputGroup(self: *Self, options: InputGroupOptions, entry: Node, actions: ?Node) Node {
|
|
3104
|
+
if (self.composition_policy != null) return composer.Composer(Self).inputGroup(self, options, entry, actions);
|
|
2979
3105
|
var semantics = options.semantics;
|
|
2980
3106
|
if (semantics.role == .none) semantics.role = .group;
|
|
2981
3107
|
var entry_node = entry;
|
|
@@ -3007,6 +3133,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3007
3133
|
/// keep ghost/icon buttons optically inside the field's own text
|
|
3008
3134
|
/// inset without double-padding the seam.
|
|
3009
3135
|
pub fn inputGroupActions(self: *Self, options: InputGroupActionsOptions, children: anytype) Node {
|
|
3136
|
+
if (self.composition_policy != null) return composer.Composer(Self).inputActions(self, options, children);
|
|
3010
3137
|
var node = self.el(.row, .{
|
|
3011
3138
|
.key = options.key,
|
|
3012
3139
|
.global_key = options.global_key,
|
|
@@ -3070,6 +3197,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3070
3197
|
/// number otherwise — and hairline separators connect the steps.
|
|
3071
3198
|
/// Display-only: driving `active` belongs to the app model.
|
|
3072
3199
|
pub fn stepper(self: *Self, options: StepperOptions, steps: []const StepperStep) Node {
|
|
3200
|
+
if (self.composition_policy != null) return composer.Composer(Self).stepper(self, options, steps);
|
|
3073
3201
|
var semantics = options.semantics;
|
|
3074
3202
|
if (semantics.role == .none) semantics.role = .list;
|
|
3075
3203
|
const node_count = if (steps.len == 0) 0 else steps.len * 2 - 1;
|
|
@@ -3139,11 +3267,12 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3139
3267
|
/// `timelineItem` nodes.
|
|
3140
3268
|
pub fn timeline(self: *Self, options: TimelineOptions, items: anytype) Node {
|
|
3141
3269
|
var semantics = options.semantics;
|
|
3142
|
-
if (
|
|
3270
|
+
const compiled = if (self.composition_policy) |owner| composition_recipes.plan(owner, .timeline, 0, semantics.role, 0, 0, 0, 0, options.gap) else null;
|
|
3271
|
+
if (compiled) |p| semantics.role = p.role() else if (semantics.role == .none) semantics.role = .list;
|
|
3143
3272
|
return self.el(.column, .{
|
|
3144
3273
|
.key = options.key,
|
|
3145
3274
|
.global_key = options.global_key,
|
|
3146
|
-
.gap = options.gap,
|
|
3275
|
+
.gap = if (compiled) |p| p.float(0) else options.gap,
|
|
3147
3276
|
.grow = options.grow,
|
|
3148
3277
|
.semantics = semantics,
|
|
3149
3278
|
}, items);
|
|
@@ -3186,6 +3315,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3186
3315
|
/// pressable — a trailing chevron with `on_press` bound to the
|
|
3187
3316
|
/// item's root (presses on the content fall through to it).
|
|
3188
3317
|
pub fn timelineItem(self: *Self, options: TimelineItemOptions) Node {
|
|
3318
|
+
if (self.composition_policy != null) return composer.Composer(Self).timelineItem(self, options);
|
|
3189
3319
|
const dot = options.indicator.len == 0 and options.icon.len == 0;
|
|
3190
3320
|
const indicator = self.el(.badge, .{
|
|
3191
3321
|
.variant = options.variant,
|
|
@@ -3288,6 +3418,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3288
3418
|
var semantics = options.semantics;
|
|
3289
3419
|
if (semantics.role == .none) semantics.role = .group;
|
|
3290
3420
|
const page_nodes = self.childNodes(pages);
|
|
3421
|
+
if (self.composition_policy != null) return composer.Composer(Self).nav(self, options, page_nodes);
|
|
3291
3422
|
if (page_nodes.len == 0) {
|
|
3292
3423
|
return self.el(.stack, .{
|
|
3293
3424
|
.key = options.key,
|
|
@@ -3404,14 +3535,23 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3404
3535
|
warnUncoveredText(widget.kind, widget.placeholder);
|
|
3405
3536
|
warnInertWrap(widget.kind, node.wrap);
|
|
3406
3537
|
warnTextSizeKind(widget.kind, widget.size);
|
|
3407
|
-
|
|
3538
|
+
const construction_plan: construction.FinalPlan = if (self.construction_policy) |policy|
|
|
3539
|
+
construction.finalize(policy, &widget, node.style_tokens, tokens.*, node.wrap, node.nodes.len == 2, constructionHandlers(node))
|
|
3540
|
+
else blk: {
|
|
3541
|
+
applyStyleTokens(&widget.style, node.style_tokens, tokens);
|
|
3542
|
+
if (node.wrap == false and widget.kind == .text) widget.text_no_wrap = true;
|
|
3543
|
+
break :blk .{
|
|
3544
|
+
.make_span = node.wrap == true and widget.kind == .text and widget.spans.len == 0 and widget.text.len > 0,
|
|
3545
|
+
.split = widget.kind == .split and node.nodes.len == 2,
|
|
3546
|
+
};
|
|
3547
|
+
};
|
|
3408
3548
|
// Opt-in text wrapping reuses the span paragraph machinery: a
|
|
3409
3549
|
// wrapped text leaf becomes a single-span paragraph over its
|
|
3410
3550
|
// own bytes (the span invariant: span text subslices
|
|
3411
3551
|
// `widget.text`), so wrapping, intrinsic sizing, wrapped
|
|
3412
3552
|
// height reservation, and rendering are all the existing span
|
|
3413
3553
|
// path — no forked text pipeline.
|
|
3414
|
-
if (
|
|
3554
|
+
if (construction_plan.make_span) {
|
|
3415
3555
|
const spans = try self.arena.alloc(canvas.TextSpan, 1);
|
|
3416
3556
|
spans[0] = .{ .text = widget.text };
|
|
3417
3557
|
widget.spans = spans;
|
|
@@ -3424,9 +3564,6 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3424
3564
|
// Span paragraphs honor the same explicit no-wrap policy.
|
|
3425
3565
|
// `Ui.code` uses this to keep highlighted logical lines
|
|
3426
3566
|
// intact inside its horizontal scroll region.
|
|
3427
|
-
if (node.wrap == false and widget.kind == .text) {
|
|
3428
|
-
widget.text_no_wrap = true;
|
|
3429
|
-
}
|
|
3430
3567
|
widget.id = if (node.global_key) |global_key|
|
|
3431
3568
|
structuralId(global_id_seed, widget.kind, global_key)
|
|
3432
3569
|
else
|
|
@@ -3454,34 +3591,36 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3454
3591
|
sink.record(widget.id, source, key_trail.items(), key_trail.truncated);
|
|
3455
3592
|
}
|
|
3456
3593
|
}
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
widget.
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3594
|
+
if (self.construction_policy == null) {
|
|
3595
|
+
// Typed handlers imply the matching accessibility actions, the
|
|
3596
|
+
// same way a stringly `command` does for engine-owned dispatch.
|
|
3597
|
+
if (node.on_press != null) widget.semantics.actions.press = true;
|
|
3598
|
+
if (node.on_drag != null) widget.semantics.actions.drag = true;
|
|
3599
|
+
// A double-press handler makes the element pressable too:
|
|
3600
|
+
// the double-click's first release must land somewhere, and
|
|
3601
|
+
// an element that acts on double click without claiming
|
|
3602
|
+
// presses would be unreachable by pointer at all.
|
|
3603
|
+
if (node.on_double_press != null) widget.semantics.actions.press = true;
|
|
3604
|
+
if (node.on_toggle != null) widget.semantics.actions.toggle = true;
|
|
3605
|
+
// A hold handler makes the element pressable (hit target +
|
|
3606
|
+
// press claimer), like on_press: the hold gesture starts as a
|
|
3607
|
+
// press, and the classic list-row shape (press to open, hold
|
|
3608
|
+
// for the menu) pairs the two on one element.
|
|
3609
|
+
if (node.on_hold != null) widget.semantics.actions.press = true;
|
|
3610
|
+
// Hover family: binding either edge makes the element
|
|
3611
|
+
// hover-hittable (`Widget.hover_msgs` — the chart
|
|
3612
|
+
// hover-details shape, a hit target that claims no
|
|
3613
|
+
// presses), never pressable: hover is not an action a
|
|
3614
|
+
// screen reader can invoke, so no semantic action is
|
|
3615
|
+
// stamped.
|
|
3616
|
+
if (node.on_hover_enter != null or node.on_hover_leave != null) widget.hover_msgs = true;
|
|
3617
|
+
if (node.on_input != null) widget.semantics.actions.set_text = true;
|
|
3618
|
+
if (widget.kind == .slider and (node.on_value != null or node.on_change != null)) {
|
|
3619
|
+
widget.semantics.actions.increment = true;
|
|
3620
|
+
widget.semantics.actions.decrement = true;
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
if (construction_plan.split) {
|
|
3485
3624
|
// Synthesize the draggable divider between the two panes.
|
|
3486
3625
|
// Both markup engines build through this finalize, so the
|
|
3487
3626
|
// handle exists everywhere a split does. Pane keys keep
|
|
@@ -3492,7 +3631,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3492
3631
|
// into the neighbor.
|
|
3493
3632
|
const child_widgets = try self.arena.alloc(Widget, 3);
|
|
3494
3633
|
child_widgets[0] = try self.finalizeNode(node.nodes[0], widget.id, node.nodes[0].key orelse UiKey{ .index = 0 }, handlers, handler_len, tokens, key_trail);
|
|
3495
|
-
child_widgets[1] = splitDividerWidget(widget);
|
|
3634
|
+
child_widgets[1] = try self.splitDividerWidget(widget);
|
|
3496
3635
|
child_widgets[2] = try self.finalizeNode(node.nodes[1], widget.id, node.nodes[1].key orelse UiKey{ .index = 1 }, handlers, handler_len, tokens, key_trail);
|
|
3497
3636
|
child_widgets[0].layout.clip_content = true;
|
|
3498
3637
|
child_widgets[2].layout.clip_content = true;
|
|
@@ -3600,13 +3739,30 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3600
3739
|
/// native selection resolves.
|
|
3601
3740
|
fn appendContextMenuFallbackSurface(self: *Self, widget: *Widget, declared: []const ContextMenuItem) error{OutOfMemory}!void {
|
|
3602
3741
|
if (declared.len == 0) return;
|
|
3603
|
-
|
|
3742
|
+
var surface = if (self.construction_policy) |policy|
|
|
3743
|
+
(try construction.synthesize(policy, 2, false, false, false, 0, self.context_menu_fallback_point, self.arena)).widget
|
|
3744
|
+
else
|
|
3745
|
+
Widget{ .kind = .dropdown_menu, .semantics = .{ .label = "Context menu" } };
|
|
3746
|
+
const surface_id = structuralId(widget.id, surface.kind, UiKey{ .str = "context-menu" });
|
|
3747
|
+
surface.id = surface_id;
|
|
3748
|
+
surface.appearance_policy = widget.appearance_policy;
|
|
3604
3749
|
const item_widgets = try self.arena.alloc(Widget, declared.len);
|
|
3605
3750
|
const item_ids = try self.arena.alloc(ObjectId, declared.len);
|
|
3606
3751
|
for (declared, 0..) |item, index| {
|
|
3752
|
+
if (self.construction_policy) |policy| {
|
|
3753
|
+
const descriptor = try construction.synthesize(policy, 1, false, item.separator, item.enabled, 0, null, self.arena);
|
|
3754
|
+
var item_widget = descriptor.widget;
|
|
3755
|
+
item_widget.id = structuralId(surface_id, item_widget.kind, UiKey{ .int = @intCast(index) });
|
|
3756
|
+
item_widget.appearance_policy = widget.appearance_policy;
|
|
3757
|
+
if (descriptor.item_identity) item_widget.text = item.label;
|
|
3758
|
+
item_widgets[index] = item_widget;
|
|
3759
|
+
item_ids[index] = if (descriptor.item_identity) item_widget.id else 0;
|
|
3760
|
+
continue;
|
|
3761
|
+
}
|
|
3607
3762
|
if (item.separator) {
|
|
3608
3763
|
item_widgets[index] = .{
|
|
3609
3764
|
.kind = .separator,
|
|
3765
|
+
.appearance_policy = widget.appearance_policy,
|
|
3610
3766
|
.id = structuralId(surface_id, .separator, UiKey{ .int = @intCast(index) }),
|
|
3611
3767
|
};
|
|
3612
3768
|
item_ids[index] = 0;
|
|
@@ -3614,6 +3770,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3614
3770
|
}
|
|
3615
3771
|
var item_widget = Widget{
|
|
3616
3772
|
.kind = .menu_item,
|
|
3773
|
+
.appearance_policy = widget.appearance_policy,
|
|
3617
3774
|
.id = structuralId(surface_id, .menu_item, UiKey{ .int = @intCast(index) }),
|
|
3618
3775
|
.text = item.label,
|
|
3619
3776
|
.state = .{ .disabled = !item.enabled },
|
|
@@ -3622,19 +3779,14 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3622
3779
|
item_widgets[index] = item_widget;
|
|
3623
3780
|
item_ids[index] = item_widget.id;
|
|
3624
3781
|
}
|
|
3625
|
-
|
|
3626
|
-
.kind = .dropdown_menu,
|
|
3627
|
-
.id = surface_id,
|
|
3628
|
-
.semantics = .{ .label = "Context menu" },
|
|
3629
|
-
.children = item_widgets,
|
|
3630
|
-
};
|
|
3782
|
+
surface.children = item_widgets;
|
|
3631
3783
|
// Anchor at the recorded click point when the request carried
|
|
3632
3784
|
// one (offset 0: the surface corner sits at the pointer, the
|
|
3633
3785
|
// native-menu convention); the widget-edge anchor remains the
|
|
3634
3786
|
// pointer-less floor. Either way the anchored-surface edge
|
|
3635
3787
|
// rules apply: flip above the anchor when the surface would
|
|
3636
3788
|
// cross the bottom edge, clamp into the window.
|
|
3637
|
-
surface.layout.anchor = if (self.context_menu_fallback_point) |point|
|
|
3789
|
+
if (self.construction_policy == null) surface.layout.anchor = if (self.context_menu_fallback_point) |point|
|
|
3638
3790
|
.{ .placement = .below, .alignment = .start, .offset = 0, .point = point }
|
|
3639
3791
|
else
|
|
3640
3792
|
.{ .placement = .below, .alignment = .start };
|
|
@@ -3649,6 +3801,14 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3649
3801
|
};
|
|
3650
3802
|
}
|
|
3651
3803
|
|
|
3804
|
+
fn constructionHandlers(node: Node) u16 {
|
|
3805
|
+
var mask: u16 = 0;
|
|
3806
|
+
inline for (.{ "on_press", "on_drag", "on_double_press", "on_toggle", "on_hold", "on_hover_enter", "on_hover_leave", "on_input", "on_value", "on_change" }, 0..) |name, i| {
|
|
3807
|
+
if (@field(node, name) != null) mask |= @as(u16, 1) << @intCast(i);
|
|
3808
|
+
}
|
|
3809
|
+
return mask;
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3652
3812
|
fn appendHandler(handlers: []Handler, handler_len: *usize, id: ObjectId, event: UiHandlerEvent, msg: ?Msg) void {
|
|
3653
3813
|
const value = msg orelse return;
|
|
3654
3814
|
handlers[handler_len.*] = .{ .id = id, .event = event, .action = .{ .message = value } };
|
|
@@ -3749,7 +3909,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3749
3909
|
}
|
|
3750
3910
|
}
|
|
3751
3911
|
|
|
3752
|
-
fn widgetFromOptions(kind: WidgetKind, options: ElementOptions) Widget {
|
|
3912
|
+
fn widgetFromOptions(self: *Self, kind: WidgetKind, options: ElementOptions) Widget {
|
|
3753
3913
|
warnStackContainerGap(kind, options.gap);
|
|
3754
3914
|
warnUnknownIconName(options.icon);
|
|
3755
3915
|
warnInertScrollAxis(kind, .{ .virtualized = options.virtualized, .axis = options.axis, .value_x = options.value_x });
|
|
@@ -3760,6 +3920,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3760
3920
|
.transform = options.transform,
|
|
3761
3921
|
.text = options.text,
|
|
3762
3922
|
.placeholder = options.placeholder,
|
|
3923
|
+
.command = options.command,
|
|
3763
3924
|
.icon = options.icon,
|
|
3764
3925
|
.icon_placement = options.icon_placement,
|
|
3765
3926
|
.text_alignment = options.text_alignment,
|
|
@@ -3775,8 +3936,9 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3775
3936
|
.scroll_axes = options.axis,
|
|
3776
3937
|
.variant = options.variant,
|
|
3777
3938
|
.size = options.size,
|
|
3939
|
+
.backdrop_blur_token = options.backdrop_blur_token,
|
|
3778
3940
|
.state = .{
|
|
3779
|
-
.selected =
|
|
3941
|
+
.selected = false,
|
|
3780
3942
|
.expanded = options.expanded,
|
|
3781
3943
|
.disabled = options.disabled,
|
|
3782
3944
|
},
|
|
@@ -3800,15 +3962,6 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3800
3962
|
.virtual_anchor_index = options.virtual_anchor_index,
|
|
3801
3963
|
.virtual_anchor_extent = options.virtual_anchor_extent,
|
|
3802
3964
|
.virtual_total_extent = options.virtual_total_extent,
|
|
3803
|
-
.min_size = .{ .width = @max(options.width, options.min_width), .height = options.height },
|
|
3804
|
-
// Explicit sizes are definite (min AND max). Resizable
|
|
3805
|
-
// is the exception: width documents the initial width
|
|
3806
|
-
// and the engine's drag handle keeps writing larger
|
|
3807
|
-
// frames past it.
|
|
3808
|
-
.max_size = if (kind == .resizable) .{} else .{
|
|
3809
|
-
.width = if (options.width > 0) options.width else options.max_width,
|
|
3810
|
-
.height = options.height,
|
|
3811
|
-
},
|
|
3812
3965
|
},
|
|
3813
3966
|
.style = options.style,
|
|
3814
3967
|
.semantics = options.semantics,
|
|
@@ -3819,6 +3972,21 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3819
3972
|
.resize_origin = options.resize_origin,
|
|
3820
3973
|
.tooltip_delay_ms = options.tooltip_delay,
|
|
3821
3974
|
};
|
|
3975
|
+
if (self.construction_policy) |policy| {
|
|
3976
|
+
construction.element(policy, &widget, options);
|
|
3977
|
+
return widget;
|
|
3978
|
+
}
|
|
3979
|
+
widget.state.selected = options.checked or options.selected;
|
|
3980
|
+
widget.layout.min_size = .{ .width = @max(options.width, options.min_width), .height = options.height };
|
|
3981
|
+
// Authored sizes are definite; resizable width seeds a frame
|
|
3982
|
+
// that the drag capability may grow beyond that initial size.
|
|
3983
|
+
widget.layout.max_size = if (kind == .resizable) .{} else .{
|
|
3984
|
+
.width = if (options.width > 0) options.width else options.max_width,
|
|
3985
|
+
.height = options.height,
|
|
3986
|
+
};
|
|
3987
|
+
// A checked radio starts with the same canonical value as a
|
|
3988
|
+
// retained selection, so activating it is not a change edge.
|
|
3989
|
+
if (kind == .radio and widget.state.selected) widget.value = 1;
|
|
3822
3990
|
applyKindDefaultLayout(kind, options, &widget.layout);
|
|
3823
3991
|
return widget;
|
|
3824
3992
|
}
|
|
@@ -3828,11 +3996,20 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3828
3996
|
/// Its `value` is stamped with the EFFECTIVE fraction by the
|
|
3829
3997
|
/// layout pass; the authored value seeds keyboard steps before
|
|
3830
3998
|
/// the first layout.
|
|
3831
|
-
fn splitDividerWidget(split_widget: Widget) Widget {
|
|
3999
|
+
fn splitDividerWidget(self: *Self, split_widget: Widget) error{OutOfMemory}!Widget {
|
|
4000
|
+
if (self.construction_policy) |policy| {
|
|
4001
|
+
var result = (try construction.synthesize(policy, 0, split_widget.state.disabled, false, false, split_widget.value, null, self.arena)).widget;
|
|
4002
|
+
result.id = structuralId(split_widget.id, result.kind, UiKey{ .str = "divider" });
|
|
4003
|
+
result.interaction_policy = split_widget.interaction_policy;
|
|
4004
|
+
result.appearance_policy = split_widget.appearance_policy;
|
|
4005
|
+
return result;
|
|
4006
|
+
}
|
|
3832
4007
|
return .{
|
|
3833
4008
|
.kind = .split_divider,
|
|
3834
4009
|
.id = structuralId(split_widget.id, .split_divider, UiKey{ .str = "divider" }),
|
|
3835
4010
|
.value = split_widget.value,
|
|
4011
|
+
.interaction_policy = split_widget.interaction_policy,
|
|
4012
|
+
.appearance_policy = split_widget.appearance_policy,
|
|
3836
4013
|
.state = .{ .disabled = split_widget.state.disabled },
|
|
3837
4014
|
.semantics = .{ .label = "Split divider" },
|
|
3838
4015
|
};
|
|
@@ -3897,19 +4074,10 @@ fn isTextEntryWidget(widget: Widget) bool {
|
|
|
3897
4074
|
}
|
|
3898
4075
|
|
|
3899
4076
|
fn isSubmitKeyboard(widget: Widget, keyboard: canvas.WidgetKeyboardEvent) bool {
|
|
4077
|
+
if (canvas.isWidgetTextEntry(widget)) return canvas.widgetKeyboardTextSubmit(widget, keyboard);
|
|
3900
4078
|
if (widget.state.disabled or keyboard.phase != .key_down) return false;
|
|
3901
4079
|
if (!std.ascii.eqlIgnoreCase(keyboard.key, "enter")) return false;
|
|
3902
4080
|
return switch (widget.kind) {
|
|
3903
|
-
// Single-line entry: plain Enter submits.
|
|
3904
|
-
.text_field, .search_field, .input, .combobox => !keyboard.modifiers.hasNavigationModifier(),
|
|
3905
|
-
// Multi-line entry: Enter edits (newline), so submit rides the
|
|
3906
|
-
// primary chord — cmd+Enter on macOS, ctrl+Enter elsewhere.
|
|
3907
|
-
// Shift/alt variants stay free for apps.
|
|
3908
|
-
.textarea => if (widget.submit_on_enter)
|
|
3909
|
-
(!keyboard.modifiers.hasNavigationModifier() and !keyboard.modifiers.shift) or
|
|
3910
|
-
(keyboard.modifiers.hasCommandModifier() and !keyboard.modifiers.alt and !keyboard.modifiers.shift)
|
|
3911
|
-
else
|
|
3912
|
-
keyboard.modifiers.hasCommandModifier() and !keyboard.modifiers.alt and !keyboard.modifiers.shift,
|
|
3913
4081
|
// List rows: plain Enter is the row's primary action when the
|
|
3914
4082
|
// app binds `on_submit` (play the track, open the record); the
|
|
3915
4083
|
// select activation keeps Space. `msgForKeyboard` resolves the
|