@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
|
@@ -2825,6 +2825,10 @@ test "widget focus target lookup validates focusable ids" {
|
|
|
2825
2825
|
try std.testing.expect(layout.focusTargetById(4) == null);
|
|
2826
2826
|
try std.testing.expect(layout.focusTargetById(99) == null);
|
|
2827
2827
|
|
|
2828
|
+
for (layout.nodes, 0..) |node, index| {
|
|
2829
|
+
try std.testing.expectEqualDeep(layout.focusTargetById(node.widget.id), layout.focusTargetAtIndex(index));
|
|
2830
|
+
}
|
|
2831
|
+
try std.testing.expect(layout.focusTargetAtIndex(layout.nodes.len) == null);
|
|
2828
2832
|
const target = layout.focusTargetById(3).?;
|
|
2829
2833
|
try std.testing.expectEqual(@as(ObjectId, 3), target.id);
|
|
2830
2834
|
try std.testing.expectEqual(WidgetKind.button, target.kind);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//! Copied metric plans; font and paragraph measurement are explicit capabilities.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const tokens_model = @import("tokens.zig");
|
|
5
|
+
const widgets = @import("widgets.zig");
|
|
6
|
+
const text = @import("text.zig");
|
|
7
|
+
const spans = @import("text_spans.zig");
|
|
8
|
+
pub const reference = @import("widget_metrics.zig");
|
|
9
|
+
pub const Operation = enum(u8) { button, body, label, badge, typography, line, wrap, gutter, aligned_frame, content_frame, height, button_icon, button_gap, badge_icon, badge_gap, row_icon, row_gap, row_height, button_inset, inset, alert_inset, tab_text, tab_height, tab_inset, tab_icon, tab_gap, tab_list, sized_density, sized_token, size_scale, density, density_scale, intrinsic };
|
|
10
|
+
fn word(b: []u8, at: usize, value: u32) void {
|
|
11
|
+
std.mem.writeInt(u32, b[at..][0..4], value, .little);
|
|
12
|
+
}
|
|
13
|
+
fn read(b: []const u8, at: usize) u32 {
|
|
14
|
+
return std.mem.readInt(u32, b[at..][0..4], .little);
|
|
15
|
+
}
|
|
16
|
+
fn float(b: []const u8, at: usize) f32 {
|
|
17
|
+
return @bitCast(read(b, at));
|
|
18
|
+
}
|
|
19
|
+
pub const Result = struct {
|
|
20
|
+
bytes: [32]u8,
|
|
21
|
+
pub fn scalar(self: Result) f32 {
|
|
22
|
+
return float(&self.bytes, 8);
|
|
23
|
+
}
|
|
24
|
+
pub fn size(self: Result) ?geometry.SizeF {
|
|
25
|
+
return if (read(&self.bytes, 4) == 4) null else .init(float(&self.bytes, 12), float(&self.bytes, 16));
|
|
26
|
+
}
|
|
27
|
+
pub fn rect(self: Result) geometry.RectF {
|
|
28
|
+
return .init(float(&self.bytes, 8), float(&self.bytes, 12), float(&self.bytes, 16), float(&self.bytes, 20));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
pub const Request = struct {
|
|
32
|
+
bytes: [224]u8 = @splat(0),
|
|
33
|
+
pub fn init(op: Operation, widget: widgets.Widget, tokens: tokens_model.DesignTokens, base: f32) Request {
|
|
34
|
+
var self: Request = .{};
|
|
35
|
+
self.bytes[0..9].* = .{ 32, 1, @intFromEnum(op), @import("render_plan_policy.zig").numericFlags(), @intFromEnum(widget.size), @intFromEnum(tokens.density), @intFromEnum(tokens.controls.tabs_indicator), @intFromEnum(widget.kind), @import("control_geometry_policy.zig").signalingFlags() };
|
|
36
|
+
const flags: u32 = @as(u32, @intFromBool(widget.text.len > 0)) | (@as(u32, @intFromBool(widget.icon.len > 0)) << 1) | (@as(u32, @intFromBool(widget.spans.len > 0)) << 2) | (@as(u32, @intFromBool(widget.layout.zero_intrinsic)) << 3) | (@as(u32, @intFromBool(widget.hasCodeDiff())) << 4) | (@as(u32, @intFromBool(tokens.pixel_snap.geometry)) << 7);
|
|
37
|
+
word(&self.bytes, 12, flags);
|
|
38
|
+
self.put(16, base);
|
|
39
|
+
inline for (.{ "body_size", "label_size", "button_size", "heading_size", "display_size", "title_size" }, 0..) |name, i| self.put(20 + i * 4, @field(tokens.typography, name));
|
|
40
|
+
inline for (.{ "control_height_sm", "control_height", "control_height_lg", "button_inset_sm", "button_inset", "button_inset_lg", "button_label_sm_step", "button_label_lg_step", "button_icon_gap", "icon_text_step", "row_extent", "size_inset_step", "tabs_label_size_step", "tabs_trigger_height", "tabs_trigger_inset", "tabs_list_inset" }, 0..) |name, i| self.put(44 + i * 4, @field(tokens.metrics, name));
|
|
41
|
+
inline for (.{ "sm", "md", "lg", "xs" }, 0..) |name, i| self.put(108 + i * 4, @field(tokens.spacing, name));
|
|
42
|
+
self.put(124, tokens.pixel_snap.scale);
|
|
43
|
+
self.frame(widget.frame);
|
|
44
|
+
inline for (.{ "left", "right", "top", "bottom" }, 0..) |name, i| self.put(152 + i * 4, @field(widget.layout.padding, name));
|
|
45
|
+
word(&self.bytes, 176, widget.codeLineNumberDigits());
|
|
46
|
+
word(&self.bytes, 180, std.math.cast(u32, widget.children.len) orelse @panic("widget metric child count exceeds wire range"));
|
|
47
|
+
self.put(188, widget.layout.min_size.width);
|
|
48
|
+
self.put(192, widget.layout.min_size.height);
|
|
49
|
+
self.put(196, widget.layout.gap);
|
|
50
|
+
return self;
|
|
51
|
+
}
|
|
52
|
+
pub fn put(self: *Request, at: usize, value: f32) void {
|
|
53
|
+
word(&self.bytes, at, @bitCast(value));
|
|
54
|
+
}
|
|
55
|
+
pub fn frame(self: *Request, value: geometry.RectF) void {
|
|
56
|
+
inline for (.{ "x", "y", "width", "height" }, 0..) |name, i| self.put(128 + i * 4, @field(value, name));
|
|
57
|
+
}
|
|
58
|
+
pub fn run(self_: Request, widget: widgets.Widget, tokens: tokens_model.DesignTokens) Result {
|
|
59
|
+
var self = self_;
|
|
60
|
+
const policy = tokens.control_geometry_policy orelse @panic("missing widget metric owner");
|
|
61
|
+
for (0..3) |_| {
|
|
62
|
+
var copied: Result = .{ .bytes = @splat(0xa5) };
|
|
63
|
+
if (policy(&self.bytes, &copied.bytes) != copied.bytes.len or read(&copied.bytes, 0) != 1) @panic("invalid compiled widget metric length");
|
|
64
|
+
const mode = read(&copied.bytes, 4);
|
|
65
|
+
const ranges: []const [2]usize = switch (mode) {
|
|
66
|
+
1 => &.{.{ 12, 32 }},
|
|
67
|
+
2 => &.{ .{ 8, 12 }, .{ 20, 32 } },
|
|
68
|
+
3 => &.{ .{ 8, 12 }, .{ 16, 20 } },
|
|
69
|
+
4 => &.{.{ 8, 32 }},
|
|
70
|
+
5 => &.{.{ 24, 32 }},
|
|
71
|
+
else => @panic("invalid compiled widget metric presence"),
|
|
72
|
+
};
|
|
73
|
+
for (ranges) |range| if (!std.mem.allEqual(u8, copied.bytes[range[0]..range[1]], 0)) @panic("invalid compiled absent widget metric fields");
|
|
74
|
+
const op: Operation = @enumFromInt(self.bytes[2]);
|
|
75
|
+
if (mode != 3) {
|
|
76
|
+
const expected: u32 = switch (op) {
|
|
77
|
+
.intrinsic => if (mode == 4) 4 else 2,
|
|
78
|
+
.aligned_frame, .content_frame => 5,
|
|
79
|
+
else => 1,
|
|
80
|
+
};
|
|
81
|
+
if (mode != expected) @panic("invalid compiled widget metric operation result");
|
|
82
|
+
return copied;
|
|
83
|
+
}
|
|
84
|
+
const capability = read(&copied.bytes, 20);
|
|
85
|
+
const count = read(&copied.bytes, 28);
|
|
86
|
+
const size = float(&copied.bytes, 24);
|
|
87
|
+
const flags = read(&self.bytes, 12);
|
|
88
|
+
if (capability != 3 and !std.mem.allEqual(u8, copied.bytes[12..16], 0)) @panic("invalid absent measurement width");
|
|
89
|
+
if (capability > 4 or (capability != 4 and count != 0) or (capability == 4 and (count == 0 or count > 20))) @panic("invalid widget measurement descriptor");
|
|
90
|
+
if (capability == 3) {
|
|
91
|
+
if ((op != .aligned_frame and op != .content_frame) or flags & 64 != 0) @panic("invalid widget paragraph continuation");
|
|
92
|
+
var runs: [spans.max_text_span_runs_per_paragraph]spans.TextSpanRun = undefined;
|
|
93
|
+
const laid = spans.layoutTextSpans(widget.spans, .{ .size = size, .max_width = float(&copied.bytes, 12), .wrap = if (widget.text_no_wrap) .none else .word, .alignment = widget.text_alignment, .typography = tokens.typography, .measure = tokens.text_measure, .text_run_policy = tokens.text_run_policy }, &runs);
|
|
94
|
+
self.put(148, laid.size.height);
|
|
95
|
+
word(&self.bytes, 12, flags | 64);
|
|
96
|
+
} else {
|
|
97
|
+
if (flags & 32 != 0 or (op != .intrinsic and op != .gutter and op != .content_frame) or (capability != 4 and op != .intrinsic)) @panic("invalid widget font continuation");
|
|
98
|
+
if (capability == 2) {
|
|
99
|
+
self.put(144, spans.textSpansIntrinsicWidth(widget.spans, .{ .size = size, .max_width = 0, .wrap = if (widget.text_no_wrap) .none else .word, .alignment = widget.text_alignment, .typography = tokens.typography, .measure = tokens.text_measure, .text_run_policy = tokens.text_run_policy }));
|
|
100
|
+
self.put(172, spans.textSpansMaxScale(widget.spans));
|
|
101
|
+
self.put(168, @import("widget_metrics.zig").widgetCodeLineNumberGutterWidth(widget, tokens));
|
|
102
|
+
} else {
|
|
103
|
+
const zeros: [20]u8 = @splat('0');
|
|
104
|
+
const font = if (capability == 1) tokens.typography.buttonFontId() else if (capability == 4) tokens.typography.mono_font_id else tokens.typography.font_id;
|
|
105
|
+
self.put(144, text.measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, font, if (capability == 4) zeros[0..count] else widget.text, size));
|
|
106
|
+
}
|
|
107
|
+
word(&self.bytes, 12, flags | 32);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
@panic("incomplete widget metric measurement");
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
pub fn scalar(op: Operation, widget: widgets.Widget, tokens: tokens_model.DesignTokens, base: f32) f32 {
|
|
114
|
+
return Request.init(op, widget, tokens, base).run(widget, tokens).scalar();
|
|
115
|
+
}
|
|
116
|
+
pub fn frame(op: Operation, widget: widgets.Widget, tokens: tokens_model.DesignTokens, value: geometry.RectF) geometry.RectF {
|
|
117
|
+
if (op == .content_frame) std.debug.assert(!value.hasNegativeSize());
|
|
118
|
+
var request = Request.init(op, widget, tokens, 0);
|
|
119
|
+
request.frame(value);
|
|
120
|
+
return request.run(widget, tokens).rect();
|
|
121
|
+
}
|
|
122
|
+
pub fn intrinsic(widget: widgets.Widget, tokens: tokens_model.DesignTokens) ?geometry.SizeF {
|
|
123
|
+
var request = Request.init(.intrinsic, widget, tokens, 0);
|
|
124
|
+
if (widget.kind == .separator) request.put(184, @import("widget_render_style.zig").controlStrokeWidth(widget, @import("widget_render_style.zig").componentControlVisualTokens(widget, tokens), tokens.stroke.hairline));
|
|
125
|
+
return request.run(widget, tokens).size();
|
|
126
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const policy = @import("widget_metric_policy.zig");
|
|
1
2
|
const std = @import("std");
|
|
2
3
|
const geometry = @import("geometry");
|
|
3
4
|
const token_model = @import("tokens.zig");
|
|
@@ -20,6 +21,7 @@ const Widget = widget_model.Widget;
|
|
|
20
21
|
/// approximation. Packs with a large-button type rung state a positive
|
|
21
22
|
/// lg step.
|
|
22
23
|
pub fn widgetButtonTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
24
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.button, widget, tokens, 0);
|
|
23
25
|
return switch (widget.size) {
|
|
24
26
|
.sm => @max(8, tokens.typography.button_size - tokens.metrics.button_label_sm_step),
|
|
25
27
|
.lg => @max(8, tokens.typography.button_size + tokens.metrics.button_label_lg_step),
|
|
@@ -28,6 +30,7 @@ pub fn widgetButtonTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
pub fn widgetBodyTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
33
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.body, widget, tokens, 0);
|
|
31
34
|
// heading/display are typography-token rungs, honored on text leaves
|
|
32
35
|
// only: they REPLACE the body base with the named token instead of
|
|
33
36
|
// stepping it, so the whole type scale stays themable through
|
|
@@ -43,17 +46,19 @@ pub fn widgetBodyTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
43
46
|
else => {},
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
return
|
|
49
|
+
return widgetTypographySizeWithTokens(widget, tokens.typography.body_size, tokens);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
pub fn widgetLabelTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
50
|
-
return
|
|
53
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.label, widget, tokens, 0);
|
|
54
|
+
return widgetTypographySizeWithTokens(widget, tokens.typography.label_size, tokens);
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/// Badge text sits one rung below the label size (12 on the default
|
|
54
58
|
/// scale) — the compact chip register.
|
|
55
59
|
pub fn widgetBadgeTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
56
|
-
return
|
|
60
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.badge, widget, tokens, 0);
|
|
61
|
+
return widgetTypographySizeWithTokens(widget, @max(8, tokens.typography.label_size - 1), tokens);
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
pub fn widgetTypographySize(widget: Widget, base: f32) f32 {
|
|
@@ -88,6 +93,7 @@ pub fn widgetLineHeight(text_size: f32) f32 {
|
|
|
88
93
|
/// the smallest real overflow (a glyph), so genuinely overflowing text
|
|
89
94
|
/// still elides and any admitted overhang stays sub-pixel-scale.
|
|
90
95
|
pub fn textWrapMaxWidth(tokens: DesignTokens, width: f32) f32 {
|
|
96
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.wrap, .{ .kind = .text }, tokens, width);
|
|
91
97
|
if (!tokens.pixel_snap.geometry) return width;
|
|
92
98
|
const scale = tokens.pixel_snap.scale;
|
|
93
99
|
if (!std.math.isFinite(scale) or scale <= 0) return width;
|
|
@@ -109,6 +115,8 @@ pub fn widgetTextSpanLayoutOptions(widget: Widget, tokens: DesignTokens, max_wid
|
|
|
109
115
|
.alignment = widget.text_alignment,
|
|
110
116
|
.typography = tokens.typography,
|
|
111
117
|
.measure = tokens.text_measure,
|
|
118
|
+
.text_run_policy = tokens.text_run_policy,
|
|
119
|
+
.paragraph_policy = tokens.paragraph_policy,
|
|
112
120
|
};
|
|
113
121
|
}
|
|
114
122
|
|
|
@@ -119,6 +127,7 @@ const min_code_line_number_digits: usize = 3;
|
|
|
119
127
|
/// keeps one +/- column. Marker bytes never live in `Widget.text`; paint
|
|
120
128
|
/// selects them from a compile-time table.
|
|
121
129
|
pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32 {
|
|
130
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.gutter, widget, tokens, 0);
|
|
122
131
|
const has_diff = widget.hasCodeDiff();
|
|
123
132
|
const line_number_digits = widget.codeLineNumberDigits();
|
|
124
133
|
if (line_number_digits == 0 and !has_diff) return 0;
|
|
@@ -130,8 +139,9 @@ pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32
|
|
|
130
139
|
@max(@as(usize, line_number_digits), min_code_line_number_digits),
|
|
131
140
|
zeros.len,
|
|
132
141
|
);
|
|
133
|
-
return text_model.
|
|
142
|
+
return text_model.measureTextWidthForFontWithPolicy(
|
|
134
143
|
tokens.text_measure,
|
|
144
|
+
tokens.text_run_policy,
|
|
135
145
|
tokens.typography.mono_font_id,
|
|
136
146
|
zeros[0..digits],
|
|
137
147
|
widgetBodyTextSize(widget, tokens),
|
|
@@ -143,6 +153,7 @@ pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32
|
|
|
143
153
|
/// keeps a short text-only cell aligned with image-bearing or wrapped peers.
|
|
144
154
|
/// Other paragraph kinds keep their normal top-aligned document flow.
|
|
145
155
|
pub fn widgetTextSpanAlignedContentFrame(widget: Widget, content_in: geometry.RectF, tokens: DesignTokens) geometry.RectF {
|
|
156
|
+
if (tokens.control_geometry_policy != null) return policy.frame(.aligned_frame, widget, tokens, content_in);
|
|
146
157
|
if (widget.kind != .data_cell or widget.spans.len == 0 or content_in.height <= 0) return content_in;
|
|
147
158
|
var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
|
|
148
159
|
const layout = text_spans_model.layoutTextSpans(
|
|
@@ -160,6 +171,7 @@ pub fn widgetTextSpanAlignedContentFrame(widget: Widget, content_in: geometry.Re
|
|
|
160
171
|
/// and selection all use this exact frame so numbered source and cell links
|
|
161
172
|
/// stay one coherent text model.
|
|
162
173
|
pub fn widgetTextSpanContentFrame(widget: Widget, tokens: DesignTokens) geometry.RectF {
|
|
174
|
+
if (tokens.control_geometry_policy != null) return policy.frame(.content_frame, widget, tokens, widget.frame);
|
|
163
175
|
var content = widget.frame.inset(widget.layout.padding);
|
|
164
176
|
const gutter = @min(content.width, widgetCodeLineNumberGutterWidth(widget, tokens));
|
|
165
177
|
content.x += gutter;
|
|
@@ -178,6 +190,7 @@ pub fn widgetTextSpanContentFrame(widget: Widget, tokens: DesignTokens) geometry
|
|
|
178
190
|
/// one-toolbar-row invariant this ladder exists for. The `icon` size is
|
|
179
191
|
/// the default square.
|
|
180
192
|
pub fn widgetControlHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
193
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.height, widget, tokens, 0);
|
|
181
194
|
const base: f32 = switch (widget.size) {
|
|
182
195
|
.sm => tokens.metrics.control_height_sm,
|
|
183
196
|
.default, .icon, .heading, .display => tokens.metrics.control_height,
|
|
@@ -192,6 +205,7 @@ pub fn widgetControlHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
192
205
|
/// Shared by intrinsic layout and render so measured widths and painted
|
|
193
206
|
/// pixels agree.
|
|
194
207
|
pub fn widgetButtonIconExtent(widget: Widget, tokens: DesignTokens) f32 {
|
|
208
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.button_icon, widget, tokens, 0);
|
|
195
209
|
return widgetButtonTextSize(widget, tokens) + tokens.metrics.icon_text_step;
|
|
196
210
|
}
|
|
197
211
|
|
|
@@ -201,18 +215,20 @@ pub fn widgetButtonIconExtent(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
201
215
|
/// widens with the size ladder; a bigger button earns more air at its
|
|
202
216
|
/// edges (the inset), not inside its own label.
|
|
203
217
|
pub fn widgetButtonIconGap(widget: Widget, tokens: DesignTokens) f32 {
|
|
204
|
-
|
|
218
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.button_gap, widget, tokens, 0);
|
|
205
219
|
return densityValue(tokens, tokens.metrics.button_icon_gap);
|
|
206
220
|
}
|
|
207
221
|
|
|
208
222
|
/// Extent of a vector icon inside a badge (`widget.icon`): sized just
|
|
209
223
|
/// above the badge's label text. Shared by intrinsic layout and render.
|
|
210
224
|
pub fn widgetBadgeIconExtent(widget: Widget, tokens: DesignTokens) f32 {
|
|
225
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.badge_icon, widget, tokens, 0);
|
|
211
226
|
return widgetLabelTextSize(widget, tokens) + tokens.metrics.icon_text_step;
|
|
212
227
|
}
|
|
213
228
|
|
|
214
229
|
/// Gap between a badge's inline icon and its label.
|
|
215
230
|
pub fn widgetBadgeIconGap(widget: Widget, tokens: DesignTokens) f32 {
|
|
231
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.badge_gap, widget, tokens, 0);
|
|
216
232
|
return widgetControlInset(widget, tokens, tokens.spacing.sm);
|
|
217
233
|
}
|
|
218
234
|
|
|
@@ -221,15 +237,18 @@ pub fn widgetBadgeIconGap(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
221
237
|
/// icon and label read as one line. Shared by intrinsic layout and
|
|
222
238
|
/// render so measured widths and painted pixels agree.
|
|
223
239
|
pub fn widgetRowIconExtent(widget: Widget, tokens: DesignTokens) f32 {
|
|
240
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.row_icon, widget, tokens, 0);
|
|
224
241
|
return widgetBodyTextSize(widget, tokens) + tokens.metrics.icon_text_step;
|
|
225
242
|
}
|
|
226
243
|
|
|
227
244
|
/// Gap between a row's leading icon and its label.
|
|
228
245
|
pub fn widgetRowIconGap(widget: Widget, tokens: DesignTokens) f32 {
|
|
246
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.row_gap, widget, tokens, 0);
|
|
229
247
|
return widgetControlInset(widget, tokens, tokens.spacing.sm);
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
pub fn widgetDefaultRowHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
251
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.row_height, widget, tokens, 0);
|
|
233
252
|
return widgetSizedDensityValue(widget, tokens, tokens.metrics.row_extent);
|
|
234
253
|
}
|
|
235
254
|
|
|
@@ -244,6 +263,7 @@ pub fn widgetDefaultRowHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
244
263
|
/// `icon`-sized buttons center their glyph in the square and need no
|
|
245
264
|
/// inset.
|
|
246
265
|
pub fn widgetButtonInset(widget: Widget, tokens: DesignTokens) f32 {
|
|
266
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.button_inset, widget, tokens, 0);
|
|
247
267
|
if (widget.size == .icon) return 0;
|
|
248
268
|
const base: f32 = switch (widget.size) {
|
|
249
269
|
.sm => tokens.metrics.button_inset_sm,
|
|
@@ -254,12 +274,14 @@ pub fn widgetButtonInset(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
254
274
|
}
|
|
255
275
|
|
|
256
276
|
pub fn widgetControlInset(widget: Widget, tokens: DesignTokens, base: f32) f32 {
|
|
277
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.inset, widget, tokens, base);
|
|
257
278
|
return densityValue(tokens, widgetSizedTokenValue(widget, tokens, base));
|
|
258
279
|
}
|
|
259
280
|
|
|
260
281
|
/// Alert chrome/content inset: one token-backed metric for rendering,
|
|
261
282
|
/// effective default layout padding, and intrinsic/wrapped measurement.
|
|
262
283
|
pub fn widgetAlertInset(widget: Widget, tokens: DesignTokens) f32 {
|
|
284
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.alert_inset, widget, tokens, 0);
|
|
263
285
|
return widgetControlInset(widget, tokens, tokens.spacing.lg);
|
|
264
286
|
}
|
|
265
287
|
|
|
@@ -268,37 +290,45 @@ pub fn widgetAlertInset(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
268
290
|
/// underline register owns the taller, label-hugging geometry measured
|
|
269
291
|
/// from the Geist primary Tabs component.
|
|
270
292
|
pub fn widgetTabTriggerTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
293
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.tab_text, widget, tokens, 0);
|
|
271
294
|
if (tokens.controls.tabs_indicator == .pill) return widgetLabelTextSize(widget, tokens);
|
|
272
|
-
return
|
|
295
|
+
return widgetTypographySizeWithTokens(widget, @max(8, tokens.typography.label_size + tokens.metrics.tabs_label_size_step), tokens);
|
|
273
296
|
}
|
|
274
297
|
|
|
275
298
|
pub fn widgetTabTriggerHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
299
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.tab_height, widget, tokens, 0);
|
|
276
300
|
if (tokens.controls.tabs_indicator == .pill) return widgetControlHeight(widget, tokens);
|
|
277
301
|
return widgetSizedDensityValue(widget, tokens, @max(0, tokens.metrics.tabs_trigger_height));
|
|
278
302
|
}
|
|
279
303
|
|
|
280
304
|
pub fn widgetTabTriggerInset(widget: Widget, tokens: DesignTokens) f32 {
|
|
305
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.tab_inset, widget, tokens, 0);
|
|
281
306
|
if (tokens.controls.tabs_indicator == .pill) return widgetControlInset(widget, tokens, tokens.spacing.md);
|
|
282
307
|
return widgetControlInset(widget, tokens, @max(0, tokens.metrics.tabs_trigger_inset));
|
|
283
308
|
}
|
|
284
309
|
|
|
285
310
|
pub fn widgetTabTriggerIconExtent(widget: Widget, tokens: DesignTokens) f32 {
|
|
311
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.tab_icon, widget, tokens, 0);
|
|
286
312
|
return widgetTabTriggerTextSize(widget, tokens) + tokens.metrics.icon_text_step;
|
|
287
313
|
}
|
|
288
314
|
|
|
289
315
|
pub fn widgetTabTriggerIconGap(tokens: DesignTokens) f32 {
|
|
316
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.tab_gap, .{ .kind = .text }, tokens, 0);
|
|
290
317
|
return densityValue(tokens, tokens.metrics.button_icon_gap);
|
|
291
318
|
}
|
|
292
319
|
|
|
293
320
|
pub fn underlineTabsListInset(tokens: DesignTokens) f32 {
|
|
321
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.tab_list, .{ .kind = .text }, tokens, 0);
|
|
294
322
|
return densityValue(tokens, @max(0, tokens.metrics.tabs_list_inset));
|
|
295
323
|
}
|
|
296
324
|
|
|
297
325
|
pub fn widgetSizedDensityValue(widget: Widget, tokens: DesignTokens, value: f32) f32 {
|
|
326
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.sized_density, widget, tokens, value);
|
|
298
327
|
return densityValue(tokens, value) * widgetSizeScale(widget);
|
|
299
328
|
}
|
|
300
329
|
|
|
301
330
|
pub fn widgetSizedTokenValue(widget: Widget, tokens: DesignTokens, value: f32) f32 {
|
|
331
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.sized_token, widget, tokens, value);
|
|
302
332
|
return widget_model.widgetSizeSteppedValue(widget.size, value, tokens.metrics.size_inset_step);
|
|
303
333
|
}
|
|
304
334
|
|
|
@@ -311,6 +341,7 @@ pub fn widgetSizeScale(widget: Widget) f32 {
|
|
|
311
341
|
}
|
|
312
342
|
|
|
313
343
|
pub fn densityValue(tokens: DesignTokens, value: f32) f32 {
|
|
344
|
+
if (tokens.control_geometry_policy != null) return policy.scalar(.density, .{ .kind = .text }, tokens, value);
|
|
314
345
|
return value * densityScale(tokens.density);
|
|
315
346
|
}
|
|
316
347
|
|
|
@@ -321,3 +352,11 @@ pub fn densityScale(density: Density) f32 {
|
|
|
321
352
|
.spacious => 1.125,
|
|
322
353
|
};
|
|
323
354
|
}
|
|
355
|
+
|
|
356
|
+
/// Token-aware SDK entry points preserve the legacy pure helper signatures.
|
|
357
|
+
pub fn widgetTypographySizeWithTokens(widget: Widget, base: f32, tokens: DesignTokens) f32 {
|
|
358
|
+
return if (tokens.control_geometry_policy != null) policy.scalar(.typography, widget, tokens, base) else widgetTypographySize(widget, base);
|
|
359
|
+
}
|
|
360
|
+
pub fn widgetLineHeightWithTokens(text_size: f32, tokens: DesignTokens) f32 {
|
|
361
|
+
return if (tokens.control_geometry_policy != null) policy.scalar(.line, .{ .kind = .text }, tokens, text_size) else widgetLineHeight(text_size);
|
|
362
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
//! Copied paint boundary. Portable code owns all damage geometry; native code
|
|
2
|
+
//! supplies requested font measurements and caller-owned result storage.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const geometry = @import("geometry");
|
|
5
|
+
const widgets = @import("widgets.zig");
|
|
6
|
+
const tokens_model = @import("tokens.zig");
|
|
7
|
+
const events = @import("events.zig");
|
|
8
|
+
const changes = @import("widget_change_policy.zig");
|
|
9
|
+
const text_metrics = @import("text_metrics.zig");
|
|
10
|
+
pub const Policy = changes.Policy;
|
|
11
|
+
const missing = std.math.maxInt(u32);
|
|
12
|
+
const header_size = 544;
|
|
13
|
+
const node_size = 128;
|
|
14
|
+
const tables = .{ "button_default", "button_primary", "button_secondary", "button_outline", "button_ghost", "button_destructive", "toggle_button", "accordion", "alert", "bubble", "card", "dialog", "drawer", "sheet", "select", "input", "text_field", "search_field", "combobox", "textarea", "list_item", "menu_item", "data_cell", "tabs", "segmented_control", "button_group", "checkbox", "radio", "switch_control", "slider", "progress", "scrollbar", "panel", "resizable", "popover", "menu_surface", "dropdown_menu", "tooltip", "avatar", "badge", "separator", "skeleton", "spinner" };
|
|
15
|
+
const sizes = [_]widgets.WidgetSize{ .sm, .default, .lg, .icon, .heading, .display };
|
|
16
|
+
pub fn owner(layout: anytype) ?Policy {
|
|
17
|
+
const T = switch (@typeInfo(@TypeOf(layout))) {
|
|
18
|
+
.pointer => |p| p.child,
|
|
19
|
+
else => @TypeOf(layout),
|
|
20
|
+
};
|
|
21
|
+
if (comptime @hasField(T, "paint_policy")) return layout.paint_policy;
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
fn word(bytes: []u8, at: usize, value: usize) void {
|
|
25
|
+
std.mem.writeInt(u32, bytes[at..][0..4], std.math.cast(u32, value) orelse @panic("paint wire capacity"), .little);
|
|
26
|
+
}
|
|
27
|
+
fn read(bytes: []const u8, at: usize) u32 {
|
|
28
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
29
|
+
}
|
|
30
|
+
fn float(bytes: []u8, at: usize, value: f32) void {
|
|
31
|
+
word(bytes, at, @as(u32, @bitCast(value)));
|
|
32
|
+
}
|
|
33
|
+
fn readFloat(bytes: []const u8, at: usize) f32 {
|
|
34
|
+
return @bitCast(read(bytes, at));
|
|
35
|
+
}
|
|
36
|
+
fn rect(bytes: []u8, at: usize, value: geometry.RectF) void {
|
|
37
|
+
inline for (.{ "x", "y", "width", "height" }, 0..) |name, i| float(bytes, at + i * 4, @field(value, name));
|
|
38
|
+
}
|
|
39
|
+
fn optional(bytes: []const u8, at: usize) ?geometry.RectF {
|
|
40
|
+
if (read(bytes, at) == 0) return null;
|
|
41
|
+
return .init(readFloat(bytes, at + 4), readFloat(bytes, at + 8), readFloat(bytes, at + 12), readFloat(bytes, at + 16));
|
|
42
|
+
}
|
|
43
|
+
fn sizeCode(size: widgets.WidgetSize) usize {
|
|
44
|
+
for (sizes, 0..) |candidate, i| if (size == candidate) return i;
|
|
45
|
+
unreachable;
|
|
46
|
+
}
|
|
47
|
+
fn writeNode(bytes: []u8, node: events.WidgetLayoutNode) void {
|
|
48
|
+
const w = node.widget;
|
|
49
|
+
word(bytes, 0, widgets.widgetKindCode(w.kind));
|
|
50
|
+
word(bytes, 4, sizeCode(w.size));
|
|
51
|
+
word(bytes, 8, @intFromEnum(w.variant));
|
|
52
|
+
word(bytes, 12, if (node.parent_index) |p| @as(u32, @truncate(p)) else missing);
|
|
53
|
+
word(bytes, 124, if (node.parent_index) |p| @as(u64, p) >> 32 else 0);
|
|
54
|
+
word(bytes, 16, @as(u32, @truncate(node.depth)));
|
|
55
|
+
word(bytes, 120, @as(u64, node.depth) >> 32);
|
|
56
|
+
const alignment: u32 = switch (w.text_alignment) {
|
|
57
|
+
.start => 0,
|
|
58
|
+
.center => 1,
|
|
59
|
+
.end => 2,
|
|
60
|
+
};
|
|
61
|
+
const flags = @as(u32, @intFromBool(w.semantics.hidden)) | (@as(u32, @intFromBool(w.layout.clip_content)) << 1) |
|
|
62
|
+
(@as(u32, @intFromBool(w.layout.anchor != null)) << 2) | (@as(u32, @intFromBool(w.scrim)) << 3) |
|
|
63
|
+
(@as(u32, @intFromBool(w.text.len > 0)) << 4) | (@as(u32, @intFromBool(w.icon.len > 0)) << 5) |
|
|
64
|
+
(@as(u32, @intFromBool(w.style.border != null)) << 6) | (@as(u32, @intFromBool(w.style.stroke_width != null)) << 7) |
|
|
65
|
+
(@as(u32, @intFromBool(w.group_segment != .none)) << 8) | (alignment << 9) | (@as(u32, @intFromBool(node.parent_index != null)) << 11);
|
|
66
|
+
word(bytes, 20, flags);
|
|
67
|
+
word(bytes, 24, changes.stateBits(w.state));
|
|
68
|
+
word(bytes, 28, if (w.backdrop_blur_token) |t| @intFromEnum(t) else missing);
|
|
69
|
+
rect(bytes, 32, node.frame);
|
|
70
|
+
rect(bytes, 48, w.frame);
|
|
71
|
+
inline for (.{ "a", "b", "c", "d", "tx", "ty" }, 0..) |name, i| float(bytes, 64 + i * 4, @field(w.transform, name));
|
|
72
|
+
float(bytes, 88, w.value);
|
|
73
|
+
float(bytes, 92, w.style.stroke_width orelse 0);
|
|
74
|
+
if (w.style.border) |border| inline for (.{ "r", "g", "b", "a" }, 0..) |name, i| float(bytes, 96 + i * 4, @field(border, name));
|
|
75
|
+
float(bytes, 112, w.backdrop_blur);
|
|
76
|
+
}
|
|
77
|
+
fn writeTokens(bytes: []u8, tokens: tokens_model.DesignTokens) void {
|
|
78
|
+
const values = [_]f32{
|
|
79
|
+
tokens.stroke.focus, tokens.stroke.focus_offset, tokens.stroke.regular, tokens.stroke.hairline,
|
|
80
|
+
@floatFromInt(@intFromEnum(tokens.density)), @floatFromInt(@intFromBool(tokens.pixel_snap.geometry)), tokens.pixel_snap.scale, tokens.typography.label_size,
|
|
81
|
+
tokens.metrics.tabs_label_size_step, tokens.metrics.tabs_trigger_inset, tokens.metrics.size_inset_step, tokens.metrics.icon_text_step,
|
|
82
|
+
tokens.metrics.button_icon_gap, tokens.metrics.tabs_indicator_thickness, tokens.metrics.slider_thumb_width, tokens.metrics.slider_thumb_height,
|
|
83
|
+
tokens.shadow.sm.y, tokens.shadow.sm.blur, tokens.shadow.sm.spread, tokens.shadow.md.y,
|
|
84
|
+
tokens.shadow.md.blur, tokens.shadow.md.spread, tokens.blur.none, tokens.blur.sm,
|
|
85
|
+
tokens.blur.md, tokens.colors.scrim.a, @floatFromInt(@intFromBool(tokens.controls.button_group_style == .detached)), @floatFromInt(@intFromBool(tokens.controls.tabs_indicator == .underline)),
|
|
86
|
+
tokens.blur.scrim, 0, 0, 0,
|
|
87
|
+
};
|
|
88
|
+
for (values, 0..) |v, i| float(bytes, 64 + i * 4, v);
|
|
89
|
+
inline for (tables, 0..) |name, i| {
|
|
90
|
+
const value = @field(tokens.controls, name).stroke_width;
|
|
91
|
+
word(bytes, 192 + i * 8, @intFromBool(value != null));
|
|
92
|
+
float(bytes, 196 + i * 8, value orelse 0);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
pub const Plan = struct {
|
|
96
|
+
allocator: std.mem.Allocator,
|
|
97
|
+
request: []u8,
|
|
98
|
+
result: []u8,
|
|
99
|
+
length: usize,
|
|
100
|
+
pub fn diff(allocator: std.mem.Allocator, policy: Policy, previous: anytype, next: anytype, tokens: tokens_model.DesignTokens, previous_root: ?geometry.RectF, next_root: ?geometry.RectF, change: changes.Plan) std.mem.Allocator.Error!Plan {
|
|
101
|
+
return init(allocator, policy, previous.nodes, next.nodes, tokens, previous_root, next_root, 1, change.result[0 .. 16 + change.length * 16], change.length);
|
|
102
|
+
}
|
|
103
|
+
pub fn render(allocator: std.mem.Allocator, policy: Policy, layout: anytype, tokens: tokens_model.DesignTokens, change: changes.RenderPlan) std.mem.Allocator.Error!Plan {
|
|
104
|
+
return init(allocator, policy, layout.nodes, &.{}, tokens, null, null, 2, change.result[0 .. 32 + change.length * 16 + (change.group_lengths[0] + change.group_lengths[1]) * 4], 1);
|
|
105
|
+
}
|
|
106
|
+
fn init(allocator: std.mem.Allocator, policy: Policy, previous: []const events.WidgetLayoutNode, next: []const events.WidgetLayoutNode, tokens: tokens_model.DesignTokens, previous_root: ?geometry.RectF, next_root: ?geometry.RectF, mode: u8, payload: []const u8, length: usize) std.mem.Allocator.Error!Plan {
|
|
107
|
+
const total = std.math.add(usize, previous.len, next.len) catch @panic("paint node capacity");
|
|
108
|
+
const base_size = std.math.add(usize, header_size, std.math.mul(usize, total, node_size) catch @panic("paint byte capacity")) catch @panic("paint byte capacity");
|
|
109
|
+
const request = try allocator.alloc(u8, std.math.add(usize, base_size, payload.len) catch @panic("paint payload capacity"));
|
|
110
|
+
errdefer allocator.free(request);
|
|
111
|
+
@memset(request, 0);
|
|
112
|
+
request[0..4].* = .{ 26, 0, 2, @import("render_plan_policy.zig").numericFlags() };
|
|
113
|
+
word(request, 4, previous.len);
|
|
114
|
+
word(request, 8, next.len);
|
|
115
|
+
word(request, 12, payload.len);
|
|
116
|
+
word(request, 16, mode);
|
|
117
|
+
word(request, 28, @as(u32, @intFromBool(previous_root != null)) | (@as(u32, @intFromBool(next_root != null)) << 1));
|
|
118
|
+
if (previous_root) |r| rect(request, 32, r);
|
|
119
|
+
if (next_root) |r| rect(request, 48, r);
|
|
120
|
+
writeTokens(request, tokens);
|
|
121
|
+
for (previous, 0..) |n, i| writeNode(request[header_size + i * node_size ..][0..node_size], n);
|
|
122
|
+
for (next, 0..) |n, i| writeNode(request[header_size + (previous.len + i) * node_size ..][0..node_size], n);
|
|
123
|
+
const measurements = try allocator.alloc(u8, std.math.add(usize, 8, std.math.mul(usize, total, 8) catch @panic("paint measurement capacity")) catch @panic("paint measurement capacity"));
|
|
124
|
+
defer allocator.free(measurements);
|
|
125
|
+
@memset(measurements, 0xa5);
|
|
126
|
+
@memcpy(request[base_size..], payload);
|
|
127
|
+
const measured = policy(request, measurements);
|
|
128
|
+
if (measured < 8 or measured > measurements.len or !std.mem.eql(u8, measurements[0..4], &.{ 1, 0, 0, 0 })) @panic("invalid compiled paint measurement header");
|
|
129
|
+
const measure_count = read(measurements, 4);
|
|
130
|
+
if (measure_count > total or measured != 8 + @as(usize, measure_count) * 8) @panic("invalid compiled paint measurement count");
|
|
131
|
+
// Validate the entire request list before calling the native capability.
|
|
132
|
+
for (0..measure_count) |i| {
|
|
133
|
+
const slot = read(measurements, 8 + i * 8);
|
|
134
|
+
if (slot >= total) @panic("invalid compiled paint measurement slot");
|
|
135
|
+
for (0..i) |earlier| if (read(measurements, 8 + earlier * 8) == slot) @panic("duplicate compiled paint measurement slot");
|
|
136
|
+
}
|
|
137
|
+
for (0..measure_count) |i| {
|
|
138
|
+
const slot = read(measurements, 8 + i * 8);
|
|
139
|
+
const node = if (slot < previous.len) previous[slot] else next[slot - previous.len];
|
|
140
|
+
const size = readFloat(measurements, 12 + i * 8);
|
|
141
|
+
const width = text_metrics.measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, node.widget.text, size);
|
|
142
|
+
float(request, header_size + @as(usize, slot) * node_size + 116, width);
|
|
143
|
+
}
|
|
144
|
+
request[1] = mode;
|
|
145
|
+
word(request, 12, payload.len);
|
|
146
|
+
@memcpy(request[base_size..], payload);
|
|
147
|
+
const result = try allocator.alloc(u8, std.math.add(usize, 8, std.math.mul(usize, length, 20) catch @panic("paint result capacity")) catch @panic("paint result capacity"));
|
|
148
|
+
errdefer allocator.free(result);
|
|
149
|
+
@memset(result, 0xa5);
|
|
150
|
+
const written = policy(request, result);
|
|
151
|
+
if (written != result.len or !std.mem.eql(u8, result[0..4], &.{ 1, mode, 0, 0 }) or read(result, 4) != length) @panic("invalid compiled paint result header");
|
|
152
|
+
for (0..length) |i| {
|
|
153
|
+
const at = 8 + i * 20;
|
|
154
|
+
if (read(result, at) > 1) @panic("invalid compiled paint result presence");
|
|
155
|
+
if (read(result, at) == 0 and !std.mem.allEqual(u8, result[at + 4 ..][0..16], 0)) @panic("invalid compiled absent paint bounds");
|
|
156
|
+
}
|
|
157
|
+
return .{ .allocator = allocator, .request = request, .result = result, .length = length };
|
|
158
|
+
}
|
|
159
|
+
pub fn bounds(self: Plan, slot: usize) ?geometry.RectF {
|
|
160
|
+
return optional(self.result, 8 + slot * 20);
|
|
161
|
+
}
|
|
162
|
+
pub fn deinit(self: Plan) void {
|
|
163
|
+
self.allocator.free(self.request);
|
|
164
|
+
self.allocator.free(self.result);
|
|
165
|
+
}
|
|
166
|
+
};
|