@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { test } from "node:test";
|
|
5
|
+
import { invocationCases } from "./invocation_cases.ts";
|
|
6
|
+
import { invoke } from "./invocation_fixture.ts";
|
|
7
|
+
assert.ok(process.argv[2], "run with the compiled corewire path (zig build test-corewire-policy)");
|
|
8
|
+
const corewire = path.resolve(process.argv[2]);
|
|
9
|
+
// Captured from the independent native coordinator, before this migration.
|
|
10
|
+
// Mirror hashes include the reviewed stateless-runtime API addition.
|
|
11
|
+
// Facade hashes include exact u32 image identities, nonreplacing file
|
|
12
|
+
// results and exact-range timers. Removing the reviewed timer encoder
|
|
13
|
+
// addition recovers every previous complete facade pin. The byte-key
|
|
14
|
+
// encoder and bounded 4 MiB view changes are also audited against those
|
|
15
|
+
// complete pins; their removal recovers the earlier generator output.
|
|
16
|
+
// Exact audio and close/minimize encoder additions are likewise audited
|
|
17
|
+
// by recovering each complete earlier facade after removing those blocks.
|
|
18
|
+
// Exact subprocess and cancellation records are independently audited:
|
|
19
|
+
// removing only their encoder cases recovers every preceding complete facade.
|
|
20
|
+
const goldens = JSON.parse(fs.readFileSync(new URL("invocation_goldens.json", import.meta.url), "utf8"));
|
|
21
|
+
for (const item of invocationCases()) test("invocation: " + item.name, () => {
|
|
22
|
+
assert.ok(goldens[item.name], "missing independent native reference");
|
|
23
|
+
assert.deepEqual(invoke(corewire, item), goldens[item.name]);
|
|
24
|
+
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Portable invocation rules; raw argument bytes and OS facts cross explicitly.
|
|
2
|
+
import type { EmissionInput } from "./core_emission.ts";
|
|
3
|
+
import type { Diagnostic } from "./core_contract.ts";
|
|
4
|
+
import { emitMirror } from "./emit_mirror.ts";
|
|
5
|
+
import { emitFacade } from "./emit_facade.ts";
|
|
6
|
+
import { emitProfile } from "./profile_emission.ts";
|
|
7
|
+
import { rewriteEffective } from "./lossless_projection.ts";
|
|
8
|
+
import { coreUsage, serviceUsage } from "./invocation_usage.ts";
|
|
9
|
+
|
|
10
|
+
export interface OutputPlan { kind: string; flag: string; path_index: number }
|
|
11
|
+
export interface InvocationPlan {
|
|
12
|
+
mode: string; input: number | null; outputs: OutputPlan[];
|
|
13
|
+
check_only: boolean; optimization: number | null; slots: number[];
|
|
14
|
+
error: number[]; exit_code: number;
|
|
15
|
+
}
|
|
16
|
+
export function textBytes(text: string): number[] {
|
|
17
|
+
const out: number[] = [];
|
|
18
|
+
for (const b of new TextEncoder().encode(text)) out.push(b);
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
function same(a: number[], b: number[]): boolean {
|
|
22
|
+
return a.length === b.length && a.every((c, i) => c === b[i]);
|
|
23
|
+
}
|
|
24
|
+
function equals(a: number[], text: string): boolean { return same(a, textBytes(text)); }
|
|
25
|
+
function foldSame(a: number[], b: number[]): boolean {
|
|
26
|
+
if (a.length !== b.length) return false;
|
|
27
|
+
for (let i = 0; i < a.length; i++) {
|
|
28
|
+
const x = a[i] >= 65 && a[i] <= 90 ? a[i] + 32 : a[i];
|
|
29
|
+
const y = b[i] >= 65 && b[i] <= 90 ? b[i] + 32 : b[i];
|
|
30
|
+
if (x !== y) return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
export function diagnostic(prefix: string, subject: number[], suffix: string): number[] {
|
|
35
|
+
const out = textBytes(prefix);
|
|
36
|
+
for (const b of subject) out.push(b);
|
|
37
|
+
for (const b of textBytes(suffix)) out.push(b);
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function refuse(plan: InvocationPlan, error: number[]): InvocationPlan {
|
|
41
|
+
plan.error = error; plan.exit_code = 2; return plan;
|
|
42
|
+
}
|
|
43
|
+
const coreFlags = ["--out", "--facade", "--profile", "--effective-sidecar"];
|
|
44
|
+
const coreKinds = ["mirror", "facade", "profile", "effective"];
|
|
45
|
+
const serviceFlags = ["--service-host-main", "--service-registry", "--service-client", "--service-inproc-main", "--service-inproc-profile"];
|
|
46
|
+
const serviceKinds = ["host", "registry", "client", "inproc_main", "inproc_profile"];
|
|
47
|
+
function output(plan: InvocationPlan, flag: string, kind: string, index: number): void {
|
|
48
|
+
const found = plan.outputs.find(o => o.kind === kind);
|
|
49
|
+
if (found !== undefined) found.path_index = index;
|
|
50
|
+
else plan.outputs.push({ flag, kind, path_index: index });
|
|
51
|
+
}
|
|
52
|
+
function ordered(plan: InvocationPlan, kinds: string[]): void {
|
|
53
|
+
const outputs: OutputPlan[] = [];
|
|
54
|
+
for (const kind of kinds) for (const entry of plan.outputs) if (entry.kind === kind) outputs.push(entry);
|
|
55
|
+
plan.outputs = outputs;
|
|
56
|
+
}
|
|
57
|
+
export function planInvocation(args: number[][]): InvocationPlan {
|
|
58
|
+
const plan: InvocationPlan = { mode: "core", input: null, outputs: [], check_only: false,
|
|
59
|
+
optimization: null, slots: [], error: [], exit_code: 0 };
|
|
60
|
+
let service = false;
|
|
61
|
+
// Service selection preserves the native prefix scan: arguments before its
|
|
62
|
+
// first flag are ignored; unknown arguments after that flag refuse.
|
|
63
|
+
for (let i = 1; i < args.length; i++) {
|
|
64
|
+
const arg = args[i]; let recognized = false;
|
|
65
|
+
if (i + 1 < args.length && equals(arg, "--services-sidecar")) {
|
|
66
|
+
service = true; plan.input = ++i; recognized = true;
|
|
67
|
+
} else if (i + 1 < args.length) {
|
|
68
|
+
for (let j = 0; j < serviceFlags.length; j++) if (equals(arg, serviceFlags[j])) {
|
|
69
|
+
service = true; output(plan, serviceFlags[j], serviceKinds[j], ++i); recognized = true; break;
|
|
70
|
+
}
|
|
71
|
+
if (!recognized && service && equals(arg, "--optimization")) {
|
|
72
|
+
plan.optimization = ++i; recognized = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!recognized && service) return refuse(plan, diagnostic('corewire: unknown service projection argument "', arg, '"\n'));
|
|
76
|
+
}
|
|
77
|
+
if (service) {
|
|
78
|
+
plan.mode = "service"; ordered(plan, serviceKinds);
|
|
79
|
+
if (plan.optimization !== null && !equals(args[plan.optimization], "dev") && !equals(args[plan.optimization], "release"))
|
|
80
|
+
return refuse(plan, textBytes("corewire: --optimization must be dev or release\n"));
|
|
81
|
+
if (plan.input === null) return refuse(plan, textBytes(serviceUsage));
|
|
82
|
+
if (plan.outputs.length === 0) return refuse(plan, textBytes("corewire: the service projection needs at least one output\n"));
|
|
83
|
+
const host = plan.outputs.find(o => o.kind === "host"), registry = plan.outputs.find(o => o.kind === "registry");
|
|
84
|
+
if (host !== undefined && registry !== undefined && foldSame(args[host.path_index], args[registry.path_index]))
|
|
85
|
+
return refuse(plan, textBytes("corewire: the service host and registry outputs name one file\n"));
|
|
86
|
+
return plan;
|
|
87
|
+
}
|
|
88
|
+
plan.input = null; plan.outputs = []; plan.optimization = null;
|
|
89
|
+
for (let i = 1; i < args.length; i++) {
|
|
90
|
+
const arg = args[i]; let recognized = false;
|
|
91
|
+
if (equals(arg, "--sidecar") && i + 1 < args.length) { plan.input = ++i; recognized = true; }
|
|
92
|
+
else if (equals(arg, "--f64-slot") && i + 1 < args.length) { plan.slots.push(++i); recognized = true; }
|
|
93
|
+
else if (equals(arg, "--optimization") && i + 1 < args.length) { plan.optimization = ++i; recognized = true; }
|
|
94
|
+
else if (equals(arg, "--check")) { plan.check_only = true; recognized = true; }
|
|
95
|
+
else if (i + 1 < args.length) for (let j = 0; j < coreFlags.length; j++) if (equals(arg, coreFlags[j])) {
|
|
96
|
+
output(plan, coreFlags[j], coreKinds[j], ++i); recognized = true; break;
|
|
97
|
+
}
|
|
98
|
+
if (!recognized) return refuse(plan, diagnostic('corewire: unknown argument "', arg, '"\n\n' + coreUsage));
|
|
99
|
+
}
|
|
100
|
+
ordered(plan, coreKinds);
|
|
101
|
+
if (plan.input === null || ((plan.outputs.length > 0) === plan.check_only)) return refuse(plan, textBytes(coreUsage));
|
|
102
|
+
return plan;
|
|
103
|
+
}
|
|
104
|
+
export function aliasPolicy(input: number[], paths: number[][], identities: boolean[][]): number[] {
|
|
105
|
+
for (let i = 0; i < paths.length; i++) {
|
|
106
|
+
const path = paths[i];
|
|
107
|
+
if (foldSame(path, input)) return diagnostic("corewire: output ", path, " names the sidecar itself — generating would destroy the input contract\n");
|
|
108
|
+
if (identities[i][0]) return diagnostic("corewire: output ", path, " resolves to the sidecar's own file — generating would destroy the input contract\n");
|
|
109
|
+
for (let j = i + 1; j < paths.length; j++) if (foldSame(path, paths[j]) || identities[i][j + 1])
|
|
110
|
+
return diagnostic("corewire: two outputs name one file (", path, ") — the later projection would overwrite the earlier\n");
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
export interface CoreInvocationInput extends EmissionInput {
|
|
115
|
+
slots: number[][]; check_only: boolean; outputs: string[];
|
|
116
|
+
optimization: string | null; entry: string; entry_utf8: boolean;
|
|
117
|
+
entry_unrelated: boolean; facade_path: number[]; profile_directory: number[];
|
|
118
|
+
entry_bytes: number[]; source: string; canonical_source: string;
|
|
119
|
+
}
|
|
120
|
+
export interface CoreInvocationResult {
|
|
121
|
+
mirror: string; facade: string; profile: string; effective: string;
|
|
122
|
+
diagnostics: Diagnostic[]; error: number[]; exit_code: number;
|
|
123
|
+
}
|
|
124
|
+
export function emitCoreInvocation(input: CoreInvocationInput): CoreInvocationResult {
|
|
125
|
+
const result: CoreInvocationResult = { mirror: "", facade: "", profile: "", effective: "", diagnostics: [], error: [], exit_code: 0 };
|
|
126
|
+
const s = input.sidecar;
|
|
127
|
+
for (const raw of input.slots) {
|
|
128
|
+
const attested = s.integer_slots.some(slot => same(textBytes(slot.slot), raw));
|
|
129
|
+
if (!attested) {
|
|
130
|
+
result.error = diagnostic("corewire: --f64-slot ", raw, " names no attested integer slot of this contract — a misspelling would silently demote nothing; check the contract's integer_slots\n");
|
|
131
|
+
result.exit_code = 2; return result;
|
|
132
|
+
}
|
|
133
|
+
let demoted = false;
|
|
134
|
+
for (const record of s.types.structs) for (const field of record.fields) {
|
|
135
|
+
if (!same(textBytes(record.name + "." + field.name), raw) || record.name.includes(".") || field.name.includes(".")) continue;
|
|
136
|
+
const type = field.type.kind === "optional" ? field.type.inner! : field.type;
|
|
137
|
+
if (type.kind !== "i64") continue;
|
|
138
|
+
type.kind = "f64"; demoted = true;
|
|
139
|
+
}
|
|
140
|
+
if (!demoted) {
|
|
141
|
+
result.error = diagnostic("corewire: --f64-slot ", raw, " does not name a record field slot (Container.field) — only record-field slots demote today; a message-arm or helper slot demotion needs its own emitter support\n");
|
|
142
|
+
result.exit_code = 2; return result;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
s.integer_slots = s.integer_slots.filter(slot => !input.slots.some(raw => same(textBytes(slot.slot), raw)));
|
|
146
|
+
const mirror = emitMirror(input); result.diagnostics = mirror.diagnostics;
|
|
147
|
+
if (mirror.diagnostics.length !== 0) { result.exit_code = 1; return result; }
|
|
148
|
+
result.mirror = mirror.output;
|
|
149
|
+
const needsProfile = input.check_only || input.outputs.includes("profile");
|
|
150
|
+
if (input.check_only || input.outputs.includes("facade") || needsProfile) {
|
|
151
|
+
const facade = emitFacade(input); result.diagnostics = facade.diagnostics;
|
|
152
|
+
if (facade.diagnostics.length !== 0) { result.exit_code = 1; return result; }
|
|
153
|
+
result.facade = facade.output;
|
|
154
|
+
}
|
|
155
|
+
if (needsProfile) {
|
|
156
|
+
if (input.entry_unrelated) {
|
|
157
|
+
result.error = diagnostic("corewire: --facade ", input.facade_path, " has no path relative to the --profile directory ");
|
|
158
|
+
for (const b of input.profile_directory) result.error.push(b);
|
|
159
|
+
for (const b of textBytes(" — the profile's entry must reach the facade from beside the profile; emit them under one root\n")) result.error.push(b);
|
|
160
|
+
result.exit_code = 2; return result;
|
|
161
|
+
}
|
|
162
|
+
if (!input.entry_utf8) {
|
|
163
|
+
result.error = diagnostic('corewire: the profile\'s entry spelling "', input.entry_bytes, '" is not valid UTF-8 — the profile is a JSON document and JSON text carries UTF-8 only; rename the facade file\n');
|
|
164
|
+
result.exit_code = 2; return result;
|
|
165
|
+
}
|
|
166
|
+
if (input.optimization !== null && input.optimization !== "dev" && input.optimization !== "release") {
|
|
167
|
+
result.error = textBytes("corewire: --optimization must be dev or release\n"); result.exit_code = 2; return result;
|
|
168
|
+
}
|
|
169
|
+
const profile = emitProfile(s, input.entry, input.optimization ?? ""); result.diagnostics = profile.diagnostics;
|
|
170
|
+
if (profile.diagnostics.length !== 0) { result.exit_code = 1; return result; }
|
|
171
|
+
result.profile = profile.output;
|
|
172
|
+
}
|
|
173
|
+
if (input.outputs.includes("effective")) result.effective = input.slots.length === 0 ? input.source : rewriteEffective(input.canonical_source, input.slots);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//! Owned-byte adapters for compiled invocation rules and decoded OS facts.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const sidecar_mod = @import("sidecar.zig");
|
|
4
|
+
const PanicSink = *const fn (?*anyopaque, [*]const u8, usize, u64) callconv(.c) void;
|
|
5
|
+
extern fn nsc_profile_set_panic_sink(PanicSink, ?*anyopaque) void;
|
|
6
|
+
extern fn nsc_profile_init() void;
|
|
7
|
+
extern fn nsc_profile_collect() void;
|
|
8
|
+
extern fn nsc_profile_invocation_plan([*]const u8, usize, *[*]const u8, *usize) void;
|
|
9
|
+
extern fn nsc_profile_invocation_aliases([*]const u8, usize, *[*]const u8, *usize) void;
|
|
10
|
+
extern fn nsc_profile_core_invocation([*]const u8, usize, *[*]const u8, *usize) void;
|
|
11
|
+
extern fn nsc_profile_effective_sidecar([*]const u8, usize, *[*]const u8, *usize) void;
|
|
12
|
+
|
|
13
|
+
pub const Output = struct { kind: enum { mirror, facade, profile, effective, host, registry, client, inproc_main, inproc_profile }, flag: []const u8, path_index: usize };
|
|
14
|
+
pub const Plan = struct {
|
|
15
|
+
mode: enum { core, service },
|
|
16
|
+
input: ?usize,
|
|
17
|
+
outputs: []const Output,
|
|
18
|
+
check_only: bool,
|
|
19
|
+
optimization: ?usize,
|
|
20
|
+
slots: []const usize,
|
|
21
|
+
@"error": []const u8,
|
|
22
|
+
exit_code: u8,
|
|
23
|
+
};
|
|
24
|
+
pub const CoreResult = struct {
|
|
25
|
+
mirror: []const u8,
|
|
26
|
+
facade: []const u8,
|
|
27
|
+
profile: []const u8,
|
|
28
|
+
effective: []const u8,
|
|
29
|
+
diagnostics: []const struct { path: []const u8, message: []const u8 },
|
|
30
|
+
@"error": []const u8,
|
|
31
|
+
exit_code: u8,
|
|
32
|
+
};
|
|
33
|
+
pub const Entry = struct {
|
|
34
|
+
text: []const u8 = "core_facade.ts",
|
|
35
|
+
utf8: bool = true,
|
|
36
|
+
unrelated: bool = false,
|
|
37
|
+
facade_path: []const u8 = "",
|
|
38
|
+
profile_directory: []const u8 = "",
|
|
39
|
+
bytes: []const u8 = "core_facade.ts",
|
|
40
|
+
};
|
|
41
|
+
const Operation = enum { plan, aliases, core, effective };
|
|
42
|
+
fn panicSink(_: ?*anyopaque, message: [*]const u8, len: usize, _: u64) callconv(.c) void {
|
|
43
|
+
std.debug.print("corewire: invocation policy trapped: {s}\n", .{message[0..len]});
|
|
44
|
+
std.process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
fn call(arena: std.mem.Allocator, operation: Operation, input: []const u8) error{OutOfMemory}![]const u8 {
|
|
47
|
+
nsc_profile_set_panic_sink(panicSink, null);
|
|
48
|
+
nsc_profile_init();
|
|
49
|
+
defer nsc_profile_collect();
|
|
50
|
+
var ptr: [*]const u8 = undefined;
|
|
51
|
+
var len: usize = 0;
|
|
52
|
+
switch (operation) {
|
|
53
|
+
.plan => nsc_profile_invocation_plan(input.ptr, input.len, &ptr, &len),
|
|
54
|
+
.aliases => nsc_profile_invocation_aliases(input.ptr, input.len, &ptr, &len),
|
|
55
|
+
.core => nsc_profile_core_invocation(input.ptr, input.len, &ptr, &len),
|
|
56
|
+
.effective => nsc_profile_effective_sidecar(input.ptr, input.len, &ptr, &len),
|
|
57
|
+
}
|
|
58
|
+
return arena.dupe(u8, ptr[0..len]);
|
|
59
|
+
}
|
|
60
|
+
fn decode(comptime T: type, arena: std.mem.Allocator, source: []const u8) error{OutOfMemory}!T {
|
|
61
|
+
return std.json.parseFromSliceLeaky(T, arena, source, .{ .allocate = .alloc_always }) catch |err| switch (err) {
|
|
62
|
+
error.OutOfMemory => return error.OutOfMemory,
|
|
63
|
+
else => @panic("corewire: malformed compiled invocation result"),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Byte arrays preserve arguments/path spellings that are not UTF-8. They
|
|
67
|
+
// are transported as facts, never converted through JavaScript strings.
|
|
68
|
+
fn rawJson(arena: std.mem.Allocator, bytes: []const u8) !std.json.Value {
|
|
69
|
+
var array: std.json.Array = .init(arena);
|
|
70
|
+
for (bytes) |byte| try array.append(.{ .integer = byte });
|
|
71
|
+
return .{ .array = array };
|
|
72
|
+
}
|
|
73
|
+
fn rawList(arena: std.mem.Allocator, values: []const []const u8) ![]const std.json.Value {
|
|
74
|
+
const out = try arena.alloc(std.json.Value, values.len);
|
|
75
|
+
for (values, 0..) |value, index| out[index] = try rawJson(arena, value);
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
pub fn plan(arena: std.mem.Allocator, args: []const []const u8) !Plan {
|
|
79
|
+
const input = try std.json.Stringify.valueAlloc(arena, try rawList(arena, args), .{});
|
|
80
|
+
return decode(Plan, arena, try call(arena, .plan, input));
|
|
81
|
+
}
|
|
82
|
+
pub fn aliases(arena: std.mem.Allocator, input: []const u8, paths: []const []const u8, identities: []const []const bool) ![]const u8 {
|
|
83
|
+
const facts = try std.json.Stringify.valueAlloc(arena, .{
|
|
84
|
+
.input = try rawJson(arena, input),
|
|
85
|
+
.paths = try rawList(arena, paths),
|
|
86
|
+
.identities = identities,
|
|
87
|
+
}, .{});
|
|
88
|
+
return decode([]const u8, arena, try call(arena, .aliases, facts));
|
|
89
|
+
}
|
|
90
|
+
pub fn canonicalJson(arena: std.mem.Allocator, source: []const u8) ![]const u8 {
|
|
91
|
+
// Scalar JSON spellings are decoder facts: f64 shortest formatting,
|
|
92
|
+
// full-width integers and unknown additive fields never roundtrip
|
|
93
|
+
// through a JavaScript number. TypeScript selects and edits the tree.
|
|
94
|
+
const root = try std.json.parseFromSliceLeaky(std.json.Value, arena, source, .{});
|
|
95
|
+
return std.json.Stringify.valueAlloc(arena, root, .{ .whitespace = .indent_2 });
|
|
96
|
+
}
|
|
97
|
+
pub fn effective(arena: std.mem.Allocator, source: []const u8, slots: []const []const u8) ![]const u8 {
|
|
98
|
+
if (slots.len == 0) return source;
|
|
99
|
+
const facts = try std.json.Stringify.valueAlloc(arena, .{
|
|
100
|
+
.canonical_source = try canonicalJson(arena, source),
|
|
101
|
+
.slots = try rawList(arena, slots),
|
|
102
|
+
}, .{});
|
|
103
|
+
return call(arena, .effective, facts);
|
|
104
|
+
}
|
|
105
|
+
pub fn core(arena: std.mem.Allocator, sidecar: sidecar_mod.Sidecar, invocation: Plan, args: []const []const u8, entry: Entry, source: []const u8) !CoreResult {
|
|
106
|
+
const slots = try arena.alloc([]const u8, invocation.slots.len);
|
|
107
|
+
for (invocation.slots, 0..) |index, at| slots[at] = args[index];
|
|
108
|
+
const outputs = try arena.alloc([]const u8, invocation.outputs.len);
|
|
109
|
+
var need_effective = false;
|
|
110
|
+
for (invocation.outputs, 0..) |out, at| {
|
|
111
|
+
outputs[at] = @tagName(out.kind);
|
|
112
|
+
if (out.kind == .effective) need_effective = true;
|
|
113
|
+
}
|
|
114
|
+
const optimization = if (invocation.optimization) |index| args[index] else null;
|
|
115
|
+
const input = try std.json.Stringify.valueAlloc(arena, .{
|
|
116
|
+
.sidecar = sidecar,
|
|
117
|
+
.build_id_hex = try std.fmt.allocPrint(arena, "{x:0>16}", .{sidecar.build_id}),
|
|
118
|
+
.model_fingerprint_hex = try std.fmt.allocPrint(arena, "{x:0>16}", .{sidecar.model_fingerprint}),
|
|
119
|
+
.wire_text = try std.fmt.allocPrint(arena, "{d}", .{sidecar.wire_version}),
|
|
120
|
+
.abi_text = try std.fmt.allocPrint(arena, "{d}", .{sidecar.abi_version}),
|
|
121
|
+
.snapshot_text = try std.fmt.allocPrint(arena, "{d}", .{sidecar.abi.snapshot_format}),
|
|
122
|
+
.slots = try rawList(arena, slots),
|
|
123
|
+
.outputs = outputs,
|
|
124
|
+
.check_only = invocation.check_only,
|
|
125
|
+
.optimization = if (optimization) |value| if (std.unicode.utf8ValidateSlice(value)) value else "invalid" else null,
|
|
126
|
+
.entry = entry.text,
|
|
127
|
+
.entry_utf8 = entry.utf8,
|
|
128
|
+
.entry_unrelated = entry.unrelated,
|
|
129
|
+
.facade_path = try rawJson(arena, entry.facade_path),
|
|
130
|
+
.profile_directory = try rawJson(arena, entry.profile_directory),
|
|
131
|
+
.entry_bytes = try rawJson(arena, entry.bytes),
|
|
132
|
+
.source = if (need_effective) source else "",
|
|
133
|
+
.canonical_source = if (need_effective and slots.len != 0) try canonicalJson(arena, source) else "",
|
|
134
|
+
}, .{});
|
|
135
|
+
return decode(CoreResult, arena, try call(arena, .core, input));
|
|
136
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// CLI conformance over independent native-reference outcomes, including all
|
|
2
|
+
// generated files and refusal ordering. The two schemas stay explicit.
|
|
3
|
+
import { baseContract as coreContract, coreCases } from "./core_cases.ts";
|
|
4
|
+
import { baseContract as serviceContract } from "./service_cases.ts";
|
|
5
|
+
export interface InvocationCase { name: string; args: string[]; core: string; services: string; directories: string[] }
|
|
6
|
+
export function invocationCases(): InvocationCase[] {
|
|
7
|
+
const core = JSON.stringify(coreContract(), (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value);
|
|
8
|
+
const services = JSON.stringify(serviceContract());
|
|
9
|
+
const cases: InvocationCase[] = [];
|
|
10
|
+
function add(name: string, args: string[], source = core): void {
|
|
11
|
+
cases.push({ name, args, core: source, services, directories: ["nested"] });
|
|
12
|
+
}
|
|
13
|
+
const input = ["--sidecar", "input.json"], service = ["--services-sidecar", "services.json"];
|
|
14
|
+
const coreFlags = ["--out", "--facade", "--profile", "--effective-sidecar"];
|
|
15
|
+
const outputs = ["mirror", "facade", "profile", "effective"];
|
|
16
|
+
const serviceFlags = ["--service-host-main", "--service-registry", "--service-client", "--service-inproc-main", "--service-inproc-profile"];
|
|
17
|
+
const serviceOutputs = ["host", "registry", "client", "inproc", "service-profile"];
|
|
18
|
+
add("no-arguments", []);
|
|
19
|
+
add("no-core-input", ["--out", "mirror"]);
|
|
20
|
+
add("no-core-output", input);
|
|
21
|
+
add("check-and-output", [...input, "--check", "--out", "mirror"]);
|
|
22
|
+
add("repeated-check", [...input, "--check", "--check"]);
|
|
23
|
+
for (const flag of ["--sidecar", "--optimization", "--f64-slot", ...coreFlags]) add("core-missing-value-" + flag, [...input, "--check", flag]);
|
|
24
|
+
add("unknown-core", [...input, "--check", "--wat"]);
|
|
25
|
+
add("empty-core-argument", [...input, "--check", ""]);
|
|
26
|
+
add("flag-consumed-as-input", ["--sidecar", "--check", "--out", "mirror"]);
|
|
27
|
+
add("last-core-input", ["--sidecar", "missing", ...input, "--check"]);
|
|
28
|
+
add("core-optimization-ignored-mirror", [...input, "--optimization", "invalid", "--out", "mirror"]);
|
|
29
|
+
add("core-optimization-ignored-effective", [...input, "--optimization", "invalid", "--effective-sidecar", "effective"]);
|
|
30
|
+
add("core-optimization-refused-check", [...input, "--optimization", "invalid", "--check"]);
|
|
31
|
+
add("last-core-optimization", [...input, "--optimization", "invalid", "--optimization", "release", "--profile", "profile"]);
|
|
32
|
+
for (let i = 0; i < coreFlags.length; i++) add("last-core-output-" + i, [...input, coreFlags[i], "old", coreFlags[i], outputs[i]]);
|
|
33
|
+
add("reverse-core-outputs", [...input, ...coreFlags.flatMap((_, i) => [coreFlags[3 - i], outputs[3 - i]]), "--f64-slot", "Model.count"]);
|
|
34
|
+
add("profile-relative-entry", [...input, "--profile", "nested/profile", "--facade", "facade", "--optimization", "dev"]);
|
|
35
|
+
add("core-alias-before-decode", [...input, "--out", "./input.json"], "{");
|
|
36
|
+
add("core-output-pair-alias", [...input, "--profile", "same", "--out", "same"]);
|
|
37
|
+
add("core-staging-prefix-alias", [...input, "--out", "mirror", "--facade", "mirror.corewire-tmp"]);
|
|
38
|
+
add("decode-before-slot", [...input, "--check", "--f64-slot", "Missing.count"], "{");
|
|
39
|
+
add("slot-before-optimization", [...input, "--check", "--f64-slot", "Missing.count", "--optimization", "invalid"]);
|
|
40
|
+
add("mirror-before-optimization", [...input, "--check", "--optimization", "invalid"], core.replace('"wire_version":10', '"wire_version":0'));
|
|
41
|
+
add("facade-before-optimization", [...input, "--check", "--optimization", "invalid"], coreCases().find(c => c.name === "unbound-helper-shadow")!.input);
|
|
42
|
+
add("check-demotion", [...input, "--check", "--f64-slot", "Model.count"]);
|
|
43
|
+
add("check-duplicate-demotion", [...input, "--check", "--f64-slot", "Model.count", "--f64-slot", "Model.count"]);
|
|
44
|
+
add("service-prefix-ignored", ["--unknown", "--sidecar", "ignored", "--optimization", "invalid", ...service, "--service-client", "client"]);
|
|
45
|
+
add("service-prefix-output-flag-value", ["--out", "--service-client", "client", ...service]);
|
|
46
|
+
add("unknown-service-after-input", [...service, "--unknown"]);
|
|
47
|
+
add("core-flag-after-service", [...service, "--check"]);
|
|
48
|
+
add("service-no-input", ["--service-client", "client"]);
|
|
49
|
+
add("service-no-output", service);
|
|
50
|
+
add("service-optimization-before-missing-input", ["--service-client", "client", "--optimization", "invalid"]);
|
|
51
|
+
add("last-service-input", ["--services-sidecar", "missing", ...service, "--service-client", "client"]);
|
|
52
|
+
add("last-service-optimization", [...service, "--optimization", "invalid", "--optimization", "dev", "--service-inproc-profile", "service-profile"]);
|
|
53
|
+
for (const flag of ["--services-sidecar", "--optimization", ...serviceFlags]) add("service-missing-value-" + flag, [...service, flag]);
|
|
54
|
+
for (let i = 0; i < serviceFlags.length; i++) add("last-service-output-" + i, [...service, serviceFlags[i], "old", serviceFlags[i], serviceOutputs[i]]);
|
|
55
|
+
add("reverse-service-outputs", [...service, ...serviceFlags.flatMap((_, i) => [serviceFlags[4 - i], serviceOutputs[4 - i]]), "--optimization", "release"]);
|
|
56
|
+
add("service-host-registry-case-alias", [...service, "--service-host-main", "SAME", "--service-registry", "same"]);
|
|
57
|
+
add("service-sequential-client-over-registry", [...service, "--service-client", "same", "--service-registry", "same"]);
|
|
58
|
+
add("service-sequential-profile-over-inproc", [...service, "--service-inproc-profile", "same", "--service-inproc-main", "same"]);
|
|
59
|
+
return cases;
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import type { InvocationCase } from "./invocation_cases.ts";
|
|
8
|
+
export interface InvocationOutcome { status: number | null; diagnostics: string; files: Record<string, string> }
|
|
9
|
+
export function invoke(corewire: string, item: InvocationCase): InvocationOutcome {
|
|
10
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "native-corewire-invocation-"));
|
|
11
|
+
try {
|
|
12
|
+
fs.writeFileSync(path.join(dir, "input.json"), item.core);
|
|
13
|
+
fs.writeFileSync(path.join(dir, "services.json"), item.services);
|
|
14
|
+
for (const file of ["mirror", "facade", "profile", "effective", "old", "host", "registry", "client", "inproc", "service-profile", "same"]) fs.writeFileSync(path.join(dir, file), "retain");
|
|
15
|
+
for (const subdir of item.directories) fs.mkdirSync(path.join(dir, subdir));
|
|
16
|
+
const result = spawnSync(corewire, item.args, { cwd: dir, encoding: "utf8", maxBuffer: 32 * 1024 * 1024 });
|
|
17
|
+
assert.ifError(result.error); assert.equal(result.signal, null, result.stderr); assert.equal(result.stdout, "");
|
|
18
|
+
const files: Record<string, string> = {};
|
|
19
|
+
function collect(subdir: string): void {
|
|
20
|
+
for (const entry of fs.readdirSync(path.join(dir, subdir), { withFileTypes: true })) {
|
|
21
|
+
const name = subdir ? subdir + "/" + entry.name : entry.name;
|
|
22
|
+
if (entry.isDirectory()) collect(name);
|
|
23
|
+
else files[name] = createHash("sha256").update(fs.readFileSync(path.join(dir, name))).digest("hex");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
collect("");
|
|
27
|
+
// realpath can normalize the temporary root; diagnostic semantics use
|
|
28
|
+
// a portable root spelling without discarding the filename or refusal.
|
|
29
|
+
let diagnostics = result.stderr.replaceAll(fs.realpathSync(dir), ".").replaceAll(dir, ".");
|
|
30
|
+
if (path.sep === "\\") diagnostics = diagnostics.replaceAll("\\", "/");
|
|
31
|
+
return { status: result.status, diagnostics, files };
|
|
32
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
33
|
+
}
|