@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
|
@@ -144,6 +144,12 @@ pub const CollectedImageSource = struct {
|
|
|
144
144
|
/// are byte-identical. An app can use this during `update` to issue
|
|
145
145
|
/// `fx.loadImage` effects, then pass successful mappings back through
|
|
146
146
|
/// `Options.images` on the next view.
|
|
147
|
+
/// Use the compiled portable owner with explicit scratch storage. Results
|
|
148
|
+
/// remain in the caller's fixed output records after either arena resets.
|
|
149
|
+
pub fn collectImageSourcesOwned(policy: @import("markdown_content_policy.zig").Policy, arena: std.mem.Allocator, source: []const u8, output: []CollectedImageSource) ![]const CollectedImageSource {
|
|
150
|
+
return @import("markdown_content_policy.zig").collect(policy, arena, source, output);
|
|
151
|
+
}
|
|
152
|
+
|
|
147
153
|
pub fn collectImageSources(source: []const u8, output: []CollectedImageSource) []const CollectedImageSource {
|
|
148
154
|
var lines = LineIterator{ .source = source };
|
|
149
155
|
var len: usize = 0;
|
|
@@ -298,7 +304,7 @@ pub fn Markdown(comptime Msg: type) type {
|
|
|
298
304
|
pub fn detailsMsg(comptime tag: std.meta.Tag(Msg)) *const fn (index: usize) Msg {
|
|
299
305
|
return struct {
|
|
300
306
|
fn make(index: usize) Msg {
|
|
301
|
-
return @unionInit(Msg, @tagName(tag), index);
|
|
307
|
+
return @unionInit(Msg, @tagName(tag), @as(@FieldType(Msg, @tagName(tag)), @intCast(index)));
|
|
302
308
|
}
|
|
303
309
|
}.make;
|
|
304
310
|
}
|
|
@@ -308,6 +314,10 @@ pub fn Markdown(comptime Msg: type) type {
|
|
|
308
314
|
/// the existing convention) and malformed markdown degrades to
|
|
309
315
|
/// plain text.
|
|
310
316
|
pub fn view(ui: *Ui, source: []const u8, options: Options) Node {
|
|
317
|
+
if (ui.markdown_content_policy) |policy| return @import("markdown_content_policy.zig").view(Msg, policy, ui, source, options) catch {
|
|
318
|
+
ui.failed = true;
|
|
319
|
+
return ui.column(.{}, .{});
|
|
320
|
+
};
|
|
311
321
|
var builder = Builder{ .ui = ui, .options = options };
|
|
312
322
|
var lines = LineIterator{ .source = source };
|
|
313
323
|
const blocks = builder.parseBlocks(&lines, .document);
|
|
@@ -1933,7 +1943,7 @@ fn collectTableImageSources(
|
|
|
1933
1943
|
const alignments = tableDelimiterAlignments(delimiter_line) orelse return false;
|
|
1934
1944
|
if (alignments.len != header.len) return false;
|
|
1935
1945
|
|
|
1936
|
-
for (header.cells) |cell| appendLeadingImageSource(output, len, cell);
|
|
1946
|
+
for (header.cells[0..header.len]) |cell| appendLeadingImageSource(output, len, cell);
|
|
1937
1947
|
_ = lines.next(); // delimiter
|
|
1938
1948
|
while (lines.peek()) |line| {
|
|
1939
1949
|
const trimmed = std.mem.trim(u8, line, " \t");
|
|
@@ -1941,7 +1951,7 @@ fn collectTableImageSources(
|
|
|
1941
1951
|
_ = lines.next();
|
|
1942
1952
|
const visible = imageDiscoveryVisiblePrefix(line, html_state);
|
|
1943
1953
|
if (splitTableRow(visible)) |row| {
|
|
1944
|
-
for (row.cells) |cell| appendLeadingImageSource(output, len, cell);
|
|
1954
|
+
for (row.cells[0..row.len]) |cell| appendLeadingImageSource(output, len, cell);
|
|
1945
1955
|
}
|
|
1946
1956
|
if (len.* >= output.len) break;
|
|
1947
1957
|
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
//! Execute copied Markdown recipes. Portable parsing and composition belong
|
|
2
|
+
//! to the compiled owner; this adapter supplies arenas, typed routes and Ui.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const canvas = @import("root.zig");
|
|
5
|
+
const markdown = @import("markdown.zig");
|
|
6
|
+
pub const Policy = *const fn (request: []const u8, arena: std.mem.Allocator) []const u8;
|
|
7
|
+
|
|
8
|
+
const Reader = struct {
|
|
9
|
+
bytes: []const u8,
|
|
10
|
+
at: usize = 0,
|
|
11
|
+
fn take(self: *Reader, len: usize) ![]const u8 {
|
|
12
|
+
if (len > self.bytes.len - self.at) return error.InvalidMarkdownRecipe;
|
|
13
|
+
defer self.at += len;
|
|
14
|
+
return self.bytes[self.at..][0..len];
|
|
15
|
+
}
|
|
16
|
+
fn word(self: *Reader) !u32 {
|
|
17
|
+
return std.mem.readInt(u32, (try self.take(4))[0..4], .little);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
fn put(bytes: []u8, at: usize, value: usize) !void {
|
|
21
|
+
const encoded = std.math.cast(u32, value) orelse return error.MarkdownRequestTooLarge;
|
|
22
|
+
std.mem.writeInt(u32, bytes[at..][0..4], encoded, .little);
|
|
23
|
+
}
|
|
24
|
+
fn request(arena: std.mem.Allocator, source: []const u8, issue: ?[]const u8, expanded: []const bool, images: []const markdown.ResolvedImage, operation: u8, capacity: usize) ![]u8 {
|
|
25
|
+
const image_count = @min(images.len, markdown.max_markdown_images);
|
|
26
|
+
var len = try std.math.add(usize, 24, source.len);
|
|
27
|
+
len = try std.math.add(usize, len, if (issue) |bytes| bytes.len else 0);
|
|
28
|
+
len = try std.math.add(usize, len, expanded.len);
|
|
29
|
+
for (images[0..image_count]) |image| len = try std.math.add(usize, len, try std.math.add(usize, 20, image.source.len));
|
|
30
|
+
const bytes = try arena.alloc(u8, len);
|
|
31
|
+
@memset(bytes[0..24], 0);
|
|
32
|
+
bytes[0] = 22;
|
|
33
|
+
bytes[1] = operation;
|
|
34
|
+
bytes[2] = 1;
|
|
35
|
+
bytes[3] = @intFromBool(issue != null);
|
|
36
|
+
try put(bytes, 4, source.len);
|
|
37
|
+
try put(bytes, 8, if (issue) |value| value.len else 0);
|
|
38
|
+
try put(bytes, 12, expanded.len);
|
|
39
|
+
try put(bytes, 16, image_count);
|
|
40
|
+
try put(bytes, 20, capacity);
|
|
41
|
+
var at: usize = 24;
|
|
42
|
+
@memcpy(bytes[at..][0..source.len], source);
|
|
43
|
+
at += source.len;
|
|
44
|
+
if (issue) |value| {
|
|
45
|
+
@memcpy(bytes[at..][0..value.len], value);
|
|
46
|
+
at += value.len;
|
|
47
|
+
}
|
|
48
|
+
for (expanded) |flag| {
|
|
49
|
+
bytes[at] = @intFromBool(flag);
|
|
50
|
+
at += 1;
|
|
51
|
+
}
|
|
52
|
+
for (images[0..image_count]) |image| {
|
|
53
|
+
std.mem.writeInt(u64, bytes[at..][0..8], image.image, .little);
|
|
54
|
+
std.mem.writeInt(u32, bytes[at + 8 ..][0..4], @bitCast(image.width), .little);
|
|
55
|
+
std.mem.writeInt(u32, bytes[at + 12 ..][0..4], @bitCast(image.height), .little);
|
|
56
|
+
try put(bytes, at + 16, image.source.len);
|
|
57
|
+
at += 20;
|
|
58
|
+
@memcpy(bytes[at..][0..image.source.len], image.source);
|
|
59
|
+
at += image.source.len;
|
|
60
|
+
}
|
|
61
|
+
std.debug.assert(at == bytes.len);
|
|
62
|
+
return bytes;
|
|
63
|
+
}
|
|
64
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
65
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
66
|
+
}
|
|
67
|
+
fn float(bytes: []const u8, at: usize) f32 {
|
|
68
|
+
return @bitCast(word(bytes, at));
|
|
69
|
+
}
|
|
70
|
+
fn textAlign(value: u8) !canvas.TextAlign {
|
|
71
|
+
return switch (value) {
|
|
72
|
+
0 => .start,
|
|
73
|
+
1 => .center,
|
|
74
|
+
2 => .end,
|
|
75
|
+
else => error.InvalidMarkdownRecipe,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
fn mainAlign(value: u32) !canvas.WidgetMainAlignment {
|
|
79
|
+
return switch (value) {
|
|
80
|
+
0 => .start,
|
|
81
|
+
1 => .center,
|
|
82
|
+
2 => .end,
|
|
83
|
+
else => error.InvalidMarkdownRecipe,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fn validateHeader(header: []const u8) !void {
|
|
88
|
+
const op = header[0];
|
|
89
|
+
if (op > 8 or header[2] > 2 or word(header, 36) > 64 or word(header, 40) > 32) return error.InvalidMarkdownRecipe;
|
|
90
|
+
if (op != 5 and header[1] != 0 or op == 5 and header[1] > 5) return error.InvalidMarkdownRecipe;
|
|
91
|
+
const allowed_flags: u8 = switch (op) {
|
|
92
|
+
1 => 8,
|
|
93
|
+
2 => 3,
|
|
94
|
+
5 => 12,
|
|
95
|
+
6 => 16,
|
|
96
|
+
else => 0,
|
|
97
|
+
};
|
|
98
|
+
if (header[3] & ~allowed_flags != 0) return error.InvalidMarkdownRecipe;
|
|
99
|
+
const ordinal: i32 = @bitCast(word(header, 32));
|
|
100
|
+
if (ordinal < -1 or ordinal >= markdown.max_markdown_details_per_document or ordinal >= 0 and (op != 5 or header[1] != 2)) return error.InvalidMarkdownRecipe;
|
|
101
|
+
if (op != 8 and (word(header, 24) != 0 or word(header, 28) != 0 or word(header, 52) != 0)) return error.InvalidMarkdownRecipe;
|
|
102
|
+
if (op != 7 and word(header, 56) != 0) return error.InvalidMarkdownRecipe;
|
|
103
|
+
if (op != 3 and op != 7 and word(header, 44) != 0) return error.InvalidMarkdownRecipe;
|
|
104
|
+
if (op != 6 and op != 8 and ordinal < 0 and word(header, 48) != 0) return error.InvalidMarkdownRecipe;
|
|
105
|
+
if (op != 2 and word(header, 40) != 0) return error.InvalidMarkdownRecipe;
|
|
106
|
+
if (op != 0 and op != 1 and op != 5 and word(header, 36) != 0) return error.InvalidMarkdownRecipe;
|
|
107
|
+
if (op != 2 and op != 5 and header[2] != 0) return error.InvalidMarkdownRecipe;
|
|
108
|
+
const main = word(header, 60);
|
|
109
|
+
if (main != std.math.maxInt(u32) and (op != 1 and op != 5 or main > 2)) return error.InvalidMarkdownRecipe;
|
|
110
|
+
for ([_]usize{ 4, 8, 12 }) |offset| {
|
|
111
|
+
const value = float(header, offset);
|
|
112
|
+
if (!std.math.isFinite(value) or value < 0 or op != 0 and op != 1 and op != 2 and op != 5 and word(header, offset) != 0) return error.InvalidMarkdownRecipe;
|
|
113
|
+
}
|
|
114
|
+
if (op != 5 and op != 8 and (word(header, 16) != 0 or word(header, 20) != 0)) return error.InvalidMarkdownRecipe;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
pub fn collect(policy: Policy, arena: std.mem.Allocator, source: []const u8, output: []markdown.CollectedImageSource) ![]const markdown.CollectedImageSource {
|
|
118
|
+
const input = try request(arena, source, null, &.{}, &.{}, 1, output.len);
|
|
119
|
+
var reader = Reader{ .bytes = policy(input, arena) };
|
|
120
|
+
if (try reader.word() != 1) return error.InvalidMarkdownRecipe;
|
|
121
|
+
const count = try reader.word();
|
|
122
|
+
if (count > output.len) return error.InvalidMarkdownRecipe;
|
|
123
|
+
for (output[0..count]) |*record| {
|
|
124
|
+
const len = try reader.word();
|
|
125
|
+
if (len > record.bytes.len) return error.InvalidMarkdownRecipe;
|
|
126
|
+
@memcpy(record.bytes[0..len], try reader.take(len));
|
|
127
|
+
record.len = len;
|
|
128
|
+
}
|
|
129
|
+
if (reader.at != reader.bytes.len) return error.InvalidMarkdownRecipe;
|
|
130
|
+
return output[0..count];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
pub fn view(comptime Msg: type, policy: Policy, ui: *canvas.Ui(Msg), source: []const u8, options: markdown.Markdown(Msg).Options) !canvas.Ui(Msg).Node {
|
|
134
|
+
const input = try request(ui.arena, source, options.issue_link_base, options.details_expanded, options.images, 0, 0);
|
|
135
|
+
return execute(Msg, ui, policy(input, ui.arena), options);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
pub fn execute(comptime Msg: type, ui: *canvas.Ui(Msg), bytes: []const u8, routes: markdown.Markdown(Msg).Options) !canvas.Ui(Msg).Node {
|
|
139
|
+
const Ui = canvas.Ui(Msg);
|
|
140
|
+
// Text, links and labels all outlive the input packet, including when
|
|
141
|
+
// nested code construction resets or replaces a compiled result arena.
|
|
142
|
+
var reader = Reader{ .bytes = try ui.arena.dupe(u8, bytes) };
|
|
143
|
+
if (try reader.word() != 1) return error.InvalidMarkdownRecipe;
|
|
144
|
+
const count = try reader.word();
|
|
145
|
+
const root = try reader.word();
|
|
146
|
+
if (try reader.word() != 0 or count == 0 or root >= count or count > (bytes.len - reader.at) / 64) return error.InvalidMarkdownRecipe;
|
|
147
|
+
const nodes = try ui.arena.alloc(Ui.Node, count);
|
|
148
|
+
for (nodes, 0..) |*node, index| {
|
|
149
|
+
const header = try reader.take(64);
|
|
150
|
+
try validateHeader(header);
|
|
151
|
+
const child_count = word(header, 36);
|
|
152
|
+
if (child_count > (bytes.len - reader.at) / 4) return error.InvalidMarkdownRecipe;
|
|
153
|
+
const children = try ui.arena.alloc(Ui.Node, child_count);
|
|
154
|
+
for (children) |*child| {
|
|
155
|
+
const slot = try reader.word();
|
|
156
|
+
if (slot >= index) return error.InvalidMarkdownRecipe;
|
|
157
|
+
child.* = nodes[slot];
|
|
158
|
+
}
|
|
159
|
+
const span_count = word(header, 40);
|
|
160
|
+
const spans = try ui.arena.alloc(canvas.TextSpan, span_count);
|
|
161
|
+
for (spans) |*span| {
|
|
162
|
+
const h = try reader.take(16);
|
|
163
|
+
const flags = word(h, 0);
|
|
164
|
+
if (flags > 63 or !std.math.isFinite(float(h, 4)) or float(h, 4) < 0) return error.InvalidMarkdownRecipe;
|
|
165
|
+
span.* = .{ .weight = if (flags & 1 != 0) .bold else .regular, .italic = flags & 2 != 0, .monospace = flags & 4 != 0, .underline = flags & 8 != 0, .strikethrough = flags & 16 != 0, .background = if (flags & 32 != 0) .surface_pressed else null, .scale = float(h, 4), .text = try reader.take(word(h, 8)), .link = try reader.take(word(h, 12)) };
|
|
166
|
+
}
|
|
167
|
+
const text = try reader.take(word(header, 44));
|
|
168
|
+
const label = try reader.take(word(header, 48));
|
|
169
|
+
const link = try reader.take(word(header, 52));
|
|
170
|
+
const alignment = try textAlign(header[2]);
|
|
171
|
+
const flags = header[3];
|
|
172
|
+
const ordinal: i32 = @bitCast(word(header, 32));
|
|
173
|
+
if (ordinal < -1 or ordinal >= markdown.max_markdown_details_per_document) return error.InvalidMarkdownRecipe;
|
|
174
|
+
var o: Ui.ElementOptions = .{ .grow = float(header, 4), .padding = if (float(header, 8) == 0) null else float(header, 8), .gap = float(header, 12), .width = float(header, 16), .height = float(header, 20), .text_alignment = alignment, .on_link = routes.on_link, .style_tokens = .{ .foreground = if (flags & 1 != 0) .text_muted else null } };
|
|
175
|
+
const main = word(header, 60);
|
|
176
|
+
if (main != std.math.maxInt(u32)) o.main = try mainAlign(main);
|
|
177
|
+
if (flags & 8 != 0) o.cross = .center;
|
|
178
|
+
node.* = switch (header[0]) {
|
|
179
|
+
0 => ui.column(o, .{children}),
|
|
180
|
+
1 => ui.row(o, .{children}),
|
|
181
|
+
2 => blk: {
|
|
182
|
+
if (flags & 2 != 0) o.text_alignment = .start;
|
|
183
|
+
var paragraph = ui.paragraph(o, spans);
|
|
184
|
+
if (flags & 2 != 0) {
|
|
185
|
+
paragraph.widget.kind = .data_cell;
|
|
186
|
+
paragraph.widget.text_alignment = alignment;
|
|
187
|
+
}
|
|
188
|
+
break :blk paragraph;
|
|
189
|
+
},
|
|
190
|
+
3 => ui.text(.{}, text),
|
|
191
|
+
4 => ui.separator(.{}),
|
|
192
|
+
5 => blk: {
|
|
193
|
+
const kind: canvas.WidgetKind = switch (header[1]) {
|
|
194
|
+
0 => .separator,
|
|
195
|
+
1 => .stack,
|
|
196
|
+
2 => .list_item,
|
|
197
|
+
3 => .table,
|
|
198
|
+
4 => .data_row,
|
|
199
|
+
5 => .data_cell,
|
|
200
|
+
else => return error.InvalidMarkdownRecipe,
|
|
201
|
+
};
|
|
202
|
+
if (header[1] == 0) {
|
|
203
|
+
o.width = 0;
|
|
204
|
+
o.frame = .init(0, 0, float(header, 16), 0);
|
|
205
|
+
}
|
|
206
|
+
if (ordinal >= 0) {
|
|
207
|
+
o.key = .{ .int = @intCast(ordinal) };
|
|
208
|
+
o.semantics.label = label;
|
|
209
|
+
o.on_press = if (routes.on_details) |make| make(@intCast(ordinal)) else null;
|
|
210
|
+
}
|
|
211
|
+
var element = ui.el(kind, o, .{children});
|
|
212
|
+
if (ordinal >= 0) element.widget.state.expanded = flags & 4 != 0;
|
|
213
|
+
if (header[1] == 5) element.widget.text_alignment = alignment;
|
|
214
|
+
break :blk element;
|
|
215
|
+
},
|
|
216
|
+
6 => ui.checkbox(.{ .checked = flags & 16 != 0, .disabled = true, .semantics = .{ .label = label } }),
|
|
217
|
+
7 => blk: {
|
|
218
|
+
const language = std.enums.fromInt(canvas.code.Language, word(header, 56)) orelse return error.InvalidMarkdownRecipe;
|
|
219
|
+
break :blk ui.code(.{ .language = language }, text);
|
|
220
|
+
},
|
|
221
|
+
8 => ui.image(.{ .image = std.mem.readInt(u64, header[24..32], .little), .width = float(header, 16), .height = float(header, 20), .semantics = .{ .role = if (link.len > 0) .link else .image, .label = label, .focusable = link.len > 0 }, .on_press = if (link.len > 0 and routes.on_link != null) routes.on_link.?(link) else null }),
|
|
222
|
+
else => unreachable,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
if (reader.at != bytes.len) return error.InvalidMarkdownRecipe;
|
|
226
|
+
return nodes[root];
|
|
227
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//! Convert authored registered-image boundary records without rounding ids.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const markdown = @import("markdown.zig");
|
|
4
|
+
const reflect = @import("ui_markup_reflect.zig");
|
|
5
|
+
|
|
6
|
+
fn number(value: anytype) f64 {
|
|
7
|
+
return switch (@typeInfo(@TypeOf(value))) {
|
|
8
|
+
.int => @floatFromInt(value),
|
|
9
|
+
.float => @floatCast(value),
|
|
10
|
+
else => unreachable,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
fn word(value: anytype, limit: f64) error{InvalidImageIdentity}!u32 {
|
|
14
|
+
const n = number(value);
|
|
15
|
+
if (!std.math.isFinite(n) or n < 0 or n >= limit or @floor(n) != n) return error.InvalidImageIdentity;
|
|
16
|
+
return @intFromFloat(n);
|
|
17
|
+
}
|
|
18
|
+
fn identity(value: anytype) error{InvalidImageIdentity}!u64 {
|
|
19
|
+
if (comptime @typeInfo(@TypeOf(value)) == .pointer) return identity(value.*);
|
|
20
|
+
const T = reflect.Pointee(@TypeOf(value));
|
|
21
|
+
switch (@typeInfo(T)) {
|
|
22
|
+
.int => return std.math.cast(u64, value) orelse error.InvalidImageIdentity,
|
|
23
|
+
.float => {
|
|
24
|
+
const n = number(value);
|
|
25
|
+
if (!std.math.isFinite(n) or n < 0 or n >= 9007199254740992 or @floor(n) != n) return error.InvalidImageIdentity;
|
|
26
|
+
return @intFromFloat(n);
|
|
27
|
+
},
|
|
28
|
+
.@"struct" => return @as(u64, try word(value.imageLower, 4294967296)) | (@as(u64, try word(value.imageUpper, 2147483648)) << 32),
|
|
29
|
+
else => unreachable,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
pub fn convert(arena: std.mem.Allocator, items: anytype) ![]const markdown.ResolvedImage {
|
|
33
|
+
const Item = std.meta.Elem(@TypeOf(items));
|
|
34
|
+
if (comptime Item == markdown.ResolvedImage) return items;
|
|
35
|
+
const output = try arena.alloc(markdown.ResolvedImage, items.len);
|
|
36
|
+
for (items, output, 0..) |item, *result, index| result.* = .{
|
|
37
|
+
.source = items[index].source[0..],
|
|
38
|
+
.image = try identity(item.image),
|
|
39
|
+
.width = @floatCast(number(item.width)),
|
|
40
|
+
.height = @floatCast(number(item.height)),
|
|
41
|
+
};
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
test "Markdown image boundary accepts pointers and exact words while refusing malformed shapes" {
|
|
46
|
+
const Identity = struct { imageLower: f64, imageUpper: f64 };
|
|
47
|
+
const Item = struct { source: []const u8, image: *const Identity, width: i64, height: f64 };
|
|
48
|
+
try std.testing.expect(reflect.isMarkdownImageItem(*const Item));
|
|
49
|
+
const BadIdentity = struct { imageLower: bool, imageUpper: f64 };
|
|
50
|
+
const Bad = struct { source: []const u8, image: BadIdentity, width: i64, height: f64 };
|
|
51
|
+
try std.testing.expect(!reflect.isMarkdownImageItem(Bad));
|
|
52
|
+
try std.testing.expect(!reflect.isMarkdownImageItem(struct { image: Identity, width: i64, height: f64 }));
|
|
53
|
+
const id: Identity = .{ .imageLower = 4294967295, .imageUpper = 2147483647 };
|
|
54
|
+
const item: Item = .{ .source = "source\x00\xff", .image = &id, .width = 9, .height = 7.25 };
|
|
55
|
+
const items = [_]*const Item{&item};
|
|
56
|
+
const result = try convert(std.testing.allocator, items[0..]);
|
|
57
|
+
defer std.testing.allocator.free(result);
|
|
58
|
+
try std.testing.expectEqual(@as(u64, 0x7fff_ffff_ffff_ffff), result[0].image);
|
|
59
|
+
try std.testing.expectEqualStrings(item.source, result[0].source);
|
|
60
|
+
try std.testing.expectEqual(@as(f32, 9), result[0].width);
|
|
61
|
+
try std.testing.expectEqual(@as(f32, 7.25), result[0].height);
|
|
62
|
+
for ([_]Identity{
|
|
63
|
+
.{ .imageLower = -1, .imageUpper = 0 }, .{ .imageLower = 4294967296, .imageUpper = 0 },
|
|
64
|
+
.{ .imageLower = 0.5, .imageUpper = 0 }, .{ .imageLower = 0, .imageUpper = 2147483648 },
|
|
65
|
+
.{ .imageLower = std.math.nan(f64), .imageUpper = 0 }, .{ .imageLower = 0, .imageUpper = std.math.inf(f64) },
|
|
66
|
+
}) |bad| try std.testing.expectError(error.InvalidImageIdentity, identity(bad));
|
|
67
|
+
try std.testing.expectError(error.InvalidImageIdentity, identity(@as(f64, 9007199254740992)));
|
|
68
|
+
try std.testing.expectEqual(@as(u64, 9007199254740991), try identity(@as(f64, 9007199254740991)));
|
|
69
|
+
const native = [_]markdown.ResolvedImage{.{ .source = "native", .image = 0xffff_ffff_ffff_ffff, .width = 2, .height = 3 }};
|
|
70
|
+
const passthrough = try convert(std.testing.allocator, native[0..]);
|
|
71
|
+
try std.testing.expectEqual(native[0].image, passthrough[0].image);
|
|
72
|
+
try std.testing.expectEqual(native[0..].ptr, passthrough.ptr);
|
|
73
|
+
const scalar: u64 = 0x7fff_ffff_ffff_ffff;
|
|
74
|
+
const ScalarItem = struct { source: [3]u8, image: *const u64, width: f32, height: f32 };
|
|
75
|
+
try std.testing.expect(reflect.isMarkdownImageItem(ScalarItem));
|
|
76
|
+
const scalars = [_]ScalarItem{.{ .source = .{ 'p', 0, 255 }, .image = &scalar, .width = 2, .height = 3 }};
|
|
77
|
+
const converted = try convert(std.testing.allocator, scalars[0..]);
|
|
78
|
+
defer std.testing.allocator.free(converted);
|
|
79
|
+
try std.testing.expectEqual(scalar, converted[0].image);
|
|
80
|
+
try std.testing.expectEqualStrings("p\x00\xff", converted[0].source);
|
|
81
|
+
}
|
|
@@ -1321,14 +1321,14 @@ test "the README-shaped fixture renders through the mapper and the reference ren
|
|
|
1321
1321
|
// 760x2400 with default tokens and the deterministic bundled-face
|
|
1322
1322
|
// metrics. It pins the whole document register in one number: heading
|
|
1323
1323
|
// scales, wrapped bullets and em-dash spacing at the face's real
|
|
1324
|
-
// advances,
|
|
1325
|
-
// 0.6 em cells), GFM tables as borderless cells on hairline row
|
|
1324
|
+
// advances, regular/medium/bold sans and mono outlines (fixed-pitch
|
|
1325
|
+
// runs sit in their 0.6 em cells), GFM tables as borderless cells on hairline row
|
|
1326
1326
|
// separators with vertically centered cell content, bare fenced code
|
|
1327
1327
|
// with preserved source indentation and language-token colors, and
|
|
1328
1328
|
// near-black underlined links.
|
|
1329
1329
|
// Update deliberately when markdown rendering changes, reviewing the
|
|
1330
1330
|
// rendered pixels first (see reference_tests.zig conventions).
|
|
1331
|
-
const markdown_document_reference_signature: u64 =
|
|
1331
|
+
const markdown_document_reference_signature: u64 = 13932087754745656842;
|
|
1332
1332
|
|
|
1333
1333
|
fn markdownGoldenDumpRequested() bool {
|
|
1334
1334
|
if (comptime !@import("builtin").link_libc) return false;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
//! Native-owned request buffers and copied portable measurement continuations.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const widgets = @import("widgets.zig");
|
|
5
|
+
const tokens_model = @import("tokens.zig");
|
|
6
|
+
const metric = @import("widget_metric_policy.zig");
|
|
7
|
+
const container = @import("container_layout_policy.zig");
|
|
8
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
9
|
+
fn word(b: []u8, at: usize, value: u32) void {
|
|
10
|
+
std.mem.writeInt(u32, b[at..][0..4], value, .little);
|
|
11
|
+
}
|
|
12
|
+
fn read(b: []const u8, at: usize) u32 {
|
|
13
|
+
return std.mem.readInt(u32, b[at..][0..4], .little);
|
|
14
|
+
}
|
|
15
|
+
fn put(b: []u8, at: usize, value: f32) void {
|
|
16
|
+
word(b, at, @bitCast(value));
|
|
17
|
+
}
|
|
18
|
+
fn float(b: []const u8, at: usize) f32 {
|
|
19
|
+
return @bitCast(read(b, at));
|
|
20
|
+
}
|
|
21
|
+
fn absent(b: []const u8, first: usize, end: usize) void {
|
|
22
|
+
if (!std.mem.allEqual(u8, b[first..end], 0)) @panic("invalid absent measurement fields");
|
|
23
|
+
}
|
|
24
|
+
pub const WrappedAction = enum(u32) { done, intrinsic, paragraph, row_width, bubble_width, child_height };
|
|
25
|
+
pub const WrappedResult = struct {
|
|
26
|
+
bytes: [32]u8,
|
|
27
|
+
pub fn action(self: WrappedResult) WrappedAction {
|
|
28
|
+
return @enumFromInt(read(&self.bytes, 4));
|
|
29
|
+
}
|
|
30
|
+
pub fn index(self: WrappedResult) usize {
|
|
31
|
+
return read(&self.bytes, 8);
|
|
32
|
+
}
|
|
33
|
+
pub fn height(self: WrappedResult) f32 {
|
|
34
|
+
return float(&self.bytes, 12);
|
|
35
|
+
}
|
|
36
|
+
pub fn width(self: WrappedResult) f32 {
|
|
37
|
+
return float(&self.bytes, 16);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
pub const WrappedPlan = struct {
|
|
41
|
+
allocator: std.mem.Allocator,
|
|
42
|
+
policy: Policy,
|
|
43
|
+
request: []u8,
|
|
44
|
+
count: usize,
|
|
45
|
+
pub fn init(allocator: std.mem.Allocator, widget: widgets.Widget, tokens: tokens_model.DesignTokens, width: f32, depth: usize, limit: usize, variable_row: bool, accordion_content: bool, selected: bool) !WrappedPlan {
|
|
46
|
+
const count = widget.children.len;
|
|
47
|
+
const request = try allocator.alloc(u8, try std.math.add(usize, 288, try std.math.mul(usize, count, 32)));
|
|
48
|
+
@memset(request, 0);
|
|
49
|
+
request[0..4].* = .{ 34, 1, if (accordion_content) 2 else if (variable_row) 1 else 0, @as(u8, @intFromBool(widget.layout.virtualized)) | (@as(u8, @intFromBool(widget.layout.padding_is_kind_default)) << 1) | (@as(u8, @intFromBool(selected)) << 2) };
|
|
50
|
+
word(request, 4, std.math.cast(u32, count) orelse @panic("wrapped child count exceeds wire range"));
|
|
51
|
+
word(request, 8, std.math.cast(u32, depth) orelse std.math.maxInt(u32));
|
|
52
|
+
word(request, 12, @intCast(limit));
|
|
53
|
+
for ([_]f32{ width, widget.frame.height, widget.layout.min_size.height, widget.layout.max_size.height }, 0..) |value, i| put(request, 16 + i * 4, value);
|
|
54
|
+
const registers = metric.Request.init(.intrinsic, widget, tokens, 0);
|
|
55
|
+
@memcpy(request[64..288], ®isters.bytes);
|
|
56
|
+
return .{ .allocator = allocator, .policy = tokens.measurement_coordination_policy.?, .request = request, .count = count };
|
|
57
|
+
}
|
|
58
|
+
pub fn deinit(self: WrappedPlan) void {
|
|
59
|
+
self.allocator.free(self.request);
|
|
60
|
+
}
|
|
61
|
+
pub fn setChild(self: WrappedPlan, index: usize, child: widgets.Widget, flow: bool) void {
|
|
62
|
+
const at = 288 + index * 32;
|
|
63
|
+
word(self.request, at, @as(u32, @intFromBool(flow)) | (@as(u32, @intFromBool(child.kind == .bubble)) << 1) | (@as(u32, @intFromBool(child.variant == .ghost)) << 2));
|
|
64
|
+
put(self.request, at + 4, child.frame.width);
|
|
65
|
+
put(self.request, at + 20, child.layout.min_size.width);
|
|
66
|
+
put(self.request, at + 24, child.layout.max_size.width);
|
|
67
|
+
}
|
|
68
|
+
pub fn run(self: WrappedPlan) WrappedResult {
|
|
69
|
+
var result: WrappedResult = .{ .bytes = @splat(0xa5) };
|
|
70
|
+
if (self.policy(self.request, &result.bytes) != 32 or read(&result.bytes, 0) != 1 or read(&result.bytes, 4) > 5) @panic("invalid wrapped measurement result");
|
|
71
|
+
absent(&result.bytes, 20, 32);
|
|
72
|
+
const action = result.action();
|
|
73
|
+
if (action == .done) {
|
|
74
|
+
absent(&result.bytes, 8, 12);
|
|
75
|
+
absent(&result.bytes, 16, 20);
|
|
76
|
+
} else {
|
|
77
|
+
absent(&result.bytes, 12, 16);
|
|
78
|
+
if (action == .intrinsic or action == .paragraph) {
|
|
79
|
+
absent(&result.bytes, 8, 12);
|
|
80
|
+
if (read(self.request, 40) & @as(u32, if (action == .intrinsic) 1 else 2) != 0) @panic("repeated wrapped measurement");
|
|
81
|
+
if (action == .intrinsic) absent(&result.bytes, 16, 20);
|
|
82
|
+
} else {
|
|
83
|
+
const index = result.index();
|
|
84
|
+
if (index >= self.count or read(self.request, 288 + index * 32) & 1 == 0 or read(self.request, 304 + index * 32) & @as(u32, if (action == .child_height) 2 else 1) != 0) @panic("invalid wrapped child continuation");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
pub fn reply(self: WrappedPlan, result: WrappedResult, value: f32) void {
|
|
90
|
+
switch (result.action()) {
|
|
91
|
+
.done => unreachable,
|
|
92
|
+
.intrinsic, .paragraph => {
|
|
93
|
+
const intrinsic = result.action() == .intrinsic;
|
|
94
|
+
put(self.request, if (intrinsic) 32 else 36, value);
|
|
95
|
+
word(self.request, 40, read(self.request, 40) | @as(u32, if (intrinsic) 1 else 2));
|
|
96
|
+
},
|
|
97
|
+
.row_width, .bubble_width, .child_height => {
|
|
98
|
+
const at = 288 + result.index() * 32;
|
|
99
|
+
const height = result.action() == .child_height;
|
|
100
|
+
put(self.request, at + @as(usize, if (height) 12 else 8), value);
|
|
101
|
+
word(self.request, at + 16, read(self.request, at + 16) | @as(u32, if (height) 2 else 1));
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
pub const ChildAction = enum(u32) { done, main, cross };
|
|
107
|
+
pub const ChildResult = struct {
|
|
108
|
+
bytes: [64]u8,
|
|
109
|
+
pub fn action(self: ChildResult) ChildAction {
|
|
110
|
+
return @enumFromInt(read(&self.bytes, 4));
|
|
111
|
+
}
|
|
112
|
+
pub fn dimension(self: ChildResult) usize {
|
|
113
|
+
return read(&self.bytes, 8);
|
|
114
|
+
}
|
|
115
|
+
pub fn child(self: ChildResult) container.Child {
|
|
116
|
+
return .{ .flags = read(&self.bytes, 16), .grow = float(&self.bytes, 20), .main = float(&self.bytes, 24), .cross = float(&self.bytes, 28), .offset_main = float(&self.bytes, 32), .offset_cross = float(&self.bytes, 36), .min_main = float(&self.bytes, 40), .max_main = float(&self.bytes, 44), .min_cross = float(&self.bytes, 48), .max_cross = float(&self.bytes, 52), .measured_main = float(&self.bytes, 56), .measured_cross = float(&self.bytes, 60) };
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
pub const ChildPlan = struct {
|
|
120
|
+
policy: Policy,
|
|
121
|
+
request: [80]u8 = @splat(0),
|
|
122
|
+
pub fn init(widget: widgets.Widget, tokens: tokens_model.DesignTokens, axis: u8, fill: bool, stretch: bool, measure_cross: bool) ChildPlan {
|
|
123
|
+
var self: ChildPlan = .{ .policy = tokens.measurement_coordination_policy.? };
|
|
124
|
+
self.request[0..7].* = .{ 35, 1, axis, @as(u8, @intFromBool(fill)) | (@as(u8, @intFromBool(stretch)) << 1) | (@as(u8, @intFromBool(measure_cross)) << 2) | (@as(u8, @intFromBool(tokens.controls.tabs_indicator == .underline)) << 3) | (@as(u8, @intFromBool(tokens.metrics.tabs_list_full_width)) << 4), @intFromEnum(widget.kind), @intFromEnum(widget.variant), @import("render_plan_policy.zig").numericFlags() };
|
|
125
|
+
const values = [_]f32{ widget.frame.x, widget.frame.y, widget.frame.width, widget.frame.height, widget.layout.min_size.width, widget.layout.min_size.height, widget.layout.max_size.width, widget.layout.max_size.height, widget.layout.grow };
|
|
126
|
+
for (values, 0..) |value, i| put(&self.request, 16 + i * 4, value);
|
|
127
|
+
return self;
|
|
128
|
+
}
|
|
129
|
+
pub fn run(self: ChildPlan) ChildResult {
|
|
130
|
+
var result: ChildResult = .{ .bytes = @splat(0xa5) };
|
|
131
|
+
if (self.policy(&self.request, &result.bytes) != 64 or read(&result.bytes, 0) != 1 or read(&result.bytes, 4) > 2) @panic("invalid axis measurement result");
|
|
132
|
+
absent(&result.bytes, 12, 16);
|
|
133
|
+
if (result.action() == .done) {
|
|
134
|
+
absent(&result.bytes, 8, 12);
|
|
135
|
+
if (read(&result.bytes, 16) > 31) @panic("invalid axis child flags");
|
|
136
|
+
} else {
|
|
137
|
+
absent(&result.bytes, 16, 64);
|
|
138
|
+
if (result.dimension() > 1 or read(&self.request, 8) & @as(u32, if (result.action() == .main) 1 else 2) != 0) @panic("invalid axis continuation");
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
pub fn reply(self: *ChildPlan, result: ChildResult, size: geometry.SizeF) void {
|
|
143
|
+
const main = result.action() == .main;
|
|
144
|
+
std.debug.assert(result.action() != .done);
|
|
145
|
+
put(&self.request, if (main) 52 else 56, if (result.dimension() == 0) size.width else size.height);
|
|
146
|
+
word(&self.request, 8, read(&self.request, 8) | @as(u32, if (main) 1 else 2));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
pub const SpanResult = struct {
|
|
150
|
+
bytes: [16]u8,
|
|
151
|
+
pub fn pending(self: SpanResult) bool {
|
|
152
|
+
return read(&self.bytes, 4) == 1;
|
|
153
|
+
}
|
|
154
|
+
pub fn index(self: SpanResult) usize {
|
|
155
|
+
return read(&self.bytes, 8);
|
|
156
|
+
}
|
|
157
|
+
pub fn found(self: SpanResult) bool {
|
|
158
|
+
return read(&self.bytes, 12) == 1;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
pub const SpanPlan = struct {
|
|
162
|
+
allocator: std.mem.Allocator,
|
|
163
|
+
policy: Policy,
|
|
164
|
+
request: []u8,
|
|
165
|
+
count: usize,
|
|
166
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, widget: widgets.Widget, depth: usize, limit: usize) !SpanPlan {
|
|
167
|
+
const count = widget.children.len;
|
|
168
|
+
const request = try allocator.alloc(u8, try std.math.add(usize, 16, try std.math.mul(usize, count, 4)));
|
|
169
|
+
@memset(request, 0);
|
|
170
|
+
request[0..4].* = .{ 36, 1, @intFromEnum(widget.kind), @intFromBool(widget.spans.len > 0) };
|
|
171
|
+
word(request, 4, std.math.cast(u32, depth) orelse std.math.maxInt(u32));
|
|
172
|
+
word(request, 8, @intCast(limit));
|
|
173
|
+
word(request, 12, std.math.cast(u32, count) orelse @panic("span child count exceeds wire range"));
|
|
174
|
+
return .{ .allocator = allocator, .policy = policy, .request = request, .count = count };
|
|
175
|
+
}
|
|
176
|
+
pub fn deinit(self: SpanPlan) void {
|
|
177
|
+
self.allocator.free(self.request);
|
|
178
|
+
}
|
|
179
|
+
pub fn run(self: SpanPlan) SpanResult {
|
|
180
|
+
var result: SpanResult = .{ .bytes = @splat(0xa5) };
|
|
181
|
+
if (self.policy(self.request, &result.bytes) != 16 or read(&result.bytes, 0) != 1 or read(&result.bytes, 4) > 1 or read(&result.bytes, 12) > 1) @panic("invalid span subtree result");
|
|
182
|
+
if (result.pending()) {
|
|
183
|
+
if (result.index() >= self.count or read(self.request, 16 + result.index() * 4) != 0) @panic("invalid span child continuation");
|
|
184
|
+
absent(&result.bytes, 12, 16);
|
|
185
|
+
} else absent(&result.bytes, 8, 12);
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
pub fn reply(self: SpanPlan, result: SpanResult, found: bool) void {
|
|
189
|
+
std.debug.assert(result.pending());
|
|
190
|
+
word(self.request, 16 + result.index() * 4, if (found) 2 else 1);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
pub const AxisAction = enum(u32) { done, child, first_spans, second_spans, wrapped };
|
|
194
|
+
pub const AxisResult = struct {
|
|
195
|
+
bytes: [32]u8,
|
|
196
|
+
pub fn action(self: AxisResult) AxisAction {
|
|
197
|
+
return @enumFromInt(read(&self.bytes, 4));
|
|
198
|
+
}
|
|
199
|
+
pub fn index(self: AxisResult) usize {
|
|
200
|
+
return read(&self.bytes, 8);
|
|
201
|
+
}
|
|
202
|
+
pub fn width(self: AxisResult) f32 {
|
|
203
|
+
return float(&self.bytes, 16);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
pub const AxisPlan = struct {
|
|
207
|
+
allocator: std.mem.Allocator,
|
|
208
|
+
policy: Policy,
|
|
209
|
+
request: []u8,
|
|
210
|
+
result: []u8,
|
|
211
|
+
count: usize,
|
|
212
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, count: usize, content: geometry.RectF, axis: u8, main: u8, cross: u8, gap: f32) !AxisPlan {
|
|
213
|
+
const request = try allocator.alloc(u8, try std.math.add(usize, 64, try std.math.mul(usize, count, 64)));
|
|
214
|
+
errdefer allocator.free(request);
|
|
215
|
+
const result = try allocator.alloc(u8, try std.math.add(usize, 44, try std.math.mul(usize, count, 16)));
|
|
216
|
+
@memset(request, 0);
|
|
217
|
+
request[0..3].* = .{ 37, 1, @import("render_plan_policy.zig").numericFlags() };
|
|
218
|
+
word(request, 4, std.math.cast(u32, count) orelse @panic("axis child count exceeds wire range"));
|
|
219
|
+
request[16..24].* = .{ 5, 0, axis, main, cross, 0, 0, 0 };
|
|
220
|
+
word(request, 24, @intCast(count));
|
|
221
|
+
for ([_]f32{ content.x, content.y, content.width, content.height, gap }, 0..) |value, i| put(request, 28 + i * 4, value);
|
|
222
|
+
return .{ .allocator = allocator, .policy = policy, .request = request, .result = result, .count = count };
|
|
223
|
+
}
|
|
224
|
+
pub fn deinit(self: AxisPlan) void {
|
|
225
|
+
self.allocator.free(self.result);
|
|
226
|
+
self.allocator.free(self.request);
|
|
227
|
+
}
|
|
228
|
+
pub fn setFlow(self: AxisPlan, index: usize, flow: bool) void {
|
|
229
|
+
word(self.request, 64 + index * 64, @intFromBool(flow));
|
|
230
|
+
}
|
|
231
|
+
pub fn run(self: AxisPlan) AxisResult {
|
|
232
|
+
@memset(self.result, 0xa5);
|
|
233
|
+
const written = self.policy(self.request, self.result);
|
|
234
|
+
if (written < 32 or read(self.result, 0) != 1 or read(self.result, 4) > 4) @panic("invalid axis coordination result");
|
|
235
|
+
const result: AxisResult = .{ .bytes = self.result[0..32].* };
|
|
236
|
+
absent(&result.bytes, 12, 16);
|
|
237
|
+
absent(&result.bytes, 20, 32);
|
|
238
|
+
if (result.action() == .done) {
|
|
239
|
+
if (written != self.result.len or read(self.result, 32) != self.count) @panic("invalid axis allocation length");
|
|
240
|
+
absent(&result.bytes, 8, 20);
|
|
241
|
+
} else {
|
|
242
|
+
const index = result.index();
|
|
243
|
+
if (written != 32 or index >= self.count or read(self.request, 64 + index * 64) & 1 == 0) @panic("invalid axis child continuation");
|
|
244
|
+
const state = read(self.request, 112 + index * 64);
|
|
245
|
+
const bit: u32 = switch (result.action()) {
|
|
246
|
+
.done => unreachable,
|
|
247
|
+
.child => 1,
|
|
248
|
+
.first_spans => 2,
|
|
249
|
+
.second_spans => 4,
|
|
250
|
+
.wrapped => 8,
|
|
251
|
+
};
|
|
252
|
+
if (state & bit != 0) @panic("repeated axis coordination query");
|
|
253
|
+
if (result.action() != .wrapped) absent(&result.bytes, 16, 20);
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
pub fn replyChild(self: AxisPlan, result: AxisResult, child: container.Child) void {
|
|
258
|
+
std.debug.assert(result.action() == .child);
|
|
259
|
+
const at = 64 + result.index() * 64;
|
|
260
|
+
word(self.request, at, child.flags);
|
|
261
|
+
const values = [_]f32{ child.grow, child.main, child.cross, child.offset_main, child.offset_cross, child.min_main, child.max_main, child.min_cross, child.max_cross, child.measured_main, child.measured_cross };
|
|
262
|
+
for (values, 0..) |value, i| put(self.request, at + 4 + i * 4, value);
|
|
263
|
+
word(self.request, at + 48, 1);
|
|
264
|
+
}
|
|
265
|
+
pub fn replySpans(self: AxisPlan, result: AxisResult, found: bool) void {
|
|
266
|
+
std.debug.assert(result.action() == .first_spans or result.action() == .second_spans);
|
|
267
|
+
const at = 64 + result.index() * 64;
|
|
268
|
+
const first = result.action() == .first_spans;
|
|
269
|
+
word(self.request, at + @as(usize, if (first) 52 else 56), @intFromBool(found));
|
|
270
|
+
word(self.request, at + 48, read(self.request, at + 48) | @as(u32, if (first) 2 else 4));
|
|
271
|
+
}
|
|
272
|
+
pub fn replyHeight(self: AxisPlan, result: AxisResult, height: f32) void {
|
|
273
|
+
std.debug.assert(result.action() == .wrapped);
|
|
274
|
+
const at = 64 + result.index() * 64;
|
|
275
|
+
put(self.request, at + 60, height);
|
|
276
|
+
word(self.request, at + 48, read(self.request, at + 48) | 8);
|
|
277
|
+
}
|
|
278
|
+
pub fn used(self: AxisPlan) f32 {
|
|
279
|
+
return float(self.result, 36);
|
|
280
|
+
}
|
|
281
|
+
pub fn overflow(self: AxisPlan) f32 {
|
|
282
|
+
return float(self.result, 40);
|
|
283
|
+
}
|
|
284
|
+
pub fn frame(self: AxisPlan, index: usize) geometry.RectF {
|
|
285
|
+
const at = 44 + index * 16;
|
|
286
|
+
return .init(float(self.result, at), float(self.result, at + 4), float(self.result, at + 8), float(self.result, at + 12));
|
|
287
|
+
}
|
|
288
|
+
};
|