@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
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
//! the OTHER axis along for the ride — would snap the OS scroller back
|
|
25
25
|
//! mid-gesture.
|
|
26
26
|
|
|
27
|
+
const host_regions = @import("host_input_regions_policy.zig");
|
|
27
28
|
const std = @import("std");
|
|
28
29
|
const geometry = @import("geometry");
|
|
29
30
|
const canvas = @import("canvas");
|
|
@@ -49,8 +50,12 @@ pub fn RuntimeCanvasWidgetScrollDrivers(comptime Runtime: type) type {
|
|
|
49
50
|
/// engine's drawn scrollbar and kinetic stepper stand down. Runs
|
|
50
51
|
/// on the reconciled nodes before they are copied into the view,
|
|
51
52
|
/// so rebuild-time clamping sees the flag too.
|
|
52
|
-
pub fn stampCanvasWidgetNativeScroll(self: *const Runtime, nodes: []canvas.WidgetLayoutNode) void {
|
|
53
|
+
pub fn stampCanvasWidgetNativeScroll(self: *const Runtime, nodes: []canvas.WidgetLayoutNode, policy: host_regions.Policy) void {
|
|
53
54
|
if (!canvasWidgetScrollDriversSupported(self)) return;
|
|
55
|
+
if (host_regions.plan(policy, .stamp, .{ .nodes = nodes, .supported = true })) |program| {
|
|
56
|
+
program.stamp(nodes);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
54
59
|
for (nodes) |*node| {
|
|
55
60
|
if (canvasWidgetScrollDriverEligible(node.*)) node.widget.runtime_flags.native_scroll = true;
|
|
56
61
|
}
|
|
@@ -65,6 +70,27 @@ pub fn RuntimeCanvasWidgetScrollDrivers(comptime Runtime: type) type {
|
|
|
65
70
|
if (self.views[view_index].kind != .gpu_surface or !self.views[view_index].open) return;
|
|
66
71
|
if (!canvasWidgetScrollDriversSupported(self)) return;
|
|
67
72
|
const view = &self.views[view_index];
|
|
73
|
+
if (host_regions.plan(view.canvas_widget_surface_scope_policy, .drivers, .{
|
|
74
|
+
.nodes = view.widget_layout_nodes[0..view.widget_layout_node_count],
|
|
75
|
+
.tokens = view.widget_tokens,
|
|
76
|
+
.frame = view.frame,
|
|
77
|
+
.supported = true,
|
|
78
|
+
.measure_view = view,
|
|
79
|
+
.tracked_ids = view.scroll_driver_ids[0..view.scroll_driver_count],
|
|
80
|
+
.tracked_offsets = view.scroll_driver_offsets[0..view.scroll_driver_count],
|
|
81
|
+
})) |program| {
|
|
82
|
+
program.stamp(view.widget_layout_nodes[0..view.widget_layout_node_count]);
|
|
83
|
+
self.options.platform.services.setGpuSurfaceScrollDrivers(view.window_id, view.label, program.drivers[0..program.driver_count], program.occluders[0..program.occluder_count]) catch |err| {
|
|
84
|
+
if (err != error.UnsupportedService) scroll_driver_log.warn("scroll driver sync failed for view '{s}': {s}", .{ view.label, @errorName(err) });
|
|
85
|
+
return;
|
|
86
|
+
};
|
|
87
|
+
for (program.drivers[0..program.driver_count], 0..) |driver, i| {
|
|
88
|
+
view.scroll_driver_ids[i] = driver.id;
|
|
89
|
+
view.scroll_driver_offsets[i] = .init(driver.offset_x, driver.offset_y);
|
|
90
|
+
}
|
|
91
|
+
view.scroll_driver_count = program.driver_count;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
68
94
|
|
|
69
95
|
var drivers: [platform.max_gpu_surface_scroll_drivers]platform.GpuSurfaceScrollDriver = undefined;
|
|
70
96
|
var ids: [platform.max_gpu_surface_scroll_drivers]u64 = undefined;
|
|
@@ -309,6 +335,18 @@ fn trackedScrollDriverOffset(view: anytype, driver_id: u64) ?geometry.OffsetF {
|
|
|
309
335
|
}
|
|
310
336
|
|
|
311
337
|
fn recordScrollDriverOffset(view: anytype, driver_id: u64, offset: geometry.OffsetF) void {
|
|
338
|
+
if (host_regions.plan(view.canvas_widget_surface_scope_policy, .record, .{
|
|
339
|
+
.record_id = driver_id,
|
|
340
|
+
.tracked_ids = view.scroll_driver_ids[0..view.scroll_driver_count],
|
|
341
|
+
.tracked_offsets = view.scroll_driver_offsets[0..view.scroll_driver_count],
|
|
342
|
+
})) |program| {
|
|
343
|
+
if (program.detail == std.math.maxInt(u32)) return;
|
|
344
|
+
const index = program.detail;
|
|
345
|
+
view.scroll_driver_ids[index] = driver_id;
|
|
346
|
+
view.scroll_driver_offsets[index] = offset;
|
|
347
|
+
if (index == view.scroll_driver_count) view.scroll_driver_count += 1;
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
312
350
|
for (view.scroll_driver_ids[0..view.scroll_driver_count], 0..) |id, index| {
|
|
313
351
|
if (id != driver_id) continue;
|
|
314
352
|
view.scroll_driver_offsets[index] = offset;
|
|
@@ -752,6 +752,37 @@ test "runtime applies stored design token scroll physics" {
|
|
|
752
752
|
try std.testing.expectApproxEqAbs(@as(f32, 21.28), retained.nodes[0].widget.value, 0.001);
|
|
753
753
|
try std.testing.expectApproxEqAbs(@as(f32, -21.28), retained.nodes[1].frame.y, 0.001);
|
|
754
754
|
try std.testing.expectEqual(@as(f32, 80), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
|
|
755
|
+
|
|
756
|
+
// A mechanical notch uses the same distance multiplier, but cancels
|
|
757
|
+
// the preceding smooth scroll's velocity and cannot start a fling.
|
|
758
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
759
|
+
.window_id = 1,
|
|
760
|
+
.label = "canvas",
|
|
761
|
+
.kind = .scroll,
|
|
762
|
+
.scroll_is_detented = true,
|
|
763
|
+
.x = 20,
|
|
764
|
+
.y = 20,
|
|
765
|
+
.delta_y = 40,
|
|
766
|
+
.timestamp_ns = 1_000_000_000,
|
|
767
|
+
} });
|
|
768
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
769
|
+
try std.testing.expectApproxEqAbs(@as(f32, 41.28), retained.nodes[0].widget.value, 0.001);
|
|
770
|
+
try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
|
|
771
|
+
try std.testing.expect(!harness.runtime.views[0].canvasWidgetKineticScrollActive());
|
|
772
|
+
|
|
773
|
+
for (1..3) |frame_index| {
|
|
774
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
775
|
+
.window_id = 1,
|
|
776
|
+
.label = "canvas",
|
|
777
|
+
.size = geometry.SizeF.init(180, 72),
|
|
778
|
+
.scale_factor = 1,
|
|
779
|
+
.frame_index = frame_index,
|
|
780
|
+
.timestamp_ns = 1_000_000_000 + frame_index * 16_000_000,
|
|
781
|
+
.frame_interval_ns = 16_000_000,
|
|
782
|
+
} });
|
|
783
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
784
|
+
try std.testing.expectApproxEqAbs(@as(f32, 41.28), retained.nodes[0].widget.value, 0.001);
|
|
785
|
+
}
|
|
755
786
|
}
|
|
756
787
|
|
|
757
788
|
test "runtime refreshes hovered canvas widget after scroll clipping" {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const motion_policy = @import("widget_motion_policy.zig");
|
|
3
|
+
const sampling_policy = @import("motion_sampling_policy.zig");
|
|
2
4
|
const geometry = @import("geometry");
|
|
3
5
|
const canvas = @import("canvas");
|
|
4
6
|
const platform = @import("../platform/root.zig");
|
|
@@ -10,13 +12,11 @@ const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
|
|
|
10
12
|
const runtime_canvas_widget_scroll_drivers = @import("canvas_widget_scroll_drivers.zig");
|
|
11
13
|
const launch_timing = @import("launch_timing.zig");
|
|
12
14
|
const runtime_canvas_widget_display = @import("canvas_widget_display.zig");
|
|
13
|
-
const runtime_view = @import("view.zig");
|
|
14
15
|
const runtime_canvas_widget_events = @import("canvas_widget_events.zig");
|
|
15
16
|
const runtime_automation_widget_dispatch = @import("automation_widget_dispatch.zig");
|
|
16
17
|
const runtime_gpu_surface_events = @import("gpu_surface_events.zig");
|
|
17
18
|
const widget_bridge = @import("widget_bridge.zig");
|
|
18
19
|
|
|
19
|
-
const validateViewLabel = validation.validateViewLabel;
|
|
20
20
|
const max_canvas_widget_nodes_per_view = canvas_limits.max_canvas_widget_nodes_per_view;
|
|
21
21
|
const max_canvas_widget_semantics_per_view = canvas_limits.max_canvas_widget_semantics_per_view;
|
|
22
22
|
const max_canvas_widget_text_bytes_per_view = canvas_limits.max_canvas_widget_text_bytes_per_view;
|
|
@@ -54,7 +54,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
54
54
|
return struct {
|
|
55
55
|
pub fn setCanvasWidgetLayout(self: *Runtime, window_id: platform.WindowId, label: []const u8, layout: canvas.WidgetLayoutTree) anyerror!platform.ViewInfo {
|
|
56
56
|
try validateRuntimeViewParent(self, window_id);
|
|
57
|
-
try
|
|
57
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
58
58
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
59
59
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
60
60
|
if (layout.nodes.len > max_canvas_widget_nodes_per_view) return error.WidgetNodeLimitReached;
|
|
@@ -76,7 +76,8 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
76
76
|
const previous_layout = self.views[index].widgetLayoutTree();
|
|
77
77
|
const source_semantics = try layout.collectSemantics(&self.canvas_widget_source_semantics_scratch);
|
|
78
78
|
const reconciled_nodes = &self.canvas_widget_reconcile_nodes;
|
|
79
|
-
|
|
79
|
+
var tokens = self.views[index].widget_tokens;
|
|
80
|
+
tokens.text_run_policy = layout.text_run_policy orelse tokens.text_run_policy;
|
|
80
81
|
// Reconcile scratch lives on the Runtime, not the stack: at
|
|
81
82
|
// the 1024-node budget these arrays total several hundred
|
|
82
83
|
// KiB, and the single-threaded event loop makes the shared
|
|
@@ -114,7 +115,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
114
115
|
// regions before the copy so rebuild-time clamping and display
|
|
115
116
|
// emission both see the flag (engine scrollbar + engine clamp
|
|
116
117
|
// stand down; the OS scroller owns them).
|
|
117
|
-
ScrollDriverMethods(Runtime).stampCanvasWidgetNativeScroll(self, reconciled_nodes[0..reconciled_layout.nodes.len]);
|
|
118
|
+
ScrollDriverMethods(Runtime).stampCanvasWidgetNativeScroll(self, reconciled_nodes[0..reconciled_layout.nodes.len], self.views[index].canvas_widget_surface_scope_policy);
|
|
118
119
|
// Engine-side rebuild clamp AFTER the stamp: natively driven
|
|
119
120
|
// regions skip it, so a rebuild landing mid-rubber-band keeps
|
|
120
121
|
// the OS scroller's overscrolled offset instead of clamping it
|
|
@@ -169,11 +170,11 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
169
170
|
// replaces the former. The plan applies after the copy,
|
|
170
171
|
// where it can restore the previous pose onto the freshly
|
|
171
172
|
// retained nodes.
|
|
172
|
-
const disclosure_plan = planCanvasWidgetDisclosureTween(self, index, previous_layout, reconciled_layout);
|
|
173
|
+
const disclosure_plan = try planCanvasWidgetDisclosureTween(self, index, previous_layout, reconciled_layout);
|
|
173
174
|
// Drag reflow uses the same two-pose planning seam, but keeps
|
|
174
175
|
// the adopted layout at its truthful final geometry and records
|
|
175
176
|
// presentation-only offsets for keyed draggable widgets.
|
|
176
|
-
const drag_layout_motion_plan = planCanvasWidgetDragLayoutMotion(self, index, previous_layout, reconciled_layout);
|
|
177
|
+
const drag_layout_motion_plan = try planCanvasWidgetDragLayoutMotion(self, index, previous_layout, reconciled_layout);
|
|
177
178
|
const previous_cursor = self.views[index].canvas_widget_cursor;
|
|
178
179
|
const previous_widget_revision = self.views[index].widget_revision;
|
|
179
180
|
// The adoption witness (`canvas_widget_layout_adoptions`)
|
|
@@ -253,7 +254,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
253
254
|
|
|
254
255
|
pub fn canvasWidgetLayout(self: *const Runtime, window_id: platform.WindowId, label: []const u8) anyerror!canvas.WidgetLayoutTree {
|
|
255
256
|
try validateRuntimeViewParent(self, window_id);
|
|
256
|
-
try
|
|
257
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
257
258
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
258
259
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
259
260
|
return self.views[index].widgetLayoutTree();
|
|
@@ -261,7 +262,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
261
262
|
|
|
262
263
|
pub fn canvasWidgetSemantics(self: *const Runtime, window_id: platform.WindowId, label: []const u8) anyerror![]const canvas.WidgetSemanticsNode {
|
|
263
264
|
try validateRuntimeViewParent(self, window_id);
|
|
264
|
-
try
|
|
265
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
265
266
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
266
267
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
267
268
|
return self.views[index].widgetSemantics();
|
|
@@ -275,7 +276,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
275
276
|
action: runtime_api.CanvasWidgetAccessibilityAction,
|
|
276
277
|
) anyerror!platform.ViewInfo {
|
|
277
278
|
try validateRuntimeViewParent(self, window_id);
|
|
278
|
-
try
|
|
279
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
279
280
|
if (action.id == 0) return error.InvalidCommand;
|
|
280
281
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
281
282
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
@@ -370,7 +371,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
370
371
|
|
|
371
372
|
pub fn stepCanvasWidgetKineticScroll(self: *Runtime, window_id: platform.WindowId, label: []const u8, dt_ms: f32) anyerror!platform.ViewInfo {
|
|
372
373
|
try validateRuntimeViewParent(self, window_id);
|
|
373
|
-
try
|
|
374
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
374
375
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
375
376
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
376
377
|
|
|
@@ -416,7 +417,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
416
417
|
/// drag tracks the pointer and must re-wrap live.
|
|
417
418
|
pub fn startCanvasWidgetLayoutTween(self: *Runtime, window_id: platform.WindowId, label: []const u8, tween: canvas.CanvasWidgetLayoutTween) anyerror!platform.ViewInfo {
|
|
418
419
|
try validateRuntimeViewParent(self, window_id);
|
|
419
|
-
try
|
|
420
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
420
421
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
421
422
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
422
423
|
try startCanvasWidgetLayoutTweenForView(self, index, tween, true);
|
|
@@ -435,6 +436,37 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
435
436
|
/// armed this tween IS the target declaration; echoing it back
|
|
436
437
|
/// would be a redundant rebuild).
|
|
437
438
|
fn startCanvasWidgetLayoutTweenForView(self: *Runtime, index: usize, tween: canvas.CanvasWidgetLayoutTween, announce: bool) anyerror!void {
|
|
439
|
+
if (self.views[index].widget_tokens.widget_motion_policy) |policy| {
|
|
440
|
+
const view = &self.views[index];
|
|
441
|
+
const node_index = view.canvasWidgetNodeIndexById(tween.id);
|
|
442
|
+
const active = view.findCanvasWidgetLayoutTween(tween.id);
|
|
443
|
+
const current = if (node_index) |i| view.widget_layout_nodes[i].widget.value else 0;
|
|
444
|
+
const flags = @as(u8, @intFromBool(tween.id != 0)) | (@as(u8, @intFromBool(std.math.isFinite(tween.to))) << 1) |
|
|
445
|
+
(@as(u8, @intFromBool(if (node_index) |i| view.widget_layout_nodes[i].widget.kind == .split else false)) << 2) |
|
|
446
|
+
(@as(u8, @intFromBool(active != null)) << 3) | (@as(u8, @intFromBool(self.appearance.reduce_motion)) << 4) |
|
|
447
|
+
(@as(u8, @intFromBool(view.canvas_widget_layout_tween_count < view.canvas_widget_layout_tweens.len)) << 5) |
|
|
448
|
+
(@as(u8, @intFromBool(announce)) << 6);
|
|
449
|
+
const plan = motion_policy.admission(policy, flags, tween.duration_ms, current, tween.to, if (active) |v| v.spec.to else 0);
|
|
450
|
+
if (plan.action == .invalid) return error.InvalidCommand;
|
|
451
|
+
if (plan.remove) view.removeCanvasWidgetLayoutTween(tween.id);
|
|
452
|
+
switch (plan.action) {
|
|
453
|
+
.none => return,
|
|
454
|
+
.snap => if (try view.applyCanvasWidgetSplitFraction(node_index.?, tween.to)) |dirty| {
|
|
455
|
+
try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, index, dirty);
|
|
456
|
+
},
|
|
457
|
+
.arm => if (!view.armCanvasWidgetLayoutTween(.{ .spec = tween, .from = current })) @panic("compiled tween slot admission changed"),
|
|
458
|
+
.retarget => {
|
|
459
|
+
const retained = view.findCanvasWidgetLayoutTween(tween.id) orelse @panic("compiled tween owner vanished");
|
|
460
|
+
retained.spec = tween;
|
|
461
|
+
retained.from = current;
|
|
462
|
+
retained.start_ns = 0;
|
|
463
|
+
},
|
|
464
|
+
.invalid => unreachable,
|
|
465
|
+
}
|
|
466
|
+
if (plan.announce) view.noteCanvasWidgetResizeEvent(tween.id);
|
|
467
|
+
if (plan.frame) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
438
470
|
if (tween.id == 0) return error.InvalidCommand;
|
|
439
471
|
if (!std.math.isFinite(tween.to)) return error.InvalidCommand;
|
|
440
472
|
const node_index = self.views[index].canvasWidgetNodeIndexById(tween.id) orelse return error.InvalidCommand;
|
|
@@ -485,10 +517,13 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
485
517
|
/// tween re-arms on the first rebuild after release.
|
|
486
518
|
fn armSourceDeclaredLayoutTweens(self: *Runtime, index: usize, source: canvas.WidgetLayoutTree) anyerror!void {
|
|
487
519
|
for (source.nodes) |node| {
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
520
|
+
if (self.views[index].widget_tokens.widget_motion_policy) |policy| {
|
|
521
|
+
if (!motion_policy.source(policy, node.widget.kind, node.widget.id, canvasWidgetSplitDividerPressed(self, index, node.widget.id), node.widget.resize_duration_ms, node.widget.value)) continue;
|
|
522
|
+
} else {
|
|
523
|
+
if (node.widget.kind != .split or node.widget.id == 0) continue;
|
|
524
|
+
if (node.widget.resize_duration_ms == 0 or node.widget.value == 0) continue;
|
|
525
|
+
if (canvasWidgetSplitDividerPressed(self, index, node.widget.id)) continue;
|
|
526
|
+
}
|
|
492
527
|
startCanvasWidgetLayoutTweenForView(self, index, .{
|
|
493
528
|
.id = node.widget.id,
|
|
494
529
|
.to = node.widget.value,
|
|
@@ -538,21 +573,17 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
538
573
|
/// reflow stopped being disclosure-shaped) — the new pose
|
|
539
574
|
/// stands snapped;
|
|
540
575
|
/// - `none`: nothing armed, nothing to arm.
|
|
541
|
-
const CanvasWidgetDisclosureAction =
|
|
542
|
-
|
|
543
|
-
const CanvasWidgetDragLayoutMotionPlan = struct {
|
|
544
|
-
apply: bool = false,
|
|
545
|
-
motions: [canvas_limits.max_canvas_widget_drag_layout_motions_per_view]canvas.WidgetLayoutMotion = undefined,
|
|
546
|
-
motion_count: usize = 0,
|
|
547
|
-
};
|
|
576
|
+
const CanvasWidgetDisclosureAction = motion_policy.DisclosureAction;
|
|
577
|
+
const CanvasWidgetDragLayoutMotionPlan = motion_policy.DragPlan;
|
|
548
578
|
|
|
549
579
|
/// FLIP planning for drag-driven list/board reflow. Each keyed
|
|
550
580
|
/// draggable begins at its CURRENTLY PRESENTED origin (including an
|
|
551
581
|
/// in-flight offset) and eases toward the newly declared frame. New
|
|
552
582
|
/// placeholders have no previous pose and therefore appear as the
|
|
553
583
|
/// honest blank destination immediately.
|
|
554
|
-
fn planCanvasWidgetDragLayoutMotion(self: *Runtime, view_index: usize, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree) CanvasWidgetDragLayoutMotionPlan {
|
|
584
|
+
fn planCanvasWidgetDragLayoutMotion(self: *Runtime, view_index: usize, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree) anyerror!CanvasWidgetDragLayoutMotionPlan {
|
|
555
585
|
const view = &self.views[view_index];
|
|
586
|
+
if (self.views[view_index].widget_tokens.widget_motion_policy) |policy| return motion_policy.drag(self.owned_allocator, policy, previous, next, &self.views[view_index], self.appearance.reduce_motion);
|
|
556
587
|
var plan = CanvasWidgetDragLayoutMotionPlan{};
|
|
557
588
|
if (!view.canvas_widget_drag_layout_motion_armed) return plan;
|
|
558
589
|
plan.apply = true;
|
|
@@ -632,21 +663,15 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
632
663
|
return previous_count > 0 or plan.motion_count > 0;
|
|
633
664
|
}
|
|
634
665
|
|
|
635
|
-
const CanvasWidgetDisclosurePlan =
|
|
636
|
-
action: CanvasWidgetDisclosureAction = .none,
|
|
637
|
-
duration_ms: u32 = 0,
|
|
638
|
-
revealing_ids: [canvas_limits.max_canvas_widget_disclosure_flips_per_view]canvas.ObjectId = undefined,
|
|
639
|
-
revealing_id_count: usize = 0,
|
|
640
|
-
moves: [canvas_limits.max_canvas_widget_disclosure_moves_per_view]runtime_view.CanvasWidgetDisclosureMove = undefined,
|
|
641
|
-
move_count: usize = 0,
|
|
642
|
-
};
|
|
666
|
+
const CanvasWidgetDisclosurePlan = motion_policy.DisclosurePlan;
|
|
643
667
|
|
|
644
668
|
/// The planning half of the disclosure tween (see
|
|
645
669
|
/// `CanvasWidgetDisclosureTweenState` for the design): pure
|
|
646
670
|
/// reads over the previous retained pose and the reconciled
|
|
647
671
|
/// next pose, no mutation — the caller applies the plan after
|
|
648
672
|
/// the reconciled tree is retained.
|
|
649
|
-
fn planCanvasWidgetDisclosureTween(self: *Runtime, view_index: usize, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree) CanvasWidgetDisclosurePlan {
|
|
673
|
+
fn planCanvasWidgetDisclosureTween(self: *Runtime, view_index: usize, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree) anyerror!CanvasWidgetDisclosurePlan {
|
|
674
|
+
if (self.views[view_index].widget_tokens.widget_motion_policy) |policy| return motion_policy.disclosure(self.owned_allocator, policy, previous, next, &self.views[view_index], self.appearance.reduce_motion);
|
|
650
675
|
var plan = CanvasWidgetDisclosurePlan{};
|
|
651
676
|
const view = &self.views[view_index];
|
|
652
677
|
const was_active = view.canvas_widget_disclosure_tween.active;
|
|
@@ -794,8 +819,9 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
794
819
|
const node = &view.widget_layout_nodes[move.node_index];
|
|
795
820
|
move.to_y = node.frame.y;
|
|
796
821
|
move.to_height = node.frame.height;
|
|
797
|
-
const
|
|
798
|
-
const
|
|
822
|
+
const pose = if (view.widget_tokens.widget_motion_policy) |policy| motion_policy.pose(policy, 2, tween.progress, move.from_y, move.to_y, move.from_height, move.to_height) else motion_policy.Pose{ .done = tween.progress >= 1, .a = move.from_y + (move.to_y - move.from_y) * tween.progress, .b = move.from_height + (move.to_height - move.from_height) * tween.progress };
|
|
823
|
+
const y = pose.a;
|
|
824
|
+
const height = pose.b;
|
|
799
825
|
if (node.frame.y == y and node.frame.height == height) continue;
|
|
800
826
|
node.frame.y = y;
|
|
801
827
|
node.frame.height = height;
|
|
@@ -829,19 +855,22 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
829
855
|
// First advancing frame stamps the clock — the split
|
|
830
856
|
// tween's discipline, so the ramp runs on the frame clock
|
|
831
857
|
// from the first frame that could have painted it.
|
|
832
|
-
if (
|
|
858
|
+
if (view.widget_tokens.widget_motion_policy) |policy| {
|
|
859
|
+
tween.start_ns = motion_policy.clock(policy, tween.start_ns, timestamp_ns);
|
|
860
|
+
} else if (tween.start_ns == 0 or timestamp_ns < tween.start_ns) {
|
|
833
861
|
tween.start_ns = timestamp_ns;
|
|
834
862
|
}
|
|
835
|
-
const progress = canvas.layoutTweenProgress(tween.easing, tween.spring, tween.start_ns, tween.duration_ms, timestamp_ns);
|
|
836
|
-
const done = progress >= 1;
|
|
863
|
+
const progress = if (view.widget_tokens.widget_motion_policy) |policy| sampling_policy.progress(tween.easing, tween.spring, tween.start_ns, tween.duration_ms, timestamp_ns, policy) else canvas.layoutTweenProgress(tween.easing, tween.spring, tween.start_ns, tween.duration_ms, timestamp_ns);
|
|
864
|
+
const done = if (view.widget_tokens.widget_motion_policy) |policy| motion_policy.pose(policy, 1, progress, 0, 0, 0, 0).done else progress >= 1;
|
|
837
865
|
tween.progress = progress;
|
|
838
866
|
|
|
839
867
|
var dirty: ?geometry.RectF = null;
|
|
840
868
|
for (tween.moves[0..tween.move_count]) |move| {
|
|
841
869
|
if (move.node_index >= view.widget_layout_node_count) continue;
|
|
842
870
|
const node = &view.widget_layout_nodes[move.node_index];
|
|
843
|
-
const
|
|
844
|
-
const
|
|
871
|
+
const pose = if (view.widget_tokens.widget_motion_policy) |policy| motion_policy.pose(policy, 1, progress, move.from_y, move.to_y, move.from_height, move.to_height) else motion_policy.Pose{ .done = done, .a = if (done) move.to_y else move.from_y + (move.to_y - move.from_y) * progress, .b = if (done) move.to_height else move.from_height + (move.to_height - move.from_height) * progress };
|
|
872
|
+
const y = pose.a;
|
|
873
|
+
const height = pose.b;
|
|
845
874
|
if (node.frame.y == y and node.frame.height == height) continue;
|
|
846
875
|
dirty = unionDisclosureDirty(dirty, node.frame.normalized());
|
|
847
876
|
node.frame.y = y;
|
|
@@ -879,13 +908,18 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
879
908
|
for (view.canvas_widget_drag_layout_motions[0..view.canvas_widget_drag_layout_motion_count]) |motion_value| {
|
|
880
909
|
if (view.canvasWidgetNodeIndexById(motion_value.id) == null) continue;
|
|
881
910
|
var motion = motion_value;
|
|
882
|
-
if (
|
|
883
|
-
|
|
884
|
-
if (
|
|
885
|
-
motion.
|
|
886
|
-
|
|
887
|
-
motion.from_offset.
|
|
888
|
-
|
|
911
|
+
if (view.widget_tokens.widget_motion_policy) |policy| {
|
|
912
|
+
motion.start_ns = motion_policy.clock(policy, motion.start_ns, timestamp_ns);
|
|
913
|
+
} else if (motion.start_ns == 0 or timestamp_ns < motion.start_ns) motion.start_ns = timestamp_ns;
|
|
914
|
+
const progress = if (view.widget_tokens.widget_motion_policy) |policy| sampling_policy.progress(motion.easing, motion.spring, motion.start_ns, motion.duration_ms, timestamp_ns, policy) else canvas.layoutTweenProgress(motion.easing, motion.spring, motion.start_ns, motion.duration_ms, timestamp_ns);
|
|
915
|
+
if (view.widget_tokens.widget_motion_policy) |policy| {
|
|
916
|
+
const pose = motion_policy.pose(policy, 3, progress, motion.from_offset.dx, 0, motion.from_offset.dy, 0);
|
|
917
|
+
if (pose.done) continue;
|
|
918
|
+
motion.offset = .init(pose.a, pose.b);
|
|
919
|
+
} else {
|
|
920
|
+
if (progress >= 1) continue;
|
|
921
|
+
motion.offset = geometry.OffsetF.init(motion.from_offset.dx * (1 - progress), motion.from_offset.dy * (1 - progress));
|
|
922
|
+
}
|
|
889
923
|
view.canvas_widget_drag_layout_motions[write_index] = motion;
|
|
890
924
|
write_index += 1;
|
|
891
925
|
}
|
|
@@ -928,12 +962,15 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
928
962
|
// First advancing frame stamps the clock: the ramp runs
|
|
929
963
|
// on the frame clock from the first frame that could
|
|
930
964
|
// have painted it, the manual idiom's discipline.
|
|
931
|
-
if (
|
|
965
|
+
if (self.views[view_index].widget_tokens.widget_motion_policy) |policy| {
|
|
966
|
+
tween.start_ns = motion_policy.clock(policy, tween.start_ns, timestamp_ns);
|
|
967
|
+
} else if (tween.start_ns == 0 or timestamp_ns < tween.start_ns) {
|
|
932
968
|
tween.start_ns = timestamp_ns;
|
|
933
969
|
}
|
|
934
|
-
const progress = canvas.layoutTweenProgress(tween.spec.easing, tween.spec.spring, tween.start_ns, tween.spec.duration_ms, timestamp_ns);
|
|
935
|
-
const done = progress >= 1;
|
|
936
|
-
const
|
|
970
|
+
const progress = if (self.views[view_index].widget_tokens.widget_motion_policy) |policy| sampling_policy.progress(tween.spec.easing, tween.spec.spring, tween.start_ns, tween.spec.duration_ms, timestamp_ns, policy) else canvas.layoutTweenProgress(tween.spec.easing, tween.spec.spring, tween.start_ns, tween.spec.duration_ms, timestamp_ns);
|
|
971
|
+
const pose = if (self.views[view_index].widget_tokens.widget_motion_policy) |policy| motion_policy.pose(policy, 0, progress, tween.from, tween.spec.to, 0, 0) else motion_policy.Pose{ .done = progress >= 1, .a = if (progress >= 1) tween.spec.to else tween.from + (tween.spec.to - tween.from) * progress, .b = 0 };
|
|
972
|
+
const done = pose.done;
|
|
973
|
+
const value = pose.a;
|
|
937
974
|
const dirty = if (done)
|
|
938
975
|
try self.views[view_index].applyCanvasWidgetSplitFraction(node_index, value)
|
|
939
976
|
else
|
|
@@ -967,7 +1004,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
967
1004
|
|
|
968
1005
|
pub fn setCanvasWidgetDesignTokens(self: *Runtime, window_id: platform.WindowId, label: []const u8, tokens: canvas.DesignTokens) anyerror!platform.ViewInfo {
|
|
969
1006
|
try validateRuntimeViewParent(self, window_id);
|
|
970
|
-
try
|
|
1007
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
971
1008
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
972
1009
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
973
1010
|
if (std.meta.eql(self.views[index].widget_tokens, tokens)) return self.views[index].info();
|
|
@@ -982,7 +1019,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
982
1019
|
|
|
983
1020
|
pub fn canvasWidgetDesignTokens(self: *const Runtime, window_id: platform.WindowId, label: []const u8) anyerror!canvas.DesignTokens {
|
|
984
1021
|
try validateRuntimeViewParent(self, window_id);
|
|
985
|
-
try
|
|
1022
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
986
1023
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
987
1024
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
988
1025
|
return self.views[index].widget_tokens;
|
|
@@ -990,7 +1027,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
990
1027
|
|
|
991
1028
|
pub fn canvasWidgetTextGeometry(self: *const Runtime, window_id: platform.WindowId, label: []const u8, id: canvas.ObjectId) anyerror!canvas.WidgetTextGeometry {
|
|
992
1029
|
try validateRuntimeViewParent(self, window_id);
|
|
993
|
-
try
|
|
1030
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
994
1031
|
if (id == 0) return error.InvalidCommand;
|
|
995
1032
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
996
1033
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
@@ -1001,7 +1038,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
1001
1038
|
|
|
1002
1039
|
pub fn editCanvasWidgetText(self: *Runtime, window_id: platform.WindowId, label: []const u8, id: canvas.ObjectId, edit: canvas.TextInputEvent) anyerror!platform.ViewInfo {
|
|
1003
1040
|
try validateRuntimeViewParent(self, window_id);
|
|
1004
|
-
try
|
|
1041
|
+
try @import("shell_admission_policy.zig").label(self.shell_admission_policy, 0, label);
|
|
1005
1042
|
if (id == 0) return error.InvalidCommand;
|
|
1006
1043
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
1007
1044
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
@@ -1011,7 +1048,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
1011
1048
|
// source (the keyboard choke point's rule): a single-line
|
|
1012
1049
|
// field's editor never accepts a line break, whoever writes.
|
|
1013
1050
|
const node = self.views[index].widgetLayoutTree().findById(id) orelse return error.InvalidCommand;
|
|
1014
|
-
const sanitized = canvas.
|
|
1051
|
+
const sanitized = canvas.sanitizedTextInputEventForWidget(node.widget, edit) orelse return self.views[index].info();
|
|
1015
1052
|
if (self.views[index].canvasWidgetTextEditNeedsLargeStorage(id, sanitized)) {
|
|
1016
1053
|
try ensureCanvasWidgetLargeTextStorageThrough(self, index);
|
|
1017
1054
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//! Explicit native external-producer capabilities. Portable app state and
|
|
2
|
+
//! channel lifecycle stay in the app; this source owns a detached OS sampler.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const builtin = @import("builtin");
|
|
5
|
+
const effects = @import("effects.zig");
|
|
6
|
+
const clock = @import("clock.zig");
|
|
7
|
+
const sample_interval_ms = 500;
|
|
8
|
+
const max_line_bytes = 96;
|
|
9
|
+
|
|
10
|
+
pub fn start(name: []const u8, payload: []const u8, handle: effects.ChannelHandle) !void {
|
|
11
|
+
if (!std.mem.eql(u8, name, "native-sdk.process.samples")) return error.UnknownChannelSource;
|
|
12
|
+
if (payload.len != 0) return error.InvalidChannelSourceArguments;
|
|
13
|
+
if (comptime builtin.single_threaded) return error.UnsupportedChannelSource;
|
|
14
|
+
try startSamplerThread(handle);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fn startSamplerThread(handle: effects.ChannelHandle) std.Thread.SpawnError!void {
|
|
18
|
+
const thread = try std.Thread.spawn(.{}, samplerMain, .{handle});
|
|
19
|
+
thread.detach();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// The app-owned source: real process readings on a real thread, paced
|
|
23
|
+
/// by its own sleep — the loop never ticks for it.
|
|
24
|
+
fn samplerMain(handle: effects.ChannelHandle) void {
|
|
25
|
+
var threaded: std.Io.Threaded = .init(std.heap.page_allocator, .{});
|
|
26
|
+
defer threaded.deinit();
|
|
27
|
+
const io = threaded.io();
|
|
28
|
+
const started_ms = clock.monotonicMs();
|
|
29
|
+
var index: u64 = 0;
|
|
30
|
+
while (true) {
|
|
31
|
+
std.Io.sleep(io, std.Io.Duration.fromMilliseconds(sample_interval_ms), .awake) catch return;
|
|
32
|
+
index += 1;
|
|
33
|
+
var buffer: [max_line_bytes]u8 = undefined;
|
|
34
|
+
const line = formatSample(&buffer, index, started_ms);
|
|
35
|
+
// The post's answer is the worker's whole protocol — "retry
|
|
36
|
+
// later" and "stop forever" are different answers on purpose.
|
|
37
|
+
switch (handle.post(line)) {
|
|
38
|
+
// Staged: one `.data` Msg delivers on the next drain.
|
|
39
|
+
.accepted => {},
|
|
40
|
+
// Transient back-pressure: THIS sample is dropped and
|
|
41
|
+
// counted — the next delivered event carries the totals
|
|
42
|
+
// and the status line reports them — but sampling
|
|
43
|
+
// continues. A stalled drain is not a stop.
|
|
44
|
+
.dropped_full => {},
|
|
45
|
+
// A programming error by construction here: samples are
|
|
46
|
+
// bounded at max_line_bytes, far under the channel's
|
|
47
|
+
// post bound — no retry of the same bytes could ever land.
|
|
48
|
+
.dropped_oversized => unreachable,
|
|
49
|
+
// The occupancy is over for good — Stop closed the
|
|
50
|
+
// channel, or the app tore down. Wind down.
|
|
51
|
+
.closed => return,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// One reading of this process: sample ordinal, uptime, and (where the
|
|
57
|
+
/// OS reports it) the peak resident set size.
|
|
58
|
+
fn formatSample(buffer: []u8, index: u64, started_ms: u64) []const u8 {
|
|
59
|
+
const now_ms = clock.monotonicMs();
|
|
60
|
+
const uptime_ms: u64 = if (now_ms > started_ms) now_ms - started_ms else 0;
|
|
61
|
+
const rss_kb = currentMaxRssKb();
|
|
62
|
+
if (rss_kb > 0) {
|
|
63
|
+
return std.fmt.bufPrint(buffer, "sample {d}: uptime {d}.{d:0>1}s, peak rss {d} KiB", .{
|
|
64
|
+
index, uptime_ms / 1000, (uptime_ms % 1000) / 100, rss_kb,
|
|
65
|
+
}) catch "sample";
|
|
66
|
+
}
|
|
67
|
+
return std.fmt.bufPrint(buffer, "sample {d}: uptime {d}.{d:0>1}s", .{
|
|
68
|
+
index, uptime_ms / 1000, (uptime_ms % 1000) / 100,
|
|
69
|
+
}) catch "sample";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// This process's peak resident set size in KiB, 0 where unavailable.
|
|
73
|
+
/// macOS reports `maxrss` in bytes, Linux in KiB — normalized here.
|
|
74
|
+
fn currentMaxRssKb() u64 {
|
|
75
|
+
if (builtin.os.tag == .windows or !builtin.link_libc) return 0;
|
|
76
|
+
var usage: std.c.rusage = undefined;
|
|
77
|
+
if (std.c.getrusage(std.c.rusage.SELF, &usage) != 0) return 0;
|
|
78
|
+
const raw: u64 = @intCast(@max(usage.maxrss, 0));
|
|
79
|
+
return if (builtin.os.tag.isDarwin()) raw / 1024 else raw;
|
|
80
|
+
}
|