@native-sdk/cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1796 -83
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/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 +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -780,6 +780,7 @@ test "a declared context menu presents as the anchored fallback surface on prese
|
|
|
780
780
|
defer std.testing.allocator.destroy(app_state);
|
|
781
781
|
app_state.* = TaskRowApp.init(std.heap.page_allocator, .{}, taskRowOptions());
|
|
782
782
|
defer app_state.deinit();
|
|
783
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
783
784
|
const app = app_state.app();
|
|
784
785
|
try harness.start(app);
|
|
785
786
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -1999,6 +2000,30 @@ test "malformed adapter theme accents reject the rebuild instead of inheriting s
|
|
|
1999
2000
|
try std.testing.expect(!app_state.installed);
|
|
2000
2001
|
}
|
|
2001
2002
|
|
|
2003
|
+
test "model accessibility theme flags preserve omission and explicit false and complete-token precedence" {
|
|
2004
|
+
const state = try std.testing.allocator.create(CounterApp);
|
|
2005
|
+
defer std.testing.allocator.destroy(state);
|
|
2006
|
+
state.* = CounterApp.init(std.testing.allocator, .{}, counterOptions());
|
|
2007
|
+
defer state.deinit();
|
|
2008
|
+
state.theme_state_known = true;
|
|
2009
|
+
const accent = canvas.Color.rgb8(0xdf, 0x26, 0x70);
|
|
2010
|
+
const flags = [_]?bool{ null, false, true };
|
|
2011
|
+
for ([_]bool{ false, true }) |dark| for ([_]bool{ false, true }) |os_contrast| for ([_]bool{ false, true }) |os_motion| {
|
|
2012
|
+
state.system_appearance = .{ .color_scheme = if (dark) .dark else .light, .high_contrast = os_contrast, .reduce_motion = os_motion };
|
|
2013
|
+
for (flags) |contrast| for (flags) |motion| {
|
|
2014
|
+
state.theme_state = .{ .pack = .geist, .accent = accent, .high_contrast = contrast, .reduce_motion = motion };
|
|
2015
|
+
const scheme: canvas.ColorScheme = if (dark) .dark else .light;
|
|
2016
|
+
var expected = canvas.DesignTokens.theme(.{ .pack = .geist, .color_scheme = scheme, .contrast = if (contrast orelse os_contrast) .high else .standard, .reduce_motion = motion orelse os_motion });
|
|
2017
|
+
if (!(contrast orelse os_contrast)) expected = expected.withOverrides(canvas.accentOverrides(accent, scheme));
|
|
2018
|
+
try std.testing.expectEqualDeep(expected, state.effectiveTokens());
|
|
2019
|
+
};
|
|
2020
|
+
};
|
|
2021
|
+
const complete = canvas.DesignTokens.theme(.{ .color_scheme = .light });
|
|
2022
|
+
state.options.tokens = complete;
|
|
2023
|
+
state.theme_state = .{ .high_contrast = true, .reduce_motion = true, .invalid_accent = "ignored" };
|
|
2024
|
+
try std.testing.expectEqualDeep(complete, state.effectiveTokens());
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2002
2027
|
test "forced theme state still follows accessibility axes while scheme-only OS flips do not restyle" {
|
|
2003
2028
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2004
2029
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -2235,6 +2260,14 @@ const watch_import_parts_markup_v2 =
|
|
|
2235
2260
|
\\</template>
|
|
2236
2261
|
;
|
|
2237
2262
|
|
|
2263
|
+
const watch_nested_import_root_markup =
|
|
2264
|
+
\\<import src="components/actions.native"/>
|
|
2265
|
+
\\<column gap="8" padding="12">
|
|
2266
|
+
\\ <text>Count {count}</text>
|
|
2267
|
+
\\ <use template="actions" />
|
|
2268
|
+
\\</column>
|
|
2269
|
+
;
|
|
2270
|
+
|
|
2238
2271
|
test "the markup watch reloads when an IMPORTED file changes on disk" {
|
|
2239
2272
|
const io = std.testing.io;
|
|
2240
2273
|
const watch_path = ".zig-cache/ui-app-markup-watch-import-test.native";
|
|
@@ -2309,26 +2342,27 @@ test "the markup watch reloads when an IMPORTED file changes on disk" {
|
|
|
2309
2342
|
}
|
|
2310
2343
|
|
|
2311
2344
|
const watch_import_sources = [_]canvas.ui_markup.SourceFile{
|
|
2312
|
-
.{ .path = "
|
|
2313
|
-
.{ .path = "
|
|
2345
|
+
.{ .path = "app.native", .source = watch_nested_import_root_markup },
|
|
2346
|
+
.{ .path = "components/actions.native", .source = watch_import_parts_markup },
|
|
2314
2347
|
};
|
|
2315
2348
|
|
|
2316
2349
|
const CompiledImportCounterView = canvas.CompiledMarkupImports(
|
|
2317
2350
|
CounterModel,
|
|
2318
2351
|
CounterMsg,
|
|
2319
|
-
"
|
|
2352
|
+
"app.native",
|
|
2320
2353
|
&watch_import_sources,
|
|
2321
2354
|
);
|
|
2322
2355
|
|
|
2323
2356
|
test "with imports the compiled view stays the baseline until the watched closure changes" {
|
|
2324
2357
|
const io = std.testing.io;
|
|
2325
|
-
const
|
|
2326
|
-
const
|
|
2358
|
+
const watch_root = ".zig-cache/ui-app-markup-watch-root";
|
|
2359
|
+
const watch_path = watch_root ++ "/app.native";
|
|
2360
|
+
const parts_path = watch_root ++ "/components/actions.native";
|
|
2327
2361
|
const cwd = std.Io.Dir.cwd();
|
|
2328
|
-
try cwd.
|
|
2329
|
-
defer cwd.
|
|
2362
|
+
try cwd.createDirPath(io, watch_root ++ "/components");
|
|
2363
|
+
defer cwd.deleteTree(io, watch_root) catch {};
|
|
2364
|
+
try cwd.writeFile(io, .{ .sub_path = watch_path, .data = watch_nested_import_root_markup });
|
|
2330
2365
|
try cwd.writeFile(io, .{ .sub_path = parts_path, .data = watch_import_parts_markup });
|
|
2331
|
-
defer cwd.deleteFile(io, parts_path) catch {};
|
|
2332
2366
|
|
|
2333
2367
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2334
2368
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -2337,7 +2371,7 @@ test "with imports the compiled view stays the baseline until the watched closur
|
|
|
2337
2371
|
var options = markupCounterOptions();
|
|
2338
2372
|
options.view = CompiledImportCounterView.build;
|
|
2339
2373
|
options.markup = .{
|
|
2340
|
-
.source =
|
|
2374
|
+
.source = watch_nested_import_root_markup,
|
|
2341
2375
|
.sources = &watch_import_sources,
|
|
2342
2376
|
.watch_path = watch_path,
|
|
2343
2377
|
.io = io,
|
|
@@ -4656,6 +4690,7 @@ test "ui app dispatches native context menu selections as typed messages" {
|
|
|
4656
4690
|
.view = taskView,
|
|
4657
4691
|
});
|
|
4658
4692
|
defer app_state.deinit();
|
|
4693
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
4659
4694
|
const app = app_state.app();
|
|
4660
4695
|
try harness.start(app);
|
|
4661
4696
|
|
|
@@ -4766,6 +4801,7 @@ test "a rebuild while the native menu is open never redirects the visible select
|
|
|
4766
4801
|
.view = reorderView,
|
|
4767
4802
|
});
|
|
4768
4803
|
defer app_state.deinit();
|
|
4804
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
4769
4805
|
const app = app_state.app();
|
|
4770
4806
|
try harness.start(app);
|
|
4771
4807
|
|
|
@@ -4946,6 +4982,7 @@ test "context menu selection dispatches the original arena payload across rebuil
|
|
|
4946
4982
|
.view = arenaPayloadView,
|
|
4947
4983
|
});
|
|
4948
4984
|
defer app_state.deinit();
|
|
4985
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
4949
4986
|
const app = app_state.app();
|
|
4950
4987
|
try harness.start(app);
|
|
4951
4988
|
|
|
@@ -5133,6 +5170,7 @@ test "any superseding presentation or dispatch releases the app menu's snapshot
|
|
|
5133
5170
|
.view = arenaPayloadView,
|
|
5134
5171
|
});
|
|
5135
5172
|
defer app_state.deinit();
|
|
5173
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5136
5174
|
const app = app_state.app();
|
|
5137
5175
|
try harness.start(app);
|
|
5138
5176
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5226,6 +5264,7 @@ test "rebuilds under an open menu stay bounded at two trees" {
|
|
|
5226
5264
|
.view = arenaPayloadView,
|
|
5227
5265
|
});
|
|
5228
5266
|
defer app_state.deinit();
|
|
5267
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5229
5268
|
const app = app_state.app();
|
|
5230
5269
|
try harness.start(app);
|
|
5231
5270
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5377,6 +5416,7 @@ test "a failing rebuild routed into the live arena under an open menu drops the
|
|
|
5377
5416
|
.view = pinFailureView,
|
|
5378
5417
|
});
|
|
5379
5418
|
defer app_state.deinit();
|
|
5419
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5380
5420
|
const app = app_state.app();
|
|
5381
5421
|
try harness.start(app);
|
|
5382
5422
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5462,6 +5502,7 @@ test "dismissing the menu after a failed pinned rebuild restores the dropped tre
|
|
|
5462
5502
|
.view = pinFailureView,
|
|
5463
5503
|
});
|
|
5464
5504
|
defer app_state.deinit();
|
|
5505
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5465
5506
|
const app = app_state.app();
|
|
5466
5507
|
try harness.start(app);
|
|
5467
5508
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5536,6 +5577,7 @@ test "a selection whose update breaks the build budget keeps the live tree and i
|
|
|
5536
5577
|
.view = pinFailureView,
|
|
5537
5578
|
});
|
|
5538
5579
|
defer app_state.deinit();
|
|
5580
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5539
5581
|
const app = app_state.app();
|
|
5540
5582
|
try harness.start(app);
|
|
5541
5583
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5632,6 +5674,7 @@ test "a menu presented while the tree is dropped still resolves once the model r
|
|
|
5632
5674
|
.view = pinFailureView,
|
|
5633
5675
|
});
|
|
5634
5676
|
defer app_state.deinit();
|
|
5677
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5635
5678
|
const app = app_state.app();
|
|
5636
5679
|
try harness.start(app);
|
|
5637
5680
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -6278,6 +6321,7 @@ test "windowed virtual list scrolls, re-windows, budgets to the viewport, and fi
|
|
|
6278
6321
|
defer std.testing.allocator.destroy(app_state);
|
|
6279
6322
|
app_state.* = VirtualFeedApp.init(std.heap.page_allocator, .{}, virtualFeedAppOptions());
|
|
6280
6323
|
defer app_state.deinit();
|
|
6324
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
6281
6325
|
const app = app_state.app();
|
|
6282
6326
|
try harness.start(app);
|
|
6283
6327
|
|
|
@@ -7932,3 +7976,569 @@ test "a primary drag released outside the view retires containment and its proof
|
|
|
7932
7976
|
try std.testing.expectEqual(@as(usize, 0), harness.runtime.views[0].canvas_widget_hover_msg_chain_len);
|
|
7933
7977
|
try std.testing.expect(!harness.runtime.views[0].canvas_widget_hover_pointer_live);
|
|
7934
7978
|
}
|
|
7979
|
+
|
|
7980
|
+
const StatusPolicyModel = struct { revision: u32 = 0, present: bool = true };
|
|
7981
|
+
const StatusPolicyMsg = union(enum) { bump, remove, restore };
|
|
7982
|
+
const StatusPolicyApp = ui_app_model.UiApp(StatusPolicyModel, StatusPolicyMsg);
|
|
7983
|
+
fn statusPolicyUpdate(model: *StatusPolicyModel, msg: StatusPolicyMsg) void {
|
|
7984
|
+
switch (msg) {
|
|
7985
|
+
.bump => model.revision += 1,
|
|
7986
|
+
.remove => model.present = false,
|
|
7987
|
+
.restore => model.present = true,
|
|
7988
|
+
}
|
|
7989
|
+
}
|
|
7990
|
+
fn statusPolicyView(ui: *StatusPolicyApp.Ui, model: *const StatusPolicyModel) StatusPolicyApp.Ui.Node {
|
|
7991
|
+
return ui.text(.{}, ui.fmt("Revision {d}", .{model.revision}));
|
|
7992
|
+
}
|
|
7993
|
+
fn statusPolicyItems(model: *const StatusPolicyModel, scratch: *StatusPolicyApp.StatusItemsScratch) []const StatusPolicyApp.StatusItemDescriptor {
|
|
7994
|
+
if (!model.present) return &.{};
|
|
7995
|
+
const title = std.fmt.bufPrint(&scratch.title_buffers[0], "Revision {d}", .{model.revision}) catch unreachable;
|
|
7996
|
+
scratch.items[0] = .{ .id = 1, .label = title, .command = "app.bump" };
|
|
7997
|
+
scratch.status_items[0] = .{ .id = 100, .state = .{ .title = title, .tooltip = title, .items = scratch.items[0..1] } };
|
|
7998
|
+
return scratch.status_items[0..1];
|
|
7999
|
+
}
|
|
8000
|
+
const StatusPolicyProbe = struct {
|
|
8001
|
+
var calls = [_]usize{0} ** 3;
|
|
8002
|
+
var ignore: bool = false;
|
|
8003
|
+
var retire: u8 = 0;
|
|
8004
|
+
var patch: u8 = 0;
|
|
8005
|
+
fn decide(request: []const u8, output: []u8) usize {
|
|
8006
|
+
calls[request[0]] += 1;
|
|
8007
|
+
output[1] = 255;
|
|
8008
|
+
if (request[0] == 0) {
|
|
8009
|
+
output[0] = retire;
|
|
8010
|
+
return 2;
|
|
8011
|
+
}
|
|
8012
|
+
if (request[0] == 2) {
|
|
8013
|
+
output[0] = patch;
|
|
8014
|
+
return 2;
|
|
8015
|
+
}
|
|
8016
|
+
if (ignore) {
|
|
8017
|
+
output[0] = 0;
|
|
8018
|
+
return 2;
|
|
8019
|
+
}
|
|
8020
|
+
const slot: u8 = 6;
|
|
8021
|
+
const at = 4 + @as(usize, request[2]) * 4 + slot * 5;
|
|
8022
|
+
output[0] = if (request[at] == 1) 3 else 2;
|
|
8023
|
+
output[1] = slot;
|
|
8024
|
+
return 2;
|
|
8025
|
+
}
|
|
8026
|
+
};
|
|
8027
|
+
fn startStatusPolicyApp(harness: anytype, policy: ?*const fn ([]const u8, []u8) usize) !*StatusPolicyApp {
|
|
8028
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8029
|
+
const state = try std.testing.allocator.create(StatusPolicyApp);
|
|
8030
|
+
state.* = StatusPolicyApp.init(std.heap.page_allocator, .{}, .{
|
|
8031
|
+
.name = "status-policy-test",
|
|
8032
|
+
.scene = counter_scene,
|
|
8033
|
+
.canvas_label = canvas_label,
|
|
8034
|
+
.update = statusPolicyUpdate,
|
|
8035
|
+
.view = statusPolicyView,
|
|
8036
|
+
.status_items_fn = statusPolicyItems,
|
|
8037
|
+
.status_policy = policy,
|
|
8038
|
+
});
|
|
8039
|
+
errdefer {
|
|
8040
|
+
state.deinit();
|
|
8041
|
+
std.testing.allocator.destroy(state);
|
|
8042
|
+
}
|
|
8043
|
+
try harness.start(state.app());
|
|
8044
|
+
try harness.runtime.dispatchPlatformEvent(state.app(), .{ .gpu_surface_frame = .{
|
|
8045
|
+
.label = canvas_label,
|
|
8046
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8047
|
+
.scale_factor = 1,
|
|
8048
|
+
.frame_index = 1,
|
|
8049
|
+
.timestamp_ns = 1_000_000,
|
|
8050
|
+
.nonblank = true,
|
|
8051
|
+
} });
|
|
8052
|
+
return state;
|
|
8053
|
+
}
|
|
8054
|
+
|
|
8055
|
+
test "status host consumes authoritative admission slot patch and retirement decisions" {
|
|
8056
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8057
|
+
defer harness.destroy(std.testing.allocator);
|
|
8058
|
+
StatusPolicyProbe.calls = @splat(0);
|
|
8059
|
+
StatusPolicyProbe.ignore = false;
|
|
8060
|
+
StatusPolicyProbe.retire = 0;
|
|
8061
|
+
StatusPolicyProbe.patch = 0;
|
|
8062
|
+
const state = try startStatusPolicyApp(harness, StatusPolicyProbe.decide);
|
|
8063
|
+
defer {
|
|
8064
|
+
state.deinit();
|
|
8065
|
+
std.testing.allocator.destroy(state);
|
|
8066
|
+
}
|
|
8067
|
+
try std.testing.expect(state.applied_status_items[6].active);
|
|
8068
|
+
try std.testing.expect(!state.applied_status_items[0].active);
|
|
8069
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8070
|
+
// Deliberately suppress changed hashes: native must honor the returned plan.
|
|
8071
|
+
try std.testing.expectEqualStrings("Revision 0", harness.null_platform.statusItemTitle(100));
|
|
8072
|
+
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.trayShellUpdateCount());
|
|
8073
|
+
StatusPolicyProbe.patch = 2;
|
|
8074
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8075
|
+
try std.testing.expectEqualStrings("Revision 2", harness.null_platform.statusItemTitle(100));
|
|
8076
|
+
try std.testing.expectEqualStrings("Revision 0", harness.null_platform.statusItemTooltip(100));
|
|
8077
|
+
try std.testing.expectEqualStrings("Revision 0", harness.null_platform.statusItemMenu(100)[0].label);
|
|
8078
|
+
StatusPolicyProbe.patch = 5;
|
|
8079
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8080
|
+
try std.testing.expectEqualStrings("Revision 3", harness.null_platform.statusItemTooltip(100));
|
|
8081
|
+
try std.testing.expectEqualStrings("Revision 3", harness.null_platform.statusItemMenu(100)[0].label);
|
|
8082
|
+
try std.testing.expectEqualStrings("Revision 2", harness.null_platform.statusItemTitle(100));
|
|
8083
|
+
try state.dispatch(&harness.runtime, 1, .remove);
|
|
8084
|
+
try std.testing.expect(harness.null_platform.statusItemExists(100)); // Policy retains an absent declaration.
|
|
8085
|
+
StatusPolicyProbe.retire = 1 << 6;
|
|
8086
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8087
|
+
try std.testing.expect(!harness.null_platform.statusItemExists(100));
|
|
8088
|
+
StatusPolicyProbe.retire = 0;
|
|
8089
|
+
StatusPolicyProbe.ignore = true;
|
|
8090
|
+
try state.dispatch(&harness.runtime, 1, .restore);
|
|
8091
|
+
try std.testing.expect(!harness.null_platform.statusItemExists(100)); // Valid id intentionally refused.
|
|
8092
|
+
try std.testing.expect(StatusPolicyProbe.calls[0] > 0 and StatusPolicyProbe.calls[1] > 0 and StatusPolicyProbe.calls[2] > 0);
|
|
8093
|
+
}
|
|
8094
|
+
|
|
8095
|
+
const StatusFailureProbe = struct {
|
|
8096
|
+
var original: zero_platform.PlatformServices = undefined;
|
|
8097
|
+
var creates: usize = 0;
|
|
8098
|
+
var removes: usize = 0;
|
|
8099
|
+
var shells: usize = 0;
|
|
8100
|
+
var presentations: usize = 0;
|
|
8101
|
+
var menus: usize = 0;
|
|
8102
|
+
var fail_create: bool = false;
|
|
8103
|
+
var fail_remove: bool = false;
|
|
8104
|
+
var fail_patch: bool = false;
|
|
8105
|
+
fn create(_: ?*anyopaque, id: u32, options: zero_platform.TrayOptions) anyerror!void {
|
|
8106
|
+
creates += 1;
|
|
8107
|
+
if (fail_create) return error.CreateFailed;
|
|
8108
|
+
try original.createStatusItem(id, options);
|
|
8109
|
+
}
|
|
8110
|
+
fn remove(_: ?*anyopaque, id: u32) anyerror!void {
|
|
8111
|
+
removes += 1;
|
|
8112
|
+
if (fail_remove) return error.RemoveFailed;
|
|
8113
|
+
try original.removeStatusItem(id);
|
|
8114
|
+
}
|
|
8115
|
+
fn shell(_: ?*anyopaque, id: u32, options: zero_platform.TrayShell) anyerror!void {
|
|
8116
|
+
shells += 1;
|
|
8117
|
+
if (fail_patch) return error.UnsupportedService;
|
|
8118
|
+
try original.updateStatusItemShell(id, options);
|
|
8119
|
+
}
|
|
8120
|
+
fn presentation(_: ?*anyopaque, id: u32, options: zero_platform.TrayPresentation) anyerror!void {
|
|
8121
|
+
presentations += 1;
|
|
8122
|
+
if (fail_patch) return error.UnsupportedService;
|
|
8123
|
+
try original.updateStatusItemPresentation(id, options);
|
|
8124
|
+
}
|
|
8125
|
+
fn menu(_: ?*anyopaque, id: u32, items: []const zero_platform.TrayMenuItem) anyerror!void {
|
|
8126
|
+
menus += 1;
|
|
8127
|
+
if (fail_patch) return error.UpdateFailed;
|
|
8128
|
+
try original.updateStatusItemMenu(id, items);
|
|
8129
|
+
}
|
|
8130
|
+
};
|
|
8131
|
+
|
|
8132
|
+
test "status capability failures retain slots retry creates and preserve sticky update behavior" {
|
|
8133
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8134
|
+
defer harness.destroy(std.testing.allocator);
|
|
8135
|
+
StatusFailureProbe.original = harness.runtime.options.platform.services;
|
|
8136
|
+
StatusFailureProbe.creates = 0;
|
|
8137
|
+
StatusFailureProbe.removes = 0;
|
|
8138
|
+
StatusFailureProbe.shells = 0;
|
|
8139
|
+
StatusFailureProbe.presentations = 0;
|
|
8140
|
+
StatusFailureProbe.menus = 0;
|
|
8141
|
+
StatusFailureProbe.fail_create = true;
|
|
8142
|
+
StatusFailureProbe.fail_remove = false;
|
|
8143
|
+
StatusFailureProbe.fail_patch = false;
|
|
8144
|
+
harness.runtime.options.platform.services.create_tray_fn = StatusFailureProbe.create;
|
|
8145
|
+
harness.runtime.options.platform.services.remove_tray_fn = StatusFailureProbe.remove;
|
|
8146
|
+
harness.runtime.options.platform.services.update_tray_shell_fn = StatusFailureProbe.shell;
|
|
8147
|
+
harness.runtime.options.platform.services.update_tray_presentation_fn = StatusFailureProbe.presentation;
|
|
8148
|
+
harness.runtime.options.platform.services.update_tray_menu_fn = StatusFailureProbe.menu;
|
|
8149
|
+
const state = try startStatusPolicyApp(harness, null);
|
|
8150
|
+
defer {
|
|
8151
|
+
state.deinit();
|
|
8152
|
+
std.testing.allocator.destroy(state);
|
|
8153
|
+
}
|
|
8154
|
+
try std.testing.expectEqual(@as(usize, 0), state.applied_status_item_count);
|
|
8155
|
+
StatusFailureProbe.fail_create = false;
|
|
8156
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8157
|
+
try std.testing.expectEqual(@as(usize, 1), state.applied_status_item_count);
|
|
8158
|
+
try std.testing.expect(harness.null_platform.statusItemExists(100));
|
|
8159
|
+
StatusFailureProbe.fail_patch = true;
|
|
8160
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8161
|
+
try std.testing.expect(state.applied_status_items[0].shell_unsupported and state.applied_status_items[0].presentation_unsupported);
|
|
8162
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.shells);
|
|
8163
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.presentations);
|
|
8164
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.menus);
|
|
8165
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8166
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.shells);
|
|
8167
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.presentations);
|
|
8168
|
+
try std.testing.expectEqual(@as(usize, 2), StatusFailureProbe.menus); // Changed menus still try independently.
|
|
8169
|
+
StatusFailureProbe.fail_remove = true;
|
|
8170
|
+
try state.dispatch(&harness.runtime, 1, .remove);
|
|
8171
|
+
try std.testing.expectEqual(@as(usize, 1), state.applied_status_item_count);
|
|
8172
|
+
try std.testing.expect(harness.null_platform.statusItemExists(100));
|
|
8173
|
+
StatusFailureProbe.fail_remove = false;
|
|
8174
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8175
|
+
try std.testing.expectEqual(@as(usize, 0), state.applied_status_item_count);
|
|
8176
|
+
try std.testing.expectEqual(@as(usize, 2), StatusFailureProbe.removes);
|
|
8177
|
+
StatusFailureProbe.fail_patch = false;
|
|
8178
|
+
try state.dispatch(&harness.runtime, 1, .restore);
|
|
8179
|
+
try std.testing.expect(!state.applied_status_items[0].shell_unsupported and !state.applied_status_items[0].presentation_unsupported);
|
|
8180
|
+
}
|
|
8181
|
+
|
|
8182
|
+
const dispatch_reference = @import("app_dispatch_policy.zig");
|
|
8183
|
+
const DispatchProbe = struct {
|
|
8184
|
+
var stages: [128]u8 = @splat(0);
|
|
8185
|
+
var count: usize = 0;
|
|
8186
|
+
var suppress_render: bool = false;
|
|
8187
|
+
var suppress_apply: bool = false;
|
|
8188
|
+
var suppress_pending: bool = false;
|
|
8189
|
+
var suppress_event: bool = false;
|
|
8190
|
+
var suppress_tail: bool = false;
|
|
8191
|
+
var suppress_secondary: bool = false;
|
|
8192
|
+
var suppress_capture: bool = false;
|
|
8193
|
+
fn reset() void {
|
|
8194
|
+
count = 0;
|
|
8195
|
+
suppress_render = false;
|
|
8196
|
+
suppress_apply = false;
|
|
8197
|
+
suppress_pending = false;
|
|
8198
|
+
suppress_event = false;
|
|
8199
|
+
suppress_tail = false;
|
|
8200
|
+
suppress_secondary = false;
|
|
8201
|
+
suppress_capture = false;
|
|
8202
|
+
}
|
|
8203
|
+
fn policy(request: []const u8, output: []u8) usize {
|
|
8204
|
+
std.debug.assert(request.len == 6 and request[0] == 19);
|
|
8205
|
+
if (count < stages.len) {
|
|
8206
|
+
stages[count] = request[1];
|
|
8207
|
+
count += 1;
|
|
8208
|
+
}
|
|
8209
|
+
var plan = dispatch_reference.reference(@enumFromInt(request[1]), request[2], request[3]);
|
|
8210
|
+
if ((suppress_render and request[1] == 2) or
|
|
8211
|
+
(suppress_apply and request[1] == 1) or
|
|
8212
|
+
(suppress_pending and request[1] == 3) or
|
|
8213
|
+
(suppress_event and request[1] == 9) or
|
|
8214
|
+
(suppress_tail and request[1] == 8) or
|
|
8215
|
+
(suppress_secondary and request[1] == 7)) plan = @splat(0);
|
|
8216
|
+
if (suppress_capture and request[1] == 4) plan = @splat(0);
|
|
8217
|
+
@memcpy(output, &plan);
|
|
8218
|
+
return plan.len;
|
|
8219
|
+
}
|
|
8220
|
+
};
|
|
8221
|
+
|
|
8222
|
+
test "dispatch coordination consumes preparation update rendering and event plans" {
|
|
8223
|
+
DispatchProbe.reset();
|
|
8224
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8225
|
+
defer harness.destroy(std.testing.allocator);
|
|
8226
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8227
|
+
const state = try std.testing.allocator.create(CounterApp);
|
|
8228
|
+
defer std.testing.allocator.destroy(state);
|
|
8229
|
+
var options = counterOptions();
|
|
8230
|
+
options.app_dispatch_policy = DispatchProbe.policy;
|
|
8231
|
+
state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
8232
|
+
defer state.deinit();
|
|
8233
|
+
// A pre-install update executes, but refuses a view build.
|
|
8234
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
8235
|
+
try std.testing.expectEqual(@as(u32, 1), state.model.count);
|
|
8236
|
+
try std.testing.expect(!state.installed);
|
|
8237
|
+
try std.testing.expectEqualSlices(u8, &.{ 0, 1, 2 }, DispatchProbe.stages[0..DispatchProbe.count]);
|
|
8238
|
+
const app = state.app();
|
|
8239
|
+
try harness.start(app);
|
|
8240
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8241
|
+
.label = canvas_label,
|
|
8242
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8243
|
+
.scale_factor = 2,
|
|
8244
|
+
.frame_index = 1,
|
|
8245
|
+
.timestamp_ns = 1_000_000,
|
|
8246
|
+
.nonblank = true,
|
|
8247
|
+
} });
|
|
8248
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 1"));
|
|
8249
|
+
DispatchProbe.reset();
|
|
8250
|
+
DispatchProbe.suppress_render = true;
|
|
8251
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
8252
|
+
try std.testing.expectEqual(@as(u32, 2), state.model.count);
|
|
8253
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 1"));
|
|
8254
|
+
DispatchProbe.reset();
|
|
8255
|
+
DispatchProbe.suppress_apply = true;
|
|
8256
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
8257
|
+
try std.testing.expectEqual(@as(u32, 2), state.model.count);
|
|
8258
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 2"));
|
|
8259
|
+
DispatchProbe.reset();
|
|
8260
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .window_id = 1, .name = "counter.reset" } });
|
|
8261
|
+
try std.testing.expectEqual(@as(u32, 0), state.model.count);
|
|
8262
|
+
try std.testing.expect(std.mem.indexOfScalar(u8, DispatchProbe.stages[0..DispatchProbe.count], 9) != null);
|
|
8263
|
+
try harness.stop(app);
|
|
8264
|
+
}
|
|
8265
|
+
|
|
8266
|
+
const DrainModel = struct { count: u32 = 0, handle: effects_mod.ChannelHandle = .{} };
|
|
8267
|
+
const DrainMsg = union(enum) { event: effects_mod.EffectChannelEvent, unused };
|
|
8268
|
+
const DrainApp = ui_app_model.UiApp(DrainModel, DrainMsg);
|
|
8269
|
+
fn drainUpdate(model: *DrainModel, msg: DrainMsg, _: *DrainApp.Effects) void {
|
|
8270
|
+
if (msg == .event and msg.event.kind == .data) {
|
|
8271
|
+
model.count += 1;
|
|
8272
|
+
if (model.count == 1) _ = model.handle.post("next-boundary");
|
|
8273
|
+
}
|
|
8274
|
+
}
|
|
8275
|
+
fn drainView(ui: *DrainApp.Ui, model: *const DrainModel) DrainApp.Ui.Node {
|
|
8276
|
+
return ui.text(.{}, ui.fmt("Drain {d}", .{model.count}));
|
|
8277
|
+
}
|
|
8278
|
+
test "dispatch coordination consumes drain admission and retains the captured causal boundary" {
|
|
8279
|
+
DispatchProbe.reset();
|
|
8280
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8281
|
+
defer harness.destroy(std.testing.allocator);
|
|
8282
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8283
|
+
const state = try std.testing.allocator.create(DrainApp);
|
|
8284
|
+
defer std.testing.allocator.destroy(state);
|
|
8285
|
+
state.* = DrainApp.init(std.heap.page_allocator, .{}, .{
|
|
8286
|
+
.name = "dispatch-drain",
|
|
8287
|
+
.scene = counter_scene,
|
|
8288
|
+
.canvas_label = canvas_label,
|
|
8289
|
+
.update_fx = drainUpdate,
|
|
8290
|
+
.view = drainView,
|
|
8291
|
+
.app_dispatch_policy = DispatchProbe.policy,
|
|
8292
|
+
});
|
|
8293
|
+
defer state.deinit();
|
|
8294
|
+
try state.drainEffects(&harness.runtime);
|
|
8295
|
+
try std.testing.expectEqualSlices(u8, &.{ 3, 4 }, DispatchProbe.stages[0..DispatchProbe.count]);
|
|
8296
|
+
const app = state.app();
|
|
8297
|
+
try harness.start(app);
|
|
8298
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8299
|
+
.label = canvas_label,
|
|
8300
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8301
|
+
.scale_factor = 2,
|
|
8302
|
+
.frame_index = 1,
|
|
8303
|
+
.timestamp_ns = 1_000_000,
|
|
8304
|
+
.nonblank = true,
|
|
8305
|
+
} });
|
|
8306
|
+
state.model.handle = state.effects.openChannel(.{ .key = std.math.maxInt(u64), .on_event = DrainApp.Effects.channelMsg(.event) });
|
|
8307
|
+
try std.testing.expectEqual(effects_mod.ChannelHandle.PostResult.accepted, state.model.handle.post("first"));
|
|
8308
|
+
DispatchProbe.reset();
|
|
8309
|
+
DispatchProbe.suppress_pending = true;
|
|
8310
|
+
try state.drainEffects(&harness.runtime);
|
|
8311
|
+
try std.testing.expectEqual(@as(u32, 0), state.model.count);
|
|
8312
|
+
try std.testing.expect(state.effects.hasPending());
|
|
8313
|
+
DispatchProbe.reset();
|
|
8314
|
+
DispatchProbe.suppress_capture = true;
|
|
8315
|
+
try state.drainEffects(&harness.runtime);
|
|
8316
|
+
try std.testing.expectEqual(@as(u32, 0), state.model.count);
|
|
8317
|
+
try std.testing.expect(state.effects.hasPending());
|
|
8318
|
+
DispatchProbe.reset();
|
|
8319
|
+
try state.drainEffects(&harness.runtime);
|
|
8320
|
+
try std.testing.expectEqual(@as(u32, 1), state.model.count);
|
|
8321
|
+
try std.testing.expect(state.effects.hasPending());
|
|
8322
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Drain 1"));
|
|
8323
|
+
try state.drainEffects(&harness.runtime);
|
|
8324
|
+
try std.testing.expectEqual(@as(u32, 2), state.model.count);
|
|
8325
|
+
try std.testing.expect(!state.effects.hasPending());
|
|
8326
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Drain 2"));
|
|
8327
|
+
try harness.stop(app);
|
|
8328
|
+
}
|
|
8329
|
+
|
|
8330
|
+
test "dispatch coordination consumes direct and standalone event settlement plans" {
|
|
8331
|
+
for ([_]bool{ false, true }) |standalone| {
|
|
8332
|
+
DispatchProbe.reset();
|
|
8333
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8334
|
+
defer harness.destroy(std.testing.allocator);
|
|
8335
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8336
|
+
const state = try std.testing.allocator.create(CaptureApp);
|
|
8337
|
+
defer std.testing.allocator.destroy(state);
|
|
8338
|
+
var options = captureOptions();
|
|
8339
|
+
options.app_dispatch_policy = DispatchProbe.policy;
|
|
8340
|
+
state.* = CaptureApp.init(std.heap.page_allocator, .{}, options);
|
|
8341
|
+
defer state.deinit();
|
|
8342
|
+
const app = state.app();
|
|
8343
|
+
try harness.start(app);
|
|
8344
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8345
|
+
.label = canvas_label,
|
|
8346
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8347
|
+
.scale_factor = 2,
|
|
8348
|
+
.frame_index = 1,
|
|
8349
|
+
.timestamp_ns = 1_000_000,
|
|
8350
|
+
.nonblank = true,
|
|
8351
|
+
} });
|
|
8352
|
+
try hoverMove(harness, app, 50, 20);
|
|
8353
|
+
DispatchProbe.reset();
|
|
8354
|
+
if (standalone) {
|
|
8355
|
+
DispatchProbe.suppress_event = true;
|
|
8356
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "capture.hide", .window_id = 1 } });
|
|
8357
|
+
} else {
|
|
8358
|
+
DispatchProbe.suppress_tail = true;
|
|
8359
|
+
try state.dispatch(&harness.runtime, 1, .hide_row);
|
|
8360
|
+
}
|
|
8361
|
+
try std.testing.expectEqualStrings("", state.model.leftText());
|
|
8362
|
+
DispatchProbe.reset();
|
|
8363
|
+
// A subsequent event completes the captured edge with its owned bytes.
|
|
8364
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "unmapped", .window_id = 1 } });
|
|
8365
|
+
try std.testing.expectEqualStrings("left-after-0-churns", state.model.leftText());
|
|
8366
|
+
try harness.stop(app);
|
|
8367
|
+
}
|
|
8368
|
+
}
|
|
8369
|
+
|
|
8370
|
+
const DispatchWindowModel = struct { count: u32 = 0, open: bool = true, fail_main: bool = false, fail_secondary: bool = false };
|
|
8371
|
+
const DispatchWindowMsg = union(enum) { bump, idle };
|
|
8372
|
+
const DispatchWindowApp = ui_app_model.UiApp(DispatchWindowModel, DispatchWindowMsg);
|
|
8373
|
+
var dispatch_main_builds: usize = 0;
|
|
8374
|
+
var dispatch_secondary_builds: usize = 0;
|
|
8375
|
+
fn dispatchWindowUpdate(model: *DispatchWindowModel, msg: DispatchWindowMsg) void {
|
|
8376
|
+
if (msg == .bump) model.count += 1;
|
|
8377
|
+
}
|
|
8378
|
+
fn dispatchWindowView(ui: *DispatchWindowApp.Ui, model: *const DispatchWindowModel) DispatchWindowApp.Ui.Node {
|
|
8379
|
+
dispatch_main_builds += 1;
|
|
8380
|
+
return ui.text(.{}, ui.fmt("Main {d}", .{model.count}));
|
|
8381
|
+
}
|
|
8382
|
+
fn dispatchWindowTheme(model: *const DispatchWindowModel) DispatchWindowApp.ThemeState {
|
|
8383
|
+
return if (model.fail_main) .{ .invalid_accent = "bad" } else .{};
|
|
8384
|
+
}
|
|
8385
|
+
fn dispatchWindows(model: *const DispatchWindowModel, scratch: *DispatchWindowApp.WindowsScratch) []const DispatchWindowApp.WindowDescriptor {
|
|
8386
|
+
if (!model.open) return &.{};
|
|
8387
|
+
scratch.windows[0] = .{ .label = "panel", .canvas_label = "panel-canvas", .title = "Panel", .width = 320, .height = 240 };
|
|
8388
|
+
return scratch.windows[0..1];
|
|
8389
|
+
}
|
|
8390
|
+
fn dispatchPanelView(ui: *DispatchWindowApp.Ui, model: *const DispatchWindowModel, _: []const u8) DispatchWindowApp.Ui.Node {
|
|
8391
|
+
dispatch_secondary_builds += 1;
|
|
8392
|
+
if (model.fail_secondary) {
|
|
8393
|
+
const nodes = ui.arena.alloc(DispatchWindowApp.Ui.Node, core.max_canvas_widget_nodes_per_view + 40) catch @panic("fixture allocation");
|
|
8394
|
+
for (nodes) |*node| node.* = ui.text(.{}, "overflow");
|
|
8395
|
+
return ui.column(.{}, nodes);
|
|
8396
|
+
}
|
|
8397
|
+
return ui.text(.{}, ui.fmt("Panel {d}", .{model.count}));
|
|
8398
|
+
}
|
|
8399
|
+
test "dispatch coordination preserves main secondary failure ordering and independent reinitialization" {
|
|
8400
|
+
const saved_log_level = std.testing.log_level;
|
|
8401
|
+
std.testing.log_level = .err;
|
|
8402
|
+
defer std.testing.log_level = saved_log_level;
|
|
8403
|
+
for (0..2) |_| {
|
|
8404
|
+
DispatchProbe.reset();
|
|
8405
|
+
dispatch_main_builds = 0;
|
|
8406
|
+
dispatch_secondary_builds = 0;
|
|
8407
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8408
|
+
defer harness.destroy(std.testing.allocator);
|
|
8409
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8410
|
+
const state = try std.testing.allocator.create(DispatchWindowApp);
|
|
8411
|
+
defer std.testing.allocator.destroy(state);
|
|
8412
|
+
state.* = DispatchWindowApp.init(std.heap.page_allocator, .{}, .{
|
|
8413
|
+
.name = "dispatch-windows",
|
|
8414
|
+
.scene = counter_scene,
|
|
8415
|
+
.canvas_label = canvas_label,
|
|
8416
|
+
.update = dispatchWindowUpdate,
|
|
8417
|
+
.view = dispatchWindowView,
|
|
8418
|
+
.theme_state_fn = dispatchWindowTheme,
|
|
8419
|
+
.windows_fn = dispatchWindows,
|
|
8420
|
+
.window_view = dispatchPanelView,
|
|
8421
|
+
.app_dispatch_policy = DispatchProbe.policy,
|
|
8422
|
+
});
|
|
8423
|
+
defer state.deinit();
|
|
8424
|
+
const app = state.app();
|
|
8425
|
+
try harness.start(app);
|
|
8426
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8427
|
+
.label = canvas_label,
|
|
8428
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8429
|
+
.scale_factor = 2,
|
|
8430
|
+
.frame_index = 1,
|
|
8431
|
+
.timestamp_ns = 1_000_000,
|
|
8432
|
+
.nonblank = true,
|
|
8433
|
+
} });
|
|
8434
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8435
|
+
.window_id = 2,
|
|
8436
|
+
.label = "panel-canvas",
|
|
8437
|
+
.size = geometry.SizeF.init(320, 240),
|
|
8438
|
+
.scale_factor = 2,
|
|
8439
|
+
.frame_index = 1,
|
|
8440
|
+
.timestamp_ns = 2_000_000,
|
|
8441
|
+
.nonblank = true,
|
|
8442
|
+
} });
|
|
8443
|
+
try state.dispatch(&harness.runtime, 2, .bump);
|
|
8444
|
+
try std.testing.expect(dispatch_secondary_builds > 0);
|
|
8445
|
+
const secondary_before = dispatch_secondary_builds;
|
|
8446
|
+
state.model.fail_main = true;
|
|
8447
|
+
try std.testing.expectError(error.InvalidThemeAccent, state.dispatch(&harness.runtime, 2, .bump));
|
|
8448
|
+
try std.testing.expectEqual(secondary_before, dispatch_secondary_builds);
|
|
8449
|
+
state.model.fail_main = false;
|
|
8450
|
+
state.model.fail_secondary = true;
|
|
8451
|
+
try std.testing.expectError(error.WidgetLayoutListFull, state.dispatch(&harness.runtime, 2, .bump));
|
|
8452
|
+
try std.testing.expectEqual(secondary_before + 1, dispatch_secondary_builds);
|
|
8453
|
+
DispatchProbe.suppress_secondary = true;
|
|
8454
|
+
try state.dispatch(&harness.runtime, 2, .idle);
|
|
8455
|
+
try std.testing.expectEqual(secondary_before + 1, dispatch_secondary_builds);
|
|
8456
|
+
DispatchProbe.suppress_secondary = false;
|
|
8457
|
+
state.model.fail_secondary = false;
|
|
8458
|
+
try state.dispatch(&harness.runtime, 2, .bump);
|
|
8459
|
+
try std.testing.expectEqual(@as(u32, 4), state.model.count);
|
|
8460
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Main 4"));
|
|
8461
|
+
try harness.stop(app);
|
|
8462
|
+
}
|
|
8463
|
+
}
|
|
8464
|
+
|
|
8465
|
+
const component_reference = @import("component_policy.zig");
|
|
8466
|
+
const ComponentProbe = struct {
|
|
8467
|
+
var calls: usize = 0;
|
|
8468
|
+
var suppress_snapshot = false;
|
|
8469
|
+
fn policy(packet: []const u8, output: []u8) usize {
|
|
8470
|
+
calls += 1;
|
|
8471
|
+
if (packet[0] == 22) {
|
|
8472
|
+
const stage: component_reference.Stage = @enumFromInt(packet[1]);
|
|
8473
|
+
var result = component_reference.reference(stage, packet[2] != 0, packet[3] != 0, packet[4] != 0, std.mem.readInt(u64, packet[8..16], .little), std.mem.readInt(u64, packet[16..24], .little));
|
|
8474
|
+
if (suppress_snapshot and stage == .shown_count) @memset(result[8..], 0);
|
|
8475
|
+
@memcpy(output[0..result.len], &result);
|
|
8476
|
+
return result.len;
|
|
8477
|
+
}
|
|
8478
|
+
std.debug.assert(packet[0] == 23);
|
|
8479
|
+
const scroll: canvas.ScrollState = .{
|
|
8480
|
+
.offset_y = @bitCast(std.mem.readInt(u32, packet[8..12], .little)),
|
|
8481
|
+
.viewport_extent_y = @bitCast(std.mem.readInt(u32, packet[12..16], .little)),
|
|
8482
|
+
.content_extent_y = @bitCast(std.mem.readInt(u32, packet[16..20], .little)),
|
|
8483
|
+
.offset_x = @bitCast(std.mem.readInt(u32, packet[20..24], .little)),
|
|
8484
|
+
.viewport_extent_x = @bitCast(std.mem.readInt(u32, packet[24..28], .little)),
|
|
8485
|
+
.content_extent_x = @bitCast(std.mem.readInt(u32, packet[28..32], .little)),
|
|
8486
|
+
};
|
|
8487
|
+
const result = component_reference.reachReference(packet[1] != 0, packet[2] != 0, scroll, packet[3] != 0, packet[4] != 0);
|
|
8488
|
+
output[0..8].* = .{ @intFromBool(result.horizontal), @intFromEnum(result.action), 0, 0, 0, 0, 0, 0 };
|
|
8489
|
+
return 8;
|
|
8490
|
+
}
|
|
8491
|
+
};
|
|
8492
|
+
|
|
8493
|
+
test "component coordination consumes callback counts before pinning and restores swallowed selection" {
|
|
8494
|
+
ComponentProbe.calls = 0;
|
|
8495
|
+
ComponentProbe.suppress_snapshot = true;
|
|
8496
|
+
defer ComponentProbe.suppress_snapshot = false;
|
|
8497
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8498
|
+
defer harness.destroy(std.testing.allocator);
|
|
8499
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8500
|
+
const app_state = try std.testing.allocator.create(TaskRowApp);
|
|
8501
|
+
defer std.testing.allocator.destroy(app_state);
|
|
8502
|
+
app_state.* = TaskRowApp.init(std.heap.page_allocator, .{}, taskRowOptions());
|
|
8503
|
+
defer app_state.deinit();
|
|
8504
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
8505
|
+
const app = app_state.app();
|
|
8506
|
+
try harness.start(app);
|
|
8507
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{ .label = canvas_label, .size = geometry.SizeF.init(400, 300), .scale_factor = 1, .frame_index = 1, .timestamp_ns = 1_000_000, .nonblank = true } });
|
|
8508
|
+
const id = findIn(app_state.tree.?.root, .list_item, "Task").?;
|
|
8509
|
+
const layout = try harness.runtime.canvasWidgetLayout(1, canvas_label);
|
|
8510
|
+
const frame = layout.findById(id).?.frame;
|
|
8511
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = canvas_label, .kind = .pointer_down, .button = 1, .x = frame.x + 4, .y = frame.y + 4, .timestamp_ns = 2_000_000 } });
|
|
8512
|
+
try std.testing.expectEqual(@as(usize, 0), app_state.context_menu_shown_count);
|
|
8513
|
+
const token = harness.null_platform.context_menu_token;
|
|
8514
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .context_menu_action = .{ .window_id = 1, .view_label = canvas_label, .token = token, .item_id = 1 } });
|
|
8515
|
+
try std.testing.expectEqual(@as(u32, 0), app_state.model.completed);
|
|
8516
|
+
try std.testing.expect(app_state.context_menu_pin == null);
|
|
8517
|
+
try std.testing.expect(app_state.tree != null);
|
|
8518
|
+
try std.testing.expect(ComponentProbe.calls > 0);
|
|
8519
|
+
}
|
|
8520
|
+
|
|
8521
|
+
test "component coordination preserves end latches and full-table silence" {
|
|
8522
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8523
|
+
defer harness.destroy(std.testing.allocator);
|
|
8524
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8525
|
+
const app_state = try std.testing.allocator.create(VirtualFeedApp);
|
|
8526
|
+
defer std.testing.allocator.destroy(app_state);
|
|
8527
|
+
app_state.* = VirtualFeedApp.init(std.heap.page_allocator, .{}, virtualFeedAppOptions());
|
|
8528
|
+
defer app_state.deinit();
|
|
8529
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
8530
|
+
const app = app_state.app();
|
|
8531
|
+
try harness.start(app);
|
|
8532
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{ .label = canvas_label, .size = geometry.SizeF.init(400, 300), .scale_factor = 1, .frame_index = 1, .timestamp_ns = 1_000_000, .nonblank = true } });
|
|
8533
|
+
const id = app_state.virtual_windows[0].id;
|
|
8534
|
+
for (&app_state.reach_end_fired, 0..) |*slot, index| slot.* = .{ .id = @as(u64, @intCast(index)) + 5000, .axis = .vertical };
|
|
8535
|
+
const before = app_state.model.fetches;
|
|
8536
|
+
const scroll: canvas.ScrollState = .{ .offset_y = 300, .viewport_extent_y = 100, .content_extent_y = 400 };
|
|
8537
|
+
for (0..3) |_| try app.event(&harness.runtime, .{ .canvas_widget_scroll = .{ .window_id = 1, .view_label = canvas_label, .id = id, .scroll = scroll } });
|
|
8538
|
+
try std.testing.expectEqual(before, app_state.model.fetches);
|
|
8539
|
+
app_state.reach_end_fired[0] = .{};
|
|
8540
|
+
try app.event(&harness.runtime, .{ .canvas_widget_scroll = .{ .window_id = 1, .view_label = canvas_label, .id = id, .scroll = scroll } });
|
|
8541
|
+
try std.testing.expectEqual(before + 1, app_state.model.fetches);
|
|
8542
|
+
try app.event(&harness.runtime, .{ .canvas_widget_scroll = .{ .window_id = 1, .view_label = canvas_label, .id = id, .scroll = scroll } });
|
|
8543
|
+
try std.testing.expectEqual(before + 1, app_state.model.fetches);
|
|
8544
|
+
}
|