@native-sdk/cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1796 -83
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -31,6 +31,7 @@ const builtin = @import("builtin");
|
|
|
31
31
|
const canvas = @import("root.zig");
|
|
32
32
|
const markup = @import("ui_markup.zig");
|
|
33
33
|
const interpreter = @import("ui_markup_view.zig");
|
|
34
|
+
const reflect = @import("ui_markup_reflect.zig");
|
|
34
35
|
|
|
35
36
|
const Value = interpreter.Value;
|
|
36
37
|
|
|
@@ -142,16 +143,21 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
142
143
|
slot_nodes: []const markup.MarkupNode = &.{},
|
|
143
144
|
slot_entries: []const ScopeEntry = &.{},
|
|
144
145
|
SiteScope: type = void,
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
/// True when a value arg came from a declaration default rather
|
|
147
|
+
/// than an explicit use-site argument.
|
|
148
|
+
defaulted: bool = false,
|
|
149
|
+
const Kind = enum { item, value_arg, slice_arg, slot, virtual };
|
|
147
150
|
};
|
|
148
151
|
|
|
152
|
+
const VirtualBinding = struct { options: Ui.VirtualListOptions, range: canvas.VirtualListRange, consumed: *bool };
|
|
153
|
+
|
|
149
154
|
fn EntryPayload(comptime entry: ScopeEntry) type {
|
|
150
155
|
return switch (entry.kind) {
|
|
151
156
|
.item => *const entry.Item,
|
|
152
157
|
.value_arg => Value,
|
|
153
158
|
.slice_arg => []const entry.Item,
|
|
154
159
|
.slot => entry.SiteScope,
|
|
160
|
+
.virtual => VirtualBinding,
|
|
155
161
|
};
|
|
156
162
|
}
|
|
157
163
|
|
|
@@ -260,6 +266,24 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
260
266
|
// ------------------------------------------------------ building
|
|
261
267
|
|
|
262
268
|
fn buildElement(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype) Ui.Node {
|
|
269
|
+
return buildElementWithForwardedPress(node, entries, ui, model, scope, null);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
fn buildElementWithForwardedPress(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, forwarded_press: ?MsgT) Ui.Node {
|
|
273
|
+
var built = buildElementInner(node, entries, ui, model, scope, forwarded_press);
|
|
274
|
+
if (forwarded_press) |msg| {
|
|
275
|
+
// A press declared on <use> belongs to the expanded root.
|
|
276
|
+
// The root-specific builder may also use it to render its
|
|
277
|
+
// press affordance; this final stamp covers generic roots.
|
|
278
|
+
built.on_press = msg;
|
|
279
|
+
built.widget.semantics.focusable = true;
|
|
280
|
+
}
|
|
281
|
+
return built;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
fn buildElementInner(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, forwarded_press: ?MsgT) Ui.Node {
|
|
285
|
+
if (comptime std.mem.eql(u8, node.name, "virtual-window")) return buildVirtualWindow(node, entries, ui, model, scope);
|
|
286
|
+
if (comptime std.mem.eql(u8, node.name, "virtual-list")) return buildVirtualList(node, entries, ui, model, scope);
|
|
263
287
|
if (comptime std.mem.eql(u8, node.name, "markdown")) {
|
|
264
288
|
return buildMarkdown(node, entries, ui, model, scope);
|
|
265
289
|
}
|
|
@@ -277,7 +301,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
277
301
|
return buildTimeline(node, entries, ui, model, scope);
|
|
278
302
|
}
|
|
279
303
|
if (comptime std.mem.eql(u8, node.name, "timeline-item")) {
|
|
280
|
-
return buildTimelineItem(node, entries, ui, model, scope);
|
|
304
|
+
return buildTimelineItem(node, entries, ui, model, scope, forwarded_press);
|
|
281
305
|
}
|
|
282
306
|
if (comptime std.mem.eql(u8, node.name, "chart")) {
|
|
283
307
|
return buildChart(node, entries, ui, model, scope);
|
|
@@ -487,7 +511,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
487
511
|
return built;
|
|
488
512
|
},
|
|
489
513
|
.app => |spelled| options.icon = spelled,
|
|
490
|
-
.binding => options.icon = stringAttr(node, entries, comptime node.attr("name").?, ui, model, scope, markup.icon_name_message),
|
|
514
|
+
.binding => options.icon = stringAttr(node, entries, "name", comptime node.attr("name").?, ui, model, scope, markup.icon_name_message),
|
|
491
515
|
.invalid => unreachable,
|
|
492
516
|
}
|
|
493
517
|
return ui.el(kind, options, .{});
|
|
@@ -607,6 +631,128 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
607
631
|
}
|
|
608
632
|
}
|
|
609
633
|
|
|
634
|
+
fn virtualCountAttr(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime name: []const u8, comptime fallback: usize, ui: *Ui, model: *const ModelT, scope: anytype) usize {
|
|
635
|
+
if (comptime node.attr(name) == null) return fallback;
|
|
636
|
+
const raw = comptime node.attr(name).?;
|
|
637
|
+
comptime requireVariant(exprVariant(node, entries, raw), &.{.integer}, node, "virtual window count requires an integer");
|
|
638
|
+
const value = evalExpr(node, entries, raw, ui, model, scope);
|
|
639
|
+
if (value == .integer and value.integer >= 0 and value.integer <= 9007199254740991) return @intCast(value.integer);
|
|
640
|
+
return runtimeFail(usize, ui);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
fn virtualExtentAttr(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime name: []const u8, ui: *Ui, model: *const ModelT, scope: anytype) f32 {
|
|
644
|
+
if (comptime node.attr(name) == null) return 0;
|
|
645
|
+
const value = floatAttr(node, entries, node.attr(name).?, ui, model, scope);
|
|
646
|
+
if (!std.math.isFinite(value) or value < 0) return runtimeFail(f32, ui);
|
|
647
|
+
return value;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
fn buildVirtualWindow(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype) Ui.Node {
|
|
651
|
+
comptime {
|
|
652
|
+
for (entries) |entry| if (entry.kind == .virtual) fail(node, "virtual-window declarations cannot nest");
|
|
653
|
+
if (node.children.len != 1 or (node.children[0].kind != .element and node.children[0].kind != .use_block)) fail(node, "virtual-window requires one root child");
|
|
654
|
+
for (node.attrs) |attribute| if (!markup.nameInList(attribute.name, &markup.virtual_window_attrs)) fail(node, "unsupported virtual-window attribute");
|
|
655
|
+
}
|
|
656
|
+
const identity = comptime node.attr("id") orelse fail(node, "virtual-window requires id");
|
|
657
|
+
const name = comptime node.attr("as") orelse fail(node, "virtual-window requires as");
|
|
658
|
+
const id = canvas.globalWidgetId(.scroll_view, .{ .str = identity });
|
|
659
|
+
if (ui.virtualWindows().len >= canvas.max_virtual_windows) return runtimeFail(Ui.Node, ui);
|
|
660
|
+
for (ui.virtualWindows()) |prior| if (prior.id == id) return runtimeFail(Ui.Node, ui);
|
|
661
|
+
var options = Ui.VirtualListOptions{
|
|
662
|
+
.id = identity,
|
|
663
|
+
.item_count = virtualCountAttr(node, entries, "item-count", 0, ui, model, scope),
|
|
664
|
+
.item_extent = virtualExtentAttr(node, entries, "item-extent", ui, model, scope),
|
|
665
|
+
.gap = virtualExtentAttr(node, entries, "gap", ui, model, scope),
|
|
666
|
+
.overscan = virtualCountAttr(node, entries, "overscan", 4, ui, model, scope),
|
|
667
|
+
.viewport_fallback = virtualExtentAttr(node, entries, "viewport-fallback", ui, model, scope),
|
|
668
|
+
.index_base = virtualCountAttr(node, entries, "index-base", 0, ui, model, scope),
|
|
669
|
+
.anchor = if (comptime std.mem.eql(u8, node.attr("anchor") orelse "leading", "trailing")) .trailing else .leading,
|
|
670
|
+
};
|
|
671
|
+
if (options.index_base > 9007199254740991 - options.item_count) return runtimeFail(Ui.Node, ui);
|
|
672
|
+
if (comptime node.attr("extent-estimate") != null) {
|
|
673
|
+
const estimate = comptime node.attr("extent-estimate").?;
|
|
674
|
+
if (comptime @hasDecl(ModelT, "virtualExtentHelper") and @hasDecl(ModelT, "virtualExtentEstimate")) {
|
|
675
|
+
const helper = comptime ModelT.virtualExtentHelper(estimate) orelse fail(node, "extent-estimate requires a numeric index helper");
|
|
676
|
+
options.extent_estimate = ModelT.virtualExtentEstimate;
|
|
677
|
+
options.extent_context = @ptrFromInt(@as(usize, helper) + 1);
|
|
678
|
+
} else comptime fail(node, "extent-estimate requires a stable compiled helper capability");
|
|
679
|
+
}
|
|
680
|
+
if (options.extent_estimate == null and options.item_extent == 0) return runtimeFail(Ui.Node, ui);
|
|
681
|
+
const consumed = ui.arena.create(bool) catch return runtimeFail(Ui.Node, ui);
|
|
682
|
+
consumed.* = false;
|
|
683
|
+
const binding = VirtualBinding{ .options = options, .range = ui.virtualWindow(options), .consumed = consumed };
|
|
684
|
+
const inner = comptime entries ++ &[_]ScopeEntry{.{ .name = name, .kind = .virtual, .Item = canvas.VirtualListRange }};
|
|
685
|
+
const result = if (comptime node.children[0].kind == .use_block) buildUse(node.children[0], inner, ui, model, .{ .parent = scope, .item = binding }) else buildElement(node.children[0], inner, ui, model, .{ .parent = scope, .item = binding });
|
|
686
|
+
if (!consumed.*) return runtimeFail(Ui.Node, ui);
|
|
687
|
+
return result;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
fn buildVirtualList(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype) Ui.Node {
|
|
691
|
+
const index = comptime scopeIndex(entries, node.attr("window") orelse fail(node, "virtual-list requires window")) orelse fail(node, "virtual-list requires an enclosing window");
|
|
692
|
+
comptime {
|
|
693
|
+
if (entries[index].kind != .virtual) fail(node, "virtual-list requires an enclosing window");
|
|
694
|
+
if (node.children.len != 1 or (node.children[0].kind != .element and node.children[0].kind != .use_block)) fail(node, "virtual-list requires one keyed root per row");
|
|
695
|
+
}
|
|
696
|
+
const name = comptime node.attr("as") orelse fail(node, "virtual-list requires as");
|
|
697
|
+
const each = comptime node.attr("each") orelse fail(node, "virtual-list requires each");
|
|
698
|
+
const query = comptime blk: {
|
|
699
|
+
if (!@hasDecl(ModelT, each)) fail(node, "virtual-list each requires a complete range query");
|
|
700
|
+
const Decl = @TypeOf(@field(ModelT, each));
|
|
701
|
+
if (!reflect.isVirtualItemFn(ModelT, Decl)) fail(node, "virtual-list each requires a complete range query");
|
|
702
|
+
break :blk @typeInfo(Decl).@"fn";
|
|
703
|
+
};
|
|
704
|
+
const Parameter = query.params[1].type.?;
|
|
705
|
+
const Range = reflect.Pointee(Parameter);
|
|
706
|
+
const Item = reflect.sliceElement(query.return_type.?).?;
|
|
707
|
+
const resolved = scopePayload(entries, index, scope);
|
|
708
|
+
if (resolved.consumed.*) return runtimeFail(Ui.Node, ui);
|
|
709
|
+
resolved.consumed.* = true;
|
|
710
|
+
var range: Range = undefined;
|
|
711
|
+
inline for (@typeInfo(Range).@"struct".fields) |field| {
|
|
712
|
+
const source = @field(resolved.range, field.name);
|
|
713
|
+
@field(range, field.name) = switch (@typeInfo(field.type)) {
|
|
714
|
+
.int => @intCast(source),
|
|
715
|
+
.float => if (@typeInfo(@TypeOf(source)) == .int) @floatFromInt(source) else @floatCast(source),
|
|
716
|
+
else => unreachable,
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
const argument = if (Parameter == Range) range else ⦥
|
|
720
|
+
const items = if (comptime query.params.len == 3) @field(ModelT, each)(model, argument, ui.arena) else @field(ModelT, each)(model, argument);
|
|
721
|
+
if (items.len != resolved.range.itemCount()) return runtimeFail(Ui.Node, ui);
|
|
722
|
+
var rows: std.ArrayListUnmanaged(Ui.Node) = .empty;
|
|
723
|
+
const inner = comptime entries ++ &[_]ScopeEntry{.{ .name = name, .kind = .item, .Item = Item }};
|
|
724
|
+
for (items) |*item| {
|
|
725
|
+
const row = if (comptime node.children[0].kind == .use_block) buildUse(node.children[0], inner, ui, model, .{ .parent = scope, .item = item }) else buildElement(node.children[0], inner, ui, model, .{ .parent = scope, .item = item });
|
|
726
|
+
if (row.key == null and row.global_key == null) return runtimeFail(Ui.Node, ui);
|
|
727
|
+
rows.append(ui.arena, row) catch return runtimeFail(Ui.Node, ui);
|
|
728
|
+
}
|
|
729
|
+
const proxy = comptime blk: {
|
|
730
|
+
var copy = node;
|
|
731
|
+
copy.name = "scroll";
|
|
732
|
+
var attributes: []const markup.MarkupAttr = &.{};
|
|
733
|
+
for (node.attrs) |attribute| {
|
|
734
|
+
if (!std.mem.eql(u8, attribute.name, "window") and !std.mem.eql(u8, attribute.name, "each") and !std.mem.eql(u8, attribute.name, "as")) attributes = attributes ++ &[_]markup.MarkupAttr{attribute};
|
|
735
|
+
}
|
|
736
|
+
copy.attrs = attributes;
|
|
737
|
+
break :blk copy;
|
|
738
|
+
};
|
|
739
|
+
var element: Ui.ElementOptions = .{};
|
|
740
|
+
applyAttrs(proxy, entries, ui, model, scope, &element);
|
|
741
|
+
var options = resolved.options;
|
|
742
|
+
options.width = element.width;
|
|
743
|
+
options.height = element.height;
|
|
744
|
+
options.min_width = element.min_width;
|
|
745
|
+
options.grow = element.grow;
|
|
746
|
+
options.padding = element.padding orelse 0;
|
|
747
|
+
options.style_tokens = element.style_tokens;
|
|
748
|
+
options.semantics = element.semantics;
|
|
749
|
+
options.overscroll = element.overscroll;
|
|
750
|
+
options.on_scroll = element.on_scroll;
|
|
751
|
+
options.on_reach_end = element.on_reach_end;
|
|
752
|
+
options.on_reach_start = element.on_reach_start;
|
|
753
|
+
return ui.virtualList(options, resolved.range, .{rows.items});
|
|
754
|
+
}
|
|
755
|
+
|
|
610
756
|
fn buildChildren(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, out: *std.ArrayListUnmanaged(Ui.Node)) void {
|
|
611
757
|
buildChildList(comptime node.children, entries, ui, model, scope, out);
|
|
612
758
|
}
|
|
@@ -786,8 +932,8 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
786
932
|
const expression = markup.parseAttrExpression(raw) orelse fail(node, markup.markdown_issue_link_base_message);
|
|
787
933
|
if (expression == .equals) fail(node, markup.markdown_issue_link_base_message);
|
|
788
934
|
}
|
|
789
|
-
comptime requireVariant(
|
|
790
|
-
const base = switch (
|
|
935
|
+
comptime requireVariant(attrExprVariant(node, entries, "issue-link-base", raw), &.{.string}, node, markup.markdown_issue_link_base_message);
|
|
936
|
+
const base = switch (attrExprValue(node, entries, "issue-link-base", raw, ui, model, scope)) {
|
|
791
937
|
.string => |text| text,
|
|
792
938
|
else => runtimeFail([]const u8, ui),
|
|
793
939
|
};
|
|
@@ -887,7 +1033,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
887
1033
|
options.grow = floatAttr(node, entries, comptime node.attr("grow").?, ui, model, scope);
|
|
888
1034
|
}
|
|
889
1035
|
if (comptime (node.attr("label") != null)) {
|
|
890
|
-
options.semantics.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1036
|
+
options.semantics.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
891
1037
|
}
|
|
892
1038
|
if (comptime (node.attr("key") != null)) {
|
|
893
1039
|
options.key = attrKey(node, entries, comptime node.attr("key").?, ui, model, scope, "keys must be integers or strings");
|
|
@@ -928,7 +1074,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
928
1074
|
const expression = markup.parseMessageExpression(raw) orelse fail(node, markup.markdown_on_details_message);
|
|
929
1075
|
if (expression.payload.len != 0) fail(node, markup.markdown_on_details_message);
|
|
930
1076
|
for (@typeInfo(MsgT).@"union".fields) |field| {
|
|
931
|
-
if (field.type == usize and std.mem.eql(u8, field.name, expression.tag)) {
|
|
1077
|
+
if ((field.type == usize or field.type == i64) and std.mem.eql(u8, field.name, expression.tag)) {
|
|
932
1078
|
return Md.detailsMsg(@field(std.meta.Tag(MsgT), field.name));
|
|
933
1079
|
}
|
|
934
1080
|
}
|
|
@@ -974,17 +1120,23 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
974
1120
|
if (comptime (scope_index_opt != null)) {
|
|
975
1121
|
const scope_index = comptime scope_index_opt.?;
|
|
976
1122
|
comptime {
|
|
977
|
-
if (entries[scope_index].kind != .slice_arg or entries[scope_index].Item
|
|
1123
|
+
if (entries[scope_index].kind != .slice_arg or !reflect.isMarkdownImageItem(entries[scope_index].Item)) {
|
|
978
1124
|
fail(node, markup.markdown_images_message);
|
|
979
1125
|
}
|
|
980
1126
|
}
|
|
981
|
-
return scopePayload(entries, scope_index, scope)
|
|
1127
|
+
return @import("markdown_image_binding.zig").convert(ui.arena, scopePayload(entries, scope_index, scope)) catch {
|
|
1128
|
+
ui.failed = true;
|
|
1129
|
+
return &.{};
|
|
1130
|
+
};
|
|
982
1131
|
}
|
|
983
1132
|
const info = comptime (eachInfo(path) orelse fail(node, markup.markdown_images_message));
|
|
984
1133
|
comptime {
|
|
985
|
-
if (info.Item
|
|
1134
|
+
if (!reflect.isMarkdownImageItem(info.Item)) fail(node, markup.markdown_images_message);
|
|
986
1135
|
}
|
|
987
|
-
return eachItems(info, ui, model)
|
|
1136
|
+
return @import("markdown_image_binding.zig").convert(ui.arena, eachItems(info, ui, model)) catch {
|
|
1137
|
+
ui.failed = true;
|
|
1138
|
+
return &.{};
|
|
1139
|
+
};
|
|
988
1140
|
}
|
|
989
1141
|
|
|
990
1142
|
// ------------------------------------------------ stepper/timeline
|
|
@@ -1005,6 +1157,10 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1005
1157
|
}
|
|
1006
1158
|
if (node.attr("active") == null) fail(node, markup.stepper_active_message);
|
|
1007
1159
|
for (node.children) |child| {
|
|
1160
|
+
if (child.kind == .slot_block) {
|
|
1161
|
+
if (node.children.len != 1) fail(child, markup.stepper_children_message);
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1008
1164
|
if (child.kind != .element or !std.mem.eql(u8, child.name, "step")) {
|
|
1009
1165
|
fail(child, markup.stepper_children_message);
|
|
1010
1166
|
}
|
|
@@ -1027,14 +1183,34 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1027
1183
|
options.global_key = attrKey(node, entries, comptime node.attr("global-key").?, ui, model, scope, "keys must be integers or strings");
|
|
1028
1184
|
}
|
|
1029
1185
|
if (comptime (node.attr("label") != null)) {
|
|
1030
|
-
options.semantics.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1186
|
+
options.semantics.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1187
|
+
}
|
|
1188
|
+
const slot_index: ?usize = comptime if (node.children.len == 1 and node.children[0].kind == .slot_block) innermostSlotIndex(entries) else null;
|
|
1189
|
+
if (comptime (node.children.len == 1 and node.children[0].kind == .slot_block and slot_index == null)) {
|
|
1190
|
+
comptime fail(node.children[0], markup.slot_outside_template_message);
|
|
1031
1191
|
}
|
|
1032
|
-
const
|
|
1192
|
+
const step_nodes = comptime if (slot_index) |index| entries[index].slot_nodes else node.children;
|
|
1193
|
+
const steps = ui.arena.alloc(Ui.StepperStep, step_nodes.len) catch {
|
|
1033
1194
|
ui.failed = true;
|
|
1034
1195
|
return ui.el(.row, .{}, .{});
|
|
1035
1196
|
};
|
|
1036
|
-
|
|
1037
|
-
|
|
1197
|
+
if (comptime (slot_index != null)) {
|
|
1198
|
+
const index = comptime slot_index.?;
|
|
1199
|
+
const site_scope = scopePayload(entries, index, scope);
|
|
1200
|
+
inline for (0..step_nodes.len) |step_index| {
|
|
1201
|
+
const child = comptime step_nodes[step_index];
|
|
1202
|
+
if (comptime (child.kind != .element or !std.mem.eql(u8, child.name, "step"))) fail(child, markup.stepper_children_message);
|
|
1203
|
+
comptime {
|
|
1204
|
+
for (child.attrs) |attribute| {
|
|
1205
|
+
if (!std.mem.eql(u8, attribute.name, "kind")) fail(child, markup.step_attr_message);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
steps[step_index] = .{ .label = interpolatedText(child, comptime entries[index].slot_entries, ui, model, site_scope) };
|
|
1209
|
+
}
|
|
1210
|
+
} else {
|
|
1211
|
+
inline for (0..step_nodes.len) |index| {
|
|
1212
|
+
steps[index] = .{ .label = interpolatedText(comptime step_nodes[index], entries, ui, model, scope) };
|
|
1213
|
+
}
|
|
1038
1214
|
}
|
|
1039
1215
|
return ui.stepper(options, steps);
|
|
1040
1216
|
}
|
|
@@ -1079,7 +1255,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1079
1255
|
}
|
|
1080
1256
|
var options: Ui.InputGroupOptions = .{};
|
|
1081
1257
|
if (comptime (node.attr("label") != null)) {
|
|
1082
|
-
options.semantics.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1258
|
+
options.semantics.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1083
1259
|
}
|
|
1084
1260
|
if (comptime (node.attr("width") != null)) {
|
|
1085
1261
|
options.width = floatAttr(node, entries, comptime node.attr("width").?, ui, model, scope);
|
|
@@ -1163,7 +1339,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1163
1339
|
options.global_key = attrKey(node, entries, comptime node.attr("global-key").?, ui, model, scope, "keys must be integers or strings");
|
|
1164
1340
|
}
|
|
1165
1341
|
if (comptime (node.attr("label") != null)) {
|
|
1166
|
-
options.semantics.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1342
|
+
options.semantics.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1167
1343
|
}
|
|
1168
1344
|
var children: std.ArrayListUnmanaged(Ui.Node) = .empty;
|
|
1169
1345
|
buildChildren(node, entries, ui, model, scope, &children);
|
|
@@ -1171,7 +1347,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1171
1347
|
}
|
|
1172
1348
|
|
|
1173
1349
|
/// Comptime mirror of the interpreter's `buildTimelineItem`.
|
|
1174
|
-
fn buildTimelineItem(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype) Ui.Node {
|
|
1350
|
+
fn buildTimelineItem(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, forwarded_press: ?MsgT) Ui.Node {
|
|
1175
1351
|
comptime {
|
|
1176
1352
|
if (node.children.len != 0) fail(node.children[0], markup.timeline_item_children_message);
|
|
1177
1353
|
if (node.attr("title") == null) fail(node, markup.timeline_item_title_message);
|
|
@@ -1193,22 +1369,22 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1193
1369
|
}
|
|
1194
1370
|
}
|
|
1195
1371
|
var options: Ui.TimelineItemOptions = .{ .title = "" };
|
|
1196
|
-
options.title = stringAttr(node, entries, comptime node.attr("title").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1372
|
+
options.title = stringAttr(node, entries, "title", comptime node.attr("title").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1197
1373
|
if (comptime (node.attr("description") != null)) {
|
|
1198
|
-
options.description = stringAttr(node, entries, comptime node.attr("description").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1374
|
+
options.description = stringAttr(node, entries, "description", comptime node.attr("description").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1199
1375
|
}
|
|
1200
1376
|
if (comptime (node.attr("meta") != null)) {
|
|
1201
|
-
options.meta = stringAttr(node, entries, comptime node.attr("meta").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1377
|
+
options.meta = stringAttr(node, entries, "meta", comptime node.attr("meta").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1202
1378
|
}
|
|
1203
1379
|
if (comptime (node.attr("indicator") != null)) {
|
|
1204
|
-
options.indicator = stringAttr(node, entries, comptime node.attr("indicator").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1380
|
+
options.indicator = stringAttr(node, entries, "indicator", comptime node.attr("indicator").?, ui, model, scope, markup.timeline_item_text_attr_message);
|
|
1205
1381
|
}
|
|
1206
1382
|
if (comptime (node.attr("icon") != null)) {
|
|
1207
1383
|
// Vector icon indicator: the shared icon value grammar,
|
|
1208
1384
|
// resolved at comptime like every icon attribute.
|
|
1209
1385
|
switch (comptime iconValueChecked(node, node.attr("icon").?, markup.button_icon_message)) {
|
|
1210
1386
|
.builtin, .app => |name| options.icon = name,
|
|
1211
|
-
.binding => options.icon = stringAttr(node, entries, comptime node.attr("icon").?, ui, model, scope, markup.button_icon_message),
|
|
1387
|
+
.binding => options.icon = stringAttr(node, entries, "icon", comptime node.attr("icon").?, ui, model, scope, markup.button_icon_message),
|
|
1212
1388
|
.invalid => unreachable,
|
|
1213
1389
|
}
|
|
1214
1390
|
}
|
|
@@ -1251,6 +1427,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1251
1427
|
if (comptime (node.attr("global-key") != null)) {
|
|
1252
1428
|
options.global_key = attrKey(node, entries, comptime node.attr("global-key").?, ui, model, scope, "keys must be integers or strings");
|
|
1253
1429
|
}
|
|
1430
|
+
if (forwarded_press) |msg| options.on_press = msg;
|
|
1254
1431
|
return ui.timelineItem(options);
|
|
1255
1432
|
}
|
|
1256
1433
|
|
|
@@ -1341,7 +1518,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1341
1518
|
options.global_key = attrKey(node, entries, comptime node.attr("global-key").?, ui, model, scope, "keys must be integers or strings");
|
|
1342
1519
|
}
|
|
1343
1520
|
if (comptime (node.attr("label") != null)) {
|
|
1344
|
-
options.semantics.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1521
|
+
options.semantics.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1345
1522
|
}
|
|
1346
1523
|
const series = ui.arena.alloc(canvas.ChartSeries, node.children.len) catch {
|
|
1347
1524
|
ui.failed = true;
|
|
@@ -1397,7 +1574,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1397
1574
|
};
|
|
1398
1575
|
}
|
|
1399
1576
|
if (comptime (node.attr("label") != null)) {
|
|
1400
|
-
series.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, markup.series_label_message);
|
|
1577
|
+
series.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, markup.series_label_message);
|
|
1401
1578
|
}
|
|
1402
1579
|
return series;
|
|
1403
1580
|
}
|
|
@@ -1426,7 +1603,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1426
1603
|
}
|
|
1427
1604
|
var options: Ui.VideoOptions = .{};
|
|
1428
1605
|
if (comptime (node.attr("src") != null)) {
|
|
1429
|
-
options.src = stringAttr(node, entries, comptime node.attr("src").?, ui, model, scope, markup.video_src_message);
|
|
1606
|
+
options.src = stringAttr(node, entries, "src", comptime node.attr("src").?, ui, model, scope, markup.video_src_message);
|
|
1430
1607
|
}
|
|
1431
1608
|
if (comptime (node.attr("controls") != null)) {
|
|
1432
1609
|
options.controls = videoFlagValue(node, entries, comptime node.attr("controls").?, ui, model, scope);
|
|
@@ -1450,7 +1627,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1450
1627
|
options.grow = floatAttr(node, entries, comptime node.attr("grow").?, ui, model, scope);
|
|
1451
1628
|
}
|
|
1452
1629
|
if (comptime (node.attr("label") != null)) {
|
|
1453
|
-
options.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1630
|
+
options.label = stringAttr(node, entries, "label", comptime node.attr("label").?, ui, model, scope, "label expects text");
|
|
1454
1631
|
}
|
|
1455
1632
|
if (comptime (node.attr("key") != null)) {
|
|
1456
1633
|
options.key = attrKey(node, entries, comptime node.attr("key").?, ui, model, scope, "keys must be integers or strings");
|
|
@@ -1551,9 +1728,9 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1551
1728
|
}
|
|
1552
1729
|
}
|
|
1553
1730
|
|
|
1554
|
-
fn stringAttr(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype, comptime message: []const u8) []const u8 {
|
|
1555
|
-
comptime requireVariant(
|
|
1556
|
-
return switch (
|
|
1731
|
+
fn stringAttr(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime attribute_name: []const u8, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype, comptime message: []const u8) []const u8 {
|
|
1732
|
+
comptime requireVariant(attrExprVariant(node, entries, attribute_name, raw), &.{.string}, node, message);
|
|
1733
|
+
return switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
1557
1734
|
.string => |text| text,
|
|
1558
1735
|
else => runtimeFail([]const u8, ui),
|
|
1559
1736
|
};
|
|
@@ -1588,7 +1765,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1588
1765
|
/// parsed as an expression.
|
|
1589
1766
|
defaulted: bool = false,
|
|
1590
1767
|
|
|
1591
|
-
const Kind = enum { value, slice };
|
|
1768
|
+
const Kind = enum { value, slice, virtual };
|
|
1592
1769
|
};
|
|
1593
1770
|
|
|
1594
1771
|
/// Expand a `<use>` site: resolve the template, check its declared
|
|
@@ -1623,7 +1800,13 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1623
1800
|
.parent = buildArgScope(specs, entries, node, ui, model, scope),
|
|
1624
1801
|
.item = scope,
|
|
1625
1802
|
};
|
|
1626
|
-
|
|
1803
|
+
const forwarded_press: ?MsgT = if (comptime (node.attr("on-press") != null)) blk: {
|
|
1804
|
+
const press_attr = comptime node.attrEntry("on-press").?;
|
|
1805
|
+
var scratch: Ui.ElementOptions = .{};
|
|
1806
|
+
applyMessageAttr(node, press_attr, entries, ui, model, scope, &scratch);
|
|
1807
|
+
break :blk scratch.on_press;
|
|
1808
|
+
} else null;
|
|
1809
|
+
return buildElementWithForwardedPress(comptime template_node.children[0], body_entries, ui, model, body_scope, forwarded_press);
|
|
1627
1810
|
}
|
|
1628
1811
|
|
|
1629
1812
|
fn useArgSpecs(comptime node: markup.MarkupNode, comptime template_node: markup.MarkupNode, comptime site_entries: []const ScopeEntry) []const ArgSpec {
|
|
@@ -1631,6 +1814,10 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1631
1814
|
@setEvalBranchQuota(10_000);
|
|
1632
1815
|
for (node.attrs) |attribute| {
|
|
1633
1816
|
if (std.mem.eql(u8, attribute.name, "template")) continue;
|
|
1817
|
+
if (std.mem.eql(u8, attribute.name, "on-press")) continue;
|
|
1818
|
+
if (std.mem.startsWith(u8, attribute.name, "on-")) {
|
|
1819
|
+
fail(node, markup.use_forwarded_event_message);
|
|
1820
|
+
}
|
|
1634
1821
|
if (!markup.templateDeclaresArg(template_node, attribute.name)) {
|
|
1635
1822
|
fail(node, markup.use_extra_arg_message);
|
|
1636
1823
|
}
|
|
@@ -1686,6 +1873,9 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1686
1873
|
const path = expression.binding;
|
|
1687
1874
|
const head = interpreter.pathHead(path);
|
|
1688
1875
|
if (scopeIndex(site_entries, head)) |index| {
|
|
1876
|
+
if (site_entries[index].kind == .virtual and interpreter.pathTail(path) == null) {
|
|
1877
|
+
return .{ .name = arg_name, .raw = raw, .kind = .virtual, .site_index = index };
|
|
1878
|
+
}
|
|
1689
1879
|
if (site_entries[index].kind == .slice_arg and interpreter.pathTail(path) == null) {
|
|
1690
1880
|
return .{ .name = arg_name, .raw = raw, .kind = .slice, .Item = site_entries[index].Item, .site_index = index };
|
|
1691
1881
|
}
|
|
@@ -1707,8 +1897,9 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1707
1897
|
var entries: []const ScopeEntry = &.{};
|
|
1708
1898
|
for (specs) |spec| {
|
|
1709
1899
|
entries = entries ++ &[_]ScopeEntry{switch (spec.kind) {
|
|
1710
|
-
.value => .{ .name = spec.name, .kind = .value_arg, .variant = spec.variant },
|
|
1900
|
+
.value => .{ .name = spec.name, .kind = .value_arg, .variant = spec.variant, .defaulted = spec.defaulted },
|
|
1711
1901
|
.slice => .{ .name = spec.name, .kind = .slice_arg, .Item = spec.Item },
|
|
1902
|
+
.virtual => .{ .name = spec.name, .kind = .virtual, .Item = canvas.VirtualListRange },
|
|
1712
1903
|
}};
|
|
1713
1904
|
}
|
|
1714
1905
|
return entries;
|
|
@@ -1719,6 +1910,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1719
1910
|
return switch (spec.kind) {
|
|
1720
1911
|
.value => Value,
|
|
1721
1912
|
.slice => []const spec.Item,
|
|
1913
|
+
.virtual => VirtualBinding,
|
|
1722
1914
|
};
|
|
1723
1915
|
}
|
|
1724
1916
|
|
|
@@ -1742,7 +1934,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1742
1934
|
}
|
|
1743
1935
|
|
|
1744
1936
|
fn argPayloadValue(comptime spec: ArgSpec, comptime site_entries: []const ScopeEntry, comptime node: markup.MarkupNode, ui: *Ui, model: *const ModelT, site_scope: anytype) ArgPayload(spec) {
|
|
1745
|
-
if (comptime (spec.kind == .slice)) {
|
|
1937
|
+
if (comptime (spec.kind == .slice or spec.kind == .virtual)) {
|
|
1746
1938
|
if (comptime (spec.site_index != null)) {
|
|
1747
1939
|
return scopePayload(site_entries, comptime spec.site_index.?, site_scope);
|
|
1748
1940
|
}
|
|
@@ -1814,7 +2006,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1814
2006
|
const Leaf = comptime (OnType(Item, field_path, false) orelse fail(node, "key does not name a field on the item"));
|
|
1815
2007
|
comptime requireVariant(bindingVariant(Leaf), &.{ .integer, .string }, node, "key fields must be integers or strings");
|
|
1816
2008
|
const value = interpreter.valueOf(Leaf, valueOn(Item, field_path, item, ui.arena)) orelse unreachable;
|
|
1817
|
-
return uiKeyFromValue(value
|
|
2009
|
+
return uiKeyFromValue(value);
|
|
1818
2010
|
}
|
|
1819
2011
|
|
|
1820
2012
|
// ---------------------------------------------------- attributes
|
|
@@ -1831,11 +2023,17 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1831
2023
|
options.key = attrKey(node, entries, attribute.value, ui, model, scope, "keys must be integers or strings");
|
|
1832
2024
|
} else if (comptime std.mem.eql(u8, attribute.name, "global-key")) {
|
|
1833
2025
|
options.global_key = attrKey(node, entries, attribute.value, ui, model, scope, "keys must be integers or strings");
|
|
2026
|
+
} else if (comptime std.mem.eql(u8, attribute.name, "focusable")) {
|
|
2027
|
+
comptime requireVariant(attrExprVariant(node, entries, attribute.name, attribute.value), &.{.boolean}, node, "focusable expects a boolean");
|
|
2028
|
+
options.semantics.focusable = switch (attrExprValue(node, entries, attribute.name, attribute.value, ui, model, scope)) {
|
|
2029
|
+
.boolean => |flag| flag,
|
|
2030
|
+
else => runtimeFail(bool, ui),
|
|
2031
|
+
};
|
|
1834
2032
|
} else if (comptime std.mem.eql(u8, attribute.name, "role")) {
|
|
1835
2033
|
options.semantics.role = roleValue(node, entries, attribute.value, ui, model, scope);
|
|
1836
2034
|
} else if (comptime std.mem.eql(u8, attribute.name, "label")) {
|
|
1837
|
-
comptime requireVariant(
|
|
1838
|
-
options.semantics.label = switch (
|
|
2035
|
+
comptime requireVariant(attrExprVariant(node, entries, attribute.name, attribute.value), &.{.string}, node, "label expects text");
|
|
2036
|
+
options.semantics.label = switch (attrExprValue(node, entries, attribute.name, attribute.value, ui, model, scope)) {
|
|
1839
2037
|
.string => |text| text,
|
|
1840
2038
|
else => runtimeFail([]const u8, ui),
|
|
1841
2039
|
};
|
|
@@ -1876,7 +2074,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1876
2074
|
comptime if (!markup.iconAttrElement(node.name)) fail(node, markup.button_icon_element_message);
|
|
1877
2075
|
switch (comptime iconValueChecked(node, attribute.value, markup.button_icon_message)) {
|
|
1878
2076
|
.builtin, .app => |name| options.icon = name,
|
|
1879
|
-
.binding => options.icon = stringAttr(node, entries, attribute.value, ui, model, scope, markup.button_icon_message),
|
|
2077
|
+
.binding => options.icon = stringAttr(node, entries, attribute.name, attribute.value, ui, model, scope, markup.button_icon_message),
|
|
1880
2078
|
.invalid => unreachable,
|
|
1881
2079
|
}
|
|
1882
2080
|
} else if (comptime std.mem.eql(u8, attribute.name, "anchor")) {
|
|
@@ -1919,7 +2117,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1919
2117
|
} else if (comptime std.mem.eql(u8, attribute.name, "radius")) {
|
|
1920
2118
|
options.style_tokens.radius = comptime radiusTokenRef(node, attribute.value);
|
|
1921
2119
|
} else {
|
|
1922
|
-
setOption(node, comptime optionFieldName(node, attribute.name), attribute.value, entries, ui, model, scope, options);
|
|
2120
|
+
setOption(node, comptime optionFieldName(node, attribute.name), attribute.name, attribute.value, entries, ui, model, scope, options);
|
|
1923
2121
|
}
|
|
1924
2122
|
}
|
|
1925
2123
|
}
|
|
@@ -2012,14 +2210,15 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2012
2210
|
if (expression != .binding) fail(node, markup.terminal_pty_message);
|
|
2013
2211
|
}
|
|
2014
2212
|
const path = comptime markup.parseAttrExpression(raw).?.binding;
|
|
2015
|
-
comptime requireVariant(pathVariant(node, entries, path, true), &.{.integer}, node, markup.terminal_pty_message);
|
|
2213
|
+
comptime requireVariant(pathVariant(node, entries, path, true), &.{ .integer, .string }, node, markup.terminal_pty_message);
|
|
2016
2214
|
// Range-checked before the u64 cast (the interpreter fails
|
|
2017
2215
|
// the same way): a signed model field can deliver a negative
|
|
2018
2216
|
// — fail the build, never trap.
|
|
2019
|
-
|
|
2020
|
-
.integer => |int| if (int < 0) runtimeFail(u64, ui) else @intCast(int),
|
|
2021
|
-
|
|
2022
|
-
|
|
2217
|
+
switch (bindingValue(node, entries, path, ui, model, scope, true)) {
|
|
2218
|
+
.integer => |int| options.pty = if (int < 0) runtimeFail(u64, ui) else @intCast(int),
|
|
2219
|
+
.string => |name| options.pty_name = name,
|
|
2220
|
+
else => options.pty = runtimeFail(u64, ui),
|
|
2221
|
+
}
|
|
2023
2222
|
}
|
|
2024
2223
|
|
|
2025
2224
|
fn colorStyleField(comptime attr_name: []const u8) ?[]const u8 {
|
|
@@ -2064,24 +2263,37 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2064
2263
|
}
|
|
2065
2264
|
}
|
|
2066
2265
|
|
|
2067
|
-
fn setOption(comptime node: markup.MarkupNode, comptime zig_field: []const u8, comptime raw: []const u8, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, options: *Ui.ElementOptions) void {
|
|
2266
|
+
fn setOption(comptime node: markup.MarkupNode, comptime zig_field: []const u8, comptime attribute_name: []const u8, comptime raw: []const u8, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, options: *Ui.ElementOptions) void {
|
|
2068
2267
|
const FieldType = @FieldType(Ui.ElementOptions, zig_field);
|
|
2069
|
-
const variant = comptime
|
|
2268
|
+
const variant = comptime attrExprVariant(node, entries, attribute_name, raw);
|
|
2070
2269
|
switch (comptime @typeInfo(FieldType)) {
|
|
2071
2270
|
.float => {
|
|
2072
2271
|
comptime requireVariant(variant, &.{ .float, .integer }, node, "expected a number");
|
|
2073
|
-
@field(options, zig_field) = switch (
|
|
2272
|
+
@field(options, zig_field) = switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
2074
2273
|
.float => |float| float,
|
|
2075
2274
|
.integer => |int| @floatFromInt(int),
|
|
2076
2275
|
else => runtimeFail(FieldType, ui),
|
|
2077
2276
|
};
|
|
2078
2277
|
},
|
|
2079
|
-
.bool => @field(options, zig_field) =
|
|
2278
|
+
.bool => @field(options, zig_field) = attrExprValue(node, entries, attribute_name, raw, ui, model, scope).truthy(),
|
|
2080
2279
|
.optional => |optional| switch (@typeInfo(optional.child)) {
|
|
2081
|
-
.bool => @field(options, zig_field) =
|
|
2280
|
+
.bool => @field(options, zig_field) = attrExprValue(node, entries, attribute_name, raw, ui, model, scope).truthy(),
|
|
2281
|
+
.@"enum" => {
|
|
2282
|
+
comptime requireVariant(variant, &.{.string}, node, "expected an option name");
|
|
2283
|
+
const expression = comptime markup.parseAttrExpression(raw).?;
|
|
2284
|
+
if (comptime expression == .literal) {
|
|
2285
|
+
@field(options, zig_field) = comptime (std.meta.stringToEnum(optional.child, expression.literal) orelse fail(node, "unknown option value"));
|
|
2286
|
+
} else {
|
|
2287
|
+
const text = switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
2288
|
+
.string => |text| text,
|
|
2289
|
+
else => runtimeFail([]const u8, ui),
|
|
2290
|
+
};
|
|
2291
|
+
@field(options, zig_field) = std.meta.stringToEnum(optional.child, text) orelse runtimeFail(optional.child, ui);
|
|
2292
|
+
}
|
|
2293
|
+
},
|
|
2082
2294
|
.float => {
|
|
2083
2295
|
comptime requireVariant(variant, &.{ .float, .integer }, node, "expected a number");
|
|
2084
|
-
@field(options, zig_field) = switch (
|
|
2296
|
+
@field(options, zig_field) = switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
2085
2297
|
.float => |float| float,
|
|
2086
2298
|
.integer => |int| @floatFromInt(int),
|
|
2087
2299
|
else => runtimeFail(optional.child, ui),
|
|
@@ -2099,7 +2311,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2099
2311
|
// @intCast TRAPPED on it instead of failing the
|
|
2100
2312
|
// build. The field type is the honest upper bound;
|
|
2101
2313
|
// no semantic cap is invented on top of it.
|
|
2102
|
-
@field(options, zig_field) = switch (
|
|
2314
|
+
@field(options, zig_field) = switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
2103
2315
|
.integer => |int| if (int < 0 or int > std.math.maxInt(FieldType)) runtimeFail(FieldType, ui) else @intCast(int),
|
|
2104
2316
|
else => runtimeFail(FieldType, ui),
|
|
2105
2317
|
};
|
|
@@ -2112,7 +2324,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2112
2324
|
// is a compile error, not a failed rebuild.
|
|
2113
2325
|
@field(options, zig_field) = comptime (std.meta.stringToEnum(FieldType, expression.literal) orelse fail(node, "unknown option value"));
|
|
2114
2326
|
} else {
|
|
2115
|
-
const text = switch (
|
|
2327
|
+
const text = switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
2116
2328
|
.string => |text| text,
|
|
2117
2329
|
else => runtimeFail([]const u8, ui),
|
|
2118
2330
|
};
|
|
@@ -2121,7 +2333,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2121
2333
|
},
|
|
2122
2334
|
.pointer => {
|
|
2123
2335
|
comptime requireVariant(variant, &.{.string}, node, "expected text");
|
|
2124
|
-
@field(options, zig_field) = switch (
|
|
2336
|
+
@field(options, zig_field) = switch (attrExprValue(node, entries, attribute_name, raw, ui, model, scope)) {
|
|
2125
2337
|
.string => |text| text,
|
|
2126
2338
|
else => runtimeFail(FieldType, ui),
|
|
2127
2339
|
};
|
|
@@ -2130,21 +2342,39 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2130
2342
|
}
|
|
2131
2343
|
}
|
|
2132
2344
|
|
|
2133
|
-
fn attrKey(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype, comptime message: []const u8) canvas.UiKey {
|
|
2345
|
+
fn attrKey(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype, comptime message: []const u8) ?canvas.UiKey {
|
|
2134
2346
|
comptime requireVariant(exprVariant(node, entries, raw), &.{ .integer, .string }, node, message);
|
|
2135
|
-
|
|
2347
|
+
const omitted_default = comptime blk: {
|
|
2348
|
+
const expression = markup.parseAttrExpression(raw) orelse break :blk false;
|
|
2349
|
+
if (expression != .binding) break :blk false;
|
|
2350
|
+
const path = expression.binding;
|
|
2351
|
+
if (interpreter.pathTail(path) != null) break :blk false;
|
|
2352
|
+
const index = scopeIndex(entries, interpreter.pathHead(path)) orelse break :blk false;
|
|
2353
|
+
break :blk entries[index].defaulted;
|
|
2354
|
+
};
|
|
2355
|
+
return optionalUiKeyFromValue(evalExpr(node, entries, raw, ui, model, scope), ui, omitted_default);
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
fn uiKeyFromValue(value: Value) canvas.UiKey {
|
|
2359
|
+
return switch (value) {
|
|
2360
|
+
.integer => |int| canvas.uiKey(@as(u64, @bitCast(int))),
|
|
2361
|
+
.string => |text| canvas.uiKey(text),
|
|
2362
|
+
else => unreachable,
|
|
2363
|
+
};
|
|
2136
2364
|
}
|
|
2137
2365
|
|
|
2138
|
-
fn
|
|
2366
|
+
fn optionalUiKeyFromValue(value: Value, ui: *Ui, omitted_default: bool) ?canvas.UiKey {
|
|
2139
2367
|
return switch (value) {
|
|
2140
2368
|
// Keys are identity, not quantities: a negative integer
|
|
2141
2369
|
// id maps bijectively into the u64 key space (the
|
|
2142
2370
|
// interpreter's itemKey/attrKey rule), never a trap.
|
|
2143
2371
|
.integer => |int| canvas.uiKey(@as(u64, @bitCast(int))),
|
|
2144
|
-
|
|
2372
|
+
// Empty defaults are the template-language spelling for an
|
|
2373
|
+
// omitted optional key; preserve unkeyed structural identity.
|
|
2374
|
+
.string => |text| if (text.len == 0 and omitted_default) null else canvas.uiKey(text),
|
|
2145
2375
|
else => blk: {
|
|
2146
2376
|
ui.failed = true;
|
|
2147
|
-
break :blk
|
|
2377
|
+
break :blk null;
|
|
2148
2378
|
},
|
|
2149
2379
|
};
|
|
2150
2380
|
}
|
|
@@ -2243,6 +2473,8 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2243
2473
|
options.on_hover_enter = msg;
|
|
2244
2474
|
} else if (comptime std.mem.eql(u8, event, "hover-leave")) {
|
|
2245
2475
|
options.on_hover_leave = msg;
|
|
2476
|
+
} else if (comptime std.mem.eql(u8, event, "reach-start") and std.mem.eql(u8, node.name, "scroll")) {
|
|
2477
|
+
options.on_reach_start = msg;
|
|
2246
2478
|
} else if (comptime std.mem.eql(u8, event, "reach-end")) {
|
|
2247
2479
|
// The approach-end signal (infinite-scroll fetch) is
|
|
2248
2480
|
// emitted for scroll containers only (interpreter and
|
|
@@ -2456,6 +2688,14 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2456
2688
|
|
|
2457
2689
|
const invalid_expression_message = markup.invalid_expression_message;
|
|
2458
2690
|
|
|
2691
|
+
fn attrExprValue(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime attribute_name: []const u8, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype) Value {
|
|
2692
|
+
const expression = comptime (markup.parseAttrExpression(raw) orelse fail(node, invalid_expression_message));
|
|
2693
|
+
if (comptime (expression == .literal)) {
|
|
2694
|
+
return comptime interpreter.literalValueForAttribute(expression.literal, attribute_name);
|
|
2695
|
+
}
|
|
2696
|
+
return evalExpr(node, entries, raw, ui, model, scope);
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2459
2699
|
fn evalExpr(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype) Value {
|
|
2460
2700
|
const expression = comptime (markup.parseAttrExpression(raw) orelse fail(node, invalid_expression_message));
|
|
2461
2701
|
if (comptime (expression == .literal)) {
|
|
@@ -2583,6 +2823,21 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2583
2823
|
}
|
|
2584
2824
|
}
|
|
2585
2825
|
|
|
2826
|
+
fn attrExprVariant(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime attribute_name: []const u8, comptime raw: []const u8) ?ValueVariant {
|
|
2827
|
+
comptime {
|
|
2828
|
+
const expression = markup.parseAttrExpression(raw) orelse fail(node, invalid_expression_message);
|
|
2829
|
+
if (expression == .literal) {
|
|
2830
|
+
return switch (interpreter.literalValueForAttribute(expression.literal, attribute_name)) {
|
|
2831
|
+
.string => .string,
|
|
2832
|
+
.integer => .integer,
|
|
2833
|
+
.float => .float,
|
|
2834
|
+
.boolean => .boolean,
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
return exprVariant(node, entries, raw);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2586
2841
|
/// Innermost scope entry whose name matches `head`.
|
|
2587
2842
|
fn scopeIndex(comptime entries: []const ScopeEntry, comptime head: []const u8) ?usize {
|
|
2588
2843
|
comptime {
|
|
@@ -2671,6 +2926,10 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2671
2926
|
}
|
|
2672
2927
|
const Leaf = comptime BindingLeaf(node, entries, path, allow_arena);
|
|
2673
2928
|
const item = scopePayload(entries, index, scope);
|
|
2929
|
+
if (comptime entry.kind == .virtual) {
|
|
2930
|
+
const tail = comptime interpreter.pathTail(path).?;
|
|
2931
|
+
return interpreter.valueOf(Leaf, valueOn(canvas.VirtualListRange, tail, &item.range, ui.arena)) orelse unreachable;
|
|
2932
|
+
}
|
|
2674
2933
|
if (comptime (interpreter.pathTail(path) != null)) {
|
|
2675
2934
|
const tail = comptime interpreter.pathTail(path).?;
|
|
2676
2935
|
return interpreter.valueOf(Leaf, valueOn(entry.Item, tail, item, ui.arena)) orelse unreachable;
|
|
@@ -3000,6 +3259,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
3000
3259
|
.bool => false,
|
|
3001
3260
|
.@"enum" => |info| @field(T, info.fields[0].name),
|
|
3002
3261
|
.pointer => "",
|
|
3262
|
+
.@"struct" => if (T == Ui.Node) .{} else comptime @compileError("no placeholder for " ++ @typeName(T)),
|
|
3003
3263
|
else => comptime @compileError("no placeholder for " ++ @typeName(T)),
|
|
3004
3264
|
};
|
|
3005
3265
|
}
|