@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
package/src/root.zig
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const builtin = @import("builtin");
|
|
2
|
+
|
|
1
3
|
pub const geometry = @import("geometry");
|
|
2
4
|
pub const assets = @import("assets");
|
|
3
5
|
pub const app_dirs = @import("app_dirs");
|
|
@@ -24,6 +26,16 @@ pub const security = @import("security/root.zig");
|
|
|
24
26
|
pub const updater = @import("updater/root.zig");
|
|
25
27
|
pub const update_check_command = platform.update_check_command;
|
|
26
28
|
|
|
29
|
+
// App test and model-contract binaries can link the AppKit host without
|
|
30
|
+
// analyzing platform.macos. Keep its Zig C exports in every macOS SDK module
|
|
31
|
+
// so those binaries can resolve the host's updater calls too.
|
|
32
|
+
comptime {
|
|
33
|
+
if (builtin.os.tag == .macos) {
|
|
34
|
+
_ = updater.c_api.native_sdk_update_verify_feed;
|
|
35
|
+
_ = updater.c_api.native_sdk_update_verify_archive;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
pub const Runtime = runtime.Runtime;
|
|
28
40
|
pub const RuntimeOptions = runtime.Options;
|
|
29
41
|
pub const App = runtime.App;
|
|
@@ -33,6 +45,7 @@ pub const Command = runtime.Command;
|
|
|
33
45
|
pub const CommandEvent = runtime.CommandEvent;
|
|
34
46
|
pub const CommandSource = runtime.CommandSource;
|
|
35
47
|
pub const TestHarness = runtime.TestHarness;
|
|
48
|
+
pub const native_testing = @import("runtime/ts_test_host.zig");
|
|
36
49
|
pub const UiApp = runtime.UiApp;
|
|
37
50
|
pub const UiAppWithFeatures = runtime.UiAppWithFeatures;
|
|
38
51
|
pub const UiAppFeatures = runtime.UiAppFeatures;
|
|
@@ -139,6 +152,10 @@ pub const max_effect_image_source_bytes = runtime.max_effect_image_source_bytes;
|
|
|
139
152
|
pub const effect_image_blob_hash_len = runtime.effect_image_blob_hash_len;
|
|
140
153
|
pub const EffectChannelEvent = runtime.EffectChannelEvent;
|
|
141
154
|
pub const EffectChannelEventKind = runtime.EffectChannelEventKind;
|
|
155
|
+
pub const HostChannelSourceBinding = runtime.HostChannelSourceBinding;
|
|
156
|
+
pub const EffectChannelSourceState = runtime.EffectChannelSourceState;
|
|
157
|
+
pub const EffectChannelSourceResult = runtime.EffectChannelSourceResult;
|
|
158
|
+
pub const max_channel_source_payload = runtime.max_channel_source_payload;
|
|
142
159
|
pub const ChannelHandle = runtime.ChannelHandle;
|
|
143
160
|
pub const max_effect_channels = runtime.max_effect_channels;
|
|
144
161
|
pub const max_effect_channel_bytes = runtime.max_effect_channel_bytes;
|
|
@@ -160,7 +177,9 @@ pub const max_effect_host_name_bytes = runtime.max_effect_host_name_bytes;
|
|
|
160
177
|
pub const max_effect_host_payload_bytes = runtime.max_effect_host_payload_bytes;
|
|
161
178
|
pub const max_effect_host_result_bytes = runtime.max_effect_host_result_bytes;
|
|
162
179
|
pub const TsCoreHost = runtime.TsCoreHost;
|
|
180
|
+
pub const TsCoreHostWithRuntimeModel = runtime.TsCoreHostWithRuntimeModel;
|
|
163
181
|
pub const TsUiApp = runtime.TsUiApp;
|
|
182
|
+
pub const TsUiAppWithFeatures = runtime.TsUiAppWithFeatures;
|
|
164
183
|
pub const Clock = runtime.Clock;
|
|
165
184
|
pub const TestClock = runtime.TestClock;
|
|
166
185
|
pub const nowMs = runtime.nowMs;
|
|
@@ -169,6 +188,8 @@ pub const monotonicMs = runtime.monotonicMs;
|
|
|
169
188
|
pub const monotonicNanoseconds = runtime.monotonicNanoseconds;
|
|
170
189
|
pub const setFreestandingMonotonicNanoseconds = runtime.setFreestandingMonotonicNanoseconds;
|
|
171
190
|
pub const RegisteredImage = runtime.RegisteredImage;
|
|
191
|
+
pub const max_registered_canvas_fonts = runtime.max_registered_canvas_fonts;
|
|
192
|
+
pub const max_registered_canvas_font_bytes = runtime.max_registered_canvas_font_bytes;
|
|
172
193
|
pub const max_registered_canvas_images = runtime.max_registered_canvas_images;
|
|
173
194
|
pub const max_registered_canvas_image_pixel_bytes = runtime.max_registered_canvas_image_pixel_bytes;
|
|
174
195
|
pub const max_registered_canvas_image_pixel_bytes_ceiling = runtime.max_registered_canvas_image_pixel_bytes_ceiling;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//! Copied accessibility facts. Native owns borrowed strings, exact identities,
|
|
2
|
+
//! text history, fingerprints and OS publication; compiled code derives nodes.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const canvas = @import("canvas");
|
|
5
|
+
const platform = @import("../platform/root.zig");
|
|
6
|
+
const bridge = @import("widget_bridge.zig");
|
|
7
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
8
|
+
pub const Publication = enum { unchanged, deferred, publish };
|
|
9
|
+
const roles = [_]canvas.WidgetRole{ .none, .group, .text, .link, .image, .button, .textbox, .tooltip, .dialog, .menu, .menuitem, .list, .listitem, .row, .grid, .gridcell, .tab, .checkbox, .radio, .radiogroup, .switch_control, .slider, .progressbar, .chart, .tree, .treeitem, .separator };
|
|
10
|
+
const states = [_][]const u8{ "hovered", "pressed", "focused", "disabled", "selected", "required", "read_only", "invalid" };
|
|
11
|
+
comptime {
|
|
12
|
+
if (roles.len != @typeInfo(canvas.WidgetRole).@"enum".fields.len or platform.max_widget_accessibility_nodes != 64) @compileError("update accessibility packet limits");
|
|
13
|
+
}
|
|
14
|
+
fn roleCode(role: canvas.WidgetRole) u32 {
|
|
15
|
+
for (roles, 0..) |candidate, i| if (role == candidate) return @intCast(i);
|
|
16
|
+
unreachable;
|
|
17
|
+
}
|
|
18
|
+
fn word(bytes: []u8, at: usize, value: u32) void {
|
|
19
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
20
|
+
}
|
|
21
|
+
fn read(bytes: []const u8, at: usize) u32 {
|
|
22
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
23
|
+
}
|
|
24
|
+
fn identity(bytes: []u8, at: usize, value: u64) void {
|
|
25
|
+
std.mem.writeInt(u64, bytes[at..][0..8], value, .little);
|
|
26
|
+
}
|
|
27
|
+
fn run(policy: Policy, request: []const u8, output: []u8) void {
|
|
28
|
+
if (policy(request, output) != output.len) @panic("invalid compiled accessibility result size");
|
|
29
|
+
}
|
|
30
|
+
pub fn publication(policy: Policy, published: bool, previous: u64, next: u64, allow_deferral: bool, defer_live: bool) Publication {
|
|
31
|
+
var request: [20]u8 = @splat(0);
|
|
32
|
+
request[0..4].* = .{ 68, 1, @intFromBool(published), @as(u8, @intFromBool(allow_deferral)) | (@as(u8, @intFromBool(defer_live)) << 1) };
|
|
33
|
+
identity(&request, 4, next);
|
|
34
|
+
identity(&request, 12, previous);
|
|
35
|
+
var output: [4]u8 = undefined;
|
|
36
|
+
run(policy, &request, &output);
|
|
37
|
+
if (output[0] > 2 or !std.mem.eql(u8, output[1..], &.{ 0, 0, 0 })) @panic("invalid compiled accessibility publication");
|
|
38
|
+
return @enumFromInt(output[0]);
|
|
39
|
+
}
|
|
40
|
+
pub fn flush(policy: Policy, pending: bool, frame_requested: bool, force: bool) bool {
|
|
41
|
+
const request = [_]u8{ 68, 2, @intFromBool(pending), @as(u8, @intFromBool(frame_requested)) | (@as(u8, @intFromBool(force)) << 1) };
|
|
42
|
+
var output: [4]u8 = undefined;
|
|
43
|
+
run(policy, &request, &output);
|
|
44
|
+
if (output[0] > 1 or !std.mem.eql(u8, output[1..], &.{ 0, 0, 0 })) @panic("invalid compiled accessibility flush");
|
|
45
|
+
return output[0] == 1;
|
|
46
|
+
}
|
|
47
|
+
pub fn project(allocator: std.mem.Allocator, policy: Policy, semantics: []const canvas.WidgetSemanticsNode, keyboard_active: bool, focused: bool, focused_id: u64, hovered_id: u64, pressed_id: u64, output: []platform.WidgetAccessibilityNode) ![]platform.WidgetAccessibilityNode {
|
|
48
|
+
if (semantics.len > 1024 or output.len > platform.max_widget_accessibility_nodes) return error.InvalidViewOptions;
|
|
49
|
+
const request = try allocator.alloc(u8, 40 + semantics.len * 32);
|
|
50
|
+
defer allocator.free(request);
|
|
51
|
+
@memset(request, 0);
|
|
52
|
+
request[0..4].* = .{ 68, 0, @intFromBool(keyboard_active), @intFromBool(focused) };
|
|
53
|
+
word(request, 4, @intCast(semantics.len));
|
|
54
|
+
word(request, 8, @intCast(output.len));
|
|
55
|
+
identity(request, 16, focused_id);
|
|
56
|
+
identity(request, 24, hovered_id);
|
|
57
|
+
identity(request, 32, pressed_id);
|
|
58
|
+
for (semantics, 0..) |node, i| {
|
|
59
|
+
const at = 40 + i * 32;
|
|
60
|
+
identity(request, at, node.id);
|
|
61
|
+
word(request, at + 8, if (node.parent_index) |p| std.math.cast(u32, p) orelse std.math.maxInt(u32) else std.math.maxInt(u32));
|
|
62
|
+
word(request, at + 12, roleCode(node.role));
|
|
63
|
+
var state: u32 = 0;
|
|
64
|
+
inline for (states, 0..) |field, bit| if (@field(node.state, field)) {
|
|
65
|
+
state |= @as(u32, 1) << @intCast(bit);
|
|
66
|
+
};
|
|
67
|
+
word(request, at + 16, state);
|
|
68
|
+
const flags: u32 = @as(u32, @intFromBool(node.list.present)) | (@as(u32, @intFromBool(node.scroll.present)) << 1) | (@as(u32, @intFromBool(node.value != null)) << 2) | (@as(u32, @intFromBool(node.focusable)) << 3) | (@as(u32, @intFromBool(node.state.expanded != null)) << 4) | (@as(u32, @intFromBool(node.state.expanded orelse false)) << 5);
|
|
69
|
+
word(request, at + 20, flags);
|
|
70
|
+
word(request, at + 24, @bitCast(node.value orelse @as(f32, 0)));
|
|
71
|
+
var actions: u32 = 0;
|
|
72
|
+
inline for (@typeInfo(platform.WidgetAccessibilityActions).@"struct".fields, 0..) |field, bit| if (@field(node.actions, field.name)) {
|
|
73
|
+
actions |= @as(u32, 1) << @intCast(bit);
|
|
74
|
+
};
|
|
75
|
+
word(request, at + 28, actions);
|
|
76
|
+
}
|
|
77
|
+
const count = @min(output.len, semantics.len);
|
|
78
|
+
const result = try allocator.alloc(u8, 8 + count * 28);
|
|
79
|
+
defer allocator.free(result);
|
|
80
|
+
run(policy, request, result);
|
|
81
|
+
if (read(result, 0) != count or read(result, 4) != 0) @panic("invalid compiled accessibility node count");
|
|
82
|
+
for (output[0..count], semantics[0..count], 0..) |*target, node, i| {
|
|
83
|
+
const at = 8 + i * 28;
|
|
84
|
+
const flags = read(result, at + 16);
|
|
85
|
+
const present = read(result, at + 20);
|
|
86
|
+
const actions = read(result, at + 24);
|
|
87
|
+
if (read(result, at + 8) > 1 or flags > 2047 or present > 3 or actions > 2047) @panic("invalid compiled accessibility node flags");
|
|
88
|
+
target.* = .{
|
|
89
|
+
.id = node.id,
|
|
90
|
+
.parent_id = if (read(result, at + 8) == 1) std.mem.readInt(u64, result[at..][0..8], .little) else null,
|
|
91
|
+
.role = std.enums.fromInt(platform.WidgetAccessibilityRole, read(result, at + 12)) orelse @panic("invalid compiled accessibility role"),
|
|
92
|
+
.label = node.label,
|
|
93
|
+
.text_value = node.text_value,
|
|
94
|
+
.placeholder = node.placeholder,
|
|
95
|
+
.text_selection = bridge.platformWidgetAccessibilityTextRange(node.text_selection),
|
|
96
|
+
.text_composition = bridge.platformWidgetAccessibilityTextRange(node.text_composition),
|
|
97
|
+
.value = node.value,
|
|
98
|
+
.bounds = node.bounds,
|
|
99
|
+
.grid_row_index = node.grid_row_index,
|
|
100
|
+
.grid_column_index = node.grid_column_index,
|
|
101
|
+
.grid_row_count = node.grid_row_count,
|
|
102
|
+
.grid_column_count = node.grid_column_count,
|
|
103
|
+
.list_item_index = if (present & 1 != 0) node.list.item_index else null,
|
|
104
|
+
.list_item_count = if (present & 1 != 0) node.list.item_count else null,
|
|
105
|
+
.scroll_offset = if (present & 2 != 0) node.scroll.offset else null,
|
|
106
|
+
.scroll_viewport_extent = if (present & 2 != 0) node.scroll.viewport_extent else null,
|
|
107
|
+
.scroll_content_extent = if (present & 2 != 0) node.scroll.content_extent else null,
|
|
108
|
+
.enabled = flags & 1 != 0,
|
|
109
|
+
.focused = flags & 2 != 0,
|
|
110
|
+
.hovered = flags & 4 != 0,
|
|
111
|
+
.pressed = flags & 8 != 0,
|
|
112
|
+
.selected = flags & 16 != 0,
|
|
113
|
+
.required = flags & 32 != 0,
|
|
114
|
+
.read_only = flags & 64 != 0,
|
|
115
|
+
.invalid = flags & 128 != 0,
|
|
116
|
+
.expanded = if (flags & 256 != 0) flags & 512 != 0 else null,
|
|
117
|
+
.focusable = flags & 1024 != 0,
|
|
118
|
+
};
|
|
119
|
+
inline for (@typeInfo(platform.WidgetAccessibilityActions).@"struct".fields, 0..) |field, bit| @field(target.actions, field.name) = actions & (@as(u32, 1) << @intCast(bit)) != 0;
|
|
120
|
+
}
|
|
121
|
+
return output[0..count];
|
|
122
|
+
}
|
package/src/runtime/api.zig
CHANGED
|
@@ -425,6 +425,34 @@ pub fn App(comptime Runtime: type) type {
|
|
|
425
425
|
source: platform.WebViewSource = platform.WebViewSource.html(""),
|
|
426
426
|
source_fn: ?SourceFn = null,
|
|
427
427
|
scene_fn: ?SceneFn = null,
|
|
428
|
+
/// Portable shell frame planning. Results are copied into native
|
|
429
|
+
/// storage before any OS operation; the owning core cycle resets.
|
|
430
|
+
shell_layout_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
431
|
+
view_coordination_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
432
|
+
window_lifecycle_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
433
|
+
image_registry_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
434
|
+
font_registry_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
435
|
+
shell_coordination_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
436
|
+
shell_admission_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
437
|
+
system_admission_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
438
|
+
bridge_descriptor_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
439
|
+
authorization_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
440
|
+
builtin_coordination_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
441
|
+
automation_command_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
442
|
+
automation_interaction_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
443
|
+
snapshot_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
444
|
+
host_flow_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
445
|
+
/// Portable command routing and status-item selection. Native retains
|
|
446
|
+
/// registry bytes, exact handles and OS capability execution.
|
|
447
|
+
command_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
448
|
+
text_cache_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
449
|
+
render_cache_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
450
|
+
render_plan_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
451
|
+
render_override_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
452
|
+
replay_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
453
|
+
recording_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
454
|
+
blob_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
455
|
+
render_damage_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
428
456
|
start_fn: ?StartFn = null,
|
|
429
457
|
event_fn: ?EventFn = null,
|
|
430
458
|
stop_fn: ?StopFn = null,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//! Portable dispatch scheduling with copied plans and native-owned execution.
|
|
2
|
+
pub const Policy = ?*const fn ([]const u8, []u8) usize;
|
|
3
|
+
pub const Stage = enum(u8) { dispatch_begin, update, dispatch_render, drain_installed, drain_pending, drain_rebuild, video_rebuild, secondary, direct_tail, event_tail, error_selection };
|
|
4
|
+
pub const Action = enum(u8) { end, bind, sync, apply, audio, update_fx, update, relational_flush, main, pending_query, capture_drain, video_query, secondary, hover, take_error };
|
|
5
|
+
pub const Plan = [16]u8;
|
|
6
|
+
pub fn plan(policy: Policy, stage: Stage, a: u8, b: u8) Plan {
|
|
7
|
+
const request = [_]u8{ 19, @intFromEnum(stage), a, b, 0, 0 };
|
|
8
|
+
if (policy) |callback| {
|
|
9
|
+
var result: Plan = undefined;
|
|
10
|
+
if (callback(&request, &result) != result.len) @panic("invalid compiled app dispatch plan size");
|
|
11
|
+
const allowed: u16 = switch (stage) {
|
|
12
|
+
.dispatch_begin => (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4),
|
|
13
|
+
.update => (1 << 5) | (1 << 6) | (1 << 7),
|
|
14
|
+
.dispatch_render, .video_rebuild => 1 << 8,
|
|
15
|
+
.drain_installed => 1 << 9,
|
|
16
|
+
.drain_pending => (1 << 1) | (1 << 2) | (1 << 10) | (1 << 4),
|
|
17
|
+
.drain_rebuild => (1 << 8) | (1 << 11),
|
|
18
|
+
.secondary => 1 << 12,
|
|
19
|
+
.direct_tail, .event_tail => 1 << 13,
|
|
20
|
+
.error_selection => 1 << 14,
|
|
21
|
+
};
|
|
22
|
+
var ended = false;
|
|
23
|
+
var seen: u16 = 0;
|
|
24
|
+
for (result) |byte| {
|
|
25
|
+
if (byte == 0) {
|
|
26
|
+
ended = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (ended or byte > @intFromEnum(Action.take_error)) @panic("invalid compiled app dispatch action");
|
|
30
|
+
const bit = @as(u16, 1) << @as(u4, @intCast(byte));
|
|
31
|
+
if (allowed & bit == 0) @panic("unexpected compiled app dispatch stage action");
|
|
32
|
+
if (seen & bit != 0) @panic("duplicate compiled app dispatch action");
|
|
33
|
+
seen |= bit;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
return reference(stage, a, b);
|
|
38
|
+
}
|
|
39
|
+
pub fn reference(stage: Stage, a: u8, b: u8) Plan {
|
|
40
|
+
var result: Plan = @splat(0);
|
|
41
|
+
switch (stage) {
|
|
42
|
+
.dispatch_begin => result[0..4].* = .{ 1, 2, 3, 4 },
|
|
43
|
+
.update => result[0..2].* = .{ if (a != 0) 5 else 6, 7 },
|
|
44
|
+
.dispatch_render, .video_rebuild => {
|
|
45
|
+
if (a != 0) result[0] = 8;
|
|
46
|
+
},
|
|
47
|
+
.drain_installed => {
|
|
48
|
+
if (a != 0) result[0] = 9;
|
|
49
|
+
},
|
|
50
|
+
.drain_pending => {
|
|
51
|
+
if (a != 0) result[0..4].* = .{ 1, 2, 10, 4 };
|
|
52
|
+
},
|
|
53
|
+
.drain_rebuild => result[0] = if (a != 0) 8 else if (b != 0) 11 else 0,
|
|
54
|
+
.secondary => {
|
|
55
|
+
if (a == 0) result[0] = 12;
|
|
56
|
+
},
|
|
57
|
+
.direct_tail => {
|
|
58
|
+
if (a != 0 and b == 0) result[0] = 13;
|
|
59
|
+
},
|
|
60
|
+
.event_tail => {
|
|
61
|
+
if (a == 0 or (a == 2 and b != 0)) result[0] = 13;
|
|
62
|
+
},
|
|
63
|
+
.error_selection => {
|
|
64
|
+
if (a == 0 and b != 0) result[0] = 14;
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
//! Native-owned transport and execution for compiled authorization decisions.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const bridge = @import("../bridge/root.zig");
|
|
4
|
+
const security = @import("../security/root.zig");
|
|
5
|
+
const platform = @import("../platform/root.zig");
|
|
6
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
7
|
+
pub const Mode = enum(u8) { permission, permissions, origin, external, bridge_command, builtin, external_admission };
|
|
8
|
+
const Packet = struct {
|
|
9
|
+
writer: std.Io.Writer.Allocating,
|
|
10
|
+
fn init(allocator: std.mem.Allocator, mode: Mode, flags: [4]u8) Packet {
|
|
11
|
+
var self = Packet{ .writer = .init(allocator) };
|
|
12
|
+
self.append(&.{ 88, 1, @intFromEnum(mode), flags[0], flags[1], flags[2], flags[3], 0 });
|
|
13
|
+
return self;
|
|
14
|
+
}
|
|
15
|
+
fn append(self: *Packet, value: []const u8) void {
|
|
16
|
+
self.writer.writer.writeAll(value) catch @panic("authorization transport allocation failed");
|
|
17
|
+
}
|
|
18
|
+
fn integer(self: *Packet, value: usize) void {
|
|
19
|
+
var bytes: [8]u8 = undefined;
|
|
20
|
+
std.mem.writeInt(u64, &bytes, @intCast(value), .little);
|
|
21
|
+
self.append(&bytes);
|
|
22
|
+
}
|
|
23
|
+
fn field(self: *Packet, value: []const u8) void {
|
|
24
|
+
self.integer(value.len);
|
|
25
|
+
self.append(value);
|
|
26
|
+
}
|
|
27
|
+
fn list(self: *Packet, values: []const []const u8) void {
|
|
28
|
+
self.integer(values.len);
|
|
29
|
+
for (values) |value| self.field(value);
|
|
30
|
+
}
|
|
31
|
+
fn commands(self: *Packet, values: []const bridge.CommandPolicy) void {
|
|
32
|
+
self.integer(values.len);
|
|
33
|
+
for (values) |value| {
|
|
34
|
+
self.field(value.name);
|
|
35
|
+
self.list(value.permissions);
|
|
36
|
+
self.list(value.origins);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
fn finish(self: *Packet, policy: Policy) Program {
|
|
40
|
+
const input = self.writer.written();
|
|
41
|
+
var result = Program{ .bytes = @splat(0xa5) };
|
|
42
|
+
if (policy(input, &result.bytes) != 16 or result.word(0) != 1 or result.word(4) != input[2] or result.word(8) > 1 or result.word(12) > 3) @panic("invalid compiled authorization program");
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
pub const Program = struct {
|
|
47
|
+
bytes: [16]u8,
|
|
48
|
+
pub fn word(self: *const Program, at: usize) u32 {
|
|
49
|
+
return std.mem.readInt(u32, self.bytes[at..][0..4], .little);
|
|
50
|
+
}
|
|
51
|
+
fn allowed(self: *const Program) bool {
|
|
52
|
+
if (self.word(12) != 0) @panic("unexpected authorization error");
|
|
53
|
+
return self.word(8) == 1;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
pub fn hasPermission(policy: ?Policy, grants: []const []const u8, permission: []const u8) bool {
|
|
57
|
+
const compiled = policy orelse return security.hasPermission(grants, permission);
|
|
58
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
59
|
+
var packet = Packet.init(storage.get(), .permission, @splat(0));
|
|
60
|
+
defer packet.writer.deinit();
|
|
61
|
+
packet.list(grants);
|
|
62
|
+
packet.field(permission);
|
|
63
|
+
return packet.finish(compiled).allowed();
|
|
64
|
+
}
|
|
65
|
+
pub fn hasPermissions(policy: ?Policy, grants: []const []const u8, required: []const []const u8) bool {
|
|
66
|
+
const compiled = policy orelse return security.hasPermissions(grants, required);
|
|
67
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
68
|
+
var packet = Packet.init(storage.get(), .permissions, @splat(0));
|
|
69
|
+
defer packet.writer.deinit();
|
|
70
|
+
packet.list(grants);
|
|
71
|
+
packet.list(required);
|
|
72
|
+
return packet.finish(compiled).allowed();
|
|
73
|
+
}
|
|
74
|
+
pub fn allowsOrigin(policy: ?Policy, allowed: []const []const u8, origin: []const u8) bool {
|
|
75
|
+
const compiled = policy orelse return security.allowsOrigin(allowed, origin);
|
|
76
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
77
|
+
var packet = Packet.init(storage.get(), .origin, @splat(0));
|
|
78
|
+
defer packet.writer.deinit();
|
|
79
|
+
packet.list(allowed);
|
|
80
|
+
packet.field(origin);
|
|
81
|
+
return packet.finish(compiled).allowed();
|
|
82
|
+
}
|
|
83
|
+
pub fn allowsExternalUrl(policy: ?Policy, value: security.ExternalLinkPolicy, url: []const u8) bool {
|
|
84
|
+
const compiled = policy orelse return security.allowsExternalUrl(value, url);
|
|
85
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
86
|
+
var packet = Packet.init(storage.get(), .external, .{ @intFromBool(value.action == .open_system_browser), 0, 0, 0 });
|
|
87
|
+
defer packet.writer.deinit();
|
|
88
|
+
packet.list(value.allowed_urls);
|
|
89
|
+
packet.field(url);
|
|
90
|
+
return packet.finish(compiled).allowed();
|
|
91
|
+
}
|
|
92
|
+
pub fn bridgeAllows(policy: ?Policy, value: bridge.Policy, command: []const u8, origin: []const u8) bool {
|
|
93
|
+
const compiled = policy orelse return value.allows(command, origin);
|
|
94
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
95
|
+
var packet = Packet.init(storage.get(), .bridge_command, .{ @intFromBool(value.enabled), 0, 0, 0 });
|
|
96
|
+
defer packet.writer.deinit();
|
|
97
|
+
packet.list(value.permissions);
|
|
98
|
+
packet.commands(value.commands);
|
|
99
|
+
packet.field(command);
|
|
100
|
+
packet.field(origin);
|
|
101
|
+
return packet.finish(compiled).allowed();
|
|
102
|
+
}
|
|
103
|
+
pub fn builtinAllows(policy: Policy, value: bridge.Policy, navigation: security.Policy, js_window_api: bool, command: []const u8, origin: []const u8, permission: ?[]const u8) bool {
|
|
104
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
105
|
+
var packet = Packet.init(storage.get(), .builtin, .{ @intFromBool(value.enabled), @intFromBool(js_window_api), @intFromBool(permission != null), 0 });
|
|
106
|
+
defer packet.writer.deinit();
|
|
107
|
+
packet.list(navigation.permissions);
|
|
108
|
+
packet.list(value.permissions);
|
|
109
|
+
packet.commands(value.commands);
|
|
110
|
+
packet.list(navigation.navigation.allowed_origins);
|
|
111
|
+
packet.field(command);
|
|
112
|
+
packet.field(origin);
|
|
113
|
+
packet.field(permission orelse "");
|
|
114
|
+
return packet.finish(policy).allowed();
|
|
115
|
+
}
|
|
116
|
+
pub fn validateExternalUrl(policy: ?Policy, value: security.ExternalLinkPolicy, url: []const u8) !void {
|
|
117
|
+
const compiled = policy orelse {
|
|
118
|
+
if (url.len == 0) return error.InvalidExternalUrl;
|
|
119
|
+
if (url.len > platform.max_external_url_bytes) return error.ExternalUrlTooLarge;
|
|
120
|
+
if (!std.mem.startsWith(u8, url, "https://") and !std.mem.startsWith(u8, url, "http://")) return error.InvalidExternalUrl;
|
|
121
|
+
for (url) |ch| if (ch <= 0x20 or ch == 0x7f) return error.InvalidExternalUrl;
|
|
122
|
+
if (!security.allowsExternalUrl(value, url)) return error.NavigationDenied;
|
|
123
|
+
return;
|
|
124
|
+
};
|
|
125
|
+
var storage = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
126
|
+
var packet = Packet.init(storage.get(), .external_admission, .{ @intFromBool(value.action == .open_system_browser), 0, 0, 0 });
|
|
127
|
+
defer packet.writer.deinit();
|
|
128
|
+
packet.list(value.allowed_urls);
|
|
129
|
+
packet.field(url);
|
|
130
|
+
packet.integer(platform.max_external_url_bytes);
|
|
131
|
+
const result = packet.finish(compiled);
|
|
132
|
+
switch (result.word(12)) {
|
|
133
|
+
0 => if (result.word(8) != 1) @panic("invalid compiled external admission"),
|
|
134
|
+
1 => return error.InvalidExternalUrl,
|
|
135
|
+
2 => return error.ExternalUrlTooLarge,
|
|
136
|
+
3 => return error.NavigationDenied,
|
|
137
|
+
else => unreachable,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/// Parsing, handler lookup/execution and response buffers remain native capabilities.
|
|
141
|
+
pub fn dispatch(policy: ?Policy, value: bridge.Dispatcher, raw: []const u8, source: bridge.Source, output: []u8) []const u8 {
|
|
142
|
+
const compiled = policy orelse return value.dispatch(raw, source, output);
|
|
143
|
+
if (raw.len > bridge.max_message_bytes) return bridge.writeErrorResponse(output, "", .payload_too_large, "Bridge request is too large");
|
|
144
|
+
const request = bridge.parseRequest(raw) catch return bridge.writeErrorResponse(output, "", .invalid_request, "Bridge request is malformed");
|
|
145
|
+
if (!bridgeAllows(compiled, value.policy, request.command, source.origin)) return bridge.writeErrorResponse(output, request.id, .permission_denied, "Bridge command is not permitted");
|
|
146
|
+
const handler = value.registry.find(request.command) orelse return bridge.writeErrorResponse(output, request.id, .unknown_command, "Bridge command is not registered");
|
|
147
|
+
var result_buffer: [bridge.max_result_bytes]u8 = undefined;
|
|
148
|
+
const result = handler.invoke_fn(handler.context, .{ .request = request, .source = source }, &result_buffer) catch |err| return bridge.writeErrorResponse(output, request.id, .handler_failed, @errorName(err));
|
|
149
|
+
return bridge.writeSuccessResponse(output, request.id, result);
|
|
150
|
+
}
|