@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
package/src/runtime/flow.zig
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
const builtin_coordination = @import("builtin_coordination_policy.zig");
|
|
2
|
+
const authorization = @import("authorization_policy.zig");
|
|
1
3
|
const std = @import("std");
|
|
2
4
|
const geometry = @import("geometry");
|
|
3
5
|
const trace = @import("trace");
|
|
4
6
|
const json = @import("json");
|
|
5
7
|
const validation = @import("validation.zig");
|
|
8
|
+
const command_policy = @import("command_policy.zig");
|
|
6
9
|
const runtime_api = @import("api.zig");
|
|
7
10
|
const runtime_async_bridge = @import("async_bridge.zig");
|
|
8
11
|
const runtime_automation_snapshot = @import("automation_snapshot.zig");
|
|
9
12
|
const runtime_automation_widget_dispatch = @import("automation_widget_dispatch.zig");
|
|
10
|
-
const automation_commands = @import("
|
|
13
|
+
const automation_commands = @import("automation_command_policy.zig");
|
|
11
14
|
const launch_timing = @import("launch_timing.zig");
|
|
12
15
|
const runtime_clock = @import("clock.zig");
|
|
13
16
|
const runtime_state = @import("state.zig");
|
|
@@ -25,6 +28,9 @@ const bridge = @import("../bridge/root.zig");
|
|
|
25
28
|
const extensions = @import("../extensions/root.zig");
|
|
26
29
|
const app_manifest = @import("app_manifest");
|
|
27
30
|
const platform = @import("../platform/root.zig");
|
|
31
|
+
const host_flow = @import("host_flow_policy.zig");
|
|
32
|
+
const native_reference = @import("flow_reference.zig");
|
|
33
|
+
const HostEventPump = @import("host_event_pump.zig").HostEventPump;
|
|
28
34
|
const security = @import("../security/root.zig");
|
|
29
35
|
|
|
30
36
|
const validateCommandName = validation.validateCommandName;
|
|
@@ -59,6 +65,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
59
65
|
const RunContext = struct {
|
|
60
66
|
runtime: *Runtime,
|
|
61
67
|
app: App,
|
|
68
|
+
host_events: HostEventPump,
|
|
62
69
|
};
|
|
63
70
|
|
|
64
71
|
fn WindowViewMethods() type {
|
|
@@ -90,6 +97,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
pub fn run(self: *Runtime, app: App) anyerror!void {
|
|
100
|
+
const policy = app.host_flow_policy orelse return native_reference.RuntimeFlow(Runtime).run(self, app);
|
|
93
101
|
var init_fields: [3]trace.Field = undefined;
|
|
94
102
|
init_fields[0] = trace.string("app", app.name);
|
|
95
103
|
init_fields[1] = trace.string("platform", self.options.platform.name);
|
|
@@ -99,81 +107,58 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
99
107
|
init_field_count += 1;
|
|
100
108
|
}
|
|
101
109
|
log(self, "runtime.init", "runtime initialized", init_fields[0..init_field_count]);
|
|
102
|
-
try app_manifest.validateCommands(self.options.commands);
|
|
103
|
-
try self.options.platform.services.configureSecurityPolicy(self.options.security);
|
|
104
|
-
try self.options.platform.services.configureMenus(self.options.menus);
|
|
105
|
-
try self.options.platform.services.configureShortcuts(self.options.shortcuts);
|
|
106
|
-
// Automation liveness: the drain (`consumeAutomationCommand`,
|
|
107
|
-
// in `frame` below) runs at most once per frame_requested
|
|
108
|
-
// turn, and an idle app produces no frames — so a queued
|
|
109
|
-
// command must WAKE the loop the way user input does. The
|
|
110
|
-
// arrival watcher polls the dropbox slot on its own thread
|
|
111
|
-
// and asks the platform for one coalesced frame tick through
|
|
112
|
-
// its thread-safe `request_frame_fn` whenever a command is
|
|
113
|
-
// pending. Consumption itself stays on the frame boundary,
|
|
114
|
-
// so command order, one-command-per-frame, and session
|
|
115
|
-
// recording/replay (commands nest inside recorded
|
|
116
|
-
// frame_requested events) are unchanged; only the frame's
|
|
117
|
-
// ARRIVAL time moves. No automation server (any non-dev
|
|
118
|
-
// build) means no thread and no polls at all.
|
|
119
110
|
var command_watcher: automation.Watcher = undefined;
|
|
120
111
|
var command_watcher_running = false;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
var cleanup_armed = false;
|
|
113
|
+
var context: RunContext = .{ .runtime = self, .app = app, .host_events = .{ .allocator = self.owned_allocator, .policy = policy } };
|
|
114
|
+
defer if (cleanup_armed) {
|
|
115
|
+
const cleanup = host_flow.plan(policy, .cleanup, .{ .a = @intFromBool(self.app_stop_delivered), .b = @intFromBool(command_watcher_running) });
|
|
116
|
+
for (cleanup) |action| switch (action) {
|
|
117
|
+
0 => break,
|
|
118
|
+
1 => context.host_events.deinit(),
|
|
119
|
+
2 => {
|
|
120
|
+
self.app_stop_delivered = true;
|
|
121
|
+
app.stop(self) catch |err| log(self, "app.stop.failed", @errorName(err), &.{trace.string("app", app.name)});
|
|
122
|
+
},
|
|
123
|
+
3 => self.disarmMediaSurfaceWakes(),
|
|
124
|
+
4 => command_watcher.stop(),
|
|
125
|
+
else => unreachable,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const program = host_flow.plan(policy, .run, .{});
|
|
129
|
+
for (program) |action| switch (action) {
|
|
130
|
+
0 => break,
|
|
131
|
+
1 => if (app.command_policy) |commands| try command_policy.catalog(commands, self.options.commands) else try app_manifest.validateCommands(self.options.commands),
|
|
132
|
+
2 => try self.options.platform.services.configureSecurityPolicy(self.options.security),
|
|
133
|
+
3 => try self.options.platform.services.configureMenus(self.options.menus),
|
|
134
|
+
4 => try self.options.platform.services.configureShortcuts(self.options.shortcuts),
|
|
135
|
+
5 => {
|
|
136
|
+
const watcher_admission = host_flow.gate(policy, 4, @intFromBool(self.options.automation != null), @intFromBool(self.options.platform.services.request_frame_fn != null));
|
|
137
|
+
if (watcher_admission != 0) {
|
|
138
|
+
const server = self.options.automation.?;
|
|
139
|
+
if (watcher_admission == 1) {
|
|
140
|
+
const request_fn = self.options.platform.services.request_frame_fn.?;
|
|
141
|
+
command_watcher_running = command_watcher.start(server, .{
|
|
142
|
+
.context = self.options.platform.services.context,
|
|
143
|
+
.request_fn = request_fn,
|
|
144
|
+
});
|
|
145
|
+
if (host_flow.gate(policy, 5, @intFromBool(command_watcher_running), 0) != 0) {
|
|
146
|
+
log(self, "automation.watcher_failed", "automation command watcher thread did not start; commands drain on the next unrelated frame", &.{});
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
// A platform without the cross-thread frame request
|
|
150
|
+
// keeps the old behavior (commands drain on whatever
|
|
151
|
+
// frame arrives next); say so once instead of wedging
|
|
152
|
+
// silently.
|
|
153
|
+
log(self, "automation.watcher_unsupported", "platform has no cross-thread frame request; automation commands drain on the next unrelated frame", &.{});
|
|
154
|
+
}
|
|
129
155
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
log(self, "automation.watcher_unsupported", "platform has no cross-thread frame request; automation commands drain on the next unrelated frame", &.{});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// Stopped (joined) before the platform loop's resources go
|
|
139
|
-
// away, so the watcher can never call into a dead host.
|
|
140
|
-
defer if (command_watcher_running) command_watcher.stop();
|
|
141
|
-
|
|
142
|
-
// Media-surface wake teardown: producers a slow app forgot
|
|
143
|
-
// to release may push (and try to wake this platform) at
|
|
144
|
-
// any later time from their own threads. Disarm their wake
|
|
145
|
-
// bindings before the caller's later-declared defers tear
|
|
146
|
-
// the host down — declared BEFORE the app-stop defer below
|
|
147
|
-
// so it runs AFTER the stop hook (LIFO), letting the hook
|
|
148
|
-
// join producer threads first. The same run-exit ordering
|
|
149
|
-
// that stops the automation arrival watcher.
|
|
150
|
-
defer self.disarmMediaSurfaceWakes();
|
|
151
|
-
|
|
152
|
-
// Teardown ordering contract: everything the app must do
|
|
153
|
-
// against the live platform — silencing an active audio
|
|
154
|
-
// player, disarming platform timers, joining effect workers
|
|
155
|
-
// that post through the platform's wake service — happens in
|
|
156
|
-
// the app's stop hook, and that hook is guaranteed to run
|
|
157
|
-
// before run() returns. The app's OWN deinit cannot serve
|
|
158
|
-
// this purpose: it is typically a `defer` in main that runs
|
|
159
|
-
// only after the runner's later-declared defers have already
|
|
160
|
-
// destroyed the platform host and freed the runtime, so any
|
|
161
|
-
// platform service call from there dereferences freed memory
|
|
162
|
-
// (the quit-while-audio-plays use-after-free). The platform's
|
|
163
|
-
// `.app_shutdown` event delivers the stop hook on the normal
|
|
164
|
-
// quit path; this defer delivers it when the loop exits any
|
|
165
|
-
// other way (an error unwind, a host that stops without a
|
|
166
|
-
// shutdown event) — exactly once either way, gated by
|
|
167
|
-
// `app_stop_delivered`.
|
|
168
|
-
defer if (!self.app_stop_delivered) {
|
|
169
|
-
self.app_stop_delivered = true;
|
|
170
|
-
app.stop(self) catch |err| log(self, "app.stop.failed", @errorName(err), &.{trace.string("app", app.name)});
|
|
156
|
+
cleanup_armed = true;
|
|
157
|
+
},
|
|
158
|
+
6 => try self.options.platform.run(handlePlatformEvent, &context),
|
|
159
|
+
7 => log(self, "runtime.done", "runtime finished", &.{}),
|
|
160
|
+
else => unreachable,
|
|
171
161
|
};
|
|
172
|
-
|
|
173
|
-
var context: RunContext = .{ .runtime = self, .app = app };
|
|
174
|
-
try self.options.platform.run(handlePlatformEvent, &context);
|
|
175
|
-
|
|
176
|
-
log(self, "runtime.done", "runtime finished", &.{});
|
|
177
162
|
}
|
|
178
163
|
|
|
179
164
|
fn reservePrimaryStartupWindow(self: *Runtime) anyerror!void {
|
|
@@ -202,93 +187,140 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
202
187
|
}
|
|
203
188
|
|
|
204
189
|
pub fn dispatchPlatformEvent(self: *Runtime, app: App, event_value: platform.Event) anyerror!void {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
recorder.commitEvent();
|
|
214
|
-
if (recorder.wantsCheckpoint(self.frame_index)) {
|
|
215
|
-
recorder.recordCheckpoint(self.frame_index, self.sessionStateFingerprint());
|
|
216
|
-
}
|
|
217
|
-
// Seal on shutdown, here rather than only at run() exit:
|
|
218
|
-
// a host that terminates without unwinding the platform
|
|
219
|
-
// loop still leaves a whole journal behind.
|
|
220
|
-
if (event_value == .app_shutdown) recorder.finish();
|
|
190
|
+
const policy = app.host_flow_policy orelse return native_reference.RuntimeFlow(Runtime).dispatchPlatformEvent(self, app, event_value);
|
|
191
|
+
const kind = host_flow.eventKind(event_value);
|
|
192
|
+
const entry = host_flow.plan(policy, .journal_enter, .{ .kind = kind, .a = @intFromBool(self.options.session_recorder != null), .b = @intFromBool(self.invalidated) });
|
|
193
|
+
for (entry) |action| switch (action) {
|
|
194
|
+
0 => break,
|
|
195
|
+
1 => self.options.session_recorder.?.stageEvent(event_value),
|
|
196
|
+
2 => log(self, "platform.event", null, &.{trace.string("event", event_value.name())}),
|
|
197
|
+
else => unreachable,
|
|
221
198
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
199
|
+
defer {
|
|
200
|
+
const exit = host_flow.plan(policy, .journal_exit, .{ .kind = kind, .a = @intFromBool(self.options.session_recorder != null) });
|
|
201
|
+
for (exit) |action| switch (action) {
|
|
202
|
+
0 => break,
|
|
203
|
+
1 => self.options.session_recorder.?.commitEvent(),
|
|
204
|
+
2 => {
|
|
205
|
+
const recorder = self.options.session_recorder.?;
|
|
206
|
+
if (recorder.wantsCheckpoint(self.frame_index)) recorder.recordCheckpoint(self.frame_index, self.sessionStateFingerprint());
|
|
207
|
+
},
|
|
208
|
+
3 => self.options.session_recorder.?.finish(),
|
|
209
|
+
else => unreachable,
|
|
210
|
+
};
|
|
226
211
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
212
|
+
errdefer |err| if (host_flow.gate(policy, 9, kind, 0) != 0) recordDispatchError(self, "app_start", err);
|
|
213
|
+
const program = host_flow.plan(policy, .platform_event, .{ .kind = kind });
|
|
214
|
+
var scene_value: ?app_manifest.ShellConfig = null;
|
|
215
|
+
var was_open = false;
|
|
216
|
+
var routed_drop: ?runtime_api.CanvasWidgetFileDropEvent = null;
|
|
217
|
+
for (program) |byte| switch (@as(host_flow.Action, @enumFromInt(byte))) {
|
|
218
|
+
.end => break,
|
|
219
|
+
.install => {
|
|
220
|
+
self.shell_layout_policy = app.shell_layout_policy;
|
|
221
|
+
self.view_coordination_policy = app.view_coordination_policy;
|
|
222
|
+
self.window_lifecycle_policy = app.window_lifecycle_policy;
|
|
223
|
+
self.image_registry_policy = app.image_registry_policy;
|
|
224
|
+
self.font_registry_policy = app.font_registry_policy;
|
|
225
|
+
self.shell_coordination_policy = app.shell_coordination_policy;
|
|
226
|
+
self.shell_admission_policy = app.shell_admission_policy;
|
|
227
|
+
self.system_admission_policy = app.system_admission_policy;
|
|
228
|
+
self.bridge_descriptor_policy = app.bridge_descriptor_policy;
|
|
229
|
+
self.authorization_policy = app.authorization_policy;
|
|
230
|
+
self.builtin_coordination_policy = app.builtin_coordination_policy;
|
|
231
|
+
self.automation_command_policy = app.automation_command_policy;
|
|
232
|
+
self.automation_interaction_policy = app.automation_interaction_policy;
|
|
233
|
+
self.snapshot_policy = app.snapshot_policy;
|
|
234
|
+
self.frame_profile.policy = app.snapshot_policy;
|
|
235
|
+
self.command_policy = app.command_policy;
|
|
236
|
+
self.context_menu_policy = app.context_menu_policy;
|
|
237
|
+
self.text_cache_policy = app.text_cache_policy;
|
|
238
|
+
self.render_cache_policy = app.render_cache_policy;
|
|
239
|
+
self.render_plan_policy = app.render_plan_policy;
|
|
240
|
+
self.render_override_policy = app.render_override_policy;
|
|
241
|
+
self.render_damage_policy = app.render_damage_policy;
|
|
242
|
+
self.host_flow_policy = app.host_flow_policy;
|
|
243
|
+
},
|
|
244
|
+
.lap_start => {
|
|
236
245
|
launch_timing.lap("app_start");
|
|
246
|
+
},
|
|
247
|
+
.reserve => {
|
|
237
248
|
try reservePrimaryStartupWindow(self);
|
|
249
|
+
},
|
|
250
|
+
.start => {
|
|
238
251
|
try app.start(self);
|
|
252
|
+
},
|
|
253
|
+
.extensions_start => {
|
|
239
254
|
if (self.options.extensions) |registry| try registry.startAll(extensionContext(self));
|
|
255
|
+
},
|
|
256
|
+
.lifecycle_start => {
|
|
240
257
|
try dispatchEvent(self, app, .{ .lifecycle = .start });
|
|
258
|
+
},
|
|
259
|
+
.lap_started => {
|
|
241
260
|
launch_timing.lap("app_started");
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
261
|
+
},
|
|
262
|
+
.scene => {
|
|
263
|
+
scene_value = try app.scene();
|
|
264
|
+
},
|
|
265
|
+
.load => {
|
|
266
|
+
if (host_flow.gate(policy, 8, @intFromBool(scene_value != null), 0) != 0) try loadScene(self, app, scene_value.?) else try loadStartupWindows(self, app);
|
|
267
|
+
},
|
|
268
|
+
.lap_loaded => {
|
|
247
269
|
launch_timing.lap("scene_loaded");
|
|
270
|
+
},
|
|
271
|
+
.startup_dirty => {
|
|
248
272
|
self.invalidateFor(.startup, null);
|
|
273
|
+
},
|
|
274
|
+
.start_log => {
|
|
249
275
|
log(self, "app.start", "app started", &.{trace.string("app", app.name)});
|
|
250
276
|
},
|
|
251
|
-
.
|
|
277
|
+
.activate => {
|
|
252
278
|
try WindowViewMethods().setAppActive(self, true);
|
|
253
|
-
try dispatchEvent(self, app, .{ .lifecycle = .activate });
|
|
254
|
-
emitAppLifecycleEvent(self, "app:activate") catch |err| log(self, "app.activate.emit_failed", @errorName(err), &.{});
|
|
255
279
|
},
|
|
256
|
-
.
|
|
257
|
-
// The app-active register flips FIRST — before the
|
|
258
|
-
// tooltip reset and before the app hears the
|
|
259
|
-
// lifecycle event — so a model that rebuilds FROM
|
|
260
|
-
// its deactivation callback adopts under a runtime
|
|
261
|
-
// that already knows the app is inactive: the
|
|
262
|
-
// adoption arm's reveal/arm paths are gated on this
|
|
263
|
-
// register and stay silent.
|
|
280
|
+
.deactivate => {
|
|
264
281
|
try WindowViewMethods().setAppActive(self, false);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
// the app hears the lifecycle event, so a model that
|
|
268
|
-
// rebuilds on deactivate adopts against clean
|
|
269
|
-
// tooltip state instead of a stale shown slot.
|
|
282
|
+
},
|
|
283
|
+
.tooltip_reset => {
|
|
270
284
|
try CanvasWidgetEventMethods().resetCanvasTooltipIntentForAppDeactivation(self);
|
|
285
|
+
},
|
|
286
|
+
.lifecycle_activate => {
|
|
287
|
+
try dispatchEvent(self, app, .{ .lifecycle = .activate });
|
|
288
|
+
},
|
|
289
|
+
.lifecycle_deactivate => {
|
|
271
290
|
try dispatchEvent(self, app, .{ .lifecycle = .deactivate });
|
|
291
|
+
},
|
|
292
|
+
.emit_activate => {
|
|
293
|
+
emitAppLifecycleEvent(self, "app:activate") catch |err| log(self, "app.activate.emit_failed", @errorName(err), &.{});
|
|
294
|
+
},
|
|
295
|
+
.emit_deactivate => {
|
|
272
296
|
emitAppLifecycleEvent(self, "app:deactivate") catch |err| log(self, "app.deactivate.emit_failed", @errorName(err), &.{});
|
|
273
297
|
},
|
|
274
|
-
.
|
|
275
|
-
self.appearance =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// advance batches and retained wrap results must miss
|
|
279
|
-
// rather than serve metrics measured under the
|
|
280
|
-
// previous appearance.
|
|
298
|
+
.appearance => {
|
|
299
|
+
self.appearance = event_value.appearance_changed;
|
|
300
|
+
},
|
|
301
|
+
.text_generation => {
|
|
281
302
|
canvas.bumpTextMeasureGeneration();
|
|
282
|
-
try dispatchEvent(self, app, .{ .appearance_changed = appearance });
|
|
283
303
|
},
|
|
284
|
-
.
|
|
285
|
-
self.
|
|
304
|
+
.appearance_event => {
|
|
305
|
+
try dispatchEvent(self, app, .{ .appearance_changed = event_value.appearance_changed });
|
|
306
|
+
},
|
|
307
|
+
.surface => {
|
|
308
|
+
self.surface = event_value.surface_resized;
|
|
309
|
+
},
|
|
310
|
+
.surface_window => {
|
|
311
|
+
const surface_value = event_value.surface_resized;
|
|
286
312
|
if (WindowViewMethods().findWindowIndexById(self, surface_value.id)) |index| {
|
|
287
313
|
self.windows[index].info.frame.width = surface_value.size.width;
|
|
288
314
|
self.windows[index].info.frame.height = surface_value.size.height;
|
|
289
315
|
self.windows[index].info.scale_factor = surface_value.scale_factor;
|
|
290
316
|
}
|
|
317
|
+
},
|
|
318
|
+
.surface_layout => {
|
|
319
|
+
const surface_value = event_value.surface_resized;
|
|
291
320
|
WindowViewMethods().relayoutShellViews(self, surface_value.id) catch |err| log(self, "shell.relayout_failed", @errorName(err), &.{trace.uint("window_id", surface_value.id)});
|
|
321
|
+
},
|
|
322
|
+
.surface_emit => {
|
|
323
|
+
const surface_value = event_value.surface_resized;
|
|
292
324
|
var detail_buffer: [512]u8 = undefined;
|
|
293
325
|
var detail_writer = std.Io.Writer.fixed(&detail_buffer);
|
|
294
326
|
try detail_writer.print("{{\"width\":{d},\"height\":{d},\"scale\":{d},\"safeAreaInsets\":{{\"top\":{d},\"right\":{d},\"bottom\":{d},\"left\":{d}}},\"keyboardInsets\":{{\"top\":{d},\"right\":{d},\"bottom\":{d},\"left\":{d}}}}}", .{
|
|
@@ -305,7 +337,12 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
305
337
|
surface_value.keyboard_insets.left,
|
|
306
338
|
});
|
|
307
339
|
emitWindowEvent(self, surface_value.id, "resize", detail_writer.buffered()) catch |err| log(self, "window.resize.emit_failed", @errorName(err), &.{});
|
|
308
|
-
|
|
340
|
+
},
|
|
341
|
+
.surface_dirty => {
|
|
342
|
+
self.invalidateFor(.surface_resize, geometry.RectF.fromSize(event_value.surface_resized.size));
|
|
343
|
+
},
|
|
344
|
+
.surface_log => {
|
|
345
|
+
const surface_value = event_value.surface_resized;
|
|
309
346
|
const fields = [_]trace.Field{
|
|
310
347
|
trace.float("width", surface_value.size.width),
|
|
311
348
|
trace.float("height", surface_value.size.height),
|
|
@@ -313,18 +350,26 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
313
350
|
};
|
|
314
351
|
log(self, "surface.resize", "surface updated", &fields);
|
|
315
352
|
},
|
|
316
|
-
.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const was_open = if (WindowViewMethods().findWindowIndexById(self, state.id)) |index| self.windows[index].info.open else false;
|
|
353
|
+
.capture_open => {
|
|
354
|
+
const state = event_value.window_frame_changed;
|
|
355
|
+
was_open = if (WindowViewMethods().findWindowIndexById(self, state.id)) |index| self.windows[index].info.open else false;
|
|
356
|
+
},
|
|
357
|
+
.window_update => {
|
|
358
|
+
const state = event_value.window_frame_changed;
|
|
323
359
|
WindowViewMethods().updateWindowState(self, state) catch |err| log(self, "window.state.update_failed", @errorName(err), &.{trace.string("label", state.label)});
|
|
360
|
+
},
|
|
361
|
+
.window_layout => {
|
|
362
|
+
const state = event_value.window_frame_changed;
|
|
324
363
|
WindowViewMethods().relayoutShellViews(self, state.id) catch |err| log(self, "shell.relayout_failed", @errorName(err), &.{trace.uint("window_id", state.id)});
|
|
364
|
+
},
|
|
365
|
+
.window_save => {
|
|
366
|
+
const state = event_value.window_frame_changed;
|
|
325
367
|
if (self.options.window_state_store) |store| {
|
|
326
368
|
store.saveWindow(WindowViewMethods().runtimeWindowStateForPersistence(self, state)) catch |err| log(self, "window.state.save_failed", @errorName(err), &.{trace.string("label", state.label)});
|
|
327
369
|
}
|
|
370
|
+
},
|
|
371
|
+
.window_log => {
|
|
372
|
+
const state = event_value.window_frame_changed;
|
|
328
373
|
log(self, "window.frame", "window frame updated", &.{
|
|
329
374
|
trace.string("label", state.label),
|
|
330
375
|
trace.float("x", state.frame.x),
|
|
@@ -332,38 +377,94 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
332
377
|
trace.float("width", state.frame.width),
|
|
333
378
|
trace.float("height", state.frame.height),
|
|
334
379
|
});
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
// comes from runtime storage, which outlives the
|
|
340
|
-
// event's transient slices.
|
|
380
|
+
},
|
|
381
|
+
.window_close => {
|
|
382
|
+
const state = event_value.window_frame_changed;
|
|
383
|
+
if (host_flow.gate(policy, 1, @intFromBool(was_open), @intFromBool(state.open)) != 0) {
|
|
341
384
|
const label = if (WindowViewMethods().findWindowIndexById(self, state.id)) |index| self.windows[index].info.label else state.label;
|
|
342
385
|
try dispatchEvent(self, app, .{ .window_closed = .{ .window_id = state.id, .label = label } });
|
|
343
386
|
}
|
|
344
387
|
},
|
|
345
|
-
.
|
|
346
|
-
|
|
347
|
-
// window LOSING key here also drops its views'
|
|
348
|
-
// tooltip conversations there.
|
|
388
|
+
.focus_window => {
|
|
389
|
+
const window_id = event_value.window_focused;
|
|
349
390
|
if (WindowViewMethods().findWindowIndexById(self, window_id)) |index| try WindowViewMethods().setFocusedIndex(self, index);
|
|
391
|
+
},
|
|
392
|
+
.dirty => {
|
|
350
393
|
self.invalidated = true;
|
|
351
394
|
},
|
|
352
|
-
.
|
|
353
|
-
|
|
354
|
-
// their pointer stream, so the host reports the
|
|
355
|
-
// focus edge explicitly. Keep the canvas widget id
|
|
356
|
-
// as per-view focus memory while its view blurs:
|
|
357
|
-
// inactive terminal/text carets paint honestly, and
|
|
358
|
-
// clicking back into the canvas resumes its normal
|
|
359
|
-
// pointer-driven widget focus path.
|
|
395
|
+
.focus_view => {
|
|
396
|
+
const focus = event_value.view_focused;
|
|
360
397
|
try WindowViewMethods().setFocusedView(self, focus.window_id, focus.label);
|
|
361
|
-
self.invalidated = true;
|
|
362
398
|
},
|
|
363
|
-
.
|
|
364
|
-
|
|
365
|
-
|
|
399
|
+
.frame => {
|
|
400
|
+
try frame(self, app);
|
|
401
|
+
},
|
|
402
|
+
.bridge => {
|
|
403
|
+
try handleBridgeMessage(self, app, event_value.bridge_message);
|
|
404
|
+
},
|
|
405
|
+
.tray_log => {
|
|
406
|
+
const action = event_value.tray_action;
|
|
366
407
|
log(self, "tray.action", "tray item selected", &.{ trace.uint("status_item_id", action.status_item_id), trace.uint("item_id", action.item_id) });
|
|
408
|
+
},
|
|
409
|
+
.shortcut_event => {
|
|
410
|
+
try dispatchEvent(self, app, .{ .shortcut = event_value.shortcut });
|
|
411
|
+
},
|
|
412
|
+
.shortcut_emit => {
|
|
413
|
+
const shortcut = event_value.shortcut;
|
|
414
|
+
emitShortcutEvent(self, shortcut) catch |err| log(self, "shortcut.emit_failed", @errorName(err), &.{trace.string("id", shortcut.id)});
|
|
415
|
+
},
|
|
416
|
+
.command_dirty => {
|
|
417
|
+
self.invalidateFor(.command, null);
|
|
418
|
+
},
|
|
419
|
+
.gpu_resize_log => {
|
|
420
|
+
const resize_event = event_value.gpu_surface_resized;
|
|
421
|
+
log(self, "gpu_surface.resize", "gpu surface resized", &.{
|
|
422
|
+
trace.string("label", resize_event.label),
|
|
423
|
+
trace.float("width", resize_event.frame.width),
|
|
424
|
+
trace.float("height", resize_event.frame.height),
|
|
425
|
+
trace.float("scale", resize_event.scale_factor),
|
|
426
|
+
});
|
|
427
|
+
},
|
|
428
|
+
.drop_route => {
|
|
429
|
+
const drop = event_value.files_dropped;
|
|
430
|
+
routed_drop = self.routeCanvasWidgetFileDrop(drop, &self.widget_event_route_entries) catch |err| blk: {
|
|
431
|
+
const refusal: u8 = switch (err) {
|
|
432
|
+
error.WindowNotFound => 1,
|
|
433
|
+
error.ViewNotFound => 2,
|
|
434
|
+
error.InvalidViewOptions => 3,
|
|
435
|
+
else => 4,
|
|
436
|
+
};
|
|
437
|
+
if (host_flow.gate(policy, 7, refusal, 0) == 0) return @as(anyerror!void, err);
|
|
438
|
+
break :blk null;
|
|
439
|
+
};
|
|
440
|
+
},
|
|
441
|
+
.drop_widget => {
|
|
442
|
+
if (host_flow.gate(policy, 8, @intFromBool(routed_drop != null), 0) != 0) try dispatchEvent(self, app, .{ .canvas_widget_file_drop = routed_drop.? });
|
|
443
|
+
},
|
|
444
|
+
.drop_event => {
|
|
445
|
+
try dispatchEvent(self, app, .{ .files_dropped = event_value.files_dropped });
|
|
446
|
+
},
|
|
447
|
+
.drop_emit => {
|
|
448
|
+
const drop = event_value.files_dropped;
|
|
449
|
+
emitFileDropEvent(self, drop) catch |err| log(self, "drop.files.emit_failed", @errorName(err), &.{trace.uint("window_id", drop.window_id)});
|
|
450
|
+
},
|
|
451
|
+
.lifecycle_stop => {
|
|
452
|
+
try dispatchEvent(self, app, .{ .lifecycle = .stop });
|
|
453
|
+
},
|
|
454
|
+
.extensions_stop => {
|
|
455
|
+
if (self.options.extensions) |registry| try registry.stopAll(extensionContext(self));
|
|
456
|
+
},
|
|
457
|
+
.mark_stop => {
|
|
458
|
+
self.app_stop_delivered = true;
|
|
459
|
+
},
|
|
460
|
+
.stop => {
|
|
461
|
+
try app.stop(self);
|
|
462
|
+
},
|
|
463
|
+
.stop_log => {
|
|
464
|
+
log(self, "app.stop", "app stopped", &.{trace.string("app", app.name)});
|
|
465
|
+
},
|
|
466
|
+
.command_tray_action => {
|
|
467
|
+
const action = event_value.tray_action;
|
|
367
468
|
try dispatchCommand(self, app, .{
|
|
368
469
|
.name = SystemServiceMethods().statusItemCommandNameForItem(self, action.status_item_id, action.item_id),
|
|
369
470
|
.source = .tray,
|
|
@@ -371,17 +472,16 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
371
472
|
.tray_item_id = action.item_id,
|
|
372
473
|
});
|
|
373
474
|
},
|
|
374
|
-
.
|
|
475
|
+
.command_shortcut => {
|
|
476
|
+
const shortcut = event_value.shortcut;
|
|
375
477
|
try dispatchCommand(self, app, .{
|
|
376
478
|
.name = shortcut.id,
|
|
377
479
|
.source = .shortcut,
|
|
378
480
|
.window_id = shortcut.window_id,
|
|
379
481
|
});
|
|
380
|
-
try dispatchEvent(self, app, .{ .shortcut = shortcut });
|
|
381
|
-
emitShortcutEvent(self, shortcut) catch |err| log(self, "shortcut.emit_failed", @errorName(err), &.{trace.string("id", shortcut.id)});
|
|
382
|
-
self.invalidateFor(.command, null);
|
|
383
482
|
},
|
|
384
|
-
.
|
|
483
|
+
.command_native_command => {
|
|
484
|
+
const command = event_value.native_command;
|
|
385
485
|
try dispatchCommand(self, app, .{
|
|
386
486
|
.name = command.name,
|
|
387
487
|
.source = WindowViewMethods().commandSourceForNativeView(self, command.window_id, command.view_label),
|
|
@@ -389,64 +489,16 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
389
489
|
.view_label = command.view_label,
|
|
390
490
|
});
|
|
391
491
|
},
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
// `dispatchPlatformEvent` reaches the platform callback,
|
|
395
|
-
// latches its failure flag, and exits the whole app — so a
|
|
396
|
-
// runtime-side capacity or render fault on a keystroke,
|
|
397
|
-
// click, scroll, resize, or frame tick must land in the
|
|
398
|
-
// dispatch-error ring (loud, queryable, traced at `.err`)
|
|
399
|
-
// while the app keeps running. The failing interaction is
|
|
400
|
-
// refused; the next one starts clean. The TestHarness's
|
|
401
|
-
// `.propagate` policy still returns the error so tests
|
|
402
|
-
// fail loud instead of leaving silent stale frames.
|
|
403
|
-
.gpu_surface_frame => |frame_event| GpuSurfaceEventMethods().dispatchGpuSurfaceFrame(self, app, frame_event) catch |err| {
|
|
404
|
-
recordDispatchError(self, "gpu_surface_frame", err);
|
|
405
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
406
|
-
},
|
|
407
|
-
.gpu_surface_resized => |resize_event| {
|
|
408
|
-
GpuSurfaceEventMethods().dispatchGpuSurfaceResized(self, app, resize_event) catch |err| {
|
|
409
|
-
recordDispatchError(self, "gpu_surface_resized", err);
|
|
410
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
411
|
-
};
|
|
412
|
-
log(self, "gpu_surface.resize", "gpu surface resized", &.{
|
|
413
|
-
trace.string("label", resize_event.label),
|
|
414
|
-
trace.float("width", resize_event.frame.width),
|
|
415
|
-
trace.float("height", resize_event.frame.height),
|
|
416
|
-
trace.float("scale", resize_event.scale_factor),
|
|
417
|
-
});
|
|
418
|
-
},
|
|
419
|
-
.gpu_surface_input => |input_event| GpuSurfaceEventMethods().dispatchGpuSurfaceInput(self, app, input_event) catch |err| {
|
|
420
|
-
recordDispatchError(self, "gpu_surface_input", err);
|
|
421
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
422
|
-
},
|
|
423
|
-
.gpu_surface_scroll_driver => |driver_event| ScrollDriverMethods().dispatchGpuSurfaceScrollDriver(self, app, driver_event) catch |err| {
|
|
424
|
-
recordDispatchError(self, "gpu_surface_scroll_driver", err);
|
|
425
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
426
|
-
},
|
|
427
|
-
.context_menu_action => |action_event| ContextMenuMethods().dispatchContextMenuAction(self, app, action_event) catch |err| {
|
|
428
|
-
recordDispatchError(self, "context_menu_action", err);
|
|
429
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
430
|
-
},
|
|
431
|
-
.widget_accessibility_action => |action_event| {
|
|
432
|
-
_ = self.dispatchCanvasWidgetAccessibilityAction(app, action_event.window_id, action_event.label, .{
|
|
433
|
-
.id = action_event.id,
|
|
434
|
-
.action = canvasWidgetAccessibilityActionKindFromPlatform(action_event.action),
|
|
435
|
-
.text = action_event.text,
|
|
436
|
-
.selection = if (action_event.selection) |selection| .{ .anchor = selection.start, .focus = selection.end } else null,
|
|
437
|
-
}) catch |err| {
|
|
438
|
-
recordDispatchError(self, "widget_accessibility_action", err);
|
|
439
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
440
|
-
};
|
|
441
|
-
},
|
|
442
|
-
.menu_command => |command| {
|
|
492
|
+
.command_menu_command => {
|
|
493
|
+
const command = event_value.menu_command;
|
|
443
494
|
try dispatchCommand(self, app, .{
|
|
444
495
|
.name = command.name,
|
|
445
496
|
.source = .menu,
|
|
446
497
|
.window_id = command.window_id,
|
|
447
498
|
});
|
|
448
499
|
},
|
|
449
|
-
.
|
|
500
|
+
.command_tray_command => {
|
|
501
|
+
const command = event_value.tray_command;
|
|
450
502
|
try dispatchCommand(self, app, .{
|
|
451
503
|
.name = command.name,
|
|
452
504
|
.source = .tray,
|
|
@@ -454,126 +506,103 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
454
506
|
.status_item_id = command.status_item_id,
|
|
455
507
|
});
|
|
456
508
|
},
|
|
457
|
-
.
|
|
509
|
+
.command_notification_command => {
|
|
510
|
+
const command = event_value.notification_command;
|
|
458
511
|
try dispatchCommand(self, app, .{
|
|
459
512
|
.name = command.name,
|
|
460
513
|
.source = .notification,
|
|
461
514
|
.window_id = command.window_id,
|
|
462
515
|
});
|
|
463
516
|
},
|
|
464
|
-
.
|
|
465
|
-
try dispatchEvent(self, app, .{ .timer =
|
|
517
|
+
.event_timer => {
|
|
518
|
+
try dispatchEvent(self, app, .{ .timer = event_value.timer });
|
|
466
519
|
},
|
|
467
|
-
.
|
|
468
|
-
try dispatchEvent(self, app, .{ .audio =
|
|
520
|
+
.event_audio => {
|
|
521
|
+
try dispatchEvent(self, app, .{ .audio = event_value.audio });
|
|
469
522
|
},
|
|
470
|
-
.
|
|
471
|
-
try dispatchEvent(self, app, .{ .video =
|
|
523
|
+
.event_video => {
|
|
524
|
+
try dispatchEvent(self, app, .{ .video = event_value.video });
|
|
472
525
|
},
|
|
473
|
-
.
|
|
526
|
+
.event_wake => {
|
|
474
527
|
try dispatchEvent(self, app, .effects_wake);
|
|
475
528
|
},
|
|
476
|
-
.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
error.InvalidViewOptions,
|
|
481
|
-
=> null,
|
|
482
|
-
else => return err,
|
|
529
|
+
.capability_gpu_surface_frame => {
|
|
530
|
+
GpuSurfaceEventMethods().dispatchGpuSurfaceFrame(self, app, event_value.gpu_surface_frame) catch |err| {
|
|
531
|
+
recordDispatchError(self, "gpu_surface_frame", err);
|
|
532
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
483
533
|
};
|
|
484
|
-
if (widget_drop_event) |drop_event| {
|
|
485
|
-
try dispatchEvent(self, app, .{ .canvas_widget_file_drop = drop_event });
|
|
486
|
-
}
|
|
487
|
-
try dispatchEvent(self, app, .{ .files_dropped = drop });
|
|
488
|
-
emitFileDropEvent(self, drop) catch |err| log(self, "drop.files.emit_failed", @errorName(err), &.{trace.uint("window_id", drop.window_id)});
|
|
489
|
-
self.invalidateFor(.command, null);
|
|
490
534
|
},
|
|
491
|
-
.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
// second time (the hook contract is exactly-once).
|
|
497
|
-
self.app_stop_delivered = true;
|
|
498
|
-
try app.stop(self);
|
|
499
|
-
log(self, "app.stop", "app stopped", &.{trace.string("app", app.name)});
|
|
535
|
+
.capability_gpu_surface_resized => {
|
|
536
|
+
GpuSurfaceEventMethods().dispatchGpuSurfaceResized(self, app, event_value.gpu_surface_resized) catch |err| {
|
|
537
|
+
recordDispatchError(self, "gpu_surface_resized", err);
|
|
538
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
539
|
+
};
|
|
500
540
|
},
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
log(self, "runtime.event", null, &event_fields);
|
|
507
|
-
// A handler/update error degrades — recorded and observable,
|
|
508
|
-
// never fatal. Propagating it would reach the platform
|
|
509
|
-
// callback, set `failed`, and exit the whole app. The tag
|
|
510
|
-
// name (not `Event.name()`, which for commands aliases
|
|
511
|
-
// transient command-name storage) keeps ring records static.
|
|
512
|
-
// Under the TestHarness's `.propagate` policy the recorded
|
|
513
|
-
// error additionally returns, so capacity errors fail tests
|
|
514
|
-
// instead of leaving silent stale frames.
|
|
515
|
-
app.event(self, event_value) catch |err| {
|
|
516
|
-
recordDispatchError(self, @tagName(event_value), err);
|
|
517
|
-
if (self.dispatch_error_policy == .propagate) return err;
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
switch (event_value) {
|
|
521
|
-
.command => {
|
|
522
|
-
if (self.options.extensions) |registry| {
|
|
523
|
-
registry.dispatchCommand(extensionContext(self), .{ .name = event_value.command.name }) catch |err| {
|
|
524
|
-
recordDispatchError(self, "extension.command", err);
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
self.invalidateFor(.command, null);
|
|
541
|
+
.capability_gpu_surface_input => {
|
|
542
|
+
GpuSurfaceEventMethods().dispatchGpuSurfaceInput(self, app, event_value.gpu_surface_input) catch |err| {
|
|
543
|
+
recordDispatchError(self, "gpu_surface_input", err);
|
|
544
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
545
|
+
};
|
|
528
546
|
},
|
|
529
|
-
.
|
|
530
|
-
|
|
547
|
+
.capability_gpu_surface_scroll_driver => {
|
|
548
|
+
ScrollDriverMethods().dispatchGpuSurfaceScrollDriver(self, app, event_value.gpu_surface_scroll_driver) catch |err| {
|
|
549
|
+
recordDispatchError(self, "gpu_surface_scroll_driver", err);
|
|
550
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
551
|
+
};
|
|
531
552
|
},
|
|
532
|
-
.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
.audio => {},
|
|
538
|
-
.video => {},
|
|
539
|
-
.files_dropped => {},
|
|
540
|
-
.gpu_surface_frame => {},
|
|
541
|
-
.gpu_surface_resized => {},
|
|
542
|
-
.gpu_surface_input => {},
|
|
543
|
-
.canvas_widget_pointer => {},
|
|
544
|
-
.canvas_widget_keyboard => {},
|
|
545
|
-
.canvas_widget_scroll => {},
|
|
546
|
-
.canvas_widget_file_drop => {},
|
|
547
|
-
.canvas_widget_drag => {},
|
|
548
|
-
.canvas_widget_context_menu => {
|
|
549
|
-
self.invalidateFor(.command, null);
|
|
553
|
+
.capability_context_menu_action => {
|
|
554
|
+
ContextMenuMethods().dispatchContextMenuAction(self, app, event_value.context_menu_action) catch |err| {
|
|
555
|
+
recordDispatchError(self, "context_menu_action", err);
|
|
556
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
557
|
+
};
|
|
550
558
|
},
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
.canvas_widget_context_menu_dismissed => {},
|
|
557
|
-
.canvas_widget_context_menu_request => {
|
|
558
|
-
// The app loop answers by mounting the anchored
|
|
559
|
-
// fallback surface: a visual change.
|
|
560
|
-
self.invalidateFor(.command, null);
|
|
559
|
+
.capability_widget_context_menu_action => {
|
|
560
|
+
AutomationWidgetMethods().dispatchWidgetContextMenuItem(self, app, event_value.widget_context_menu_action) catch |err| {
|
|
561
|
+
recordDispatchError(self, "widget_context_menu_action", err);
|
|
562
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
563
|
+
};
|
|
561
564
|
},
|
|
562
|
-
.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
.capability_widget_accessibility_action => {
|
|
566
|
+
const action_event = event_value.widget_accessibility_action;
|
|
567
|
+
_ = self.dispatchCanvasWidgetAccessibilityAction(app, action_event.window_id, action_event.label, .{
|
|
568
|
+
.id = action_event.id,
|
|
569
|
+
.action = canvasWidgetAccessibilityActionKindFromPlatform(action_event.action),
|
|
570
|
+
.text = action_event.text,
|
|
571
|
+
.selection = if (action_event.selection) |selection| .{ .anchor = selection.start, .focus = selection.end } else null,
|
|
572
|
+
}) catch |err| {
|
|
573
|
+
recordDispatchError(self, "widget_accessibility_action", err);
|
|
574
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
575
|
+
};
|
|
568
576
|
},
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
pub fn dispatchEvent(self: *Runtime, app: App, event_value: Event) anyerror!void {
|
|
581
|
+
const policy = app.host_flow_policy orelse return native_reference.RuntimeFlow(Runtime).dispatchEvent(self, app, event_value);
|
|
582
|
+
const program = host_flow.plan(policy, .app_event, .{ .kind = host_flow.appKind(event_value) });
|
|
583
|
+
for (program) |action| switch (action) {
|
|
584
|
+
0 => break,
|
|
585
|
+
1 => if (self.options.extensions) |registry| {
|
|
586
|
+
registry.dispatchCommand(extensionContext(self), .{ .name = event_value.command.name }) catch |err| recordDispatchError(self, "extension.command", err);
|
|
587
|
+
},
|
|
588
|
+
2 => self.invalidateFor(.command, null),
|
|
589
|
+
3 => self.invalidateFor(.state, null),
|
|
590
|
+
4 => log(self, "runtime.event", null, &.{trace.string("event", event_value.name())}),
|
|
591
|
+
5 => app.event(self, event_value) catch |err| {
|
|
592
|
+
recordDispatchError(self, @tagName(event_value), err);
|
|
593
|
+
if (host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0) return @as(anyerror!void, err);
|
|
594
|
+
},
|
|
595
|
+
else => unreachable,
|
|
596
|
+
};
|
|
572
597
|
}
|
|
573
598
|
|
|
574
599
|
pub fn dispatchCommand(self: *Runtime, app: App, command: CommandEvent) anyerror!void {
|
|
575
|
-
|
|
576
|
-
|
|
600
|
+
const plan: command_policy.Dispatch = if (self.command_policy) |policy| command_policy.dispatch(policy, command.name) else native: {
|
|
601
|
+
try validateCommandName(command.name);
|
|
602
|
+
break :native if (std.mem.eql(u8, command.name, platform.update_check_command)) .updater else .app;
|
|
603
|
+
};
|
|
604
|
+
if (plan == .invalid) return error.InvalidCommand;
|
|
605
|
+
if (plan == .updater) {
|
|
577
606
|
self.options.platform.services.checkForUpdates(true) catch |err| switch (err) {
|
|
578
607
|
error.UnsupportedService => return dispatchEvent(self, app, .{ .command = command }),
|
|
579
608
|
else => return err,
|
|
@@ -618,7 +647,8 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
618
647
|
});
|
|
619
648
|
app.event(self, .{ .lifecycle = .frame }) catch |err| {
|
|
620
649
|
recordDispatchError(self, "lifecycle", err);
|
|
621
|
-
if (self.dispatch_error_policy == .propagate)
|
|
650
|
+
const propagate = if (app.host_flow_policy) |policy| host_flow.gate(policy, 2, @intFromBool(self.dispatch_error_policy == .propagate), 0) != 0 else self.dispatch_error_policy == .propagate;
|
|
651
|
+
if (propagate) return err;
|
|
622
652
|
};
|
|
623
653
|
}
|
|
624
654
|
|
|
@@ -643,6 +673,11 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
643
673
|
}
|
|
644
674
|
|
|
645
675
|
fn handlePlatformEvent(context: *anyopaque, event_value: platform.Event) anyerror!void {
|
|
676
|
+
const run_context: *RunContext = @ptrCast(@alignCast(context));
|
|
677
|
+
try run_context.host_events.dispatch(context, dispatchHostEvent, event_value);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
fn dispatchHostEvent(context: *anyopaque, event_value: platform.Event) anyerror!void {
|
|
646
681
|
const run_context: *RunContext = @ptrCast(@alignCast(context));
|
|
647
682
|
try run_context.runtime.dispatchPlatformEvent(run_context.app, event_value);
|
|
648
683
|
}
|
|
@@ -704,21 +739,30 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
704
739
|
}
|
|
705
740
|
|
|
706
741
|
fn loadScene(self: *Runtime, app: App, scene: app_manifest.ShellConfig) anyerror!void {
|
|
707
|
-
|
|
742
|
+
if (self.shell_admission_policy) |policy|
|
|
743
|
+
try @import("shell_admission_policy.zig").scene(policy, scene, &.{})
|
|
744
|
+
else
|
|
745
|
+
try app_manifest.validateShell(scene, &.{});
|
|
708
746
|
if (scene.windows.len == 0) {
|
|
709
747
|
log(self, "scene.load", "loaded empty app scene", &.{trace.string("app", app.name)});
|
|
710
748
|
return;
|
|
711
749
|
}
|
|
712
750
|
|
|
713
751
|
const uses_default_empty_source = appUsesDefaultEmptyWebViewSource(App, app);
|
|
714
|
-
const source = if (
|
|
752
|
+
const source = if (if (self.shell_coordination_policy) |policy|
|
|
753
|
+
@import("shell_coordination_policy.zig").scene(policy, scene.windows, uses_default_empty_source).decisions != 0
|
|
754
|
+
else
|
|
755
|
+
sceneNeedsMainWebView(scene) or !uses_default_empty_source)
|
|
715
756
|
try WindowViewMethods().copyLoadedSource(self, try app.webViewSource())
|
|
716
757
|
else
|
|
717
758
|
null;
|
|
718
759
|
if (source != null and !self.options.web_layer) return error.WebViewLayerNotBuilt;
|
|
719
760
|
self.loaded_source = source;
|
|
720
761
|
|
|
721
|
-
const startup_uses_source =
|
|
762
|
+
const startup_uses_source = if (self.shell_coordination_policy) |policy|
|
|
763
|
+
@import("shell_coordination_policy.zig").scene(policy, scene.windows[0..1], uses_default_empty_source).choices[0] & 4 != 0
|
|
764
|
+
else
|
|
765
|
+
sceneWindowUsesAppSource(scene.windows[0], uses_default_empty_source);
|
|
722
766
|
try loadStartupSceneWindow(
|
|
723
767
|
self,
|
|
724
768
|
scene.windows[0],
|
|
@@ -726,7 +770,11 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
726
770
|
if (startup_uses_source) .allow_source_less else .never_source,
|
|
727
771
|
);
|
|
728
772
|
for (scene.windows[1..]) |window| {
|
|
729
|
-
if (
|
|
773
|
+
if (if (self.shell_coordination_policy) |policy|
|
|
774
|
+
@import("shell_coordination_policy.zig").scene(policy, &.{window}, uses_default_empty_source).choices[0] & 4 != 0
|
|
775
|
+
else
|
|
776
|
+
sceneWindowUsesAppSource(window, uses_default_empty_source))
|
|
777
|
+
{
|
|
730
778
|
_ = try WindowViewMethods().createShellWindowWithSourceMode(self, window, source, source != null);
|
|
731
779
|
} else {
|
|
732
780
|
_ = try WindowViewMethods().createSourcelessShellWindow(self, window);
|
|
@@ -840,7 +888,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
840
888
|
self.invalidateFor(.command, null);
|
|
841
889
|
return;
|
|
842
890
|
}
|
|
843
|
-
const response =
|
|
891
|
+
const response = authorization.dispatch(self.authorization_policy, dispatcher, message.bytes, .{ .origin = message.origin, .window_id = message.window_id, .webview_label = message.webview_label }, &response_buffer);
|
|
844
892
|
try completeBridgeResponse(self, message.window_id, message.webview_label, response);
|
|
845
893
|
self.invalidateFor(.command, null);
|
|
846
894
|
log(self, "bridge.dispatch", "bridge request handled", &.{
|
|
@@ -852,7 +900,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
852
900
|
fn handleAsyncBridgeMessage(self: *Runtime, dispatcher: bridge.Dispatcher, message: platform.BridgeMessage) anyerror!bool {
|
|
853
901
|
const request = bridge.parseRequest(message.bytes) catch return false;
|
|
854
902
|
const handler = dispatcher.async_registry.find(request.command) orelse return false;
|
|
855
|
-
if (!dispatcher.policy
|
|
903
|
+
if (!authorization.bridgeAllows(self.authorization_policy, dispatcher.policy, request.command, message.origin)) {
|
|
856
904
|
var response_buffer: [bridge.max_response_bytes]u8 = undefined;
|
|
857
905
|
const response = bridge.writeErrorResponse(&response_buffer, request.id, .permission_denied, "Bridge command is not permitted");
|
|
858
906
|
try completeBridgeResponse(self, message.window_id, message.webview_label, response);
|
|
@@ -951,7 +999,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
951
999
|
try handleBridgeMessage(self, app, .{ .bytes = command.value, .origin = "zero://inline", .window_id = 1, .webview_label = "main" });
|
|
952
1000
|
},
|
|
953
1001
|
.resize => {
|
|
954
|
-
const parsed = try parseAutomationResizeCommand(command.value);
|
|
1002
|
+
const parsed = try parseAutomationResizeCommand(self.automation_command_policy, command.value);
|
|
955
1003
|
try dispatchPlatformEvent(self, app, .{ .surface_resized = .{
|
|
956
1004
|
.id = 1,
|
|
957
1005
|
.size = geometry.SizeF.init(parsed.width, parsed.height),
|
|
@@ -964,7 +1012,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
964
1012
|
};
|
|
965
1013
|
},
|
|
966
1014
|
.native_command => {
|
|
967
|
-
const parsed = try parseAutomationNativeCommand(command.value);
|
|
1015
|
+
const parsed = try parseAutomationNativeCommand(self.automation_command_policy, command.value);
|
|
968
1016
|
try dispatchPlatformEvent(self, app, .{ .native_command = .{
|
|
969
1017
|
.name = parsed.name,
|
|
970
1018
|
.window_id = 1,
|
|
@@ -972,41 +1020,41 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
972
1020
|
} });
|
|
973
1021
|
},
|
|
974
1022
|
.widget_action => {
|
|
975
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetAction(self, app, try parseAutomationWidgetAction(command.value));
|
|
1023
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetAction(self, app, try parseAutomationWidgetAction(self.automation_command_policy, command.value));
|
|
976
1024
|
},
|
|
977
1025
|
.widget_click => {
|
|
978
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetClick(self, app, try parseAutomationWidgetTarget(command.value));
|
|
1026
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetClick(self, app, try parseAutomationWidgetTarget(self.automation_command_policy, command.value));
|
|
979
1027
|
},
|
|
980
1028
|
.widget_hold => {
|
|
981
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetHold(self, app, try parseAutomationWidgetTarget(command.value));
|
|
1029
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetHold(self, app, try parseAutomationWidgetTarget(self.automation_command_policy, command.value));
|
|
982
1030
|
},
|
|
983
1031
|
.widget_context_press => {
|
|
984
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetContextPress(self, app, try parseAutomationWidgetTarget(command.value));
|
|
1032
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetContextPress(self, app, try parseAutomationWidgetTarget(self.automation_command_policy, command.value));
|
|
985
1033
|
},
|
|
986
1034
|
.widget_context_menu => {
|
|
987
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetContextMenuItem(self, app, try parseAutomationWidgetContextMenuItem(command.value));
|
|
1035
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetContextMenuItem(self, app, try parseAutomationWidgetContextMenuItem(self.automation_command_policy, command.value));
|
|
988
1036
|
},
|
|
989
1037
|
.widget_drag => {
|
|
990
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetPointerDrag(self, app, try parseAutomationWidgetPointerDrag(command.value));
|
|
1038
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetPointerDrag(self, app, try parseAutomationWidgetPointerDrag(self.automation_command_policy, command.value));
|
|
991
1039
|
},
|
|
992
1040
|
.widget_wheel => {
|
|
993
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetWheel(self, app, try parseAutomationWidgetWheel(command.value));
|
|
1041
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetWheel(self, app, try parseAutomationWidgetWheel(self.automation_command_policy, command.value));
|
|
994
1042
|
},
|
|
995
1043
|
.widget_key => {
|
|
996
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetKeyInput(self, app, try parseAutomationWidgetKey(command.value));
|
|
1044
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetKeyInput(self, app, try parseAutomationWidgetKey(self.automation_command_policy, command.value));
|
|
997
1045
|
},
|
|
998
1046
|
.widget_pinch => {
|
|
999
|
-
try AutomationWidgetMethods().dispatchAutomationWidgetPinch(self, app, try parseAutomationWidgetPinch(command.value));
|
|
1047
|
+
try AutomationWidgetMethods().dispatchAutomationWidgetPinch(self, app, try parseAutomationWidgetPinch(self.automation_command_policy, command.value));
|
|
1000
1048
|
},
|
|
1001
1049
|
.menu_command => {
|
|
1002
1050
|
try dispatchPlatformEvent(self, app, .{ .menu_command = .{
|
|
1003
|
-
.name = try parseAutomationCommandName(command.value),
|
|
1051
|
+
.name = try parseAutomationCommandName(self.automation_command_policy, command.value),
|
|
1004
1052
|
.window_id = 1,
|
|
1005
1053
|
} });
|
|
1006
1054
|
},
|
|
1007
1055
|
.shortcut => {
|
|
1008
1056
|
try dispatchPlatformEvent(self, app, .{ .shortcut = .{
|
|
1009
|
-
.id = try parseAutomationCommandName(command.value),
|
|
1057
|
+
.id = try parseAutomationCommandName(self.automation_command_policy, command.value),
|
|
1010
1058
|
.key = "",
|
|
1011
1059
|
.window_id = 1,
|
|
1012
1060
|
} });
|
|
@@ -1018,7 +1066,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
1018
1066
|
// UiApp's window fallback are all the real path. A
|
|
1019
1067
|
// stale or unknown item id is loud driver misuse,
|
|
1020
1068
|
// like widget-click on an unmounted widget.
|
|
1021
|
-
const target = try parseAutomationTrayTarget(command.value);
|
|
1069
|
+
const target = try parseAutomationTrayTarget(self.automation_command_policy, command.value);
|
|
1022
1070
|
if (!SystemServiceMethods().statusItemMenuItemActionable(self, target.status_item_id, target.item_id)) return error.InvalidCommand;
|
|
1023
1071
|
try dispatchPlatformEvent(self, app, .{ .tray_action = .{
|
|
1024
1072
|
.status_item_id = target.status_item_id,
|
|
@@ -1026,7 +1074,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
1026
1074
|
} });
|
|
1027
1075
|
},
|
|
1028
1076
|
.focus_view => {
|
|
1029
|
-
try WindowViewMethods().focusView(self, 1, try parseAutomationViewLabel(command.value));
|
|
1077
|
+
try WindowViewMethods().focusView(self, 1, try parseAutomationViewLabel(self.automation_command_policy, command.value));
|
|
1030
1078
|
},
|
|
1031
1079
|
.focus_next_view => {
|
|
1032
1080
|
_ = try WindowViewMethods().focusNextView(self, 1);
|
|
@@ -1053,7 +1101,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
1053
1101
|
self.invalidateFor(.command, null);
|
|
1054
1102
|
},
|
|
1055
1103
|
.provenance => {
|
|
1056
|
-
try AutomationWidgetMethods().dispatchAutomationProvenance(self, app, try parseAutomationProvenanceTarget(command.value));
|
|
1104
|
+
try AutomationWidgetMethods().dispatchAutomationProvenance(self, app, try parseAutomationProvenanceTarget(self.automation_command_policy, command.value));
|
|
1057
1105
|
},
|
|
1058
1106
|
.wait => {},
|
|
1059
1107
|
}
|
|
@@ -1067,7 +1115,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
1067
1115
|
/// artifacts across captures.
|
|
1068
1116
|
pub fn publishAutomationScreenshot(self: *Runtime, value: []const u8) anyerror!void {
|
|
1069
1117
|
const server = self.options.automation orelse return;
|
|
1070
|
-
const parsed = try parseAutomationScreenshotCommand(value);
|
|
1118
|
+
const parsed = try parseAutomationScreenshotCommand(self.automation_command_policy, value);
|
|
1071
1119
|
// Screenshots address a gpu_surface view by label across ALL
|
|
1072
1120
|
// open windows, like the widget verbs — a secondary window's
|
|
1073
1121
|
// canvas captures the same way the main one does.
|
|
@@ -1141,7 +1189,37 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
1141
1189
|
const resolveWindowSelector = BuiltinBridgeMethods.resolveWindowSelector;
|
|
1142
1190
|
const writeWindowListJson = BuiltinBridgeMethods.writeWindowListJson;
|
|
1143
1191
|
|
|
1192
|
+
fn handleCompiledBuiltinBridgeMessage(self: *Runtime, app: App, message: platform.BridgeMessage) anyerror!bool {
|
|
1193
|
+
const request = bridge.parseRequest(message.bytes) catch return false;
|
|
1194
|
+
const plan = builtin_coordination.route(self.builtin_coordination_policy.?, .none, request.command);
|
|
1195
|
+
if (plan.family() == .none) return false;
|
|
1196
|
+
var response_buffer: [bridge.max_response_bytes]u8 = undefined;
|
|
1197
|
+
var result_buffer: [bridge.max_result_bytes]u8 = undefined;
|
|
1198
|
+
if (!allowsBuiltinBridgeCommand(self, request.command, message.origin, plan.permission())) {
|
|
1199
|
+
const response = bridge.writeErrorResponse(&response_buffer, request.id, .permission_denied, plan.deniedMessage());
|
|
1200
|
+
try completeBridgeResponse(self, message.window_id, message.webview_label, response);
|
|
1201
|
+
self.invalidateFor(.command, null);
|
|
1202
|
+
return true;
|
|
1203
|
+
}
|
|
1204
|
+
const response = switch (plan.family()) {
|
|
1205
|
+
.none => unreachable,
|
|
1206
|
+
.command => dispatchCommandBridgeCommand(self, app, request, message.window_id, message.webview_label, &result_buffer, &response_buffer),
|
|
1207
|
+
.window => dispatchWindowBridgeCommand(self, request, &result_buffer, &response_buffer),
|
|
1208
|
+
.view => dispatchViewBridgeCommand(self, request, message.window_id, &result_buffer, &response_buffer),
|
|
1209
|
+
.webview => dispatchWebViewBridgeCommand(self, request, message.window_id, &result_buffer, &response_buffer),
|
|
1210
|
+
.platform => dispatchPlatformBridgeCommand(self, request, &result_buffer, &response_buffer),
|
|
1211
|
+
.dialog => dispatchDialogBridgeCommand(self, request, &result_buffer, &response_buffer),
|
|
1212
|
+
.os => dispatchOsBridgeCommand(self, request, message.origin, &result_buffer, &response_buffer),
|
|
1213
|
+
.clipboard => dispatchClipboardBridgeCommand(self, request, &result_buffer, &response_buffer),
|
|
1214
|
+
.credentials => dispatchCredentialBridgeCommand(self, request, &result_buffer, &response_buffer),
|
|
1215
|
+
};
|
|
1216
|
+
try completeBridgeResponse(self, message.window_id, message.webview_label, response);
|
|
1217
|
+
self.invalidateFor(.command, null);
|
|
1218
|
+
return true;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1144
1221
|
fn handleBuiltinBridgeMessage(self: *Runtime, app: App, message: platform.BridgeMessage) anyerror!bool {
|
|
1222
|
+
if (self.builtin_coordination_policy != null) return handleCompiledBuiltinBridgeMessage(self, app, message);
|
|
1145
1223
|
const request = bridge.parseRequest(message.bytes) catch return false;
|
|
1146
1224
|
const is_command = std.mem.startsWith(u8, request.command, "native-sdk.command.");
|
|
1147
1225
|
const is_window = std.mem.startsWith(u8, request.command, "native-sdk.window.");
|