@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
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//! Copied widget-motion packets. Native retains identities, buffers and
|
|
2
|
+
//! render samples; compiled policy cannot borrow retained-tree storage.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const canvas = @import("canvas");
|
|
5
|
+
const geometry = @import("geometry");
|
|
6
|
+
const limits = @import("canvas_limits.zig");
|
|
7
|
+
const view_model = @import("view.zig");
|
|
8
|
+
const widget_runtime = @import("canvas_widget_runtime.zig");
|
|
9
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
10
|
+
comptime {
|
|
11
|
+
const kinds = @typeInfo(canvas.WidgetKind).@"enum".fields;
|
|
12
|
+
if (kinds.len != 63 or @intFromEnum(canvas.WidgetKind.accordion) != 14) @compileError("update motion kind wire");
|
|
13
|
+
const easings = .{ "linear", "standard", "emphasized", "spring" };
|
|
14
|
+
for (@typeInfo(canvas.Easing).@"enum".fields, easings, 0..) |field, name, i| {
|
|
15
|
+
if (!std.mem.eql(u8, field.name, name) or field.value != i) @compileError("update motion easing wire");
|
|
16
|
+
}
|
|
17
|
+
const loops = .{ "none", "ping_pong", "wrap" };
|
|
18
|
+
for (@typeInfo(canvas.CanvasRenderAnimationLoop).@"enum".fields, loops, 0..) |field, name, i| {
|
|
19
|
+
if (!std.mem.eql(u8, field.name, name) or field.value != i) @compileError("update motion loop wire");
|
|
20
|
+
}
|
|
21
|
+
if (limits.max_canvas_widget_nodes_per_view > 1024 or limits.max_canvas_widget_disclosure_flips_per_view > 8 or limits.max_canvas_widget_disclosure_moves_per_view > 256 or limits.max_canvas_widget_drag_layout_motions_per_view > 64 or limits.max_canvas_widget_loop_animations_per_view > 64) @compileError("update motion capacity wire");
|
|
22
|
+
}
|
|
23
|
+
pub const DisclosureAction = enum { none, arm, refresh, retire };
|
|
24
|
+
pub const DisclosurePlan = struct {
|
|
25
|
+
action: DisclosureAction = .none,
|
|
26
|
+
duration_ms: u32 = 0,
|
|
27
|
+
revealing_ids: [limits.max_canvas_widget_disclosure_flips_per_view]canvas.ObjectId = undefined,
|
|
28
|
+
revealing_id_count: usize = 0,
|
|
29
|
+
moves: [limits.max_canvas_widget_disclosure_moves_per_view]view_model.CanvasWidgetDisclosureMove = undefined,
|
|
30
|
+
move_count: usize = 0,
|
|
31
|
+
};
|
|
32
|
+
pub const DragPlan = struct {
|
|
33
|
+
apply: bool = false,
|
|
34
|
+
motions: [limits.max_canvas_widget_drag_layout_motions_per_view]canvas.WidgetLayoutMotion = undefined,
|
|
35
|
+
motion_count: usize = 0,
|
|
36
|
+
};
|
|
37
|
+
pub const Admission = struct { action: enum { none, snap, arm, retarget, invalid }, remove: bool, announce: bool, frame: bool };
|
|
38
|
+
pub fn admission(policy: Policy, flags: u8, duration: u32, current: f32, target: f32, active_target: f32) Admission {
|
|
39
|
+
var input: [24]u8 = @splat(0);
|
|
40
|
+
input[0..3].* = .{ 18, 0, flags };
|
|
41
|
+
word(input[4..8], duration);
|
|
42
|
+
float(input[8..12], current);
|
|
43
|
+
float(input[12..16], target);
|
|
44
|
+
float(input[16..20], active_target);
|
|
45
|
+
var out: [4]u8 = undefined;
|
|
46
|
+
run(policy, &input, &out);
|
|
47
|
+
if ((out[0] > 3 and out[0] != 255) or out[1] > 1 or out[2] > 1 or out[3] > 1) @panic("invalid compiled tween admission");
|
|
48
|
+
return .{ .action = if (out[0] == 255) .invalid else @enumFromInt(out[0]), .remove = out[1] == 1, .announce = out[2] == 1, .frame = out[3] == 1 };
|
|
49
|
+
}
|
|
50
|
+
pub fn source(policy: Policy, kind: canvas.WidgetKind, id: u64, pressed: bool, duration: u32, value: f32) bool {
|
|
51
|
+
var input: [16]u8 = @splat(0);
|
|
52
|
+
input[0..3].* = .{ 18, 1, @as(u8, @intFromBool(kind == .split)) | (@as(u8, @intFromBool(id != 0)) << 1) | (@as(u8, @intFromBool(pressed)) << 2) };
|
|
53
|
+
word(input[4..8], duration);
|
|
54
|
+
float(input[8..12], value);
|
|
55
|
+
var out: [4]u8 = undefined;
|
|
56
|
+
run(policy, &input, &out);
|
|
57
|
+
if (out[0] > 1 or !std.mem.eql(u8, out[1..], &.{ 0, 0, 0 })) @panic("invalid compiled declared tween");
|
|
58
|
+
return out[0] == 1;
|
|
59
|
+
}
|
|
60
|
+
pub fn disclosure(allocator: std.mem.Allocator, policy: Policy, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree, view: anytype, reduced: bool) !DisclosurePlan {
|
|
61
|
+
const input = try allocator.alloc(u8, 24 + (previous.nodes.len + next.nodes.len) * 32);
|
|
62
|
+
defer allocator.free(input);
|
|
63
|
+
@memset(input, 0);
|
|
64
|
+
input[0..4].* = .{ 18, 2, @intFromBool(view.canvas_widget_disclosure_tween.active), @intFromBool(reduced) };
|
|
65
|
+
word(input[4..8], view.widget_tokens.motion.durationMs(.normal));
|
|
66
|
+
word(input[8..12], @intCast(previous.nodes.len));
|
|
67
|
+
word(input[12..16], @intCast(next.nodes.len));
|
|
68
|
+
var plan = DisclosurePlan{};
|
|
69
|
+
word(input[16..20], plan.revealing_ids.len);
|
|
70
|
+
word(input[20..24], plan.moves.len);
|
|
71
|
+
for (previous.nodes, 0..) |node, i| disclosureNode(input[24 + i * 32 ..][0..32], node, false);
|
|
72
|
+
for (next.nodes, 0..) |node, i| disclosureNode(input[24 + (previous.nodes.len + i) * 32 ..][0..32], node, view.canvasWidgetDisclosureTogglePending(node.widget.id));
|
|
73
|
+
var out: [16 + limits.max_canvas_widget_disclosure_flips_per_view * 8 + limits.max_canvas_widget_disclosure_moves_per_view * 24]u8 = undefined;
|
|
74
|
+
run(policy, input, &out);
|
|
75
|
+
plan.revealing_id_count = readWord(out[4..8]);
|
|
76
|
+
plan.move_count = readWord(out[8..12]);
|
|
77
|
+
if (out[0] > 3 or plan.revealing_id_count > plan.revealing_ids.len or plan.move_count > plan.moves.len or !std.mem.eql(u8, out[1..4], &.{ 0, 0, 0 })) @panic("invalid compiled disclosure plan");
|
|
78
|
+
plan.action = @enumFromInt(out[0]);
|
|
79
|
+
plan.duration_ms = readWord(out[12..16]);
|
|
80
|
+
for (plan.revealing_ids[0..plan.revealing_id_count], 0..) |*id, i| id.* = readWide(out[16 + i * 8 ..][0..8]);
|
|
81
|
+
for (plan.moves[0..plan.move_count], 0..) |*move, i| {
|
|
82
|
+
const bytes = out[16 + plan.revealing_ids.len * 8 + i * 24 ..][0..24];
|
|
83
|
+
const index = readWord(bytes[0..4]);
|
|
84
|
+
if (index >= next.nodes.len or readWord(bytes[4..8]) != 0) @panic("invalid compiled disclosure node index");
|
|
85
|
+
move.* = .{ .node_index = index, .from_y = readFloat(bytes[8..12]), .from_height = readFloat(bytes[12..16]), .to_y = readFloat(bytes[16..20]), .to_height = readFloat(bytes[20..24]) };
|
|
86
|
+
}
|
|
87
|
+
return plan;
|
|
88
|
+
}
|
|
89
|
+
fn disclosureNode(bytes: []u8, node: canvas.WidgetLayoutNode, pending: bool) void {
|
|
90
|
+
wide(bytes[0..8], node.widget.id);
|
|
91
|
+
bytes[8] = @intCast(@intFromEnum(node.widget.kind));
|
|
92
|
+
bytes[9] = @intFromBool(widget_runtime.canvasWidgetBooleanSelected(node.widget));
|
|
93
|
+
bytes[10] = @intFromBool(pending);
|
|
94
|
+
inline for (.{ "x", "y", "width", "height" }, 0..) |name, i| float(bytes[16 + i * 4 ..][0..4], @field(node.frame, name));
|
|
95
|
+
}
|
|
96
|
+
pub fn drag(allocator: std.mem.Allocator, policy: Policy, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree, view: anytype, reduced: bool) !DragPlan {
|
|
97
|
+
const input = try allocator.alloc(u8, 24 + next.nodes.len * 48);
|
|
98
|
+
defer allocator.free(input);
|
|
99
|
+
@memset(input, 0);
|
|
100
|
+
input[0..4].* = .{ 18, 3, @intFromBool(view.canvas_widget_drag_layout_motion_armed), @intFromBool(reduced) };
|
|
101
|
+
const duration = view.widget_tokens.motion.durationMs(.normal);
|
|
102
|
+
word(input[4..8], duration);
|
|
103
|
+
word(input[8..12], @intCast(next.nodes.len));
|
|
104
|
+
var plan = DragPlan{};
|
|
105
|
+
word(input[12..16], plan.motions.len);
|
|
106
|
+
const old = view.canvas_widget_drag_layout_motions[0..view.canvas_widget_drag_layout_motion_count];
|
|
107
|
+
for (next.nodes, 0..) |node, i| {
|
|
108
|
+
const bytes = input[24 + i * 48 ..][0..48];
|
|
109
|
+
const id = node.widget.id;
|
|
110
|
+
wide(bytes[0..8], id);
|
|
111
|
+
const prev = previous.findById(id);
|
|
112
|
+
const motion = findMotion(old, id);
|
|
113
|
+
const landing = view.canvas_widget_drag_landing_source_id == id;
|
|
114
|
+
word(bytes[8..12], @as(u32, @intFromBool(prev != null)) | (@as(u32, @intFromBool(node.widget.semantics.actions.drag)) << 1) | (@as(u32, @intFromBool(motion != null)) << 2) | (@as(u32, @intFromBool(landing)) << 3));
|
|
115
|
+
const before = if (prev) |p| p.frame.normalized() else geometry.RectF{};
|
|
116
|
+
const after = node.frame.normalized();
|
|
117
|
+
float(bytes[12..16], before.x);
|
|
118
|
+
float(bytes[16..20], before.y);
|
|
119
|
+
float(bytes[20..24], after.x);
|
|
120
|
+
float(bytes[24..28], after.y);
|
|
121
|
+
if (motion) |m| {
|
|
122
|
+
float(bytes[28..32], m.offset.dx);
|
|
123
|
+
float(bytes[32..36], m.offset.dy);
|
|
124
|
+
}
|
|
125
|
+
float(bytes[36..40], view.canvas_widget_drag_landing_origin.x);
|
|
126
|
+
float(bytes[40..44], view.canvas_widget_drag_landing_origin.y);
|
|
127
|
+
}
|
|
128
|
+
var out: [8 + limits.max_canvas_widget_drag_layout_motions_per_view * 16]u8 = undefined;
|
|
129
|
+
run(policy, input, &out);
|
|
130
|
+
plan.apply = out[0] == 1;
|
|
131
|
+
plan.motion_count = readWord(out[4..8]);
|
|
132
|
+
if (out[0] > 1 or plan.motion_count > plan.motions.len or !std.mem.eql(u8, out[1..4], &.{ 0, 0, 0 })) @panic("invalid compiled drag motion plan");
|
|
133
|
+
for (plan.motions[0..plan.motion_count], 0..) |*motion, i| {
|
|
134
|
+
const bytes = out[8 + i * 16 ..][0..16];
|
|
135
|
+
const index = readWord(bytes[0..4]);
|
|
136
|
+
if (index >= next.nodes.len or readWord(bytes[4..8]) > 1) @panic("invalid compiled drag motion index");
|
|
137
|
+
const id = next.nodes[index].widget.id;
|
|
138
|
+
if (readWord(bytes[4..8]) == 1) {
|
|
139
|
+
motion.* = findMotion(old, id) orelse @panic("compiled motion lost retained owner");
|
|
140
|
+
} else {
|
|
141
|
+
const offset = geometry.OffsetF.init(readFloat(bytes[8..12]), readFloat(bytes[12..16]));
|
|
142
|
+
motion.* = .{ .id = id, .from_offset = offset, .offset = offset, .escape_ancestor_clips = view.canvas_widget_drag_landing_source_id == id, .duration_ms = duration, .easing = .emphasized, .spring = view.widget_tokens.motion.spring };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return plan;
|
|
146
|
+
}
|
|
147
|
+
fn findMotion(motions: []const canvas.WidgetLayoutMotion, id: u64) ?canvas.WidgetLayoutMotion {
|
|
148
|
+
for (motions) |motion| if (motion.id == id) return motion;
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
pub const Pose = struct { done: bool, a: f32, b: f32 };
|
|
152
|
+
pub fn pose(policy: Policy, mode: u8, progress: f32, a: f32, to_a: f32, b: f32, to_b: f32) Pose {
|
|
153
|
+
var input: [32]u8 = @splat(0);
|
|
154
|
+
input[0..4].* = .{ 18, 4, 0, mode };
|
|
155
|
+
const values = [_]f32{ progress, a, to_a, b, to_b };
|
|
156
|
+
for (values, 0..) |v, i| float(input[4 + i * 4 ..][0..4], v);
|
|
157
|
+
var out: [12]u8 = undefined;
|
|
158
|
+
run(policy, &input, &out);
|
|
159
|
+
if (out[0] > 1 or !std.mem.eql(u8, out[1..4], &.{ 0, 0, 0 })) @panic("invalid compiled motion pose");
|
|
160
|
+
return .{ .done = out[0] == 1, .a = readFloat(out[4..8]), .b = readFloat(out[8..12]) };
|
|
161
|
+
}
|
|
162
|
+
pub fn clock(policy: Policy, start: u64, timestamp: u64) u64 {
|
|
163
|
+
var input: [24]u8 = @splat(0);
|
|
164
|
+
input[0..2].* = .{ 18, 5 };
|
|
165
|
+
wide(input[8..16], start);
|
|
166
|
+
wide(input[16..24], timestamp);
|
|
167
|
+
var out: [8]u8 = undefined;
|
|
168
|
+
run(policy, &input, &out);
|
|
169
|
+
return readWide(&out);
|
|
170
|
+
}
|
|
171
|
+
pub const Caret = struct { remove: bool, arm: bool, id: u64, start: u64 };
|
|
172
|
+
pub fn caret(policy: Policy, flags: u8, previous: u64, desired: u64, start: u64) Caret {
|
|
173
|
+
var input: [40]u8 = @splat(0);
|
|
174
|
+
input[0..3].* = .{ 18, 6, flags };
|
|
175
|
+
wide(input[8..16], previous);
|
|
176
|
+
wide(input[16..24], desired);
|
|
177
|
+
wide(input[24..32], start);
|
|
178
|
+
var out: [24]u8 = undefined;
|
|
179
|
+
run(policy, &input, &out);
|
|
180
|
+
if (out[0] > 1 or out[1] > 1 or !std.mem.eql(u8, out[2..8], &.{ 0, 0, 0, 0, 0, 0 })) @panic("invalid compiled caret plan");
|
|
181
|
+
return .{ .remove = out[0] == 1, .arm = out[1] == 1, .id = readWide(out[8..16]), .start = readWide(out[16..24]) };
|
|
182
|
+
}
|
|
183
|
+
pub const Loop = struct { arm: bool, start: u64, duration: u32, easing: canvas.Easing, loop: canvas.CanvasRenderAnimationLoop, from: f32, to: f32 };
|
|
184
|
+
pub fn loop(policy: Policy, mode: u8, flags: u8, period: u32, count: usize, segment: usize, capacity: usize, tail: f32, existing: u64, start: u64, easing: canvas.Easing) Loop {
|
|
185
|
+
var input: [48]u8 = @splat(0);
|
|
186
|
+
input[0..4].* = .{ 18, 7, flags, mode };
|
|
187
|
+
word(input[4..8], period);
|
|
188
|
+
word(input[8..12], @intCast(count));
|
|
189
|
+
word(input[12..16], @intCast(segment));
|
|
190
|
+
word(input[16..20], @intCast(capacity));
|
|
191
|
+
float(input[20..24], tail);
|
|
192
|
+
wide(input[24..32], existing);
|
|
193
|
+
wide(input[32..40], start);
|
|
194
|
+
input[40] = @intCast(@intFromEnum(easing));
|
|
195
|
+
var out: [32]u8 = undefined;
|
|
196
|
+
run(policy, &input, &out);
|
|
197
|
+
if (out[0] > 1 or out[1] > 3 or out[2] > 2 or out[3] != 0 or !std.mem.eql(u8, out[24..32], &.{ 0, 0, 0, 0, 0, 0, 0, 0 })) @panic("invalid compiled loop plan");
|
|
198
|
+
return .{ .arm = out[0] == 1, .start = readWide(out[8..16]), .duration = readWord(out[4..8]), .easing = @enumFromInt(out[1]), .loop = @enumFromInt(out[2]), .from = readFloat(out[16..20]), .to = readFloat(out[20..24]) };
|
|
199
|
+
}
|
|
200
|
+
fn run(policy: Policy, input: []const u8, out: []u8) void {
|
|
201
|
+
if (policy(input, out) != out.len) @panic("invalid compiled widget motion result length");
|
|
202
|
+
}
|
|
203
|
+
pub fn retireLoops(policy: Policy, previous: []const u64, desired: []const u64, removed: []u64) []const u64 {
|
|
204
|
+
var input: [16 + limits.max_canvas_widget_loop_animations_per_view * 16]u8 = @splat(0);
|
|
205
|
+
input[0..2].* = .{ 18, 8 };
|
|
206
|
+
word(input[4..8], @intCast(previous.len));
|
|
207
|
+
word(input[8..12], @intCast(desired.len));
|
|
208
|
+
for (previous, 0..) |id, i| wide(input[16 + i * 8 ..][0..8], id);
|
|
209
|
+
for (desired, 0..) |id, i| wide(input[16 + (previous.len + i) * 8 ..][0..8], id);
|
|
210
|
+
var out: [4 + limits.max_canvas_widget_loop_animations_per_view * 4]u8 = undefined;
|
|
211
|
+
run(policy, input[0 .. 16 + (previous.len + desired.len) * 8], out[0 .. 4 + previous.len * 4]);
|
|
212
|
+
const count = readWord(out[0..4]);
|
|
213
|
+
if (count > previous.len or count > removed.len) @panic("invalid compiled loop retirement count");
|
|
214
|
+
for (removed[0..count], 0..) |*id, i| {
|
|
215
|
+
const index = readWord(out[4 + i * 4 ..][0..4]);
|
|
216
|
+
if (index >= previous.len) @panic("invalid compiled loop retirement index");
|
|
217
|
+
id.* = previous[index];
|
|
218
|
+
}
|
|
219
|
+
return removed[0..count];
|
|
220
|
+
}
|
|
221
|
+
fn word(bytes: []u8, v: u32) void {
|
|
222
|
+
std.mem.writeInt(u32, bytes[0..4], v, .little);
|
|
223
|
+
}
|
|
224
|
+
fn wide(bytes: []u8, v: u64) void {
|
|
225
|
+
std.mem.writeInt(u64, bytes[0..8], v, .little);
|
|
226
|
+
}
|
|
227
|
+
fn float(bytes: []u8, v: f32) void {
|
|
228
|
+
word(bytes, @bitCast(v));
|
|
229
|
+
}
|
|
230
|
+
fn readWord(bytes: []const u8) u32 {
|
|
231
|
+
return std.mem.readInt(u32, bytes[0..4], .little);
|
|
232
|
+
}
|
|
233
|
+
fn readWide(bytes: []const u8) u64 {
|
|
234
|
+
return std.mem.readInt(u64, bytes[0..8], .little);
|
|
235
|
+
}
|
|
236
|
+
fn readFloat(bytes: []const u8) f32 {
|
|
237
|
+
return @bitCast(readWord(bytes));
|
|
238
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//! Rebuild decisions over copied facts. Exact keyed storage lookups, byte
|
|
2
|
+
//! equality and fingerprinting stay native; the compiled planner owns admission
|
|
3
|
+
//! and restoration. Every result is copied before another callback can run.
|
|
4
|
+
const std = @import("std");
|
|
5
|
+
const canvas = @import("canvas");
|
|
6
|
+
const limits = @import("canvas_limits.zig");
|
|
7
|
+
pub const Policy = ?*const fn ([]const u8, []u8) usize;
|
|
8
|
+
pub const Action = struct { flags: u32, value: f32 };
|
|
9
|
+
pub const Plan = struct { entries: [limits.max_canvas_widget_nodes_per_view]Action = undefined };
|
|
10
|
+
|
|
11
|
+
pub fn build(policy: Policy, layout: canvas.WidgetLayoutTree, controls: anytype, sources: anytype, texts: anytype, comptime hidden: anytype, comptime fingerprint: anytype, comptime minimumWidth: anytype) ?Plan {
|
|
12
|
+
const callback = policy orelse return null;
|
|
13
|
+
if (layout.nodes.len > limits.max_canvas_widget_nodes_per_view) @panic("widget reconcile exceeds view budget");
|
|
14
|
+
var input: [8 + limits.max_canvas_widget_nodes_per_view * 64]u8 = undefined;
|
|
15
|
+
const bytes = input[0 .. 8 + layout.nodes.len * 64];
|
|
16
|
+
@memset(bytes, 0);
|
|
17
|
+
bytes[0] = 93;
|
|
18
|
+
std.mem.writeInt(u32, bytes[4..8], @intCast(layout.nodes.len), .little);
|
|
19
|
+
for (layout.nodes, 0..) |node, i| {
|
|
20
|
+
const w = node.widget;
|
|
21
|
+
const fact = bytes[8 + i * 64 ..][0..64];
|
|
22
|
+
const control = controls.firstWithKind(w.id, w.kind);
|
|
23
|
+
const source = sources.firstWithKind(w.id, w.kind);
|
|
24
|
+
const text = texts.firstWithKind(w.id, w.kind);
|
|
25
|
+
fact[0] = @intCast(canvas.widgetKindCode(w.kind));
|
|
26
|
+
fact[1] = bit(w.id != 0, 0) | bit(w.state.disabled, 1) | bit(hidden(layout, i), 2) |
|
|
27
|
+
bit(control != null, 3) | bit(source != null, 4) | bit(text != null, 5) |
|
|
28
|
+
bit(w.runtime_flags.code_editor, 6) | bit(w.hasCodeDiff(), 7);
|
|
29
|
+
fact[2] = bit(w.state.selected or w.value >= 0.5, 0) |
|
|
30
|
+
bit(if (source) |entry| entry.selected else false, 1) |
|
|
31
|
+
bit(if (control) |entry| entry.state.selected or entry.value >= 0.5 else false, 2) |
|
|
32
|
+
bit(if (control) |entry| entry.state.pressed else false, 3);
|
|
33
|
+
float(fact[4..8], w.value);
|
|
34
|
+
float(fact[8..12], if (source) |entry| entry.value else 0);
|
|
35
|
+
float(fact[12..16], if (control) |entry| entry.value else 0);
|
|
36
|
+
float(fact[16..20], minimumWidth(w));
|
|
37
|
+
fact[20] = bit(w.text_selection != null, 0) | bit(w.text_composition != null, 1) |
|
|
38
|
+
bit(if (w.text_selection) |selection| selection.affinity == .downstream else false, 2);
|
|
39
|
+
if (w.text_selection) |selection| {
|
|
40
|
+
wide(fact[24..32], selection.anchor);
|
|
41
|
+
wide(fact[32..40], selection.focus);
|
|
42
|
+
}
|
|
43
|
+
if (text) |entry| {
|
|
44
|
+
const source_text = fingerprint(w.text);
|
|
45
|
+
fact[2] |= bit(std.mem.eql(u8, w.text, entry.text), 4) | bit(w.static_text_group_id == entry.static_text_group_id, 5) |
|
|
46
|
+
bit(source_text.len == entry.source_text_len and source_text.hash == entry.source_text_hash, 6);
|
|
47
|
+
fact[20] |= bit(entry.text_selection != null, 3) |
|
|
48
|
+
bit(if (entry.text_selection) |selection| selection.affinity == .downstream else false, 4) |
|
|
49
|
+
bit(entry.source_text_selection != null, 5) |
|
|
50
|
+
bit(if (entry.source_text_selection) |selection| selection.affinity == .downstream else false, 6);
|
|
51
|
+
if (entry.text_selection) |selection| {
|
|
52
|
+
wide(fact[40..48], selection.anchor);
|
|
53
|
+
wide(fact[48..56], selection.focus);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
var output: [8 + limits.max_canvas_widget_nodes_per_view * 8]u8 = undefined;
|
|
58
|
+
const size = callback(bytes, &output);
|
|
59
|
+
if (size != 8 + layout.nodes.len * 8 or output[0] != 93 or output[1] != 0 or output[2] != 0 or output[3] != 0 or
|
|
60
|
+
std.mem.readInt(u32, output[4..8], .little) != layout.nodes.len) @panic("invalid compiled widget reconcile header");
|
|
61
|
+
var plan = Plan{};
|
|
62
|
+
for (plan.entries[0..layout.nodes.len], 0..) |*action, i| {
|
|
63
|
+
const at = 8 + i * 8;
|
|
64
|
+
const flags = std.mem.readInt(u32, output[at..][0..4], .little);
|
|
65
|
+
if (flags > 2047 or (flags & 2 != 0 and flags & 1 == 0) or (flags & (16 | 128 | 256 | 512) != 0 and flags & 32 == 0) or
|
|
66
|
+
(flags & 512 != 0 and flags & 256 == 0) or (flags & (1 | 4 | 8) != 0 and controls.firstWithKind(layout.nodes[i].widget.id, layout.nodes[i].widget.kind) == null) or
|
|
67
|
+
(flags & (16 | 32 | 64 | 128 | 256 | 512) != 0 and texts.firstWithKind(layout.nodes[i].widget.id, layout.nodes[i].widget.kind) == null))
|
|
68
|
+
@panic("invalid compiled widget reconcile action");
|
|
69
|
+
action.* = .{ .flags = flags, .value = @bitCast(std.mem.readInt(u32, output[at + 4 ..][0..4], .little)) };
|
|
70
|
+
}
|
|
71
|
+
return plan;
|
|
72
|
+
}
|
|
73
|
+
fn bit(value: bool, shift: u3) u8 {
|
|
74
|
+
return @as(u8, @intFromBool(value)) << shift;
|
|
75
|
+
}
|
|
76
|
+
fn float(bytes: *[4]u8, value: f32) void {
|
|
77
|
+
std.mem.writeInt(u32, bytes, @bitCast(value), .little);
|
|
78
|
+
}
|
|
79
|
+
fn wide(bytes: *[8]u8, value: usize) void {
|
|
80
|
+
std.mem.writeInt(u64, bytes, @intCast(value), .little);
|
|
81
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//! Rebuild collection plans over copied facts. Returned ordinals select native
|
|
2
|
+
//! records; text, hashes, selections and code-cache identities never transfer
|
|
3
|
+
//! ownership. Native reference collectors remain independent when absent.
|
|
4
|
+
const std = @import("std");
|
|
5
|
+
const canvas = @import("canvas");
|
|
6
|
+
const limits = @import("canvas_limits.zig");
|
|
7
|
+
pub const Policy = ?*const fn ([]const u8, []u8) usize;
|
|
8
|
+
pub const Operation = enum(u8) { source_scroll, source_control, control, scroll, source_text, text, autofocus };
|
|
9
|
+
pub const Selection = struct { node: usize, source: ?usize, selected: bool, resizable: bool, code_diff: bool };
|
|
10
|
+
pub const Plan = struct {
|
|
11
|
+
entries: [limits.max_canvas_widget_nodes_per_view]Selection = undefined,
|
|
12
|
+
count: usize = 0,
|
|
13
|
+
target: ?usize = null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
pub fn collect(policy: Policy, operation: Operation, nodes: []const canvas.WidgetLayoutNode, sources: anytype, capacity: usize, states: usize) ?Plan {
|
|
17
|
+
const callback = policy orelse return null;
|
|
18
|
+
if (nodes.len > limits.max_canvas_widget_nodes_per_view or sources.len > limits.max_canvas_widget_nodes_per_view or capacity > limits.max_canvas_widget_nodes_per_view or states > limits.max_canvas_widget_nodes_per_view)
|
|
19
|
+
@panic("widget retention table exceeds view budget");
|
|
20
|
+
var input: [24 + limits.max_canvas_widget_nodes_per_view * 32]u8 = undefined;
|
|
21
|
+
const bytes = input[0 .. 24 + (nodes.len + sources.len) * 16];
|
|
22
|
+
@memset(bytes, 0);
|
|
23
|
+
bytes[0] = 92;
|
|
24
|
+
bytes[1] = @intFromEnum(operation);
|
|
25
|
+
word(bytes[4..8], nodes.len);
|
|
26
|
+
word(bytes[8..12], sources.len);
|
|
27
|
+
word(bytes[12..16], capacity);
|
|
28
|
+
word(bytes[16..20], states);
|
|
29
|
+
for (nodes, 0..) |node, i| {
|
|
30
|
+
const fact = bytes[24 + i * 16 ..][0..16];
|
|
31
|
+
wide(fact[0..8], node.widget.id);
|
|
32
|
+
fact[8] = @intCast(canvas.widgetKindCode(node.widget.kind));
|
|
33
|
+
const selection = node.widget.text_selection;
|
|
34
|
+
fact[9] = @as(u8, @intFromBool(node.widget.autofocus)) |
|
|
35
|
+
(@as(u8, @intFromBool(selection != null)) << 1) |
|
|
36
|
+
(@as(u8, @intFromBool(if (selection) |value| !value.isCollapsed(node.widget.text.len) else false)) << 2) |
|
|
37
|
+
(@as(u8, @intFromBool(node.widget.hasCodeDiff())) << 3) |
|
|
38
|
+
(@as(u8, @intFromBool(node.widget.state.selected)) << 4);
|
|
39
|
+
std.mem.writeInt(u32, fact[12..16], @bitCast(node.widget.value), .little);
|
|
40
|
+
}
|
|
41
|
+
for (sources, 0..) |source, i| {
|
|
42
|
+
const fact = bytes[24 + (nodes.len + i) * 16 ..][0..16];
|
|
43
|
+
wide(fact[0..8], source.id);
|
|
44
|
+
fact[8] = if (comptime @hasField(@TypeOf(source), "kind")) @intCast(canvas.widgetKindCode(source.kind)) else 0;
|
|
45
|
+
}
|
|
46
|
+
var output: [16 + limits.max_canvas_widget_nodes_per_view * 12]u8 = undefined;
|
|
47
|
+
const size = callback(bytes, &output);
|
|
48
|
+
if (size < 16 or size > output.len or output[0] != 92 or output[1] != @intFromEnum(operation) or output[2] != 0 or output[3] != 0 or read(output[12..16]) != 0)
|
|
49
|
+
@panic("invalid compiled widget retention header");
|
|
50
|
+
var plan = Plan{};
|
|
51
|
+
plan.count = read(output[4..8]);
|
|
52
|
+
const target = read(output[8..12]);
|
|
53
|
+
if (plan.count > capacity or size != 16 + plan.count * 12 or (target != std.math.maxInt(u32) and (operation != .autofocus or target >= nodes.len)))
|
|
54
|
+
@panic("invalid compiled widget retention counts");
|
|
55
|
+
plan.target = if (target == std.math.maxInt(u32)) null else target;
|
|
56
|
+
for (plan.entries[0..plan.count], 0..) |*entry, i| {
|
|
57
|
+
const at = 16 + i * 12;
|
|
58
|
+
const index = read(output[at..][0..4]);
|
|
59
|
+
const source = read(output[at + 4 ..][0..4]);
|
|
60
|
+
const flags = read(output[at + 8 ..][0..4]);
|
|
61
|
+
if (index >= nodes.len or (i > 0 and index <= plan.entries[i - 1].node) or (source != std.math.maxInt(u32) and source >= sources.len) or flags > 7)
|
|
62
|
+
@panic("invalid compiled widget retention entry");
|
|
63
|
+
entry.* = .{ .node = index, .source = if (source == std.math.maxInt(u32)) null else source, .selected = flags & 1 != 0, .resizable = flags & 2 != 0, .code_diff = flags & 4 != 0 };
|
|
64
|
+
}
|
|
65
|
+
return plan;
|
|
66
|
+
}
|
|
67
|
+
fn word(bytes: *[4]u8, value: usize) void {
|
|
68
|
+
std.mem.writeInt(u32, bytes, @intCast(value), .little);
|
|
69
|
+
}
|
|
70
|
+
fn wide(bytes: *[8]u8, value: u64) void {
|
|
71
|
+
std.mem.writeInt(u64, bytes, value, .little);
|
|
72
|
+
}
|
|
73
|
+
fn read(bytes: *const [4]u8) usize {
|
|
74
|
+
return std.mem.readInt(u32, bytes, .little);
|
|
75
|
+
}
|
|
@@ -680,3 +680,66 @@ test "runtime handles built-in JavaScript platform support commands" {
|
|
|
680
680
|
try std.testing.expect(std.mem.indexOf(u8, chromium_platform.lastBridgeResponse(), "\"invalid_request\"") != null);
|
|
681
681
|
try std.testing.expect(std.mem.indexOf(u8, chromium_platform.lastBridgeResponse(), "Platform feature is invalid") != null);
|
|
682
682
|
}
|
|
683
|
+
|
|
684
|
+
test "reusing a closed window slot preserves every shifted window's owned fields" {
|
|
685
|
+
const TestApp = struct {
|
|
686
|
+
fn app(self: *@This()) App {
|
|
687
|
+
return .{ .context = self, .name = "window-storage", .source = platform.WebViewSource.html("<p>Main</p>") };
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
691
|
+
defer harness.destroy(std.testing.allocator);
|
|
692
|
+
var app_state: TestApp = .{};
|
|
693
|
+
try harness.start(app_state.app());
|
|
694
|
+
const old = try harness.runtime.createWindow(.{ .label = "old", .title = "Old" });
|
|
695
|
+
const assets = try harness.runtime.createWindow(.{
|
|
696
|
+
.label = "assets-window",
|
|
697
|
+
.title = "Asset window title",
|
|
698
|
+
.source = platform.WebViewSource.assets(.{ .root_path = "assets/root", .entry = "page.html", .origin = "zero://panels", .spa_fallback = false }),
|
|
699
|
+
});
|
|
700
|
+
const html = try harness.runtime.createWindow(.{ .label = "html-window", .title = "HTML window title", .source = platform.WebViewSource.html("<p>Surviving HTML</p>") });
|
|
701
|
+
try harness.runtime.createShellViews(old.id, &.{.{ .label = "old-view", .kind = .toolbar }}, geometry.RectF.init(0, 0, 400, 300));
|
|
702
|
+
try harness.runtime.createShellViews(assets.id, &.{
|
|
703
|
+
.{ .label = "asset-parent", .kind = .toolbar },
|
|
704
|
+
.{ .label = "asset-child", .kind = .button, .parent = "asset-parent" },
|
|
705
|
+
}, geometry.RectF.init(0, 0, 400, 300));
|
|
706
|
+
try harness.runtime.createShellViews(html.id, &.{.{ .label = "html-view", .kind = .toolbar }}, geometry.RectF.init(0, 0, 400, 300));
|
|
707
|
+
const parent = "owned-parent";
|
|
708
|
+
@memcpy(harness.runtime.windows[2].main_parent_storage[0..parent.len], parent);
|
|
709
|
+
harness.runtime.windows[2].main_parent = harness.runtime.windows[2].main_parent_storage[0..parent.len];
|
|
710
|
+
try harness.runtime.closeWindow(old.id);
|
|
711
|
+
const replacement = try harness.runtime.createWindow(.{ .label = "old", .title = "Replacement title", .source = platform.WebViewSource.html("replacement bytes") });
|
|
712
|
+
try harness.runtime.createShellViews(replacement.id, &.{.{ .label = "replacement-view", .kind = .toolbar }}, geometry.RectF.init(0, 0, 400, 300));
|
|
713
|
+
const shifted_assets = &harness.runtime.windows[1];
|
|
714
|
+
const shifted_html = &harness.runtime.windows[2];
|
|
715
|
+
try std.testing.expectEqual(assets.id, shifted_assets.info.id);
|
|
716
|
+
try std.testing.expectEqual(html.id, shifted_html.info.id);
|
|
717
|
+
try std.testing.expectEqualStrings("assets-window", shifted_assets.info.label);
|
|
718
|
+
try std.testing.expectEqualStrings("Asset window title", shifted_assets.info.title);
|
|
719
|
+
try std.testing.expectEqualStrings(parent, shifted_assets.main_parent.?);
|
|
720
|
+
const source = shifted_assets.source.?;
|
|
721
|
+
try std.testing.expectEqualStrings("zero://panels", source.bytes);
|
|
722
|
+
try std.testing.expectEqualStrings("assets/root", source.asset_options.?.root_path);
|
|
723
|
+
try std.testing.expectEqualStrings("page.html", source.asset_options.?.entry);
|
|
724
|
+
try std.testing.expectEqualStrings("zero://panels", source.asset_options.?.origin);
|
|
725
|
+
try std.testing.expect(!source.asset_options.?.spa_fallback);
|
|
726
|
+
try std.testing.expectEqualStrings("html-window", shifted_html.info.label);
|
|
727
|
+
try std.testing.expectEqualStrings("HTML window title", shifted_html.info.title);
|
|
728
|
+
try std.testing.expectEqualStrings("<p>Surviving HTML</p>", shifted_html.source.?.bytes);
|
|
729
|
+
try std.testing.expectEqual(@intFromPtr(&shifted_assets.label_storage), @intFromPtr(shifted_assets.info.label.ptr));
|
|
730
|
+
try std.testing.expectEqual(@intFromPtr(&shifted_assets.source_storage.asset_entry), @intFromPtr(source.asset_options.?.entry.ptr));
|
|
731
|
+
try std.testing.expectEqual(@intFromPtr(&shifted_html.source_storage.bytes), @intFromPtr(shifted_html.source.?.bytes.ptr));
|
|
732
|
+
try std.testing.expectEqualStrings("assets-window", harness.null_platform.windows[1].label);
|
|
733
|
+
try std.testing.expectEqualStrings("Asset window title", harness.null_platform.windows[1].title);
|
|
734
|
+
try std.testing.expectEqualStrings("html-window", harness.null_platform.windows[2].label);
|
|
735
|
+
try std.testing.expectEqualStrings("HTML window title", harness.null_platform.windows[2].title);
|
|
736
|
+
const layout = &harness.runtime.shell_layouts[0];
|
|
737
|
+
try std.testing.expectEqual(assets.id, layout.window_id);
|
|
738
|
+
try std.testing.expectEqualStrings("asset-parent", layout.views[0].label);
|
|
739
|
+
try std.testing.expectEqualStrings("asset-child", layout.views[1].label);
|
|
740
|
+
try std.testing.expectEqualStrings("asset-parent", layout.views[1].parent.?);
|
|
741
|
+
try std.testing.expectEqual(@intFromPtr(&layout.label_storage[1]), @intFromPtr(layout.views[1].label.ptr));
|
|
742
|
+
try std.testing.expectEqual(@intFromPtr(&layout.parent_storage[1]), @intFromPtr(layout.views[1].parent.?.ptr));
|
|
743
|
+
try std.testing.expectEqual(html.id, harness.runtime.shell_layouts[1].window_id);
|
|
744
|
+
try std.testing.expectEqualStrings("html-view", harness.runtime.shell_layouts[1].views[0].label);
|
|
745
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//! Raw copied window observations; storage and OS capabilities stay native.
|
|
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) { begin, finish, focus, keyboard, host, replay, focused_index };
|
|
7
|
+
pub const Verb = enum(u8) { close, hide, show, focus, minimize };
|
|
8
|
+
pub const Outcome = enum(u32) { success, failed, window_not_found };
|
|
9
|
+
pub const Options = struct {
|
|
10
|
+
id: u64 = 0,
|
|
11
|
+
value: bool = false,
|
|
12
|
+
app_active: ?bool = null,
|
|
13
|
+
cursor: usize = 0,
|
|
14
|
+
target: usize = 0,
|
|
15
|
+
saved: u32 = 0,
|
|
16
|
+
outcome: Outcome = .success,
|
|
17
|
+
label: []const u8 = "",
|
|
18
|
+
frame: geometry.RectF = .zero(),
|
|
19
|
+
variant: u8 = 0,
|
|
20
|
+
};
|
|
21
|
+
pub const Program = struct {
|
|
22
|
+
status: u32,
|
|
23
|
+
selected: ?usize,
|
|
24
|
+
decisions: u32,
|
|
25
|
+
mask: u32,
|
|
26
|
+
flags: u32,
|
|
27
|
+
active: bool,
|
|
28
|
+
frame: geometry.RectF,
|
|
29
|
+
pub fn has(self: Program, bit: u32) bool {
|
|
30
|
+
return self.decisions & bit != 0;
|
|
31
|
+
}
|
|
32
|
+
pub fn admitted(self: Program) !void {
|
|
33
|
+
if (self.status != 0) return error.WindowNotFound;
|
|
34
|
+
}
|
|
35
|
+
pub fn apply(self: Program, info: *platform.WindowInfo) void {
|
|
36
|
+
if (self.mask & 1 != 0) info.open = self.flags & 1 != 0;
|
|
37
|
+
if (self.mask & 2 != 0) info.focused = self.flags & 2 != 0;
|
|
38
|
+
if (self.mask & 4 != 0) info.hidden = self.flags & 4 != 0;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
pub fn flags(info: platform.WindowInfo) u32 {
|
|
42
|
+
return @as(u32, @intFromBool(info.open)) | (@as(u32, @intFromBool(info.focused)) << 1) | (@as(u32, @intFromBool(info.hidden)) << 2);
|
|
43
|
+
}
|
|
44
|
+
fn put(bytes: []u8, at: usize, value: u32) void {
|
|
45
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
46
|
+
}
|
|
47
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
48
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
49
|
+
}
|
|
50
|
+
pub fn plan(policy: Policy, runtime: anytype, mode: Mode, options: Options) Program {
|
|
51
|
+
if (platform.max_windows != 16 or platform.max_views != 32 or platform.max_window_label_bytes != 64 or runtime.window_count > 16 or runtime.view_count > 32) @panic("window lifecycle observation capacity");
|
|
52
|
+
var request: [128 + 16 * 128 + 32 * 16]u8 = @splat(0);
|
|
53
|
+
request[0..4].* = .{ 81, 1, @intFromEnum(mode), options.variant };
|
|
54
|
+
put(&request, 4, @intCast(runtime.window_count));
|
|
55
|
+
put(&request, 8, @intCast(runtime.view_count));
|
|
56
|
+
put(&request, 12, @intFromBool(options.value));
|
|
57
|
+
std.mem.writeInt(u64, request[16..24], options.id, .little);
|
|
58
|
+
put(&request, 24, std.math.cast(u32, options.cursor) orelse std.math.maxInt(u32));
|
|
59
|
+
put(&request, 28, std.math.cast(u32, options.target) orelse std.math.maxInt(u32));
|
|
60
|
+
// Oversized lookup labels cannot match a stored label; preserve that miss
|
|
61
|
+
// without borrowing or truncating them into an existing window identity.
|
|
62
|
+
const label_length = @min(options.label.len, 65);
|
|
63
|
+
put(&request, 32, options.saved);
|
|
64
|
+
put(&request, 36, @intFromEnum(options.outcome));
|
|
65
|
+
put(&request, 40, @intCast(label_length));
|
|
66
|
+
put(&request, 44, @intFromBool(options.app_active orelse runtime.app_active));
|
|
67
|
+
for ([_]f32{ options.frame.x, options.frame.y, options.frame.width, options.frame.height }, 0..) |value, i| put(&request, 48 + i * 4, @bitCast(value));
|
|
68
|
+
if (label_length <= 64) @memcpy(request[64..][0..label_length], options.label);
|
|
69
|
+
for (runtime.windows[0..runtime.window_count], 0..) |*window, i| {
|
|
70
|
+
const at = 128 + i * 128;
|
|
71
|
+
if (window.info.label.len > 64) @panic("window lifecycle label capacity");
|
|
72
|
+
std.mem.writeInt(u64, request[at..][0..8], window.info.id, .little);
|
|
73
|
+
put(&request, at + 8, flags(window.info) | (@as(u32, @intFromBool(window.activate_on_show)) << 3) | (@as(u32, @intFromBool(window.main_frame_set)) << 4));
|
|
74
|
+
put(&request, at + 12, @intCast(window.info.label.len));
|
|
75
|
+
@memcpy(request[at + 64 ..][0..window.info.label.len], window.info.label);
|
|
76
|
+
}
|
|
77
|
+
var at = 128 + runtime.window_count * 128;
|
|
78
|
+
for (runtime.views[0..runtime.view_count]) |*view| {
|
|
79
|
+
std.mem.writeInt(u64, request[at..][0..8], view.window_id, .little);
|
|
80
|
+
put(&request, at + 8, @intFromBool(view.keyboard_active));
|
|
81
|
+
at += 16;
|
|
82
|
+
}
|
|
83
|
+
var output: [64]u8 = @splat(0xa5);
|
|
84
|
+
const length = policy(request[0..at], &output);
|
|
85
|
+
if (length != output.len or word(&output, 0) != 1 or word(&output, 4) != @intFromEnum(mode) or word(&output, 8) > 1 or word(&output, 20) > 7 or word(&output, 24) & ~word(&output, 20) != 0 or word(&output, 28) > 1) @panic("invalid compiled window lifecycle shape");
|
|
86
|
+
for (output[48..]) |byte| if (byte != 0) @panic("invalid compiled window lifecycle reserved bytes");
|
|
87
|
+
const selected = word(&output, 12);
|
|
88
|
+
if (selected != std.math.maxInt(u32) and selected >= runtime.window_count) @panic("invalid compiled window lifecycle selection");
|
|
89
|
+
const decisions = word(&output, 16);
|
|
90
|
+
const allowed: u32 = switch (mode) {
|
|
91
|
+
.begin => 16,
|
|
92
|
+
.finish => 15,
|
|
93
|
+
.focus => 32,
|
|
94
|
+
.keyboard => 1,
|
|
95
|
+
.host => 148,
|
|
96
|
+
.replay => 71,
|
|
97
|
+
.focused_index => 0,
|
|
98
|
+
};
|
|
99
|
+
if (decisions & ~allowed != 0 or (word(&output, 8) != 0 and mode != .begin) or (selected == std.math.maxInt(u32) and mode != .begin and mode != .keyboard and mode != .replay)) @panic("invalid compiled window lifecycle admission");
|
|
100
|
+
const mask = word(&output, 20);
|
|
101
|
+
const status = word(&output, 8);
|
|
102
|
+
const empty = selected == std.math.maxInt(u32);
|
|
103
|
+
const valid = switch (mode) {
|
|
104
|
+
.begin => if (status != 0) mask == 0 and decisions == 0 else !empty and mask == switch (options.variant) {
|
|
105
|
+
0 => @as(u32, 7),
|
|
106
|
+
1 => 6,
|
|
107
|
+
2 => 4,
|
|
108
|
+
else => 0,
|
|
109
|
+
} and (decisions == 0 or options.variant == 3),
|
|
110
|
+
.finish => selected == options.cursor and (if (decisions == 8) mask == switch (options.variant) {
|
|
111
|
+
0 => @as(u32, 7),
|
|
112
|
+
1 => 6,
|
|
113
|
+
2 => 4,
|
|
114
|
+
else => 0,
|
|
115
|
+
} else mask == 0 and (decisions == 2 or decisions == 3 or decisions == 6)),
|
|
116
|
+
.focus => selected == options.cursor and mask == 2,
|
|
117
|
+
.keyboard => empty and mask == 0,
|
|
118
|
+
.host => selected == options.cursor and mask == 5 and (decisions == 4 or decisions == 16 or decisions == 132 or decisions == 144),
|
|
119
|
+
.replay => if (decisions == 64) mask == 0 else !empty and ((decisions == 3 and mask == 7) or (decisions == 6 and mask == 4)),
|
|
120
|
+
.focused_index => selected == options.cursor and mask == 0,
|
|
121
|
+
};
|
|
122
|
+
if (!valid or ((mode != .keyboard and mode != .focused_index) and word(&output, 28) != 0)) @panic("invalid compiled window lifecycle program");
|
|
123
|
+
if (decisions & 128 == 0) {
|
|
124
|
+
for (output[32..48]) |byte| if (byte != 0) @panic("invalid compiled window lifecycle unused frame");
|
|
125
|
+
} else if (word(&output, 32) != 0 or word(&output, 36) != 0) @panic("invalid compiled window lifecycle content origin");
|
|
126
|
+
return .{ .status = word(&output, 8), .selected = if (selected == std.math.maxInt(u32)) null else selected, .decisions = decisions, .mask = word(&output, 20), .flags = word(&output, 24), .active = word(&output, 28) == 1, .frame = .init(@bitCast(word(&output, 32)), @bitCast(word(&output, 36)), @bitCast(word(&output, 40)), @bitCast(word(&output, 44))) };
|
|
127
|
+
}
|