@native-sdk/cli 0.10.0 → 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 +1818 -87
- 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/core/references/web-engines-packaging-debugging.md +2 -1
- 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/codesign.zig +125 -74
- 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/package.zig +85 -1
- 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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const coordination = @import("shell_coordination_policy.zig");
|
|
3
|
+
const lifecycle = @import("window_lifecycle_policy.zig");
|
|
2
4
|
const geometry = @import("geometry");
|
|
3
5
|
const validation = @import("validation.zig");
|
|
4
6
|
const shell_layout = @import("shell_layout.zig");
|
|
@@ -99,6 +101,7 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
99
101
|
pub const viewTreeHasFocusedDepth = WindowViewRuntimeMethods.viewTreeHasFocusedDepth;
|
|
100
102
|
|
|
101
103
|
pub fn closeWindow(self: *Runtime, window_id: platform.WindowId) anyerror!void {
|
|
104
|
+
if (self.window_lifecycle_policy) |policy| return Self.executeWindowCapability(self, policy, .close, window_id);
|
|
102
105
|
const index = Self.findWindowIndexById(self, window_id) orelse return error.WindowNotFound;
|
|
103
106
|
// Flip the runtime flag BEFORE the platform call: hosts that
|
|
104
107
|
// run the close delegate synchronously (macOS `performClose`
|
|
@@ -124,20 +127,52 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
124
127
|
self.windows[index].info.focused = false;
|
|
125
128
|
self.windows[index].info.hidden = false;
|
|
126
129
|
self.options.platform.services.closeWindow(window_id) catch |err| {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
// Replay adopts startup windows from recorded host events.
|
|
131
|
+
// They have runtime ownership but may have no native owner
|
|
132
|
+
// on the headless host. Preserve the app's close transition
|
|
133
|
+
// before the later recorded native close notification.
|
|
134
|
+
if (!self.replay_window_chrome_active or err != error.WindowNotFound) {
|
|
135
|
+
self.windows[index].info.open = was_open;
|
|
136
|
+
self.windows[index].info.focused = was_focused;
|
|
137
|
+
self.windows[index].info.hidden = was_hidden;
|
|
138
|
+
return err;
|
|
139
|
+
}
|
|
131
140
|
};
|
|
132
141
|
Self.removeWindowRuntimeViews(self, window_id);
|
|
133
142
|
self.invalidated = true;
|
|
134
143
|
}
|
|
135
144
|
|
|
145
|
+
/// Replay a successful native window capability without entering the
|
|
146
|
+
/// platform. The journal supplies the outcome; native retains view
|
|
147
|
+
/// ownership and applies the corresponding bookkeeping transition.
|
|
148
|
+
pub fn restoreWindowCapabilityResult(self: *Runtime, label: []const u8, closed: bool) void {
|
|
149
|
+
if (self.window_lifecycle_policy) |policy| {
|
|
150
|
+
const program = lifecycle.plan(policy, self, .replay, .{ .label = label, .value = closed });
|
|
151
|
+
if (program.has(64)) return;
|
|
152
|
+
const index = program.selected.?;
|
|
153
|
+
program.apply(&self.windows[index].info);
|
|
154
|
+
if (program.has(1)) Self.removeWindowRuntimeViews(self, self.windows[index].info.id);
|
|
155
|
+
if (program.has(4)) Self.setFocusedIndex(self, index) catch return;
|
|
156
|
+
if (program.has(2)) self.invalidated = true;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const index = Self.findWindowIndexByLabel(self, label) orelse return;
|
|
160
|
+
if (!self.windows[index].info.open) return;
|
|
161
|
+
self.windows[index].info.hidden = false;
|
|
162
|
+
if (closed) {
|
|
163
|
+
self.windows[index].info.open = false;
|
|
164
|
+
self.windows[index].info.focused = false;
|
|
165
|
+
Self.removeWindowRuntimeViews(self, self.windows[index].info.id);
|
|
166
|
+
} else Self.setFocusedIndex(self, index) catch return;
|
|
167
|
+
self.invalidated = true;
|
|
168
|
+
}
|
|
169
|
+
|
|
136
170
|
/// The real OS minimize verb for a tracked window (app-drawn
|
|
137
171
|
/// window controls on chromeless windows). No runtime
|
|
138
172
|
/// bookkeeping moves: a minimized window stays open and keeps
|
|
139
173
|
/// its views — it comes back from the Dock/taskbar.
|
|
140
174
|
pub fn minimizeWindow(self: *Runtime, window_id: platform.WindowId) anyerror!void {
|
|
175
|
+
if (self.window_lifecycle_policy) |policy| return Self.executeWindowCapability(self, policy, .minimize, window_id);
|
|
141
176
|
const index = Self.findWindowIndexById(self, window_id) orelse return error.WindowNotFound;
|
|
142
177
|
// The same liveness gate as showWindow below: a retained
|
|
143
178
|
// closed slot must not reach the platform (the CEF host
|
|
@@ -150,6 +185,7 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
150
185
|
/// `showWindow` brings it back. This is an app-driven hide, not a
|
|
151
186
|
/// close, so identity and rendered state are retained.
|
|
152
187
|
pub fn hideWindow(self: *Runtime, window_id: platform.WindowId) anyerror!void {
|
|
188
|
+
if (self.window_lifecycle_policy) |policy| return Self.executeWindowCapability(self, policy, .hide, window_id);
|
|
153
189
|
const index = Self.findWindowIndexById(self, window_id) orelse return error.WindowNotFound;
|
|
154
190
|
if (!self.windows[index].info.open) return error.WindowNotFound;
|
|
155
191
|
const was_hidden = self.windows[index].info.hidden;
|
|
@@ -172,6 +208,7 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
172
208
|
/// back on platform failure. A window that was never hidden
|
|
173
209
|
/// just comes to the front.
|
|
174
210
|
pub fn showWindow(self: *Runtime, window_id: platform.WindowId) anyerror!void {
|
|
211
|
+
if (self.window_lifecycle_policy) |policy| return Self.executeWindowCapability(self, policy, .show, window_id);
|
|
175
212
|
const index = Self.findWindowIndexById(self, window_id) orelse return error.WindowNotFound;
|
|
176
213
|
// A closed window keeps its table slot (the id and label
|
|
177
214
|
// release lazily, at the next create), so resolving the id
|
|
@@ -198,6 +235,40 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
198
235
|
self.invalidated = true;
|
|
199
236
|
}
|
|
200
237
|
|
|
238
|
+
/// Executes the capability sequence selected from fresh observations.
|
|
239
|
+
/// Outcome classification crosses the policy boundary; rollback fields,
|
|
240
|
+
/// replay exceptions and follow-up focus stay in the compiled program.
|
|
241
|
+
pub fn executeWindowCapability(self: *Runtime, policy: lifecycle.Policy, verb: lifecycle.Verb, window_id: platform.WindowId) anyerror!void {
|
|
242
|
+
const begin = lifecycle.plan(policy, self, .begin, .{ .id = window_id, .variant = @intFromEnum(verb) });
|
|
243
|
+
try begin.admitted();
|
|
244
|
+
const index = begin.selected.?;
|
|
245
|
+
const saved = lifecycle.flags(self.windows[index].info);
|
|
246
|
+
begin.apply(&self.windows[index].info);
|
|
247
|
+
if (begin.has(16)) try Self.showWindow(self, window_id);
|
|
248
|
+
var failure: ?anyerror = null;
|
|
249
|
+
switch (verb) {
|
|
250
|
+
.close => self.options.platform.services.closeWindow(window_id) catch |err| {
|
|
251
|
+
failure = err;
|
|
252
|
+
},
|
|
253
|
+
.hide => self.options.platform.services.hideWindow(window_id) catch |err| {
|
|
254
|
+
failure = err;
|
|
255
|
+
},
|
|
256
|
+
.show => self.options.platform.services.showWindow(window_id) catch |err| {
|
|
257
|
+
failure = err;
|
|
258
|
+
},
|
|
259
|
+
.focus => self.options.platform.services.focusWindow(window_id) catch |err| {
|
|
260
|
+
failure = err;
|
|
261
|
+
},
|
|
262
|
+
.minimize => return self.options.platform.services.minimizeWindow(window_id),
|
|
263
|
+
}
|
|
264
|
+
const finish = lifecycle.plan(policy, self, .finish, .{ .cursor = index, .variant = @intFromEnum(verb), .saved = saved, .value = self.replay_window_chrome_active, .outcome = if (failure) |err| (if (err == error.WindowNotFound) .window_not_found else .failed) else .success });
|
|
265
|
+
finish.apply(&self.windows[index].info);
|
|
266
|
+
if (finish.has(8)) return failure.?;
|
|
267
|
+
if (finish.has(1)) Self.removeWindowRuntimeViews(self, window_id);
|
|
268
|
+
if (finish.has(4)) try Self.setFocusedIndex(self, index);
|
|
269
|
+
if (finish.has(2)) self.invalidated = true;
|
|
270
|
+
}
|
|
271
|
+
|
|
201
272
|
/// The graceful app quit: ask the platform to terminate through
|
|
202
273
|
/// the SAME shutdown path a last-window close takes — the host
|
|
203
274
|
/// emits `app_shutdown` (journaled like any platform event),
|
|
@@ -244,9 +315,9 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
244
315
|
.resizable = shell_window.resizable,
|
|
245
316
|
.restore_state = shell_window.restore_state,
|
|
246
317
|
.restore_policy = shellRestorePolicy(shell_window.restore_policy),
|
|
247
|
-
.initial_placement = if (shell_window.x != null or shell_window.y != null) .explicit else .default,
|
|
318
|
+
.initial_placement = if (self.shell_coordination_policy) |policy| coordination.presentation(policy, shell_window).placement else if (shell_window.x != null or shell_window.y != null) .explicit else .default,
|
|
248
319
|
.titlebar = shell_layout.shellTitlebarStyle(shell_window.titlebar),
|
|
249
|
-
.show = shell_layout.shellWindowShowMode(shell_window),
|
|
320
|
+
.show = if (self.shell_coordination_policy) |policy| coordination.presentation(policy, shell_window).show else shell_layout.shellWindowShowMode(shell_window),
|
|
250
321
|
.transparent = shell_window.transparent,
|
|
251
322
|
.always_on_top = shell_window.always_on_top,
|
|
252
323
|
.click_through = shell_window.click_through,
|
|
@@ -264,7 +335,11 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
264
335
|
}
|
|
265
336
|
|
|
266
337
|
pub fn createShellViews(self: *Runtime, window_id: platform.WindowId, views: []const app_manifest.ShellView, bounds: geometry.RectF) anyerror!void {
|
|
267
|
-
if (
|
|
338
|
+
if (self.shell_coordination_policy) |policy| {
|
|
339
|
+
var request = coordination.request(.admission, 0, 0, 2);
|
|
340
|
+
std.mem.writeInt(u64, request[16..24], views.len, .little);
|
|
341
|
+
try coordination.plan(policy, &request).admit();
|
|
342
|
+
} else if (views.len > app_manifest.max_shell_views_per_window) return error.ViewLimitReached;
|
|
268
343
|
try Self.validateShellViewCreatePlan(self, window_id, views);
|
|
269
344
|
|
|
270
345
|
var main_state: RuntimeMainWebViewState = undefined;
|
|
@@ -290,6 +365,27 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
290
365
|
var native_view_count: usize = 0;
|
|
291
366
|
var child_webview_count: usize = 0;
|
|
292
367
|
for (views, 0..) |view, index| {
|
|
368
|
+
if (self.shell_coordination_policy) |policy| {
|
|
369
|
+
var duplicate = false;
|
|
370
|
+
for (views[0..index]) |previous| {
|
|
371
|
+
if (coordination.equal(policy, previous.label, view.label)) duplicate = true;
|
|
372
|
+
}
|
|
373
|
+
const main_label = coordination.equal(policy, view.label, "main");
|
|
374
|
+
var exists = main_label;
|
|
375
|
+
for (self.views[0..self.view_count]) |stored| {
|
|
376
|
+
if (stored.open and stored.window_id == window_id and coordination.equal(policy, stored.label, view.label)) exists = true;
|
|
377
|
+
}
|
|
378
|
+
for (self.webviews[0..self.webview_count]) |stored| {
|
|
379
|
+
if (stored.open and stored.window_id == window_id and coordination.equal(policy, stored.label, view.label)) exists = true;
|
|
380
|
+
}
|
|
381
|
+
var request = coordination.request(.admission, @as(u32, @intFromBool(duplicate)) | (@as(u32, @intFromBool(exists)) << 1) | (@as(u32, @intFromBool(main_label)) << 2), 0, 0);
|
|
382
|
+
coordination.put(&request, 16, @intFromEnum(view.kind));
|
|
383
|
+
const program = coordination.plan(policy, &request);
|
|
384
|
+
try program.admit();
|
|
385
|
+
if (program.decisions == 1) child_webview_count += 1;
|
|
386
|
+
if (program.decisions == 2) native_view_count += 1;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
293
389
|
for (views[0..index]) |previous| {
|
|
294
390
|
if (std.mem.eql(u8, previous.label, view.label)) return error.DuplicateViewLabel;
|
|
295
391
|
}
|
|
@@ -304,11 +400,35 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
304
400
|
}
|
|
305
401
|
}
|
|
306
402
|
|
|
403
|
+
if (self.shell_coordination_policy) |policy| {
|
|
404
|
+
var request = coordination.request(.admission, 0, 0, 1);
|
|
405
|
+
coordination.put(&request, 20, @intCast(native_view_count));
|
|
406
|
+
coordination.put(&request, 24, @intCast(child_webview_count));
|
|
407
|
+
coordination.put(&request, 28, @intCast(self.view_count));
|
|
408
|
+
coordination.put(&request, 32, @intCast(self.webview_count));
|
|
409
|
+
return coordination.plan(policy, &request).admit();
|
|
410
|
+
}
|
|
307
411
|
if (native_view_count > platform.max_views - self.view_count) return error.ViewLimitReached;
|
|
308
412
|
if (child_webview_count > platform.max_webviews - self.webview_count) return error.WebViewLimitReached;
|
|
309
413
|
}
|
|
310
414
|
|
|
311
415
|
pub fn applyShellViews(self: *Runtime, window_id: platform.WindowId, views: []const app_manifest.ShellView, bounds: geometry.RectF, mode: ShellApplyMode, tracked_labels: ?*[app_manifest.max_shell_views_per_window][]const u8, tracked_count: ?*usize) anyerror!void {
|
|
416
|
+
if (self.shell_layout_policy) |policy| {
|
|
417
|
+
const plan = shell_layout.compiledShellPlan(policy, bounds, views);
|
|
418
|
+
for (plan.items[0..plan.count]) |item| {
|
|
419
|
+
const view = views[item.index];
|
|
420
|
+
const did_create = try Self.applyShellView(self, shell_layout.shellViewOptionsWithFrame(window_id, view, item.platform_frame), mode);
|
|
421
|
+
if (did_create) {
|
|
422
|
+
if (tracked_labels) |labels| {
|
|
423
|
+
const count = tracked_count.?;
|
|
424
|
+
labels[count.*] = view.label;
|
|
425
|
+
count.* += 1;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (plan.invalid_parents) return error.InvalidViewOptions;
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
312
432
|
var layout = ShellLayout.init(bounds, views);
|
|
313
433
|
var created: [app_manifest.max_shell_views_per_window]bool = [_]bool{false} ** app_manifest.max_shell_views_per_window;
|
|
314
434
|
var created_count: usize = 0;
|
|
@@ -336,6 +456,25 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
336
456
|
}
|
|
337
457
|
|
|
338
458
|
pub fn applyShellView(self: *Runtime, options: platform.ViewOptions, mode: ShellApplyMode) anyerror!bool {
|
|
459
|
+
if (self.shell_coordination_policy) |policy| {
|
|
460
|
+
const main_label = coordination.equal(policy, options.label, "main");
|
|
461
|
+
const facts = @as(u32, @intFromBool(mode == .update)) | (@as(u32, @intFromBool(main_label)) << 1);
|
|
462
|
+
var request = coordination.request(.apply, facts, 0, 0);
|
|
463
|
+
coordination.put(&request, 16, @intFromEnum(options.kind));
|
|
464
|
+
const program = coordination.plan(policy, &request);
|
|
465
|
+
if (program.decisions & 1 != 0) try Self.setMainWebViewParent(self, options.window_id, options.parent);
|
|
466
|
+
if (program.decisions & 2 != 0) {
|
|
467
|
+
_ = try Self.createView(self, options);
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
_ = Self.updateView(self, options.window_id, options.label, .{ .frame = options.frame, .layer = options.layer }) catch |err| {
|
|
471
|
+
var finish = request;
|
|
472
|
+
coordination.put(&finish, 4, facts | (@as(u32, @intFromBool(err == error.ViewNotFound or err == error.WebViewNotFound)) << 2));
|
|
473
|
+
if (coordination.plan(policy, &finish).decisions & 8 != 0) return false;
|
|
474
|
+
return err;
|
|
475
|
+
};
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
339
478
|
switch (mode) {
|
|
340
479
|
.create => {
|
|
341
480
|
if (options.kind == .webview and isMainWebViewLabel(options.label)) {
|
|
@@ -369,6 +508,15 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
369
508
|
|
|
370
509
|
pub fn rollbackCreatedShellViews(self: *Runtime, window_id: platform.WindowId, labels: []const []const u8) void {
|
|
371
510
|
var index = labels.len;
|
|
511
|
+
if (self.shell_coordination_policy) |policy| {
|
|
512
|
+
while (true) {
|
|
513
|
+
const request = coordination.request(.rollback, 0, @intCast(labels.len), @intCast(index));
|
|
514
|
+
const slot = coordination.plan(policy, &request).selected orelse break;
|
|
515
|
+
Self.closeView(self, window_id, labels[slot]) catch {};
|
|
516
|
+
index = slot;
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
372
520
|
while (index > 0) {
|
|
373
521
|
index -= 1;
|
|
374
522
|
Self.closeView(self, window_id, labels[index]) catch {};
|
|
@@ -391,13 +539,18 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
391
539
|
const window = self.windows[index];
|
|
392
540
|
var restore_error: ?anyerror = null;
|
|
393
541
|
|
|
394
|
-
if (
|
|
395
|
-
|
|
542
|
+
const restore = if (self.shell_coordination_policy) |policy| compiled: {
|
|
543
|
+
var request = coordination.request(.restore, @as(u32, @intFromBool(window.source != null)) | (@as(u32, @intFromBool(window.main_frame_set != state.frame_set)) << 1), @bitCast(window.main_layer), @bitCast(state.layer));
|
|
544
|
+
for ([_]f32{ window.main_frame.x, window.main_frame.y, window.main_frame.width, window.main_frame.height, state.frame.x, state.frame.y, state.frame.width, state.frame.height }, 0..) |value, i| coordination.put(&request, 16 + i * 4, @bitCast(value));
|
|
545
|
+
break :compiled coordination.plan(policy, &request).decisions;
|
|
546
|
+
} else @as(u32, if (window.source != null and (window.main_frame_set != state.frame_set or !Self.rectsEqual(window.main_frame, state.frame))) 1 else 0) | @as(u32, if (window.source != null and window.main_layer != state.layer) 2 else 0);
|
|
547
|
+
{
|
|
548
|
+
if (restore & 1 != 0) {
|
|
396
549
|
self.options.platform.services.setWebViewFrame(window_id, "main", state.frame) catch |err| {
|
|
397
550
|
restore_error = err;
|
|
398
551
|
};
|
|
399
552
|
}
|
|
400
|
-
if (
|
|
553
|
+
if (restore & 2 != 0) {
|
|
401
554
|
self.options.platform.services.setWebViewLayer(window_id, "main", state.layer) catch |err| {
|
|
402
555
|
if (restore_error == null) restore_error = err;
|
|
403
556
|
};
|
package/src/tooling/codesign.zig
CHANGED
|
@@ -13,14 +13,13 @@ pub const CodesignArgs = struct {
|
|
|
13
13
|
identity: []const u8 = "-",
|
|
14
14
|
entitlements: ?[]const u8 = null,
|
|
15
15
|
hardened_runtime: bool = false,
|
|
16
|
+
secure_timestamp: bool = false,
|
|
16
17
|
deep: bool = true,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
pub const NotarizeArgs = struct {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
apple_id: ?[]const u8 = null,
|
|
23
|
-
password_keychain_item: ?[]const u8 = null,
|
|
21
|
+
artifact_path: []const u8,
|
|
22
|
+
keychain_profile: []const u8,
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
// Every command in this pipeline is built as an ARGV ARRAY, never as a
|
|
@@ -29,7 +28,7 @@ pub const NotarizeArgs = struct {
|
|
|
29
28
|
// replaced split `My App.app` into two arguments, codesign signed
|
|
30
29
|
// nothing, and the failure never surfaced.
|
|
31
30
|
|
|
32
|
-
pub const sign_argv_capacity =
|
|
31
|
+
pub const sign_argv_capacity = 11;
|
|
33
32
|
|
|
34
33
|
pub fn signArgv(buffer: *[sign_argv_capacity][]const u8, args: CodesignArgs) []const []const u8 {
|
|
35
34
|
var len: usize = 0;
|
|
@@ -51,6 +50,10 @@ pub fn signArgv(buffer: *[sign_argv_capacity][]const u8, args: CodesignArgs) []c
|
|
|
51
50
|
buffer[len] = "runtime";
|
|
52
51
|
len += 1;
|
|
53
52
|
}
|
|
53
|
+
if (args.secure_timestamp) {
|
|
54
|
+
buffer[len] = "--timestamp";
|
|
55
|
+
len += 1;
|
|
56
|
+
}
|
|
54
57
|
if (args.entitlements) |ent| {
|
|
55
58
|
buffer[len] = "--entitlements";
|
|
56
59
|
len += 1;
|
|
@@ -67,6 +70,11 @@ pub fn verifyArgv(buffer: *[6][]const u8, app_path: []const u8) []const []const
|
|
|
67
70
|
return buffer;
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
pub fn verifyArtifactArgv(buffer: *[5][]const u8, artifact_path: []const u8) []const []const u8 {
|
|
74
|
+
buffer.* = .{ "codesign", "--verify", "--strict", "--verbose=2", artifact_path };
|
|
75
|
+
return buffer;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
pub fn zipArgv(buffer: *[6][]const u8, app_path: []const u8, zip_path: []const u8) []const []const u8 {
|
|
71
79
|
buffer.* = .{ "ditto", "-c", "-k", "--keepParent", app_path, zip_path };
|
|
72
80
|
return buffer;
|
|
@@ -77,37 +85,18 @@ pub fn stapleArgv(buffer: *[4][]const u8, app_path: []const u8) []const []const
|
|
|
77
85
|
return buffer;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
pub const
|
|
88
|
+
pub fn stapleValidateArgv(buffer: *[4][]const u8, app_path: []const u8) []const []const u8 {
|
|
89
|
+
buffer.* = .{ "xcrun", "stapler", "validate", app_path };
|
|
90
|
+
return buffer;
|
|
91
|
+
}
|
|
81
92
|
|
|
82
|
-
pub fn notarizeSubmitArgv(buffer: *[
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
buffer
|
|
89
|
-
len += 1;
|
|
90
|
-
buffer[len] = zip_path;
|
|
91
|
-
len += 1;
|
|
92
|
-
buffer[len] = "--team-id";
|
|
93
|
-
len += 1;
|
|
94
|
-
buffer[len] = args.team_id;
|
|
95
|
-
len += 1;
|
|
96
|
-
if (args.apple_id) |apple_id| {
|
|
97
|
-
buffer[len] = "--apple-id";
|
|
98
|
-
len += 1;
|
|
99
|
-
buffer[len] = apple_id;
|
|
100
|
-
len += 1;
|
|
101
|
-
}
|
|
102
|
-
if (password_value) |value| {
|
|
103
|
-
buffer[len] = "--password";
|
|
104
|
-
len += 1;
|
|
105
|
-
buffer[len] = value;
|
|
106
|
-
len += 1;
|
|
107
|
-
}
|
|
108
|
-
buffer[len] = "--wait";
|
|
109
|
-
len += 1;
|
|
110
|
-
return buffer[0..len];
|
|
93
|
+
pub fn notarizeSubmitArgv(buffer: *[9][]const u8, artifact_path: []const u8, keychain_profile: []const u8) []const []const u8 {
|
|
94
|
+
buffer.* = .{
|
|
95
|
+
"xcrun", "notarytool", "submit",
|
|
96
|
+
artifact_path, "--keychain-profile", keychain_profile,
|
|
97
|
+
"--wait", "--output-format", "json",
|
|
98
|
+
};
|
|
99
|
+
return buffer;
|
|
111
100
|
}
|
|
112
101
|
|
|
113
102
|
pub fn signAdHoc(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8) !SignResult {
|
|
@@ -120,10 +109,20 @@ pub fn signIdentity(allocator: std.mem.Allocator, io: std.Io, app_path: []const
|
|
|
120
109
|
.identity = identity,
|
|
121
110
|
.entitlements = entitlements,
|
|
122
111
|
.hardened_runtime = true,
|
|
112
|
+
.secure_timestamp = true,
|
|
123
113
|
.deep = true,
|
|
124
114
|
});
|
|
125
115
|
}
|
|
126
116
|
|
|
117
|
+
pub fn signIdentityArtifact(allocator: std.mem.Allocator, io: std.Io, artifact_path: []const u8, identity: []const u8) !SignResult {
|
|
118
|
+
return runSign(allocator, io, .{
|
|
119
|
+
.app_path = artifact_path,
|
|
120
|
+
.identity = identity,
|
|
121
|
+
.secure_timestamp = true,
|
|
122
|
+
.deep = false,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
127
126
|
/// `codesign --verify --deep --strict` over the signed bundle: the same
|
|
128
127
|
/// check Gatekeeper and an Apple silicon launch effectively run, so a
|
|
129
128
|
/// signature that only LOOKS applied (stale seal, unsigned nested code)
|
|
@@ -133,37 +132,58 @@ pub fn verify(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8) !S
|
|
|
133
132
|
return runTool(allocator, io, verifyArgv(&buffer, app_path));
|
|
134
133
|
}
|
|
135
134
|
|
|
136
|
-
pub fn
|
|
137
|
-
const
|
|
135
|
+
pub fn verifyArtifact(allocator: std.mem.Allocator, io: std.Io, artifact_path: []const u8) !SignResult {
|
|
136
|
+
var buffer: [5][]const u8 = undefined;
|
|
137
|
+
return runTool(allocator, io, verifyArtifactArgv(&buffer, artifact_path));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
pub fn notarizeApp(allocator: std.mem.Allocator, io: std.Io, args: NotarizeArgs) !SignResult {
|
|
141
|
+
const zip_path = try std.fmt.allocPrint(allocator, "{s}.notarize.zip", .{args.artifact_path});
|
|
138
142
|
defer allocator.free(zip_path);
|
|
143
|
+
defer std.Io.Dir.cwd().deleteFile(io, zip_path) catch {};
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
allocator.free(zip_result.message);
|
|
145
|
-
}
|
|
145
|
+
var zip_buffer: [6][]const u8 = undefined;
|
|
146
|
+
const zip_result = try runTool(allocator, io, zipArgv(&zip_buffer, args.artifact_path, zip_path));
|
|
147
|
+
if (!zip_result.ok) return failedStep(allocator, "ditto (zip for notarization)", zip_result);
|
|
148
|
+
allocator.free(zip_result.message);
|
|
146
149
|
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
defer if (password_value) |value| allocator.free(value);
|
|
153
|
-
var submit_buffer: [notarize_submit_argv_capacity][]const u8 = undefined;
|
|
154
|
-
const submit_result = try runTool(allocator, io, notarizeSubmitArgv(&submit_buffer, zip_path, password_value, args));
|
|
155
|
-
if (!submit_result.ok) return failedStep(allocator, "notarytool submit", submit_result);
|
|
156
|
-
allocator.free(submit_result.message);
|
|
157
|
-
}
|
|
150
|
+
return notarizeArtifact(allocator, io, .{
|
|
151
|
+
.artifact_path = args.artifact_path,
|
|
152
|
+
.keychain_profile = args.keychain_profile,
|
|
153
|
+
}, zip_path);
|
|
154
|
+
}
|
|
158
155
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
pub fn notarizeArtifact(allocator: std.mem.Allocator, io: std.Io, args: NotarizeArgs, submission_path: ?[]const u8) !SignResult {
|
|
157
|
+
var submit_buffer: [9][]const u8 = undefined;
|
|
158
|
+
const submit_result = try runTool(allocator, io, notarizeSubmitArgv(&submit_buffer, submission_path orelse args.artifact_path, args.keychain_profile));
|
|
159
|
+
if (!submit_result.ok) return failedStep(allocator, "notarytool submit", submit_result);
|
|
160
|
+
if (!notarizationAccepted(allocator, submit_result.message)) return failedStep(allocator, "notarytool returned a non-accepted status", submit_result);
|
|
161
|
+
allocator.free(submit_result.message);
|
|
165
162
|
|
|
166
|
-
|
|
163
|
+
var staple_buffer: [4][]const u8 = undefined;
|
|
164
|
+
const staple_result = try runTool(allocator, io, stapleArgv(&staple_buffer, args.artifact_path));
|
|
165
|
+
if (!staple_result.ok) return failedStep(allocator, "stapler staple", staple_result);
|
|
166
|
+
allocator.free(staple_result.message);
|
|
167
|
+
|
|
168
|
+
var validate_buffer: [4][]const u8 = undefined;
|
|
169
|
+
const validate_result = try runTool(allocator, io, stapleValidateArgv(&validate_buffer, args.artifact_path));
|
|
170
|
+
if (!validate_result.ok) return failedStep(allocator, "stapler validate", validate_result);
|
|
171
|
+
allocator.free(validate_result.message);
|
|
172
|
+
|
|
173
|
+
return .{ .ok = true, .message = try allocator.dupe(u8, "notarization accepted, stapled, and validated") };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fn notarizationAccepted(allocator: std.mem.Allocator, output: []const u8) bool {
|
|
177
|
+
const start = std.mem.indexOfScalar(u8, output, '{') orelse return false;
|
|
178
|
+
const end = std.mem.lastIndexOfScalar(u8, output, '}') orelse return false;
|
|
179
|
+
if (end < start) return false;
|
|
180
|
+
var parsed = std.json.parseFromSlice(std.json.Value, allocator, output[start .. end + 1], .{}) catch return false;
|
|
181
|
+
defer parsed.deinit();
|
|
182
|
+
const status = switch (parsed.value) {
|
|
183
|
+
.object => |object| object.get("status") orelse return false,
|
|
184
|
+
else => return false,
|
|
185
|
+
};
|
|
186
|
+
return status == .string and std.mem.eql(u8, status.string, "Accepted");
|
|
167
187
|
}
|
|
168
188
|
|
|
169
189
|
fn failedStep(allocator: std.mem.Allocator, step: []const u8, result: SignResult) !SignResult {
|
|
@@ -215,13 +235,30 @@ test "identity sign argv includes runtime and entitlements as single arguments"
|
|
|
215
235
|
.identity = "Developer ID Application: Test Person (ABCD1234)",
|
|
216
236
|
.entitlements = "assets dir/native-sdk.entitlements",
|
|
217
237
|
.hardened_runtime = true,
|
|
238
|
+
.secure_timestamp = true,
|
|
239
|
+
});
|
|
240
|
+
const expected = [_][]const u8{
|
|
241
|
+
"codesign", "--sign",
|
|
242
|
+
"Developer ID Application: Test Person (ABCD1234)", "--force",
|
|
243
|
+
"--deep", "--options",
|
|
244
|
+
"runtime", "--timestamp",
|
|
245
|
+
"--entitlements", "assets dir/native-sdk.entitlements",
|
|
246
|
+
"/tmp/My Demo App.app",
|
|
247
|
+
};
|
|
248
|
+
try expectArgv(&expected, argv);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
test "distribution artifact sign argv requests a secure timestamp without app-only options" {
|
|
252
|
+
var buffer: [sign_argv_capacity][]const u8 = undefined;
|
|
253
|
+
const argv = signArgv(&buffer, .{
|
|
254
|
+
.app_path = "/tmp/My Demo App.dmg",
|
|
255
|
+
.identity = "Developer ID Application: Test Person (ABCD1234)",
|
|
256
|
+
.secure_timestamp = true,
|
|
257
|
+
.deep = false,
|
|
218
258
|
});
|
|
219
259
|
const expected = [_][]const u8{
|
|
220
|
-
"codesign",
|
|
221
|
-
"
|
|
222
|
-
"--deep", "--options",
|
|
223
|
-
"runtime", "--entitlements",
|
|
224
|
-
"assets dir/native-sdk.entitlements", "/tmp/My Demo App.app",
|
|
260
|
+
"codesign", "--sign", "Developer ID Application: Test Person (ABCD1234)",
|
|
261
|
+
"--force", "--timestamp", "/tmp/My Demo App.dmg",
|
|
225
262
|
};
|
|
226
263
|
try expectArgv(&expected, argv);
|
|
227
264
|
}
|
|
@@ -233,14 +270,17 @@ test "verify argv runs the strict deep check on the bundle path" {
|
|
|
233
270
|
try expectArgv(&expected, argv);
|
|
234
271
|
}
|
|
235
272
|
|
|
236
|
-
test "
|
|
237
|
-
var buffer: [
|
|
238
|
-
const argv =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
273
|
+
test "artifact verify argv runs the strict check without bundle recursion" {
|
|
274
|
+
var buffer: [5][]const u8 = undefined;
|
|
275
|
+
const argv = verifyArtifactArgv(&buffer, "/tmp/My Demo App.dmg");
|
|
276
|
+
const expected = [_][]const u8{ "codesign", "--verify", "--strict", "--verbose=2", "/tmp/My Demo App.dmg" };
|
|
277
|
+
try expectArgv(&expected, argv);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
test "notarize submit argv uses a keychain profile, waits, and requests JSON" {
|
|
281
|
+
var buffer: [9][]const u8 = undefined;
|
|
282
|
+
const argv = notarizeSubmitArgv(&buffer, "/tmp/My Demo App.dmg", "vercel-release");
|
|
283
|
+
const expected = [_][]const u8{ "xcrun", "notarytool", "submit", "/tmp/My Demo App.dmg", "--keychain-profile", "vercel-release", "--wait", "--output-format", "json" };
|
|
244
284
|
try expectArgv(&expected, argv);
|
|
245
285
|
}
|
|
246
286
|
|
|
@@ -250,12 +290,23 @@ test "staple and zip argv carry spaced paths as single arguments" {
|
|
|
250
290
|
const staple_expected = [_][]const u8{ "xcrun", "stapler", "staple", "/tmp/My Demo App.app" };
|
|
251
291
|
try expectArgv(&staple_expected, staple);
|
|
252
292
|
|
|
293
|
+
var validate_buffer: [4][]const u8 = undefined;
|
|
294
|
+
const validate = stapleValidateArgv(&validate_buffer, "/tmp/My Demo App.app");
|
|
295
|
+
const validate_expected = [_][]const u8{ "xcrun", "stapler", "validate", "/tmp/My Demo App.app" };
|
|
296
|
+
try expectArgv(&validate_expected, validate);
|
|
297
|
+
|
|
253
298
|
var zip_buffer: [6][]const u8 = undefined;
|
|
254
299
|
const zip = zipArgv(&zip_buffer, "/tmp/My Demo App.app", "/tmp/My Demo App.app.zip");
|
|
255
300
|
const zip_expected = [_][]const u8{ "ditto", "-c", "-k", "--keepParent", "/tmp/My Demo App.app", "/tmp/My Demo App.app.zip" };
|
|
256
301
|
try expectArgv(&zip_expected, zip);
|
|
257
302
|
}
|
|
258
303
|
|
|
304
|
+
test "notarization accepts only an explicit Accepted JSON status" {
|
|
305
|
+
try std.testing.expect(notarizationAccepted(std.testing.allocator, "{\"id\":\"123\",\"status\":\"Accepted\"}\n"));
|
|
306
|
+
try std.testing.expect(!notarizationAccepted(std.testing.allocator, "{\"id\":\"123\",\"status\":\"Invalid\"}\n"));
|
|
307
|
+
try std.testing.expect(!notarizationAccepted(std.testing.allocator, "not JSON"));
|
|
308
|
+
}
|
|
309
|
+
|
|
259
310
|
test "a failing tool surfaces its own output, not a silent success" {
|
|
260
311
|
if (@import("builtin").os.tag == .windows) return error.SkipZigTest;
|
|
261
312
|
// `false` exits 1 with no output: the result must be a failure.
|