@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/effects.zig
CHANGED
|
@@ -72,14 +72,15 @@ const builtin = @import("builtin");
|
|
|
72
72
|
const canvas = @import("canvas");
|
|
73
73
|
const canvas_limits = @import("canvas_limits.zig");
|
|
74
74
|
const platform = @import("../platform/root.zig");
|
|
75
|
-
const validation = @import("validation.zig");
|
|
76
75
|
const runtime_clock = @import("clock.zig");
|
|
77
76
|
const persist_store = @import("persist_store.zig");
|
|
78
77
|
const record_store = @import("record_store.zig");
|
|
79
78
|
const relational_store = @import("relational_store.zig");
|
|
80
79
|
const credentials_store = @import("credentials_store.zig");
|
|
80
|
+
const keyboard_input = @import("keyboard_input.zig");
|
|
81
81
|
const file_access = @import("file_access.zig");
|
|
82
82
|
const pty_transport = @import("pty.zig");
|
|
83
|
+
const global_shortcuts_mod = @import("global_shortcuts.zig");
|
|
83
84
|
|
|
84
85
|
/// Maximum in-flight effects (spawn slots / worker threads).
|
|
85
86
|
pub const max_effects: usize = 16;
|
|
@@ -374,6 +375,9 @@ pub const WindowActionBinding = struct {
|
|
|
374
375
|
minimize_fn: *const fn (context: *anyopaque, window_label: []const u8) bool,
|
|
375
376
|
hide_fn: *const fn (context: *anyopaque, window_label: []const u8) bool,
|
|
376
377
|
show_fn: *const fn (context: *anyopaque, window_label: []const u8) bool,
|
|
378
|
+
/// Replay the synchronous show bookkeeping without an OS call. The
|
|
379
|
+
/// later native frame event must not delay keyboard-focus loss.
|
|
380
|
+
replay_show_fn: ?*const fn (context: *anyopaque, window_label: []const u8) void = null,
|
|
377
381
|
dock_presence_fn: *const fn (context: *anyopaque, visible: bool) bool,
|
|
378
382
|
quit_fn: *const fn (context: *anyopaque) bool,
|
|
379
383
|
};
|
|
@@ -387,6 +391,11 @@ pub const SystemServiceBinding = struct {
|
|
|
387
391
|
open_external_url_fn: *const fn (context: *anyopaque, url: []const u8) anyerror!void,
|
|
388
392
|
reveal_path_fn: *const fn (context: *anyopaque, path: []const u8) anyerror!void,
|
|
389
393
|
format_local_time_fn: *const fn (context: *anyopaque, timestamp_ms: i64, style: platform.LocalTimeStyle, buffer: []u8) anyerror![]const u8,
|
|
394
|
+
execute_capability_fn: ?*const fn (context: *anyopaque, name: []const u8, payload: []const u8, output: []u8) anyerror![]const u8 = null,
|
|
395
|
+
/// Restore only runtime window bookkeeping from a journaled successful
|
|
396
|
+
/// capability, without invoking native window focus or close services.
|
|
397
|
+
replay_window_result_fn: ?*const fn (context: *anyopaque, label: []const u8, closed: bool) void = null,
|
|
398
|
+
keyboard_input: ?keyboard_input.Binding = null,
|
|
390
399
|
};
|
|
391
400
|
|
|
392
401
|
/// Type-erased handle to the embedding host's named-command services,
|
|
@@ -433,6 +442,21 @@ pub const HostChannelBinding = struct {
|
|
|
433
442
|
acquire_fn: *const fn (context: *anyopaque, key: u64) ?ChannelHandle,
|
|
434
443
|
};
|
|
435
444
|
|
|
445
|
+
/// Loop-thread startup only. Implementations copy arguments before returning
|
|
446
|
+
/// and may retain the generation-safe handle; they must not reenter the UI.
|
|
447
|
+
pub const HostChannelSourceBinding = struct {
|
|
448
|
+
context: *anyopaque,
|
|
449
|
+
start_fn: *const fn (context: *anyopaque, name: []const u8, payload: []const u8, handle: ChannelHandle) anyerror!void,
|
|
450
|
+
};
|
|
451
|
+
pub const EffectChannelSourceState = enum(u8) { skipped, started, failed };
|
|
452
|
+
pub const EffectChannelSourceResult = struct {
|
|
453
|
+
key: u64,
|
|
454
|
+
state: EffectChannelSourceState,
|
|
455
|
+
bytes: []const u8 = "",
|
|
456
|
+
};
|
|
457
|
+
pub const max_channel_source_payload = 4096;
|
|
458
|
+
const max_channel_source_request = 1 + max_effect_host_name_bytes + 4 + max_channel_source_payload;
|
|
459
|
+
|
|
436
460
|
pub const HostCallCompletion = struct {
|
|
437
461
|
key: u64,
|
|
438
462
|
ok: bool,
|
|
@@ -1266,6 +1290,9 @@ pub const EffectAudioCaptureEvent = struct {
|
|
|
1266
1290
|
const audio_capture_packet_header_bytes: usize = 24;
|
|
1267
1291
|
const audio_capture_packet_magic = "AC01";
|
|
1268
1292
|
|
|
1293
|
+
pub const EffectGlobalShortcutEventKind = global_shortcuts_mod.EffectGlobalShortcutEventKind;
|
|
1294
|
+
pub const EffectGlobalShortcutEvent = global_shortcuts_mod.EffectGlobalShortcutEvent;
|
|
1295
|
+
|
|
1269
1296
|
/// Convert the channel envelope used internally by capture into its public
|
|
1270
1297
|
/// typed event. Also useful to native integrations that intentionally route
|
|
1271
1298
|
/// capture through a generic `channelMsg` handler.
|
|
@@ -2030,6 +2057,12 @@ pub const EffectResultKind = enum(u8) {
|
|
|
2030
2057
|
/// salted digest and length; replay synthesizes same-length placeholder
|
|
2031
2058
|
/// bytes and never consults an OS keychain.
|
|
2032
2059
|
credentials = 18,
|
|
2060
|
+
/// Successful native window bookkeeping, at execution rather than Msg
|
|
2061
|
+
/// delivery. `code` is 0 for focus and 1 for close; the complete copied
|
|
2062
|
+
/// request and correlated reply ride `payload` and `stderr_tail`.
|
|
2063
|
+
window_execution = 19,
|
|
2064
|
+
/// Immediate external producer startup; request rides payload, error rides stderr_tail.
|
|
2065
|
+
channel_source = 20,
|
|
2033
2066
|
};
|
|
2034
2067
|
|
|
2035
2068
|
/// Journaled wall-clock reads buffered for replay (`Effects.wallMs`).
|
|
@@ -2952,6 +2985,15 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
2952
2985
|
}.make;
|
|
2953
2986
|
}
|
|
2954
2987
|
|
|
2988
|
+
/// Msg constructor for `setGlobalShortcuts` reports.
|
|
2989
|
+
pub fn globalShortcutMsg(comptime tag: std.meta.Tag(Msg)) ChannelMsgFn {
|
|
2990
|
+
return struct {
|
|
2991
|
+
fn make(event: EffectChannelEvent) Msg {
|
|
2992
|
+
return @unionInit(Msg, @tagName(tag), global_shortcuts_mod.decodeChannelEvent(event));
|
|
2993
|
+
}
|
|
2994
|
+
}.make;
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2955
2997
|
/// Comptime Msg constructor for `on_event` of pty effects:
|
|
2956
2998
|
/// `ptyMsg(.shell)` builds `Msg{ .shell = event }` — the
|
|
2957
2999
|
/// variant's payload type must be `native_sdk.EffectPtyEvent`.
|
|
@@ -3042,6 +3084,8 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
3042
3084
|
/// valid until the fetch's response is drained.
|
|
3043
3085
|
pub const FetchRequest = struct {
|
|
3044
3086
|
key: u64,
|
|
3087
|
+
generation: u64 = 0,
|
|
3088
|
+
timeout_ms: u32 = 0,
|
|
3045
3089
|
method: std.http.Method,
|
|
3046
3090
|
url: []const u8,
|
|
3047
3091
|
headers: []const std.http.Header,
|
|
@@ -3083,9 +3127,10 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
3083
3127
|
/// valid until the result is fed and drained.
|
|
3084
3128
|
pub const FileRequest = struct {
|
|
3085
3129
|
key: u64,
|
|
3130
|
+
generation: u64 = 0,
|
|
3086
3131
|
op: EffectFileOp,
|
|
3087
3132
|
path: []const u8,
|
|
3088
|
-
/// The bytes a `writeFile` would write; `""` for reads.
|
|
3133
|
+
/// The bytes a `writeFile` or `appendFile` would write; `""` for reads.
|
|
3089
3134
|
bytes: []const u8 = "",
|
|
3090
3135
|
};
|
|
3091
3136
|
|
|
@@ -3158,6 +3203,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
3158
3203
|
/// stays valid until the result is fed and drained.
|
|
3159
3204
|
pub const ClipboardRequest = struct {
|
|
3160
3205
|
key: u64,
|
|
3206
|
+
generation: u64 = 0,
|
|
3161
3207
|
op: EffectClipboardOp,
|
|
3162
3208
|
/// The text a `writeClipboard` would write; `""` for reads.
|
|
3163
3209
|
text: []const u8 = "",
|
|
@@ -3436,6 +3482,12 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
3436
3482
|
max_pending: u32 = max_effect_channel_pending,
|
|
3437
3483
|
};
|
|
3438
3484
|
|
|
3485
|
+
pub const SetGlobalShortcutsOptions = struct {
|
|
3486
|
+
key: u64,
|
|
3487
|
+
shortcuts: []const platform.Shortcut,
|
|
3488
|
+
on_event: ChannelMsgFn,
|
|
3489
|
+
};
|
|
3490
|
+
|
|
3439
3491
|
pub const PtySpawnOptions = struct {
|
|
3440
3492
|
/// Caller-chosen identity, stored in the model. Shares the
|
|
3441
3493
|
/// keyed families' one key space, occupied from spawn until
|
|
@@ -4480,6 +4532,24 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
4480
4532
|
}
|
|
4481
4533
|
};
|
|
4482
4534
|
|
|
4535
|
+
const ReplayChannelSource = struct {
|
|
4536
|
+
key: u64,
|
|
4537
|
+
state: EffectChannelSourceState,
|
|
4538
|
+
request_len: usize,
|
|
4539
|
+
request: [max_channel_source_request]u8,
|
|
4540
|
+
failure_len: u8,
|
|
4541
|
+
failure: [255]u8,
|
|
4542
|
+
};
|
|
4543
|
+
|
|
4544
|
+
const ReplayWindowExecution = struct {
|
|
4545
|
+
key: u64,
|
|
4546
|
+
closed: bool,
|
|
4547
|
+
request_len: u16,
|
|
4548
|
+
request: [293]u8,
|
|
4549
|
+
reply_len: u8,
|
|
4550
|
+
reply: [38]u8,
|
|
4551
|
+
};
|
|
4552
|
+
|
|
4483
4553
|
const Slot = struct {
|
|
4484
4554
|
state: std.atomic.Value(SlotState) = std.atomic.Value(SlotState).init(.idle),
|
|
4485
4555
|
generation: u32 = 0,
|
|
@@ -4596,6 +4666,11 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
4596
4666
|
/// credential slots or letting an older set finish last.
|
|
4597
4667
|
credentials_waiting: bool = false,
|
|
4598
4668
|
credentials_sequence: u64 = 0,
|
|
4669
|
+
// Desktop calls can enter AppKit or remove runtime views. UiApp
|
|
4670
|
+
// executes them only after its current rebuild has settled.
|
|
4671
|
+
desktop_waiting: bool = false,
|
|
4672
|
+
replay_window_reply_len: u8 = 0,
|
|
4673
|
+
replay_window_reply: [38]u8 = undefined,
|
|
4599
4674
|
// ---- image-only fields (kind == .image) ----
|
|
4600
4675
|
on_image: ?ImageMsgFn = null,
|
|
4601
4676
|
/// The local source path (the URL rides `url_storage`, a
|
|
@@ -4864,6 +4939,11 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
4864
4939
|
/// requests reject loudly in real mode, and the fake executor
|
|
4865
4940
|
/// parks requests for `feedHostResult` regardless.
|
|
4866
4941
|
host_calls: ?HostCallBinding = null,
|
|
4942
|
+
channel_sources: ?HostChannelSourceBinding = null,
|
|
4943
|
+
replay_channel_sources: [64]ReplayChannelSource = undefined,
|
|
4944
|
+
replay_channel_source_len: usize = 0,
|
|
4945
|
+
replay_channel_source_diverged: bool = false,
|
|
4946
|
+
channel_source_reply: [255]u8 = undefined,
|
|
4867
4947
|
/// Capability-installed record-store service. Store commands are
|
|
4868
4948
|
/// SDK-reserved routed requests, so their results reuse the request
|
|
4869
4949
|
/// journal/replay path while the database handle stays host-owned.
|
|
@@ -4969,6 +5049,9 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
4969
5049
|
fetch_start_rejections: std.atomic.Value(u32) = std.atomic.Value(u32).init(0),
|
|
4970
5050
|
next_generation: u32 = 1,
|
|
4971
5051
|
next_credentials_sequence: u64 = 1,
|
|
5052
|
+
defer_desktop_capabilities: bool = false,
|
|
5053
|
+
flushing_desktop_capabilities: bool = false,
|
|
5054
|
+
system_admission_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
4972
5055
|
/// The channel family's OWN generation counter — u64 and
|
|
4973
5056
|
/// monotonic for the process's lifetime, never the shared u32
|
|
4974
5057
|
/// `next_generation` above: channel handles live on app-owned
|
|
@@ -5008,6 +5091,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
5008
5091
|
/// channel table; this tiny loop-side mirror exists to quiesce native
|
|
5009
5092
|
/// audio callbacks before closing/reusing their channel occupancy.
|
|
5010
5093
|
audio_capture_slots: [2]AudioCaptureSlot = [_]AudioCaptureSlot{.{}} ** 2,
|
|
5094
|
+
global_shortcuts: global_shortcuts_mod.Session = .{},
|
|
5011
5095
|
/// Monotonic post-order stamp shared by every channel's staging
|
|
5012
5096
|
/// FIFO and the close markers: the cross-channel delivery order
|
|
5013
5097
|
/// and the drain boundary's causality cut (posts stamped at or
|
|
@@ -5106,6 +5190,9 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
5106
5190
|
/// after (freed when the queue empties, and at `deinit`) — the
|
|
5107
5191
|
/// pending stages' storage discipline.
|
|
5108
5192
|
replay_video_sources: [max_effect_replay_video_source_entries]ReplayVideoSource = undefined,
|
|
5193
|
+
replay_window_executions: [64]ReplayWindowExecution = undefined,
|
|
5194
|
+
replay_window_execution_len: usize = 0,
|
|
5195
|
+
replay_window_diverged: bool = false,
|
|
5109
5196
|
replay_video_source_spill: []ReplayVideoSource = &.{},
|
|
5110
5197
|
replay_video_source_len: usize = 0,
|
|
5111
5198
|
/// A journaled cascade resolution paired against a different
|
|
@@ -5113,6 +5200,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
5113
5200
|
/// for `finishReplay`, which turns it into the divergence
|
|
5114
5201
|
/// refusal the void-returning `loadVideo` cannot raise itself.
|
|
5115
5202
|
replay_video_diverged: bool = false,
|
|
5203
|
+
replay_audio_diverged: bool = false,
|
|
5116
5204
|
/// Drain-pass counter (incremented in `drainBoundary`): the
|
|
5117
5205
|
/// retired-video sweep's clock. Loop-thread only.
|
|
5118
5206
|
drain_pass_seq: u64 = 0,
|
|
@@ -5251,6 +5339,10 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
5251
5339
|
}
|
|
5252
5340
|
capture.* = .{};
|
|
5253
5341
|
}
|
|
5342
|
+
if (self.global_shortcuts.platform_configured) {
|
|
5343
|
+
if (self.services) |services| services.configureGlobalShortcuts(&.{}, .{}, &.{}) catch {};
|
|
5344
|
+
}
|
|
5345
|
+
self.global_shortcuts = .{};
|
|
5254
5346
|
// Silence the platform audio player (best effort) and clear
|
|
5255
5347
|
// the channel.
|
|
5256
5348
|
if (self.audio.active and !self.audio.fake) {
|
|
@@ -6337,12 +6429,21 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
6337
6429
|
}
|
|
6338
6430
|
|
|
6339
6431
|
/// End-of-journal consistency check (the `.finish` replay
|
|
6340
|
-
/// control):
|
|
6432
|
+
/// control): synchronous audio deliveries must match and leave no
|
|
6433
|
+
/// fed results pending; every journaled video cascade resolution must have
|
|
6341
6434
|
/// been consumed by the load it named, and none may have paired
|
|
6342
6435
|
/// against a different key. A leftover or mismatched record
|
|
6343
6436
|
/// means the replayed updates issued different loads than the
|
|
6344
6437
|
/// recording — divergence, not success.
|
|
6345
|
-
pub fn finishReplay(self: *Self) error{ReplayVideoDivergence}!void {
|
|
6438
|
+
pub fn finishReplay(self: *Self) error{ ReplayAudioDivergence, ReplayVideoDivergence, ReplayWindowDivergence, ReplayChannelSourceDivergence }!void {
|
|
6439
|
+
if (self.replay_channel_source_diverged or self.replay_channel_source_len != 0) return error.ReplayChannelSourceDivergence;
|
|
6440
|
+
if (self.replay_window_diverged or self.replay_window_execution_len != 0) return error.ReplayWindowDivergence;
|
|
6441
|
+
for (&self.slots) |*slot| if (slot.replay_window_reply_len != 0) return error.ReplayWindowDivergence;
|
|
6442
|
+
if (self.replay_audio_diverged) return error.ReplayAudioDivergence;
|
|
6443
|
+
for (0..self.pending_exit_len) |offset| {
|
|
6444
|
+
const entry = self.pending_exits[(self.pending_exit_head + offset) % max_effect_pending_exits];
|
|
6445
|
+
if (entry == .audio and entry.audio.resolve) return error.ReplayAudioDivergence;
|
|
6446
|
+
}
|
|
6346
6447
|
if (self.replay_video_diverged) return error.ReplayVideoDivergence;
|
|
6347
6448
|
if (self.replay_video_source_len > 0) {
|
|
6348
6449
|
std.debug.print(
|
|
@@ -7695,11 +7796,76 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
7695
7796
|
return .{ .shared = shared, .generation = generation };
|
|
7696
7797
|
}
|
|
7697
7798
|
|
|
7698
|
-
///
|
|
7699
|
-
///
|
|
7700
|
-
///
|
|
7701
|
-
|
|
7702
|
-
|
|
7799
|
+
/// Capture startup truth before publishing the issuing dispatch. The
|
|
7800
|
+
/// handle must come from this open, never a same-key old occupancy.
|
|
7801
|
+
/// Returned failure bytes are borrowed until the next source start.
|
|
7802
|
+
pub fn startChannelSource(self: *Self, key: u64, handle: ?ChannelHandle, name: []const u8, payload: []const u8) EffectChannelSourceResult {
|
|
7803
|
+
std.debug.assert(name.len > 0 and name.len <= max_effect_host_name_bytes and payload.len <= max_channel_source_payload);
|
|
7804
|
+
var request: [max_channel_source_request]u8 = undefined;
|
|
7805
|
+
request[0] = @intCast(name.len);
|
|
7806
|
+
@memcpy(request[1..][0..name.len], name);
|
|
7807
|
+
std.mem.writeInt(u32, request[1 + name.len ..][0..4], @intCast(payload.len), .little);
|
|
7808
|
+
@memcpy(request[5 + name.len ..][0..payload.len], payload);
|
|
7809
|
+
const encoded = request[0 .. 5 + name.len + payload.len];
|
|
7810
|
+
if (self.replay) {
|
|
7811
|
+
if (self.replay_channel_source_len == 0) {
|
|
7812
|
+
self.replay_channel_source_diverged = true;
|
|
7813
|
+
return .{ .key = key, .state = .failed, .bytes = "replay_diverged" };
|
|
7814
|
+
}
|
|
7815
|
+
const entry = &self.replay_channel_sources[0];
|
|
7816
|
+
if (entry.key != key or !std.mem.eql(u8, encoded, entry.request[0..entry.request_len]) or
|
|
7817
|
+
((entry.state == .skipped) != (handle == null))) self.replay_channel_source_diverged = true;
|
|
7818
|
+
const state = entry.state;
|
|
7819
|
+
const len = entry.failure_len;
|
|
7820
|
+
@memcpy(self.channel_source_reply[0..len], entry.failure[0..len]);
|
|
7821
|
+
self.replay_channel_source_len -= 1;
|
|
7822
|
+
std.mem.copyForwards(ReplayChannelSource, self.replay_channel_sources[0..self.replay_channel_source_len], self.replay_channel_sources[1 .. self.replay_channel_source_len + 1]);
|
|
7823
|
+
return .{ .key = key, .state = state, .bytes = self.channel_source_reply[0..len] };
|
|
7824
|
+
}
|
|
7825
|
+
var result: EffectChannelSourceResult = .{ .key = key, .state = .skipped };
|
|
7826
|
+
if (handle) |live| {
|
|
7827
|
+
if (live.live()) {
|
|
7828
|
+
result.state = .started;
|
|
7829
|
+
const outcome = if (self.channel_sources) |binding|
|
|
7830
|
+
binding.start_fn(binding.context, name, payload, live)
|
|
7831
|
+
else if (self.executor == .fake)
|
|
7832
|
+
error.UnsupportedChannelSource
|
|
7833
|
+
else
|
|
7834
|
+
@import("channel_sources.zig").start(name, payload, live);
|
|
7835
|
+
outcome catch |err| {
|
|
7836
|
+
result.state = .failed;
|
|
7837
|
+
const failure = @errorName(err);
|
|
7838
|
+
result.bytes = failure[0..@min(failure.len, self.channel_source_reply.len)];
|
|
7839
|
+
};
|
|
7840
|
+
}
|
|
7841
|
+
}
|
|
7842
|
+
self.journalNote(.{ .kind = .channel_source, .key = key, .code = @intFromEnum(result.state), .payload = encoded, .stderr_tail = result.bytes });
|
|
7843
|
+
return result;
|
|
7844
|
+
}
|
|
7845
|
+
|
|
7846
|
+
pub fn pushReplayChannelSource(self: *Self, record: EffectResultRecord) !void {
|
|
7847
|
+
const canonical: EffectResultRecord = .{ .kind = .channel_source, .key = record.key, .code = record.code, .payload = record.payload, .stderr_tail = record.stderr_tail };
|
|
7848
|
+
if (!self.replay or record.kind != .channel_source or record.code < 0 or record.code > 2 or
|
|
7849
|
+
!std.meta.eql(record, canonical) or record.payload.len < 6 or record.payload.len > max_channel_source_request or
|
|
7850
|
+
record.stderr_tail.len > 255 or (record.code == 2) != (record.stderr_tail.len != 0)) return error.ReplayDamagedRecord;
|
|
7851
|
+
const name_len: usize = record.payload[0];
|
|
7852
|
+
if (name_len == 0 or record.payload.len < 5 + name_len or
|
|
7853
|
+
!std.unicode.utf8ValidateSlice(record.payload[1..][0..name_len]) or
|
|
7854
|
+
std.mem.readInt(u32, record.payload[1 + name_len ..][0..4], .little) != record.payload.len - 5 - name_len or
|
|
7855
|
+
record.payload.len - 5 - name_len > max_channel_source_payload) return error.ReplayDamagedRecord;
|
|
7856
|
+
if (self.replay_channel_source_len == self.replay_channel_sources.len) return error.ReplayChannelSourceDivergence;
|
|
7857
|
+
const entry = &self.replay_channel_sources[self.replay_channel_source_len];
|
|
7858
|
+
entry.key = record.key;
|
|
7859
|
+
entry.state = @enumFromInt(record.code);
|
|
7860
|
+
entry.request_len = record.payload.len;
|
|
7861
|
+
@memcpy(entry.request[0..record.payload.len], record.payload);
|
|
7862
|
+
entry.failure_len = @intCast(record.stderr_tail.len);
|
|
7863
|
+
@memcpy(entry.failure[0..record.stderr_tail.len], record.stderr_tail);
|
|
7864
|
+
self.replay_channel_source_len += 1;
|
|
7865
|
+
}
|
|
7866
|
+
|
|
7867
|
+
/// Resolve the open occupancy's generation-safe posting handle.
|
|
7868
|
+
/// Closing and absent occupancies have no handle.
|
|
7703
7869
|
pub fn channelHandle(self: *Self, key: u64) ?ChannelHandle {
|
|
7704
7870
|
for (&self.channel_slots) |*slot| {
|
|
7705
7871
|
if (slot.state == .open and slot.key == key) {
|
|
@@ -7806,6 +7972,80 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
7806
7972
|
if (result != .accepted) return error.EffectQueueFull;
|
|
7807
7973
|
}
|
|
7808
7974
|
|
|
7975
|
+
/// Register or replace the app's global shortcut set.
|
|
7976
|
+
pub fn setGlobalShortcuts(self: *Self, options: SetGlobalShortcutsOptions) void {
|
|
7977
|
+
const session = &self.global_shortcuts;
|
|
7978
|
+
if (session.active and session.key != options.key) {
|
|
7979
|
+
self.rejectChannel(options.key, options.on_event, true);
|
|
7980
|
+
return;
|
|
7981
|
+
}
|
|
7982
|
+
if (!session.active) {
|
|
7983
|
+
if (self.keyOccupiedUntilDelivery(options.key)) {
|
|
7984
|
+
self.rejectChannel(options.key, options.on_event, true);
|
|
7985
|
+
return;
|
|
7986
|
+
}
|
|
7987
|
+
_ = self.openChannel(.{ .key = options.key, .on_event = options.on_event });
|
|
7988
|
+
if (self.findChannelSlot(options.key) == null) return;
|
|
7989
|
+
session.* = .{ .active = true, .key = options.key };
|
|
7990
|
+
}
|
|
7991
|
+
const handle = self.channelHandle(options.key) orelse return;
|
|
7992
|
+
if (!handle.live()) return;
|
|
7993
|
+
|
|
7994
|
+
var accepted: [platform.max_global_shortcuts]platform.Shortcut = undefined;
|
|
7995
|
+
var accepted_count: usize = 0;
|
|
7996
|
+
for (options.shortcuts) |shortcut| {
|
|
7997
|
+
if (global_shortcuts_mod.admissible(shortcut, accepted[0..accepted_count])) {
|
|
7998
|
+
accepted[accepted_count] = shortcut;
|
|
7999
|
+
accepted_count += 1;
|
|
8000
|
+
} else {
|
|
8001
|
+
postGlobalShortcutReport(handle, .rejected, shortcut);
|
|
8002
|
+
}
|
|
8003
|
+
}
|
|
8004
|
+
|
|
8005
|
+
var statuses: [platform.max_global_shortcuts]platform.GlobalShortcutStatus = undefined;
|
|
8006
|
+
var unsupported = false;
|
|
8007
|
+
if (self.executor == .fake) {
|
|
8008
|
+
for (accepted[0..accepted_count], 0..) |shortcut, index| {
|
|
8009
|
+
statuses[index] = .registered;
|
|
8010
|
+
for (accepted[0..index]) |earlier| {
|
|
8011
|
+
if (platform.sameShortcutCombination(earlier, shortcut)) statuses[index] = .conflict;
|
|
8012
|
+
}
|
|
8013
|
+
}
|
|
8014
|
+
} else if (self.services) |services| {
|
|
8015
|
+
services.configureGlobalShortcuts(accepted[0..accepted_count], globalShortcutSink(handle), statuses[0..accepted_count]) catch {
|
|
8016
|
+
unsupported = true;
|
|
8017
|
+
};
|
|
8018
|
+
session.platform_configured = session.platform_configured or !unsupported;
|
|
8019
|
+
} else {
|
|
8020
|
+
unsupported = true;
|
|
8021
|
+
}
|
|
8022
|
+
|
|
8023
|
+
var next: [platform.max_global_shortcuts]global_shortcuts_mod.Binding = undefined;
|
|
8024
|
+
for (accepted[0..accepted_count], 0..) |shortcut, index| {
|
|
8025
|
+
const kind: EffectGlobalShortcutEventKind = if (unsupported) .unsupported else switch (statuses[index]) {
|
|
8026
|
+
inline else => |status| @field(EffectGlobalShortcutEventKind, @tagName(status)),
|
|
8027
|
+
};
|
|
8028
|
+
const unchanged = if (session.find(shortcut.id)) |previous| previous.shortcut.matches(shortcut) and previous.kind == .registered else false;
|
|
8029
|
+
if (!unchanged or kind != .registered) postGlobalShortcutReport(handle, kind, shortcut);
|
|
8030
|
+
next[index] = .{ .shortcut = .init(shortcut), .kind = kind };
|
|
8031
|
+
}
|
|
8032
|
+
@memcpy(session.bindings[0..accepted_count], next[0..accepted_count]);
|
|
8033
|
+
session.count = accepted_count;
|
|
8034
|
+
}
|
|
8035
|
+
|
|
8036
|
+
/// Unregister the set; reports end with `stopped`.
|
|
8037
|
+
pub fn clearGlobalShortcuts(self: *Self, key: u64) void {
|
|
8038
|
+
if (!self.global_shortcuts.active or self.global_shortcuts.key != key) return;
|
|
8039
|
+
self.closeChannel(key);
|
|
8040
|
+
}
|
|
8041
|
+
|
|
8042
|
+
fn releaseGlobalShortcuts(self: *Self) void {
|
|
8043
|
+
if (self.global_shortcuts.platform_configured) {
|
|
8044
|
+
if (self.services) |services| services.configureGlobalShortcuts(&.{}, globalShortcutSink(self.channelHandle(self.global_shortcuts.key) orelse .{}), &.{}) catch {};
|
|
8045
|
+
}
|
|
8046
|
+
self.global_shortcuts = .{};
|
|
8047
|
+
}
|
|
8048
|
+
|
|
7809
8049
|
/// Close the open channel with `key`: posts stop landing
|
|
7810
8050
|
/// immediately (the handle answers `.closed`), the staged
|
|
7811
8051
|
/// backlog flushes in post order, and exactly one terminal
|
|
@@ -7815,6 +8055,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
7815
8055
|
/// is NOT a channel's close (channels end the way audio does:
|
|
7816
8056
|
/// through their own verb).
|
|
7817
8057
|
pub fn closeChannel(self: *Self, key: u64) void {
|
|
8058
|
+
if (self.global_shortcuts.active and self.global_shortcuts.key == key) self.releaseGlobalShortcuts();
|
|
7818
8059
|
if (self.findAudioCaptureByKey(key)) |capture| {
|
|
7819
8060
|
if (capture.platform_started) {
|
|
7820
8061
|
if (self.services) |services| services.audioCaptureStop(capture.source) catch {};
|
|
@@ -8592,7 +8833,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
8592
8833
|
/// user-visible side effect.
|
|
8593
8834
|
pub fn showNotification(self: *Self, options: platform.NotificationOptions) void {
|
|
8594
8835
|
if (self.executor == .fake or self.replay) return;
|
|
8595
|
-
|
|
8836
|
+
@import("system_admission_policy.zig").notification(self.system_admission_policy, options) catch return;
|
|
8596
8837
|
const services = self.services orelse return;
|
|
8597
8838
|
services.showNotification(options) catch {};
|
|
8598
8839
|
}
|
|
@@ -9346,6 +9587,40 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9346
9587
|
self.startHostRequest(options, max_effect_host_payload_bytes, max_effect_host_result_bytes, null, null, null);
|
|
9347
9588
|
}
|
|
9348
9589
|
|
|
9590
|
+
pub const KeyChordOptions = struct {
|
|
9591
|
+
key: u64,
|
|
9592
|
+
chord: platform.KeyChord,
|
|
9593
|
+
on_result: ?HostMsgFn = null,
|
|
9594
|
+
};
|
|
9595
|
+
|
|
9596
|
+
pub const KeyboardAccessOptions = struct {
|
|
9597
|
+
key: u64,
|
|
9598
|
+
prompt: bool = false,
|
|
9599
|
+
on_result: ?HostMsgFn = null,
|
|
9600
|
+
};
|
|
9601
|
+
|
|
9602
|
+
/// Post a key chord to the focused app; requires the `keyboard_input` permission.
|
|
9603
|
+
pub fn sendKeyChord(self: *Self, options: KeyChordOptions) void {
|
|
9604
|
+
var payload: [keyboard_input.max_chord_payload_bytes]u8 = undefined;
|
|
9605
|
+
self.hostRequest(.{
|
|
9606
|
+
.key = options.key,
|
|
9607
|
+
.name = keyboard_input.send_chord_name,
|
|
9608
|
+
.payload = keyboard_input.encodeChord(&payload, options.chord),
|
|
9609
|
+
.on_result = options.on_result,
|
|
9610
|
+
});
|
|
9611
|
+
}
|
|
9612
|
+
|
|
9613
|
+
/// Ask for the OS grant; the ok bytes are `granted`, `denied`, or `not_required`.
|
|
9614
|
+
pub fn keyboardAccessStatus(self: *Self, options: KeyboardAccessOptions) void {
|
|
9615
|
+
const payload = [_]u8{@intFromBool(options.prompt)};
|
|
9616
|
+
self.hostRequest(.{
|
|
9617
|
+
.key = options.key,
|
|
9618
|
+
.name = keyboard_input.access_status_name,
|
|
9619
|
+
.payload = &payload,
|
|
9620
|
+
.on_result = options.on_result,
|
|
9621
|
+
});
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9349
9624
|
fn startHostRequest(
|
|
9350
9625
|
self: *Self,
|
|
9351
9626
|
options: HostRequestOptions,
|
|
@@ -9470,6 +9745,8 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9470
9745
|
slot.on_file = null;
|
|
9471
9746
|
slot.on_clipboard = null;
|
|
9472
9747
|
slot.on_host = options.on_result;
|
|
9748
|
+
slot.desktop_waiting = false;
|
|
9749
|
+
slot.replay_window_reply_len = 0;
|
|
9473
9750
|
slot.on_credentials = credentials_fn;
|
|
9474
9751
|
slot.cancel_requested.store(false, .release);
|
|
9475
9752
|
// `cancelled_generation` stays sticky, exactly as in `spawn`.
|
|
@@ -9494,7 +9771,10 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9494
9771
|
|
|
9495
9772
|
// Fake mode (tests and session replay) parks here: the feed
|
|
9496
9773
|
// is the only terminal source.
|
|
9497
|
-
if (fake)
|
|
9774
|
+
if (fake) {
|
|
9775
|
+
slot.desktop_waiting = self.defer_desktop_capabilities and @import("desktop_files.zig").isName(slot.hostName());
|
|
9776
|
+
return;
|
|
9777
|
+
}
|
|
9498
9778
|
if (store_op) |operation| {
|
|
9499
9779
|
if (operation == .get or operation == .scan) {
|
|
9500
9780
|
self.performBoundStoreRequest(slot.hostName(), options.key, slot.fetchPayload());
|
|
@@ -9508,6 +9788,10 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9508
9788
|
return;
|
|
9509
9789
|
}
|
|
9510
9790
|
if (native_request) {
|
|
9791
|
+
if (self.defer_desktop_capabilities and @import("desktop_files.zig").isName(slot.hostName())) {
|
|
9792
|
+
slot.desktop_waiting = true;
|
|
9793
|
+
return;
|
|
9794
|
+
}
|
|
9511
9795
|
self.performNativeHostRequest(slot.hostName(), options.key, slot.fetchPayload());
|
|
9512
9796
|
return;
|
|
9513
9797
|
}
|
|
@@ -9516,27 +9800,163 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9516
9800
|
}
|
|
9517
9801
|
|
|
9518
9802
|
fn isNativeHostRequestName(name: []const u8) bool {
|
|
9519
|
-
return std.mem.startsWith(u8, name, "core.store.") or
|
|
9803
|
+
return @import("desktop_files.zig").isName(name) or std.mem.startsWith(u8, name, "core.store.") or
|
|
9520
9804
|
std.mem.eql(u8, name, "native-sdk.launch-at-login.status") or
|
|
9521
9805
|
std.mem.eql(u8, name, "native-sdk.launch-at-login.set") or
|
|
9522
|
-
std.mem.eql(u8, name, "native-sdk.time.formatLocal")
|
|
9806
|
+
std.mem.eql(u8, name, "native-sdk.time.formatLocal") or
|
|
9807
|
+
keyboard_input.isRequestName(name);
|
|
9523
9808
|
}
|
|
9524
9809
|
|
|
9525
9810
|
fn isNativeHostSendName(name: []const u8) bool {
|
|
9526
9811
|
return std.mem.eql(u8, name, "native-sdk.os.openUrl") or
|
|
9812
|
+
std.mem.eql(u8, name, "native-sdk.debug.log") or
|
|
9527
9813
|
std.mem.eql(u8, name, "native-sdk.os.revealPath");
|
|
9528
9814
|
}
|
|
9529
9815
|
|
|
9530
9816
|
fn performNativeHostSend(self: *Self, name: []const u8, payload: []const u8) void {
|
|
9817
|
+
if (std.mem.eql(u8, name, "native-sdk.debug.log")) {
|
|
9818
|
+
if (payload.len <= 4096) std.debug.print("{s}", .{payload});
|
|
9819
|
+
return;
|
|
9820
|
+
}
|
|
9531
9821
|
const binding = self.system_services orelse return;
|
|
9532
9822
|
if (std.mem.eql(u8, name, "native-sdk.os.openUrl")) {
|
|
9533
|
-
binding.open_external_url_fn(binding.context, payload) catch {
|
|
9823
|
+
binding.open_external_url_fn(binding.context, payload) catch |err| {
|
|
9824
|
+
if (err == error.NavigationDenied) {
|
|
9825
|
+
std.debug.print("native warning: external URL denied by security.navigation.external_links\n", .{});
|
|
9826
|
+
} else {
|
|
9827
|
+
std.debug.print("native warning: external URL open failed: {s}\n", .{@errorName(err)});
|
|
9828
|
+
}
|
|
9829
|
+
};
|
|
9534
9830
|
} else {
|
|
9535
9831
|
binding.reveal_path_fn(binding.context, payload) catch {};
|
|
9536
9832
|
}
|
|
9537
9833
|
}
|
|
9538
9834
|
|
|
9835
|
+
/// Execute a captured batch in issue order after the view transaction.
|
|
9836
|
+
/// Slots own copied payloads; cancellation and replacement invalidate
|
|
9837
|
+
/// captured generations. Calls queued by a nested native event belong
|
|
9838
|
+
/// to the next batch, and fake/replay executors never reach the OS.
|
|
9839
|
+
pub fn flushDesktopCapabilities(self: *Self) void {
|
|
9840
|
+
if (self.executor == .fake) {
|
|
9841
|
+
if (self.replay) self.flushReplayWindowExecutions();
|
|
9842
|
+
return;
|
|
9843
|
+
}
|
|
9844
|
+
if (self.flushing_desktop_capabilities) return;
|
|
9845
|
+
self.flushing_desktop_capabilities = true;
|
|
9846
|
+
defer self.flushing_desktop_capabilities = false;
|
|
9847
|
+
const Pending = struct { index: usize, generation: u32 };
|
|
9848
|
+
var pending: [total_effect_slots]Pending = undefined;
|
|
9849
|
+
var count: usize = 0;
|
|
9850
|
+
const boundary = self.next_generation;
|
|
9851
|
+
for (&self.slots, 0..) |*slot, index| {
|
|
9852
|
+
if (slot.kind != .host or slot.fake or !slot.desktop_waiting or slot.state.load(.acquire) != .running) continue;
|
|
9853
|
+
var at = count;
|
|
9854
|
+
while (at > 0 and boundary -% pending[at - 1].generation < boundary -% slot.generation) : (at -= 1) {
|
|
9855
|
+
pending[at] = pending[at - 1];
|
|
9856
|
+
}
|
|
9857
|
+
pending[at] = .{ .index = index, .generation = slot.generation };
|
|
9858
|
+
count += 1;
|
|
9859
|
+
}
|
|
9860
|
+
for (pending[0..count]) |entry| {
|
|
9861
|
+
const slot = &self.slots[entry.index];
|
|
9862
|
+
if (slot.generation != entry.generation or slot.kind != .host or slot.fake or !slot.desktop_waiting or slot.state.load(.acquire) != .running) continue;
|
|
9863
|
+
slot.desktop_waiting = false;
|
|
9864
|
+
self.performDesktopCapability(entry.index);
|
|
9865
|
+
}
|
|
9866
|
+
}
|
|
9867
|
+
|
|
9868
|
+
fn feedDesktopResult(self: *Self, index: usize, generation: u32, ok: bool, bytes: []const u8) void {
|
|
9869
|
+
const slot = &self.slots[index];
|
|
9870
|
+
if (slot.kind != .host or slot.generation != generation or slot.state.load(.acquire) != .running) return;
|
|
9871
|
+
self.feedHostResult(slot.key, ok, bytes) catch {};
|
|
9872
|
+
}
|
|
9873
|
+
|
|
9874
|
+
fn performDesktopCapability(self: *Self, index: usize) void {
|
|
9875
|
+
const slot = &self.slots[index];
|
|
9876
|
+
const generation = slot.generation;
|
|
9877
|
+
const key = slot.key;
|
|
9878
|
+
const binding = self.system_services orelse return self.feedDesktopResult(index, generation, false, "unsupported");
|
|
9879
|
+
const execute = binding.execute_capability_fn orelse return self.feedDesktopResult(index, generation, false, "unsupported");
|
|
9880
|
+
// A modal native call can reenter the event loop and replace or
|
|
9881
|
+
// cancel this slot. Keep its arguments alive independently and
|
|
9882
|
+
// deliver only to the original occupancy when the call returns.
|
|
9883
|
+
var name_storage: [max_effect_host_name_bytes]u8 = undefined;
|
|
9884
|
+
const name = name_storage[0..slot.url_len];
|
|
9885
|
+
@memcpy(name, slot.hostName());
|
|
9886
|
+
const payload = self.allocator.dupe(u8, slot.fetchPayload()) catch return self.feedDesktopResult(index, generation, false, "unsupported");
|
|
9887
|
+
defer self.allocator.free(payload);
|
|
9888
|
+
const output = self.allocator.alloc(u8, max_effect_host_result_bytes) catch return self.feedDesktopResult(index, generation, false, "unsupported");
|
|
9889
|
+
defer self.allocator.free(output);
|
|
9890
|
+
const result = execute(binding.context, name, payload, output) catch |err| {
|
|
9891
|
+
self.feedDesktopResult(index, generation, false, @errorName(err));
|
|
9892
|
+
return;
|
|
9893
|
+
};
|
|
9894
|
+
if (desktopWindowSuccess(name, payload, result)) {
|
|
9895
|
+
self.journalNote(.{ .kind = .window_execution, .key = key, .code = @intFromBool(std.mem.eql(u8, name, "native-sdk.window.closeResult")), .payload = payload, .stderr_tail = result });
|
|
9896
|
+
}
|
|
9897
|
+
self.feedDesktopResult(index, generation, true, result);
|
|
9898
|
+
}
|
|
9899
|
+
|
|
9900
|
+
fn desktopWindowSuccess(name: []const u8, payload: []const u8, reply: []const u8) bool {
|
|
9901
|
+
if (!std.mem.eql(u8, name, "native-sdk.window.focusResult") and !std.mem.eql(u8, name, "native-sdk.window.closeResult")) return false;
|
|
9902
|
+
const desktop = @import("desktop_files.zig");
|
|
9903
|
+
var request = desktop.request(payload) catch return false;
|
|
9904
|
+
var response = desktop.request(reply) catch return false;
|
|
9905
|
+
if (request.at != response.at or !std.mem.eql(u8, payload[0..request.at], reply[0..response.at])) return false;
|
|
9906
|
+
const label = request.field() catch return false;
|
|
9907
|
+
request.finish() catch return false;
|
|
9908
|
+
const failure = response.field() catch return false;
|
|
9909
|
+
response.finish() catch return false;
|
|
9910
|
+
return failure.len == 0 and label.len > 0 and label.len <= 255 and std.mem.indexOfScalar(u8, label, 0) == null;
|
|
9911
|
+
}
|
|
9912
|
+
|
|
9913
|
+
/// Execution facts can precede their triggering event, like clock
|
|
9914
|
+
/// reads. Copy them until that event's settled view transaction claims
|
|
9915
|
+
/// the exact request. Neither native calls nor application Msgs run.
|
|
9916
|
+
pub fn pushReplayWindowExecution(self: *Self, record: EffectResultRecord) !void {
|
|
9917
|
+
const name = if (record.code == 1) "native-sdk.window.closeResult" else "native-sdk.window.focusResult";
|
|
9918
|
+
const canonical: EffectResultRecord = .{ .kind = .window_execution, .key = record.key, .code = record.code, .payload = record.payload, .stderr_tail = record.stderr_tail };
|
|
9919
|
+
if (!self.replay or record.kind != .window_execution or record.code < 0 or record.code > 1 or
|
|
9920
|
+
!std.meta.eql(record, canonical) or
|
|
9921
|
+
record.payload.len > 293 or record.stderr_tail.len > 38 or
|
|
9922
|
+
!desktopWindowSuccess(name, record.payload, record.stderr_tail)) return error.ReplayDamagedRecord;
|
|
9923
|
+
if (self.replay_window_execution_len == self.replay_window_executions.len) return error.ReplayWindowDivergence;
|
|
9924
|
+
const entry = &self.replay_window_executions[self.replay_window_execution_len];
|
|
9925
|
+
entry.key = record.key;
|
|
9926
|
+
entry.closed = record.code == 1;
|
|
9927
|
+
entry.request_len = @intCast(record.payload.len);
|
|
9928
|
+
@memcpy(entry.request[0..record.payload.len], record.payload);
|
|
9929
|
+
entry.reply_len = @intCast(record.stderr_tail.len);
|
|
9930
|
+
@memcpy(entry.reply[0..record.stderr_tail.len], record.stderr_tail);
|
|
9931
|
+
self.replay_window_execution_len += 1;
|
|
9932
|
+
}
|
|
9933
|
+
|
|
9934
|
+
fn flushReplayWindowExecutions(self: *Self) void {
|
|
9935
|
+
while (self.replay_window_execution_len > 0) {
|
|
9936
|
+
const entry = &self.replay_window_executions[0];
|
|
9937
|
+
const index = self.findActiveSlot(entry.key) orelse break;
|
|
9938
|
+
const slot = &self.slots[index];
|
|
9939
|
+
const name = if (entry.closed) "native-sdk.window.closeResult" else "native-sdk.window.focusResult";
|
|
9940
|
+
if (slot.kind != .host or !slot.fake or (self.defer_desktop_capabilities and !slot.desktop_waiting) or slot.state.load(.acquire) != .running or
|
|
9941
|
+
!std.mem.eql(u8, slot.hostName(), name) or !std.mem.eql(u8, slot.fetchPayload(), entry.request[0..entry.request_len])) break;
|
|
9942
|
+
if (slot.replay_window_reply_len != 0) {
|
|
9943
|
+
self.replay_window_diverged = true;
|
|
9944
|
+
break;
|
|
9945
|
+
}
|
|
9946
|
+
slot.desktop_waiting = false;
|
|
9947
|
+
slot.replay_window_reply_len = entry.reply_len;
|
|
9948
|
+
@memcpy(slot.replay_window_reply[0..entry.reply_len], entry.reply[0..entry.reply_len]);
|
|
9949
|
+
self.restoreDesktopWindowResult(slot, entry.reply[0..entry.reply_len]);
|
|
9950
|
+
self.replay_window_execution_len -= 1;
|
|
9951
|
+
std.mem.copyForwards(ReplayWindowExecution, self.replay_window_executions[0..self.replay_window_execution_len], self.replay_window_executions[1 .. self.replay_window_execution_len + 1]);
|
|
9952
|
+
}
|
|
9953
|
+
}
|
|
9954
|
+
|
|
9539
9955
|
fn performNativeHostRequest(self: *Self, name: []const u8, key: u64, payload: []const u8) void {
|
|
9956
|
+
if (@import("desktop_files.zig").isName(name)) {
|
|
9957
|
+
self.performDesktopCapability(self.findActiveSlot(key) orelse return);
|
|
9958
|
+
return;
|
|
9959
|
+
}
|
|
9540
9960
|
if (std.mem.startsWith(u8, name, "core.store.")) {
|
|
9541
9961
|
self.performBoundStoreRequest(name, key, payload);
|
|
9542
9962
|
return;
|
|
@@ -9545,6 +9965,13 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9545
9965
|
self.performBoundSystemRequest(name, key, payload);
|
|
9546
9966
|
return;
|
|
9547
9967
|
}
|
|
9968
|
+
if (keyboard_input.isRequestName(name)) {
|
|
9969
|
+
const binding = (self.system_services orelse return self.feedUnsupportedNativeRequest(key)).keyboard_input orelse
|
|
9970
|
+
return self.feedUnsupportedNativeRequest(key);
|
|
9971
|
+
const result = keyboard_input.execute(binding, name, payload);
|
|
9972
|
+
self.feedHostResult(key, result.ok, result.bytes) catch {};
|
|
9973
|
+
return;
|
|
9974
|
+
}
|
|
9548
9975
|
const services = self.services orelse {
|
|
9549
9976
|
self.feedHostResult(key, false, "unsupported") catch {};
|
|
9550
9977
|
return;
|
|
@@ -9572,6 +9999,10 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
9572
9999
|
self.feedHostResult(key, true, launchAtLoginStatusName(status)) catch {};
|
|
9573
10000
|
}
|
|
9574
10001
|
|
|
10002
|
+
fn feedUnsupportedNativeRequest(self: *Self, key: u64) void {
|
|
10003
|
+
self.feedHostResult(key, false, "unsupported") catch {};
|
|
10004
|
+
}
|
|
10005
|
+
|
|
9575
10006
|
fn performBoundStoreRequest(self: *Self, name: []const u8, key: u64, payload: []const u8) void {
|
|
9576
10007
|
const binding = self.record_store_binding orelse {
|
|
9577
10008
|
self.feedHostResult(key, false, "rejected") catch {};
|
|
@@ -10007,6 +10438,25 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10007
10438
|
} });
|
|
10008
10439
|
}
|
|
10009
10440
|
|
|
10441
|
+
/// Cancel only an image load under this exact identity. A rejected
|
|
10442
|
+
/// image request may share a key with another live effect; that
|
|
10443
|
+
/// incumbent belongs to its original caller and must stay intact.
|
|
10444
|
+
pub fn cancelImage(self: *Self, key: u64) void {
|
|
10445
|
+
const index = self.findActiveSlot(key) orelse self.findFinishedSlot(key) orelse return;
|
|
10446
|
+
if (self.slots[index].kind != .image) return;
|
|
10447
|
+
self.cancel(key);
|
|
10448
|
+
}
|
|
10449
|
+
|
|
10450
|
+
/// Named bridge operations use their own keys, but full-width image
|
|
10451
|
+
/// identities may coincide with them. Preserve the image incumbent
|
|
10452
|
+
/// when a rejected named operation is cancelled before delivery.
|
|
10453
|
+
pub fn cancelNonImage(self: *Self, key: u64) void {
|
|
10454
|
+
if (self.findActiveSlot(key) orelse self.findFinishedSlot(key)) |index| {
|
|
10455
|
+
if (self.slots[index].kind == .image) return;
|
|
10456
|
+
}
|
|
10457
|
+
self.cancel(key);
|
|
10458
|
+
}
|
|
10459
|
+
|
|
10010
10460
|
/// Cancel a running effect by key. After this returns, no
|
|
10011
10461
|
/// further `on_line` Msgs for that spawn are dispatched; one
|
|
10012
10462
|
/// `on_exit` Msg with reason `.cancelled` follows once the
|
|
@@ -10132,7 +10582,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10132
10582
|
/// platform without a timer service delivers exactly one Msg
|
|
10133
10583
|
/// with outcome `.rejected` on the next drain.
|
|
10134
10584
|
pub fn startTimer(self: *Self, options: StartTimerOptions) void {
|
|
10135
|
-
if (options.interval_ms == 0) return self.rejectTimer(options);
|
|
10585
|
+
if (options.interval_ms == 0 or options.interval_ms > std.math.maxInt(u64) / std.time.ns_per_ms) return self.rejectTimer(options);
|
|
10136
10586
|
const fake = self.executor == .fake;
|
|
10137
10587
|
// Services are bound before init_fx/update ever run; a null
|
|
10138
10588
|
// here means a host without the platform timer arm.
|
|
@@ -10208,11 +10658,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10208
10658
|
/// is its own namespace (like timer keys) and identifies the
|
|
10209
10659
|
/// playback in every event; it consumes no `max_effects` slots.
|
|
10210
10660
|
pub fn playAudio(self: *Self, options: PlayAudioOptions) void {
|
|
10211
|
-
|
|
10212
|
-
options.path.len > max_effect_audio_path_bytes or
|
|
10213
|
-
options.url.len > max_effect_audio_path_bytes or
|
|
10214
|
-
options.cache_path.len > max_effect_audio_path_bytes;
|
|
10215
|
-
if (rejected) {
|
|
10661
|
+
if (audioPlayRejected(options)) {
|
|
10216
10662
|
self.deliverLoopAudio(.{ .key = options.key, .kind = .rejected }, options.on_event);
|
|
10217
10663
|
return;
|
|
10218
10664
|
}
|
|
@@ -10271,6 +10717,15 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10271
10717
|
if (volume != 1.0) services.audioSetVolume(volume) catch {};
|
|
10272
10718
|
}
|
|
10273
10719
|
|
|
10720
|
+
/// The native source admission boundary; rejected loads retain the
|
|
10721
|
+
/// active player and deliver their own deferred result.
|
|
10722
|
+
pub fn audioPlayRejected(options: PlayAudioOptions) bool {
|
|
10723
|
+
return (options.path.len == 0 and options.url.len == 0) or
|
|
10724
|
+
options.path.len > max_effect_audio_path_bytes or
|
|
10725
|
+
options.url.len > max_effect_audio_path_bytes or
|
|
10726
|
+
options.cache_path.len > max_effect_audio_path_bytes;
|
|
10727
|
+
}
|
|
10728
|
+
|
|
10274
10729
|
/// Pause the current playback in place. Idle channels no-op; no
|
|
10275
10730
|
/// event echoes — the caller commanded it, so the caller knows.
|
|
10276
10731
|
pub fn pauseAudio(self: *Self) void {
|
|
@@ -10364,12 +10819,19 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10364
10819
|
/// a `close_policy = .hide` hide and also brings back a minimized
|
|
10365
10820
|
/// or merely backgrounded window. Fire-and-forget, same contract
|
|
10366
10821
|
/// as `closeWindow`: no event echoes beyond the window's own
|
|
10367
|
-
/// frame event, an unknown label is a no-op, and
|
|
10368
|
-
///
|
|
10822
|
+
/// frame event, an unknown label is a no-op, and ordinary fake
|
|
10823
|
+
/// execution only records the request in the mirror. Replay also
|
|
10824
|
+
/// restores the synchronous visibility/focus transition before
|
|
10825
|
+
/// any checkpoint, without entering the native show service.
|
|
10369
10826
|
pub fn showWindow(self: *Self, window_label: []const u8) void {
|
|
10370
10827
|
self.window_action_state.show_count += 1;
|
|
10371
10828
|
self.window_action_state.record(window_label);
|
|
10372
|
-
if (self.executor == .fake)
|
|
10829
|
+
if (self.executor == .fake) {
|
|
10830
|
+
if (self.replay) if (self.window_actions) |binding| {
|
|
10831
|
+
if (binding.replay_show_fn) |restore| restore(binding.context, window_label);
|
|
10832
|
+
};
|
|
10833
|
+
return;
|
|
10834
|
+
}
|
|
10373
10835
|
const binding = self.window_actions orelse return;
|
|
10374
10836
|
_ = binding.show_fn(binding.context, window_label);
|
|
10375
10837
|
}
|
|
@@ -10424,10 +10886,6 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10424
10886
|
/// or has no handler. Loop-thread only; called by
|
|
10425
10887
|
/// `UiApp.handleEvent` for `.audio` platform events.
|
|
10426
10888
|
pub fn takeAudioMsg(self: *Self, platform_event: platform.AudioEvent) ?Msg {
|
|
10427
|
-
// Under replay the journaled effect records are the ONLY
|
|
10428
|
-
// Msg source (fed through `feedAudioEvent`); the replayed
|
|
10429
|
-
// platform `.audio` events would double-deliver.
|
|
10430
|
-
if (self.replay) return null;
|
|
10431
10889
|
const kind: EffectAudioEventKind = switch (platform_event.kind) {
|
|
10432
10890
|
.loaded => .loaded,
|
|
10433
10891
|
.position => .position,
|
|
@@ -10445,6 +10903,21 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10445
10903
|
.buffering = platform_event.buffering,
|
|
10446
10904
|
.bands = platform_event.bands,
|
|
10447
10905
|
}) orelse return null;
|
|
10906
|
+
if (self.replay) {
|
|
10907
|
+
// Live reports deliver synchronously. Pair the fed result
|
|
10908
|
+
// with this event now, leaving deferred rejections and other
|
|
10909
|
+
// completions in their original drain order.
|
|
10910
|
+
if (self.takePendingAudioMatching(event.key)) |recorded| {
|
|
10911
|
+
if (!std.meta.eql(recorded, event)) {
|
|
10912
|
+
self.replay_audio_diverged = true;
|
|
10913
|
+
return null;
|
|
10914
|
+
}
|
|
10915
|
+
const event_fn = audio_fn orelse return null;
|
|
10916
|
+
return event_fn(recorded);
|
|
10917
|
+
}
|
|
10918
|
+
if (audio_fn != null) self.replay_audio_diverged = true;
|
|
10919
|
+
return null;
|
|
10920
|
+
}
|
|
10448
10921
|
const event_fn = audio_fn orelse return null;
|
|
10449
10922
|
self.journalNote(.{
|
|
10450
10923
|
.kind = .audio,
|
|
@@ -10490,6 +10963,36 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10490
10963
|
};
|
|
10491
10964
|
}
|
|
10492
10965
|
|
|
10966
|
+
/// Queue every field of a recorded delivery, including its owner
|
|
10967
|
+
/// key and spectrum transport flags. Platform audio events pair
|
|
10968
|
+
/// these records synchronously; fake executor feeds still drain.
|
|
10969
|
+
pub fn feedAudioRecord(self: *Self, event: EffectAudio) !void {
|
|
10970
|
+
if (!self.audio.active or self.audio.key != event.key) return error.EffectNotFound;
|
|
10971
|
+
self.deliverPending(.{ .audio = .{ .event = event, .audio_fn = null, .resolve = true } });
|
|
10972
|
+
}
|
|
10973
|
+
|
|
10974
|
+
/// Remove only the first fed audio result for this channel. Shift
|
|
10975
|
+
/// entries and their sequence stamps together so unrelated deferred
|
|
10976
|
+
/// completions retain their exact order, including wrapped rings.
|
|
10977
|
+
fn takePendingAudioMatching(self: *Self, key: u64) ?EffectAudio {
|
|
10978
|
+
for (0..self.pending_exit_len) |offset| {
|
|
10979
|
+
const index = (self.pending_exit_head + offset) % max_effect_pending_exits;
|
|
10980
|
+
const entry = self.pending_exits[index];
|
|
10981
|
+
if (entry != .audio or !entry.audio.resolve or entry.audio.event.key != key) continue;
|
|
10982
|
+
var hole = offset;
|
|
10983
|
+
while (hole + 1 < self.pending_exit_len) : (hole += 1) {
|
|
10984
|
+
const to = (self.pending_exit_head + hole) % max_effect_pending_exits;
|
|
10985
|
+
const from = (self.pending_exit_head + hole + 1) % max_effect_pending_exits;
|
|
10986
|
+
self.pending_exits[to] = self.pending_exits[from];
|
|
10987
|
+
self.pending_exit_seqs[to] = self.pending_exit_seqs[from];
|
|
10988
|
+
}
|
|
10989
|
+
self.pending_exit_len -= 1;
|
|
10990
|
+
if (self.pending_exit_len == 0) self.pending_exit_head = 0;
|
|
10991
|
+
return entry.audio.event;
|
|
10992
|
+
}
|
|
10993
|
+
return null;
|
|
10994
|
+
}
|
|
10995
|
+
|
|
10493
10996
|
/// Fake executor / replay: feed one audio event as the platform
|
|
10494
10997
|
/// would deliver it. The event resolves against the live channel
|
|
10495
10998
|
/// at drain time (key and handler from the channel, mirrors
|
|
@@ -10499,9 +11002,8 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
10499
11002
|
return self.feedAudioEventBuffering(kind, position_ms, duration_ms, playing, false);
|
|
10500
11003
|
}
|
|
10501
11004
|
|
|
10502
|
-
/// `feedAudioEvent` with the stream-stall flag
|
|
10503
|
-
///
|
|
10504
|
-
/// suites use; the plain feed keeps local-file tests terse.
|
|
11005
|
+
/// `feedAudioEvent` with the stream-stall flag for fake executor
|
|
11006
|
+
/// stream tests; the plain feed keeps local-file tests terse.
|
|
10505
11007
|
pub fn feedAudioEventBuffering(self: *Self, kind: EffectAudioEventKind, position_ms: u64, duration_ms: u64, playing: bool, buffering: bool) !void {
|
|
10506
11008
|
if (!self.audio.active) return error.EffectNotFound;
|
|
10507
11009
|
self.deliverPending(.{ .audio = .{
|
|
@@ -11749,6 +12251,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
11749
12251
|
if (entry.retire_slot) |slot_index| {
|
|
11750
12252
|
const parked = &self.channel_slots[slot_index];
|
|
11751
12253
|
if (parked.state != .idle and parked.generation == entry.retire_generation) {
|
|
12254
|
+
if (self.global_shortcuts.active and self.global_shortcuts.key == parked.key) self.global_shortcuts = .{};
|
|
11752
12255
|
retireChannelSlot(parked);
|
|
11753
12256
|
}
|
|
11754
12257
|
}
|
|
@@ -12751,6 +13254,8 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
12751
13254
|
if (seen == index) {
|
|
12752
13255
|
return .{
|
|
12753
13256
|
.key = slot.key,
|
|
13257
|
+
.generation = slot.generation,
|
|
13258
|
+
.timeout_ms = slot.timeout_ms,
|
|
12754
13259
|
.method = slot.method,
|
|
12755
13260
|
.url = slot.fetchUrl(),
|
|
12756
13261
|
.headers = slot.fetchHeaders(),
|
|
@@ -12846,6 +13351,16 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
12846
13351
|
/// feed, which must deliver exactly the reason the recorded
|
|
12847
13352
|
/// session delivered (`.signaled`, `.cancelled`, ...).
|
|
12848
13353
|
pub fn feedExitReason(self: *Self, key: u64, code: i32, reason: EffectExitReason) error{EffectNotFound}!void {
|
|
13354
|
+
return self.feedExitWithMetadata(key, code, reason, .{});
|
|
13355
|
+
}
|
|
13356
|
+
|
|
13357
|
+
/// Preserve the complete journaled terminal, including loss that
|
|
13358
|
+
/// cannot be inferred from an already-truncated output/tail payload.
|
|
13359
|
+
pub fn feedExitWithMetadata(self: *Self, key: u64, code: i32, reason: EffectExitReason, metadata: struct {
|
|
13360
|
+
output_truncated: bool = false,
|
|
13361
|
+
stderr_truncated: bool = false,
|
|
13362
|
+
dropped_lines: ?u32 = null,
|
|
13363
|
+
}) error{EffectNotFound}!void {
|
|
12849
13364
|
const slot_index = self.findActiveFakeSlot(key, .spawn) orelse return error.EffectNotFound;
|
|
12850
13365
|
const slot = &self.slots[slot_index];
|
|
12851
13366
|
var entry: Entry = .{
|
|
@@ -12855,12 +13370,16 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
12855
13370
|
.key = slot.key,
|
|
12856
13371
|
.code = code,
|
|
12857
13372
|
.reason = reason,
|
|
12858
|
-
.dropped_lines = slot.dropped_total,
|
|
13373
|
+
.dropped_lines = metadata.dropped_lines orelse slot.dropped_total,
|
|
13374
|
+
.collect_truncated = metadata.output_truncated,
|
|
13375
|
+
.stderr_truncated = metadata.stderr_truncated,
|
|
12859
13376
|
.exit_fn = slot.on_exit,
|
|
12860
13377
|
};
|
|
12861
13378
|
const exit_fn = slot.on_exit;
|
|
12862
13379
|
if (slot.output_mode == .collect) {
|
|
12863
13380
|
stampCollectExit(slot, &entry);
|
|
13381
|
+
entry.collect_truncated = entry.collect_truncated or metadata.output_truncated;
|
|
13382
|
+
entry.stderr_truncated = entry.stderr_truncated or metadata.stderr_truncated;
|
|
12864
13383
|
slot.state.store(.draining, .release);
|
|
12865
13384
|
if (!self.enqueue(&entry)) {
|
|
12866
13385
|
self.releaseSpawnSlot(slot);
|
|
@@ -12890,6 +13409,8 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
12890
13409
|
.code = code,
|
|
12891
13410
|
.reason = reason,
|
|
12892
13411
|
.dropped_lines = entry.dropped_lines,
|
|
13412
|
+
.output_truncated = entry.collect_truncated,
|
|
13413
|
+
.stderr_truncated = entry.stderr_truncated,
|
|
12893
13414
|
}, exit_fn);
|
|
12894
13415
|
}
|
|
12895
13416
|
self.wakeHost();
|
|
@@ -12998,9 +13519,10 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
12998
13519
|
if (seen == index) {
|
|
12999
13520
|
return .{
|
|
13000
13521
|
.key = slot.key,
|
|
13522
|
+
.generation = slot.generation,
|
|
13001
13523
|
.op = slot.file_op,
|
|
13002
13524
|
.path = slot.filePath(),
|
|
13003
|
-
.bytes = if (slot.file_op == .write) slot.fetchPayload() else "",
|
|
13525
|
+
.bytes = if (slot.file_op == .write or slot.file_op == .append) slot.fetchPayload() else "",
|
|
13004
13526
|
};
|
|
13005
13527
|
}
|
|
13006
13528
|
seen += 1;
|
|
@@ -13151,6 +13673,7 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13151
13673
|
if (seen == index) {
|
|
13152
13674
|
return .{
|
|
13153
13675
|
.key = slot.key,
|
|
13676
|
+
.generation = slot.generation,
|
|
13154
13677
|
.op = slot.clipboard_op,
|
|
13155
13678
|
.text = if (slot.clipboard_op == .write) slot.fetchPayload() else "",
|
|
13156
13679
|
};
|
|
@@ -13382,6 +13905,32 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13382
13905
|
return count;
|
|
13383
13906
|
}
|
|
13384
13907
|
|
|
13908
|
+
/// The index-th parked fake database operation, in slot order. Live
|
|
13909
|
+
/// query facts borrow engine-owned storage until the next operation.
|
|
13910
|
+
pub fn pendingDbAt(self: *Self, index: usize) ?struct {
|
|
13911
|
+
key: u64,
|
|
13912
|
+
generation: u64,
|
|
13913
|
+
kind: DbSlotKind,
|
|
13914
|
+
sql: []const u8,
|
|
13915
|
+
params: []const EffectDbValue,
|
|
13916
|
+
tables: []const []const u8,
|
|
13917
|
+
} {
|
|
13918
|
+
var seen: usize = 0;
|
|
13919
|
+
for (&self.db_slots) |*slot| {
|
|
13920
|
+
if (!slot.active or !slot.fake) continue;
|
|
13921
|
+
if (seen == index) return .{
|
|
13922
|
+
.key = slot.key,
|
|
13923
|
+
.generation = slot.generation,
|
|
13924
|
+
.kind = slot.kind,
|
|
13925
|
+
.sql = if (slot.live) |live| live.sql else "",
|
|
13926
|
+
.params = if (slot.live) |live| live.params else &.{},
|
|
13927
|
+
.tables = if (slot.live) |live| live.tables else &.{},
|
|
13928
|
+
};
|
|
13929
|
+
seen += 1;
|
|
13930
|
+
}
|
|
13931
|
+
return null;
|
|
13932
|
+
}
|
|
13933
|
+
|
|
13385
13934
|
/// Number of parked (still-active) fake host requests.
|
|
13386
13935
|
pub fn pendingHostCount(self: *Self) usize {
|
|
13387
13936
|
var count: usize = 0;
|
|
@@ -13419,13 +13968,21 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13419
13968
|
/// whole one); if the completion queue is somehow full, the
|
|
13420
13969
|
/// terminal still lands through the pending ring as an err —
|
|
13421
13970
|
/// never a silent ok with lost bytes.
|
|
13422
|
-
pub fn feedHostResult(self: *Self, key: u64, ok: bool, bytes: []const u8) error{EffectNotFound}!void {
|
|
13971
|
+
pub fn feedHostResult(self: *Self, key: u64, ok: bool, bytes: []const u8) error{ EffectNotFound, ReplayWindowDivergence }!void {
|
|
13423
13972
|
const slot_index = blk: {
|
|
13424
13973
|
const index = self.findActiveSlot(key) orelse return error.EffectNotFound;
|
|
13425
13974
|
if (self.slots[index].kind != .host and self.slots[index].kind != .store and self.slots[index].kind != .credentials) return error.EffectNotFound;
|
|
13426
13975
|
break :blk index;
|
|
13427
13976
|
};
|
|
13428
13977
|
const slot = &self.slots[slot_index];
|
|
13978
|
+
if (self.replay and desktopWindowSuccess(slot.hostName(), slot.fetchPayload(), bytes)) {
|
|
13979
|
+
// Test-owned replies can arrive after the request's settled
|
|
13980
|
+
// view flush. Their execution fact belongs to this completion
|
|
13981
|
+
// boundary; live facts are normally claimed by the flush.
|
|
13982
|
+
self.flushReplayWindowExecutions();
|
|
13983
|
+
if (!ok or slot.replay_window_reply_len == 0 or !std.mem.eql(u8, bytes, slot.replay_window_reply[0..slot.replay_window_reply_len])) return error.ReplayWindowDivergence;
|
|
13984
|
+
} else if (self.replay and slot.replay_window_reply_len != 0) return error.ReplayWindowDivergence;
|
|
13985
|
+
slot.replay_window_reply_len = 0;
|
|
13429
13986
|
const buffer = slot.fetch_buffer orelse return error.EffectNotFound;
|
|
13430
13987
|
const capacity = buffer.len - slot.payload_len;
|
|
13431
13988
|
var delivered_ok = ok;
|
|
@@ -13434,6 +13991,12 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13434
13991
|
delivered_ok = false;
|
|
13435
13992
|
delivered = "host result over budget";
|
|
13436
13993
|
}
|
|
13994
|
+
if (slot.fake and !self.replay and delivered_ok) {
|
|
13995
|
+
if (desktopWindowSuccess(slot.hostName(), slot.fetchPayload(), delivered)) {
|
|
13996
|
+
self.journalNote(.{ .kind = .window_execution, .key = key, .code = @intFromBool(std.mem.eql(u8, slot.hostName(), "native-sdk.window.closeResult")), .payload = slot.fetchPayload(), .stderr_tail = delivered });
|
|
13997
|
+
}
|
|
13998
|
+
self.restoreDesktopWindowResult(slot, delivered);
|
|
13999
|
+
}
|
|
13437
14000
|
@memcpy(buffer[slot.payload_len..][0..delivered.len], delivered);
|
|
13438
14001
|
slot.body_len = delivered.len;
|
|
13439
14002
|
var entry: Entry = .{
|
|
@@ -13466,6 +14029,23 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13466
14029
|
self.wakeHost();
|
|
13467
14030
|
}
|
|
13468
14031
|
|
|
14032
|
+
fn restoreDesktopWindowResult(self: *Self, slot: *Slot, bytes: []const u8) void {
|
|
14033
|
+
const closed = std.mem.eql(u8, slot.hostName(), "native-sdk.window.closeResult");
|
|
14034
|
+
if (!closed and !std.mem.eql(u8, slot.hostName(), "native-sdk.window.focusResult")) return;
|
|
14035
|
+
const binding = self.system_services orelse return;
|
|
14036
|
+
const restore = binding.replay_window_result_fn orelse return;
|
|
14037
|
+
const desktop = @import("desktop_files.zig");
|
|
14038
|
+
var request = desktop.request(slot.fetchPayload()) catch return;
|
|
14039
|
+
var reply = desktop.request(bytes) catch return;
|
|
14040
|
+
if (request.at != reply.at or !std.mem.eql(u8, request.bytes[0..request.at], bytes[0..reply.at])) return;
|
|
14041
|
+
const label = request.field() catch return;
|
|
14042
|
+
request.finish() catch return;
|
|
14043
|
+
const failure = reply.field() catch return;
|
|
14044
|
+
reply.finish() catch return;
|
|
14045
|
+
if (failure.len != 0 or label.len == 0 or label.len > 255 or std.mem.indexOfScalar(u8, label, 0) != null) return;
|
|
14046
|
+
restore(binding.context, label, closed);
|
|
14047
|
+
}
|
|
14048
|
+
|
|
13469
14049
|
/// Replay one redacted credential result. A successful get receives a
|
|
13470
14050
|
/// deterministic same-length placeholder derived from the recorded
|
|
13471
14051
|
/// digest; no keychain is touched and no live secret is recoverable
|
|
@@ -13527,6 +14107,15 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13527
14107
|
return null;
|
|
13528
14108
|
}
|
|
13529
14109
|
|
|
14110
|
+
/// Build a fake timer's platform event without firing it. Harnesses
|
|
14111
|
+
/// that record sessions dispatch this event through Runtime so replay
|
|
14112
|
+
/// can regenerate the timer Msg from the same journaled input.
|
|
14113
|
+
pub fn fakeTimerEvent(self: *Self, key: u64, timestamp_ns: u64) error{EffectNotFound}!platform.TimerEvent {
|
|
14114
|
+
const index = self.findActiveTimerIndex(key) orelse return error.EffectNotFound;
|
|
14115
|
+
if (!self.timer_slots[index].fake) return error.EffectNotFound;
|
|
14116
|
+
return .{ .id = effectTimerPlatformId(index), .timestamp_ns = timestamp_ns };
|
|
14117
|
+
}
|
|
14118
|
+
|
|
13530
14119
|
/// Fire the fake fx timer with `key` by hand: its `on_fire` Msg
|
|
13531
14120
|
/// (timestamp 0 — the fake executor has no clock) lands through
|
|
13532
14121
|
/// the pending ring and drains on the next `.effects_wake`
|
|
@@ -13692,6 +14281,20 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
13692
14281
|
return null;
|
|
13693
14282
|
}
|
|
13694
14283
|
|
|
14284
|
+
fn postGlobalShortcutReport(handle: ChannelHandle, kind: EffectGlobalShortcutEventKind, shortcut: platform.Shortcut) void {
|
|
14285
|
+
var packet: [global_shortcuts_mod.max_packet_bytes]u8 = undefined;
|
|
14286
|
+
_ = handle.post(global_shortcuts_mod.encodePacket(&packet, kind, shortcut));
|
|
14287
|
+
}
|
|
14288
|
+
|
|
14289
|
+
fn globalShortcutSink(handle: ChannelHandle) platform.GlobalShortcutSink {
|
|
14290
|
+
return .{ .context = handle.shared, .generation = handle.generation, .push_fn = pushGlobalShortcutEvent };
|
|
14291
|
+
}
|
|
14292
|
+
|
|
14293
|
+
fn pushGlobalShortcutEvent(context: ?*anyopaque, generation: u64, event: platform.GlobalShortcutEvent) void {
|
|
14294
|
+
const handle: ChannelHandle = .{ .shared = @ptrCast(@alignCast(context orelse return)), .generation = generation };
|
|
14295
|
+
postGlobalShortcutReport(handle, if (event.phase == .pressed) .pressed else .released, event.shortcut);
|
|
14296
|
+
}
|
|
14297
|
+
|
|
13695
14298
|
fn pushAudioCaptureEvent(context: ?*anyopaque, generation: u64, event: platform.AudioCaptureEvent) platform.AudioCapturePushResult {
|
|
13696
14299
|
const shared: *ChannelShared = @ptrCast(@alignCast(context orelse return .closed));
|
|
13697
14300
|
var packet: [max_effect_channel_bytes]u8 = undefined;
|
|
@@ -14453,6 +15056,8 @@ pub fn Effects(comptime Msg: type) type {
|
|
|
14453
15056
|
slot.line_buffer = null;
|
|
14454
15057
|
}
|
|
14455
15058
|
if (slot.kind == .credentials) slot.credentials_waiting = false;
|
|
15059
|
+
slot.desktop_waiting = false;
|
|
15060
|
+
slot.replay_window_reply_len = 0;
|
|
14456
15061
|
slot.state.store(.idle, .release);
|
|
14457
15062
|
}
|
|
14458
15063
|
|