@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
|
@@ -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 = .{
|
|
@@ -1976,6 +1977,51 @@ test "model-derived theme state composes forced/system schemes and model accent
|
|
|
1976
1977
|
try std.testing.expect(!std.meta.eql(teal, actual.colors.accent));
|
|
1977
1978
|
}
|
|
1978
1979
|
|
|
1980
|
+
test "window appearance follows model schemes and restores system inheritance" {
|
|
1981
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1982
|
+
defer harness.destroy(std.testing.allocator);
|
|
1983
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1984
|
+
var options = counterOptions();
|
|
1985
|
+
options.theme_state_fn = counterThemeState;
|
|
1986
|
+
const state = try CounterApp.create(std.heap.page_allocator, options);
|
|
1987
|
+
defer state.destroy();
|
|
1988
|
+
const app = state.app();
|
|
1989
|
+
try harness.start(app);
|
|
1990
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{ .color_scheme = .light } });
|
|
1991
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1992
|
+
.label = canvas_label,
|
|
1993
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1994
|
+
.scale_factor = 1,
|
|
1995
|
+
.frame_index = 1,
|
|
1996
|
+
.timestamp_ns = 1_000_000,
|
|
1997
|
+
.nonblank = true,
|
|
1998
|
+
} });
|
|
1999
|
+
try std.testing.expectEqual(zero_platform.WindowColorScheme.dark, harness.null_platform.windowColorScheme(1).?);
|
|
2000
|
+
// The override must never replace the real system appearance input.
|
|
2001
|
+
try std.testing.expectEqual(zero_platform.ColorScheme.light, state.system_appearance.color_scheme);
|
|
2002
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
2003
|
+
try std.testing.expectEqual(zero_platform.WindowColorScheme.system, harness.null_platform.windowColorScheme(1).?);
|
|
2004
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{ .color_scheme = .dark } });
|
|
2005
|
+
const dark = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .pack = .geist });
|
|
2006
|
+
try std.testing.expectEqualDeep(dark.colors.background, state.effectiveTokens().colors.background);
|
|
2007
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
2008
|
+
try std.testing.expectEqual(zero_platform.WindowColorScheme.light, harness.null_platform.windowColorScheme(1).?);
|
|
2009
|
+
try std.testing.expectEqual(zero_platform.ColorScheme.dark, state.system_appearance.color_scheme);
|
|
2010
|
+
|
|
2011
|
+
// An explicit complete token register still outranks themeState. Do
|
|
2012
|
+
// not evaluate an ignored malformed helper or infer chrome from RGB.
|
|
2013
|
+
state.options.tokens = canvas.DesignTokens.theme(.{ .color_scheme = .dark });
|
|
2014
|
+
state.options.theme_state_fn = invalidCounterThemeState;
|
|
2015
|
+
try state.rebuild(&harness.runtime, 1);
|
|
2016
|
+
try std.testing.expectEqual(zero_platform.WindowColorScheme.system, harness.null_platform.windowColorScheme(1).?);
|
|
2017
|
+
|
|
2018
|
+
// Backends without this optional capability keep rendering normally.
|
|
2019
|
+
harness.runtime.options.platform.services.set_window_color_scheme_fn = null;
|
|
2020
|
+
state.options.tokens = null;
|
|
2021
|
+
state.options.theme_state_fn = counterThemeState;
|
|
2022
|
+
try state.rebuild(&harness.runtime, 1);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
1979
2025
|
test "malformed adapter theme accents reject the rebuild instead of inheriting silently" {
|
|
1980
2026
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1981
2027
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -1999,6 +2045,30 @@ test "malformed adapter theme accents reject the rebuild instead of inheriting s
|
|
|
1999
2045
|
try std.testing.expect(!app_state.installed);
|
|
2000
2046
|
}
|
|
2001
2047
|
|
|
2048
|
+
test "model accessibility theme flags preserve omission and explicit false and complete-token precedence" {
|
|
2049
|
+
const state = try std.testing.allocator.create(CounterApp);
|
|
2050
|
+
defer std.testing.allocator.destroy(state);
|
|
2051
|
+
state.* = CounterApp.init(std.testing.allocator, .{}, counterOptions());
|
|
2052
|
+
defer state.deinit();
|
|
2053
|
+
state.theme_state_known = true;
|
|
2054
|
+
const accent = canvas.Color.rgb8(0xdf, 0x26, 0x70);
|
|
2055
|
+
const flags = [_]?bool{ null, false, true };
|
|
2056
|
+
for ([_]bool{ false, true }) |dark| for ([_]bool{ false, true }) |os_contrast| for ([_]bool{ false, true }) |os_motion| {
|
|
2057
|
+
state.system_appearance = .{ .color_scheme = if (dark) .dark else .light, .high_contrast = os_contrast, .reduce_motion = os_motion };
|
|
2058
|
+
for (flags) |contrast| for (flags) |motion| {
|
|
2059
|
+
state.theme_state = .{ .pack = .geist, .accent = accent, .high_contrast = contrast, .reduce_motion = motion };
|
|
2060
|
+
const scheme: canvas.ColorScheme = if (dark) .dark else .light;
|
|
2061
|
+
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 });
|
|
2062
|
+
if (!(contrast orelse os_contrast)) expected = expected.withOverrides(canvas.accentOverrides(accent, scheme));
|
|
2063
|
+
try std.testing.expectEqualDeep(expected, state.effectiveTokens());
|
|
2064
|
+
};
|
|
2065
|
+
};
|
|
2066
|
+
const complete = canvas.DesignTokens.theme(.{ .color_scheme = .light });
|
|
2067
|
+
state.options.tokens = complete;
|
|
2068
|
+
state.theme_state = .{ .high_contrast = true, .reduce_motion = true, .invalid_accent = "ignored" };
|
|
2069
|
+
try std.testing.expectEqualDeep(complete, state.effectiveTokens());
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2002
2072
|
test "forced theme state still follows accessibility axes while scheme-only OS flips do not restyle" {
|
|
2003
2073
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2004
2074
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -2235,6 +2305,14 @@ const watch_import_parts_markup_v2 =
|
|
|
2235
2305
|
\\</template>
|
|
2236
2306
|
;
|
|
2237
2307
|
|
|
2308
|
+
const watch_nested_import_root_markup =
|
|
2309
|
+
\\<import src="components/actions.native"/>
|
|
2310
|
+
\\<column gap="8" padding="12">
|
|
2311
|
+
\\ <text>Count {count}</text>
|
|
2312
|
+
\\ <use template="actions" />
|
|
2313
|
+
\\</column>
|
|
2314
|
+
;
|
|
2315
|
+
|
|
2238
2316
|
test "the markup watch reloads when an IMPORTED file changes on disk" {
|
|
2239
2317
|
const io = std.testing.io;
|
|
2240
2318
|
const watch_path = ".zig-cache/ui-app-markup-watch-import-test.native";
|
|
@@ -2309,26 +2387,27 @@ test "the markup watch reloads when an IMPORTED file changes on disk" {
|
|
|
2309
2387
|
}
|
|
2310
2388
|
|
|
2311
2389
|
const watch_import_sources = [_]canvas.ui_markup.SourceFile{
|
|
2312
|
-
.{ .path = "
|
|
2313
|
-
.{ .path = "
|
|
2390
|
+
.{ .path = "app.native", .source = watch_nested_import_root_markup },
|
|
2391
|
+
.{ .path = "components/actions.native", .source = watch_import_parts_markup },
|
|
2314
2392
|
};
|
|
2315
2393
|
|
|
2316
2394
|
const CompiledImportCounterView = canvas.CompiledMarkupImports(
|
|
2317
2395
|
CounterModel,
|
|
2318
2396
|
CounterMsg,
|
|
2319
|
-
"
|
|
2397
|
+
"app.native",
|
|
2320
2398
|
&watch_import_sources,
|
|
2321
2399
|
);
|
|
2322
2400
|
|
|
2323
2401
|
test "with imports the compiled view stays the baseline until the watched closure changes" {
|
|
2324
2402
|
const io = std.testing.io;
|
|
2325
|
-
const
|
|
2326
|
-
const
|
|
2403
|
+
const watch_root = ".zig-cache/ui-app-markup-watch-root";
|
|
2404
|
+
const watch_path = watch_root ++ "/app.native";
|
|
2405
|
+
const parts_path = watch_root ++ "/components/actions.native";
|
|
2327
2406
|
const cwd = std.Io.Dir.cwd();
|
|
2328
|
-
try cwd.
|
|
2329
|
-
defer cwd.
|
|
2407
|
+
try cwd.createDirPath(io, watch_root ++ "/components");
|
|
2408
|
+
defer cwd.deleteTree(io, watch_root) catch {};
|
|
2409
|
+
try cwd.writeFile(io, .{ .sub_path = watch_path, .data = watch_nested_import_root_markup });
|
|
2330
2410
|
try cwd.writeFile(io, .{ .sub_path = parts_path, .data = watch_import_parts_markup });
|
|
2331
|
-
defer cwd.deleteFile(io, parts_path) catch {};
|
|
2332
2411
|
|
|
2333
2412
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2334
2413
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -2337,7 +2416,7 @@ test "with imports the compiled view stays the baseline until the watched closur
|
|
|
2337
2416
|
var options = markupCounterOptions();
|
|
2338
2417
|
options.view = CompiledImportCounterView.build;
|
|
2339
2418
|
options.markup = .{
|
|
2340
|
-
.source =
|
|
2419
|
+
.source = watch_nested_import_root_markup,
|
|
2341
2420
|
.sources = &watch_import_sources,
|
|
2342
2421
|
.watch_path = watch_path,
|
|
2343
2422
|
.io = io,
|
|
@@ -3946,192 +4025,16 @@ test "rapid-fire automation commands all dispatch, one per frame turn" {
|
|
|
3946
4025
|
|
|
3947
4026
|
// ---------------------------------------------------------- webview panes
|
|
3948
4027
|
|
|
3949
|
-
const preview_canvas_label = "preview-canvas";
|
|
3950
|
-
const preview_pane_anchor = "preview-pane";
|
|
3951
|
-
const example_url = "https://example.com/";
|
|
3952
|
-
const docs_url = "https://native-sdk.dev/";
|
|
3953
|
-
|
|
3954
|
-
const PreviewModel = struct {
|
|
3955
|
-
show_docs: bool = false,
|
|
3956
|
-
reload_token: u64 = 0,
|
|
3957
|
-
|
|
3958
|
-
fn url(model: *const PreviewModel) []const u8 {
|
|
3959
|
-
return if (model.show_docs) docs_url else example_url;
|
|
3960
|
-
}
|
|
3961
|
-
};
|
|
3962
|
-
|
|
3963
|
-
const PreviewMsg = union(enum) {
|
|
3964
|
-
show_docs,
|
|
3965
|
-
show_example,
|
|
3966
|
-
reload,
|
|
3967
|
-
};
|
|
3968
|
-
|
|
3969
|
-
const PreviewApp = ui_app_model.UiApp(PreviewModel, PreviewMsg);
|
|
3970
|
-
|
|
3971
|
-
fn previewUpdate(model: *PreviewModel, msg: PreviewMsg) void {
|
|
3972
|
-
switch (msg) {
|
|
3973
|
-
.show_docs => model.show_docs = true,
|
|
3974
|
-
.show_example => model.show_docs = false,
|
|
3975
|
-
.reload => model.reload_token += 1,
|
|
3976
|
-
}
|
|
3977
|
-
}
|
|
3978
|
-
|
|
3979
|
-
fn previewView(ui: *PreviewApp.Ui, model: *const PreviewModel) PreviewApp.Ui.Node {
|
|
3980
|
-
_ = model;
|
|
3981
|
-
return ui.row(.{ .gap = 0 }, .{
|
|
3982
|
-
ui.column(.{ .width = 200, .padding = 12, .gap = 8 }, .{
|
|
3983
|
-
ui.button(.{ .on_press = .show_docs }, "Docs"),
|
|
3984
|
-
ui.button(.{ .on_press = .show_example }, "Example"),
|
|
3985
|
-
ui.button(.{ .on_press = .reload }, "Reload"),
|
|
3986
|
-
}),
|
|
3987
|
-
// The empty panel that reserves the webview region: the pane
|
|
3988
|
-
// anchor resolves to this widget's layout frame.
|
|
3989
|
-
ui.panel(.{ .grow = 1, .semantics = .{ .label = preview_pane_anchor } }, .{}),
|
|
3990
|
-
});
|
|
3991
|
-
}
|
|
3992
|
-
|
|
3993
|
-
fn previewPanes(model: *const PreviewModel, out: []PreviewApp.WebViewPane) usize {
|
|
3994
|
-
out[0] = .{
|
|
3995
|
-
.label = "preview",
|
|
3996
|
-
.anchor = preview_pane_anchor,
|
|
3997
|
-
.url = model.url(),
|
|
3998
|
-
.reload_token = model.reload_token,
|
|
3999
|
-
};
|
|
4000
|
-
return 1;
|
|
4001
|
-
}
|
|
4002
|
-
|
|
4003
|
-
const preview_views = [_]app_manifest.ShellView{
|
|
4004
|
-
.{ .label = preview_canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .metal },
|
|
4005
|
-
.{ .label = "preview", .kind = .webview, .parent = preview_canvas_label, .url = example_url, .x = 200, .y = 0, .width = 440, .height = 480 },
|
|
4006
|
-
};
|
|
4007
|
-
const preview_windows = [_]app_manifest.ShellWindow{.{
|
|
4008
|
-
.label = "main",
|
|
4009
|
-
.title = "Preview",
|
|
4010
|
-
.width = 640,
|
|
4011
|
-
.height = 480,
|
|
4012
|
-
.views = &preview_views,
|
|
4013
|
-
}};
|
|
4014
|
-
const preview_scene: app_manifest.ShellConfig = .{ .windows = &preview_windows };
|
|
4015
|
-
const preview_origins = [_][]const u8{ "https://example.com", "https://native-sdk.dev", "zero://app", "zero://inline" };
|
|
4016
|
-
|
|
4017
|
-
fn previewOptions() PreviewApp.Options {
|
|
4018
|
-
return .{
|
|
4019
|
-
.name = "ui-app-preview",
|
|
4020
|
-
.scene = preview_scene,
|
|
4021
|
-
.canvas_label = preview_canvas_label,
|
|
4022
|
-
.update = previewUpdate,
|
|
4023
|
-
.view = previewView,
|
|
4024
|
-
.web_panes = previewPanes,
|
|
4025
|
-
};
|
|
4026
|
-
}
|
|
4027
|
-
|
|
4028
|
-
fn previewHarnessAndApp(app_state: *PreviewApp) !*core.TestHarness() {
|
|
4029
|
-
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(640, 480) });
|
|
4030
|
-
errdefer harness.destroy(std.testing.allocator);
|
|
4031
|
-
harness.null_platform.gpu_surfaces = true;
|
|
4032
|
-
harness.runtime.options.security.navigation.allowed_origins = &preview_origins;
|
|
4033
|
-
|
|
4034
|
-
app_state.* = PreviewApp.init(std.heap.page_allocator, .{}, previewOptions());
|
|
4035
|
-
const app = app_state.app();
|
|
4036
|
-
try harness.start(app);
|
|
4037
|
-
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
4038
|
-
.label = preview_canvas_label,
|
|
4039
|
-
.size = geometry.SizeF.init(640, 480),
|
|
4040
|
-
.scale_factor = 1,
|
|
4041
|
-
.frame_index = 1,
|
|
4042
|
-
.timestamp_ns = 1_000_000,
|
|
4043
|
-
.nonblank = true,
|
|
4044
|
-
} });
|
|
4045
|
-
return harness;
|
|
4046
|
-
}
|
|
4047
|
-
|
|
4048
|
-
fn previewNullWebView(harness: *core.TestHarness()) !null_platform_mod.NullWebView {
|
|
4049
|
-
for (harness.null_platform.webviews[0..harness.null_platform.webview_count]) |webview| {
|
|
4050
|
-
if (std.mem.eql(u8, webview.label, "preview")) return webview;
|
|
4051
|
-
}
|
|
4052
|
-
return error.TestUnexpectedResult;
|
|
4053
|
-
}
|
|
4054
|
-
|
|
4055
4028
|
test "ui app scene with a child webview stays main-webview-free" {
|
|
4056
|
-
|
|
4057
|
-
defer std.testing.allocator.destroy(app_state);
|
|
4058
|
-
const harness = try previewHarnessAndApp(app_state);
|
|
4059
|
-
defer harness.destroy(std.testing.allocator);
|
|
4060
|
-
defer app_state.deinit();
|
|
4061
|
-
|
|
4062
|
-
// The canvas-first scene never grows an implicit main webview: the
|
|
4063
|
-
// loaded source stays null and only the declared views exist.
|
|
4064
|
-
try std.testing.expect(harness.runtime.loaded_source == null);
|
|
4065
|
-
var views_buffer: [8]zero_platform.ViewInfo = undefined;
|
|
4066
|
-
const views = harness.runtime.listViews(1, &views_buffer);
|
|
4067
|
-
try std.testing.expectEqual(@as(usize, 2), views.len);
|
|
4068
|
-
for (views) |view| {
|
|
4069
|
-
try std.testing.expect(!std.mem.eql(u8, view.label, "main"));
|
|
4070
|
-
}
|
|
4029
|
+
try @import("web_pane_test_cases.zig").Cases(null).case0();
|
|
4071
4030
|
}
|
|
4072
4031
|
|
|
4073
4032
|
test "ui app webview pane snaps the webview to the anchor widget frame" {
|
|
4074
|
-
|
|
4075
|
-
defer std.testing.allocator.destroy(app_state);
|
|
4076
|
-
const harness = try previewHarnessAndApp(app_state);
|
|
4077
|
-
defer harness.destroy(std.testing.allocator);
|
|
4078
|
-
defer app_state.deinit();
|
|
4079
|
-
|
|
4080
|
-
try std.testing.expect(app_state.installed);
|
|
4081
|
-
const webview = try previewNullWebView(harness);
|
|
4082
|
-
try std.testing.expect(webview.open);
|
|
4083
|
-
try std.testing.expectEqualStrings(example_url, webview.url);
|
|
4084
|
-
|
|
4085
|
-
// The pane frame is the anchor widget's layout frame: the row's
|
|
4086
|
-
// remaining width after the 200pt sidebar column.
|
|
4087
|
-
const layout = try harness.runtime.canvasWidgetLayout(1, preview_canvas_label);
|
|
4088
|
-
var anchor_frame: ?geometry.RectF = null;
|
|
4089
|
-
for (layout.nodes) |node| {
|
|
4090
|
-
if (std.mem.eql(u8, node.widget.semantics.label, preview_pane_anchor)) anchor_frame = node.frame;
|
|
4091
|
-
}
|
|
4092
|
-
try std.testing.expect(anchor_frame != null);
|
|
4093
|
-
try std.testing.expect(anchor_frame.?.width > 0);
|
|
4094
|
-
try std.testing.expectApproxEqAbs(anchor_frame.?.x, webview.frame.x, 0.5);
|
|
4095
|
-
try std.testing.expectApproxEqAbs(anchor_frame.?.y, webview.frame.y, 0.5);
|
|
4096
|
-
try std.testing.expectApproxEqAbs(anchor_frame.?.width, webview.frame.width, 0.5);
|
|
4097
|
-
try std.testing.expectApproxEqAbs(anchor_frame.?.height, webview.frame.height, 0.5);
|
|
4098
|
-
|
|
4099
|
-
// A resize rebuild follows the anchor to its new frame.
|
|
4100
|
-
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .gpu_surface_resized = .{
|
|
4101
|
-
.label = preview_canvas_label,
|
|
4102
|
-
.window_id = 1,
|
|
4103
|
-
.frame = geometry.RectF.init(0, 0, 900, 600),
|
|
4104
|
-
.scale_factor = 1,
|
|
4105
|
-
} });
|
|
4106
|
-
const resized = try previewNullWebView(harness);
|
|
4107
|
-
try std.testing.expectApproxEqAbs(@as(f32, 900 - 200), resized.frame.width, 0.5);
|
|
4108
|
-
try std.testing.expectApproxEqAbs(@as(f32, 600), resized.frame.height, 0.5);
|
|
4033
|
+
try @import("web_pane_test_cases.zig").Cases(null).case1();
|
|
4109
4034
|
}
|
|
4110
4035
|
|
|
4111
4036
|
test "ui app webview pane navigates on url change and reloads on token bump" {
|
|
4112
|
-
|
|
4113
|
-
defer std.testing.allocator.destroy(app_state);
|
|
4114
|
-
const harness = try previewHarnessAndApp(app_state);
|
|
4115
|
-
defer harness.destroy(std.testing.allocator);
|
|
4116
|
-
defer app_state.deinit();
|
|
4117
|
-
|
|
4118
|
-
const navigations_after_install = harness.null_platform.webview_navigate_count;
|
|
4119
|
-
|
|
4120
|
-
// A model-driven URL change navigates the webview.
|
|
4121
|
-
try app_state.dispatch(&harness.runtime, 1, .show_docs);
|
|
4122
|
-
var webview = try previewNullWebView(harness);
|
|
4123
|
-
try std.testing.expectEqualStrings(docs_url, webview.url);
|
|
4124
|
-
try std.testing.expectEqual(navigations_after_install + 1, harness.null_platform.webview_navigate_count);
|
|
4125
|
-
|
|
4126
|
-
// A rebuild without a URL change does not renavigate.
|
|
4127
|
-
try app_state.dispatch(&harness.runtime, 1, .show_docs);
|
|
4128
|
-
try std.testing.expectEqual(navigations_after_install + 1, harness.null_platform.webview_navigate_count);
|
|
4129
|
-
|
|
4130
|
-
// Bumping the reload token renavigates the same URL.
|
|
4131
|
-
try app_state.dispatch(&harness.runtime, 1, .reload);
|
|
4132
|
-
webview = try previewNullWebView(harness);
|
|
4133
|
-
try std.testing.expectEqualStrings(docs_url, webview.url);
|
|
4134
|
-
try std.testing.expectEqual(navigations_after_install + 2, harness.null_platform.webview_navigate_count);
|
|
4037
|
+
try @import("web_pane_test_cases.zig").Cases(null).case2();
|
|
4135
4038
|
}
|
|
4136
4039
|
|
|
4137
4040
|
// ----------------------------------------------------------- status item
|
|
@@ -4656,6 +4559,7 @@ test "ui app dispatches native context menu selections as typed messages" {
|
|
|
4656
4559
|
.view = taskView,
|
|
4657
4560
|
});
|
|
4658
4561
|
defer app_state.deinit();
|
|
4562
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
4659
4563
|
const app = app_state.app();
|
|
4660
4564
|
try harness.start(app);
|
|
4661
4565
|
|
|
@@ -4766,6 +4670,7 @@ test "a rebuild while the native menu is open never redirects the visible select
|
|
|
4766
4670
|
.view = reorderView,
|
|
4767
4671
|
});
|
|
4768
4672
|
defer app_state.deinit();
|
|
4673
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
4769
4674
|
const app = app_state.app();
|
|
4770
4675
|
try harness.start(app);
|
|
4771
4676
|
|
|
@@ -4946,6 +4851,7 @@ test "context menu selection dispatches the original arena payload across rebuil
|
|
|
4946
4851
|
.view = arenaPayloadView,
|
|
4947
4852
|
});
|
|
4948
4853
|
defer app_state.deinit();
|
|
4854
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
4949
4855
|
const app = app_state.app();
|
|
4950
4856
|
try harness.start(app);
|
|
4951
4857
|
|
|
@@ -5133,6 +5039,7 @@ test "any superseding presentation or dispatch releases the app menu's snapshot
|
|
|
5133
5039
|
.view = arenaPayloadView,
|
|
5134
5040
|
});
|
|
5135
5041
|
defer app_state.deinit();
|
|
5042
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5136
5043
|
const app = app_state.app();
|
|
5137
5044
|
try harness.start(app);
|
|
5138
5045
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5226,6 +5133,7 @@ test "rebuilds under an open menu stay bounded at two trees" {
|
|
|
5226
5133
|
.view = arenaPayloadView,
|
|
5227
5134
|
});
|
|
5228
5135
|
defer app_state.deinit();
|
|
5136
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5229
5137
|
const app = app_state.app();
|
|
5230
5138
|
try harness.start(app);
|
|
5231
5139
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5377,6 +5285,7 @@ test "a failing rebuild routed into the live arena under an open menu drops the
|
|
|
5377
5285
|
.view = pinFailureView,
|
|
5378
5286
|
});
|
|
5379
5287
|
defer app_state.deinit();
|
|
5288
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5380
5289
|
const app = app_state.app();
|
|
5381
5290
|
try harness.start(app);
|
|
5382
5291
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5462,6 +5371,7 @@ test "dismissing the menu after a failed pinned rebuild restores the dropped tre
|
|
|
5462
5371
|
.view = pinFailureView,
|
|
5463
5372
|
});
|
|
5464
5373
|
defer app_state.deinit();
|
|
5374
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5465
5375
|
const app = app_state.app();
|
|
5466
5376
|
try harness.start(app);
|
|
5467
5377
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5536,6 +5446,7 @@ test "a selection whose update breaks the build budget keeps the live tree and i
|
|
|
5536
5446
|
.view = pinFailureView,
|
|
5537
5447
|
});
|
|
5538
5448
|
defer app_state.deinit();
|
|
5449
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5539
5450
|
const app = app_state.app();
|
|
5540
5451
|
try harness.start(app);
|
|
5541
5452
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -5632,6 +5543,7 @@ test "a menu presented while the tree is dropped still resolves once the model r
|
|
|
5632
5543
|
.view = pinFailureView,
|
|
5633
5544
|
});
|
|
5634
5545
|
defer app_state.deinit();
|
|
5546
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
5635
5547
|
const app = app_state.app();
|
|
5636
5548
|
try harness.start(app);
|
|
5637
5549
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -6278,6 +6190,7 @@ test "windowed virtual list scrolls, re-windows, budgets to the viewport, and fi
|
|
|
6278
6190
|
defer std.testing.allocator.destroy(app_state);
|
|
6279
6191
|
app_state.* = VirtualFeedApp.init(std.heap.page_allocator, .{}, virtualFeedAppOptions());
|
|
6280
6192
|
defer app_state.deinit();
|
|
6193
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
6281
6194
|
const app = app_state.app();
|
|
6282
6195
|
try harness.start(app);
|
|
6283
6196
|
|
|
@@ -7932,3 +7845,569 @@ test "a primary drag released outside the view retires containment and its proof
|
|
|
7932
7845
|
try std.testing.expectEqual(@as(usize, 0), harness.runtime.views[0].canvas_widget_hover_msg_chain_len);
|
|
7933
7846
|
try std.testing.expect(!harness.runtime.views[0].canvas_widget_hover_pointer_live);
|
|
7934
7847
|
}
|
|
7848
|
+
|
|
7849
|
+
const StatusPolicyModel = struct { revision: u32 = 0, present: bool = true };
|
|
7850
|
+
const StatusPolicyMsg = union(enum) { bump, remove, restore };
|
|
7851
|
+
const StatusPolicyApp = ui_app_model.UiApp(StatusPolicyModel, StatusPolicyMsg);
|
|
7852
|
+
fn statusPolicyUpdate(model: *StatusPolicyModel, msg: StatusPolicyMsg) void {
|
|
7853
|
+
switch (msg) {
|
|
7854
|
+
.bump => model.revision += 1,
|
|
7855
|
+
.remove => model.present = false,
|
|
7856
|
+
.restore => model.present = true,
|
|
7857
|
+
}
|
|
7858
|
+
}
|
|
7859
|
+
fn statusPolicyView(ui: *StatusPolicyApp.Ui, model: *const StatusPolicyModel) StatusPolicyApp.Ui.Node {
|
|
7860
|
+
return ui.text(.{}, ui.fmt("Revision {d}", .{model.revision}));
|
|
7861
|
+
}
|
|
7862
|
+
fn statusPolicyItems(model: *const StatusPolicyModel, scratch: *StatusPolicyApp.StatusItemsScratch) []const StatusPolicyApp.StatusItemDescriptor {
|
|
7863
|
+
if (!model.present) return &.{};
|
|
7864
|
+
const title = std.fmt.bufPrint(&scratch.title_buffers[0], "Revision {d}", .{model.revision}) catch unreachable;
|
|
7865
|
+
scratch.items[0] = .{ .id = 1, .label = title, .command = "app.bump" };
|
|
7866
|
+
scratch.status_items[0] = .{ .id = 100, .state = .{ .title = title, .tooltip = title, .items = scratch.items[0..1] } };
|
|
7867
|
+
return scratch.status_items[0..1];
|
|
7868
|
+
}
|
|
7869
|
+
const StatusPolicyProbe = struct {
|
|
7870
|
+
var calls = [_]usize{0} ** 3;
|
|
7871
|
+
var ignore: bool = false;
|
|
7872
|
+
var retire: u8 = 0;
|
|
7873
|
+
var patch: u8 = 0;
|
|
7874
|
+
fn decide(request: []const u8, output: []u8) usize {
|
|
7875
|
+
calls[request[0]] += 1;
|
|
7876
|
+
output[1] = 255;
|
|
7877
|
+
if (request[0] == 0) {
|
|
7878
|
+
output[0] = retire;
|
|
7879
|
+
return 2;
|
|
7880
|
+
}
|
|
7881
|
+
if (request[0] == 2) {
|
|
7882
|
+
output[0] = patch;
|
|
7883
|
+
return 2;
|
|
7884
|
+
}
|
|
7885
|
+
if (ignore) {
|
|
7886
|
+
output[0] = 0;
|
|
7887
|
+
return 2;
|
|
7888
|
+
}
|
|
7889
|
+
const slot: u8 = 6;
|
|
7890
|
+
const at = 4 + @as(usize, request[2]) * 4 + slot * 5;
|
|
7891
|
+
output[0] = if (request[at] == 1) 3 else 2;
|
|
7892
|
+
output[1] = slot;
|
|
7893
|
+
return 2;
|
|
7894
|
+
}
|
|
7895
|
+
};
|
|
7896
|
+
fn startStatusPolicyApp(harness: anytype, policy: ?*const fn ([]const u8, []u8) usize) !*StatusPolicyApp {
|
|
7897
|
+
harness.null_platform.gpu_surfaces = true;
|
|
7898
|
+
const state = try std.testing.allocator.create(StatusPolicyApp);
|
|
7899
|
+
state.* = StatusPolicyApp.init(std.heap.page_allocator, .{}, .{
|
|
7900
|
+
.name = "status-policy-test",
|
|
7901
|
+
.scene = counter_scene,
|
|
7902
|
+
.canvas_label = canvas_label,
|
|
7903
|
+
.update = statusPolicyUpdate,
|
|
7904
|
+
.view = statusPolicyView,
|
|
7905
|
+
.status_items_fn = statusPolicyItems,
|
|
7906
|
+
.status_policy = policy,
|
|
7907
|
+
});
|
|
7908
|
+
errdefer {
|
|
7909
|
+
state.deinit();
|
|
7910
|
+
std.testing.allocator.destroy(state);
|
|
7911
|
+
}
|
|
7912
|
+
try harness.start(state.app());
|
|
7913
|
+
try harness.runtime.dispatchPlatformEvent(state.app(), .{ .gpu_surface_frame = .{
|
|
7914
|
+
.label = canvas_label,
|
|
7915
|
+
.size = geometry.SizeF.init(400, 300),
|
|
7916
|
+
.scale_factor = 1,
|
|
7917
|
+
.frame_index = 1,
|
|
7918
|
+
.timestamp_ns = 1_000_000,
|
|
7919
|
+
.nonblank = true,
|
|
7920
|
+
} });
|
|
7921
|
+
return state;
|
|
7922
|
+
}
|
|
7923
|
+
|
|
7924
|
+
test "status host consumes authoritative admission slot patch and retirement decisions" {
|
|
7925
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
7926
|
+
defer harness.destroy(std.testing.allocator);
|
|
7927
|
+
StatusPolicyProbe.calls = @splat(0);
|
|
7928
|
+
StatusPolicyProbe.ignore = false;
|
|
7929
|
+
StatusPolicyProbe.retire = 0;
|
|
7930
|
+
StatusPolicyProbe.patch = 0;
|
|
7931
|
+
const state = try startStatusPolicyApp(harness, StatusPolicyProbe.decide);
|
|
7932
|
+
defer {
|
|
7933
|
+
state.deinit();
|
|
7934
|
+
std.testing.allocator.destroy(state);
|
|
7935
|
+
}
|
|
7936
|
+
try std.testing.expect(state.applied_status_items[6].active);
|
|
7937
|
+
try std.testing.expect(!state.applied_status_items[0].active);
|
|
7938
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
7939
|
+
// Deliberately suppress changed hashes: native must honor the returned plan.
|
|
7940
|
+
try std.testing.expectEqualStrings("Revision 0", harness.null_platform.statusItemTitle(100));
|
|
7941
|
+
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.trayShellUpdateCount());
|
|
7942
|
+
StatusPolicyProbe.patch = 2;
|
|
7943
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
7944
|
+
try std.testing.expectEqualStrings("Revision 2", harness.null_platform.statusItemTitle(100));
|
|
7945
|
+
try std.testing.expectEqualStrings("Revision 0", harness.null_platform.statusItemTooltip(100));
|
|
7946
|
+
try std.testing.expectEqualStrings("Revision 0", harness.null_platform.statusItemMenu(100)[0].label);
|
|
7947
|
+
StatusPolicyProbe.patch = 5;
|
|
7948
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
7949
|
+
try std.testing.expectEqualStrings("Revision 3", harness.null_platform.statusItemTooltip(100));
|
|
7950
|
+
try std.testing.expectEqualStrings("Revision 3", harness.null_platform.statusItemMenu(100)[0].label);
|
|
7951
|
+
try std.testing.expectEqualStrings("Revision 2", harness.null_platform.statusItemTitle(100));
|
|
7952
|
+
try state.dispatch(&harness.runtime, 1, .remove);
|
|
7953
|
+
try std.testing.expect(harness.null_platform.statusItemExists(100)); // Policy retains an absent declaration.
|
|
7954
|
+
StatusPolicyProbe.retire = 1 << 6;
|
|
7955
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
7956
|
+
try std.testing.expect(!harness.null_platform.statusItemExists(100));
|
|
7957
|
+
StatusPolicyProbe.retire = 0;
|
|
7958
|
+
StatusPolicyProbe.ignore = true;
|
|
7959
|
+
try state.dispatch(&harness.runtime, 1, .restore);
|
|
7960
|
+
try std.testing.expect(!harness.null_platform.statusItemExists(100)); // Valid id intentionally refused.
|
|
7961
|
+
try std.testing.expect(StatusPolicyProbe.calls[0] > 0 and StatusPolicyProbe.calls[1] > 0 and StatusPolicyProbe.calls[2] > 0);
|
|
7962
|
+
}
|
|
7963
|
+
|
|
7964
|
+
const StatusFailureProbe = struct {
|
|
7965
|
+
var original: zero_platform.PlatformServices = undefined;
|
|
7966
|
+
var creates: usize = 0;
|
|
7967
|
+
var removes: usize = 0;
|
|
7968
|
+
var shells: usize = 0;
|
|
7969
|
+
var presentations: usize = 0;
|
|
7970
|
+
var menus: usize = 0;
|
|
7971
|
+
var fail_create: bool = false;
|
|
7972
|
+
var fail_remove: bool = false;
|
|
7973
|
+
var fail_patch: bool = false;
|
|
7974
|
+
fn create(_: ?*anyopaque, id: u32, options: zero_platform.TrayOptions) anyerror!void {
|
|
7975
|
+
creates += 1;
|
|
7976
|
+
if (fail_create) return error.CreateFailed;
|
|
7977
|
+
try original.createStatusItem(id, options);
|
|
7978
|
+
}
|
|
7979
|
+
fn remove(_: ?*anyopaque, id: u32) anyerror!void {
|
|
7980
|
+
removes += 1;
|
|
7981
|
+
if (fail_remove) return error.RemoveFailed;
|
|
7982
|
+
try original.removeStatusItem(id);
|
|
7983
|
+
}
|
|
7984
|
+
fn shell(_: ?*anyopaque, id: u32, options: zero_platform.TrayShell) anyerror!void {
|
|
7985
|
+
shells += 1;
|
|
7986
|
+
if (fail_patch) return error.UnsupportedService;
|
|
7987
|
+
try original.updateStatusItemShell(id, options);
|
|
7988
|
+
}
|
|
7989
|
+
fn presentation(_: ?*anyopaque, id: u32, options: zero_platform.TrayPresentation) anyerror!void {
|
|
7990
|
+
presentations += 1;
|
|
7991
|
+
if (fail_patch) return error.UnsupportedService;
|
|
7992
|
+
try original.updateStatusItemPresentation(id, options);
|
|
7993
|
+
}
|
|
7994
|
+
fn menu(_: ?*anyopaque, id: u32, items: []const zero_platform.TrayMenuItem) anyerror!void {
|
|
7995
|
+
menus += 1;
|
|
7996
|
+
if (fail_patch) return error.UpdateFailed;
|
|
7997
|
+
try original.updateStatusItemMenu(id, items);
|
|
7998
|
+
}
|
|
7999
|
+
};
|
|
8000
|
+
|
|
8001
|
+
test "status capability failures retain slots retry creates and preserve sticky update behavior" {
|
|
8002
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8003
|
+
defer harness.destroy(std.testing.allocator);
|
|
8004
|
+
StatusFailureProbe.original = harness.runtime.options.platform.services;
|
|
8005
|
+
StatusFailureProbe.creates = 0;
|
|
8006
|
+
StatusFailureProbe.removes = 0;
|
|
8007
|
+
StatusFailureProbe.shells = 0;
|
|
8008
|
+
StatusFailureProbe.presentations = 0;
|
|
8009
|
+
StatusFailureProbe.menus = 0;
|
|
8010
|
+
StatusFailureProbe.fail_create = true;
|
|
8011
|
+
StatusFailureProbe.fail_remove = false;
|
|
8012
|
+
StatusFailureProbe.fail_patch = false;
|
|
8013
|
+
harness.runtime.options.platform.services.create_tray_fn = StatusFailureProbe.create;
|
|
8014
|
+
harness.runtime.options.platform.services.remove_tray_fn = StatusFailureProbe.remove;
|
|
8015
|
+
harness.runtime.options.platform.services.update_tray_shell_fn = StatusFailureProbe.shell;
|
|
8016
|
+
harness.runtime.options.platform.services.update_tray_presentation_fn = StatusFailureProbe.presentation;
|
|
8017
|
+
harness.runtime.options.platform.services.update_tray_menu_fn = StatusFailureProbe.menu;
|
|
8018
|
+
const state = try startStatusPolicyApp(harness, null);
|
|
8019
|
+
defer {
|
|
8020
|
+
state.deinit();
|
|
8021
|
+
std.testing.allocator.destroy(state);
|
|
8022
|
+
}
|
|
8023
|
+
try std.testing.expectEqual(@as(usize, 0), state.applied_status_item_count);
|
|
8024
|
+
StatusFailureProbe.fail_create = false;
|
|
8025
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8026
|
+
try std.testing.expectEqual(@as(usize, 1), state.applied_status_item_count);
|
|
8027
|
+
try std.testing.expect(harness.null_platform.statusItemExists(100));
|
|
8028
|
+
StatusFailureProbe.fail_patch = true;
|
|
8029
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8030
|
+
try std.testing.expect(state.applied_status_items[0].shell_unsupported and state.applied_status_items[0].presentation_unsupported);
|
|
8031
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.shells);
|
|
8032
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.presentations);
|
|
8033
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.menus);
|
|
8034
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8035
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.shells);
|
|
8036
|
+
try std.testing.expectEqual(@as(usize, 1), StatusFailureProbe.presentations);
|
|
8037
|
+
try std.testing.expectEqual(@as(usize, 2), StatusFailureProbe.menus); // Changed menus still try independently.
|
|
8038
|
+
StatusFailureProbe.fail_remove = true;
|
|
8039
|
+
try state.dispatch(&harness.runtime, 1, .remove);
|
|
8040
|
+
try std.testing.expectEqual(@as(usize, 1), state.applied_status_item_count);
|
|
8041
|
+
try std.testing.expect(harness.null_platform.statusItemExists(100));
|
|
8042
|
+
StatusFailureProbe.fail_remove = false;
|
|
8043
|
+
try state.dispatch(&harness.runtime, 1, .bump);
|
|
8044
|
+
try std.testing.expectEqual(@as(usize, 0), state.applied_status_item_count);
|
|
8045
|
+
try std.testing.expectEqual(@as(usize, 2), StatusFailureProbe.removes);
|
|
8046
|
+
StatusFailureProbe.fail_patch = false;
|
|
8047
|
+
try state.dispatch(&harness.runtime, 1, .restore);
|
|
8048
|
+
try std.testing.expect(!state.applied_status_items[0].shell_unsupported and !state.applied_status_items[0].presentation_unsupported);
|
|
8049
|
+
}
|
|
8050
|
+
|
|
8051
|
+
const dispatch_reference = @import("app_dispatch_policy.zig");
|
|
8052
|
+
const DispatchProbe = struct {
|
|
8053
|
+
var stages: [128]u8 = @splat(0);
|
|
8054
|
+
var count: usize = 0;
|
|
8055
|
+
var suppress_render: bool = false;
|
|
8056
|
+
var suppress_apply: bool = false;
|
|
8057
|
+
var suppress_pending: bool = false;
|
|
8058
|
+
var suppress_event: bool = false;
|
|
8059
|
+
var suppress_tail: bool = false;
|
|
8060
|
+
var suppress_secondary: bool = false;
|
|
8061
|
+
var suppress_capture: bool = false;
|
|
8062
|
+
fn reset() void {
|
|
8063
|
+
count = 0;
|
|
8064
|
+
suppress_render = false;
|
|
8065
|
+
suppress_apply = false;
|
|
8066
|
+
suppress_pending = false;
|
|
8067
|
+
suppress_event = false;
|
|
8068
|
+
suppress_tail = false;
|
|
8069
|
+
suppress_secondary = false;
|
|
8070
|
+
suppress_capture = false;
|
|
8071
|
+
}
|
|
8072
|
+
fn policy(request: []const u8, output: []u8) usize {
|
|
8073
|
+
std.debug.assert(request.len == 6 and request[0] == 19);
|
|
8074
|
+
if (count < stages.len) {
|
|
8075
|
+
stages[count] = request[1];
|
|
8076
|
+
count += 1;
|
|
8077
|
+
}
|
|
8078
|
+
var plan = dispatch_reference.reference(@enumFromInt(request[1]), request[2], request[3]);
|
|
8079
|
+
if ((suppress_render and request[1] == 2) or
|
|
8080
|
+
(suppress_apply and request[1] == 1) or
|
|
8081
|
+
(suppress_pending and request[1] == 3) or
|
|
8082
|
+
(suppress_event and request[1] == 9) or
|
|
8083
|
+
(suppress_tail and request[1] == 8) or
|
|
8084
|
+
(suppress_secondary and request[1] == 7)) plan = @splat(0);
|
|
8085
|
+
if (suppress_capture and request[1] == 4) plan = @splat(0);
|
|
8086
|
+
@memcpy(output, &plan);
|
|
8087
|
+
return plan.len;
|
|
8088
|
+
}
|
|
8089
|
+
};
|
|
8090
|
+
|
|
8091
|
+
test "dispatch coordination consumes preparation update rendering and event plans" {
|
|
8092
|
+
DispatchProbe.reset();
|
|
8093
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8094
|
+
defer harness.destroy(std.testing.allocator);
|
|
8095
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8096
|
+
const state = try std.testing.allocator.create(CounterApp);
|
|
8097
|
+
defer std.testing.allocator.destroy(state);
|
|
8098
|
+
var options = counterOptions();
|
|
8099
|
+
options.app_dispatch_policy = DispatchProbe.policy;
|
|
8100
|
+
state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
8101
|
+
defer state.deinit();
|
|
8102
|
+
// A pre-install update executes, but refuses a view build.
|
|
8103
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
8104
|
+
try std.testing.expectEqual(@as(u32, 1), state.model.count);
|
|
8105
|
+
try std.testing.expect(!state.installed);
|
|
8106
|
+
try std.testing.expectEqualSlices(u8, &.{ 0, 1, 2 }, DispatchProbe.stages[0..DispatchProbe.count]);
|
|
8107
|
+
const app = state.app();
|
|
8108
|
+
try harness.start(app);
|
|
8109
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8110
|
+
.label = canvas_label,
|
|
8111
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8112
|
+
.scale_factor = 2,
|
|
8113
|
+
.frame_index = 1,
|
|
8114
|
+
.timestamp_ns = 1_000_000,
|
|
8115
|
+
.nonblank = true,
|
|
8116
|
+
} });
|
|
8117
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 1"));
|
|
8118
|
+
DispatchProbe.reset();
|
|
8119
|
+
DispatchProbe.suppress_render = true;
|
|
8120
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
8121
|
+
try std.testing.expectEqual(@as(u32, 2), state.model.count);
|
|
8122
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 1"));
|
|
8123
|
+
DispatchProbe.reset();
|
|
8124
|
+
DispatchProbe.suppress_apply = true;
|
|
8125
|
+
try state.dispatch(&harness.runtime, 1, .increment);
|
|
8126
|
+
try std.testing.expectEqual(@as(u32, 2), state.model.count);
|
|
8127
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 2"));
|
|
8128
|
+
DispatchProbe.reset();
|
|
8129
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .window_id = 1, .name = "counter.reset" } });
|
|
8130
|
+
try std.testing.expectEqual(@as(u32, 0), state.model.count);
|
|
8131
|
+
try std.testing.expect(std.mem.indexOfScalar(u8, DispatchProbe.stages[0..DispatchProbe.count], 9) != null);
|
|
8132
|
+
try harness.stop(app);
|
|
8133
|
+
}
|
|
8134
|
+
|
|
8135
|
+
const DrainModel = struct { count: u32 = 0, handle: effects_mod.ChannelHandle = .{} };
|
|
8136
|
+
const DrainMsg = union(enum) { event: effects_mod.EffectChannelEvent, unused };
|
|
8137
|
+
const DrainApp = ui_app_model.UiApp(DrainModel, DrainMsg);
|
|
8138
|
+
fn drainUpdate(model: *DrainModel, msg: DrainMsg, _: *DrainApp.Effects) void {
|
|
8139
|
+
if (msg == .event and msg.event.kind == .data) {
|
|
8140
|
+
model.count += 1;
|
|
8141
|
+
if (model.count == 1) _ = model.handle.post("next-boundary");
|
|
8142
|
+
}
|
|
8143
|
+
}
|
|
8144
|
+
fn drainView(ui: *DrainApp.Ui, model: *const DrainModel) DrainApp.Ui.Node {
|
|
8145
|
+
return ui.text(.{}, ui.fmt("Drain {d}", .{model.count}));
|
|
8146
|
+
}
|
|
8147
|
+
test "dispatch coordination consumes drain admission and retains the captured causal boundary" {
|
|
8148
|
+
DispatchProbe.reset();
|
|
8149
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8150
|
+
defer harness.destroy(std.testing.allocator);
|
|
8151
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8152
|
+
const state = try std.testing.allocator.create(DrainApp);
|
|
8153
|
+
defer std.testing.allocator.destroy(state);
|
|
8154
|
+
state.* = DrainApp.init(std.heap.page_allocator, .{}, .{
|
|
8155
|
+
.name = "dispatch-drain",
|
|
8156
|
+
.scene = counter_scene,
|
|
8157
|
+
.canvas_label = canvas_label,
|
|
8158
|
+
.update_fx = drainUpdate,
|
|
8159
|
+
.view = drainView,
|
|
8160
|
+
.app_dispatch_policy = DispatchProbe.policy,
|
|
8161
|
+
});
|
|
8162
|
+
defer state.deinit();
|
|
8163
|
+
try state.drainEffects(&harness.runtime);
|
|
8164
|
+
try std.testing.expectEqualSlices(u8, &.{ 3, 4 }, DispatchProbe.stages[0..DispatchProbe.count]);
|
|
8165
|
+
const app = state.app();
|
|
8166
|
+
try harness.start(app);
|
|
8167
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8168
|
+
.label = canvas_label,
|
|
8169
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8170
|
+
.scale_factor = 2,
|
|
8171
|
+
.frame_index = 1,
|
|
8172
|
+
.timestamp_ns = 1_000_000,
|
|
8173
|
+
.nonblank = true,
|
|
8174
|
+
} });
|
|
8175
|
+
state.model.handle = state.effects.openChannel(.{ .key = std.math.maxInt(u64), .on_event = DrainApp.Effects.channelMsg(.event) });
|
|
8176
|
+
try std.testing.expectEqual(effects_mod.ChannelHandle.PostResult.accepted, state.model.handle.post("first"));
|
|
8177
|
+
DispatchProbe.reset();
|
|
8178
|
+
DispatchProbe.suppress_pending = true;
|
|
8179
|
+
try state.drainEffects(&harness.runtime);
|
|
8180
|
+
try std.testing.expectEqual(@as(u32, 0), state.model.count);
|
|
8181
|
+
try std.testing.expect(state.effects.hasPending());
|
|
8182
|
+
DispatchProbe.reset();
|
|
8183
|
+
DispatchProbe.suppress_capture = true;
|
|
8184
|
+
try state.drainEffects(&harness.runtime);
|
|
8185
|
+
try std.testing.expectEqual(@as(u32, 0), state.model.count);
|
|
8186
|
+
try std.testing.expect(state.effects.hasPending());
|
|
8187
|
+
DispatchProbe.reset();
|
|
8188
|
+
try state.drainEffects(&harness.runtime);
|
|
8189
|
+
try std.testing.expectEqual(@as(u32, 1), state.model.count);
|
|
8190
|
+
try std.testing.expect(state.effects.hasPending());
|
|
8191
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Drain 1"));
|
|
8192
|
+
try state.drainEffects(&harness.runtime);
|
|
8193
|
+
try std.testing.expectEqual(@as(u32, 2), state.model.count);
|
|
8194
|
+
try std.testing.expect(!state.effects.hasPending());
|
|
8195
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Drain 2"));
|
|
8196
|
+
try harness.stop(app);
|
|
8197
|
+
}
|
|
8198
|
+
|
|
8199
|
+
test "dispatch coordination consumes direct and standalone event settlement plans" {
|
|
8200
|
+
for ([_]bool{ false, true }) |standalone| {
|
|
8201
|
+
DispatchProbe.reset();
|
|
8202
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8203
|
+
defer harness.destroy(std.testing.allocator);
|
|
8204
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8205
|
+
const state = try std.testing.allocator.create(CaptureApp);
|
|
8206
|
+
defer std.testing.allocator.destroy(state);
|
|
8207
|
+
var options = captureOptions();
|
|
8208
|
+
options.app_dispatch_policy = DispatchProbe.policy;
|
|
8209
|
+
state.* = CaptureApp.init(std.heap.page_allocator, .{}, options);
|
|
8210
|
+
defer state.deinit();
|
|
8211
|
+
const app = state.app();
|
|
8212
|
+
try harness.start(app);
|
|
8213
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8214
|
+
.label = canvas_label,
|
|
8215
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8216
|
+
.scale_factor = 2,
|
|
8217
|
+
.frame_index = 1,
|
|
8218
|
+
.timestamp_ns = 1_000_000,
|
|
8219
|
+
.nonblank = true,
|
|
8220
|
+
} });
|
|
8221
|
+
try hoverMove(harness, app, 50, 20);
|
|
8222
|
+
DispatchProbe.reset();
|
|
8223
|
+
if (standalone) {
|
|
8224
|
+
DispatchProbe.suppress_event = true;
|
|
8225
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "capture.hide", .window_id = 1 } });
|
|
8226
|
+
} else {
|
|
8227
|
+
DispatchProbe.suppress_tail = true;
|
|
8228
|
+
try state.dispatch(&harness.runtime, 1, .hide_row);
|
|
8229
|
+
}
|
|
8230
|
+
try std.testing.expectEqualStrings("", state.model.leftText());
|
|
8231
|
+
DispatchProbe.reset();
|
|
8232
|
+
// A subsequent event completes the captured edge with its owned bytes.
|
|
8233
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "unmapped", .window_id = 1 } });
|
|
8234
|
+
try std.testing.expectEqualStrings("left-after-0-churns", state.model.leftText());
|
|
8235
|
+
try harness.stop(app);
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
|
|
8239
|
+
const DispatchWindowModel = struct { count: u32 = 0, open: bool = true, fail_main: bool = false, fail_secondary: bool = false };
|
|
8240
|
+
const DispatchWindowMsg = union(enum) { bump, idle };
|
|
8241
|
+
const DispatchWindowApp = ui_app_model.UiApp(DispatchWindowModel, DispatchWindowMsg);
|
|
8242
|
+
var dispatch_main_builds: usize = 0;
|
|
8243
|
+
var dispatch_secondary_builds: usize = 0;
|
|
8244
|
+
fn dispatchWindowUpdate(model: *DispatchWindowModel, msg: DispatchWindowMsg) void {
|
|
8245
|
+
if (msg == .bump) model.count += 1;
|
|
8246
|
+
}
|
|
8247
|
+
fn dispatchWindowView(ui: *DispatchWindowApp.Ui, model: *const DispatchWindowModel) DispatchWindowApp.Ui.Node {
|
|
8248
|
+
dispatch_main_builds += 1;
|
|
8249
|
+
return ui.text(.{}, ui.fmt("Main {d}", .{model.count}));
|
|
8250
|
+
}
|
|
8251
|
+
fn dispatchWindowTheme(model: *const DispatchWindowModel) DispatchWindowApp.ThemeState {
|
|
8252
|
+
return if (model.fail_main) .{ .invalid_accent = "bad" } else .{};
|
|
8253
|
+
}
|
|
8254
|
+
fn dispatchWindows(model: *const DispatchWindowModel, scratch: *DispatchWindowApp.WindowsScratch) []const DispatchWindowApp.WindowDescriptor {
|
|
8255
|
+
if (!model.open) return &.{};
|
|
8256
|
+
scratch.windows[0] = .{ .label = "panel", .canvas_label = "panel-canvas", .title = "Panel", .width = 320, .height = 240 };
|
|
8257
|
+
return scratch.windows[0..1];
|
|
8258
|
+
}
|
|
8259
|
+
fn dispatchPanelView(ui: *DispatchWindowApp.Ui, model: *const DispatchWindowModel, _: []const u8) DispatchWindowApp.Ui.Node {
|
|
8260
|
+
dispatch_secondary_builds += 1;
|
|
8261
|
+
if (model.fail_secondary) {
|
|
8262
|
+
const nodes = ui.arena.alloc(DispatchWindowApp.Ui.Node, core.max_canvas_widget_nodes_per_view + 40) catch @panic("fixture allocation");
|
|
8263
|
+
for (nodes) |*node| node.* = ui.text(.{}, "overflow");
|
|
8264
|
+
return ui.column(.{}, nodes);
|
|
8265
|
+
}
|
|
8266
|
+
return ui.text(.{}, ui.fmt("Panel {d}", .{model.count}));
|
|
8267
|
+
}
|
|
8268
|
+
test "dispatch coordination preserves main secondary failure ordering and independent reinitialization" {
|
|
8269
|
+
const saved_log_level = std.testing.log_level;
|
|
8270
|
+
std.testing.log_level = .err;
|
|
8271
|
+
defer std.testing.log_level = saved_log_level;
|
|
8272
|
+
for (0..2) |_| {
|
|
8273
|
+
DispatchProbe.reset();
|
|
8274
|
+
dispatch_main_builds = 0;
|
|
8275
|
+
dispatch_secondary_builds = 0;
|
|
8276
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8277
|
+
defer harness.destroy(std.testing.allocator);
|
|
8278
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8279
|
+
const state = try std.testing.allocator.create(DispatchWindowApp);
|
|
8280
|
+
defer std.testing.allocator.destroy(state);
|
|
8281
|
+
state.* = DispatchWindowApp.init(std.heap.page_allocator, .{}, .{
|
|
8282
|
+
.name = "dispatch-windows",
|
|
8283
|
+
.scene = counter_scene,
|
|
8284
|
+
.canvas_label = canvas_label,
|
|
8285
|
+
.update = dispatchWindowUpdate,
|
|
8286
|
+
.view = dispatchWindowView,
|
|
8287
|
+
.theme_state_fn = dispatchWindowTheme,
|
|
8288
|
+
.windows_fn = dispatchWindows,
|
|
8289
|
+
.window_view = dispatchPanelView,
|
|
8290
|
+
.app_dispatch_policy = DispatchProbe.policy,
|
|
8291
|
+
});
|
|
8292
|
+
defer state.deinit();
|
|
8293
|
+
const app = state.app();
|
|
8294
|
+
try harness.start(app);
|
|
8295
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8296
|
+
.label = canvas_label,
|
|
8297
|
+
.size = geometry.SizeF.init(400, 300),
|
|
8298
|
+
.scale_factor = 2,
|
|
8299
|
+
.frame_index = 1,
|
|
8300
|
+
.timestamp_ns = 1_000_000,
|
|
8301
|
+
.nonblank = true,
|
|
8302
|
+
} });
|
|
8303
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
8304
|
+
.window_id = 2,
|
|
8305
|
+
.label = "panel-canvas",
|
|
8306
|
+
.size = geometry.SizeF.init(320, 240),
|
|
8307
|
+
.scale_factor = 2,
|
|
8308
|
+
.frame_index = 1,
|
|
8309
|
+
.timestamp_ns = 2_000_000,
|
|
8310
|
+
.nonblank = true,
|
|
8311
|
+
} });
|
|
8312
|
+
try state.dispatch(&harness.runtime, 2, .bump);
|
|
8313
|
+
try std.testing.expect(dispatch_secondary_builds > 0);
|
|
8314
|
+
const secondary_before = dispatch_secondary_builds;
|
|
8315
|
+
state.model.fail_main = true;
|
|
8316
|
+
try std.testing.expectError(error.InvalidThemeAccent, state.dispatch(&harness.runtime, 2, .bump));
|
|
8317
|
+
try std.testing.expectEqual(secondary_before, dispatch_secondary_builds);
|
|
8318
|
+
state.model.fail_main = false;
|
|
8319
|
+
state.model.fail_secondary = true;
|
|
8320
|
+
try std.testing.expectError(error.WidgetLayoutListFull, state.dispatch(&harness.runtime, 2, .bump));
|
|
8321
|
+
try std.testing.expectEqual(secondary_before + 1, dispatch_secondary_builds);
|
|
8322
|
+
DispatchProbe.suppress_secondary = true;
|
|
8323
|
+
try state.dispatch(&harness.runtime, 2, .idle);
|
|
8324
|
+
try std.testing.expectEqual(secondary_before + 1, dispatch_secondary_builds);
|
|
8325
|
+
DispatchProbe.suppress_secondary = false;
|
|
8326
|
+
state.model.fail_secondary = false;
|
|
8327
|
+
try state.dispatch(&harness.runtime, 2, .bump);
|
|
8328
|
+
try std.testing.expectEqual(@as(u32, 4), state.model.count);
|
|
8329
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Main 4"));
|
|
8330
|
+
try harness.stop(app);
|
|
8331
|
+
}
|
|
8332
|
+
}
|
|
8333
|
+
|
|
8334
|
+
const component_reference = @import("component_policy.zig");
|
|
8335
|
+
const ComponentProbe = struct {
|
|
8336
|
+
var calls: usize = 0;
|
|
8337
|
+
var suppress_snapshot = false;
|
|
8338
|
+
fn policy(packet: []const u8, output: []u8) usize {
|
|
8339
|
+
calls += 1;
|
|
8340
|
+
if (packet[0] == 22) {
|
|
8341
|
+
const stage: component_reference.Stage = @enumFromInt(packet[1]);
|
|
8342
|
+
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));
|
|
8343
|
+
if (suppress_snapshot and stage == .shown_count) @memset(result[8..], 0);
|
|
8344
|
+
@memcpy(output[0..result.len], &result);
|
|
8345
|
+
return result.len;
|
|
8346
|
+
}
|
|
8347
|
+
std.debug.assert(packet[0] == 23);
|
|
8348
|
+
const scroll: canvas.ScrollState = .{
|
|
8349
|
+
.offset_y = @bitCast(std.mem.readInt(u32, packet[8..12], .little)),
|
|
8350
|
+
.viewport_extent_y = @bitCast(std.mem.readInt(u32, packet[12..16], .little)),
|
|
8351
|
+
.content_extent_y = @bitCast(std.mem.readInt(u32, packet[16..20], .little)),
|
|
8352
|
+
.offset_x = @bitCast(std.mem.readInt(u32, packet[20..24], .little)),
|
|
8353
|
+
.viewport_extent_x = @bitCast(std.mem.readInt(u32, packet[24..28], .little)),
|
|
8354
|
+
.content_extent_x = @bitCast(std.mem.readInt(u32, packet[28..32], .little)),
|
|
8355
|
+
};
|
|
8356
|
+
const result = component_reference.reachReference(packet[1] != 0, packet[2] != 0, scroll, packet[3] != 0, packet[4] != 0);
|
|
8357
|
+
output[0..8].* = .{ @intFromBool(result.horizontal), @intFromEnum(result.action), 0, 0, 0, 0, 0, 0 };
|
|
8358
|
+
return 8;
|
|
8359
|
+
}
|
|
8360
|
+
};
|
|
8361
|
+
|
|
8362
|
+
test "component coordination consumes callback counts before pinning and restores swallowed selection" {
|
|
8363
|
+
ComponentProbe.calls = 0;
|
|
8364
|
+
ComponentProbe.suppress_snapshot = true;
|
|
8365
|
+
defer ComponentProbe.suppress_snapshot = false;
|
|
8366
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8367
|
+
defer harness.destroy(std.testing.allocator);
|
|
8368
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8369
|
+
const app_state = try std.testing.allocator.create(TaskRowApp);
|
|
8370
|
+
defer std.testing.allocator.destroy(app_state);
|
|
8371
|
+
app_state.* = TaskRowApp.init(std.heap.page_allocator, .{}, taskRowOptions());
|
|
8372
|
+
defer app_state.deinit();
|
|
8373
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
8374
|
+
const app = app_state.app();
|
|
8375
|
+
try harness.start(app);
|
|
8376
|
+
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 } });
|
|
8377
|
+
const id = findIn(app_state.tree.?.root, .list_item, "Task").?;
|
|
8378
|
+
const layout = try harness.runtime.canvasWidgetLayout(1, canvas_label);
|
|
8379
|
+
const frame = layout.findById(id).?.frame;
|
|
8380
|
+
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 } });
|
|
8381
|
+
try std.testing.expectEqual(@as(usize, 0), app_state.context_menu_shown_count);
|
|
8382
|
+
const token = harness.null_platform.context_menu_token;
|
|
8383
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .context_menu_action = .{ .window_id = 1, .view_label = canvas_label, .token = token, .item_id = 1 } });
|
|
8384
|
+
try std.testing.expectEqual(@as(u32, 0), app_state.model.completed);
|
|
8385
|
+
try std.testing.expect(app_state.context_menu_pin == null);
|
|
8386
|
+
try std.testing.expect(app_state.tree != null);
|
|
8387
|
+
try std.testing.expect(ComponentProbe.calls > 0);
|
|
8388
|
+
}
|
|
8389
|
+
|
|
8390
|
+
test "component coordination preserves end latches and full-table silence" {
|
|
8391
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
8392
|
+
defer harness.destroy(std.testing.allocator);
|
|
8393
|
+
harness.null_platform.gpu_surfaces = true;
|
|
8394
|
+
const app_state = try std.testing.allocator.create(VirtualFeedApp);
|
|
8395
|
+
defer std.testing.allocator.destroy(app_state);
|
|
8396
|
+
app_state.* = VirtualFeedApp.init(std.heap.page_allocator, .{}, virtualFeedAppOptions());
|
|
8397
|
+
defer app_state.deinit();
|
|
8398
|
+
app_state.options.component_policy = ComponentProbe.policy;
|
|
8399
|
+
const app = app_state.app();
|
|
8400
|
+
try harness.start(app);
|
|
8401
|
+
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 } });
|
|
8402
|
+
const id = app_state.virtual_windows[0].id;
|
|
8403
|
+
for (&app_state.reach_end_fired, 0..) |*slot, index| slot.* = .{ .id = @as(u64, @intCast(index)) + 5000, .axis = .vertical };
|
|
8404
|
+
const before = app_state.model.fetches;
|
|
8405
|
+
const scroll: canvas.ScrollState = .{ .offset_y = 300, .viewport_extent_y = 100, .content_extent_y = 400 };
|
|
8406
|
+
for (0..3) |_| try app.event(&harness.runtime, .{ .canvas_widget_scroll = .{ .window_id = 1, .view_label = canvas_label, .id = id, .scroll = scroll } });
|
|
8407
|
+
try std.testing.expectEqual(before, app_state.model.fetches);
|
|
8408
|
+
app_state.reach_end_fired[0] = .{};
|
|
8409
|
+
try app.event(&harness.runtime, .{ .canvas_widget_scroll = .{ .window_id = 1, .view_label = canvas_label, .id = id, .scroll = scroll } });
|
|
8410
|
+
try std.testing.expectEqual(before + 1, app_state.model.fetches);
|
|
8411
|
+
try app.event(&harness.runtime, .{ .canvas_widget_scroll = .{ .window_id = 1, .view_label = canvas_label, .id = id, .scroll = scroll } });
|
|
8412
|
+
try std.testing.expectEqual(before + 1, app_state.model.fetches);
|
|
8413
|
+
}
|