@native-sdk/cli 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1818 -87
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +2 -1
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/codesign.zig +125 -74
- 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/package.zig +85 -1
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
//! Native numeric conversion and borrowed-buffer transport for automation.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const canvas = @import("canvas");
|
|
5
|
+
const platform = @import("../platform/root.zig");
|
|
6
|
+
const reference = @import("automation_commands.zig");
|
|
7
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
8
|
+
pub const AutomationNativeCommand = reference.AutomationNativeCommand;
|
|
9
|
+
pub const AutomationWidgetActionKind = reference.AutomationWidgetActionKind;
|
|
10
|
+
pub const AutomationWidgetAction = reference.AutomationWidgetAction;
|
|
11
|
+
pub const AutomationWidgetTarget = reference.AutomationWidgetTarget;
|
|
12
|
+
pub const AutomationProvenanceTarget = reference.AutomationProvenanceTarget;
|
|
13
|
+
pub const AutomationWidgetWheel = reference.AutomationWidgetWheel;
|
|
14
|
+
pub const AutomationWidgetContextMenuItem = reference.AutomationWidgetContextMenuItem;
|
|
15
|
+
pub const AutomationWidgetKey = reference.AutomationWidgetKey;
|
|
16
|
+
pub const AutomationWidgetPinch = reference.AutomationWidgetPinch;
|
|
17
|
+
pub const AutomationWidgetPointerDrag = reference.AutomationWidgetPointerDrag;
|
|
18
|
+
pub const AutomationResizeCommand = reference.AutomationResizeCommand;
|
|
19
|
+
pub const AutomationTrayTarget = reference.AutomationTrayTarget;
|
|
20
|
+
pub const AutomationScreenshotCommand = reference.AutomationScreenshotCommand;
|
|
21
|
+
|
|
22
|
+
const Program = struct {
|
|
23
|
+
bytes: []u8,
|
|
24
|
+
input: []const u8,
|
|
25
|
+
fn deinit(self: Program) void {
|
|
26
|
+
std.heap.page_allocator.free(self.bytes);
|
|
27
|
+
}
|
|
28
|
+
fn word(self: Program, at: usize) u32 {
|
|
29
|
+
return std.mem.readInt(u32, self.bytes[at..][0..4], .little);
|
|
30
|
+
}
|
|
31
|
+
fn entry(self: Program, index: usize) usize {
|
|
32
|
+
if (index >= self.word(20)) @panic("missing automation field");
|
|
33
|
+
return 24 + index * 24;
|
|
34
|
+
}
|
|
35
|
+
fn string(self: Program, index: usize) []const u8 {
|
|
36
|
+
const at = self.entry(index);
|
|
37
|
+
if (self.word(at) != 0) @panic("invalid automation string kind");
|
|
38
|
+
return self.input[self.word(at + 4)..][0..self.word(at + 8)];
|
|
39
|
+
}
|
|
40
|
+
fn integer(self: Program, index: usize, comptime T: type) T {
|
|
41
|
+
const at = self.entry(index);
|
|
42
|
+
if (self.word(at) == 0 or self.word(at) == 5 or self.word(at) == 6) @panic("invalid automation integer kind");
|
|
43
|
+
return std.math.cast(T, std.mem.readInt(u64, self.bytes[at + 16 ..][0..8], .little)) orelse @panic("invalid automation integer width");
|
|
44
|
+
}
|
|
45
|
+
fn float(self: Program, index: usize) f32 {
|
|
46
|
+
const at = self.entry(index);
|
|
47
|
+
if (self.word(at) != 5 and self.word(at) != 6) @panic("invalid automation float kind");
|
|
48
|
+
return @bitCast(self.word(at + 16));
|
|
49
|
+
}
|
|
50
|
+
fn validate(self: Program, len: usize, mode: u8, capacity: usize) void {
|
|
51
|
+
if (len < 24 or len > self.bytes.len) @panic("invalid automation program extent");
|
|
52
|
+
if (self.word(0) != 1 or self.word(4) != mode or self.word(8) > 2 or self.word(12) > 13 or self.word(16) > 31) @panic("invalid automation program header");
|
|
53
|
+
const count: usize = self.word(20);
|
|
54
|
+
if (count > (len - 24) / 24 or len != 24 + count * 24 or (mode == 14 and count > capacity)) @panic("invalid automation field count");
|
|
55
|
+
for (0..count) |i| {
|
|
56
|
+
const at = self.entry(i);
|
|
57
|
+
if (self.word(at) > 7 or self.word(at + 12) > 3) @panic("invalid automation conversion recipe");
|
|
58
|
+
const offset: usize = self.word(at + 4);
|
|
59
|
+
if (offset > self.input.len or self.word(at + 8) > self.input.len - offset) @panic("invalid automation borrowed span");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
fn parse(policy: Policy, mode: u8, input: []const u8, capacity: usize) !Program {
|
|
65
|
+
const allocator = std.heap.page_allocator;
|
|
66
|
+
if (input.len > std.math.maxInt(u32) or capacity > std.math.maxInt(u32)) return error.InvalidCommand;
|
|
67
|
+
const max_fields = @max(@as(usize, 6), input.len / 2 + 1);
|
|
68
|
+
var program = Program{ .bytes = try allocator.alloc(u8, 24 + max_fields * 24), .input = input };
|
|
69
|
+
errdefer program.deinit();
|
|
70
|
+
@memset(program.bytes, 0xa5);
|
|
71
|
+
var request: std.ArrayList(u8) = .empty;
|
|
72
|
+
defer request.deinit(allocator);
|
|
73
|
+
try request.appendSlice(allocator, &.{ 90, 1, mode, 0 });
|
|
74
|
+
var words: [12]u8 = @splat(0);
|
|
75
|
+
std.mem.writeInt(u32, words[0..4], @intCast(input.len), .little);
|
|
76
|
+
std.mem.writeInt(u32, words[4..8], @intCast(capacity), .little);
|
|
77
|
+
try request.appendSlice(allocator, &words);
|
|
78
|
+
try request.appendSlice(allocator, input);
|
|
79
|
+
var size = policy(request.items, program.bytes);
|
|
80
|
+
program.validate(size, mode, capacity);
|
|
81
|
+
if (program.word(8) == 0) {
|
|
82
|
+
if (mode == 14) return program;
|
|
83
|
+
return error.InvalidCommand;
|
|
84
|
+
}
|
|
85
|
+
if (program.word(8) != 1) @panic("automation conversion recipe expected");
|
|
86
|
+
const count: usize = program.word(20);
|
|
87
|
+
const facts = try request.addManyAsSlice(allocator, count * 12);
|
|
88
|
+
@memset(facts, 0);
|
|
89
|
+
for (0..count) |i| {
|
|
90
|
+
const at = program.entry(i);
|
|
91
|
+
const kind = program.word(at);
|
|
92
|
+
if (kind == 0 or kind >= 6) continue;
|
|
93
|
+
const token = input[program.word(at + 4)..][0..program.word(at + 8)];
|
|
94
|
+
const value: ?u64 = switch (kind) {
|
|
95
|
+
1 => std.fmt.parseInt(u64, token, 10) catch null,
|
|
96
|
+
2 => if (std.fmt.parseInt(u32, token, 10)) |v| v else |_| null,
|
|
97
|
+
3 => if (std.fmt.parseInt(usize, token, 10)) |v| v else |_| null,
|
|
98
|
+
4 => if (std.fmt.parseUnsigned(u32, token, 10)) |v| v else |_| null,
|
|
99
|
+
5 => if (std.fmt.parseFloat(f32, token)) |v| @as(u32, @bitCast(v)) else |_| null,
|
|
100
|
+
else => unreachable,
|
|
101
|
+
};
|
|
102
|
+
if (value) |v| {
|
|
103
|
+
std.mem.writeInt(u32, facts[i * 12 ..][0..4], 1, .little);
|
|
104
|
+
std.mem.writeInt(u64, facts[i * 12 + 4 ..][0..8], v, .little);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
request.items[3] = 1;
|
|
108
|
+
size = policy(request.items, program.bytes);
|
|
109
|
+
program.validate(size, mode, capacity);
|
|
110
|
+
if (program.word(8) == 0) return error.InvalidCommand;
|
|
111
|
+
if (program.word(8) != 2 or program.word(20) != count) @panic("automation admission expected");
|
|
112
|
+
return program;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
pub fn parseAutomationCommandName(policy: ?Policy, value: []const u8) ![]const u8 {
|
|
116
|
+
const compiled = policy orelse return reference.parseAutomationCommandName(value);
|
|
117
|
+
const p = try parse(compiled, 0, value, 0);
|
|
118
|
+
defer p.deinit();
|
|
119
|
+
return p.string(0);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
pub fn parseAutomationTrayItemId(policy: ?Policy, value: []const u8) !platform.TrayItemId {
|
|
123
|
+
const compiled = policy orelse return reference.parseAutomationTrayItemId(value);
|
|
124
|
+
const p = try parse(compiled, 1, value, 0);
|
|
125
|
+
defer p.deinit();
|
|
126
|
+
return p.integer(0, platform.TrayItemId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
pub fn parseAutomationTrayTarget(policy: ?Policy, value: []const u8) !AutomationTrayTarget {
|
|
130
|
+
const compiled = policy orelse return reference.parseAutomationTrayTarget(value);
|
|
131
|
+
const p = try parse(compiled, 2, value, 0);
|
|
132
|
+
defer p.deinit();
|
|
133
|
+
return .{ .status_item_id = p.integer(0, platform.StatusItemId), .item_id = p.integer(1, platform.TrayItemId) };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
pub fn parseAutomationViewLabel(policy: ?Policy, value: []const u8) ![]const u8 {
|
|
137
|
+
const compiled = policy orelse return reference.parseAutomationViewLabel(value);
|
|
138
|
+
const p = try parse(compiled, 3, value, 0);
|
|
139
|
+
defer p.deinit();
|
|
140
|
+
return p.string(0);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
pub fn parseAutomationNativeCommand(policy: ?Policy, value: []const u8) !AutomationNativeCommand {
|
|
144
|
+
const compiled = policy orelse return reference.parseAutomationNativeCommand(value);
|
|
145
|
+
const p = try parse(compiled, 4, value, 0);
|
|
146
|
+
defer p.deinit();
|
|
147
|
+
return .{ .name = p.string(0), .view_label = p.string(1) };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
pub fn parseAutomationWidgetAction(policy: ?Policy, value: []const u8) !AutomationWidgetAction {
|
|
151
|
+
const compiled = policy orelse return reference.parseAutomationWidgetAction(value);
|
|
152
|
+
const p = try parse(compiled, 5, value, 0);
|
|
153
|
+
defer p.deinit();
|
|
154
|
+
return .{ .view_label = p.string(0), .id = p.integer(1, canvas.ObjectId), .action = @enumFromInt(p.word(12)), .value = p.string(2) };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
pub fn parseAutomationWidgetTarget(policy: ?Policy, value: []const u8) !AutomationWidgetTarget {
|
|
158
|
+
const compiled = policy orelse return reference.parseAutomationWidgetTarget(value);
|
|
159
|
+
const p = try parse(compiled, 6, value, 0);
|
|
160
|
+
defer p.deinit();
|
|
161
|
+
return .{ .view_label = p.string(0), .id = p.integer(1, canvas.ObjectId) };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
pub fn parseAutomationProvenanceTarget(policy: ?Policy, value: []const u8) !AutomationProvenanceTarget {
|
|
165
|
+
const compiled = policy orelse return reference.parseAutomationProvenanceTarget(value);
|
|
166
|
+
const p = try parse(compiled, 7, value, 0);
|
|
167
|
+
defer p.deinit();
|
|
168
|
+
return if (p.word(12) == 1) .{ .view_label = p.string(0), .point = geometry.PointF.init(p.float(1), p.float(2)) } else .{ .view_label = p.string(0), .id = p.integer(1, canvas.ObjectId) };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
pub fn parseAutomationWidgetWheel(policy: ?Policy, value: []const u8) !AutomationWidgetWheel {
|
|
172
|
+
const compiled = policy orelse return reference.parseAutomationWidgetWheel(value);
|
|
173
|
+
const p = try parse(compiled, 8, value, 0);
|
|
174
|
+
defer p.deinit();
|
|
175
|
+
return .{ .target = .{ .view_label = p.string(0), .id = p.integer(1, canvas.ObjectId) }, .delta_y = p.float(2), .delta_x = p.float(3) };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
pub fn parseAutomationWidgetContextMenuItem(policy: ?Policy, value: []const u8) !AutomationWidgetContextMenuItem {
|
|
179
|
+
const compiled = policy orelse return reference.parseAutomationWidgetContextMenuItem(value);
|
|
180
|
+
const p = try parse(compiled, 9, value, 0);
|
|
181
|
+
defer p.deinit();
|
|
182
|
+
return .{ .target = .{ .view_label = p.string(0), .id = p.integer(1, canvas.ObjectId) }, .item_index = p.integer(2, usize) };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
pub fn parseAutomationWidgetKey(policy: ?Policy, value: []const u8) !AutomationWidgetKey {
|
|
186
|
+
const compiled = policy orelse return reference.parseAutomationWidgetKey(value);
|
|
187
|
+
const p = try parse(compiled, 10, value, 0);
|
|
188
|
+
defer p.deinit();
|
|
189
|
+
return .{ .view_label = p.string(0), .key = p.string(1), .text = p.string(2), .modifiers = .{ .shift = p.word(16) & 1 != 0, .control = p.word(16) & 2 != 0, .option = p.word(16) & 4 != 0, .command = p.word(16) & 8 != 0, .primary = p.word(16) & 16 != 0 } };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
pub fn parseAutomationWidgetPinch(policy: ?Policy, value: []const u8) !AutomationWidgetPinch {
|
|
193
|
+
const compiled = policy orelse return reference.parseAutomationWidgetPinch(value);
|
|
194
|
+
const p = try parse(compiled, 11, value, 0);
|
|
195
|
+
defer p.deinit();
|
|
196
|
+
return .{ .view_label = p.string(0), .scale = p.float(1), .point = if (p.word(12) == 1) geometry.PointF.init(p.float(2), p.float(3)) else null };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
pub fn parseAutomationWidgetPointerDrag(policy: ?Policy, value: []const u8) !AutomationWidgetPointerDrag {
|
|
200
|
+
const compiled = policy orelse return reference.parseAutomationWidgetPointerDrag(value);
|
|
201
|
+
const p = try parse(compiled, 12, value, 0);
|
|
202
|
+
defer p.deinit();
|
|
203
|
+
return .{ .target = .{ .view_label = p.string(0), .id = p.integer(1, canvas.ObjectId) }, .start_x_ratio = p.float(2), .end_x_ratio = p.float(3), .start_y_ratio = p.float(4), .end_y_ratio = p.float(5) };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
pub fn parseAutomationScreenshotCommand(policy: ?Policy, value: []const u8) !AutomationScreenshotCommand {
|
|
207
|
+
const compiled = policy orelse return reference.parseAutomationScreenshotCommand(value);
|
|
208
|
+
const p = try parse(compiled, 13, value, 0);
|
|
209
|
+
defer p.deinit();
|
|
210
|
+
return .{ .view_label = p.string(0), .scale = if (p.word(12) == 1) p.float(1) else null };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
pub fn parseAutomationDropPaths(policy: ?Policy, value: []const u8, output: [][]const u8) ![]const []const u8 {
|
|
214
|
+
const compiled = policy orelse return reference.parseAutomationDropPaths(value, output);
|
|
215
|
+
const p = try parse(compiled, 14, value, output.len);
|
|
216
|
+
defer p.deinit();
|
|
217
|
+
for (0..p.word(20)) |index| output[index] = p.string(index);
|
|
218
|
+
if (p.word(8) == 0) return error.InvalidCommand;
|
|
219
|
+
return output[0..p.word(20)];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
pub fn parseAutomationTextSelection(policy: ?Policy, value: []const u8) !canvas.TextSelection {
|
|
223
|
+
const compiled = policy orelse return reference.parseAutomationTextSelection(value);
|
|
224
|
+
const p = try parse(compiled, 15, value, 0);
|
|
225
|
+
defer p.deinit();
|
|
226
|
+
return .{ .anchor = p.integer(0, usize), .focus = p.integer(1, usize) };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
pub fn parseAutomationDragDelta(policy: ?Policy, value: []const u8) !geometry.OffsetF {
|
|
230
|
+
const compiled = policy orelse return reference.parseAutomationDragDelta(value);
|
|
231
|
+
const p = try parse(compiled, 16, value, 0);
|
|
232
|
+
defer p.deinit();
|
|
233
|
+
return geometry.OffsetF.init(p.float(0), p.float(1));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
pub fn parseAutomationResizeCommand(policy: ?Policy, value: []const u8) !AutomationResizeCommand {
|
|
237
|
+
const compiled = policy orelse return reference.parseAutomationResizeCommand(value);
|
|
238
|
+
const p = try parse(compiled, 17, value, 0);
|
|
239
|
+
defer p.deinit();
|
|
240
|
+
return .{ .width = p.float(0), .height = p.float(1), .scale_factor = p.float(2) };
|
|
241
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//! Bounded transport for ordered automation interactions. All labels, text,
|
|
2
|
+
//! paths, clocks and delivered events remain owned by the native caller.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const geometry = @import("geometry");
|
|
5
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
6
|
+
pub const Mode = enum(u8) { click, hold, context_press, wheel, key, pinch, pointer_drag, replace_text, composition, drag, drop, menu_admission, menu_completion };
|
|
7
|
+
pub const Fact = struct {
|
|
8
|
+
pub const node: u32 = 1;
|
|
9
|
+
pub const interactive: u32 = 2;
|
|
10
|
+
pub const editable: u32 = 4;
|
|
11
|
+
pub const point: u32 = 8;
|
|
12
|
+
pub const text: u32 = 16;
|
|
13
|
+
pub const view: u32 = 32;
|
|
14
|
+
pub const menu: u32 = 64;
|
|
15
|
+
pub const item: u32 = 128;
|
|
16
|
+
pub const separator: u32 = 256;
|
|
17
|
+
pub const enabled: u32 = 512;
|
|
18
|
+
pub const pending: u32 = 1024;
|
|
19
|
+
pub const window: u32 = 2048;
|
|
20
|
+
};
|
|
21
|
+
pub const Options = struct {
|
|
22
|
+
facts: u32 = 0,
|
|
23
|
+
phase: u8 = 0,
|
|
24
|
+
frame: geometry.RectF = .zero(),
|
|
25
|
+
point: geometry.PointF = .zero(),
|
|
26
|
+
delta: geometry.OffsetF = .zero(),
|
|
27
|
+
ratios: [4]f32 = @splat(0),
|
|
28
|
+
expected_token: u64 = 0,
|
|
29
|
+
current_token: u64 = 0,
|
|
30
|
+
};
|
|
31
|
+
pub const Event = enum(u32) { down, up, drag, scroll, key, text, pinch_begin, pinch_change, pinch_end, hold_timer, composition, drop };
|
|
32
|
+
pub const Key = enum(u32) { borrowed, select_all, backspace };
|
|
33
|
+
pub const Step = struct {
|
|
34
|
+
event: Event,
|
|
35
|
+
button: i32,
|
|
36
|
+
key: Key,
|
|
37
|
+
text: bool,
|
|
38
|
+
point: geometry.PointF,
|
|
39
|
+
delta: geometry.OffsetF,
|
|
40
|
+
scale: f32,
|
|
41
|
+
};
|
|
42
|
+
pub const Program = struct {
|
|
43
|
+
status: u32,
|
|
44
|
+
flags: u32,
|
|
45
|
+
count: usize,
|
|
46
|
+
origin: geometry.PointF,
|
|
47
|
+
end: geometry.PointF,
|
|
48
|
+
steps: [3]Step = undefined,
|
|
49
|
+
pub fn admit(self: Program) !void {
|
|
50
|
+
return switch (self.status) {
|
|
51
|
+
0 => {},
|
|
52
|
+
1 => error.InvalidCommand,
|
|
53
|
+
2 => error.WheelTargetUnknown,
|
|
54
|
+
3 => error.WheelTargetNotInteractive,
|
|
55
|
+
4 => error.WheelTargetHasEmptyBounds,
|
|
56
|
+
5 => error.PinchScaleBelowWireMinimum,
|
|
57
|
+
7 => error.ViewNotFound,
|
|
58
|
+
8 => error.WindowNotFound,
|
|
59
|
+
9 => error.ContextMenuUndeclared,
|
|
60
|
+
10 => error.ContextMenuItemOutOfRange,
|
|
61
|
+
11 => error.ContextMenuItemSeparator,
|
|
62
|
+
12 => error.ContextMenuItemDisabled,
|
|
63
|
+
13 => error.ContextMenuSuperseded,
|
|
64
|
+
14 => error.ContextMenuViewClosed,
|
|
65
|
+
else => unreachable,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
fn put(bytes: []u8, at: usize, value: u32) void {
|
|
70
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
71
|
+
}
|
|
72
|
+
fn float(bytes: []u8, at: usize, value: f32) void {
|
|
73
|
+
put(bytes, at, @bitCast(value));
|
|
74
|
+
}
|
|
75
|
+
pub fn request(mode: Mode, options: Options) [128]u8 {
|
|
76
|
+
var bytes: [128]u8 = @splat(0);
|
|
77
|
+
bytes[0..4].* = .{ 91, 1, @intFromEnum(mode), options.phase };
|
|
78
|
+
put(&bytes, 4, options.facts);
|
|
79
|
+
for ([_]f32{ options.frame.x, options.frame.y, options.frame.width, options.frame.height, options.point.x, options.point.y, options.delta.dx, options.delta.dy } ++ options.ratios, 0..) |value, i| float(&bytes, 8 + i * 4, value);
|
|
80
|
+
std.mem.writeInt(u64, bytes[64..72], options.expected_token, .little);
|
|
81
|
+
std.mem.writeInt(u64, bytes[72..80], options.current_token, .little);
|
|
82
|
+
return bytes;
|
|
83
|
+
}
|
|
84
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
85
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
86
|
+
}
|
|
87
|
+
fn real(bytes: []const u8, at: usize) f32 {
|
|
88
|
+
return @bitCast(word(bytes, at));
|
|
89
|
+
}
|
|
90
|
+
pub fn plan(policy: Policy, mode: Mode, options: Options) Program {
|
|
91
|
+
const input = request(mode, options);
|
|
92
|
+
var bytes: [148]u8 = @splat(0xa5);
|
|
93
|
+
const size = policy(&input, &bytes);
|
|
94
|
+
if (size < 40 or size > bytes.len or word(&bytes, 0) != 1 or word(&bytes, 4) != @intFromEnum(mode) or word(&bytes, 36) != 0) @panic("invalid compiled automation interaction header");
|
|
95
|
+
const count = word(&bytes, 16);
|
|
96
|
+
if (count > 3 or size != 40 + count * 36) @panic("invalid compiled automation interaction extent");
|
|
97
|
+
var result = Program{ .status = word(&bytes, 8), .flags = word(&bytes, 12), .count = count, .origin = .init(real(&bytes, 20), real(&bytes, 24)), .end = .init(real(&bytes, 28), real(&bytes, 32)) };
|
|
98
|
+
if (result.status > 14 or result.status == 6 or result.flags & ~@as(u32, 63) != 0 or (result.status != 0 and count != 0)) @panic("invalid compiled automation interaction result");
|
|
99
|
+
for (result.steps[0..count], 0..) |*step, i| {
|
|
100
|
+
const at = 40 + i * 36;
|
|
101
|
+
const event = std.enums.fromInt(Event, word(&bytes, at)) orelse @panic("invalid compiled automation event");
|
|
102
|
+
const key = std.enums.fromInt(Key, word(&bytes, at + 8)) orelse @panic("invalid compiled automation key");
|
|
103
|
+
if (word(&bytes, at + 4) > 1 or word(&bytes, at + 12) > 1) @panic("invalid compiled automation event fields");
|
|
104
|
+
step.* = .{ .event = event, .button = @intCast(word(&bytes, at + 4)), .key = key, .text = word(&bytes, at + 12) != 0, .point = .init(real(&bytes, at + 16), real(&bytes, at + 20)), .delta = .init(real(&bytes, at + 24), real(&bytes, at + 28)), .scale = real(&bytes, at + 32) };
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
@@ -9,24 +9,24 @@ const runtime_clock = @import("clock.zig");
|
|
|
9
9
|
const runtime_frame_profile = @import("frame_profile.zig");
|
|
10
10
|
const widget_bridge = @import("widget_bridge.zig");
|
|
11
11
|
const runtime_api = @import("api.zig");
|
|
12
|
+
const snapshot_policy = @import("snapshot_policy.zig");
|
|
12
13
|
|
|
13
14
|
const FrameDiagnostics = runtime_api.FrameDiagnostics;
|
|
14
15
|
const nowNanoseconds = runtime_clock.nowNanoseconds;
|
|
15
16
|
const timestampToU64 = runtime_clock.timestampToU64;
|
|
16
17
|
const widgetRoleName = widget_bridge.widgetRoleName;
|
|
17
|
-
const canvasWidgetSemanticParentId = widget_bridge.canvasWidgetSemanticParentId;
|
|
18
|
-
const canvasWidgetSelectedState = widget_bridge.canvasWidgetSelectedState;
|
|
19
18
|
const canvasWidgetActions = widget_bridge.canvasWidgetActions;
|
|
20
19
|
const canvasTextRange = widget_bridge.canvasTextRange;
|
|
21
|
-
const canvasVirtualRange = widget_bridge.canvasVirtualRange;
|
|
22
20
|
|
|
23
21
|
pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
24
22
|
return struct {
|
|
25
23
|
pub fn automationSnapshot(self: *Runtime, title: []const u8) automation.snapshot.Input {
|
|
26
|
-
|
|
24
|
+
if (self.snapshot_policy == null) return @import("automation_snapshot_reference.zig").RuntimeAutomationSnapshot(Runtime).automationSnapshot(self, title);
|
|
25
|
+
const count = bounded(self, self.window_count, self.automation_windows.len);
|
|
27
26
|
if (count == 0) {
|
|
28
27
|
self.automation_windows[0] = .{ .id = 1, .title = title, .bounds = geometry.RectF.fromSize(self.surface.size), .focused = true };
|
|
29
28
|
return .{
|
|
29
|
+
.serialization_policy = self.snapshot_policy,
|
|
30
30
|
.windows = self.automation_windows[0..1],
|
|
31
31
|
.views = &.{},
|
|
32
32
|
.widgets = &.{},
|
|
@@ -63,6 +63,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
63
63
|
appendAutomationWidgets(self, window.info.id, &widget_count, &menu_item_count);
|
|
64
64
|
}
|
|
65
65
|
return .{
|
|
66
|
+
.serialization_policy = self.snapshot_policy,
|
|
66
67
|
.windows = self.automation_windows[0..count],
|
|
67
68
|
.views = self.automation_views[0..view_count],
|
|
68
69
|
.widgets = self.automation_widgets[0..widget_count],
|
|
@@ -90,8 +91,8 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
90
91
|
var tray_count: usize = 0;
|
|
91
92
|
var item_offset: usize = 0;
|
|
92
93
|
for (self.status_items) |status_item| {
|
|
93
|
-
if (
|
|
94
|
-
const count =
|
|
94
|
+
if (snapshot_policy.plan(self.snapshot_policy, .bounded, .{ .flags = @intFromBool(status_item.active), .words = .{ 1, self.automation_trays.len - tray_count, 0, 0, 0, 0, 0, 0 } }).flags != 0) continue;
|
|
95
|
+
const count = bounded(self, status_item.item_count, self.automation_tray_items.len - item_offset);
|
|
95
96
|
for (status_item.items[0..count], 0..) |item, index| {
|
|
96
97
|
self.automation_tray_items[item_offset + index] = .{
|
|
97
98
|
.id = item.id,
|
|
@@ -126,7 +127,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
126
127
|
/// advancing `position_ms` is the automation-visible evidence
|
|
127
128
|
/// music is actually playing.
|
|
128
129
|
fn automationAudio(self: *Runtime) ?automation.snapshot.Audio {
|
|
129
|
-
if (
|
|
130
|
+
if (presence(self) & 1 == 0) return null;
|
|
130
131
|
return .{
|
|
131
132
|
.key = self.audio_key,
|
|
132
133
|
.playing = self.audio_playing,
|
|
@@ -145,7 +146,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
145
146
|
/// snapshot; the transport line plus the surface's placeholder
|
|
146
147
|
/// widget are the automation-visible evidence.
|
|
147
148
|
fn automationVideo(self: *Runtime) ?automation.snapshot.Video {
|
|
148
|
-
if (
|
|
149
|
+
if (presence(self) & 2 == 0) return null;
|
|
149
150
|
return .{
|
|
150
151
|
.key = self.video_key,
|
|
151
152
|
.surface = self.video_surface_id,
|
|
@@ -166,7 +167,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
166
167
|
/// snapshot path — never in the frame path; entries land in
|
|
167
168
|
/// runtime-owned storage so the returned slices stay plain values.
|
|
168
169
|
fn automationFrameProfile(self: *Runtime) ?automation.snapshot.FrameProfile {
|
|
169
|
-
if (
|
|
170
|
+
if (presence(self) & 4 == 0) return null;
|
|
170
171
|
inline for (comptime std.enums.values(runtime_frame_profile.FrameProfileStage), 0..) |stage, index| {
|
|
171
172
|
const stats = self.frame_profile.stats(stage);
|
|
172
173
|
self.automation_frame_profile_stages[index] = .{
|
|
@@ -182,7 +183,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
182
183
|
|
|
183
184
|
fn automationDiagnostics(self: *Runtime) automation.snapshot.Diagnostics {
|
|
184
185
|
const now_ns = timestampToU64(nowNanoseconds());
|
|
185
|
-
const uptime_ns =
|
|
186
|
+
const uptime_ns = snapshot_policy.plan(self.snapshot_policy, .uptime, .{ .words = .{ self.started_timestamp_ns, now_ns, 0, 0, 0, 0, 0, 0 } }).words[0];
|
|
186
187
|
return .{
|
|
187
188
|
.frame_index = self.last_diagnostics.frame_index,
|
|
188
189
|
.command_count = self.last_diagnostics.command_count,
|
|
@@ -208,18 +209,19 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
208
209
|
|
|
209
210
|
fn appendAutomationWidgets(self: *Runtime, window_id: platform.WindowId, widget_count: *usize, menu_item_count: *usize) void {
|
|
210
211
|
for (self.views[0..self.view_count]) |*view| {
|
|
211
|
-
if (
|
|
212
|
+
if (snapshot_policy.plan(self.snapshot_policy, .view, .{ .flags = bit(view.open, 1) | bit(view.kind == .gpu_surface, 2), .words = .{ view.window_id, window_id, 0, 0, 0, 0, 0, 0 } }).flags == 0) continue;
|
|
212
213
|
const layout = view.widgetLayoutTree();
|
|
213
214
|
const semantics = view.widgetSemantics();
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
const count = bounded(self, semantics.len, self.automation_widgets.len - widget_count.*);
|
|
216
|
+
for (semantics[0..count]) |node| {
|
|
217
|
+
const state = widgetProjection(self, view, semantics, node);
|
|
216
218
|
self.automation_widgets[widget_count.*] = .{
|
|
217
219
|
.window_id = view.window_id,
|
|
218
220
|
.view_label = view.label,
|
|
219
221
|
.id = node.id,
|
|
220
222
|
.role = widgetRoleName(node.role),
|
|
221
223
|
.name = node.label,
|
|
222
|
-
.parent_id =
|
|
224
|
+
.parent_id = if (state.flags & 32 != 0) semantics[@intCast(state.words[0])].id else null,
|
|
223
225
|
.value = node.value,
|
|
224
226
|
.text_value = node.text_value,
|
|
225
227
|
.placeholder = node.placeholder,
|
|
@@ -238,13 +240,13 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
238
240
|
.viewport_extent = node.scroll.viewport_extent,
|
|
239
241
|
.content_extent = node.scroll.content_extent,
|
|
240
242
|
},
|
|
241
|
-
.virtual_range =
|
|
242
|
-
.bounds =
|
|
243
|
-
.focused =
|
|
244
|
-
.enabled =
|
|
245
|
-
.hovered =
|
|
246
|
-
.pressed =
|
|
247
|
-
.selected =
|
|
243
|
+
.virtual_range = virtualProjection(self, layout.virtualRangeById(node.id)),
|
|
244
|
+
.bounds = .{ .x = state.floats[0], .y = state.floats[1], .width = state.floats[2], .height = state.floats[3] },
|
|
245
|
+
.focused = state.flags & 2 != 0,
|
|
246
|
+
.enabled = state.flags & 4 != 0,
|
|
247
|
+
.hovered = state.flags & 8 != 0,
|
|
248
|
+
.pressed = state.flags & 16 != 0,
|
|
249
|
+
.selected = state.flags & 1 != 0,
|
|
248
250
|
.expanded = node.state.expanded,
|
|
249
251
|
.required = node.state.required,
|
|
250
252
|
.read_only = node.state.read_only,
|
|
@@ -270,7 +272,7 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
270
272
|
const declared = node.widget.context_menu;
|
|
271
273
|
if (declared.len == 0) return &.{};
|
|
272
274
|
const start = menu_item_count.*;
|
|
273
|
-
const count =
|
|
275
|
+
const count = bounded(self, declared.len, self.automation_widget_menu_items.len - start);
|
|
274
276
|
for (declared[0..count], self.automation_widget_menu_items[start .. start + count]) |item, *slot| {
|
|
275
277
|
slot.* = .{
|
|
276
278
|
.label = item.label,
|
|
@@ -282,6 +284,34 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
282
284
|
return self.automation_widget_menu_items[start .. start + count];
|
|
283
285
|
}
|
|
284
286
|
|
|
287
|
+
fn bit(value: bool, mask: u32) u32 {
|
|
288
|
+
return if (value) mask else 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
fn bounded(self: *Runtime, count: usize, capacity: usize) usize {
|
|
292
|
+
return @intCast(snapshot_policy.plan(self.snapshot_policy, .bounded, .{ .flags = 1, .words = .{ count, capacity, 0, 0, 0, 0, 0, 0 } }).words[0]);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
fn presence(self: *Runtime) u8 {
|
|
296
|
+
return snapshot_policy.plan(self.snapshot_policy, .presence, .{ .flags = bit(self.audio_active, 1) | bit(self.video_active, 2) | bit(self.frame_profile.enabled, 4) }).flags;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
fn widgetProjection(self: *Runtime, view: anytype, semantics: []const canvas.WidgetSemanticsNode, node: canvas.WidgetSemanticsNode) snapshot_policy.Plan {
|
|
300
|
+
return snapshot_policy.plan(self.snapshot_policy, .widget, .{
|
|
301
|
+
.flags = bit(node.state.selected, 1) | bit(node.value != null, 2) |
|
|
302
|
+
bit(node.state.focused, 8) | bit(view.keyboard_active, 16) | bit(view.focused, 32) |
|
|
303
|
+
bit(node.state.disabled, 64) | bit(node.state.hovered, 128) | bit(node.state.pressed, 256) | bit(node.parent_index != null, 1024),
|
|
304
|
+
.words = .{ node.id, view.canvas_widget_focused_id, view.canvas_widget_hovered_id, view.canvas_widget_pressed_id, node.parent_index orelse 0, semantics.len, @intFromEnum(node.role), 0 },
|
|
305
|
+
.floats = .{ node.value orelse 0, node.bounds.x, node.bounds.y, node.bounds.width, node.bounds.height, view.frame.x, view.frame.y },
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
fn virtualProjection(self: *Runtime, range: ?canvas.VirtualListRange) automation.snapshot.WidgetVirtualRange {
|
|
310
|
+
const value = range orelse canvas.VirtualListRange{};
|
|
311
|
+
const projection = snapshot_policy.plan(self.snapshot_policy, .virtual_range, .{ .flags = @intFromBool(range != null), .words = .{ value.start_index, value.end_index, value.first_visible_index, value.last_visible_index, 0, 0, 0, 0 } });
|
|
312
|
+
return .{ .present = projection.flags != 0, .start_index = @intCast(projection.words[0]), .end_index = @intCast(projection.words[1]), .first_visible_index = @intCast(projection.words[2]), .last_visible_index = @intCast(projection.words[3]), .rendered_count = @intCast(projection.words[4]) };
|
|
313
|
+
}
|
|
314
|
+
|
|
285
315
|
pub fn frameDiagnostics(self: *Runtime) FrameDiagnostics {
|
|
286
316
|
return self.last_diagnostics;
|
|
287
317
|
}
|