@native-sdk/cli 0.10.1 → 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 +1796 -83
- 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/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/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 +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,252 @@
|
|
|
1
|
+
//! Copied paint traversal boundary. Native owns command identities, packets,
|
|
2
|
+
//! result storage and drawing execution; portable code owns scheduling.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const geometry = @import("geometry");
|
|
5
|
+
const drawing = @import("drawing.zig");
|
|
6
|
+
const widgets = @import("widgets.zig");
|
|
7
|
+
const tokens_model = @import("tokens.zig");
|
|
8
|
+
const tree = @import("widget_tree.zig");
|
|
9
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
10
|
+
const none = std.math.maxInt(u32);
|
|
11
|
+
pub fn owner(layout: anytype) ?Policy {
|
|
12
|
+
const T = switch (@typeInfo(@TypeOf(layout))) {
|
|
13
|
+
.pointer => |p| p.child,
|
|
14
|
+
else => @TypeOf(layout),
|
|
15
|
+
};
|
|
16
|
+
if (comptime @hasField(T, "paint_walk_policy")) return layout.paint_walk_policy;
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
fn put(b: []u8, at: usize, v: usize) void {
|
|
20
|
+
std.mem.writeInt(u32, b[at..][0..4], std.math.cast(u32, v) orelse @panic("paint walk wire capacity"), .little);
|
|
21
|
+
}
|
|
22
|
+
fn read(b: []const u8, at: usize) u32 {
|
|
23
|
+
return std.mem.readInt(u32, b[at..][0..4], .little);
|
|
24
|
+
}
|
|
25
|
+
fn float(b: []u8, at: usize, v: f32) void {
|
|
26
|
+
put(b, at, @as(u32, @bitCast(v)));
|
|
27
|
+
}
|
|
28
|
+
fn readFloat(b: []const u8, at: usize) f32 {
|
|
29
|
+
return @bitCast(read(b, at));
|
|
30
|
+
}
|
|
31
|
+
fn wide(b: []u8, at: usize, v: u64) void {
|
|
32
|
+
put(b, at, @as(u32, @truncate(v)));
|
|
33
|
+
put(b, at + 4, v >> 32);
|
|
34
|
+
}
|
|
35
|
+
fn slot(b: []const u8, at: usize) ?usize {
|
|
36
|
+
const v = read(b, at);
|
|
37
|
+
return if (v == none) null else v;
|
|
38
|
+
}
|
|
39
|
+
fn validateSlot(b: []const u8, at: usize, count: usize) void {
|
|
40
|
+
if (slot(b, at)) |v| {
|
|
41
|
+
if (v >= count) @panic("invalid compiled paint walk slot");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
pub const Lane = struct {
|
|
45
|
+
focused: bool,
|
|
46
|
+
hovered: bool,
|
|
47
|
+
pressed: bool,
|
|
48
|
+
logical_focus: bool,
|
|
49
|
+
group_focus: bool,
|
|
50
|
+
skip: bool,
|
|
51
|
+
wrap_opacity: bool,
|
|
52
|
+
wrap_motion: bool,
|
|
53
|
+
wrap_transform: bool,
|
|
54
|
+
suppress_flow: bool,
|
|
55
|
+
disclosure: enum(u2) { closed, revealing, open },
|
|
56
|
+
opacity: f32,
|
|
57
|
+
motion: geometry.OffsetF,
|
|
58
|
+
inverse: ?drawing.Affine,
|
|
59
|
+
};
|
|
60
|
+
pub const Facts = struct {
|
|
61
|
+
layer: i32,
|
|
62
|
+
surface_layer: i32,
|
|
63
|
+
next_sibling: ?usize,
|
|
64
|
+
first_child: ?usize,
|
|
65
|
+
next_surface: ?usize,
|
|
66
|
+
next_escaping: ?usize,
|
|
67
|
+
child_count: usize,
|
|
68
|
+
segment: widgets.WidgetGroupSegment,
|
|
69
|
+
ordinary: Lane,
|
|
70
|
+
preview: Lane,
|
|
71
|
+
};
|
|
72
|
+
fn lane(b: []const u8, at: usize) Lane {
|
|
73
|
+
const f = read(b, at);
|
|
74
|
+
return .{ .focused = f & 1 != 0, .hovered = f & 2 != 0, .pressed = f & 4 != 0, .logical_focus = f & 8 != 0, .group_focus = f & 16 != 0, .skip = f & 32 != 0, .wrap_opacity = f & 64 != 0, .wrap_motion = f & 128 != 0, .wrap_transform = f & 256 != 0, .suppress_flow = f & 512 != 0, .disclosure = @enumFromInt((f >> 10) & 3), .opacity = readFloat(b, at + 4), .motion = .{ .dx = readFloat(b, at + 8), .dy = readFloat(b, at + 12) }, .inverse = if (read(b, at + 16) == 0) null else .{ .a = readFloat(b, at + 20), .b = readFloat(b, at + 24), .c = readFloat(b, at + 28), .d = readFloat(b, at + 32), .tx = readFloat(b, at + 36), .ty = readFloat(b, at + 40) } };
|
|
75
|
+
}
|
|
76
|
+
pub const Plan = struct {
|
|
77
|
+
allocator: std.mem.Allocator,
|
|
78
|
+
request: []u8,
|
|
79
|
+
result: []u8,
|
|
80
|
+
nodes: []const @import("events.zig").WidgetLayoutNode,
|
|
81
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, layout: anytype, tokens: tokens_model.DesignTokens, state: widgets.WidgetRenderState) std.mem.Allocator.Error!Plan {
|
|
82
|
+
const node_bytes = std.math.mul(usize, layout.nodes.len, 96) catch @panic("paint walk node capacity");
|
|
83
|
+
const motion_bytes = std.math.mul(usize, state.layout_motions.len, 24) catch @panic("paint walk motion capacity");
|
|
84
|
+
const reveal_bytes = std.math.mul(usize, state.revealing_disclosure_ids.len, 8) catch @panic("paint walk reveal capacity");
|
|
85
|
+
var size: usize = 80;
|
|
86
|
+
for ([_]usize{ node_bytes, motion_bytes, reveal_bytes }) |v| size = std.math.add(usize, size, v) catch @panic("paint walk byte capacity");
|
|
87
|
+
const request = try allocator.alloc(u8, size);
|
|
88
|
+
errdefer allocator.free(request);
|
|
89
|
+
@memset(request, 0);
|
|
90
|
+
request[0..4].* = .{ 28, 1, @import("render_plan_policy.zig").numericFlags(), signalingClampFlags() | inverseNegationFlags() };
|
|
91
|
+
put(request, 4, layout.nodes.len);
|
|
92
|
+
put(request, 8, state.layout_motions.len);
|
|
93
|
+
put(request, 12, state.revealing_disclosure_ids.len);
|
|
94
|
+
var flags: u32 = @intFromBool(state.keyboard_active);
|
|
95
|
+
inline for (.{ "focused_id", "focus_visible_id", "hovered_id", "pressed_id", "drag_preview_id" }, 0..) |name, i| {
|
|
96
|
+
if (@field(state, name)) |id| {
|
|
97
|
+
flags |= @as(u32, 1) << (i + 1);
|
|
98
|
+
wide(request, 36 + i * 8, id);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
flags |= @as(u32, @intFromBool(state.rendering_drag_preview)) << 6;
|
|
102
|
+
flags |= @as(u32, @intFromBool(tokens.controls.button_group_style == .detached)) << 7;
|
|
103
|
+
put(request, 16, flags);
|
|
104
|
+
float(request, 76, invalidOperationNaN());
|
|
105
|
+
inline for (.{ "base", "overlay", "floating", "modal" }, 0..) |name, i| put(request, 20 + i * 4, @as(u32, @bitCast(@field(tokens.layer, name))));
|
|
106
|
+
for (layout.nodes, 0..) |n, i| {
|
|
107
|
+
const at = 80 + i * 96;
|
|
108
|
+
put(request, at, widgets.widgetKindCode(n.widget.kind));
|
|
109
|
+
put(request, at + 4, @as(u32, @intFromBool(n.parent_index != null)) | (@as(u32, @intFromBool(n.widget.layout.anchor != null)) << 1) | (@as(u32, @intFromBool(n.widget.semantics.hidden)) << 2) | (@as(u32, @intFromBool(n.widget.layer != null)) << 3) | (@as(u32, @intFromBool(n.widget.state.focused)) << 4) | (@as(u32, @intFromBool(n.widget.state.hovered)) << 5) | (@as(u32, @intFromBool(n.widget.state.pressed)) << 6) | (@as(u32, @intFromBool(n.widget.state.selected)) << 7));
|
|
110
|
+
if (n.parent_index) |p| wide(request, at + 8, p);
|
|
111
|
+
wide(request, at + 16, n.widget.id);
|
|
112
|
+
wide(request, at + 24, if (n.widget.id == 0) 0 else @import("widget_render.zig").dragPreviewWidgetId(n.widget.id));
|
|
113
|
+
wide(request, at + 32, n.depth);
|
|
114
|
+
put(request, at + 40, @as(u32, @bitCast(n.widget.layer orelse 0)));
|
|
115
|
+
inline for (.{ "x", "y", "width", "height" }, 0..) |name, j| float(request, at + 44 + j * 4, @field(n.frame, name));
|
|
116
|
+
inline for (.{ "a", "b", "c", "d", "tx", "ty" }, 0..) |name, j| float(request, at + 60 + j * 4, @field(n.widget.transform, name));
|
|
117
|
+
float(request, at + 84, n.widget.opacity);
|
|
118
|
+
float(request, at + 88, n.widget.value);
|
|
119
|
+
float(request, at + 92, n.widget.layout.gap);
|
|
120
|
+
}
|
|
121
|
+
for (state.layout_motions, 0..) |m, i| {
|
|
122
|
+
const at = 80 + node_bytes + i * 24;
|
|
123
|
+
wide(request, at, m.id);
|
|
124
|
+
float(request, at + 8, m.offset.dx);
|
|
125
|
+
float(request, at + 12, m.offset.dy);
|
|
126
|
+
put(request, at + 16, @intFromBool(m.escape_ancestor_clips));
|
|
127
|
+
}
|
|
128
|
+
for (state.revealing_disclosure_ids, 0..) |id, i| wide(request, 80 + node_bytes + motion_bytes + i * 8, id);
|
|
129
|
+
const result_size = std.math.add(usize, 24, std.math.mul(usize, layout.nodes.len, 120) catch @panic("paint walk result capacity")) catch @panic("paint walk result capacity");
|
|
130
|
+
const result = try allocator.alloc(u8, result_size);
|
|
131
|
+
errdefer allocator.free(result);
|
|
132
|
+
@memset(result, 0xa5);
|
|
133
|
+
if (policy(request, result) != result.len or !std.mem.eql(u8, result[0..4], &.{ 1, 0, 0, 0 }) or read(result, 4) != layout.nodes.len) @panic("invalid compiled paint walk result");
|
|
134
|
+
for (0..4) |j| validateSlot(result, 8 + j * 4, layout.nodes.len);
|
|
135
|
+
for (layout.nodes, 0..) |_, i| {
|
|
136
|
+
const at = 24 + i * 120;
|
|
137
|
+
for (0..4) |j| validateSlot(result, at + 8 + j * 4, layout.nodes.len);
|
|
138
|
+
if (read(result, at + 24) > layout.nodes.len or read(result, at + 28) > 3) @panic("invalid compiled paint walk count");
|
|
139
|
+
for ([_]usize{ at + 32, at + 76 }) |a| {
|
|
140
|
+
const f = read(result, a);
|
|
141
|
+
if (f > 3071 or ((f >> 10) & 3) > 2 or read(result, a + 16) > 1 or (read(result, a + 16) == 0 and !std.mem.allEqual(u8, result[a + 20 ..][0..24], 0))) @panic("invalid compiled paint walk lane");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return .{ .allocator = allocator, .request = request, .result = result, .nodes = layout.nodes };
|
|
145
|
+
}
|
|
146
|
+
pub fn matches(self: Plan, layout: anytype) bool {
|
|
147
|
+
return self.nodes.ptr == layout.nodes.ptr and self.nodes.len == layout.nodes.len;
|
|
148
|
+
}
|
|
149
|
+
pub fn firstRoot(self: Plan) ?usize {
|
|
150
|
+
return slot(self.result, 8);
|
|
151
|
+
}
|
|
152
|
+
pub fn firstSurface(self: Plan) ?usize {
|
|
153
|
+
return slot(self.result, 12);
|
|
154
|
+
}
|
|
155
|
+
pub fn firstEscaping(self: Plan) ?usize {
|
|
156
|
+
return slot(self.result, 16);
|
|
157
|
+
}
|
|
158
|
+
pub fn previewIndex(self: Plan) ?usize {
|
|
159
|
+
return slot(self.result, 20);
|
|
160
|
+
}
|
|
161
|
+
pub fn facts(self: Plan, index: usize) Facts {
|
|
162
|
+
const at = 24 + index * 120;
|
|
163
|
+
return .{ .layer = @bitCast(read(self.result, at)), .surface_layer = @bitCast(read(self.result, at + 4)), .next_sibling = slot(self.result, at + 8), .first_child = slot(self.result, at + 12), .next_surface = slot(self.result, at + 16), .next_escaping = slot(self.result, at + 20), .child_count = read(self.result, at + 24), .segment = @enumFromInt(read(self.result, at + 28)), .ordinary = lane(self.result, at + 32), .preview = lane(self.result, at + 76) };
|
|
164
|
+
}
|
|
165
|
+
pub fn activeLane(self: Plan, index: usize, preview: bool) Lane {
|
|
166
|
+
const f = self.facts(index);
|
|
167
|
+
return if (preview) f.preview else f.ordinary;
|
|
168
|
+
}
|
|
169
|
+
pub fn deinit(self: Plan) void {
|
|
170
|
+
self.allocator.free(self.request);
|
|
171
|
+
self.allocator.free(self.result);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
fn eligibleSurface(layout: anytype, index: usize) bool {
|
|
176
|
+
return tree.widgetEscapesAncestorClips(layout.nodes[index].widget) and !tree.isWidgetHiddenInAncestors(layout, index) and !tree.isWidgetConcealedByDisclosure(layout, index);
|
|
177
|
+
}
|
|
178
|
+
fn eligibleEscaping(layout: anytype, index: usize, state: widgets.WidgetRenderState) bool {
|
|
179
|
+
return !tree.widgetEscapesAncestorClips(layout.nodes[index].widget) and state.layoutMotionEscapesAncestorClips(layout.nodes[index].widget.id) and !tree.isWidgetHiddenInAncestors(layout, index) and !tree.isWidgetConcealedByDisclosure(layout, index);
|
|
180
|
+
}
|
|
181
|
+
pub fn referenceSurface(layout: anytype, tokens: tokens_model.DesignTokens, previous: ?tree.WidgetPaintOrder) ?usize {
|
|
182
|
+
var order = previous;
|
|
183
|
+
while (tree.nextWidgetLayoutWindowSurface(layout, tokens, order)) |index| {
|
|
184
|
+
if (eligibleSurface(layout, index)) return index;
|
|
185
|
+
order = tree.widgetLayoutWindowSurfaceOrder(layout, index, tokens);
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
pub fn referenceEscaping(layout: anytype, start: usize, state: widgets.WidgetRenderState) ?usize {
|
|
190
|
+
for (start..layout.nodes.len) |i| if (eligibleEscaping(layout, i, state)) return i;
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
pub fn referencePreview(layout: anytype, state: widgets.WidgetRenderState) ?usize {
|
|
194
|
+
const i = tree.widgetIndexById(layout, state.drag_preview_id orelse return null) orelse return null;
|
|
195
|
+
const n = layout.nodes[i];
|
|
196
|
+
return if (n.widget.kind == .resizable or n.widget.kind == .split_divider or tree.isWidgetHiddenInAncestors(layout, i) or tree.isWidgetConcealedByDisclosure(layout, i)) null else i;
|
|
197
|
+
}
|
|
198
|
+
pub fn referenceFacts(layout: anytype, index: usize, tokens: tokens_model.DesignTokens, state: widgets.WidgetRenderState) Facts {
|
|
199
|
+
const render = @import("widget_render.zig");
|
|
200
|
+
const node = layout.nodes[index];
|
|
201
|
+
const layer = tree.widgetPaintLayer(node.widget, tokens);
|
|
202
|
+
const preview: widgets.WidgetRenderState = .{ .rendering_drag_preview = true, .drag_preview_id = state.drag_preview_id, .drag_preview_origin = state.drag_preview_origin, .drag_preview_offset = state.drag_preview_offset, .revealing_disclosure_ids = state.revealing_disclosure_ids };
|
|
203
|
+
return .{
|
|
204
|
+
.layer = layer,
|
|
205
|
+
.surface_layer = tree.widgetLayoutWindowSurfaceLayer(layout, index, tokens),
|
|
206
|
+
.next_sibling = tree.nextWidgetLayoutPaintChild(layout, node.parent_index, tokens, .{ .layer = layer, .index = index }),
|
|
207
|
+
.first_child = tree.nextWidgetLayoutPaintChild(layout, index, tokens, null),
|
|
208
|
+
.next_surface = if (eligibleSurface(layout, index)) referenceSurface(layout, tokens, tree.widgetLayoutWindowSurfaceOrder(layout, index, tokens)) else null,
|
|
209
|
+
.next_escaping = if (eligibleEscaping(layout, index, state)) referenceEscaping(layout, index + 1, state) else null,
|
|
210
|
+
.child_count = tree.widgetLayoutDirectChildCount(layout, index),
|
|
211
|
+
.segment = render.referencePaintWalkSegment(layout, index, tokens),
|
|
212
|
+
.ordinary = render.referencePaintWalkLane(layout, index, state),
|
|
213
|
+
.preview = render.referencePaintWalkLane(layout, index, preview),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
pub fn referenceRoot(layout: anytype, tokens: tokens_model.DesignTokens) ?usize {
|
|
218
|
+
return tree.nextWidgetLayoutPaintChild(layout, null, tokens, null);
|
|
219
|
+
}
|
|
220
|
+
pub fn previewCommandId(id: u64) u64 {
|
|
221
|
+
return if (id == 0) 0 else @import("widget_render.zig").dragPreviewWidgetId(id);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/// A scalar ABI descriptor, measured with target f32 arithmetic rather than
|
|
225
|
+
/// assuming the unspecified JavaScript invalid-operation NaN sign.
|
|
226
|
+
fn invalidOperationNaN() f32 {
|
|
227
|
+
var operands = [_]f32{ std.math.inf(f32), 0 };
|
|
228
|
+
const pointer: *volatile [2]f32 = &operands;
|
|
229
|
+
const values = pointer.*;
|
|
230
|
+
return values[0] * values[1];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/// Hardware minimum-number operations distinguish signaling NaNs from
|
|
234
|
+
/// quiet NaNs on some targets; describe that scalar behavior explicitly.
|
|
235
|
+
fn signalingClampFlags() u8 {
|
|
236
|
+
var operand: u32 = 0x7f800001;
|
|
237
|
+
const pointer: *volatile u32 = &operand;
|
|
238
|
+
const value: f32 = @bitCast(pointer.*);
|
|
239
|
+
return @intFromBool(std.math.clamp(value, @as(f32, 0), @as(f32, 1)) == 0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/// Native inverse emission may move off-diagonal negation across a
|
|
243
|
+
/// multiplication. The descriptor preserves the otherwise unspecified NaN sign.
|
|
244
|
+
fn inverseNegationFlags() u8 {
|
|
245
|
+
var operand: drawing.Affine = .{ .b = std.math.inf(f32) };
|
|
246
|
+
const pointer: *volatile drawing.Affine = &operand;
|
|
247
|
+
var result: drawing.Affine = undefined;
|
|
248
|
+
const output: *volatile drawing.Affine = &result;
|
|
249
|
+
output.* = @import("widget_render.zig").inversePaintTransform(pointer.*).?;
|
|
250
|
+
const inverse = output.*;
|
|
251
|
+
return @as(u8, @intFromBool(@as(u32, @bitCast(inverse.a)) != @as(u32, @bitCast(inverse.b)))) << 1;
|
|
252
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
//! Copied retained presentation boundary. Native owns packets and results;
|
|
2
|
+
//! portable code derives viewport, ancestry, motion and span visibility.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const geometry = @import("geometry");
|
|
5
|
+
const drawing = @import("drawing.zig");
|
|
6
|
+
const widgets = @import("widgets.zig");
|
|
7
|
+
const tokens_model = @import("tokens.zig");
|
|
8
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
9
|
+
const node_size = 64;
|
|
10
|
+
const result_node_size = 152;
|
|
11
|
+
pub fn owner(layout: anytype) ?Policy {
|
|
12
|
+
const T = switch (@typeInfo(@TypeOf(layout))) {
|
|
13
|
+
.pointer => |p| p.child,
|
|
14
|
+
else => @TypeOf(layout),
|
|
15
|
+
};
|
|
16
|
+
if (comptime @hasField(T, "presentation_policy")) return layout.presentation_policy;
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
fn put(b: []u8, at: usize, value: usize) void {
|
|
20
|
+
std.mem.writeInt(u32, b[at..][0..4], std.math.cast(u32, value) orelse @panic("presentation wire capacity"), .little);
|
|
21
|
+
}
|
|
22
|
+
fn read(b: []const u8, at: usize) u32 {
|
|
23
|
+
return std.mem.readInt(u32, b[at..][0..4], .little);
|
|
24
|
+
}
|
|
25
|
+
fn float(b: []u8, at: usize, value: f32) void {
|
|
26
|
+
put(b, at, @as(u32, @bitCast(value)));
|
|
27
|
+
}
|
|
28
|
+
fn readFloat(b: []const u8, at: usize) f32 {
|
|
29
|
+
return @bitCast(read(b, at));
|
|
30
|
+
}
|
|
31
|
+
fn wide(b: []u8, at: usize, value: u64) void {
|
|
32
|
+
put(b, at, @as(u32, @truncate(value)));
|
|
33
|
+
put(b, at + 4, value >> 32);
|
|
34
|
+
}
|
|
35
|
+
fn rect(b: []u8, at: usize, value: geometry.RectF) void {
|
|
36
|
+
inline for (.{ "x", "y", "width", "height" }, 0..) |name, i| float(b, at + i * 4, @field(value, name));
|
|
37
|
+
}
|
|
38
|
+
fn optionalRect(b: []const u8, at: usize) ?geometry.RectF {
|
|
39
|
+
if (read(b, at) == 0) return null;
|
|
40
|
+
return .init(readFloat(b, at + 4), readFloat(b, at + 8), readFloat(b, at + 12), readFloat(b, at + 16));
|
|
41
|
+
}
|
|
42
|
+
fn optionalAffine(b: []const u8, at: usize) ?drawing.Affine {
|
|
43
|
+
if (read(b, at) == 0) return null;
|
|
44
|
+
return .{ .a = readFloat(b, at + 4), .b = readFloat(b, at + 8), .c = readFloat(b, at + 12), .d = readFloat(b, at + 16), .tx = readFloat(b, at + 20), .ty = readFloat(b, at + 24) };
|
|
45
|
+
}
|
|
46
|
+
fn validateOptional(b: []const u8, at: usize, size: usize) void {
|
|
47
|
+
if (read(b, at) > 1 or (read(b, at) == 0 and !std.mem.allEqual(u8, b[at + 4 ..][0..size], 0))) @panic("invalid compiled presentation optional");
|
|
48
|
+
}
|
|
49
|
+
pub const Facts = struct {
|
|
50
|
+
emission: ?drawing.Affine,
|
|
51
|
+
ancestor: ?drawing.Affine,
|
|
52
|
+
presentation: ?drawing.Affine,
|
|
53
|
+
preview_presentation: ?drawing.Affine,
|
|
54
|
+
visible: ?geometry.RectF,
|
|
55
|
+
preview_visible: ?geometry.RectF,
|
|
56
|
+
};
|
|
57
|
+
pub const Plan = struct {
|
|
58
|
+
allocator: std.mem.Allocator,
|
|
59
|
+
request: []u8,
|
|
60
|
+
result: []u8,
|
|
61
|
+
nodes: []const @import("events.zig").WidgetLayoutNode,
|
|
62
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, layout: anytype, tokens: tokens_model.DesignTokens, state: widgets.WidgetRenderState) std.mem.Allocator.Error!Plan {
|
|
63
|
+
return build(allocator, policy, layout, tokens, state, 1);
|
|
64
|
+
}
|
|
65
|
+
fn build(allocator: std.mem.Allocator, policy: Policy, layout: anytype, tokens: tokens_model.DesignTokens, state: widgets.WidgetRenderState, mode: u8) std.mem.Allocator.Error!Plan {
|
|
66
|
+
const node_bytes = std.math.mul(usize, layout.nodes.len, node_size) catch @panic("presentation node capacity");
|
|
67
|
+
const motion_bytes = std.math.mul(usize, state.layout_motions.len, 24) catch @panic("presentation motion capacity");
|
|
68
|
+
const size = std.math.add(usize, 64, std.math.add(usize, node_bytes, motion_bytes) catch @panic("presentation byte capacity")) catch @panic("presentation byte capacity");
|
|
69
|
+
const request = try allocator.alloc(u8, size);
|
|
70
|
+
errdefer allocator.free(request);
|
|
71
|
+
@memset(request, 0);
|
|
72
|
+
request[0..4].* = .{ 27, mode, 1, @import("render_plan_policy.zig").numericFlags() };
|
|
73
|
+
put(request, 4, layout.nodes.len);
|
|
74
|
+
put(request, 8, state.layout_motions.len);
|
|
75
|
+
const T = switch (@typeInfo(@TypeOf(layout))) {
|
|
76
|
+
.pointer => |p| p.child,
|
|
77
|
+
else => @TypeOf(layout),
|
|
78
|
+
};
|
|
79
|
+
const root_bounds: ?geometry.RectF = if (comptime @hasField(T, "root_bounds")) layout.root_bounds else null;
|
|
80
|
+
put(request, 12, @as(u32, @intFromBool(root_bounds != null)) | (@as(u32, @intFromBool(state.drag_preview_id != null)) << 1) | (@as(u32, @intFromBool(state.drag_preview_origin != null)) << 2) | (@as(u32, @intFromBool(tokens.pixel_snap.geometry)) << 3) | (@as(u32, @intFromBool(state.rendering_drag_preview)) << 4));
|
|
81
|
+
if (root_bounds) |r| rect(request, 16, r);
|
|
82
|
+
if (state.drag_preview_id) |id| wide(request, 32, id);
|
|
83
|
+
if (state.drag_preview_origin) |p| {
|
|
84
|
+
float(request, 40, p.x);
|
|
85
|
+
float(request, 44, p.y);
|
|
86
|
+
}
|
|
87
|
+
float(request, 48, state.drag_preview_offset.dx);
|
|
88
|
+
float(request, 52, state.drag_preview_offset.dy);
|
|
89
|
+
float(request, 56, tokens.pixel_snap.scale);
|
|
90
|
+
for (layout.nodes, 0..) |n, i| {
|
|
91
|
+
const at = 64 + i * node_size;
|
|
92
|
+
put(request, at, widgets.widgetKindCode(n.widget.kind));
|
|
93
|
+
put(request, at + 4, @as(u32, @intFromBool(n.parent_index != null)) | (@as(u32, @intFromBool(n.widget.layout.anchor != null)) << 1) | (@as(u32, @intFromBool(n.widget.layout.clip_content)) << 2) | (@as(u32, @intFromBool(n.widget.kind == .text and n.widget.spans.len > 0)) << 3));
|
|
94
|
+
if (n.parent_index) |p| wide(request, at + 8, p);
|
|
95
|
+
wide(request, at + 16, n.widget.id);
|
|
96
|
+
rect(request, at + 24, n.frame);
|
|
97
|
+
inline for (.{ "a", "b", "c", "d", "tx", "ty" }, 0..) |name, j| float(request, at + 40 + j * 4, @field(n.widget.transform, name));
|
|
98
|
+
}
|
|
99
|
+
for (state.layout_motions, 0..) |m, i| {
|
|
100
|
+
const at = 64 + node_bytes + i * 24;
|
|
101
|
+
wide(request, at, m.id);
|
|
102
|
+
float(request, at + 8, m.offset.dx);
|
|
103
|
+
float(request, at + 12, m.offset.dy);
|
|
104
|
+
put(request, at + 16, @intFromBool(m.escape_ancestor_clips));
|
|
105
|
+
}
|
|
106
|
+
const count = if (mode == 0) 0 else layout.nodes.len;
|
|
107
|
+
const result = try allocator.alloc(u8, std.math.add(usize, 56, std.math.mul(usize, count, result_node_size) catch @panic("presentation result capacity")) catch @panic("presentation result capacity"));
|
|
108
|
+
errdefer allocator.free(result);
|
|
109
|
+
@memset(result, 0xa5);
|
|
110
|
+
const written = policy(request, result);
|
|
111
|
+
if (written != result.len or !std.mem.eql(u8, result[0..4], &.{ 1, mode, 0, 0 }) or read(result, 4) != count) @panic("invalid compiled presentation result");
|
|
112
|
+
validateOptional(result, 8, 16);
|
|
113
|
+
validateOptional(result, 28, 24);
|
|
114
|
+
for (0..count) |i| {
|
|
115
|
+
const at = 56 + i * result_node_size;
|
|
116
|
+
for (0..4) |j| validateOptional(result, at + j * 28, 24);
|
|
117
|
+
validateOptional(result, at + 112, 16);
|
|
118
|
+
validateOptional(result, at + 132, 16);
|
|
119
|
+
}
|
|
120
|
+
return .{ .allocator = allocator, .request = request, .result = result, .nodes = layout.nodes };
|
|
121
|
+
}
|
|
122
|
+
pub fn matches(self: Plan, layout: anytype) bool {
|
|
123
|
+
return self.nodes.ptr == layout.nodes.ptr and self.nodes.len == layout.nodes.len;
|
|
124
|
+
}
|
|
125
|
+
pub fn root(self: Plan) ?geometry.RectF {
|
|
126
|
+
return optionalRect(self.result, 8);
|
|
127
|
+
}
|
|
128
|
+
pub fn drag(self: Plan) ?drawing.Affine {
|
|
129
|
+
return optionalAffine(self.result, 28);
|
|
130
|
+
}
|
|
131
|
+
pub fn facts(self: Plan, index: usize) Facts {
|
|
132
|
+
const at = 56 + index * result_node_size;
|
|
133
|
+
return .{ .emission = optionalAffine(self.result, at), .ancestor = optionalAffine(self.result, at + 28), .presentation = optionalAffine(self.result, at + 56), .preview_presentation = optionalAffine(self.result, at + 84), .visible = optionalRect(self.result, at + 112), .preview_visible = optionalRect(self.result, at + 132) };
|
|
134
|
+
}
|
|
135
|
+
pub fn deinit(self: Plan) void {
|
|
136
|
+
self.allocator.free(self.request);
|
|
137
|
+
self.allocator.free(self.result);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
pub fn rootBounds(policy: Policy, layout: anytype) ?geometry.RectF {
|
|
141
|
+
const plan = Plan.build(std.heap.page_allocator, policy, layout, .{}, .{}, 0) catch @panic("presentation root allocation failed");
|
|
142
|
+
defer plan.deinit();
|
|
143
|
+
return plan.root();
|
|
144
|
+
}
|
|
145
|
+
/// Independent native calculations for parity qualification of every copied
|
|
146
|
+
/// result, including records that ordinary rendering never reaches.
|
|
147
|
+
pub fn referenceFacts(layout: anytype, index: usize, tokens: tokens_model.DesignTokens, state: widgets.WidgetRenderState) Facts {
|
|
148
|
+
const render = @import("widget_render.zig");
|
|
149
|
+
var preview_state = state;
|
|
150
|
+
preview_state.rendering_drag_preview = true;
|
|
151
|
+
preview_state.layout_motions = &.{};
|
|
152
|
+
const drag: ?drawing.Affine = if (state.drag_preview_id) |id| blk: {
|
|
153
|
+
const slot = @import("widget_tree.zig").widgetIndexById(layout, id) orelse break :blk null;
|
|
154
|
+
const ancestor = render.widgetLayoutNodeAncestorEmissionTransform(layout, slot) orelse break :blk null;
|
|
155
|
+
break :blk render.widgetLayoutDragPreviewTranslation(layout, slot, state, ancestor);
|
|
156
|
+
} else null;
|
|
157
|
+
const outer = if (state.rendering_drag_preview) drag else drawing.Affine.identity();
|
|
158
|
+
const bounds = render.pixelSnapGeometryRect(tokens, layout.nodes[index].frame);
|
|
159
|
+
const text = layout.nodes[index].widget.kind == .text and layout.nodes[index].widget.spans.len > 0;
|
|
160
|
+
return .{
|
|
161
|
+
.emission = render.widgetLayoutNodeEmissionTransform(layout, index),
|
|
162
|
+
.ancestor = render.widgetLayoutNodeAncestorEmissionTransform(layout, index),
|
|
163
|
+
.presentation = if (outer) |t| render.widgetLayoutNodePresentationTransform(layout, index, state, t) else null,
|
|
164
|
+
.preview_presentation = if (drag) |t| render.widgetLayoutNodePresentationTransform(layout, index, preview_state, t) else null,
|
|
165
|
+
.visible = if (text) render.widgetLayoutNodeVisibleBounds(layout, index, bounds, state) else null,
|
|
166
|
+
.preview_visible = if (text) render.widgetLayoutNodeVisibleBounds(layout, index, bounds, preview_state) else null,
|
|
167
|
+
};
|
|
168
|
+
}
|