@native-sdk/cli 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1818 -87
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +2 -1
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/codesign.zig +125 -74
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/package.zig +85 -1
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
//! Copied retained-change boundary. Native transports raw values, validates
|
|
2
|
+
//! the complete plan, and reconstructs typed caller records. Matching and
|
|
3
|
+
//! change classification belong exclusively to the selected portable owner.
|
|
4
|
+
const std = @import("std");
|
|
5
|
+
const widgets = @import("widgets.zig");
|
|
6
|
+
const events = @import("events.zig");
|
|
7
|
+
const geometry = @import("geometry");
|
|
8
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
9
|
+
const missing = std.math.maxInt(u32);
|
|
10
|
+
const group_count = 9;
|
|
11
|
+
const node_header_size = 16 + group_count * 4;
|
|
12
|
+
const AllocationError = std.mem.Allocator.Error;
|
|
13
|
+
pub fn owner(layout: anytype) ?Policy {
|
|
14
|
+
const T = switch (@typeInfo(@TypeOf(layout))) {
|
|
15
|
+
.pointer => |p| p.child,
|
|
16
|
+
else => @TypeOf(layout),
|
|
17
|
+
};
|
|
18
|
+
if (comptime @hasField(T, "change_policy")) return layout.change_policy;
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
fn put(bytes: []u8, at: usize, value: u32) void {
|
|
22
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
23
|
+
}
|
|
24
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
25
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
26
|
+
}
|
|
27
|
+
fn count(value: usize) u32 {
|
|
28
|
+
return std.math.cast(u32, value) orelse @panic("widget change wire capacity");
|
|
29
|
+
}
|
|
30
|
+
fn writeWord(list: *std.ArrayList(u8), allocator: std.mem.Allocator, value: u32) AllocationError!void {
|
|
31
|
+
var bytes: [4]u8 = undefined;
|
|
32
|
+
put(&bytes, 0, value);
|
|
33
|
+
try list.appendSlice(allocator, &bytes);
|
|
34
|
+
}
|
|
35
|
+
/// Equality facts use tagged values rather than object memory or hashes.
|
|
36
|
+
/// This preserves byte slices, optional presence, wide integers, all float
|
|
37
|
+
/// payloads, and the reference's field-wise equality without padding bytes.
|
|
38
|
+
fn writeValue(list: *std.ArrayList(u8), allocator: std.mem.Allocator, value: anytype) AllocationError!void {
|
|
39
|
+
const T = @TypeOf(value);
|
|
40
|
+
switch (@typeInfo(T)) {
|
|
41
|
+
.bool => try list.appendSlice(allocator, &.{ 0, @intFromBool(value) }),
|
|
42
|
+
.int => {
|
|
43
|
+
try list.append(allocator, 1);
|
|
44
|
+
var bytes: [16]u8 = undefined;
|
|
45
|
+
const U = std.meta.Int(.unsigned, @bitSizeOf(T));
|
|
46
|
+
std.mem.writeInt(u128, &bytes, @as(U, @bitCast(value)), .little);
|
|
47
|
+
try list.appendSlice(allocator, &bytes);
|
|
48
|
+
},
|
|
49
|
+
.@"enum" => {
|
|
50
|
+
try list.append(allocator, 2);
|
|
51
|
+
try writeWord(list, allocator, @intCast(@intFromEnum(value)));
|
|
52
|
+
},
|
|
53
|
+
.float => {
|
|
54
|
+
if (T == f32) {
|
|
55
|
+
try list.append(allocator, 3);
|
|
56
|
+
try writeWord(list, allocator, @bitCast(value));
|
|
57
|
+
} else if (T == f64) {
|
|
58
|
+
try list.append(allocator, 4);
|
|
59
|
+
var bytes: [8]u8 = undefined;
|
|
60
|
+
std.mem.writeInt(u64, &bytes, @bitCast(value), .little);
|
|
61
|
+
try list.appendSlice(allocator, &bytes);
|
|
62
|
+
} else @compileError("unsupported widget change float");
|
|
63
|
+
},
|
|
64
|
+
.optional => {
|
|
65
|
+
try list.appendSlice(allocator, &.{ 5, @intFromBool(value != null) });
|
|
66
|
+
if (value) |present| try writeValue(list, allocator, present);
|
|
67
|
+
},
|
|
68
|
+
.@"struct" => |s| {
|
|
69
|
+
try list.append(allocator, 6);
|
|
70
|
+
try writeWord(list, allocator, s.fields.len);
|
|
71
|
+
inline for (s.fields) |field| try writeValue(list, allocator, @field(value, field.name));
|
|
72
|
+
},
|
|
73
|
+
.array => {
|
|
74
|
+
try list.append(allocator, 6);
|
|
75
|
+
try writeWord(list, allocator, count(value.len));
|
|
76
|
+
for (value) |item| try writeValue(list, allocator, item);
|
|
77
|
+
},
|
|
78
|
+
.pointer => |p| {
|
|
79
|
+
if (p.size != .slice) @compileError("widget change facts cannot contain native pointers");
|
|
80
|
+
try list.append(allocator, if (p.child == u8) 7 else 6);
|
|
81
|
+
try writeWord(list, allocator, count(value.len));
|
|
82
|
+
if (p.child == u8) try list.appendSlice(allocator, value) else for (value) |item| try writeValue(list, allocator, item);
|
|
83
|
+
},
|
|
84
|
+
else => @compileError("unsupported widget change fact type"),
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
fn writeNode(list: *std.ArrayList(u8), allocator: std.mem.Allocator, node: events.WidgetLayoutNode) AllocationError!void {
|
|
88
|
+
const w = node.widget;
|
|
89
|
+
const header = list.items.len;
|
|
90
|
+
try list.appendSlice(allocator, &([_]u8{0} ** node_header_size));
|
|
91
|
+
std.mem.writeInt(u64, list.items[header..][0..8], w.id, .little);
|
|
92
|
+
const flags: u32 = @intFromBool(node.parent_index == null) | (@as(u32, @intFromBool(w.hasCodeDiff())) << 1) |
|
|
93
|
+
(@as(u32, @intFromBool(w.terminal.grid != null)) << 2) | (@as(u32, @intFromBool(w.semantics.hidden)) << 3);
|
|
94
|
+
put(list.items, header + 8, flags);
|
|
95
|
+
// These are the exact dependencies of the retained reference. Anchor,
|
|
96
|
+
// zero_intrinsic, callbacks and other unobserved fields deliberately stay
|
|
97
|
+
// outside this contract; changing it is a behavior change, not a port.
|
|
98
|
+
const groups = .{
|
|
99
|
+
.{ w.kind, node.depth, node.parent_index, node.frame, w.code_line_number_digits, w.layout.padding, w.layout.padding_is_kind_default, w.layout.gap, w.layout.grow, w.layout.main_alignment, w.layout.cross_alignment, w.layout.clip_content, w.layout.columns, w.layout.virtualized, w.layout.virtual_item_extent, w.layout.virtual_overscan, w.layout.virtual_item_count, w.layout.virtual_first_index, w.layout.virtual_anchor_index, w.layout.virtual_anchor_extent, w.layout.virtual_total_extent, w.layout.min_size, w.layout.max_size },
|
|
100
|
+
.{ w.text, w.spans, w.code_language, w.static_text_group_id, w.codeDiffLines(), w.chart, w.placeholder, w.icon, w.value, w.value_x, w.scroll_axes, w.image_id, w.image_src, w.image_fit, w.image_sampling, w.image_opacity, w.stream_size, w.text_selection, w.text_composition, w.terminal.pty, w.terminal.scrollback },
|
|
101
|
+
w.command,
|
|
102
|
+
.{ w.opacity, w.transform, w.backdrop_blur, w.backdrop_blur_token, w.scrim, w.text_alignment, w.text_no_wrap, w.text_overflow, w.variant, w.size, w.style },
|
|
103
|
+
w.state,
|
|
104
|
+
w.semantics,
|
|
105
|
+
w.layer,
|
|
106
|
+
w.static_text_group_offset,
|
|
107
|
+
.{ w.opacity, w.transform },
|
|
108
|
+
};
|
|
109
|
+
comptime std.debug.assert(@typeInfo(@TypeOf(groups)).@"struct".fields.len == group_count);
|
|
110
|
+
inline for (groups, 0..) |group, i| {
|
|
111
|
+
const start = list.items.len;
|
|
112
|
+
try writeValue(list, allocator, group);
|
|
113
|
+
put(list.items, header + 16 + i * 4, count(list.items.len - start));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
pub const Flags = struct {
|
|
117
|
+
layout: bool,
|
|
118
|
+
paint: bool,
|
|
119
|
+
semantics: bool,
|
|
120
|
+
root: bool,
|
|
121
|
+
visibility: bool,
|
|
122
|
+
subtree: bool,
|
|
123
|
+
layer: bool,
|
|
124
|
+
};
|
|
125
|
+
pub const Entry = struct { kind: events.WidgetInvalidationKind, previous: ?usize, next: ?usize, flags: Flags };
|
|
126
|
+
pub const Plan = struct {
|
|
127
|
+
allocator: std.mem.Allocator,
|
|
128
|
+
request: []u8,
|
|
129
|
+
result: []u8,
|
|
130
|
+
status: u8,
|
|
131
|
+
length: usize,
|
|
132
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, previous: anytype, next: anytype, previous_root: ?geometry.RectF, next_root: ?geometry.RectF, capacity: usize) AllocationError!Plan {
|
|
133
|
+
var list: std.ArrayList(u8) = .empty;
|
|
134
|
+
defer list.deinit(allocator);
|
|
135
|
+
try list.appendSlice(allocator, &([_]u8{0} ** 64));
|
|
136
|
+
list.items[0..4].* = .{ 25, 1, 0, 0 };
|
|
137
|
+
put(list.items, 4, count(previous.nodes.len));
|
|
138
|
+
put(list.items, 8, count(next.nodes.len));
|
|
139
|
+
put(list.items, 12, count(@min(capacity, std.math.maxInt(u32))));
|
|
140
|
+
put(list.items, 16, @as(u32, @intFromBool(previous_root != null)) | (@as(u32, @intFromBool(next_root != null)) << 1));
|
|
141
|
+
for ([_]?geometry.RectF{ previous_root, next_root }, 0..) |maybe_rect, r| {
|
|
142
|
+
if (maybe_rect) |rect| for ([_]f32{ rect.x, rect.y, rect.width, rect.height }, 0..) |value, i| put(list.items, 24 + r * 16 + i * 4, @bitCast(value));
|
|
143
|
+
}
|
|
144
|
+
for (previous.nodes) |node| try writeNode(&list, allocator, node);
|
|
145
|
+
for (next.nodes) |node| try writeNode(&list, allocator, node);
|
|
146
|
+
const request = try list.toOwnedSlice(allocator);
|
|
147
|
+
errdefer allocator.free(request);
|
|
148
|
+
const maximum = std.math.add(usize, previous.nodes.len, next.nodes.len) catch @panic("widget change result capacity");
|
|
149
|
+
const bytes = std.math.add(usize, 16, std.math.mul(usize, @min(capacity, maximum), 16) catch @panic("widget change result capacity")) catch @panic("widget change result capacity");
|
|
150
|
+
const result = try allocator.alloc(u8, bytes);
|
|
151
|
+
errdefer allocator.free(result);
|
|
152
|
+
@memset(result, 0xa5);
|
|
153
|
+
const written = policy(request, result);
|
|
154
|
+
if (written < 16 or written > result.len or result[0] != 1 or result[1] != 0 or result[2] > 2 or result[3] != 0 or word(result, 8) != 0 or word(result, 12) != 0)
|
|
155
|
+
@panic("invalid compiled widget change result");
|
|
156
|
+
const length = word(result, 4);
|
|
157
|
+
if (length > capacity or length > maximum or written != 16 + @as(usize, length) * 16 or (result[2] == 1 and length != 0) or (result[2] == 2 and length != capacity))
|
|
158
|
+
@panic("invalid compiled widget change count");
|
|
159
|
+
const plan = Plan{ .allocator = allocator, .request = request, .result = result, .status = result[2], .length = length };
|
|
160
|
+
var previous_index: ?usize = null;
|
|
161
|
+
var next_index: ?usize = null;
|
|
162
|
+
var added = false;
|
|
163
|
+
// Validate the entire plan before touching caller output. Identity
|
|
164
|
+
// checks here validate references; they never select or reclassify.
|
|
165
|
+
for (0..length) |i| {
|
|
166
|
+
const planned = plan.entry(i);
|
|
167
|
+
const bits = word(result, 28 + i * 16);
|
|
168
|
+
if (bits & ~@as(u32, 127) != 0 or bits & 7 == 0 or (bits & 1 != 0 and bits & 6 != 6) or (bits & 8 != 0 and bits & 1 == 0)) @panic("invalid compiled widget change flags");
|
|
169
|
+
if (planned.kind == .added) {
|
|
170
|
+
added = true;
|
|
171
|
+
const n = planned.next orelse @panic("missing compiled added index");
|
|
172
|
+
if (n >= next.nodes.len or planned.previous != null or bits != 7 or next.nodes[n].widget.id == 0 or (next_index != null and n <= next_index.?)) @panic("invalid compiled added widget");
|
|
173
|
+
next_index = n;
|
|
174
|
+
} else {
|
|
175
|
+
const p = planned.previous orelse @panic("missing compiled previous index");
|
|
176
|
+
if (added or p >= previous.nodes.len or previous.nodes[p].widget.id == 0 or (previous_index != null and p <= previous_index.?)) @panic("invalid compiled previous widget");
|
|
177
|
+
previous_index = p;
|
|
178
|
+
if (planned.kind == .removed) {
|
|
179
|
+
if (planned.next != null or bits != 7) @panic("invalid compiled removed widget");
|
|
180
|
+
} else {
|
|
181
|
+
const n = planned.next orelse @panic("missing compiled changed index");
|
|
182
|
+
if (n >= next.nodes.len or previous.nodes[p].widget.id != next.nodes[n].widget.id) @panic("invalid compiled changed identity");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return plan;
|
|
187
|
+
}
|
|
188
|
+
pub fn deinit(self: Plan) void {
|
|
189
|
+
self.allocator.free(self.request);
|
|
190
|
+
self.allocator.free(self.result);
|
|
191
|
+
}
|
|
192
|
+
pub fn entry(self: Plan, i: usize) Entry {
|
|
193
|
+
const at = 16 + i * 16;
|
|
194
|
+
const previous = word(self.result, at + 4);
|
|
195
|
+
const next = word(self.result, at + 8);
|
|
196
|
+
const flags = word(self.result, at + 12);
|
|
197
|
+
return .{ .kind = switch (word(self.result, at)) {
|
|
198
|
+
0 => .removed,
|
|
199
|
+
1 => .changed,
|
|
200
|
+
2 => .added,
|
|
201
|
+
else => @panic("invalid compiled widget change kind"),
|
|
202
|
+
}, .previous = if (previous == missing) null else previous, .next = if (next == missing) null else next, .flags = .{
|
|
203
|
+
.layout = flags & 1 != 0,
|
|
204
|
+
.paint = flags & 2 != 0,
|
|
205
|
+
.semantics = flags & 4 != 0,
|
|
206
|
+
.root = flags & 8 != 0,
|
|
207
|
+
.visibility = flags & 16 != 0,
|
|
208
|
+
.subtree = flags & 32 != 0,
|
|
209
|
+
.layer = flags & 64 != 0,
|
|
210
|
+
} };
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
pub fn stateBits(state: widgets.WidgetState) u32 {
|
|
215
|
+
return @intFromBool(state.hovered) | (@as(u32, @intFromBool(state.pressed)) << 1) |
|
|
216
|
+
(@as(u32, @intFromBool(state.focused)) << 2) | (@as(u32, @intFromBool(state.disabled)) << 3) |
|
|
217
|
+
(@as(u32, @intFromBool(state.selected)) << 4) | (@as(u32, @intFromBool(state.expanded != null)) << 5) |
|
|
218
|
+
(@as(u32, @intFromBool(state.expanded orelse false)) << 6) | (@as(u32, @intFromBool(state.required)) << 7) |
|
|
219
|
+
(@as(u32, @intFromBool(state.read_only)) << 8) | (@as(u32, @intFromBool(state.invalid)) << 9);
|
|
220
|
+
}
|
|
221
|
+
fn writeRenderState(bytes: []u8, state: widgets.WidgetRenderState) void {
|
|
222
|
+
var flags: u32 = @as(u32, @intFromBool(state.keyboard_active)) << 7;
|
|
223
|
+
for ([_]?u64{ state.focused_id, state.focus_visible_id, state.hovered_id, state.pressed_id, state.drag_preview_id }, 0..) |id, i| {
|
|
224
|
+
flags |= @as(u32, @intFromBool(id != null)) << @intCast(i);
|
|
225
|
+
std.mem.writeInt(u64, bytes[8 + i * 8 ..][0..8], id orelse 0, .little);
|
|
226
|
+
}
|
|
227
|
+
flags |= (@as(u32, @intFromBool(state.hover_point != null)) << 5) | (@as(u32, @intFromBool(state.drag_preview_origin != null)) << 6);
|
|
228
|
+
put(bytes, 0, flags);
|
|
229
|
+
const hover = state.hover_point orelse geometry.PointF.zero();
|
|
230
|
+
const drag = state.drag_preview_origin orelse geometry.PointF.zero();
|
|
231
|
+
for ([_]f32{ hover.x, hover.y, drag.x, drag.y, state.drag_preview_offset.dx, state.drag_preview_offset.dy }, 0..) |value, i| put(bytes, 48 + i * 4, @bitCast(value));
|
|
232
|
+
}
|
|
233
|
+
pub const RenderEntry = struct { node_index: usize, terminal: bool, state: bool, previous: u32, next: u32 };
|
|
234
|
+
pub const RenderPlan = struct {
|
|
235
|
+
allocator: std.mem.Allocator,
|
|
236
|
+
request: []u8,
|
|
237
|
+
result: []u8,
|
|
238
|
+
length: usize,
|
|
239
|
+
group_lengths: [2]usize,
|
|
240
|
+
chart: bool,
|
|
241
|
+
drag: bool,
|
|
242
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, layout: anytype, previous: widgets.WidgetRenderState, next: widgets.WidgetRenderState) AllocationError!RenderPlan {
|
|
243
|
+
const node_count = layout.nodes.len;
|
|
244
|
+
const request_size = std.math.add(usize, 160, std.math.mul(usize, node_count, 24) catch @panic("render change capacity")) catch @panic("render change capacity");
|
|
245
|
+
const request = try allocator.alloc(u8, request_size);
|
|
246
|
+
errdefer allocator.free(request);
|
|
247
|
+
@memset(request, 0);
|
|
248
|
+
request[0..4].* = .{ 25, 1, 1, 0 };
|
|
249
|
+
put(request, 4, count(node_count));
|
|
250
|
+
writeRenderState(request[16..88], previous);
|
|
251
|
+
writeRenderState(request[88..160], next);
|
|
252
|
+
for (layout.nodes, 0..) |node, i| {
|
|
253
|
+
const at = 160 + i * 24;
|
|
254
|
+
put(request, at, widgets.widgetKindCode(node.widget.kind));
|
|
255
|
+
put(request, at + 4, if (node.parent_index) |p| (std.math.cast(u32, p) orelse missing) else missing);
|
|
256
|
+
std.mem.writeInt(u64, request[at + 8 ..][0..8], node.widget.id, .little);
|
|
257
|
+
put(request, at + 16, stateBits(node.widget.state));
|
|
258
|
+
const grid = node.widget.terminal.grid;
|
|
259
|
+
put(request, at + 20, @intFromBool(grid != null) | (@as(u32, @intFromBool(if (grid) |g| g.running else false)) << 1) |
|
|
260
|
+
(@as(u32, @intFromBool(if (grid) |g| g.cursor != null else false)) << 2));
|
|
261
|
+
}
|
|
262
|
+
const result_size = std.math.add(usize, 160, std.math.mul(usize, node_count, 24) catch @panic("render change result capacity")) catch @panic("render change result capacity");
|
|
263
|
+
const result = try allocator.alloc(u8, result_size);
|
|
264
|
+
errdefer allocator.free(result);
|
|
265
|
+
@memset(result, 0xa5);
|
|
266
|
+
const written = policy(request, result);
|
|
267
|
+
if (written < 32 or written > result.len or !std.mem.eql(u8, result[0..4], &.{ 1, 1, 0, 0 }) or word(result, 16) > 3 or word(result, 20) != 0 or word(result, 24) != 0 or word(result, 28) != 0)
|
|
268
|
+
@panic("invalid compiled render change result");
|
|
269
|
+
const length = word(result, 4);
|
|
270
|
+
const groups = [2]usize{ word(result, 8), word(result, 12) };
|
|
271
|
+
if (length > node_count + 8 or groups[0] > node_count or groups[1] > node_count or written != 32 + @as(usize, length) * 16 + (groups[0] + groups[1]) * 4)
|
|
272
|
+
@panic("invalid compiled render change count");
|
|
273
|
+
const plan = RenderPlan{ .allocator = allocator, .request = request, .result = result, .length = length, .group_lengths = groups, .chart = word(result, 16) & 1 != 0, .drag = word(result, 16) & 2 != 0 };
|
|
274
|
+
for (0..length) |i| {
|
|
275
|
+
const item = plan.entry(i);
|
|
276
|
+
const flags = word(result, 36 + i * 16);
|
|
277
|
+
if (item.node_index >= node_count or flags == 0 or flags > 3 or item.previous > 1023 or item.next > 1023 or
|
|
278
|
+
(item.previous & ~@as(u32, 7)) != (stateBits(layout.nodes[item.node_index].widget.state) & ~@as(u32, 7)) or
|
|
279
|
+
(item.next & ~@as(u32, 7)) != (stateBits(layout.nodes[item.node_index].widget.state) & ~@as(u32, 7))) @panic("invalid compiled render change entry");
|
|
280
|
+
}
|
|
281
|
+
for (0..2) |g| for (0..groups[g]) |i| {
|
|
282
|
+
const index = plan.groupIndex(g, i);
|
|
283
|
+
if (index >= node_count or layout.nodes[index].widget.kind != .input_group) @panic("invalid compiled focus group");
|
|
284
|
+
};
|
|
285
|
+
return plan;
|
|
286
|
+
}
|
|
287
|
+
pub fn deinit(self: RenderPlan) void {
|
|
288
|
+
self.allocator.free(self.request);
|
|
289
|
+
self.allocator.free(self.result);
|
|
290
|
+
}
|
|
291
|
+
pub fn entry(self: RenderPlan, i: usize) RenderEntry {
|
|
292
|
+
const at = 32 + i * 16;
|
|
293
|
+
return .{ .node_index = word(self.result, at), .state = word(self.result, at + 4) & 1 != 0, .terminal = word(self.result, at + 4) & 2 != 0, .previous = word(self.result, at + 8), .next = word(self.result, at + 12) };
|
|
294
|
+
}
|
|
295
|
+
pub fn groupIndex(self: RenderPlan, g: usize, i: usize) usize {
|
|
296
|
+
return word(self.result, 32 + self.length * 16 + (i + if (g == 1) self.group_lengths[0] else @as(usize, 0)) * 4);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
@@ -14,6 +14,8 @@ const widget_render_surfaces = @import("widget_render_surfaces.zig");
|
|
|
14
14
|
const widget_render_controls = @import("widget_render_controls.zig");
|
|
15
15
|
const textSpansEqual = @import("text_spans.zig").textSpansEqual;
|
|
16
16
|
const chartDataEqual = @import("chart.zig").chartDataEqual;
|
|
17
|
+
const change_policy = @import("widget_change_policy.zig");
|
|
18
|
+
const paint_policy = @import("widget_paint_policy.zig");
|
|
17
19
|
|
|
18
20
|
const Error = canvas.Error;
|
|
19
21
|
const ObjectId = canvas.ObjectId;
|
|
@@ -55,7 +57,7 @@ const controlStrokeWidth = widget_render.controlStrokeWidth;
|
|
|
55
57
|
const componentControlVisualTokens = widget_render.componentControlVisualTokens;
|
|
56
58
|
const surfaceControlVisualTokens = widget_render.surfaceControlVisualTokens;
|
|
57
59
|
const buttonStrokeWidth = widget_render.buttonStrokeWidth;
|
|
58
|
-
const selectControlVisualTokens =
|
|
60
|
+
const selectControlVisualTokens = @import("widget_render_style.zig").selectControlVisualTokensForWidget;
|
|
59
61
|
const textInputControlVisualTokens = widget_render.textInputControlVisualTokens;
|
|
60
62
|
const selectionControlVisualTokens = widget_render.selectionControlVisualTokens;
|
|
61
63
|
const listItemControlVisualTokens = widget_render.listItemControlVisualTokens;
|
|
@@ -95,6 +97,8 @@ fn widgetWithRenderState(widget: Widget, state: WidgetRenderState) Widget {
|
|
|
95
97
|
pub fn diffWidgetLayoutTrees(previous: anytype, next: anytype, tokens: DesignTokens, output: []WidgetInvalidation) Error![]const WidgetInvalidation {
|
|
96
98
|
const previous_root_bounds = widget_render.widgetLayoutRootBounds(previous);
|
|
97
99
|
const next_root_bounds = widget_render.widgetLayoutRootBounds(next);
|
|
100
|
+
if (tokens.widget_change_policy orelse tokens.widget_paint_policy orelse change_policy.owner(next) orelse change_policy.owner(previous) orelse paint_policy.owner(next) orelse paint_policy.owner(previous)) |policy|
|
|
101
|
+
return diffWithPolicy(previous, next, tokens, output, policy, previous_root_bounds, next_root_bounds);
|
|
98
102
|
const root_bounds_dirty = !optionalRectsEqual(previous_root_bounds, next_root_bounds);
|
|
99
103
|
// Id lookups ride the probe-table index whenever the trees are big
|
|
100
104
|
// enough to be worth a table reset and fit its half-full bound;
|
|
@@ -198,6 +202,66 @@ pub fn diffWidgetLayoutTrees(previous: anytype, next: anytype, tokens: DesignTok
|
|
|
198
202
|
return output[0..len];
|
|
199
203
|
}
|
|
200
204
|
|
|
205
|
+
/// Change and paint owners exchange complete copied plans. The independent
|
|
206
|
+
/// native geometry remains the reference for layouts without paint ownership.
|
|
207
|
+
fn diffWithPolicy(previous: anytype, next: anytype, tokens: DesignTokens, output: []WidgetInvalidation, policy: change_policy.Policy, previous_root: ?geometry.RectF, next_root: ?geometry.RectF) Error![]const WidgetInvalidation {
|
|
208
|
+
const plan = change_policy.Plan.init(std.heap.page_allocator, policy, previous, next, previous_root, next_root, output.len) catch @panic("widget change allocation");
|
|
209
|
+
defer plan.deinit();
|
|
210
|
+
const geometry_owner = tokens.widget_paint_policy orelse paint_policy.owner(next) orelse paint_policy.owner(previous);
|
|
211
|
+
// The reference evaluates the overflowing entry's geometry before its
|
|
212
|
+
// append fails. Keep those font capability calls, but never write that
|
|
213
|
+
// entry into the caller's complete capacity-error prefix.
|
|
214
|
+
const overflow: ?change_policy.Plan = if (geometry_owner != null and plan.status == 2)
|
|
215
|
+
change_policy.Plan.init(std.heap.page_allocator, policy, previous, next, previous_root, next_root, output.len + 1) catch @panic("widget paint overflow allocation")
|
|
216
|
+
else
|
|
217
|
+
null;
|
|
218
|
+
defer if (overflow) |extra| extra.deinit();
|
|
219
|
+
if (overflow) |extra| {
|
|
220
|
+
if (extra.length != plan.length + 1 or !std.mem.eql(u8, plan.result[16 .. 16 + plan.length * 16], extra.result[16 .. 16 + plan.length * 16])) @panic("inconsistent compiled paint overflow prefix");
|
|
221
|
+
}
|
|
222
|
+
const damage: ?paint_policy.Plan = if (geometry_owner) |owner| paint_policy.Plan.diff(std.heap.page_allocator, owner, previous, next, tokens, previous_root, next_root, overflow orelse plan) catch @panic("widget paint allocation") else null;
|
|
223
|
+
defer if (damage) |owned| owned.deinit();
|
|
224
|
+
for (0..plan.length) |i| {
|
|
225
|
+
const entry = plan.entry(i);
|
|
226
|
+
const flags = entry.flags;
|
|
227
|
+
const bounds: ?geometry.RectF = if (damage) |owned| owned.bounds(i) else switch (entry.kind) {
|
|
228
|
+
.removed => blk: {
|
|
229
|
+
const p = entry.previous.?;
|
|
230
|
+
break :blk widgetClippedDirtyBounds(previous, p, unionOptionalBounds(widgetFullPaintBounds(previous.nodes[p], tokens), widgetModalScrimBounds(previous, previous.nodes[p].widget, tokens)));
|
|
231
|
+
},
|
|
232
|
+
.added => blk: {
|
|
233
|
+
const n = entry.next.?;
|
|
234
|
+
break :blk widgetClippedDirtyBounds(next, n, unionOptionalBounds(widgetFullPaintBounds(next.nodes[n], tokens), widgetModalScrimBounds(next, next.nodes[n].widget, tokens)));
|
|
235
|
+
},
|
|
236
|
+
.changed => blk: {
|
|
237
|
+
const p = entry.previous.?;
|
|
238
|
+
const n = entry.next.?;
|
|
239
|
+
if (flags.visibility or flags.subtree) break :blk unionOptionalBounds(
|
|
240
|
+
unionOptionalBounds(widgetVisibleSubtreeFullPaintBounds(previous, p, tokens), widgetModalScrimBounds(previous, previous.nodes[p].widget, tokens)),
|
|
241
|
+
unionOptionalBounds(widgetVisibleSubtreeFullPaintBounds(next, n, tokens), widgetModalScrimBounds(next, next.nodes[n].widget, tokens)),
|
|
242
|
+
);
|
|
243
|
+
const paint_bounds = if (flags.root)
|
|
244
|
+
unionOptionalBounds(unionOptionalBounds(widgetFullPaintBounds(previous.nodes[p], tokens), widgetFullPaintBounds(next.nodes[n], tokens)), unionOptionalBounds(previous_root, next_root))
|
|
245
|
+
else if (flags.layout or flags.visibility or flags.layer)
|
|
246
|
+
unionOptionalBounds(widgetFullPaintBounds(previous.nodes[p], tokens), widgetFullPaintBounds(next.nodes[n], tokens))
|
|
247
|
+
else if (flags.paint)
|
|
248
|
+
widgetPaintChangeBounds(previous.nodes[p].widget, next.nodes[n].widget, tokens)
|
|
249
|
+
else
|
|
250
|
+
null;
|
|
251
|
+
break :blk widgetChangedClippedDirtyBounds(previous, p, next, n, paint_bounds);
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
output[i] = .{ .kind = entry.kind, .id = if (entry.previous) |p| previous.nodes[p].widget.id else next.nodes[entry.next.?].widget.id, .previous_index = entry.previous, .next_index = entry.next, .dirty_bounds = bounds, .layout_dirty = flags.layout, .paint_dirty = flags.paint, .semantics_dirty = flags.semantics };
|
|
255
|
+
}
|
|
256
|
+
// The reference leaves the complete written prefix on capacity failure.
|
|
257
|
+
return switch (plan.status) {
|
|
258
|
+
0 => output[0..plan.length],
|
|
259
|
+
1 => error.DuplicateWidgetId,
|
|
260
|
+
2 => error.WidgetInvalidationListFull,
|
|
261
|
+
else => unreachable,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
201
265
|
fn appendWidgetInvalidation(output: []WidgetInvalidation, len: *usize, invalidation: WidgetInvalidation) Error!void {
|
|
202
266
|
if (len.* >= output.len) return error.WidgetInvalidationListFull;
|
|
203
267
|
output[len.*] = invalidation;
|
|
@@ -368,6 +432,8 @@ fn widgetChange(
|
|
|
368
432
|
}
|
|
369
433
|
|
|
370
434
|
pub fn widgetRenderStateDirtyBounds(layout: anytype, previous: WidgetRenderState, next: WidgetRenderState, tokens: DesignTokens) ?geometry.RectF {
|
|
435
|
+
if (tokens.widget_change_policy orelse tokens.widget_paint_policy orelse change_policy.owner(layout) orelse paint_policy.owner(layout)) |policy|
|
|
436
|
+
return renderStateWithPolicy(layout, previous, next, tokens, policy);
|
|
371
437
|
var ids: [8]?ObjectId = [_]?ObjectId{null} ** 8;
|
|
372
438
|
var id_len: usize = 0;
|
|
373
439
|
if (previous.focused_id != next.focused_id) {
|
|
@@ -464,6 +530,51 @@ pub fn widgetRenderStateDirtyBounds(layout: anytype, previous: WidgetRenderState
|
|
|
464
530
|
return bounds;
|
|
465
531
|
}
|
|
466
532
|
|
|
533
|
+
fn widgetWithProjectedState(base: Widget, bits: u32) Widget {
|
|
534
|
+
var result = base;
|
|
535
|
+
result.state.hovered = bits & 1 != 0;
|
|
536
|
+
result.state.pressed = bits & 2 != 0;
|
|
537
|
+
result.state.focused = bits & 4 != 0;
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
fn renderStateWithPolicy(layout: anytype, previous: WidgetRenderState, next: WidgetRenderState, tokens: DesignTokens, policy: change_policy.Policy) ?geometry.RectF {
|
|
541
|
+
const plan = change_policy.RenderPlan.init(std.heap.page_allocator, policy, layout, previous, next) catch @panic("render change allocation");
|
|
542
|
+
defer plan.deinit();
|
|
543
|
+
const geometry_owner = tokens.widget_paint_policy orelse paint_policy.owner(layout);
|
|
544
|
+
const damage: ?paint_policy.Plan = if (geometry_owner) |owner| paint_policy.Plan.render(std.heap.page_allocator, owner, layout, tokens, plan) catch @panic("render paint allocation") else null;
|
|
545
|
+
defer if (damage) |owned| owned.deinit();
|
|
546
|
+
var bounds: ?geometry.RectF = if (damage) |owned| owned.bounds(0) else null;
|
|
547
|
+
if (damage == null) {
|
|
548
|
+
for (0..plan.length) |i| {
|
|
549
|
+
const item = plan.entry(i);
|
|
550
|
+
const index = item.node_index;
|
|
551
|
+
const node = layout.nodes[index];
|
|
552
|
+
if (item.terminal) bounds = unionOptionalBounds(bounds, widgetClippedDirtyBounds(layout, index, widgetFullPaintBoundsWithTransform(node, widgetAccumulatedTransform(layout, index), tokens)));
|
|
553
|
+
if (item.state) {
|
|
554
|
+
const base = widgetWithFrame(node.widget, node.frame);
|
|
555
|
+
bounds = unionOptionalBounds(bounds, widgetClippedDirtyBounds(layout, index, widgetRenderStatePaintChangeBounds(widgetWithProjectedState(base, item.previous), widgetWithProjectedState(base, item.next), tokens)));
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
for (0..2) |g| {
|
|
559
|
+
var group_bounds: ?geometry.RectF = null;
|
|
560
|
+
for (0..plan.group_lengths[g]) |i| {
|
|
561
|
+
const index = plan.groupIndex(g, i);
|
|
562
|
+
const node = layout.nodes[index];
|
|
563
|
+
var focused = widgetWithFrame(node.widget, node.frame);
|
|
564
|
+
focused.state.focused = true;
|
|
565
|
+
group_bounds = unionOptionalBounds(group_bounds, widgetClippedDirtyBounds(layout, index, widgetFocusPaintBounds(focused, tokens)));
|
|
566
|
+
}
|
|
567
|
+
bounds = unionOptionalBounds(bounds, group_bounds);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (plan.chart) {
|
|
571
|
+
bounds = unionOptionalBounds(bounds, widget_render.chartHoverDetailDirtyBounds(layout, previous, tokens));
|
|
572
|
+
bounds = unionOptionalBounds(bounds, widget_render.chartHoverDetailDirtyBounds(layout, next, tokens));
|
|
573
|
+
}
|
|
574
|
+
if (plan.drag) bounds = unionOptionalBounds(bounds, widget_render.widgetLayoutRootBounds(layout));
|
|
575
|
+
return bounds;
|
|
576
|
+
}
|
|
577
|
+
|
|
467
578
|
/// Whether a live, visible terminal cursor changes fill-vs-outline
|
|
468
579
|
/// because logical keyboard focus moved. Ended sessions are always
|
|
469
580
|
/// hollow and a grid without a cursor paints no focus-dependent pixels.
|
|
@@ -734,7 +845,7 @@ fn widgetFrameStrokeWidth(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
734
845
|
return switch (widget.kind) {
|
|
735
846
|
.accordion, .alert, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover, .menu_surface, .dropdown_menu => controlStrokeWidth(widget, surfaceControlVisualTokens(widget, tokens), tokens.stroke.hairline),
|
|
736
847
|
.button, .toggle_button, .toggle, .icon_button => if (widget.state.focused) tokens.stroke.focus else buttonStrokeWidth(widget, tokens),
|
|
737
|
-
.select => if (widget.state.focused) tokens.stroke.focus else controlStrokeWidth(widget, selectControlVisualTokens(tokens), tokens.stroke.regular),
|
|
848
|
+
.select => if (widget.state.focused) tokens.stroke.focus else controlStrokeWidth(widget, selectControlVisualTokens(widget, tokens), tokens.stroke.regular),
|
|
738
849
|
.input, .text_field, .search_field, .combobox, .textarea, .input_group => if (widget.state.focused) tokens.stroke.focus else controlStrokeWidth(widget, textInputControlVisualTokens(widget, tokens), tokens.stroke.regular),
|
|
739
850
|
.segmented_control => if (widget.state.focused) tokens.stroke.focus else controlStrokeWidth(widget, selectionControlVisualTokens(widget, tokens), tokens.stroke.regular),
|
|
740
851
|
.data_cell => if (widget.state.focused) tokens.stroke.focus else controlStrokeWidth(widget, listItemControlVisualTokens(widget, tokens), tokens.stroke.hairline),
|