@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
|
@@ -275,6 +275,122 @@ const JournalBuffer = struct {
|
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
+
test "synchronous native window callbacks record after creation and replay close and reopen" {
|
|
279
|
+
const WindowApp = struct {
|
|
280
|
+
created: u32 = 0,
|
|
281
|
+
current: platform.WindowId = 0,
|
|
282
|
+
user_closes: u32 = 0,
|
|
283
|
+
fn app(self: *@This()) core.App {
|
|
284
|
+
return .{ .context = self, .name = "causal-windows", .scene_fn = scene, .event_fn = event };
|
|
285
|
+
}
|
|
286
|
+
fn scene(_: *anyopaque) !app_manifest.ShellConfig {
|
|
287
|
+
return session_scene;
|
|
288
|
+
}
|
|
289
|
+
fn event(context: *anyopaque, runtime: *core.Runtime, incoming: core.Event) !void {
|
|
290
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
291
|
+
if (incoming == .window_closed) self.user_closes += 1;
|
|
292
|
+
if (incoming != .command) return;
|
|
293
|
+
if (std.mem.eql(u8, incoming.command.name, "child.open")) {
|
|
294
|
+
const info = try runtime.createSourcelessShellWindow(.{ .label = "child", .width = 200, .height = 100 });
|
|
295
|
+
self.current = info.id;
|
|
296
|
+
self.created += 1;
|
|
297
|
+
} else if (std.mem.eql(u8, incoming.command.name, "child.close")) try runtime.closeWindow(self.current);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const Host = struct {
|
|
301
|
+
null_platform: platform.NullPlatform,
|
|
302
|
+
base: platform.Platform = undefined,
|
|
303
|
+
handler: platform.EventHandler = undefined,
|
|
304
|
+
handler_context: *anyopaque = undefined,
|
|
305
|
+
fn value(self: *@This()) platform.Platform {
|
|
306
|
+
self.base = self.null_platform.platform();
|
|
307
|
+
var result = self.base;
|
|
308
|
+
result.context = self;
|
|
309
|
+
result.run_fn = run;
|
|
310
|
+
result.services.create_window_fn = create;
|
|
311
|
+
result.services.close_window_fn = close;
|
|
312
|
+
return result;
|
|
313
|
+
}
|
|
314
|
+
fn run(context: *anyopaque, handler: platform.EventHandler, handler_context: *anyopaque) !void {
|
|
315
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
316
|
+
self.handler = handler;
|
|
317
|
+
self.handler_context = handler_context;
|
|
318
|
+
try handler(handler_context, .app_start);
|
|
319
|
+
for ([_][]const u8{ "child.open", "child.close", "child.open", "child.close" }) |command| {
|
|
320
|
+
try handler(handler_context, .{ .menu_command = .{ .name = command } });
|
|
321
|
+
try handler(handler_context, .frame_requested);
|
|
322
|
+
}
|
|
323
|
+
try handler(handler_context, .app_shutdown);
|
|
324
|
+
}
|
|
325
|
+
fn changed(self: *@This(), info: platform.WindowInfo, open: bool) !void {
|
|
326
|
+
// Both strings are host-owned borrowed payloads. Reuse their
|
|
327
|
+
// buffers immediately after the callback, just like a native
|
|
328
|
+
// delegate returning to its window operation.
|
|
329
|
+
var label: [platform.max_window_label_bytes]u8 = undefined;
|
|
330
|
+
var title: [platform.max_window_title_bytes]u8 = undefined;
|
|
331
|
+
@memcpy(label[0..info.label.len], info.label);
|
|
332
|
+
@memcpy(title[0..info.title.len], info.title);
|
|
333
|
+
try self.handler(self.handler_context, .{ .window_frame_changed = .{
|
|
334
|
+
.id = info.id,
|
|
335
|
+
.label = label[0..info.label.len],
|
|
336
|
+
.title = title[0..info.title.len],
|
|
337
|
+
.frame = info.frame,
|
|
338
|
+
.scale_factor = info.scale_factor,
|
|
339
|
+
.open = open,
|
|
340
|
+
.focused = open and info.focused,
|
|
341
|
+
} });
|
|
342
|
+
@memset(&label, 'x');
|
|
343
|
+
@memset(&title, 'x');
|
|
344
|
+
}
|
|
345
|
+
fn create(context: ?*anyopaque, options: platform.WindowOptions) !platform.WindowInfo {
|
|
346
|
+
const null_platform: *platform.NullPlatform = @ptrCast(@alignCast(context.?));
|
|
347
|
+
const self: *@This() = @fieldParentPtr("null_platform", null_platform);
|
|
348
|
+
const info = try self.base.services.createWindow(options);
|
|
349
|
+
try self.changed(info, true);
|
|
350
|
+
return info;
|
|
351
|
+
}
|
|
352
|
+
fn close(context: ?*anyopaque, id: platform.WindowId) !void {
|
|
353
|
+
const null_platform: *platform.NullPlatform = @ptrCast(@alignCast(context.?));
|
|
354
|
+
const self: *@This() = @fieldParentPtr("null_platform", null_platform);
|
|
355
|
+
const info = for (self.null_platform.windows[0..self.null_platform.window_count]) |window| {
|
|
356
|
+
if (window.id == id) break window;
|
|
357
|
+
} else return error.WindowNotFound;
|
|
358
|
+
try self.base.services.closeWindow(id);
|
|
359
|
+
try self.changed(info, false);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
const gpa = std.testing.allocator;
|
|
363
|
+
const bytes = try gpa.create(JournalBuffer);
|
|
364
|
+
defer gpa.destroy(bytes);
|
|
365
|
+
bytes.* = .{};
|
|
366
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
367
|
+
defer gpa.destroy(recorder);
|
|
368
|
+
recorder.* = session_record.SessionRecorder.init(bytes.sink());
|
|
369
|
+
recorder.begin(.{ .app_name = "causal-windows", .platform_name = "null" });
|
|
370
|
+
const host = try gpa.create(Host);
|
|
371
|
+
defer gpa.destroy(host);
|
|
372
|
+
host.* = .{ .null_platform = platform.NullPlatform.init(.{}) };
|
|
373
|
+
host.null_platform.gpu_surfaces = true;
|
|
374
|
+
defer host.null_platform.deinit();
|
|
375
|
+
const runtime = try gpa.create(core.Runtime);
|
|
376
|
+
defer gpa.destroy(runtime);
|
|
377
|
+
core.Runtime.initAt(runtime, .{ .platform = host.value(), .allocator = gpa, .session_recorder = recorder });
|
|
378
|
+
defer runtime.deinit();
|
|
379
|
+
var recorded: WindowApp = .{};
|
|
380
|
+
try runtime.run(recorded.app());
|
|
381
|
+
try std.testing.expect(recorder.finished and !recorder.failed);
|
|
382
|
+
try std.testing.expectEqual(@as(u32, 2), recorded.created);
|
|
383
|
+
try std.testing.expectEqual(@as(u32, 0), recorded.user_closes);
|
|
384
|
+
const harness = try core.TestHarness().create(gpa, .{});
|
|
385
|
+
defer harness.destroy(gpa);
|
|
386
|
+
harness.null_platform.gpu_surfaces = true;
|
|
387
|
+
var replayed: WindowApp = .{};
|
|
388
|
+
const report = try session_replay.replaySession(&harness.runtime, replayed.app(), bytes.journalBytes(), .{ .require_same_platform = false });
|
|
389
|
+
try std.testing.expect(report.ok());
|
|
390
|
+
try std.testing.expectEqualDeep(recorded, replayed);
|
|
391
|
+
try std.testing.expectEqual(runtime.sessionStateFingerprint(), harness.runtime.sessionStateFingerprint());
|
|
392
|
+
}
|
|
393
|
+
|
|
278
394
|
const RecordedSession = struct {
|
|
279
395
|
model: SessionModel,
|
|
280
396
|
fingerprint: u64,
|
|
@@ -3274,3 +3390,439 @@ test "image effect records round-trip the blob address through the journal codec
|
|
|
3274
3390
|
try std.testing.expectEqualSlices(u8, &hash, &decoded.image_blob_hash);
|
|
3275
3391
|
try std.testing.expectEqual(@as(u64, 12_345), decoded.image_blob_len);
|
|
3276
3392
|
}
|
|
3393
|
+
|
|
3394
|
+
const ChromeReplayModel = struct { chrome: platform.WindowChrome = .{}, count: u32 = 0 };
|
|
3395
|
+
const ChromeReplayMsg = union(enum) { chrome: platform.WindowChrome, increment };
|
|
3396
|
+
const ChromeReplayApp = ui_app_mod.UiApp(ChromeReplayModel, ChromeReplayMsg);
|
|
3397
|
+
fn chromeReplayUpdate(model: *ChromeReplayModel, msg: ChromeReplayMsg) void {
|
|
3398
|
+
switch (msg) {
|
|
3399
|
+
.chrome => |chrome| model.chrome = chrome,
|
|
3400
|
+
.increment => model.count += 1,
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
fn chromeReplayMap(chrome: platform.WindowChrome) ?ChromeReplayMsg {
|
|
3404
|
+
return .{ .chrome = chrome };
|
|
3405
|
+
}
|
|
3406
|
+
fn chromeReplayView(ui: *ChromeReplayApp.Ui, model: *const ChromeReplayModel) ChromeReplayApp.Ui.Node {
|
|
3407
|
+
return ui.column(.{}, .{
|
|
3408
|
+
ui.row(.{ .window_drag = true, .height = @max(model.chrome.insets.top, 52) }, .{
|
|
3409
|
+
ui.el(.stack, .{ .width = model.chrome.insets.left }, .{}),
|
|
3410
|
+
ui.button(.{ .on_press = .increment, .context_menu = &.{
|
|
3411
|
+
.{ .label = "Increment", .msg = .increment },
|
|
3412
|
+
.{ .separator = true },
|
|
3413
|
+
.{ .label = "Disabled", .msg = .increment, .enabled = false },
|
|
3414
|
+
} }, ui.fmt("Count {d}", .{model.count})),
|
|
3415
|
+
}),
|
|
3416
|
+
ui.text(.{}, ui.fmt("{s} tabs {any}", .{ @tagName(model.chrome.form_factor), model.chrome.tabs_projected })),
|
|
3417
|
+
});
|
|
3418
|
+
}
|
|
3419
|
+
fn chromeReplayOptions() ChromeReplayApp.Options {
|
|
3420
|
+
return .{ .name = "chrome-session", .scene = session_scene, .canvas_label = canvas_label, .update = chromeReplayUpdate, .view = chromeReplayView, .on_chrome = chromeReplayMap };
|
|
3421
|
+
}
|
|
3422
|
+
fn recordChromePixels(runtime: *core.Runtime, recorder: *session_record.SessionRecorder) !void {
|
|
3423
|
+
const allocator = std.testing.allocator;
|
|
3424
|
+
const size = try runtime.canvasScreenshotPixelSize(1, canvas_label, 1);
|
|
3425
|
+
const pixels = try allocator.alloc(u8, size.byte_len);
|
|
3426
|
+
defer allocator.free(pixels);
|
|
3427
|
+
const scratch = try allocator.alloc(u8, size.byte_len);
|
|
3428
|
+
defer allocator.free(scratch);
|
|
3429
|
+
const screenshot = try runtime.renderCanvasScreenshot(1, canvas_label, 1, pixels, scratch);
|
|
3430
|
+
var writer = try std.Io.Writer.Allocating.initCapacity(allocator, try canvas.png.encodedRgba8ByteLen(screenshot.width, screenshot.height));
|
|
3431
|
+
defer writer.deinit();
|
|
3432
|
+
try canvas.png.writeRgba8(&writer.writer, screenshot.width, screenshot.height, screenshot.rgba8);
|
|
3433
|
+
recorder.recordScreenshot(canvas_label, 1, std.hash.Wyhash.hash(0, writer.written()), writer.written().len);
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
test "OS chrome results replay complete snapshots and pixels through resize fullscreen accessibility and context menus" {
|
|
3437
|
+
const gpa = std.testing.allocator;
|
|
3438
|
+
const buffer = try gpa.create(JournalBuffer);
|
|
3439
|
+
defer gpa.destroy(buffer);
|
|
3440
|
+
buffer.len = 0;
|
|
3441
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
3442
|
+
defer gpa.destroy(recorder);
|
|
3443
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
3444
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome-session" });
|
|
3445
|
+
const recorded = try core.TestHarness().create(gpa, .{ .size = .init(400, 300) });
|
|
3446
|
+
defer recorded.destroy(gpa);
|
|
3447
|
+
recorded.null_platform.gpu_surfaces = true;
|
|
3448
|
+
recorded.runtime.options.session_recorder = recorder;
|
|
3449
|
+
const state = try gpa.create(ChromeReplayApp);
|
|
3450
|
+
defer gpa.destroy(state);
|
|
3451
|
+
state.* = ChromeReplayApp.init(std.heap.page_allocator, .{}, chromeReplayOptions());
|
|
3452
|
+
defer state.deinit();
|
|
3453
|
+
const app = state.app();
|
|
3454
|
+
try recorded.start(app);
|
|
3455
|
+
const facts = [_]platform.WindowChrome{
|
|
3456
|
+
.{ .insets = .{ .top = 66, .left = 98 }, .buttons = .init(20, 26, 68, 14), .form_factor = .compact, .tabs_projected = true },
|
|
3457
|
+
.{ .insets = .{ .top = 52, .right = 88, .bottom = 3 }, .buttons = .init(280, 19, 72, 14), .form_factor = .regular },
|
|
3458
|
+
.{}, // Fullscreen removes the overlay.
|
|
3459
|
+
};
|
|
3460
|
+
for (facts, 0..) |chrome, index| {
|
|
3461
|
+
recorded.null_platform.window_chrome = chrome;
|
|
3462
|
+
if (index == 0) {
|
|
3463
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{ .label = canvas_label, .size = .init(400, 300), .scale_factor = 1, .frame_index = 1, .timestamp_ns = 1_000_000 } });
|
|
3464
|
+
} else {
|
|
3465
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_resized = .{ .window_id = 1, .label = canvas_label, .frame = .init(0, 0, 400, 300), .scale_factor = 1 } });
|
|
3466
|
+
}
|
|
3467
|
+
try std.testing.expectEqualDeep(chrome, state.model.chrome);
|
|
3468
|
+
var button_id: u64 = 0;
|
|
3469
|
+
for ((try recorded.runtime.canvasWidgetLayout(1, canvas_label)).nodes) |node| if (node.widget.kind == .button) {
|
|
3470
|
+
button_id = node.widget.id;
|
|
3471
|
+
};
|
|
3472
|
+
try std.testing.expect(button_id != 0);
|
|
3473
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .widget_accessibility_action = .{ .window_id = 1, .label = canvas_label, .id = button_id, .action = .press } });
|
|
3474
|
+
const invocation = try std.fmt.allocPrint(gpa, "widget-context-menu {s} {d} 0", .{ canvas_label, button_id });
|
|
3475
|
+
defer gpa.free(invocation);
|
|
3476
|
+
try recorded.runtime.dispatchAutomationCommand(app, invocation);
|
|
3477
|
+
try recorded.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
3478
|
+
try recordChromePixels(&recorded.runtime, recorder);
|
|
3479
|
+
}
|
|
3480
|
+
recorder.finish();
|
|
3481
|
+
try std.testing.expect(!recorder.failed);
|
|
3482
|
+
try std.testing.expect(recorder.window_chrome_count > 3);
|
|
3483
|
+
try std.testing.expectEqual(@as(u32, 6), state.model.count);
|
|
3484
|
+
var reader = try journal.Reader.init(buffer.journalBytes());
|
|
3485
|
+
var invocations: usize = 0;
|
|
3486
|
+
while (try reader.next()) |record| if (record == .event) {
|
|
3487
|
+
// Selections without their pending request cannot replay. The
|
|
3488
|
+
// complete invocation owns the nested selection and chrome facts.
|
|
3489
|
+
try std.testing.expect(record.event != .context_menu_action);
|
|
3490
|
+
if (record.event == .widget_context_menu_action) invocations += 1;
|
|
3491
|
+
};
|
|
3492
|
+
try std.testing.expectEqual(@as(usize, 3), invocations);
|
|
3493
|
+
const replayed = try core.TestHarness().create(gpa, .{ .size = .init(400, 300) });
|
|
3494
|
+
defer replayed.destroy(gpa);
|
|
3495
|
+
replayed.null_platform.gpu_surfaces = true;
|
|
3496
|
+
replayed.null_platform.window_chrome = .{ .insets = .{ .top = 999, .left = 999 }, .tabs_projected = true };
|
|
3497
|
+
const fresh = try gpa.create(ChromeReplayApp);
|
|
3498
|
+
defer gpa.destroy(fresh);
|
|
3499
|
+
fresh.* = ChromeReplayApp.init(std.heap.page_allocator, .{}, chromeReplayOptions());
|
|
3500
|
+
defer fresh.deinit();
|
|
3501
|
+
const report = try session_replay.replaySession(&replayed.runtime, fresh.app(), buffer.journalBytes(), .{ .verify = true, .require_same_platform = false });
|
|
3502
|
+
try std.testing.expect(report.ok());
|
|
3503
|
+
try std.testing.expect(report.checkpoints_verified >= 3);
|
|
3504
|
+
try std.testing.expectEqual(@as(u64, 3), report.screenshots_verified);
|
|
3505
|
+
try std.testing.expectEqualDeep(state.model, fresh.model);
|
|
3506
|
+
try std.testing.expectEqual(recorded.runtime.sessionStateFingerprint(), replayed.runtime.sessionStateFingerprint());
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
test "rejected widget menu commands leave the journal clean and degraded platform invocations replay" {
|
|
3510
|
+
const gpa = std.testing.allocator;
|
|
3511
|
+
const buffer = try gpa.create(JournalBuffer);
|
|
3512
|
+
defer gpa.destroy(buffer);
|
|
3513
|
+
buffer.len = 0;
|
|
3514
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
3515
|
+
defer gpa.destroy(recorder);
|
|
3516
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
3517
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome-session" });
|
|
3518
|
+
const recorded = try core.TestHarness().create(gpa, .{ .size = .init(400, 300) });
|
|
3519
|
+
defer recorded.destroy(gpa);
|
|
3520
|
+
recorded.null_platform.gpu_surfaces = true;
|
|
3521
|
+
recorded.runtime.options.session_recorder = recorder;
|
|
3522
|
+
recorded.runtime.dispatch_error_policy = .degrade;
|
|
3523
|
+
const state = try ChromeReplayApp.create(std.heap.page_allocator, chromeReplayOptions());
|
|
3524
|
+
defer state.destroy();
|
|
3525
|
+
const app = state.app();
|
|
3526
|
+
try recorded.start(app);
|
|
3527
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{ .label = canvas_label, .size = .init(400, 300), .scale_factor = 1, .frame_index = 1, .timestamp_ns = 1_000_000 } });
|
|
3528
|
+
var button_id: u64 = 0;
|
|
3529
|
+
var plain_id: u64 = 0;
|
|
3530
|
+
for ((try recorded.runtime.canvasWidgetLayout(1, canvas_label)).nodes) |node| {
|
|
3531
|
+
if (node.widget.kind == .button) button_id = node.widget.id;
|
|
3532
|
+
if (node.widget.kind == .text) plain_id = node.widget.id;
|
|
3533
|
+
}
|
|
3534
|
+
try std.testing.expect(button_id != 0 and plain_id != 0);
|
|
3535
|
+
const event_count = recorder.event_count;
|
|
3536
|
+
const errors = [_]anyerror{ error.ContextMenuItemSeparator, error.ContextMenuItemDisabled, error.ContextMenuItemOutOfRange };
|
|
3537
|
+
for (errors, 1..) |expected, index| {
|
|
3538
|
+
const command = try std.fmt.allocPrint(gpa, "widget-context-menu {s} {d} {d}", .{ canvas_label, button_id, index });
|
|
3539
|
+
defer gpa.free(command);
|
|
3540
|
+
try std.testing.expectError(expected, recorded.runtime.dispatchAutomationCommand(app, command));
|
|
3541
|
+
}
|
|
3542
|
+
const undeclared = try std.fmt.allocPrint(gpa, "widget-context-menu {s} {d} 0", .{ canvas_label, plain_id });
|
|
3543
|
+
defer gpa.free(undeclared);
|
|
3544
|
+
try std.testing.expectError(error.ContextMenuUndeclared, recorded.runtime.dispatchAutomationCommand(app, undeclared));
|
|
3545
|
+
try std.testing.expectEqual(event_count, recorder.event_count);
|
|
3546
|
+
try std.testing.expect(recorded.runtime.canvas_widget_context_menu_pending == null);
|
|
3547
|
+
// A platform invocation is already journaled. Its refusal follows
|
|
3548
|
+
// the interactive dispatch policy and must replay without exiting.
|
|
3549
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .widget_context_menu_action = .{ .label = canvas_label, .id = button_id, .item_index = 1 } });
|
|
3550
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .widget_context_menu_action = .{ .label = canvas_label, .id = button_id, .item_index = 0 } });
|
|
3551
|
+
try std.testing.expectEqual(@as(u32, 1), state.model.count);
|
|
3552
|
+
try recorded.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
3553
|
+
try recordChromePixels(&recorded.runtime, recorder);
|
|
3554
|
+
recorder.finish();
|
|
3555
|
+
try std.testing.expect(!recorder.failed);
|
|
3556
|
+
const replayed = try core.TestHarness().create(gpa, .{ .size = .init(400, 300) });
|
|
3557
|
+
defer replayed.destroy(gpa);
|
|
3558
|
+
replayed.null_platform.gpu_surfaces = true;
|
|
3559
|
+
replayed.runtime.dispatch_error_policy = .degrade;
|
|
3560
|
+
const fresh = try ChromeReplayApp.create(std.heap.page_allocator, chromeReplayOptions());
|
|
3561
|
+
defer fresh.destroy();
|
|
3562
|
+
const report = try session_replay.replaySession(&replayed.runtime, fresh.app(), buffer.journalBytes(), .{ .verify = true, .require_same_platform = false });
|
|
3563
|
+
try std.testing.expect(report.ok());
|
|
3564
|
+
try std.testing.expectEqual(@as(u64, 1), report.screenshots_verified);
|
|
3565
|
+
try std.testing.expectEqualDeep(state.model, fresh.model);
|
|
3566
|
+
try std.testing.expectEqual(recorded.runtime.sessionStateFingerprint(), replayed.runtime.sessionStateFingerprint());
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3569
|
+
const ChromeQueryProbe = struct {
|
|
3570
|
+
targets: []const u64,
|
|
3571
|
+
swallow: bool = false,
|
|
3572
|
+
observed: platform.WindowChrome = .{},
|
|
3573
|
+
fn start(context: *anyopaque, runtime: *core.Runtime) !void {
|
|
3574
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
3575
|
+
for (self.targets) |target| {
|
|
3576
|
+
self.observed = runtime.windowChrome(target) catch |err| {
|
|
3577
|
+
if (self.swallow) continue;
|
|
3578
|
+
return err;
|
|
3579
|
+
};
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
fn app(self: *@This()) core.App {
|
|
3583
|
+
return .{ .context = self, .name = "chrome-query", .start_fn = start };
|
|
3584
|
+
}
|
|
3585
|
+
};
|
|
3586
|
+
|
|
3587
|
+
test "replay refuses missing extra and reordered OS queries even without verification or with swallowed errors" {
|
|
3588
|
+
const gpa = std.testing.allocator;
|
|
3589
|
+
const buffer = try gpa.create(JournalBuffer);
|
|
3590
|
+
defer gpa.destroy(buffer);
|
|
3591
|
+
buffer.len = 0;
|
|
3592
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
3593
|
+
defer gpa.destroy(recorder);
|
|
3594
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
3595
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome-query" });
|
|
3596
|
+
const original = try core.TestHarness().create(gpa, .{});
|
|
3597
|
+
defer original.destroy(gpa);
|
|
3598
|
+
original.runtime.options.session_recorder = recorder;
|
|
3599
|
+
var probe: ChromeQueryProbe = .{ .targets = &.{ 1, 2 } };
|
|
3600
|
+
try original.runtime.dispatchPlatformEvent(probe.app(), .app_start);
|
|
3601
|
+
recorder.finish();
|
|
3602
|
+
try std.testing.expect(!recorder.failed);
|
|
3603
|
+
for ([_][]const u64{ &.{1}, &.{ 1, 2, 3 }, &.{ 2, 1 } }) |targets| {
|
|
3604
|
+
const fresh = try core.TestHarness().create(gpa, .{});
|
|
3605
|
+
defer fresh.destroy(gpa);
|
|
3606
|
+
var wrong: ChromeQueryProbe = .{ .targets = targets, .swallow = true };
|
|
3607
|
+
try std.testing.expectError(error.ReplayChromeDivergence, session_replay.replaySession(&fresh.runtime, wrong.app(), buffer.journalBytes(), .{ .verify = false, .require_same_platform = false }));
|
|
3608
|
+
try std.testing.expect(!fresh.runtime.replay_window_chrome_active);
|
|
3609
|
+
}
|
|
3610
|
+
// A complete sequence still succeeds and releases replay-owned facts.
|
|
3611
|
+
const fresh = try core.TestHarness().create(gpa, .{});
|
|
3612
|
+
defer fresh.destroy(gpa);
|
|
3613
|
+
const report = try session_replay.replaySession(&fresh.runtime, probe.app(), buffer.journalBytes(), .{ .verify = false, .require_same_platform = false });
|
|
3614
|
+
try std.testing.expect(report.ok());
|
|
3615
|
+
try std.testing.expect(!fresh.runtime.replay_window_chrome_active);
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
test "a logic-only journal declares absent chrome and never queries the replay host" {
|
|
3619
|
+
const gpa = std.testing.allocator;
|
|
3620
|
+
const buffer = try gpa.create(JournalBuffer);
|
|
3621
|
+
defer gpa.destroy(buffer);
|
|
3622
|
+
buffer.len = 0;
|
|
3623
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
3624
|
+
defer gpa.destroy(recorder);
|
|
3625
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
3626
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome-query", .window_chrome_source = .unavailable });
|
|
3627
|
+
recorder.stageEvent(.app_start);
|
|
3628
|
+
recorder.commitEvent();
|
|
3629
|
+
recorder.finish();
|
|
3630
|
+
const fresh = try core.TestHarness().create(gpa, .{});
|
|
3631
|
+
defer fresh.destroy(gpa);
|
|
3632
|
+
fresh.null_platform.window_chrome = .{ .insets = .{ .top = 999, .left = 999 } };
|
|
3633
|
+
var probe: ChromeQueryProbe = .{ .targets = &.{ 1, 2 } };
|
|
3634
|
+
const report = try session_replay.replaySession(&fresh.runtime, probe.app(), buffer.journalBytes(), .{ .verify = false, .require_same_platform = false });
|
|
3635
|
+
try std.testing.expect(report.ok());
|
|
3636
|
+
try std.testing.expectEqualDeep(platform.WindowChrome{}, probe.observed);
|
|
3637
|
+
// Absence cannot be combined with fabricated native query results.
|
|
3638
|
+
buffer.len = 0;
|
|
3639
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
3640
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome-query", .window_chrome_source = .unavailable });
|
|
3641
|
+
recorder.stageEvent(.app_start);
|
|
3642
|
+
recorder.recordWindowChrome(.{ .window_id = 1, .chrome = .{} });
|
|
3643
|
+
recorder.finish();
|
|
3644
|
+
try std.testing.expect(recorder.failed and !recorder.finished);
|
|
3645
|
+
}
|
|
3646
|
+
|
|
3647
|
+
const AudioChromeModel = struct { last: ?effects_mod.EffectAudio = null, count: u32 = 0 };
|
|
3648
|
+
const AudioChromeMsg = union(enum) { audio_event: effects_mod.EffectAudio };
|
|
3649
|
+
const AudioChromeApp = ui_app_mod.UiApp(AudioChromeModel, AudioChromeMsg);
|
|
3650
|
+
fn audioChromeInit(_: *AudioChromeModel, fx: *AudioChromeApp.Effects) void {
|
|
3651
|
+
fx.playAudio(.{ .key = 41, .path = "assets/session-track.mp3", .on_event = AudioChromeApp.Effects.audioMsg(.audio_event) });
|
|
3652
|
+
}
|
|
3653
|
+
fn audioChromeUpdate(model: *AudioChromeModel, msg: AudioChromeMsg) void {
|
|
3654
|
+
model.last = msg.audio_event;
|
|
3655
|
+
model.count += 1;
|
|
3656
|
+
}
|
|
3657
|
+
fn audioChromeView(ui: *AudioChromeApp.Ui, model: *const AudioChromeModel) AudioChromeApp.Ui.Node {
|
|
3658
|
+
return ui.column(.{}, .{
|
|
3659
|
+
ui.row(.{ .window_drag = true, .height = 52 }, .{ui.text(.{}, ui.fmt("Audio {d}", .{model.count}))}),
|
|
3660
|
+
ui.text(.{}, if (model.last) |event| @tagName(event.kind) else "waiting"),
|
|
3661
|
+
});
|
|
3662
|
+
}
|
|
3663
|
+
fn audioChromeOptions() AudioChromeApp.Options {
|
|
3664
|
+
return .{ .name = "audio-chrome-session", .scene = session_scene, .canvas_label = canvas_label, .update = audioChromeUpdate, .view = audioChromeView, .init_fx = audioChromeInit };
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3667
|
+
test "native audio callbacks replay in their owning event with complete chrome snapshots and pixels" {
|
|
3668
|
+
const gpa = std.testing.allocator;
|
|
3669
|
+
const buffer = try gpa.create(JournalBuffer);
|
|
3670
|
+
defer gpa.destroy(buffer);
|
|
3671
|
+
buffer.len = 0;
|
|
3672
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
3673
|
+
defer gpa.destroy(recorder);
|
|
3674
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
3675
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "audio-chrome-session" });
|
|
3676
|
+
const recorded = try core.TestHarness().create(gpa, .{ .size = .init(400, 300) });
|
|
3677
|
+
defer recorded.destroy(gpa);
|
|
3678
|
+
recorded.null_platform.gpu_surfaces = true;
|
|
3679
|
+
recorded.null_platform.window_chrome = .{ .insets = .{ .top = 52, .left = 98 }, .buttons = .init(20, 26, 68, 14) };
|
|
3680
|
+
recorded.runtime.options.session_recorder = recorder;
|
|
3681
|
+
const state = try gpa.create(AudioChromeApp);
|
|
3682
|
+
defer gpa.destroy(state);
|
|
3683
|
+
state.* = AudioChromeApp.init(std.heap.page_allocator, .{}, audioChromeOptions());
|
|
3684
|
+
defer state.deinit();
|
|
3685
|
+
state.effects.executor = .fake;
|
|
3686
|
+
const app = state.app();
|
|
3687
|
+
try recorded.start(app);
|
|
3688
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{ .label = canvas_label, .size = .init(400, 300), .scale_factor = 1, .frame_index = 1, .timestamp_ns = 1_000_000 } });
|
|
3689
|
+
const events = [_]platform.AudioEvent{
|
|
3690
|
+
.{ .kind = .loaded, .duration_ms = 30_000, .playing = true },
|
|
3691
|
+
.{ .kind = .position, .position_ms = 750, .duration_ms = 30_000, .playing = true, .buffering = true },
|
|
3692
|
+
.{ .kind = .spectrum, .position_ms = 750, .duration_ms = 30_000, .playing = false, .buffering = true, .bands = @splat(17) },
|
|
3693
|
+
.{ .kind = .position, .position_ms = 900, .duration_ms = 30_000, .playing = false },
|
|
3694
|
+
.{ .kind = .completed, .position_ms = 999, .duration_ms = 30_000, .playing = true, .buffering = true },
|
|
3695
|
+
.{ .kind = .failed, .position_ms = 12, .duration_ms = 30_000, .playing = true, .buffering = true },
|
|
3696
|
+
};
|
|
3697
|
+
for (events, 0..) |event, index| {
|
|
3698
|
+
try recorded.runtime.dispatchPlatformEvent(app, .{ .audio = event });
|
|
3699
|
+
try std.testing.expectEqual(@as(u32, @intCast(index + 1)), state.model.count);
|
|
3700
|
+
try recorded.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
3701
|
+
try recordChromePixels(&recorded.runtime, recorder);
|
|
3702
|
+
}
|
|
3703
|
+
recorder.finish();
|
|
3704
|
+
try std.testing.expect(!recorder.failed);
|
|
3705
|
+
try std.testing.expect(recorder.window_chrome_count >= events.len);
|
|
3706
|
+
const replayed = try core.TestHarness().create(gpa, .{ .size = .init(400, 300) });
|
|
3707
|
+
defer replayed.destroy(gpa);
|
|
3708
|
+
replayed.null_platform.gpu_surfaces = true;
|
|
3709
|
+
replayed.null_platform.window_chrome = .{ .buttons = .init(999, 999, 99, 99) };
|
|
3710
|
+
const fresh = try gpa.create(AudioChromeApp);
|
|
3711
|
+
defer gpa.destroy(fresh);
|
|
3712
|
+
fresh.* = AudioChromeApp.init(std.heap.page_allocator, .{}, audioChromeOptions());
|
|
3713
|
+
defer fresh.deinit();
|
|
3714
|
+
const report = try session_replay.replaySession(&replayed.runtime, fresh.app(), buffer.journalBytes(), .{ .verify = true, .require_same_platform = false });
|
|
3715
|
+
try std.testing.expect(report.ok());
|
|
3716
|
+
try std.testing.expectEqual(@as(u64, events.len), report.effects_fed);
|
|
3717
|
+
try std.testing.expectEqual(@as(u64, events.len), report.screenshots_verified);
|
|
3718
|
+
try std.testing.expectEqualDeep(state.model, fresh.model);
|
|
3719
|
+
try std.testing.expectEqualDeep(state.effects.audioSnapshot(), fresh.effects.audioSnapshot());
|
|
3720
|
+
try std.testing.expectEqual(recorded.runtime.sessionStateFingerprint(), replayed.runtime.sessionStateFingerprint());
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
test "synchronous recorded audio leaves wrapped deferred rejections in their original order" {
|
|
3724
|
+
const fx = try std.testing.allocator.create(SessionApp.Effects);
|
|
3725
|
+
defer std.testing.allocator.destroy(fx);
|
|
3726
|
+
fx.* = SessionApp.Effects.init(std.testing.allocator);
|
|
3727
|
+
defer fx.deinit();
|
|
3728
|
+
fx.armReplay();
|
|
3729
|
+
// Advance the ring head before retaining two deferred rejection Msgs.
|
|
3730
|
+
for (0..effects_mod.max_effect_pending_exits - 1) |_| {
|
|
3731
|
+
fx.playAudio(.{ .key = 7, .path = "", .on_event = SessionApp.Effects.audioMsg(.audio_event) });
|
|
3732
|
+
try std.testing.expect(fx.takeMsg() != null);
|
|
3733
|
+
}
|
|
3734
|
+
for ([_]u64{ 7, 8 }) |key| fx.playAudio(.{ .key = key, .path = "", .on_event = SessionApp.Effects.audioMsg(.audio_event) });
|
|
3735
|
+
fx.playAudio(.{ .key = 41, .path = "assets/session-track.mp3", .on_event = SessionApp.Effects.audioMsg(.audio_event) });
|
|
3736
|
+
const event: effects_mod.EffectAudio = .{ .key = 41, .kind = .loaded, .duration_ms = 30_000, .playing = true };
|
|
3737
|
+
try fx.feedAudioRecord(event);
|
|
3738
|
+
const synchronous = fx.takeAudioMsg(.{ .kind = .loaded, .duration_ms = 30_000, .playing = true }).?;
|
|
3739
|
+
try std.testing.expectEqualDeep(event, synchronous.audio_event);
|
|
3740
|
+
for ([_]u64{ 7, 8 }) |key| {
|
|
3741
|
+
const deferred = fx.takeMsg().?.audio_event;
|
|
3742
|
+
try std.testing.expectEqual(key, deferred.key);
|
|
3743
|
+
try std.testing.expectEqual(effects_mod.EffectAudioEventKind.rejected, deferred.kind);
|
|
3744
|
+
}
|
|
3745
|
+
try std.testing.expect(fx.takeMsg() == null);
|
|
3746
|
+
try fx.finishReplay();
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
test "recorded audio rejects altered missing unconsumed and wrongly owned deliveries" {
|
|
3750
|
+
for (0..4) |scenario| {
|
|
3751
|
+
const fx = try std.testing.allocator.create(SessionApp.Effects);
|
|
3752
|
+
defer std.testing.allocator.destroy(fx);
|
|
3753
|
+
fx.* = SessionApp.Effects.init(std.testing.allocator);
|
|
3754
|
+
defer fx.deinit();
|
|
3755
|
+
fx.armReplay();
|
|
3756
|
+
fx.playAudio(.{ .key = 41, .path = "assets/session-track.mp3", .on_event = SessionApp.Effects.audioMsg(.audio_event) });
|
|
3757
|
+
var event: effects_mod.EffectAudio = .{ .key = 41, .kind = .loaded, .duration_ms = 30_000, .playing = true };
|
|
3758
|
+
if (scenario == 3) {
|
|
3759
|
+
event.key = 42;
|
|
3760
|
+
try std.testing.expectError(error.EffectNotFound, fx.feedAudioRecord(event));
|
|
3761
|
+
continue;
|
|
3762
|
+
}
|
|
3763
|
+
if (scenario != 1) try fx.feedAudioRecord(event);
|
|
3764
|
+
if (scenario != 2) try std.testing.expect(fx.takeAudioMsg(.{ .kind = .loaded, .duration_ms = if (scenario == 0) 31_000 else 30_000, .playing = true }) == null);
|
|
3765
|
+
try std.testing.expectError(error.ReplayAudioDivergence, fx.finishReplay());
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3769
|
+
test "replay closes an adopted startup window before its native notification" {
|
|
3770
|
+
const ClosingApp = struct {
|
|
3771
|
+
closed: bool = false,
|
|
3772
|
+
fn app(self: *@This()) core.App {
|
|
3773
|
+
return .{ .context = self, .name = "adopted-close", .event_fn = event };
|
|
3774
|
+
}
|
|
3775
|
+
fn event(context: *anyopaque, runtime: *core.Runtime, incoming: core.Event) !void {
|
|
3776
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
3777
|
+
if (incoming == .command) {
|
|
3778
|
+
try runtime.closeWindow(incoming.command.window_id);
|
|
3779
|
+
self.closed = true;
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
};
|
|
3783
|
+
const gpa = std.testing.allocator;
|
|
3784
|
+
const bytes = try gpa.create(JournalBuffer);
|
|
3785
|
+
defer gpa.destroy(bytes);
|
|
3786
|
+
bytes.* = .{};
|
|
3787
|
+
const recorder = try gpa.create(session_record.SessionRecorder);
|
|
3788
|
+
defer gpa.destroy(recorder);
|
|
3789
|
+
recorder.* = session_record.SessionRecorder.init(bytes.sink());
|
|
3790
|
+
recorder.begin(.{ .app_name = "adopted-close", .platform_name = "null" });
|
|
3791
|
+
const recorded = try core.TestHarness().create(gpa, .{});
|
|
3792
|
+
defer recorded.destroy(gpa);
|
|
3793
|
+
recorded.runtime.options.session_recorder = recorder;
|
|
3794
|
+
const native_window = try recorded.null_platform.platform().services.createWindow(.{ .id = 1, .label = "main", .title = "Main" });
|
|
3795
|
+
var original: ClosingApp = .{};
|
|
3796
|
+
try recorded.runtime.dispatchPlatformEvent(original.app(), .app_start);
|
|
3797
|
+
const notification: platform.WindowState = .{ .id = 1, .label = "main", .title = "Main", .frame = native_window.frame, .scale_factor = 1, .open = true, .focused = true };
|
|
3798
|
+
try recorded.runtime.dispatchPlatformEvent(original.app(), .{ .window_frame_changed = notification });
|
|
3799
|
+
try recorded.runtime.dispatchPlatformEvent(original.app(), .frame_requested);
|
|
3800
|
+
try recorded.runtime.dispatchPlatformEvent(original.app(), .{ .menu_command = .{ .name = "close", .window_id = 1 } });
|
|
3801
|
+
try recorded.runtime.dispatchPlatformEvent(original.app(), .frame_requested);
|
|
3802
|
+
var closed_notification = notification;
|
|
3803
|
+
closed_notification.open = false;
|
|
3804
|
+
closed_notification.focused = false;
|
|
3805
|
+
try recorded.runtime.dispatchPlatformEvent(original.app(), .{ .window_frame_changed = closed_notification });
|
|
3806
|
+
recorder.finish();
|
|
3807
|
+
try std.testing.expect(original.closed and recorder.finished and !recorder.failed);
|
|
3808
|
+
const replayed = try core.TestHarness().create(gpa, .{});
|
|
3809
|
+
defer replayed.destroy(gpa);
|
|
3810
|
+
var fresh: ClosingApp = .{};
|
|
3811
|
+
const report = try session_replay.replaySession(&replayed.runtime, fresh.app(), bytes.journalBytes(), .{ .require_same_platform = false });
|
|
3812
|
+
try std.testing.expect(report.ok() and fresh.closed);
|
|
3813
|
+
try std.testing.expect(report.checkpoints_verified >= 2);
|
|
3814
|
+
try std.testing.expectEqual(recorded.runtime.sessionStateFingerprint(), replayed.runtime.sessionStateFingerprint());
|
|
3815
|
+
// Missing native ownership remains an error outside replay, and unrelated
|
|
3816
|
+
// native failures preserve all runtime flags even during replay.
|
|
3817
|
+
for ([_]bool{ false, true }) |replay| {
|
|
3818
|
+
const failed = try core.TestHarness().create(gpa, .{});
|
|
3819
|
+
defer failed.destroy(gpa);
|
|
3820
|
+
try failed.runtime.dispatchPlatformEvent(fresh.app(), .{ .window_frame_changed = notification });
|
|
3821
|
+
failed.runtime.replay_window_chrome_active = replay;
|
|
3822
|
+
if (replay) failed.null_platform.fail_next_close_window = true;
|
|
3823
|
+
try std.testing.expectError(if (replay) error.CloseFailed else error.WindowNotFound, failed.runtime.closeWindow(1));
|
|
3824
|
+
var windows: [platform.max_windows]platform.WindowInfo = undefined;
|
|
3825
|
+
const window = failed.runtime.listWindows(&windows)[0];
|
|
3826
|
+
try std.testing.expect(window.open and window.focused and !window.hidden);
|
|
3827
|
+
}
|
|
3828
|
+
}
|