@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
|
@@ -64,6 +64,20 @@ pub const WidgetLayoutTree = struct {
|
|
|
64
64
|
/// of every node so root-authored modals retain their window-space
|
|
65
65
|
/// contract without widening the hot node array.
|
|
66
66
|
root_bounds: ?geometry.RectF = null,
|
|
67
|
+
/// Portable observation policy; the retained node array stays unchanged.
|
|
68
|
+
semantic_policy: ?@import("surface_layout_policy.zig").Policy = null,
|
|
69
|
+
/// Explicit rule owner; independent of semantic and layout policies.
|
|
70
|
+
audit_policy: ?@import("widget_audit_policy.zig").Policy = null,
|
|
71
|
+
|
|
72
|
+
/// Explicit input owner, preserved by retained runtime views.
|
|
73
|
+
routing_policy: ?@import("widget_routing_policy.zig").Policy = null,
|
|
74
|
+
/// Explicit retained-change owner, independent of input routing.
|
|
75
|
+
change_policy: ?@import("widget_change_policy.zig").Policy = null,
|
|
76
|
+
/// Text decisions must reach reconciliation before display tokens arrive.
|
|
77
|
+
text_run_policy: ?@import("text_document_policy.zig").Policy = null,
|
|
78
|
+
paint_policy: ?@import("widget_paint_policy.zig").Policy = null,
|
|
79
|
+
presentation_policy: ?@import("widget_presentation_policy.zig").Policy = null,
|
|
80
|
+
paint_walk_policy: ?@import("widget_paint_walk_policy.zig").Policy = null,
|
|
67
81
|
|
|
68
82
|
pub fn nodeCount(self: WidgetLayoutTree) usize {
|
|
69
83
|
return self.nodes.len;
|
|
@@ -162,6 +176,11 @@ pub const WidgetLayoutTree = struct {
|
|
|
162
176
|
return widget_routing.focusWidgetTargetById(self, id, widgetScrollSemantics);
|
|
163
177
|
}
|
|
164
178
|
|
|
179
|
+
/// Native visible-focus capability; includes ancestor clipping.
|
|
180
|
+
pub fn focusTargetAtIndex(self: WidgetLayoutTree, index: usize) ?WidgetFocusTarget {
|
|
181
|
+
return widget_routing.focusWidgetTargetAtIndex(self, index, widgetScrollSemantics);
|
|
182
|
+
}
|
|
183
|
+
|
|
165
184
|
pub fn logicalFocusTargetAtIndex(self: WidgetLayoutTree, index: usize) ?WidgetFocusTarget {
|
|
166
185
|
return widget_routing.logicalFocusWidgetTargetAtIndex(self, index, widgetScrollSemantics);
|
|
167
186
|
}
|
|
@@ -212,7 +231,7 @@ pub fn layoutWidgetTreeWithTokens(widget: Widget, bounds: geometry.RectF, tokens
|
|
|
212
231
|
const root_bounds = bounds.normalized();
|
|
213
232
|
var len: usize = 0;
|
|
214
233
|
_ = try widget_layout.layoutWidgetDepth(widget, root_bounds, null, 0, output, &len, tokens);
|
|
215
|
-
return .{ .nodes = output[0..len], .root_bounds = root_bounds };
|
|
234
|
+
return .{ .nodes = output[0..len], .root_bounds = root_bounds, .semantic_policy = tokens.intrinsic_layout_policy, .audit_policy = tokens.widget_audit_policy, .routing_policy = tokens.widget_routing_policy, .change_policy = tokens.widget_change_policy, .text_run_policy = tokens.text_run_policy, .paint_policy = tokens.widget_paint_policy, .presentation_policy = tokens.widget_presentation_policy, .paint_walk_policy = tokens.widget_paint_walk_policy };
|
|
216
235
|
}
|
|
217
236
|
|
|
218
237
|
pub fn intrinsicWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
|
|
@@ -24,6 +24,13 @@ const semanticActions = event_model.semanticActions;
|
|
|
24
24
|
const max_widget_depth: usize = 32;
|
|
25
25
|
|
|
26
26
|
pub fn collectWidgetSemantics(layout: anytype, output: []WidgetSemanticsNode, scroll_semantics_fn: anytype) Error![]const WidgetSemanticsNode {
|
|
27
|
+
if (layoutPolicy(layout)) |policy| {
|
|
28
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
29
|
+
const plan = @import("semantic_tree_policy.zig").Plan.init(scratch.get(), policy, layout, null, output.len, null, @import("widget_layout.zig").virtualWidgetScrollContentExtent, true) catch @panic("semantic tree allocation failed");
|
|
30
|
+
defer plan.deinit();
|
|
31
|
+
plan.run();
|
|
32
|
+
return plan.copy(layout, output);
|
|
33
|
+
}
|
|
27
34
|
var len: usize = 0;
|
|
28
35
|
var semantic_stack: [max_widget_depth]?usize = [_]?usize{null} ** max_widget_depth;
|
|
29
36
|
var hidden_depth: ?usize = null;
|
|
@@ -436,6 +443,13 @@ pub const WidgetScrollSemantics = struct {
|
|
|
436
443
|
/// `widgetScrollSemantics` picks the primary axis for the assistive
|
|
437
444
|
/// node.
|
|
438
445
|
pub fn widgetScrollAxisMetrics(layout: anytype, node_index: usize, virtual_content_extent_fn: anytype, comptime axis: ScrollAxis, viewport: geometry.RectF) WidgetScrollMetrics {
|
|
446
|
+
if (layoutPolicy(layout)) |policy| {
|
|
447
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
448
|
+
const plan = @import("semantic_tree_policy.zig").Plan.init(scratch.get(), policy, layout, node_index, 1, viewport, virtual_content_extent_fn, axis == .vertical) catch @panic("scroll observation allocation failed");
|
|
449
|
+
defer plan.deinit();
|
|
450
|
+
plan.run();
|
|
451
|
+
return plan.axis(axis == .horizontal);
|
|
452
|
+
}
|
|
439
453
|
const node = layout.nodes[node_index];
|
|
440
454
|
switch (axis) {
|
|
441
455
|
.vertical => {
|
|
@@ -475,6 +489,13 @@ pub fn widgetScrollAxisMetrics(layout: anytype, node_index: usize, virtual_conte
|
|
|
475
489
|
/// (`widgetSemanticScrollDelta`).
|
|
476
490
|
pub fn widgetScrollSemantics(layout: anytype, node_index: usize, virtual_content_extent_fn: anytype) WidgetScrollSemantics {
|
|
477
491
|
if (node_index >= layout.nodes.len) return .{};
|
|
492
|
+
if (layoutPolicy(layout)) |policy| {
|
|
493
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
494
|
+
const plan = @import("semantic_tree_policy.zig").Plan.init(scratch.get(), policy, layout, node_index, 1, null, virtual_content_extent_fn, true) catch @panic("scroll semantics allocation failed");
|
|
495
|
+
defer plan.deinit();
|
|
496
|
+
plan.run();
|
|
497
|
+
return plan.scroll();
|
|
498
|
+
}
|
|
478
499
|
const node = layout.nodes[node_index];
|
|
479
500
|
if (!widgetExposesScrollSemantics(node.widget)) return .{};
|
|
480
501
|
|
|
@@ -596,3 +617,7 @@ fn skipSubtree(layout: anytype, index: usize) usize {
|
|
|
596
617
|
fn nonNegative(value: f32) f32 {
|
|
597
618
|
return if (value < 0) 0 else value;
|
|
598
619
|
}
|
|
620
|
+
|
|
621
|
+
fn layoutPolicy(layout: anytype) ?@import("surface_layout_policy.zig").Policy {
|
|
622
|
+
return if (@hasField(@TypeOf(layout), "semantic_policy")) layout.semantic_policy else null;
|
|
623
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const control_content = @import("control_content_policy.zig");
|
|
2
3
|
const geometry = @import("geometry");
|
|
3
4
|
const drawing_model = @import("drawing.zig");
|
|
4
5
|
const text_model = @import("text.zig");
|
|
@@ -7,6 +8,7 @@ const widget_model = @import("widgets.zig");
|
|
|
7
8
|
const widget_access = @import("widget_access.zig");
|
|
8
9
|
const widget_metrics = @import("widget_metrics.zig");
|
|
9
10
|
const text_measure_cache = @import("text_measure_cache.zig");
|
|
11
|
+
const document_policy = @import("text_document_policy.zig");
|
|
10
12
|
|
|
11
13
|
const FontId = @import("root.zig").FontId;
|
|
12
14
|
const Builder = @import("commands.zig").Builder;
|
|
@@ -22,6 +24,7 @@ const snapTextCaretSelection = text_model.snapTextCaretSelection;
|
|
|
22
24
|
const snapTextOffset = text_model.snapTextOffset;
|
|
23
25
|
const snapTextRange = text_model.snapTextRange;
|
|
24
26
|
const measureTextWidthForFont = text_model.measureTextWidthForFont;
|
|
27
|
+
const measureTextWidthForFontWithPolicy = text_model.measureTextWidthForFontWithPolicy;
|
|
25
28
|
const nextTextLineEnd = text_model.nextTextLineEnd;
|
|
26
29
|
const isTextBreakByte = text_model.isTextBreakByte;
|
|
27
30
|
const textLineRange = text_model.textLineRange;
|
|
@@ -171,8 +174,19 @@ pub fn widgetTextInputSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
171
174
|
}
|
|
172
175
|
|
|
173
176
|
pub fn widgetTextInputLayoutOptions(widget: Widget, tokens: DesignTokens, text_size: f32, inset: f32) TextLayoutOptions {
|
|
174
|
-
const line_height = widgetTextInputLineHeight(text_size);
|
|
175
|
-
const trailing_inset = widgetTextInputTrailingInset(widget, text_size, inset);
|
|
177
|
+
const line_height = widgetTextInputLineHeight(text_size, tokens);
|
|
178
|
+
const trailing_inset = widgetTextInputTrailingInset(widget, text_size, inset, tokens);
|
|
179
|
+
if (tokens.control_geometry_policy != null) {
|
|
180
|
+
var request = control_content.Request.init(.input_layout, widget.frame, tokens);
|
|
181
|
+
request.float(52, text_size);
|
|
182
|
+
request.float(56, inset);
|
|
183
|
+
request.float(64, trailing_inset);
|
|
184
|
+
if (widget.runtime_flags.code_editor) request.flags(4);
|
|
185
|
+
if (widget.text_no_wrap) request.flags(8);
|
|
186
|
+
request.bytes[8] = if (widget.kind == .textarea) 2 else if (widget.kind == .text_field) 1 else 0;
|
|
187
|
+
const result = request.run(tokens);
|
|
188
|
+
return .{ .max_width = result.scalar, .line_height = result.auxiliary, .wrap = result.wrap, .overflow = .clip, .text_run_policy = tokens.text_run_policy, .measure = tokens.text_measure };
|
|
189
|
+
}
|
|
176
190
|
return .{
|
|
177
191
|
.max_width = @max(1, widget.frame.width - inset - trailing_inset),
|
|
178
192
|
.line_height = line_height,
|
|
@@ -182,12 +196,13 @@ pub fn widgetTextInputLayoutOptions(widget: Widget, tokens: DesignTokens, text_s
|
|
|
182
196
|
// so the honest treatment is the frame clip, not an ellipsis
|
|
183
197
|
// hiding the caret's own neighborhood.
|
|
184
198
|
.overflow = .clip,
|
|
199
|
+
.text_run_policy = tokens.text_run_policy,
|
|
185
200
|
.measure = tokens.text_measure,
|
|
186
201
|
};
|
|
187
202
|
}
|
|
188
203
|
|
|
189
|
-
fn widgetTextInputLineHeight(text_size: f32) f32 {
|
|
190
|
-
return widget_metrics.
|
|
204
|
+
fn widgetTextInputLineHeight(text_size: f32, tokens: DesignTokens) f32 {
|
|
205
|
+
return widget_metrics.widgetLineHeightWithTokens(text_size, tokens);
|
|
191
206
|
}
|
|
192
207
|
|
|
193
208
|
fn widgetTextInputWrap(widget: Widget, line_height: f32) TextWrap {
|
|
@@ -200,7 +215,7 @@ fn widgetTextInputWrap(widget: Widget, line_height: f32) TextWrap {
|
|
|
200
215
|
fn widgetTextInputVerticalInset(widget: Widget, tokens: DesignTokens, text_size: f32, options: TextLayoutOptions) f32 {
|
|
201
216
|
if (widget.runtime_flags.code_editor) return 0;
|
|
202
217
|
if (options.wrap != .none) return widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.sm);
|
|
203
|
-
return @max(0, (widget.frame.height - widgetTextInputLineHeight(text_size)) * 0.5);
|
|
218
|
+
return @max(0, (widget.frame.height - widgetTextInputLineHeight(text_size, tokens)) * 0.5);
|
|
204
219
|
}
|
|
205
220
|
|
|
206
221
|
fn widgetTextInputScrollOffset(widget: Widget, tokens: DesignTokens, text_size: f32, text_inset: f32, options: TextLayoutOptions) f32 {
|
|
@@ -233,16 +248,31 @@ fn widgetTextInputMaxHorizontalScrollOffset(widget: Widget, tokens: DesignTokens
|
|
|
233
248
|
// single-line extent it draws.
|
|
234
249
|
const font_id = widgetTextInputFontId(widget, tokens);
|
|
235
250
|
const text_width = if (widget.runtime_flags.code_editor)
|
|
236
|
-
if (codeContentWidthCacheCurrent(widget, font_id, text_size))
|
|
251
|
+
if (codeContentWidthCacheCurrent(widget, font_id, text_size, options.text_run_policy))
|
|
237
252
|
widget.code_content_width
|
|
238
253
|
else
|
|
239
|
-
widestLogicalLineWidth(options.measure, font_id, widget.text, text_size)
|
|
254
|
+
widestLogicalLineWidth(options.measure, options.text_run_policy, font_id, widget.text, text_size)
|
|
240
255
|
else
|
|
241
|
-
|
|
256
|
+
measureTextWidthForFontWithPolicy(options.measure, options.text_run_policy, font_id, widgetTextInputPresentedText(widget), text_size);
|
|
242
257
|
return @max(0, text_width + text_input_caret_reserve - viewport.width);
|
|
243
258
|
}
|
|
244
259
|
|
|
245
260
|
pub fn widgetTextInputOrigin(widget: Widget, tokens: DesignTokens, text_size: f32, inset: f32, options: TextLayoutOptions) geometry.PointF {
|
|
261
|
+
if (tokens.control_geometry_policy != null) {
|
|
262
|
+
var request = control_content.Request.init(.input_origin, widget.frame, tokens);
|
|
263
|
+
request.float(52, text_size);
|
|
264
|
+
request.float(56, inset);
|
|
265
|
+
if (widget.runtime_flags.code_editor) {
|
|
266
|
+
request.flags(4);
|
|
267
|
+
request.float(64, widgetTextInputHorizontalScrollOffset(widget, tokens, text_size, inset, options));
|
|
268
|
+
request.float(68, widgetTextInputScrollOffset(widget, tokens, text_size, inset, options));
|
|
269
|
+
} else if (options.wrap != .none) {
|
|
270
|
+
request.flags(8);
|
|
271
|
+
request.float(68, widgetTextInputScrollOffset(widget, tokens, text_size, inset, options));
|
|
272
|
+
request.float(60, widgetTextInputVerticalInset(widget, tokens, text_size, options));
|
|
273
|
+
} else request.float(64, widgetTextInputHorizontalScrollOffset(widget, tokens, text_size, inset, options));
|
|
274
|
+
return request.run(tokens).point;
|
|
275
|
+
}
|
|
246
276
|
if (widget.runtime_flags.code_editor) {
|
|
247
277
|
return geometry.PointF.init(
|
|
248
278
|
widget.frame.x + inset - widgetTextInputHorizontalScrollOffset(widget, tokens, text_size, inset, options),
|
|
@@ -268,7 +298,14 @@ pub fn widgetTextInputOrigin(widget: Widget, tokens: DesignTokens, text_size: f3
|
|
|
268
298
|
|
|
269
299
|
pub fn widgetTextInputClipRect(widget: Widget, tokens: DesignTokens, text_size: f32, inset: f32, options: TextLayoutOptions) geometry.RectF {
|
|
270
300
|
const vertical_inset = widgetTextInputVerticalInset(widget, tokens, text_size, options);
|
|
271
|
-
const trailing_inset = widgetTextInputTrailingInset(widget, text_size, inset);
|
|
301
|
+
const trailing_inset = widgetTextInputTrailingInset(widget, text_size, inset, tokens);
|
|
302
|
+
if (tokens.control_geometry_policy != null) {
|
|
303
|
+
var request = control_content.Request.init(.input_clip, widget.frame, tokens);
|
|
304
|
+
request.float(56, inset);
|
|
305
|
+
request.float(60, vertical_inset);
|
|
306
|
+
request.float(64, trailing_inset);
|
|
307
|
+
return request.run(tokens).rects[0];
|
|
308
|
+
}
|
|
272
309
|
return widget.frame.normalized().deflate(.{
|
|
273
310
|
.top = vertical_inset,
|
|
274
311
|
.right = trailing_inset,
|
|
@@ -291,7 +328,7 @@ pub fn textInputContentExtentForWidget(widget: Widget, tokens: DesignTokens) f32
|
|
|
291
328
|
const text_size = widgetTextInputSize(widget, tokens);
|
|
292
329
|
const text_inset = widgetTextInputInset(widget, tokens);
|
|
293
330
|
const options = widgetTextInputLayoutOptions(widget, tokens, text_size, text_inset);
|
|
294
|
-
const line_height = widgetTextInputLineHeight(text_size);
|
|
331
|
+
const line_height = widgetTextInputLineHeight(text_size, tokens);
|
|
295
332
|
return @as(f32, @floatFromInt(widgetTextInputLineCount(widget, widgetTextInputFontId(widget, tokens), text_size, options))) * line_height;
|
|
296
333
|
}
|
|
297
334
|
|
|
@@ -370,8 +407,9 @@ pub fn textInputCaretVisibleScrollOffsetForWidget(widget: Widget, tokens: Design
|
|
|
370
407
|
@as(usize, @intFromBool(std.mem.lastIndexOfScalar(u8, widget.text[0..caret_offset], '\n') != null))
|
|
371
408
|
else
|
|
372
409
|
0;
|
|
373
|
-
const caret_x =
|
|
410
|
+
const caret_x = measureTextWidthForFontWithPolicy(
|
|
374
411
|
options.measure,
|
|
412
|
+
options.text_run_policy,
|
|
375
413
|
widgetTextInputFontId(widget, tokens),
|
|
376
414
|
widgetTextInputPresentedText(widget)[caret_line_start..caret_offset],
|
|
377
415
|
text_size,
|
|
@@ -403,18 +441,18 @@ pub fn widgetTextInputClipsText(widget: Widget, tokens: DesignTokens, text_size:
|
|
|
403
441
|
const placeholder = widgetPlaceholder(widget);
|
|
404
442
|
if (placeholder.len == 0) return false;
|
|
405
443
|
const viewport = widgetTextInputClipRect(widget, tokens, text_size, text_inset, options);
|
|
406
|
-
return
|
|
444
|
+
return measureTextWidthForFontWithPolicy(options.measure, options.text_run_policy, tokens.typography.font_id, placeholder, text_size) > viewport.width;
|
|
407
445
|
}
|
|
408
446
|
return false;
|
|
409
447
|
}
|
|
410
448
|
|
|
411
449
|
fn widgetTextInputMaxScrollOffset(widget: Widget, tokens: DesignTokens, text_size: f32, text_inset: f32, options: TextLayoutOptions) f32 {
|
|
412
450
|
const viewport = widgetTextInputClipRect(widget, tokens, text_size, text_inset, options);
|
|
413
|
-
return @max(0, textInputContentExtentForWidgetWithOptions(widget, widgetTextInputFontId(widget, tokens), text_size, options) - viewport.height);
|
|
451
|
+
return @max(0, textInputContentExtentForWidgetWithOptions(widget, widgetTextInputFontId(widget, tokens), text_size, options, tokens) - viewport.height);
|
|
414
452
|
}
|
|
415
453
|
|
|
416
|
-
fn textInputContentExtentForWidgetWithOptions(widget: Widget, font_id: FontId, text_size: f32, options: TextLayoutOptions) f32 {
|
|
417
|
-
return @as(f32, @floatFromInt(widgetTextInputLineCount(widget, font_id, text_size, options))) * widgetTextInputLineHeight(text_size);
|
|
454
|
+
fn textInputContentExtentForWidgetWithOptions(widget: Widget, font_id: FontId, text_size: f32, options: TextLayoutOptions, tokens: DesignTokens) f32 {
|
|
455
|
+
return @as(f32, @floatFromInt(widgetTextInputLineCount(widget, font_id, text_size, options))) * widgetTextInputLineHeight(text_size, tokens);
|
|
418
456
|
}
|
|
419
457
|
|
|
420
458
|
fn widgetTextInputLineCount(widget: Widget, font_id: FontId, text_size: f32, options: TextLayoutOptions) usize {
|
|
@@ -476,7 +514,8 @@ fn widgetTextInputFontId(widget: Widget, tokens: DesignTokens) FontId {
|
|
|
476
514
|
return if (widget.runtime_flags.code_editor) tokens.typography.mono_font_id else tokens.typography.font_id;
|
|
477
515
|
}
|
|
478
516
|
|
|
479
|
-
fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32) bool {
|
|
517
|
+
fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32, policy: ?document_policy.Policy) bool {
|
|
518
|
+
if (policy) |owner| return document_policy.cacheDecision(owner, widget, font_id, text_size, false) == 1;
|
|
480
519
|
if (widget.hasCodeDiff()) return false;
|
|
481
520
|
return widget.code_content_width_generation == text_measure_cache.textMeasureGeneration() and
|
|
482
521
|
widget.code_content_width_font_id == font_id and
|
|
@@ -489,12 +528,16 @@ fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32)
|
|
|
489
528
|
/// Runtime reconciliation carries this cache across unchanged app rebuilds;
|
|
490
529
|
/// edits invalidate it before caret scrolling recomputes the new document.
|
|
491
530
|
pub fn cacheTextInputContentWidthForWidget(widget: *Widget, tokens: DesignTokens) void {
|
|
492
|
-
if (
|
|
493
|
-
|
|
531
|
+
if (tokens.text_run_policy) |owner| {
|
|
532
|
+
if (document_policy.cacheDecision(owner, widget.*, 0, 0, true) == 0) return;
|
|
533
|
+
} else {
|
|
534
|
+
if (widget.kind != .textarea or !widget.runtime_flags.code_editor or !widget.text_no_wrap) return;
|
|
535
|
+
if (widget.hasCodeDiff()) return;
|
|
536
|
+
}
|
|
494
537
|
const text_size = widgetTextInputSize(widget.*, tokens);
|
|
495
538
|
const font_id = widgetTextInputFontId(widget.*, tokens);
|
|
496
|
-
if (codeContentWidthCacheCurrent(widget.*, font_id, text_size)) return;
|
|
497
|
-
widget.code_content_width = widestLogicalLineWidth(tokens.text_measure, font_id, widget.text, text_size);
|
|
539
|
+
if (codeContentWidthCacheCurrent(widget.*, font_id, text_size, tokens.text_run_policy)) return;
|
|
540
|
+
widget.code_content_width = widestLogicalLineWidth(tokens.text_measure, tokens.text_run_policy, font_id, widget.text, text_size);
|
|
498
541
|
widget.code_content_width_generation = text_measure_cache.textMeasureGeneration();
|
|
499
542
|
widget.code_content_width_font_id = font_id;
|
|
500
543
|
widget.code_content_width_size_bits = @bitCast(text_size);
|
|
@@ -502,12 +545,14 @@ pub fn cacheTextInputContentWidthForWidget(widget: *Widget, tokens: DesignTokens
|
|
|
502
545
|
|
|
503
546
|
fn widestLogicalLineWidth(
|
|
504
547
|
measure: ?*const text_model.TextMeasureProvider,
|
|
548
|
+
cache_policy: ?*const fn ([]const u8, []u8) usize,
|
|
505
549
|
font_id: FontId,
|
|
506
550
|
text: []const u8,
|
|
507
551
|
text_size: f32,
|
|
508
552
|
) f32 {
|
|
553
|
+
if (cache_policy) |owner| return document_policy.widest(owner, measure, font_id, text, text_size);
|
|
509
554
|
if (measure) |provider| {
|
|
510
|
-
if (widestLogicalLineWidthBatched(provider, font_id, text, text_size)) |width| return width;
|
|
555
|
+
if (widestLogicalLineWidthBatched(provider, cache_policy, font_id, text, text_size)) |width| return width;
|
|
511
556
|
}
|
|
512
557
|
|
|
513
558
|
var widest: f32 = 0;
|
|
@@ -527,6 +572,7 @@ fn widestLogicalLineWidth(
|
|
|
527
572
|
/// the common 10,000-line document takes only a handful of batched calls.
|
|
528
573
|
fn widestLogicalLineWidthBatched(
|
|
529
574
|
provider: *const text_model.TextMeasureProvider,
|
|
575
|
+
cache_policy: ?*const fn ([]const u8, []u8) usize,
|
|
530
576
|
font_id: FontId,
|
|
531
577
|
text: []const u8,
|
|
532
578
|
text_size: f32,
|
|
@@ -558,7 +604,7 @@ fn widestLogicalLineWidthBatched(
|
|
|
558
604
|
}
|
|
559
605
|
|
|
560
606
|
const chunk = text[chunk_start..chunk_end];
|
|
561
|
-
const advances = text_measure_cache.
|
|
607
|
+
const advances = text_measure_cache.textRunAdvancesWithPolicy(provider, cache_policy, font_id, text_size, chunk) orelse return null;
|
|
562
608
|
var line_start: usize = 0;
|
|
563
609
|
for (chunk, 0..) |byte, index| {
|
|
564
610
|
if (byte != '\n') continue;
|
|
@@ -573,7 +619,16 @@ fn widestLogicalLineWidthBatched(
|
|
|
573
619
|
return widest;
|
|
574
620
|
}
|
|
575
621
|
|
|
576
|
-
fn widgetTextInputTrailingInset(widget: Widget, text_size: f32, inset: f32) f32 {
|
|
622
|
+
fn widgetTextInputTrailingInset(widget: Widget, text_size: f32, inset: f32, tokens: DesignTokens) f32 {
|
|
623
|
+
if (tokens.control_geometry_policy != null) {
|
|
624
|
+
var request = control_content.Request.init(.trailing_inset, widget.frame, tokens);
|
|
625
|
+
request.float(52, text_size);
|
|
626
|
+
request.float(56, inset);
|
|
627
|
+
if (widget.runtime_flags.code_editor) request.flags(4);
|
|
628
|
+
if (widget.kind == .combobox) request.flags(8);
|
|
629
|
+
if (widgetTextInputShowsClearButton(widget)) request.flags(16);
|
|
630
|
+
return request.run(tokens).scalar;
|
|
631
|
+
}
|
|
577
632
|
// A code editor's leading inset is its line-number gutter, not symmetric
|
|
578
633
|
// field padding. Its source viewport runs all the way to the trailing
|
|
579
634
|
// edge; mirroring the gutter here invents horizontal overflow for lines
|
|
@@ -604,6 +659,7 @@ pub fn textInputClearButtonRect(widget: Widget, tokens: DesignTokens) ?geometry.
|
|
|
604
659
|
const text_size = widgetTextInputSize(widget, tokens);
|
|
605
660
|
const icon_size = widgetTextInputClearIconSize(text_size);
|
|
606
661
|
const inset = widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.md);
|
|
662
|
+
if (tokens.control_geometry_policy != null) return control_content.text(.clear_icon, widget.frame, text_size, inset, 0, 0, tokens).rects[0];
|
|
607
663
|
return geometry.RectF.init(
|
|
608
664
|
widget.frame.x + widget.frame.width - inset - icon_size,
|
|
609
665
|
widget.frame.y + @max(0, (widget.frame.height - icon_size) * 0.5),
|
|
@@ -618,6 +674,12 @@ pub fn textInputClearButtonRect(widget: Widget, tokens: DesignTokens) ?geometry.
|
|
|
618
674
|
pub fn textInputClearButtonHitRect(widget: Widget, tokens: DesignTokens) ?geometry.RectF {
|
|
619
675
|
const icon = textInputClearButtonRect(widget, tokens) orelse return null;
|
|
620
676
|
const pad = tokens.spacing.sm;
|
|
677
|
+
if (tokens.control_geometry_policy != null) {
|
|
678
|
+
var request = control_content.Request.init(.clear_hit, widget.frame, tokens);
|
|
679
|
+
request.float(60, icon.x);
|
|
680
|
+
request.float(64, pad);
|
|
681
|
+
return request.run(tokens).rects[0];
|
|
682
|
+
}
|
|
621
683
|
const left = @max(widget.frame.x, icon.x - pad);
|
|
622
684
|
return geometry.RectF.init(
|
|
623
685
|
left,
|
|
@@ -715,6 +777,7 @@ fn pixelSnapValueWithScale(value: f32, scale: f32) f32 {
|
|
|
715
777
|
}
|
|
716
778
|
|
|
717
779
|
fn pixelSnapTextPoint(tokens: DesignTokens, point: geometry.PointF) geometry.PointF {
|
|
780
|
+
if (tokens.control_geometry_policy != null) return control_content.point(.text_point, point, tokens);
|
|
718
781
|
if (!tokens.pixel_snap.text) return point;
|
|
719
782
|
const scale = pixelSnapScale(tokens) orelse return point;
|
|
720
783
|
return geometry.PointF.init(
|
|
@@ -122,6 +122,7 @@ fn staticTextLayoutOptions(widget: Widget, tokens: DesignTokens, text_size: f32)
|
|
|
122
122
|
.wrap = .none,
|
|
123
123
|
.alignment = widget.text_alignment,
|
|
124
124
|
.overflow = widget.text_overflow,
|
|
125
|
+
.text_run_policy = tokens.text_run_policy,
|
|
125
126
|
.measure = tokens.text_measure,
|
|
126
127
|
};
|
|
127
128
|
}
|
|
@@ -275,7 +275,8 @@ const disclosure_settle_slack: f32 = 0.5;
|
|
|
275
275
|
|
|
276
276
|
/// The bottom edge the disclosure widget's content REACHES: the deepest
|
|
277
277
|
/// maxY among its in-flow children's subtrees. Window-level surfaces float
|
|
278
|
-
/// outside the flow and never count.
|
|
278
|
+
/// outside the flow and never count. A nested disclosure's own extent
|
|
279
|
+
/// bounds its body, including concealed children laid out below its frame.
|
|
279
280
|
pub fn disclosureContentBottom(layout: anytype, node_index: usize) f32 {
|
|
280
281
|
const node = layout.nodes[node_index];
|
|
281
282
|
var bottom = -std.math.inf(f32);
|
|
@@ -289,6 +290,12 @@ pub fn disclosureContentBottom(layout: anytype, node_index: usize) f32 {
|
|
|
289
290
|
continue;
|
|
290
291
|
}
|
|
291
292
|
bottom = @max(bottom, child.frame.normalized().maxY());
|
|
293
|
+
if (widgetKindDisclosureAnimated(child.widget.kind)) {
|
|
294
|
+
const subtree_depth = child.depth;
|
|
295
|
+
index += 1;
|
|
296
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > subtree_depth) : (index += 1) {}
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
292
299
|
index += 1;
|
|
293
300
|
}
|
|
294
301
|
return bottom;
|
|
@@ -273,7 +273,10 @@ pub const WidgetRuntimeFlags = packed struct(u8) {
|
|
|
273
273
|
/// The runtime installed an OS-native scroll driver; engine-drawn
|
|
274
274
|
/// scrollbar and kinetic physics stand down for this scroll view.
|
|
275
275
|
native_scroll: bool = false,
|
|
276
|
-
|
|
276
|
+
/// The callback accepts tagged scroll requests, independently of an
|
|
277
|
+
/// optional tree role sharing this scroll container's callback slot.
|
|
278
|
+
compiled_scroll_policy: bool = false,
|
|
279
|
+
_reserved: u5 = 0,
|
|
277
280
|
};
|
|
278
281
|
|
|
279
282
|
/// Two 128-line masks for code-only diff presentation. `Widget` packs them
|
|
@@ -901,6 +904,10 @@ pub const WidgetGroupSegment = enum {
|
|
|
901
904
|
};
|
|
902
905
|
|
|
903
906
|
pub const Widget = struct {
|
|
907
|
+
/// Portable appearance resolver installed by compiled views.
|
|
908
|
+
appearance_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
909
|
+
/// Optional portable retained component policy, installed by compiled views.
|
|
910
|
+
interaction_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
904
911
|
id: ObjectId = 0,
|
|
905
912
|
kind: WidgetKind,
|
|
906
913
|
frame: geometry.RectF = .{},
|
|
@@ -1183,6 +1190,9 @@ pub const Widget = struct {
|
|
|
1183
1190
|
};
|
|
1184
1191
|
|
|
1185
1192
|
pub const BuiltinComponentOptions = struct {
|
|
1193
|
+
/// Explicit compiled construction for native toolkit extensions. Ordinary
|
|
1194
|
+
/// TypeScript views receive the same owner through their Ui builder.
|
|
1195
|
+
construction_policy: ?@import("component_construction_policy.zig").Policy = null,
|
|
1186
1196
|
id: ObjectId = 0,
|
|
1187
1197
|
frame: geometry.RectF = .{},
|
|
1188
1198
|
opacity: f32 = 1,
|
|
@@ -1232,6 +1242,7 @@ pub const BuiltinSurfacePlacementOptions = struct {
|
|
|
1232
1242
|
bounds: geometry.RectF,
|
|
1233
1243
|
preferred_size: geometry.SizeF = .{},
|
|
1234
1244
|
margin: f32 = 24,
|
|
1245
|
+
surface_layout_policy: ?@import("surface_layout_policy.zig").Policy = null,
|
|
1235
1246
|
};
|
|
1236
1247
|
|
|
1237
1248
|
/// The input-catcher behind a modal surface: a full-bounds panel whose
|
|
@@ -1272,10 +1283,9 @@ pub const BuiltinSurfaceEnterAnimationOptions = struct {
|
|
|
1272
1283
|
};
|
|
1273
1284
|
|
|
1274
1285
|
pub fn builtinComponentWidget(kind: BuiltinComponentKind, options: BuiltinComponentOptions) Widget {
|
|
1275
|
-
|
|
1276
|
-
return .{
|
|
1286
|
+
var widget: Widget = .{
|
|
1277
1287
|
.id = options.id,
|
|
1278
|
-
.kind =
|
|
1288
|
+
.kind = .stack,
|
|
1279
1289
|
.frame = options.frame,
|
|
1280
1290
|
.opacity = options.opacity,
|
|
1281
1291
|
.transform = options.transform,
|
|
@@ -1296,13 +1306,24 @@ pub fn builtinComponentWidget(kind: BuiltinComponentKind, options: BuiltinCompon
|
|
|
1296
1306
|
.layer = options.layer,
|
|
1297
1307
|
.scrim = options.scrim,
|
|
1298
1308
|
.state = options.state,
|
|
1299
|
-
.layout =
|
|
1300
|
-
.variant =
|
|
1301
|
-
.size =
|
|
1309
|
+
.layout = options.layout,
|
|
1310
|
+
.variant = .default,
|
|
1311
|
+
.size = .default,
|
|
1302
1312
|
.style = options.style,
|
|
1303
|
-
.semantics =
|
|
1313
|
+
.semantics = options.semantics,
|
|
1304
1314
|
.children = options.children,
|
|
1305
1315
|
};
|
|
1316
|
+
if (options.construction_policy) |policy| {
|
|
1317
|
+
@import("component_construction_policy.zig").builtin(policy, kind, &widget, options);
|
|
1318
|
+
} else {
|
|
1319
|
+
const descriptor = builtinComponentDescriptor(kind);
|
|
1320
|
+
widget.kind = descriptor.root_widget_kind;
|
|
1321
|
+
widget.variant = options.variant orelse builtinComponentDefaultVariant(kind);
|
|
1322
|
+
widget.size = options.size orelse builtinComponentDefaultSize(kind);
|
|
1323
|
+
widget.layout = builtinComponentLayout(kind, widget.size, options.layout);
|
|
1324
|
+
widget.semantics = builtinComponentSemantics(descriptor, options.semantics);
|
|
1325
|
+
}
|
|
1326
|
+
return widget;
|
|
1306
1327
|
}
|
|
1307
1328
|
|
|
1308
1329
|
pub fn widgetCommandPartId(part: WidgetCommandPart) ObjectId {
|
|
@@ -1351,6 +1372,14 @@ pub fn builtinStatusBarWidget(options: BuiltinStatusBarOptions) Widget {
|
|
|
1351
1372
|
}
|
|
1352
1373
|
|
|
1353
1374
|
pub fn builtinSurfaceFrame(kind: BuiltinComponentKind, options: BuiltinSurfacePlacementOptions) ?geometry.RectF {
|
|
1375
|
+
if (options.surface_layout_policy) |policy| {
|
|
1376
|
+
return @import("surface_layout_policy.zig").frame(policy, 0, switch (kind) {
|
|
1377
|
+
.dialog => 0,
|
|
1378
|
+
.drawer => 1,
|
|
1379
|
+
.sheet => 2,
|
|
1380
|
+
else => 255,
|
|
1381
|
+
}, 0, &.{ options.bounds.x, options.bounds.y, options.bounds.width, options.bounds.height, options.preferred_size.width, options.preferred_size.height, 0, 0, 0, 0, 0, 0, options.margin });
|
|
1382
|
+
}
|
|
1354
1383
|
const bounds = options.bounds.normalized();
|
|
1355
1384
|
if (bounds.isEmpty()) return null;
|
|
1356
1385
|
|
|
@@ -1647,11 +1676,12 @@ fn mergeLayoutDefaults(explicit: WidgetLayoutStyle, defaults: WidgetLayoutStyle)
|
|
|
1647
1676
|
return merged;
|
|
1648
1677
|
}
|
|
1649
1678
|
|
|
1650
|
-
test "Widget keeps the retained
|
|
1679
|
+
test "Widget keeps the reviewed retained footprint with portable component and appearance policies" {
|
|
1651
1680
|
// One layout tree holds thousands of Widgets by value. On the 64-bit
|
|
1652
|
-
// targets that run the renderer,
|
|
1653
|
-
//
|
|
1681
|
+
// targets that run the renderer, 792 bytes is the reviewed footprint:
|
|
1682
|
+
// the 776-byte native widget plus two optional 8-byte policy callbacks.
|
|
1683
|
+
// The callbacks borrow compiled code, with no per-widget allocation.
|
|
1654
1684
|
if (@sizeOf(usize) == 8) {
|
|
1655
|
-
try std.testing.expectEqual(@as(usize,
|
|
1685
|
+
try std.testing.expectEqual(@as(usize, 792), @sizeOf(Widget));
|
|
1656
1686
|
}
|
|
1657
1687
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const geometry = @import("geometry");
|
|
3
|
+
const widgets = @import("widgets.zig");
|
|
4
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
5
|
+
|
|
6
|
+
pub const Mode = enum(u32) { fallback, paragraph, column, overlay, alert, accordion, row, accordion_content };
|
|
7
|
+
pub const Action = enum(u32) { fallback, authored, paragraph, children, header };
|
|
8
|
+
pub const Options = struct {
|
|
9
|
+
kind: widgets.WidgetKind,
|
|
10
|
+
spans: bool = false,
|
|
11
|
+
virtualized: bool = false,
|
|
12
|
+
titled: bool = false,
|
|
13
|
+
open: bool = false,
|
|
14
|
+
variable_row: bool = false,
|
|
15
|
+
depth: usize = 0,
|
|
16
|
+
depth_limit: usize = 32,
|
|
17
|
+
width: f32,
|
|
18
|
+
authored_height: f32 = 0,
|
|
19
|
+
min_height: f32 = 0,
|
|
20
|
+
max_height: f32 = 0,
|
|
21
|
+
padding: geometry.InsetsF = .{},
|
|
22
|
+
gap: f32 = 0,
|
|
23
|
+
title_height: f32 = 0,
|
|
24
|
+
indent: f32 = 0,
|
|
25
|
+
floor: f32 = 0,
|
|
26
|
+
inset: f32 = 0,
|
|
27
|
+
title_gap: f32 = 0,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/// Requests and copied results remain native-owned across recursive text
|
|
31
|
+
/// measurements. The policy never resets the enclosing app/view arena.
|
|
32
|
+
pub const Plan = struct {
|
|
33
|
+
allocator: std.mem.Allocator,
|
|
34
|
+
policy: Policy,
|
|
35
|
+
request: []u8,
|
|
36
|
+
result: []u8,
|
|
37
|
+
count: usize,
|
|
38
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, count: usize, options: Options) !Plan {
|
|
39
|
+
const request = try allocator.alloc(u8, 80 + count * 16);
|
|
40
|
+
errdefer allocator.free(request);
|
|
41
|
+
const result = try allocator.alloc(u8, 20 + count * 8);
|
|
42
|
+
@memset(request, 0);
|
|
43
|
+
request[0] = 7;
|
|
44
|
+
request[2] = @intCast(widgets.widgetKindCode(options.kind));
|
|
45
|
+
request[3] = @as(u8, if (options.spans) 1 else 0) | @as(u8, if (options.virtualized) 2 else 0) | @as(u8, if (options.titled) 4 else 0) | @as(u8, if (options.open) 8 else 0) | @as(u8, if (options.variable_row) 16 else 0);
|
|
46
|
+
std.mem.writeInt(u32, request[4..8], std.math.cast(u32, count) orelse @panic("wrapped child count exceeds wire range"), .little);
|
|
47
|
+
std.mem.writeInt(u32, request[8..12], std.math.cast(u32, options.depth) orelse @panic("wrapped depth exceeds wire range"), .little);
|
|
48
|
+
std.mem.writeInt(u32, request[12..16], std.math.cast(u32, options.depth_limit) orelse @panic("wrapped depth limit exceeds wire range"), .little);
|
|
49
|
+
const values = [_]f32{ options.width, options.authored_height, options.min_height, options.max_height, options.padding.left, options.padding.right, options.padding.top, options.padding.bottom, options.gap, options.title_height, options.indent, options.floor, 0, 0, options.inset, options.title_gap };
|
|
50
|
+
for (values, 0..) |value, i| put(request[16 + i * 4 ..][0..4], value);
|
|
51
|
+
return .{ .allocator = allocator, .policy = policy, .request = request, .result = result, .count = count };
|
|
52
|
+
}
|
|
53
|
+
pub fn deinit(self: Plan) void {
|
|
54
|
+
self.allocator.free(self.result);
|
|
55
|
+
self.allocator.free(self.request);
|
|
56
|
+
}
|
|
57
|
+
pub fn setChild(self: Plan, index: usize, authored_width: f32, bubble: bool) void {
|
|
58
|
+
const bytes = self.request[80 + index * 16 ..][0..16];
|
|
59
|
+
std.mem.writeInt(u32, bytes[0..4], 1 | @as(u32, if (bubble) 2 else 0), .little);
|
|
60
|
+
put(bytes[4..8], authored_width);
|
|
61
|
+
}
|
|
62
|
+
pub fn resolveWidth(self: Plan, index: usize, value: f32) void {
|
|
63
|
+
const bytes = self.request[80 + index * 16 ..][0..16];
|
|
64
|
+
std.mem.writeInt(u32, bytes[0..4], std.mem.readInt(u32, bytes[0..4], .little) | 4, .little);
|
|
65
|
+
put(bytes[8..12], value);
|
|
66
|
+
}
|
|
67
|
+
pub fn setHeight(self: Plan, index: usize, value: f32) void {
|
|
68
|
+
put(self.request[92 + index * 16 ..][0..4], value);
|
|
69
|
+
}
|
|
70
|
+
pub fn setParagraph(self: Plan, value: f32) void {
|
|
71
|
+
put(self.request[64..68], value);
|
|
72
|
+
}
|
|
73
|
+
pub fn setFallback(self: Plan, value: f32) void {
|
|
74
|
+
put(self.request[68..72], value);
|
|
75
|
+
}
|
|
76
|
+
pub fn run(self: Plan, operation: u8) void {
|
|
77
|
+
self.request[1] = operation;
|
|
78
|
+
if (self.policy(self.request, self.result) != self.result.len or std.mem.readInt(u32, self.result[0..4], .little) != self.count) @panic("invalid compiled wrapped plan");
|
|
79
|
+
}
|
|
80
|
+
pub fn action(self: Plan) Action {
|
|
81
|
+
return @enumFromInt(std.mem.readInt(u32, self.result[4..8], .little));
|
|
82
|
+
}
|
|
83
|
+
pub fn mode(self: Plan) Mode {
|
|
84
|
+
return @enumFromInt(std.mem.readInt(u32, self.result[16..20], .little));
|
|
85
|
+
}
|
|
86
|
+
pub fn innerWidth(self: Plan) f32 {
|
|
87
|
+
return get(self.result[8..12]);
|
|
88
|
+
}
|
|
89
|
+
pub fn height(self: Plan) f32 {
|
|
90
|
+
return get(self.result[12..16]);
|
|
91
|
+
}
|
|
92
|
+
pub fn width(self: Plan, index: usize) f32 {
|
|
93
|
+
return get(self.result[20 + index * 8 ..][0..4]);
|
|
94
|
+
}
|
|
95
|
+
pub fn query(self: Plan, index: usize) u32 {
|
|
96
|
+
return std.mem.readInt(u32, self.result[24 + index * 8 ..][0..4], .little);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
fn put(bytes: *[4]u8, value: f32) void {
|
|
100
|
+
std.mem.writeInt(u32, bytes, @bitCast(value), .little);
|
|
101
|
+
}
|
|
102
|
+
fn get(bytes: *const [4]u8) f32 {
|
|
103
|
+
return @bitCast(std.mem.readInt(u32, bytes, .little));
|
|
104
|
+
}
|