@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
|
@@ -13,6 +13,8 @@ const app_manifest = @import("app_manifest");
|
|
|
13
13
|
const core = @import("core.zig");
|
|
14
14
|
const ui_app_model = @import("ui_app.zig");
|
|
15
15
|
const support = @import("test_support.zig");
|
|
16
|
+
const session_record = @import("session_record.zig");
|
|
17
|
+
const session_replay = @import("session_replay.zig");
|
|
16
18
|
|
|
17
19
|
const canvas_label = "panel-canvas";
|
|
18
20
|
const settings_canvas_label = "settings-canvas";
|
|
@@ -102,6 +104,10 @@ const Fixture = struct {
|
|
|
102
104
|
app: core.App,
|
|
103
105
|
|
|
104
106
|
fn create() !Fixture {
|
|
107
|
+
return createWithPolicy(null);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fn createWithPolicy(policy: ?*const fn ([]const u8, []u8) usize) !Fixture {
|
|
105
111
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
106
112
|
errdefer harness.destroy(std.testing.allocator);
|
|
107
113
|
harness.null_platform.gpu_surfaces = true;
|
|
@@ -112,6 +118,7 @@ const Fixture = struct {
|
|
|
112
118
|
.update = panelUpdate,
|
|
113
119
|
.view = panelView,
|
|
114
120
|
.windows_fn = panelWindows,
|
|
121
|
+
.window_policy = policy,
|
|
115
122
|
.window_view = panelWindowView,
|
|
116
123
|
});
|
|
117
124
|
const app = app_state.app();
|
|
@@ -174,6 +181,61 @@ fn widgetIdByText(layout: canvas.WidgetLayoutTree, kind: canvas.WidgetKind, text
|
|
|
174
181
|
return null;
|
|
175
182
|
}
|
|
176
183
|
|
|
184
|
+
fn panelThemeState(model: *const PanelModel) PanelApp.ThemeState {
|
|
185
|
+
return .{ .color_scheme = switch (model.bumps) {
|
|
186
|
+
0 => .dark,
|
|
187
|
+
1 => .light,
|
|
188
|
+
else => .system,
|
|
189
|
+
} };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
test "window appearance reaches new hidden and reopened secondary windows" {
|
|
193
|
+
const fixture = try Fixture.create();
|
|
194
|
+
defer fixture.destroy();
|
|
195
|
+
fixture.app_state.options.theme_state_fn = panelThemeState;
|
|
196
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
197
|
+
try std.testing.expectEqual(support.platform.WindowColorScheme.dark, fixture.harness.null_platform.windowColorScheme(1).?);
|
|
198
|
+
try fixture.clickSettingsButton();
|
|
199
|
+
var settings = fixture.settingsWindowInfo().?;
|
|
200
|
+
// Creation gets the theme before its own first GPU frame.
|
|
201
|
+
try std.testing.expect(!fixture.app_state.window_slots[0].installed);
|
|
202
|
+
try std.testing.expectEqual(support.platform.WindowColorScheme.dark, fixture.harness.null_platform.windowColorScheme(settings.id).?);
|
|
203
|
+
try fixture.harness.runtime.hideWindow(settings.id);
|
|
204
|
+
try fixture.app_state.dispatch(&fixture.harness.runtime, 1, .bump);
|
|
205
|
+
try std.testing.expectEqual(support.platform.WindowColorScheme.light, fixture.harness.null_platform.windowColorScheme(settings.id).?);
|
|
206
|
+
try std.testing.expect(fixture.settingsWindowInfo().?.hidden);
|
|
207
|
+
try fixture.harness.runtime.showWindow(settings.id);
|
|
208
|
+
try fixture.installSettingsCanvas(settings.id);
|
|
209
|
+
const light = canvas.DesignTokens.theme(.{ .color_scheme = .light });
|
|
210
|
+
const tokens = try fixture.harness.runtime.canvasWidgetDesignTokens(settings.id, settings_canvas_label);
|
|
211
|
+
try std.testing.expectEqualDeep(light.colors.background, tokens.colors.background);
|
|
212
|
+
|
|
213
|
+
// Closing and reopening reuses the declaration's label, not its old
|
|
214
|
+
// native appearance. Returning to system clears both live overrides.
|
|
215
|
+
try fixture.clickSettingsButton();
|
|
216
|
+
try fixture.app_state.dispatch(&fixture.harness.runtime, 1, .bump);
|
|
217
|
+
try fixture.clickSettingsButton();
|
|
218
|
+
settings = fixture.settingsWindowInfo().?;
|
|
219
|
+
try std.testing.expectEqual(support.platform.WindowColorScheme.system, fixture.harness.null_platform.windowColorScheme(settings.id).?);
|
|
220
|
+
try std.testing.expectEqual(support.platform.WindowColorScheme.system, fixture.harness.null_platform.windowColorScheme(1).?);
|
|
221
|
+
try fixture.installSettingsCanvas(settings.id);
|
|
222
|
+
|
|
223
|
+
// A surviving secondary window can still change appearance after the
|
|
224
|
+
// primary canvas closes. Never call the capability on the dead window.
|
|
225
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, .{ .window_frame_changed = .{
|
|
226
|
+
.id = 1,
|
|
227
|
+
.label = "main",
|
|
228
|
+
.title = "Panel",
|
|
229
|
+
.frame = geometry.RectF.init(0, 0, 400, 300),
|
|
230
|
+
.scale_factor = 2,
|
|
231
|
+
.open = false,
|
|
232
|
+
.focused = false,
|
|
233
|
+
} });
|
|
234
|
+
fixture.app_state.model.bumps = 0;
|
|
235
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
236
|
+
try std.testing.expectEqual(support.platform.WindowColorScheme.dark, fixture.harness.null_platform.windowColorScheme(settings.id).?);
|
|
237
|
+
}
|
|
238
|
+
|
|
177
239
|
test "a Msg declares the settings window, its canvas installs, and automation drives it by label" {
|
|
178
240
|
const fixture = try Fixture.create();
|
|
179
241
|
defer fixture.destroy();
|
|
@@ -705,6 +767,7 @@ test "a padded secondary drag header keeps its layout (no double reservation)" {
|
|
|
705
767
|
const VerbModel = struct {
|
|
706
768
|
settings_open: bool = true,
|
|
707
769
|
close_policy: app_manifest.WindowClosePolicy = .quit,
|
|
770
|
+
activate_settings: bool = true,
|
|
708
771
|
};
|
|
709
772
|
|
|
710
773
|
const VerbMsg = union(enum) {
|
|
@@ -746,6 +809,7 @@ fn verbWindows(model: *const VerbModel, scratch: *VerbApp.WindowsScratch) []cons
|
|
|
746
809
|
.width = 320,
|
|
747
810
|
.height = 240,
|
|
748
811
|
.close_policy = model.close_policy,
|
|
812
|
+
.activate_on_show = model.activate_settings,
|
|
749
813
|
.on_close = .settings_closed,
|
|
750
814
|
};
|
|
751
815
|
count += 1;
|
|
@@ -759,6 +823,80 @@ fn verbWindowView(ui: *VerbApp.Ui, model: *const VerbModel, window_label: []cons
|
|
|
759
823
|
return ui.text(.{}, "settings");
|
|
760
824
|
}
|
|
761
825
|
|
|
826
|
+
fn showReplayView(ui: *VerbApp.Ui, model: *const VerbModel) VerbApp.Ui.Node {
|
|
827
|
+
_ = model;
|
|
828
|
+
return ui.button(.{ .on_press = .show_settings }, "Show");
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
test "show-window replay preserves immediate focus before the native frame echo" {
|
|
832
|
+
const Sink = struct {
|
|
833
|
+
bytes: std.ArrayList(u8) = .empty,
|
|
834
|
+
fn write(context: *anyopaque, bytes: []const u8) !void {
|
|
835
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
836
|
+
try self.bytes.appendSlice(std.testing.allocator, bytes);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
for ([_]bool{ true, false }) |activate| {
|
|
840
|
+
var sink: Sink = .{};
|
|
841
|
+
defer sink.bytes.deinit(std.testing.allocator);
|
|
842
|
+
const recorder = try std.testing.allocator.create(session_record.SessionRecorder);
|
|
843
|
+
defer std.testing.allocator.destroy(recorder);
|
|
844
|
+
recorder.* = session_record.SessionRecorder.init(.{ .context = &sink, .write_fn = Sink.write });
|
|
845
|
+
recorder.begin(.{ .app_name = "show-replay", .platform_name = "null" });
|
|
846
|
+
var fingerprint: u64 = undefined;
|
|
847
|
+
for ([_]bool{ false, true }) |replaying| {
|
|
848
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
849
|
+
defer harness.destroy(std.testing.allocator);
|
|
850
|
+
harness.null_platform.gpu_surfaces = true;
|
|
851
|
+
const state = try VerbApp.create(std.heap.page_allocator, .{
|
|
852
|
+
.name = "show-replay",
|
|
853
|
+
.scene = panel_scene,
|
|
854
|
+
.canvas_label = canvas_label,
|
|
855
|
+
.update_fx = verbUpdate,
|
|
856
|
+
.view = showReplayView,
|
|
857
|
+
.windows_fn = verbWindows,
|
|
858
|
+
.window_view = verbWindowView,
|
|
859
|
+
});
|
|
860
|
+
defer state.destroy();
|
|
861
|
+
state.model.close_policy = .hide;
|
|
862
|
+
state.model.activate_settings = activate;
|
|
863
|
+
const app = state.app();
|
|
864
|
+
if (replaying) {
|
|
865
|
+
const report = try session_replay.replaySession(&harness.runtime, app, sink.bytes.items, .{ .require_same_platform = false });
|
|
866
|
+
try std.testing.expect(report.ok());
|
|
867
|
+
try std.testing.expect(report.checkpoints_verified > 0);
|
|
868
|
+
try std.testing.expectEqual(fingerprint, harness.runtime.sessionStateFingerprint());
|
|
869
|
+
// The replay callback restores runtime state only.
|
|
870
|
+
try std.testing.expectEqual(@as(u32, 0), harness.null_platform.showCountForWindow(2));
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
harness.runtime.options.session_recorder = recorder;
|
|
874
|
+
try harness.start(app);
|
|
875
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
876
|
+
.label = canvas_label,
|
|
877
|
+
.size = geometry.SizeF.init(400, 300),
|
|
878
|
+
.scale_factor = 1,
|
|
879
|
+
.frame_index = 1,
|
|
880
|
+
.timestamp_ns = 1_000_000,
|
|
881
|
+
} });
|
|
882
|
+
const hide = harness.null_platform.userCloseWindow(2) orelse return error.TestUnexpectedResult;
|
|
883
|
+
try harness.runtime.dispatchPlatformEvent(app, hide);
|
|
884
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .window_focused = 1 });
|
|
885
|
+
const layout = try harness.runtime.canvasWidgetLayout(1, canvas_label);
|
|
886
|
+
const id = widgetIdByText(layout, .button, "Show") orelse return error.TestUnexpectedResult;
|
|
887
|
+
var text: [96]u8 = undefined;
|
|
888
|
+
try harness.runtime.dispatchAutomationCommand(app, try std.fmt.bufPrint(&text, "widget-click {s} {d}", .{ canvas_label, id }));
|
|
889
|
+
// Checkpoint before any delayed host echo: active show drops
|
|
890
|
+
// the main button's keyboard focus; passive show retains it.
|
|
891
|
+
try harness.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
892
|
+
fingerprint = harness.runtime.sessionStateFingerprint();
|
|
893
|
+
recorder.finish();
|
|
894
|
+
try std.testing.expect(!recorder.failed);
|
|
895
|
+
try std.testing.expectEqual(@as(u32, 1), harness.null_platform.showCountForWindow(2));
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
762
900
|
test "window-action effects resolve labels to live windows and drive the real verbs" {
|
|
763
901
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
764
902
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -1645,3 +1783,87 @@ test "closing the pin-owning window releases its snapshot and pin" {
|
|
|
1645
1783
|
} });
|
|
1646
1784
|
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.sends);
|
|
1647
1785
|
}
|
|
1786
|
+
|
|
1787
|
+
// These intentionally choose outcomes independently of the reference key
|
|
1788
|
+
// lookup, proving the native consumer applies the policy's decisions.
|
|
1789
|
+
const WindowPolicyProbe = struct {
|
|
1790
|
+
var refuse_create = false;
|
|
1791
|
+
var retire_once = false;
|
|
1792
|
+
var has_window = false;
|
|
1793
|
+
var calls: usize = 0;
|
|
1794
|
+
|
|
1795
|
+
fn decide(request: []const u8, output: []u8) usize {
|
|
1796
|
+
calls += 1;
|
|
1797
|
+
output[0] = 0;
|
|
1798
|
+
output[1] = 255;
|
|
1799
|
+
if (request[0] == 0) {
|
|
1800
|
+
if (retire_once and has_window) {
|
|
1801
|
+
output[1] = 0;
|
|
1802
|
+
retire_once = false;
|
|
1803
|
+
has_window = false;
|
|
1804
|
+
}
|
|
1805
|
+
} else if (refuse_create) {
|
|
1806
|
+
output[0] = 2;
|
|
1807
|
+
} else if (has_window) {
|
|
1808
|
+
output[0] = 1;
|
|
1809
|
+
output[1] = 0;
|
|
1810
|
+
} else {
|
|
1811
|
+
has_window = true;
|
|
1812
|
+
}
|
|
1813
|
+
return 2;
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
|
|
1817
|
+
test "window consumer follows policy admission retirement and existing-slot decisions" {
|
|
1818
|
+
WindowPolicyProbe.refuse_create = true;
|
|
1819
|
+
WindowPolicyProbe.retire_once = false;
|
|
1820
|
+
WindowPolicyProbe.has_window = false;
|
|
1821
|
+
WindowPolicyProbe.calls = 0;
|
|
1822
|
+
const fixture = try Fixture.createWithPolicy(WindowPolicyProbe.decide);
|
|
1823
|
+
defer fixture.destroy();
|
|
1824
|
+
try fixture.clickSettingsButton();
|
|
1825
|
+
try std.testing.expect(fixture.app_state.model.settings_open);
|
|
1826
|
+
try std.testing.expect(fixture.settingsWindowInfo() == null);
|
|
1827
|
+
WindowPolicyProbe.refuse_create = false;
|
|
1828
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
1829
|
+
const first = fixture.settingsWindowInfo().?.id;
|
|
1830
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
1831
|
+
try std.testing.expectEqual(first, fixture.settingsWindowInfo().?.id);
|
|
1832
|
+
WindowPolicyProbe.retire_once = true;
|
|
1833
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
1834
|
+
try std.testing.expect(fixture.settingsWindowInfo().?.id != first);
|
|
1835
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.user_closes);
|
|
1836
|
+
try std.testing.expect(WindowPolicyProbe.calls >= 9);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
test "failed native create leaves the next policy decision's window table empty" {
|
|
1840
|
+
const AdmissionProbe = struct {
|
|
1841
|
+
fn decide(request: []const u8, output: []u8) usize {
|
|
1842
|
+
output[0] = 0;
|
|
1843
|
+
output[1] = 255;
|
|
1844
|
+
if (request[0] == 1) {
|
|
1845
|
+
var at: usize = 1;
|
|
1846
|
+
for (0..3) |_| {
|
|
1847
|
+
const length = std.mem.readInt(u32, request[at..][0..4], .little);
|
|
1848
|
+
at += 4 + length;
|
|
1849
|
+
}
|
|
1850
|
+
if (request[at] != 0) {
|
|
1851
|
+
output[0] = 1;
|
|
1852
|
+
output[1] = 0;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return 2;
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
const fixture = try Fixture.createWithPolicy(AdmissionProbe.decide);
|
|
1859
|
+
defer fixture.destroy();
|
|
1860
|
+
fixture.app_state.model.settings_open = true;
|
|
1861
|
+
fixture.harness.null_platform.fail_next_create_window = true;
|
|
1862
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
1863
|
+
try std.testing.expect(fixture.settingsWindowInfo() == null);
|
|
1864
|
+
try std.testing.expectEqual(@as(usize, 0), fixture.app_state.window_slot_count);
|
|
1865
|
+
try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
|
|
1866
|
+
try std.testing.expect(fixture.settingsWindowInfo() != null);
|
|
1867
|
+
try std.testing.expectEqual(@as(usize, 1), fixture.app_state.window_slot_count);
|
|
1868
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.user_closes);
|
|
1869
|
+
}
|
package/src/runtime/view.zig
CHANGED
|
@@ -144,6 +144,16 @@ pub const CanvasWidgetClaimedKeyGrace = enum {
|
|
|
144
144
|
/// the one focused now, so the grace and its owner pin die at blur (the
|
|
145
145
|
/// target-less twin too, when the blurred view owns it).
|
|
146
146
|
pub fn clearImeGraceOnViewBlur(runtime: anytype, view: *RuntimeView) void {
|
|
147
|
+
const composition = @import("input_composition_policy.zig");
|
|
148
|
+
const input = platform.GpuSurfaceInputEvent{ .window_id = view.window_id, .label = view.label, .kind = .ime_cancel_composition };
|
|
149
|
+
if (composition.plan(view.canvas_widget_surface_scope_policy, .retire, input, composition.observations(runtime, view))) |program| {
|
|
150
|
+
composition.installWidget(view, program);
|
|
151
|
+
view.canvas_widget_tab_input_focus_entry_held = false;
|
|
152
|
+
view.canvas_widget_terminal_paste_v_held = false;
|
|
153
|
+
if (program.has(512)) runtime.targetless_ime_preedit_len = 0;
|
|
154
|
+
if (program.has(2048)) runtime.targetless_ime_commit_grace = false;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
147
157
|
// The owner pin clears UNCONDITIONALLY, not only when a grace is
|
|
148
158
|
// armed: an active (never-cancelled) composition's owner surviving
|
|
149
159
|
// a view blur would redirect post-refocus input to the stale editor
|
|
@@ -446,6 +456,15 @@ pub const RuntimeView = struct {
|
|
|
446
456
|
widget_layout_nodes: [max_canvas_widget_nodes_per_view]canvas.WidgetLayoutNode = undefined,
|
|
447
457
|
widget_layout_node_count: usize = 0,
|
|
448
458
|
widget_layout_root_bounds: ?geometry.RectF = null,
|
|
459
|
+
/// Optional compiled traversal for this retained view. A function
|
|
460
|
+
/// pointer survives window compaction without retaining arena data.
|
|
461
|
+
canvas_widget_tab_focus_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
462
|
+
/// Portable anchored-surface ownership over native retained facts.
|
|
463
|
+
canvas_widget_surface_scope_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
464
|
+
/// Portable focus return; native keeps IDs and focus effects.
|
|
465
|
+
canvas_widget_focus_return_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
466
|
+
/// Portable tooltip ownership and binding survival over retained facts.
|
|
467
|
+
canvas_widget_tooltip_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
449
468
|
widget_semantics_nodes: [max_canvas_widget_semantics_per_view]canvas.WidgetSemanticsNode = undefined,
|
|
450
469
|
widget_semantics_node_count: usize = 0,
|
|
451
470
|
/// Fingerprint of the last accessibility tree actually handed to the
|
|
@@ -922,6 +941,7 @@ pub const RuntimeView = struct {
|
|
|
922
941
|
pub const copyCanvasFrameRenderOverrides = CanvasFrameMethods.copyCanvasFrameRenderOverrides;
|
|
923
942
|
pub const compactCanvasFrameRenderOverrideNoops = CanvasFrameMethods.compactCanvasFrameRenderOverrideNoops;
|
|
924
943
|
pub const sampleCanvasRenderAnimations = CanvasFrameMethods.sampleCanvasRenderAnimations;
|
|
944
|
+
pub const sampleCanvasRenderAnimationsWithPolicy = CanvasFrameMethods.sampleCanvasRenderAnimationsWithPolicy;
|
|
925
945
|
pub const pruneCompletedNoopCanvasRenderAnimations = CanvasFrameMethods.pruneCompletedNoopCanvasRenderAnimations;
|
|
926
946
|
pub const canvasRenderAnimationsActive = CanvasFrameMethods.canvasRenderAnimationsActive;
|
|
927
947
|
pub const copyCanvasFramePipelineCache = CanvasFrameMethods.copyCanvasFramePipelineCache;
|
|
@@ -931,9 +951,12 @@ pub const RuntimeView = struct {
|
|
|
931
951
|
pub const recordCanvasFramePresentationComplete = CanvasFrameMethods.recordCanvasFramePresentationComplete;
|
|
932
952
|
pub const refreshCanvasFrameBudgetStatus = CanvasFrameMethods.refreshCanvasFrameBudgetStatus;
|
|
933
953
|
pub const copyPresentedCanvasSummary = CanvasFrameMethods.copyPresentedCanvasSummary;
|
|
954
|
+
pub const copyPresentedCanvasSummaryWithPolicy = CanvasFrameMethods.copyPresentedCanvasSummaryWithPolicy;
|
|
934
955
|
pub const copyPresentedCanvasSummaryFrom = CanvasFrameMethods.copyPresentedCanvasSummaryFrom;
|
|
935
956
|
pub const currentCanvasHasUnkeyed = CanvasFrameMethods.currentCanvasHasUnkeyed;
|
|
957
|
+
pub const currentCanvasHasUnkeyedWithPolicy = CanvasFrameMethods.currentCanvasHasUnkeyedWithPolicy;
|
|
936
958
|
pub const diffPresentedCanvasSummary = CanvasFrameMethods.diffPresentedCanvasSummary;
|
|
959
|
+
pub const diffPresentedCanvasSummaryWithPolicy = CanvasFrameMethods.diffPresentedCanvasSummaryWithPolicy;
|
|
937
960
|
pub const currentCanvasCommandById = CanvasFrameMethods.currentCanvasCommandById;
|
|
938
961
|
pub const presentedCanvasCommandById = CanvasFrameMethods.presentedCanvasCommandById;
|
|
939
962
|
pub const copyCanvasCommand = CanvasFrameMethods.copyCanvasCommand;
|
|
@@ -971,6 +994,8 @@ pub const RuntimeView = struct {
|
|
|
971
994
|
pub const canvasWidgetOwnedMenuSurfaceIndex = CanvasWidgetTreeMethods.canvasWidgetOwnedMenuSurfaceIndex;
|
|
972
995
|
pub const canvasWidgetOwnedTooltipIndex = CanvasWidgetTreeMethods.canvasWidgetOwnedTooltipIndex;
|
|
973
996
|
pub const canvasWidgetOwnedTooltipIdForOwner = CanvasWidgetTreeMethods.canvasWidgetOwnedTooltipIdForOwner;
|
|
997
|
+
pub const CanvasTooltipIntentCause = CanvasWidgetTreeMethods.CanvasTooltipIntentCause;
|
|
998
|
+
pub const applyCompiledCanvasTooltipIntent = CanvasWidgetTreeMethods.applyCompiledCanvasTooltipIntent;
|
|
974
999
|
pub const applyCanvasTooltipVisibility = CanvasWidgetTreeMethods.applyCanvasTooltipVisibility;
|
|
975
1000
|
pub const applyCanvasTooltipVisibilityToNodes = CanvasWidgetTreeMethods.applyCanvasTooltipVisibilityToNodes;
|
|
976
1001
|
pub const applyCanvasTooltipVisibilityToNodesForShownId = CanvasWidgetTreeMethods.applyCanvasTooltipVisibilityToNodesForShownId;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const scene_policy = @import("canvas_scene_observation_policy.zig");
|
|
2
|
+
const sampling_policy = @import("motion_sampling_policy.zig");
|
|
1
3
|
const geometry = @import("geometry");
|
|
2
4
|
const canvas = @import("canvas");
|
|
3
5
|
const canvas_frame_helpers = @import("canvas_frame.zig");
|
|
@@ -435,6 +437,11 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
435
437
|
return canvas.sampleCanvasRenderAnimations(self.canvasRenderAnimations(), timestamp_ns, output);
|
|
436
438
|
}
|
|
437
439
|
|
|
440
|
+
pub fn sampleCanvasRenderAnimationsWithPolicy(self: *const RuntimeView, timestamp_ns: u64, output: []canvas.CanvasRenderOverride, policy: ?sampling_policy.Policy) anyerror![]const canvas.CanvasRenderOverride {
|
|
441
|
+
if (policy) |owner| return sampling_policy.sample(self.canvasRenderAnimations(), timestamp_ns, output, owner);
|
|
442
|
+
return self.sampleCanvasRenderAnimations(timestamp_ns, output);
|
|
443
|
+
}
|
|
444
|
+
|
|
438
445
|
pub fn pruneCompletedNoopCanvasRenderAnimations(self: *RuntimeView, timestamp_ns: u64) bool {
|
|
439
446
|
var len: usize = 0;
|
|
440
447
|
var pruned = false;
|
|
@@ -479,13 +486,14 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
479
486
|
pub fn recordCanvasFrame(self: *RuntimeView, frame: canvas.CanvasFrame) void {
|
|
480
487
|
const render_pass = frame.renderPass();
|
|
481
488
|
const gpu_packet_summary = frame.gpuPacketSummary();
|
|
489
|
+
const encoder_counts = render_pass.encoderCounts();
|
|
482
490
|
self.canvas_frame_requires_render = frame.requiresRender();
|
|
483
491
|
self.canvas_frame_full_repaint = frame.full_repaint;
|
|
484
492
|
self.canvas_frame_batch_count = frame.batch_plan.batchCount();
|
|
485
|
-
self.canvas_frame_encoder_command_count =
|
|
486
|
-
self.canvas_frame_encoder_cache_action_count =
|
|
487
|
-
self.canvas_frame_encoder_bind_pipeline_count =
|
|
488
|
-
self.canvas_frame_encoder_draw_batch_count =
|
|
493
|
+
self.canvas_frame_encoder_command_count = encoder_counts.commands;
|
|
494
|
+
self.canvas_frame_encoder_cache_action_count = encoder_counts.caches;
|
|
495
|
+
self.canvas_frame_encoder_bind_pipeline_count = encoder_counts.binds;
|
|
496
|
+
self.canvas_frame_encoder_draw_batch_count = encoder_counts.draws;
|
|
489
497
|
self.canvas_frame_pipeline_count = frame.pipeline_cache_plan.entryCount();
|
|
490
498
|
self.canvas_frame_pipeline_upload_count = frame.pipeline_cache_plan.uploadCount();
|
|
491
499
|
self.canvas_frame_pipeline_retain_count = frame.pipeline_cache_plan.retainCount();
|
|
@@ -533,7 +541,7 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
533
541
|
self.canvas_frame_gpu_packet_representable = gpu_packet_summary.fullyRepresentable();
|
|
534
542
|
self.canvas_frame_change_count = frame.changes.len;
|
|
535
543
|
self.canvas_frame_budget = frame.budget;
|
|
536
|
-
self.canvas_frame_budget_status = frame.
|
|
544
|
+
self.canvas_frame_budget_status = frame.budgetStatusFromPlanningSummaries(gpu_packet_summary, encoder_counts);
|
|
537
545
|
self.canvas_frame_dirty_bounds = frame.dirty_bounds;
|
|
538
546
|
const profile = frame.profile();
|
|
539
547
|
self.canvas_frame_profile_work_units = profile.work_units;
|
|
@@ -546,6 +554,7 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
546
554
|
pub fn recordCanvasFramePresentationComplete(self: *RuntimeView, frame: canvas.CanvasFrame) void {
|
|
547
555
|
if (!self.presented_canvas_valid or self.presented_canvas_revision != self.canvas_revision) return;
|
|
548
556
|
self.recordCanvasFrame(.{
|
|
557
|
+
.gpu_plan_policy = frame.gpu_plan_policy,
|
|
549
558
|
.frame_index = frame.frame_index,
|
|
550
559
|
.timestamp_ns = frame.timestamp_ns,
|
|
551
560
|
.surface_size = frame.surface_size,
|
|
@@ -612,6 +621,10 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
612
621
|
}
|
|
613
622
|
|
|
614
623
|
pub fn copyPresentedCanvasSummary(self: *RuntimeView, display_list: canvas.DisplayList, surface_size: geometry.SizeF, scale: f32) anyerror!void {
|
|
624
|
+
return self.copyPresentedCanvasSummaryWithPolicy(display_list, surface_size, scale, null);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
pub fn copyPresentedCanvasSummaryWithPolicy(self: *RuntimeView, display_list: canvas.DisplayList, surface_size: geometry.SizeF, scale: f32, owner: ?scene_policy.Policy) anyerror!void {
|
|
615
628
|
_ = try CanvasResourceCounts.fromDisplayList(display_list);
|
|
616
629
|
|
|
617
630
|
self.presented_canvas_valid = true;
|
|
@@ -631,9 +644,10 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
631
644
|
.id = id,
|
|
632
645
|
.bounds = command_bounds,
|
|
633
646
|
};
|
|
634
|
-
if (id == null and command_bounds != null) self.presented_canvas_has_unkeyed = true;
|
|
647
|
+
if (owner == null and id == null and command_bounds != null) self.presented_canvas_has_unkeyed = true;
|
|
635
648
|
self.presented_canvas_command_count += 1;
|
|
636
649
|
}
|
|
650
|
+
if (owner) |policy| self.presented_canvas_has_unkeyed = scene_policy.summaryHasUnkeyed(self.presented_canvas_commands[0..self.presented_canvas_command_count], policy);
|
|
637
651
|
self.presented_canvas_revision = self.canvas_revision;
|
|
638
652
|
}
|
|
639
653
|
|
|
@@ -648,6 +662,11 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
648
662
|
}
|
|
649
663
|
|
|
650
664
|
pub fn currentCanvasHasUnkeyed(self: *const RuntimeView) bool {
|
|
665
|
+
return self.currentCanvasHasUnkeyedWithPolicy(null);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
pub fn currentCanvasHasUnkeyedWithPolicy(self: *const RuntimeView, owner: ?scene_policy.Policy) bool {
|
|
669
|
+
if (owner) |policy| return scene_policy.currentHasUnkeyed(self.canvasDisplayList().commands, policy);
|
|
651
670
|
for (self.canvasDisplayList().commands) |command| {
|
|
652
671
|
if (command.objectId() == null and command.bounds() != null) return true;
|
|
653
672
|
}
|
|
@@ -655,6 +674,11 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
655
674
|
}
|
|
656
675
|
|
|
657
676
|
pub fn diffPresentedCanvasSummary(self: *const RuntimeView, output: []canvas.DiffChange) anyerror![]const canvas.DiffChange {
|
|
677
|
+
return self.diffPresentedCanvasSummaryWithPolicy(output, null);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
pub fn diffPresentedCanvasSummaryWithPolicy(self: *const RuntimeView, output: []canvas.DiffChange, owner: ?scene_policy.Policy) anyerror![]const canvas.DiffChange {
|
|
681
|
+
if (owner) |policy| return scene_policy.diff(self, output, policy);
|
|
658
682
|
if (self.canvas_revision == self.presented_canvas_revision) return output[0..0];
|
|
659
683
|
|
|
660
684
|
// Id lookups ride the probe-table index whenever the lists
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//! Copies raw window/view observations; native owns storage and OS execution.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const platform = @import("../platform/root.zig");
|
|
5
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
6
|
+
pub const Mode = enum(u8) { list, adjacent, repair, parent, absolute, platform_frame, local_frame, children, subtree, mutation, window };
|
|
7
|
+
pub const Kind = enum(u32) { none, main, native, webview };
|
|
8
|
+
pub const Selection = struct { kind: Kind = .none, slot: usize = 0 };
|
|
9
|
+
pub const Options = struct {
|
|
10
|
+
window_id: platform.WindowId,
|
|
11
|
+
label: []const u8 = "",
|
|
12
|
+
parent: ?[]const u8 = null,
|
|
13
|
+
variant: u8 = 0,
|
|
14
|
+
capacity: usize = platform.max_views + platform.max_webviews + 1,
|
|
15
|
+
depth: usize = 0,
|
|
16
|
+
cursor: usize = 0,
|
|
17
|
+
clear: bool = false,
|
|
18
|
+
frame: geometry.RectF = .zero(),
|
|
19
|
+
};
|
|
20
|
+
pub const Program = struct {
|
|
21
|
+
status: u32,
|
|
22
|
+
decision: u32,
|
|
23
|
+
selected: Selection,
|
|
24
|
+
count: usize,
|
|
25
|
+
selections: [platform.max_views + platform.max_webviews + 1]Selection = undefined,
|
|
26
|
+
frame: geometry.RectF = .zero(),
|
|
27
|
+
pub fn admitted(self: *const Program) !void {
|
|
28
|
+
return switch (self.status) {
|
|
29
|
+
0 => {},
|
|
30
|
+
1 => error.WindowNotFound,
|
|
31
|
+
2 => error.ViewNotFound,
|
|
32
|
+
3 => error.InvalidViewOptions,
|
|
33
|
+
4 => error.UnsupportedViewFocus,
|
|
34
|
+
else => unreachable,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
comptime {
|
|
39
|
+
if (platform.max_windows != 16 or platform.max_views != 32 or platform.max_webviews != 16 or platform.max_view_label_bytes != 64 or platform.max_webview_label_bytes != 64)
|
|
40
|
+
@compileError("update view coordination packet capacities");
|
|
41
|
+
}
|
|
42
|
+
fn put(bytes: []u8, at: usize, value: u32) void {
|
|
43
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
44
|
+
}
|
|
45
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
46
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
47
|
+
}
|
|
48
|
+
fn writeRect(bytes: []u8, at: usize, frame: geometry.RectF) void {
|
|
49
|
+
for ([_]f32{ frame.x, frame.y, frame.width, frame.height }, 0..) |value, i| put(bytes, at + i * 4, @bitCast(value));
|
|
50
|
+
}
|
|
51
|
+
fn readRect(bytes: []const u8, at: usize) geometry.RectF {
|
|
52
|
+
return .init(@bitCast(word(bytes, at)), @bitCast(word(bytes, at + 4)), @bitCast(word(bytes, at + 8)), @bitCast(word(bytes, at + 12)));
|
|
53
|
+
}
|
|
54
|
+
fn text(bytes: []u8, at: usize, length_at: usize, value: []const u8) void {
|
|
55
|
+
put(bytes, length_at, std.math.cast(u32, value.len) orelse std.math.maxInt(u32));
|
|
56
|
+
@memcpy(bytes[at..][0..@min(value.len, 64)], value[0..@min(value.len, 64)]);
|
|
57
|
+
}
|
|
58
|
+
fn selection(bytes: []const u8, at: usize, runtime: anytype) Selection {
|
|
59
|
+
const kind = std.enums.fromInt(Kind, word(bytes, at)) orelse @panic("invalid compiled view selection kind");
|
|
60
|
+
const slot = word(bytes, at + 4);
|
|
61
|
+
const count = switch (kind) {
|
|
62
|
+
.none => 1,
|
|
63
|
+
.main => runtime.window_count,
|
|
64
|
+
.native => runtime.view_count,
|
|
65
|
+
.webview => runtime.webview_count,
|
|
66
|
+
};
|
|
67
|
+
if (slot >= count) @panic("invalid compiled view selection slot");
|
|
68
|
+
return .{ .kind = kind, .slot = slot };
|
|
69
|
+
}
|
|
70
|
+
pub fn plan(policy: Policy, runtime: anytype, mode: Mode, options: Options) Program {
|
|
71
|
+
if (runtime.window_count > platform.max_windows or runtime.view_count > platform.max_views or runtime.webview_count > platform.max_webviews)
|
|
72
|
+
@panic("view coordination observation capacity");
|
|
73
|
+
var request: [192 + platform.max_windows * 64 + (platform.max_views + platform.max_webviews) * 192]u8 = @splat(0);
|
|
74
|
+
request[0..4].* = .{ 80, 1, @intFromEnum(mode), options.variant };
|
|
75
|
+
put(&request, 4, @intCast(runtime.window_count));
|
|
76
|
+
put(&request, 8, @intCast(runtime.view_count));
|
|
77
|
+
put(&request, 12, @intCast(runtime.webview_count));
|
|
78
|
+
std.mem.writeInt(u64, request[16..24], options.window_id, .little);
|
|
79
|
+
text(&request, 64, 24, options.label);
|
|
80
|
+
put(&request, 28, std.math.maxInt(u32));
|
|
81
|
+
if (options.parent) |parent| text(&request, 128, 28, parent);
|
|
82
|
+
put(&request, 32, @intCast(@min(options.capacity, platform.max_views + platform.max_webviews + 1)));
|
|
83
|
+
put(&request, 36, std.math.cast(u32, options.depth) orelse std.math.maxInt(u32));
|
|
84
|
+
put(&request, 40, std.math.cast(u32, options.cursor) orelse std.math.maxInt(u32));
|
|
85
|
+
put(&request, 44, @intFromBool(options.clear));
|
|
86
|
+
writeRect(&request, 48, options.frame);
|
|
87
|
+
for (runtime.windows[0..runtime.window_count], 0..) |*window, i| {
|
|
88
|
+
const at = 192 + i * 64;
|
|
89
|
+
std.mem.writeInt(u64, request[at..][0..8], window.info.id, .little);
|
|
90
|
+
put(&request, at + 8, @as(u32, @intFromBool(window.info.open)) | (@as(u32, @intFromBool(window.source != null)) << 1) | (@as(u32, @intFromBool(window.main_focused)) << 2) | (@as(u32, @intFromBool(window.main_frame_set)) << 3));
|
|
91
|
+
writeRect(&request, at + 16, window.info.frame);
|
|
92
|
+
writeRect(&request, at + 32, window.main_frame);
|
|
93
|
+
std.mem.writeInt(u64, request[at + 48 ..][0..8], window.main_view_id, .little);
|
|
94
|
+
}
|
|
95
|
+
var at = 192 + runtime.window_count * 64;
|
|
96
|
+
for (runtime.views[0..runtime.view_count]) |*view| {
|
|
97
|
+
writeView(&request, at, view, view.visible, view.enabled);
|
|
98
|
+
at += 192;
|
|
99
|
+
}
|
|
100
|
+
for (runtime.webviews[0..runtime.webview_count]) |*view| {
|
|
101
|
+
writeView(&request, at, view, true, true);
|
|
102
|
+
at += 192;
|
|
103
|
+
}
|
|
104
|
+
var output: [32 + (platform.max_views + platform.max_webviews + 1) * 8]u8 = @splat(0xa5);
|
|
105
|
+
const length = policy(request[0..at], &output);
|
|
106
|
+
if (length < 32 or length > output.len or word(&output, 0) != 1 or word(&output, 4) != @intFromEnum(mode) or word(&output, 8) > 4 or word(&output, 28) != 0)
|
|
107
|
+
@panic("invalid compiled view coordination header");
|
|
108
|
+
var result = Program{ .status = word(&output, 8), .decision = word(&output, 12), .selected = selection(&output, 16, runtime), .count = word(&output, 24) };
|
|
109
|
+
const has_frame = result.status == 0 and (mode == .absolute or mode == .platform_frame or mode == .local_frame);
|
|
110
|
+
if (result.count > result.selections.len or length != 32 + result.count * 8 + @as(usize, if (has_frame) 16 else 0) or ((mode != .list and mode != .children) and result.count != 0) or (mode == .list and result.count > options.capacity) or (result.status != 0 and (result.count != 0 or result.selected.kind != .none or result.decision != 0)))
|
|
111
|
+
@panic("invalid compiled view coordination shape");
|
|
112
|
+
const decision_limit: u32 = switch (mode) {
|
|
113
|
+
.repair, .children => 2,
|
|
114
|
+
.subtree => 1,
|
|
115
|
+
.mutation => 7,
|
|
116
|
+
else => 0,
|
|
117
|
+
};
|
|
118
|
+
if (result.decision > decision_limit or (result.selected.kind != .none and mode != .adjacent and mode != .repair and mode != .mutation))
|
|
119
|
+
@panic("invalid compiled view coordination decision");
|
|
120
|
+
const status_valid = switch (mode) {
|
|
121
|
+
.list, .repair, .children, .subtree, .mutation => result.status == 0,
|
|
122
|
+
.adjacent => result.status == 0 or result.status == 1 or result.status == 4,
|
|
123
|
+
.parent => result.status == 0 or result.status == 2 or result.status == 3,
|
|
124
|
+
.absolute, .platform_frame, .local_frame => result.status <= 3,
|
|
125
|
+
.window => result.status == 0 or result.status == 1,
|
|
126
|
+
};
|
|
127
|
+
if (!status_valid or (mode == .adjacent and result.status == 0 and result.selected.kind == .none) or (mode == .repair and ((result.decision == 2) != (result.selected.kind != .none))) or (mode == .children and (result.decision != @as(u32, options.variant) + 1 or (options.cursor != 0 and result.count > 1))) or (mode == .mutation and ((result.decision & 1 != 0) != (result.selected.kind != .none) or (result.decision & 4 != 0 and result.decision & 2 != 0))))
|
|
128
|
+
@panic("invalid compiled view coordination admission");
|
|
129
|
+
for (result.selections[0..result.count], 0..) |*selected, i| {
|
|
130
|
+
selected.* = selection(&output, 32 + i * 8, runtime);
|
|
131
|
+
if (selected.kind == .none or (mode == .children and selected.kind == .main)) @panic("invalid compiled view coordination list member");
|
|
132
|
+
if (mode == .children and options.cursor != 0 and options.cursor != (if (selected.kind == .native) selected.slot + 1 else selected.slot + 33)) @panic("invalid compiled descendant cursor result");
|
|
133
|
+
}
|
|
134
|
+
if (has_frame) result.frame = readRect(&output, 32);
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
fn writeView(bytes: []u8, at: usize, view: anytype, visible: bool, enabled: bool) void {
|
|
138
|
+
if (view.label.len > 64 or (view.parent != null and view.parent.?.len > 64)) @panic("view coordination label capacity");
|
|
139
|
+
std.mem.writeInt(u64, bytes[at..][0..8], view.window_id, .little);
|
|
140
|
+
put(bytes, at + 8, @as(u32, @intFromBool(view.open)) | (@as(u32, @intFromBool(visible)) << 1) | (@as(u32, @intFromBool(enabled)) << 2) | (@as(u32, @intFromBool(view.focused)) << 3));
|
|
141
|
+
text(bytes, at + 64, at + 16, view.label);
|
|
142
|
+
put(bytes, at + 20, std.math.maxInt(u32));
|
|
143
|
+
if (view.parent) |parent| text(bytes, at + 128, at + 20, parent);
|
|
144
|
+
std.mem.writeInt(u64, bytes[at + 24 ..][0..8], view.id, .little);
|
|
145
|
+
writeRect(bytes, at + 32, view.frame);
|
|
146
|
+
if (comptime @hasField(@TypeOf(view.*), "local_frame")) writeRect(bytes, at + 48, view.local_frame);
|
|
147
|
+
}
|