@native-sdk/cli 0.10.1 → 0.11.1
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 +393 -97
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +2030 -83
- package/native-sdk.d.ts +5 -1
- package/package.json +20 -14
- package/packages/core/compile-surface/core.ts +164 -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 +68 -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 +332 -5
- package/packages/core/sdk/core.ts +371 -85
- package/packages/core/sdk/events.d.ts +252 -0
- package/packages/core/sdk/events.ts +240 -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 +186 -19
- package/packages/core/src/cli.ts +2 -11
- 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/context_menus.ts +76 -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/diagnostics.ts +7 -0
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/extent_program.ts +53 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/frontend.ts +12 -10
- 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_canonical.ts +140 -0
- package/packages/core/src/markup_construction.ts +189 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/markup_display.ts +43 -0
- package/packages/core/src/markup_document.ts +226 -0
- package/packages/core/src/markup_elements.ts +225 -0
- package/packages/core/src/markup_expressions.ts +79 -0
- package/packages/core/src/markup_imports.ts +146 -0
- package/packages/core/src/markup_parser.ts +228 -0
- package/packages/core/src/markup_runtime.ts +93 -0
- package/packages/core/src/markup_scalars.ts +143 -0
- package/packages/core/src/markup_shapes.ts +243 -0
- package/packages/core/src/markup_specialized.ts +242 -0
- package/packages/core/src/markup_text.ts +86 -0
- package/packages/core/src/markup_values.ts +336 -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 +98 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +92 -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 +3954 -0
- package/packages/core/src/scalar_text.ts +82 -0
- package/packages/core/src/scroll_mutation.ts +86 -0
- package/packages/core/src/scroll_tree.ts +86 -0
- package/packages/core/src/service_contract.ts +55 -3
- 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 +14 -46
- package/packages/core/src/sqlite_codegen.ts +84 -0
- package/packages/core/src/staged_rebuild.ts +60 -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_bridge.ts +161 -0
- package/packages/core/src/view_check.ts +145 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_evaluator.ts +823 -0
- package/packages/core/src/view_frontend.ts +1102 -0
- package/packages/core/src/view_program.ts +221 -0
- package/packages/core/src/view_reload.ts +166 -0
- package/packages/core/src/view_reload_watch.ts +98 -0
- package/packages/core/src/view_sources.ts +34 -0
- package/packages/core/src/virtual_windows.ts +88 -0
- package/packages/core/src/web_panes.ts +67 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_continuity.ts +37 -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_reconcile.ts +63 -0
- package/packages/core/src/widget_retention.ts +62 -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 +77 -18
- package/skill-data/ts-core/SKILL.md +117 -11
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +288 -144
- package/src/app_runner/root.zig +39 -12
- package/src/app_runner/ts_compiled_view.zig +1702 -0
- package/src/app_runner/ts_core_main.zig +185 -14
- package/src/app_runner/ts_core_mobile.zig +25 -13
- package/src/automation/server.zig +57 -6
- 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/embed/host.zig +2 -0
- package/src/embed/tests.zig +2 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/keyboard_input.zig +32 -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 +4 -0
- package/src/platform/macos/appkit_host.h +7 -2
- package/src/platform/macos/appkit_host.m +219 -39
- package/src/platform/macos/cef_host.mm +15 -1
- package/src/platform/macos/global_shortcuts.zig +138 -0
- package/src/platform/macos/key_codes.zig +102 -0
- package/src/platform/macos/keyboard_input.zig +81 -0
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/root.zig +25 -3
- 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/webview_inspection_test.m +106 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +130 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +15 -0
- package/src/platform/types.zig +115 -0
- package/src/platform/windows/global_shortcuts.zig +157 -0
- package/src/platform/windows/key_codes.zig +63 -0
- package/src/platform/windows/keyboard_input.zig +136 -0
- package/src/platform/windows/root.zig +17 -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/decision_reuse.zig +133 -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/font_ttf.zig +27 -3
- package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
- package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
- package/src/primitives/canvas/fonts/OFL.txt +93 -0
- package/src/primitives/canvas/fonts/README.md +15 -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 +131 -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/markdown_tests.zig +3 -3
- 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 +15 -11
- package/src/primitives/canvas/reference_tests.zig +58 -0
- 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 +107 -4
- 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 +53 -37
- package/src/primitives/canvas/text_metrics_tests.zig +52 -7
- package/src/primitives/canvas/text_query_policy.zig +295 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +234 -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 +47 -0
- package/src/primitives/canvas/ui.zig +251 -83
- package/src/primitives/canvas/ui_markup.zig +207 -46
- package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +1724 -80
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
- package/src/primitives/canvas/ui_markup_construction.zig +146 -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_display.zig +82 -0
- package/src/primitives/canvas/ui_markup_document.zig +196 -0
- package/src/primitives/canvas/ui_markup_elements.zig +163 -0
- package/src/primitives/canvas/ui_markup_expr.zig +192 -2
- package/src/primitives/canvas/ui_markup_imports.zig +262 -0
- package/src/primitives/canvas/ui_markup_parser.zig +117 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
- package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
- package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
- package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_text.zig +128 -0
- package/src/primitives/canvas/ui_markup_values.zig +368 -0
- package/src/primitives/canvas/ui_markup_view.zig +3026 -57
- 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 +350 -0
- package/src/primitives/canvas/virtual_extents.zig +113 -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 +129 -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 +21 -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 +26 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +29 -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/bridge_payload.zig +2 -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 +183 -4
- package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
- 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 +720 -150
- 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/context_menu_policy.zig +112 -0
- package/src/runtime/core.zig +170 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +638 -33
- package/src/runtime/effects_host_tests.zig +25 -0
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +419 -341
- package/src/runtime/flow_reference.zig +1427 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/global_shortcuts.zig +75 -0
- 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/keyboard_input.zig +86 -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 +16 -0
- package/src/runtime/scroll_mutation_policy.zig +130 -0
- package/src/runtime/scroll_mutation_runtime.zig +158 -0
- package/src/runtime/scroll_tree_policy.zig +99 -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 +231 -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/staged_rebuild_policy.zig +83 -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 +65 -36
- package/src/runtime/tests.zig +2 -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 +2451 -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 +1111 -45
- package/src/runtime/ui_app.zig +1381 -650
- 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 +667 -188
- package/src/runtime/ui_app_window_tests.zig +222 -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_reload.zig +226 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +46 -26
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +503 -69
- package/src/runtime/virtual_window_policy.zig +128 -0
- package/src/runtime/web_pane_policy.zig +111 -0
- package/src/runtime/web_pane_test_cases.zig +204 -0
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_continuity_policy.zig +73 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/widget_reconcile_policy.zig +81 -0
- package/src/runtime/widget_retention_policy.zig +75 -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 +179 -11
- package/src/security/root.zig +1 -0
- 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 +23 -3
- package/src/tooling/ts_core.zig +97 -4
- package/src/tooling/verbs.zig +87 -1
- 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 +188 -0
- package/tools/corewire/core_abi.zig +55 -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 +361 -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 +300 -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 +39 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +28 -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 +59 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +204 -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 +269 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//! Independent portable reference for explicitly selected Zig-core apps.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const p = @import("replay_progress_policy.zig");
|
|
4
|
+
pub fn plan(stage: p.Stage, facts: p.Facts) p.Plan {
|
|
5
|
+
var result: p.Plan = .{};
|
|
6
|
+
switch (stage) {
|
|
7
|
+
.count => result.counter = facts.a + 1,
|
|
8
|
+
.compare => {
|
|
9
|
+
result.counter = facts.a + 1;
|
|
10
|
+
result.mismatch_count = facts.b;
|
|
11
|
+
if (facts.c != facts.d) {
|
|
12
|
+
result.mismatch = true;
|
|
13
|
+
if (facts.b < 16) result.mismatch_slot = @intCast(facts.b);
|
|
14
|
+
result.mismatch_count += 1;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
.blob_admission => result.action = if (facts.code == 0) .missing else if (facts.a > facts.b) .over_budget else .proceed,
|
|
18
|
+
.blob_result => result.action = if (facts.a != facts.b) .corrupt else .proceed,
|
|
19
|
+
.finish => result.action = if (facts.code == 2) .divergence else .proceed,
|
|
20
|
+
.window => for (facts.slots, 0..) |slot, i| {
|
|
21
|
+
if (slot.open and slot.id == facts.a) {
|
|
22
|
+
result.index = i;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
.view => for (facts.slots, 0..) |slot, i| {
|
|
27
|
+
if (slot.open and slot.kind == .gpu_surface and std.mem.eql(u8, slot.label, facts.label)) {
|
|
28
|
+
result.index = i;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
//! Independent native behavior oracle for the packed request policy test ABI.
|
|
2
|
+
//! This module is used only by tests; it retains neither packets nor secrets.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
|
|
5
|
+
pub fn plan(request: []const u8, output: []u8) usize {
|
|
6
|
+
const operation = request[0];
|
|
7
|
+
const size: usize = if (operation == 11) 16 else if (operation == 13) 20 else 8;
|
|
8
|
+
@memset(output[0..size], 0);
|
|
9
|
+
if (operation == 13) {
|
|
10
|
+
const names = [_][]const u8{ "core.credentials.set", "core.credentials.get", "core.credentials.delete" };
|
|
11
|
+
const name = request[2..][0..request[1]];
|
|
12
|
+
for (names, 0..) |candidate, kind| if (std.mem.eql(u8, name, candidate)) {
|
|
13
|
+
const payload = request[2 + name.len ..];
|
|
14
|
+
var at: usize = 0;
|
|
15
|
+
var spans: [4]u32 = @splat(0);
|
|
16
|
+
for (0..if (kind == 0) @as(usize, 2) else 1) |field| {
|
|
17
|
+
if (payload.len - at < 4) return size;
|
|
18
|
+
const length = std.mem.readInt(u32, payload[at..][0..4], .little);
|
|
19
|
+
at += 4;
|
|
20
|
+
if (length > payload.len - at) return size;
|
|
21
|
+
spans[field * 2] = @intCast(at);
|
|
22
|
+
spans[field * 2 + 1] = length;
|
|
23
|
+
at += length;
|
|
24
|
+
}
|
|
25
|
+
if (at != payload.len) return size;
|
|
26
|
+
output[0] = 1;
|
|
27
|
+
output[1] = @intCast(kind);
|
|
28
|
+
for (spans, 0..) |value, i| std.mem.writeInt(u32, output[4 + i * 4 ..][0..4], value, .little);
|
|
29
|
+
return size;
|
|
30
|
+
};
|
|
31
|
+
return size;
|
|
32
|
+
}
|
|
33
|
+
if (operation == 12) {
|
|
34
|
+
output[0] = 255;
|
|
35
|
+
output[1] = 255;
|
|
36
|
+
const name = request[2..][0..request[1]];
|
|
37
|
+
var at: usize = 2 + name.len;
|
|
38
|
+
const counts = [_]usize{ 36, 16, 16, 16, 4, 16, 16 };
|
|
39
|
+
for (counts, 0..) |count, family| for (0..count) |slot| {
|
|
40
|
+
const used = request[at] == 1;
|
|
41
|
+
const flags = request[at + 1];
|
|
42
|
+
const key = request[at + 3 ..][0..request[at + 2]];
|
|
43
|
+
const err = request[at + 3 + key.len];
|
|
44
|
+
at += 4 + key.len;
|
|
45
|
+
if (name.len == 0 or !used or (family == 1 and flags == 1) or !std.mem.eql(u8, name, key)) continue;
|
|
46
|
+
output[0] = @intCast(family);
|
|
47
|
+
output[1] = @intCast(slot);
|
|
48
|
+
output[6] = err;
|
|
49
|
+
switch (family) {
|
|
50
|
+
0 => {
|
|
51
|
+
output[2] = 1;
|
|
52
|
+
output[3] = 1;
|
|
53
|
+
output[5] = flags;
|
|
54
|
+
output[7] = flags;
|
|
55
|
+
},
|
|
56
|
+
1, 2, 3 => output[3] = 1,
|
|
57
|
+
4 => {
|
|
58
|
+
output[3] = 1;
|
|
59
|
+
if (flags == 1) output[4] = 1 else output[2] = 1;
|
|
60
|
+
},
|
|
61
|
+
5 => {
|
|
62
|
+
output[2] = 1;
|
|
63
|
+
output[3] = 1;
|
|
64
|
+
},
|
|
65
|
+
6 => if (flags == 1) {
|
|
66
|
+
output[2] = 1;
|
|
67
|
+
output[3] = 1;
|
|
68
|
+
},
|
|
69
|
+
else => unreachable,
|
|
70
|
+
}
|
|
71
|
+
return size;
|
|
72
|
+
};
|
|
73
|
+
return size;
|
|
74
|
+
}
|
|
75
|
+
const name_at: usize = if (operation == 11) 16 else 12;
|
|
76
|
+
const name_len = request[if (operation == 11) @as(usize, 3) else 2];
|
|
77
|
+
const name = request[name_at..][0..name_len];
|
|
78
|
+
const count: usize = if (operation == 11) 36 else 16;
|
|
79
|
+
var entries: [36][]const u8 = undefined;
|
|
80
|
+
var at: usize = name_at + name.len;
|
|
81
|
+
for (0..count) |slot| {
|
|
82
|
+
const len = request[at + if (operation == 11) @as(usize, 1) else 6];
|
|
83
|
+
const fixed: usize = if (operation == 11) 15 else 7;
|
|
84
|
+
entries[slot] = request[at .. at + fixed + len];
|
|
85
|
+
at += fixed + len;
|
|
86
|
+
}
|
|
87
|
+
var matching: ?usize = null;
|
|
88
|
+
for (entries[0..count], 0..) |entry, slot| {
|
|
89
|
+
const key = if (operation == 11) entry[2..][0..entry[1]] else entry[7..];
|
|
90
|
+
if (entry[0] == 1 and std.mem.eql(u8, name, key)) {
|
|
91
|
+
matching = slot;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
output[0] = 255;
|
|
96
|
+
if (operation == 11) {
|
|
97
|
+
output[1] = 255;
|
|
98
|
+
const action = request[1];
|
|
99
|
+
if (action == 1) {
|
|
100
|
+
if (matching) |slot| output[0] = @intCast(slot);
|
|
101
|
+
return size;
|
|
102
|
+
}
|
|
103
|
+
if (action == 2) {
|
|
104
|
+
const slot = request[10];
|
|
105
|
+
const entry = entries[slot];
|
|
106
|
+
const route = entry[2 + @as(usize, entry[1]) ..];
|
|
107
|
+
const ok = request[9] == 1;
|
|
108
|
+
output[0] = slot;
|
|
109
|
+
output[2] = route[if (ok) @as(usize, 0) else 1];
|
|
110
|
+
output[3] = if (ok and route[3] == 1) 2 else if (ok and route[2] == 1) 1 else 0;
|
|
111
|
+
output[4] = 1;
|
|
112
|
+
output[5] = route[4];
|
|
113
|
+
if (route[4] == 1) @memcpy(output[8..16], route[5..13]);
|
|
114
|
+
return size;
|
|
115
|
+
}
|
|
116
|
+
const first: usize = switch (request[2]) {
|
|
117
|
+
0 => 0,
|
|
118
|
+
1 => 16,
|
|
119
|
+
2 => 32,
|
|
120
|
+
else => unreachable,
|
|
121
|
+
};
|
|
122
|
+
const end: usize = if (request[2] == 2) 36 else first + 16;
|
|
123
|
+
var free: ?usize = null;
|
|
124
|
+
for (entries[first..end], first..) |entry, slot| if (entry[0] == 0) {
|
|
125
|
+
free = slot;
|
|
126
|
+
break;
|
|
127
|
+
};
|
|
128
|
+
if (action == 3) {
|
|
129
|
+
if (free) |slot| output[0] = @intCast(slot);
|
|
130
|
+
if (name.len > 0 and (matching != null or request[4] == 1)) output[3] = 1 else if (free == null) output[3] = 2 else if (request[11] == 1) output[3] = 3;
|
|
131
|
+
return size;
|
|
132
|
+
}
|
|
133
|
+
output[2] = request[6];
|
|
134
|
+
output[3] = request[7];
|
|
135
|
+
output[4] = request[8];
|
|
136
|
+
if (request[4] == 1) return size;
|
|
137
|
+
if (name.len > 0) if (matching) |slot| {
|
|
138
|
+
if (request[5] == 1) return size;
|
|
139
|
+
if (slot >= first and slot < end) {
|
|
140
|
+
output[0] = @intCast(slot);
|
|
141
|
+
return size;
|
|
142
|
+
}
|
|
143
|
+
output[1] = @intCast(slot);
|
|
144
|
+
};
|
|
145
|
+
if (free) |slot| output[0] = @intCast(slot);
|
|
146
|
+
return size;
|
|
147
|
+
}
|
|
148
|
+
std.debug.assert(operation == 14);
|
|
149
|
+
output[1..4].* = request[5..8].*;
|
|
150
|
+
if (request[1] == 0) {
|
|
151
|
+
if (request[3] == 1) return size;
|
|
152
|
+
if (name.len > 0) if (matching) |slot| {
|
|
153
|
+
const entry = entries[slot];
|
|
154
|
+
if (request[4] != 1 or entry[1] != 1 or entry[2] == 1) return size;
|
|
155
|
+
output[0] = @intCast(slot);
|
|
156
|
+
return size;
|
|
157
|
+
};
|
|
158
|
+
for (entries[0..16], 0..) |entry, slot| if (entry[0] == 0) {
|
|
159
|
+
output[0] = @intCast(slot);
|
|
160
|
+
break;
|
|
161
|
+
};
|
|
162
|
+
return size;
|
|
163
|
+
}
|
|
164
|
+
const slot = request[8];
|
|
165
|
+
const entry = entries[slot];
|
|
166
|
+
output[0] = slot;
|
|
167
|
+
if (request[10] == 0) {
|
|
168
|
+
output[4] = entry[5];
|
|
169
|
+
output[5] = 2;
|
|
170
|
+
output[6] = @intFromBool(entry[2] == 0);
|
|
171
|
+
} else switch (request[9]) {
|
|
172
|
+
0 => output[4] = entry[3],
|
|
173
|
+
1 => {
|
|
174
|
+
std.debug.assert(entry[1] == 1);
|
|
175
|
+
output[4] = entry[4];
|
|
176
|
+
output[5] = 1;
|
|
177
|
+
output[6] = @intFromBool(entry[2] == 0);
|
|
178
|
+
},
|
|
179
|
+
2 => {
|
|
180
|
+
std.debug.assert(entry[1] == 0);
|
|
181
|
+
output[4] = entry[4];
|
|
182
|
+
output[5] = 1;
|
|
183
|
+
output[6] = 1;
|
|
184
|
+
},
|
|
185
|
+
else => unreachable,
|
|
186
|
+
}
|
|
187
|
+
return size;
|
|
188
|
+
}
|
package/src/runtime/root.zig
CHANGED
|
@@ -150,6 +150,12 @@ pub const EffectChannelEventKind = runtime_effects.EffectChannelEventKind;
|
|
|
150
150
|
pub const EffectAudioCaptureEvent = runtime_effects.EffectAudioCaptureEvent;
|
|
151
151
|
pub const EffectAudioCaptureEventKind = runtime_effects.EffectAudioCaptureEventKind;
|
|
152
152
|
pub const decodeAudioCaptureChannelEvent = runtime_effects.decodeAudioCaptureChannelEvent;
|
|
153
|
+
pub const EffectGlobalShortcutEvent = runtime_effects.EffectGlobalShortcutEvent;
|
|
154
|
+
pub const EffectGlobalShortcutEventKind = runtime_effects.EffectGlobalShortcutEventKind;
|
|
155
|
+
pub const HostChannelSourceBinding = runtime_effects.HostChannelSourceBinding;
|
|
156
|
+
pub const EffectChannelSourceState = runtime_effects.EffectChannelSourceState;
|
|
157
|
+
pub const EffectChannelSourceResult = runtime_effects.EffectChannelSourceResult;
|
|
158
|
+
pub const max_channel_source_payload = runtime_effects.max_channel_source_payload;
|
|
153
159
|
pub const ChannelHandle = runtime_effects.ChannelHandle;
|
|
154
160
|
pub const max_effect_channels = runtime_effects.max_effect_channels;
|
|
155
161
|
pub const max_effect_channel_bytes = runtime_effects.max_effect_channel_bytes;
|
|
@@ -181,6 +187,7 @@ pub const max_terminal_sessions = runtime_terminal_session.max_sessions;
|
|
|
181
187
|
|
|
182
188
|
const runtime_ts_core_host = @import("ts_core_host.zig");
|
|
183
189
|
pub const TsCoreHost = runtime_ts_core_host.TsCoreHost;
|
|
190
|
+
pub const TsCoreHostWithRuntimeModel = runtime_ts_core_host.TsCoreHostWithRuntimeModel;
|
|
184
191
|
pub const ts_core_request_key_base = runtime_ts_core_host.request_key_base;
|
|
185
192
|
pub const ts_core_timer_key_base = runtime_ts_core_host.timer_key_base;
|
|
186
193
|
pub const ts_core_effect_key_base = runtime_ts_core_host.effect_key_base;
|
|
@@ -193,7 +200,9 @@ pub const ts_core_db_key_base = runtime_ts_core_host.db_key_base;
|
|
|
193
200
|
pub const ts_core_file_stream_key_base = runtime_ts_core_host.file_stream_key_base;
|
|
194
201
|
|
|
195
202
|
const runtime_ts_ui_app = @import("ts_ui_app.zig");
|
|
203
|
+
pub const view_reload = @import("view_reload.zig");
|
|
196
204
|
pub const TsUiApp = runtime_ts_ui_app.TsUiApp;
|
|
205
|
+
pub const TsUiAppWithFeatures = runtime_ts_ui_app.TsUiAppWithFeatures;
|
|
197
206
|
|
|
198
207
|
const runtime_session_journal = @import("session_journal.zig");
|
|
199
208
|
const runtime_session_record = @import("session_record.zig");
|
|
@@ -203,6 +212,7 @@ const runtime_persist_store = @import("persist_store.zig");
|
|
|
203
212
|
const runtime_record_store = @import("record_store.zig");
|
|
204
213
|
const runtime_relational_store = @import("relational_store.zig");
|
|
205
214
|
pub const session_journal = runtime_session_journal;
|
|
215
|
+
pub const session_codec_reference = @import("session_codec_reference.zig");
|
|
206
216
|
pub const session_blobs = runtime_session_blobs;
|
|
207
217
|
pub const persist_store = runtime_persist_store;
|
|
208
218
|
pub const PersistStore = runtime_persist_store.Store;
|
|
@@ -220,6 +230,8 @@ pub const SessionBlobDirStore = runtime_session_blobs.DirBlobStore;
|
|
|
220
230
|
pub const SessionHeader = runtime_session_journal.Header;
|
|
221
231
|
pub const sessionHeaderNow = runtime_session_record.headerNow;
|
|
222
232
|
pub const sessionPlatformName = runtime_session_replay.currentPlatformName;
|
|
233
|
+
pub const replay_policy = @import("replay_policy.zig");
|
|
234
|
+
pub const component_policy = @import("component_policy.zig");
|
|
223
235
|
pub const replaySession = runtime_session_replay.replaySession;
|
|
224
236
|
pub const ReplayOptions = runtime_session_replay.ReplayOptions;
|
|
225
237
|
pub const ReplayReport = runtime_session_replay.ReplayReport;
|
|
@@ -269,4 +281,8 @@ pub const CanvasPixelSize = core.CanvasPixelSize;
|
|
|
269
281
|
test {
|
|
270
282
|
std.testing.refAllDecls(@This());
|
|
271
283
|
_ = @import("tests.zig");
|
|
284
|
+
_ = @import("ts_canvas_hooks_tests.zig");
|
|
272
285
|
}
|
|
286
|
+
|
|
287
|
+
pub const host_flow_policy = @import("host_flow_policy.zig");
|
|
288
|
+
pub const host_event_pump = @import("host_event_pump.zig");
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//! Copied scroll capability programs. All state, identities, f32 numeric
|
|
2
|
+
//! operations and geometry remain native-owned; compiled code orders them.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const canvas = @import("canvas");
|
|
5
|
+
const limits = @import("canvas_limits.zig");
|
|
6
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
7
|
+
pub const Mode = enum(u8) { axis, textarea, driver, keyboard, kinetic, finish };
|
|
8
|
+
pub const Kind = enum(u8) {
|
|
9
|
+
viewport,
|
|
10
|
+
textarea_viewport,
|
|
11
|
+
region_state,
|
|
12
|
+
textarea_state,
|
|
13
|
+
delegate_textarea,
|
|
14
|
+
wheel,
|
|
15
|
+
wheel_clamped,
|
|
16
|
+
discrete,
|
|
17
|
+
zero_velocity,
|
|
18
|
+
store_axis,
|
|
19
|
+
compare_axis,
|
|
20
|
+
write_axis,
|
|
21
|
+
translate_axis,
|
|
22
|
+
event,
|
|
23
|
+
semantics,
|
|
24
|
+
revision,
|
|
25
|
+
dirty,
|
|
26
|
+
driver_y,
|
|
27
|
+
driver_x,
|
|
28
|
+
target_y,
|
|
29
|
+
target_x,
|
|
30
|
+
store_state,
|
|
31
|
+
write_both,
|
|
32
|
+
translate_both,
|
|
33
|
+
clear_velocities,
|
|
34
|
+
probe_y,
|
|
35
|
+
probe_x,
|
|
36
|
+
kinetic_y,
|
|
37
|
+
kinetic_x,
|
|
38
|
+
zero_y,
|
|
39
|
+
zero_x,
|
|
40
|
+
accumulate_dirty,
|
|
41
|
+
};
|
|
42
|
+
pub fn nodeFacts(node: canvas.WidgetLayoutNode) u8 {
|
|
43
|
+
var facts: u8 = 1;
|
|
44
|
+
if (node.widget.kind == .scroll_view) facts |= 2;
|
|
45
|
+
if (node.widget.kind == .textarea) facts |= 4;
|
|
46
|
+
if (node.widget.layout.virtualized and !canvas.widgetVirtualRuntimeScrolled(node.widget)) facts |= 8;
|
|
47
|
+
if (canvas.widgetScrollsAxis(node.widget, .vertical)) facts |= 16;
|
|
48
|
+
if (canvas.widgetScrollsAxis(node.widget, .horizontal)) facts |= 32;
|
|
49
|
+
if (node.widget.runtime_flags.native_scroll) facts |= 64;
|
|
50
|
+
return facts;
|
|
51
|
+
}
|
|
52
|
+
pub const Selection = struct {
|
|
53
|
+
include: [limits.max_canvas_widget_nodes_per_view]bool = undefined,
|
|
54
|
+
};
|
|
55
|
+
pub fn kineticSelection(policy: Policy, nodes: []const canvas.WidgetLayoutNode) Selection {
|
|
56
|
+
comptime {
|
|
57
|
+
if (limits.max_canvas_widget_nodes_per_view != 1024) @compileError("update kinetic selection wire budget");
|
|
58
|
+
}
|
|
59
|
+
if (nodes.len > limits.max_canvas_widget_nodes_per_view) @panic("kinetic selection exceeds node budget");
|
|
60
|
+
var input: [16 + limits.max_canvas_widget_nodes_per_view]u8 = @splat(0);
|
|
61
|
+
input[0] = 101;
|
|
62
|
+
input[1] = 6;
|
|
63
|
+
std.mem.writeInt(u32, input[8..12], @intCast(nodes.len), .little);
|
|
64
|
+
for (nodes, 0..) |node, i| input[16 + i] = nodeFacts(node);
|
|
65
|
+
var output: [8 + limits.max_canvas_widget_nodes_per_view]u8 = undefined;
|
|
66
|
+
if (policy(input[0 .. 16 + nodes.len], &output) != 8 + nodes.len or output[0] != 101 or output[1] != 6 or
|
|
67
|
+
output[2] != 0 or output[3] != 0 or std.mem.readInt(u32, output[4..8], .little) != nodes.len)
|
|
68
|
+
@panic("invalid kinetic selection header");
|
|
69
|
+
var result: Selection = undefined;
|
|
70
|
+
for (result.include[0..nodes.len], 0..) |*include, i| {
|
|
71
|
+
if (output[8 + i] > 1) @panic("invalid kinetic selection capability");
|
|
72
|
+
include.* = output[8 + i] == 1;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
pub const Program = struct {
|
|
77
|
+
bytes: [24]u8,
|
|
78
|
+
count: usize,
|
|
79
|
+
next: u8,
|
|
80
|
+
pub fn instruction(self: *const Program, index: usize) Kind {
|
|
81
|
+
std.debug.assert(index < self.count);
|
|
82
|
+
return @enumFromInt(self.bytes[8 + index]);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
pub fn plan(policy: Policy, mode: Mode, phase: u8, source: u8, vertical: bool, facts: u32) Program {
|
|
86
|
+
var input: [16]u8 = @splat(0);
|
|
87
|
+
input[0..5].* = .{ 101, @intFromEnum(mode), phase, source, @intFromBool(vertical) };
|
|
88
|
+
std.mem.writeInt(u32, input[8..12], facts, .little);
|
|
89
|
+
var result: Program = undefined;
|
|
90
|
+
const size = policy(&input, &result.bytes);
|
|
91
|
+
if (size < 8 or size > result.bytes.len or result.bytes[0] != 101 or result.bytes[1] != @intFromEnum(mode) or
|
|
92
|
+
std.mem.readInt(u32, result.bytes[4..8], .little) != 0)
|
|
93
|
+
@panic("invalid scroll mutation program header");
|
|
94
|
+
result.count = result.bytes[3];
|
|
95
|
+
result.next = result.bytes[2];
|
|
96
|
+
if (size != 8 + result.count or (result.next != 255 and (result.next != phase + 1 or result.next > (if (mode == .kinetic) @as(u8, 4) else 2))) or
|
|
97
|
+
(mode == .finish and result.next != 255)) @panic("invalid scroll mutation program progress");
|
|
98
|
+
if (mode != .finish and ((facts & 1 == 0 and result.count != 0) or
|
|
99
|
+
(phase > 1 and facts & 256 == 0 and result.count != 0))) @panic("invalid scroll mutation storage admission");
|
|
100
|
+
for (result.bytes[8..size]) |kind| {
|
|
101
|
+
if (kind > @intFromEnum(Kind.accumulate_dirty)) @panic("invalid scroll mutation capability");
|
|
102
|
+
const capability: Kind = @enumFromInt(kind);
|
|
103
|
+
// Capability admission, independent of the program's semantic choices.
|
|
104
|
+
const allowed = switch (capability) {
|
|
105
|
+
.viewport => phase == 0 and mode != .textarea and mode != .finish,
|
|
106
|
+
.textarea_viewport => phase == 0 and mode == .textarea,
|
|
107
|
+
.delegate_textarea => phase == 0 and mode == .axis,
|
|
108
|
+
.region_state => phase == 1 and mode != .textarea and mode != .finish,
|
|
109
|
+
.textarea_state, .compare_axis => phase == 1 and mode == .textarea,
|
|
110
|
+
.wheel, .wheel_clamped, .discrete => phase == 1 and (mode == .axis or mode == .textarea),
|
|
111
|
+
.zero_velocity, .store_axis => phase == 1 and mode == .axis,
|
|
112
|
+
.driver_y, .driver_x => phase == 1 and mode == .driver,
|
|
113
|
+
.target_y, .target_x => phase == 1 and mode == .keyboard,
|
|
114
|
+
.store_state => (phase == 1 and (mode == .driver or mode == .keyboard)) or (phase == 3 and mode == .kinetic),
|
|
115
|
+
.clear_velocities => phase == 1 and mode == .kinetic,
|
|
116
|
+
.probe_y => phase == 1 and mode == .kinetic,
|
|
117
|
+
.probe_x, .kinetic_y, .zero_y => phase == 2 and mode == .kinetic,
|
|
118
|
+
.kinetic_x, .zero_x => phase == 3 and mode == .kinetic,
|
|
119
|
+
.semantics, .revision => (phase == 2 and mode != .kinetic and mode != .finish) or (phase == 0 and mode == .finish),
|
|
120
|
+
.write_axis => phase == 2 and (mode == .axis or mode == .textarea),
|
|
121
|
+
.translate_axis => phase == 2 and mode == .axis,
|
|
122
|
+
.dirty => phase == 2 and mode != .kinetic and mode != .finish,
|
|
123
|
+
.event => (phase == 2 and (mode == .axis or mode == .driver or mode == .keyboard)) or (phase == 4 and mode == .kinetic),
|
|
124
|
+
.write_both, .translate_both => (phase == 2 and (mode == .driver or mode == .keyboard)) or (phase == 4 and mode == .kinetic),
|
|
125
|
+
.accumulate_dirty => phase == 4 and mode == .kinetic,
|
|
126
|
+
};
|
|
127
|
+
if (!allowed) @panic("invalid scroll mutation capability admission");
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//! Storage, numeric and geometry capabilities for compiled scroll programs.
|
|
2
|
+
const canvas = @import("canvas");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const programs = @import("scroll_mutation_policy.zig");
|
|
5
|
+
|
|
6
|
+
pub const Outcome = struct { dirty: ?geometry.RectF = null, changed: bool = false };
|
|
7
|
+
|
|
8
|
+
pub fn run(self: anytype, policy: programs.Policy, comptime mode: programs.Mode, index: usize, comptime axis: canvas.ScrollAxis, source: u8, delta: f32, offset_x: f32, offset_y: f32, allow_rubberband: bool) anyerror!Outcome {
|
|
9
|
+
var facts: u32 = if (allow_rubberband) 128 else 0;
|
|
10
|
+
var node: canvas.WidgetLayoutNode = undefined;
|
|
11
|
+
if (index < self.widget_layout_node_count) {
|
|
12
|
+
node = self.widget_layout_nodes[index];
|
|
13
|
+
facts |= programs.nodeFacts(node);
|
|
14
|
+
}
|
|
15
|
+
var viewport: geometry.RectF = undefined;
|
|
16
|
+
var current: canvas.ScrollState = undefined;
|
|
17
|
+
var next: canvas.ScrollState = undefined;
|
|
18
|
+
var current_axis: canvas.ScrollAxisState = undefined;
|
|
19
|
+
var next_axis: canvas.ScrollAxisState = undefined;
|
|
20
|
+
var physics: canvas.ScrollPhysics = undefined;
|
|
21
|
+
var moved = geometry.OffsetF{};
|
|
22
|
+
var dirty: ?geometry.RectF = null;
|
|
23
|
+
var phase: u8 = 0;
|
|
24
|
+
while (true) {
|
|
25
|
+
const program = programs.plan(policy, mode, phase, source, axis == .vertical, facts);
|
|
26
|
+
for (0..program.count) |i| switch (program.instruction(i)) {
|
|
27
|
+
.viewport => {
|
|
28
|
+
viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
29
|
+
if (!viewport.isEmpty()) facts |= 256;
|
|
30
|
+
},
|
|
31
|
+
.textarea_viewport => {
|
|
32
|
+
if (canvas.textInputViewportForWidget(node.widget, self.widget_tokens)) |value| {
|
|
33
|
+
viewport = value;
|
|
34
|
+
facts |= 256;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
.region_state => {
|
|
38
|
+
if (mode == .kinetic) physics = canvas.widgetScrollPhysics(node.widget, self.widget_tokens.scroll);
|
|
39
|
+
current = self.canvasWidgetScrollState(index, node, viewport);
|
|
40
|
+
if (mode == .axis) physics = canvas.widgetScrollPhysics(node.widget, self.widget_tokens.scroll);
|
|
41
|
+
next = current;
|
|
42
|
+
current_axis = current.axis(axis);
|
|
43
|
+
},
|
|
44
|
+
.textarea_state => {
|
|
45
|
+
const vertical = axis == .vertical;
|
|
46
|
+
current_axis = .{
|
|
47
|
+
.offset = if (vertical) canvas.clampedTextInputScrollOffsetForWidget(node.widget, self.widget_tokens, node.widget.value) else canvas.clampedTextInputHorizontalScrollOffsetForWidget(node.widget, self.widget_tokens, node.widget.value_x),
|
|
48
|
+
.viewport_extent = if (vertical) viewport.height else viewport.width,
|
|
49
|
+
.content_extent = if (vertical) canvas.textInputContentExtentForWidget(node.widget, self.widget_tokens) else canvas.textInputContentWidthForWidget(node.widget, self.widget_tokens),
|
|
50
|
+
};
|
|
51
|
+
physics = self.widget_tokens.scroll;
|
|
52
|
+
},
|
|
53
|
+
.delegate_textarea => return run(self, policy, .textarea, index, axis, source, delta, 0, 0, false),
|
|
54
|
+
.wheel => next_axis = current_axis.applyWheel(delta, physics),
|
|
55
|
+
.wheel_clamped => next_axis = current_axis.applyWheelClamped(delta, physics),
|
|
56
|
+
.discrete => {
|
|
57
|
+
next_axis = current_axis;
|
|
58
|
+
if (mode == .axis) {
|
|
59
|
+
if (canvas.widgetCompiledScrollResult(node.widget, .{ .operation = 1, .current = current_axis.offset, .viewport = current_axis.viewport_extent, .content = current_axis.content_extent, .delta = delta })) |result| {
|
|
60
|
+
next_axis.offset = result.dx;
|
|
61
|
+
next_axis.velocity = 0;
|
|
62
|
+
} else {
|
|
63
|
+
next_axis.offset += delta;
|
|
64
|
+
next_axis.velocity = 0;
|
|
65
|
+
next_axis = next_axis.clamped();
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
next_axis.offset += delta;
|
|
69
|
+
next_axis.velocity = 0;
|
|
70
|
+
next_axis = next_axis.clamped();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
.zero_velocity => next_axis.velocity = 0,
|
|
74
|
+
.store_axis => {
|
|
75
|
+
self.widget_scroll_states[index] = current.withAxis(axis, next_axis);
|
|
76
|
+
if (next_axis.offset != current_axis.offset) facts |= 512;
|
|
77
|
+
},
|
|
78
|
+
.compare_axis => if (next_axis.offset != current_axis.offset) {
|
|
79
|
+
facts |= 512;
|
|
80
|
+
},
|
|
81
|
+
.write_axis => switch (axis) {
|
|
82
|
+
.vertical => self.widget_layout_nodes[index].widget.value = next_axis.offset,
|
|
83
|
+
.horizontal => self.widget_layout_nodes[index].widget.value_x = next_axis.offset,
|
|
84
|
+
},
|
|
85
|
+
.translate_axis => self.translateCanvasWidgetScrollDescendants(index, if (axis == .vertical) .{ .dy = -(next_axis.offset - current_axis.offset) } else .{ .dx = -(next_axis.offset - current_axis.offset) }),
|
|
86
|
+
.event => self.noteCanvasWidgetScrollEvent(node.widget.id),
|
|
87
|
+
.semantics => try self.refreshCanvasWidgetSemantics(),
|
|
88
|
+
.revision => self.widget_revision += 1,
|
|
89
|
+
.dirty, .accumulate_dirty => dirty = self.canvasWidgetDirtyBounds(index, if (mode == .textarea) node.widget.frame else node.frame),
|
|
90
|
+
.driver_y => {
|
|
91
|
+
next.offset_y = offset_y;
|
|
92
|
+
next.velocity_y = 0;
|
|
93
|
+
},
|
|
94
|
+
.driver_x => {
|
|
95
|
+
next.offset_x = offset_x;
|
|
96
|
+
next.velocity_x = 0;
|
|
97
|
+
},
|
|
98
|
+
.target_y => next = next.withAxis(.vertical, target(node.widget, current.axis(.vertical), source)),
|
|
99
|
+
.target_x => next = next.withAxis(.horizontal, target(node.widget, current.axis(.horizontal), source)),
|
|
100
|
+
.store_state => {
|
|
101
|
+
self.widget_scroll_states[index] = next;
|
|
102
|
+
if (mode == .kinetic) {
|
|
103
|
+
if (moved.dx != 0 or moved.dy != 0) facts |= 512;
|
|
104
|
+
} else if (next.offset_y != current.offset_y or next.offset_x != current.offset_x) facts |= 512;
|
|
105
|
+
},
|
|
106
|
+
.write_both => {
|
|
107
|
+
self.widget_layout_nodes[index].widget.value = next.offset_y;
|
|
108
|
+
self.widget_layout_nodes[index].widget.value_x = next.offset_x;
|
|
109
|
+
},
|
|
110
|
+
.translate_both => {
|
|
111
|
+
const offset = if (mode == .kinetic) moved else geometry.OffsetF.init(next.offset_x - current.offset_x, next.offset_y - current.offset_y);
|
|
112
|
+
self.translateCanvasWidgetScrollDescendants(index, .{ .dx = -offset.dx, .dy = -offset.dy });
|
|
113
|
+
},
|
|
114
|
+
.clear_velocities => {
|
|
115
|
+
self.widget_scroll_states[index].velocity_y = 0;
|
|
116
|
+
self.widget_scroll_states[index].velocity_x = 0;
|
|
117
|
+
},
|
|
118
|
+
.probe_y => {
|
|
119
|
+
facts &= ~@as(u32, 1024);
|
|
120
|
+
if (current.axis(.vertical).needsKineticStep(physics)) facts |= 1024;
|
|
121
|
+
},
|
|
122
|
+
.probe_x => {
|
|
123
|
+
facts &= ~@as(u32, 1024);
|
|
124
|
+
if (current.axis(.horizontal).needsKineticStep(physics)) facts |= 1024;
|
|
125
|
+
},
|
|
126
|
+
.kinetic_y => {
|
|
127
|
+
const value = current.axis(.vertical).stepKinetic(delta, physics);
|
|
128
|
+
next = next.withAxis(.vertical, value);
|
|
129
|
+
moved.dy = value.offset - current.offset_y;
|
|
130
|
+
},
|
|
131
|
+
.kinetic_x => {
|
|
132
|
+
const value = current.axis(.horizontal).stepKinetic(delta, physics);
|
|
133
|
+
next = next.withAxis(.horizontal, value);
|
|
134
|
+
moved.dx = value.offset - current.offset_x;
|
|
135
|
+
},
|
|
136
|
+
.zero_y => next.velocity_y = 0,
|
|
137
|
+
.zero_x => next.velocity_x = 0,
|
|
138
|
+
};
|
|
139
|
+
if (program.next == 255) return .{ .dirty = dirty, .changed = facts & 512 != 0 };
|
|
140
|
+
phase = program.next;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
pub fn finish(self: anytype, policy: programs.Policy, changed: bool) anyerror!void {
|
|
145
|
+
const program = programs.plan(policy, .finish, 0, 0, false, if (changed) 512 else 0);
|
|
146
|
+
for (0..program.count) |i| switch (program.instruction(i)) {
|
|
147
|
+
.semantics => try self.refreshCanvasWidgetSemantics(),
|
|
148
|
+
.revision => self.widget_revision += 1,
|
|
149
|
+
else => unreachable,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
fn target(widget: canvas.Widget, current: canvas.ScrollAxisState, source: u8) canvas.ScrollAxisState {
|
|
154
|
+
var next = current;
|
|
155
|
+
next.offset = if (canvas.widgetCompiledScrollResult(widget, .{ .operation = if (source == 0) 12 else 13, .viewport = current.viewport_extent, .content = current.content_extent })) |result| result.dx else if (source == 0) 0 else current.maxOffset();
|
|
156
|
+
next.velocity = 0;
|
|
157
|
+
return next.clamped();
|
|
158
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//! Copied retained-tree plans. Native owns the geometry buffers and virtual
|
|
2
|
+
//! measurement; the planner chooses traversal, moving nodes and tab reveals.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const canvas = @import("canvas");
|
|
5
|
+
const geometry = @import("geometry");
|
|
6
|
+
const limits = @import("canvas_limits.zig");
|
|
7
|
+
pub const Policy = ?*const fn ([]const u8, []u8) usize;
|
|
8
|
+
pub const Request = struct {
|
|
9
|
+
operation: u8,
|
|
10
|
+
target: usize,
|
|
11
|
+
viewport: geometry.RectF = .{},
|
|
12
|
+
previous: canvas.WidgetLayoutTree = .{ .nodes = &.{} },
|
|
13
|
+
anchored_depth: ?usize = null,
|
|
14
|
+
strata: ?canvas.layout_coordination_policy.RetainedPlan = null,
|
|
15
|
+
};
|
|
16
|
+
pub const Plan = struct {
|
|
17
|
+
target: ?usize,
|
|
18
|
+
x: f32,
|
|
19
|
+
y: f32,
|
|
20
|
+
cursor: usize,
|
|
21
|
+
moving: [limits.max_canvas_widget_nodes_per_view]bool = undefined,
|
|
22
|
+
|
|
23
|
+
pub fn translate(self: *const Plan, nodes: []canvas.WidgetLayoutNode, offset: geometry.OffsetF) void {
|
|
24
|
+
for (nodes, 0..) |*node, i| if (self.moving[i]) {
|
|
25
|
+
node.frame = node.frame.translate(offset);
|
|
26
|
+
node.widget.frame = node.frame;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
pub fn build(policy: Policy, nodes: []const canvas.WidgetLayoutNode, request: Request) ?Plan {
|
|
31
|
+
const callback = policy orelse return null;
|
|
32
|
+
if (nodes.len > limits.max_canvas_widget_nodes_per_view or request.target > nodes.len or (request.operation != 2 and request.target == nodes.len)) @panic("scroll tree exceeds view budget");
|
|
33
|
+
var input: [48 + limits.max_canvas_widget_nodes_per_view * 56]u8 = undefined;
|
|
34
|
+
const bytes = input[0 .. 48 + nodes.len * 56];
|
|
35
|
+
@memset(bytes, 0);
|
|
36
|
+
bytes[0] = 94;
|
|
37
|
+
bytes[1] = request.operation;
|
|
38
|
+
word(bytes[4..8], nodes.len);
|
|
39
|
+
word(bytes[8..12], request.target);
|
|
40
|
+
word(bytes[12..16], request.anchored_depth orelse std.math.maxInt(u32));
|
|
41
|
+
rect(bytes[16..32], request.viewport);
|
|
42
|
+
if (request.operation == 0 and nodes[request.target].widget.layout.virtualized) float(bytes[32..36], canvas.virtualWidgetScrollContentExtent(nodes[request.target].widget, request.viewport.height));
|
|
43
|
+
const tree = canvas.WidgetLayoutTree{ .nodes = nodes };
|
|
44
|
+
for (nodes, 0..) |node, i| {
|
|
45
|
+
const w = node.widget;
|
|
46
|
+
const fact = bytes[48 + i * 56 ..][0..56];
|
|
47
|
+
word(fact[0..4], node.depth);
|
|
48
|
+
word(fact[4..8], node.parent_index orelse std.math.maxInt(u32));
|
|
49
|
+
var bits: u32 = 0;
|
|
50
|
+
if (canvas.widgetIsRootRelativeModal(w)) bits |= 1;
|
|
51
|
+
if (w.layout.anchor != null) bits |= 2;
|
|
52
|
+
if (canvas.widgetEscapesAncestorClips(w)) bits |= 4;
|
|
53
|
+
if (w.kind == .scroll_view or w.layout.clip_content) bits |= 8;
|
|
54
|
+
if (w.layout.virtualized) bits |= 16;
|
|
55
|
+
if (request.operation == 0 and canvas.widgetKindDisclosureAnimated(w.kind) and !canvas.disclosureSettledOpen(tree, i)) bits |= 32;
|
|
56
|
+
if (w.kind == .scroll_view and canvas.widgetScrollsAxis(w, .horizontal)) bits |= 64;
|
|
57
|
+
if (w.semantics.role == .tab and w.state.selected) {
|
|
58
|
+
bits |= 128;
|
|
59
|
+
if (request.operation == 2 and w.id != 0) for (request.previous.nodes) |previous| {
|
|
60
|
+
if (previous.widget.id != w.id) continue;
|
|
61
|
+
if (previous.widget.semantics.role == .tab and previous.widget.state.selected) bits |= 256;
|
|
62
|
+
break;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
word(fact[8..12], bits);
|
|
66
|
+
float(fact[12..16], w.value);
|
|
67
|
+
float(fact[16..20], w.value_x);
|
|
68
|
+
rect(fact[20..36], node.frame);
|
|
69
|
+
if (request.operation == 2) {
|
|
70
|
+
// Only eligible scroll ancestors consume a viewport. Other nodes
|
|
71
|
+
// may have negative extents that the tab planner normalizes itself.
|
|
72
|
+
if (bits & (64 | 16) == 64) rect(fact[36..52], node.frame.inset(w.layout.padding).normalized());
|
|
73
|
+
word(fact[52..56], if (request.strata) |plan| plan.nesting(i) else canvas.anchoredNestingDepth(nodes, i));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
var output: [24 + limits.max_canvas_widget_nodes_per_view]u8 = undefined;
|
|
77
|
+
const size = callback(bytes, &output);
|
|
78
|
+
if (size != 24 + nodes.len or output[0] != 94 or output[1] != request.operation or output[2] != 0 or output[3] != 0 or std.mem.readInt(u32, output[4..8], .little) != nodes.len) @panic("invalid compiled scroll tree header");
|
|
79
|
+
const target = std.mem.readInt(u32, output[8..12], .little);
|
|
80
|
+
const cursor = std.mem.readInt(u32, output[20..24], .little);
|
|
81
|
+
if ((target != std.math.maxInt(u32) and (request.operation != 2 or target >= nodes.len or nodes[target].widget.kind != .scroll_view)) or
|
|
82
|
+
(request.operation == 2 and (cursor <= request.target and request.target < nodes.len or cursor > nodes.len)) or
|
|
83
|
+
(request.operation != 2 and cursor != 0)) @panic("invalid compiled scroll tree target");
|
|
84
|
+
var plan = Plan{ .target = if (target == std.math.maxInt(u32)) null else target, .cursor = cursor, .x = @bitCast(std.mem.readInt(u32, output[12..16], .little)), .y = @bitCast(std.mem.readInt(u32, output[16..20], .little)) };
|
|
85
|
+
for (plan.moving[0..nodes.len], 0..) |*moving, i| {
|
|
86
|
+
if (output[24 + i] > 1 or (request.operation == 0 and output[24 + i] != 0)) @panic("invalid compiled scroll tree translation");
|
|
87
|
+
moving.* = output[24 + i] != 0;
|
|
88
|
+
}
|
|
89
|
+
return plan;
|
|
90
|
+
}
|
|
91
|
+
fn word(bytes: *[4]u8, value: usize) void {
|
|
92
|
+
std.mem.writeInt(u32, bytes, @intCast(value), .little);
|
|
93
|
+
}
|
|
94
|
+
fn float(bytes: *[4]u8, value: f32) void {
|
|
95
|
+
std.mem.writeInt(u32, bytes, @bitCast(value), .little);
|
|
96
|
+
}
|
|
97
|
+
fn rect(bytes: *[16]u8, value: geometry.RectF) void {
|
|
98
|
+
inline for (.{ value.x, value.y, value.width, value.height }, 0..) |v, i| float(bytes[i * 4 ..][0..4], v);
|
|
99
|
+
}
|