@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,140 @@
|
|
|
1
|
+
/** Command and status-item coordination over copied runtime facts. Native owns
|
|
2
|
+
* registry storage, borrowed command strings, exact OS identities and execution.
|
|
3
|
+
* Replies select native-owned rows/slots; no string or handle becomes a number.
|
|
4
|
+
*/
|
|
5
|
+
function nscvCommandSame(input: Uint8Array, first: number, firstLength: number, second: number, secondLength: number): boolean {
|
|
6
|
+
if (firstLength !== secondLength) return false;
|
|
7
|
+
for (let i = 0; i < firstLength; i++) if (input[first + i] !== input[second + i]) return false;
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function nscvCommandLiteral(input: Uint8Array, at: number, length: number, literal: readonly number[]): boolean {
|
|
12
|
+
if (length !== literal.length) return false;
|
|
13
|
+
for (let i = 0; i < length; i++) if (input[at + i] !== literal[i]) return false;
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function nscvCommandCoordination(request: Uint8Array): Uint8Array {
|
|
18
|
+
if (request.length < 8 || request[0] !== 69 || request[1]! > 5 || request[2] !== 0 || request[3] !== 0) throw new Error("invalid command coordination header");
|
|
19
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
20
|
+
const operation = request[1]!;
|
|
21
|
+
if (operation === 5) {
|
|
22
|
+
const count = wire.getUint32(4, true), entries: number[] = [];
|
|
23
|
+
let at = 8;
|
|
24
|
+
for (let slot = 0; slot < (count <= 256 ? count : 0); slot++) {
|
|
25
|
+
if (at + 8 > request.length) throw new Error("truncated command catalog header");
|
|
26
|
+
const idLength = wire.getUint32(at, true), titleLength = wire.getUint32(at + 4, true);
|
|
27
|
+
entries.push(at); at += 8 + Math.min(idLength, 128) + Math.min(titleLength, 128);
|
|
28
|
+
if (at > request.length) throw new Error("truncated command catalog bytes");
|
|
29
|
+
}
|
|
30
|
+
if (at !== request.length) throw new Error("trailing command catalog bytes");
|
|
31
|
+
const result = new Uint8Array(4);
|
|
32
|
+
if (count > 256) { result[0] = 1; return result; }
|
|
33
|
+
for (let slot = 0; slot < entries.length; slot++) {
|
|
34
|
+
const entry = entries[slot]!, idLength = wire.getUint32(entry, true), titleLength = wire.getUint32(entry + 4, true), idAt = entry + 8;
|
|
35
|
+
if (idLength === 0 || idLength > 128) { result[0] = 1; return result; }
|
|
36
|
+
if (nscvCommandLiteral(request, idAt, idLength, [46]) || nscvCommandLiteral(request, idAt, idLength, [46, 46])) { result[0] = 2; return result; }
|
|
37
|
+
// Catalog admission keeps InvalidName distinct from dispatch's
|
|
38
|
+
// InvalidCommand. The complete name scan precedes control-byte checks.
|
|
39
|
+
for (let byte = 0; byte < idLength; byte++) if (request[idAt + byte] === 0 || request[idAt + byte] === 47 || request[idAt + byte] === 92) { result[0] = 2; return result; }
|
|
40
|
+
for (let byte = 0; byte < idLength; byte++) if (request[idAt + byte] === 10 || request[idAt + byte] === 13 || request[idAt + byte] === 9) { result[0] = 1; return result; }
|
|
41
|
+
if (titleLength > 128) { result[0] = 2; return result; }
|
|
42
|
+
for (let byte = 0; byte < titleLength; byte++) if (request[idAt + idLength + byte] === 0) { result[0] = 2; return result; }
|
|
43
|
+
for (let previous = 0; previous < slot; previous++) {
|
|
44
|
+
const other = entries[previous]!;
|
|
45
|
+
if (nscvCommandSame(request, idAt, idLength, other + 8, wire.getUint32(other, true))) { result[0] = 3; return result; }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
if (operation === 0 || operation === 4) {
|
|
51
|
+
const length = wire.getUint32(4, true), limit = operation === 0 ? 128 : 64;
|
|
52
|
+
if (request.length !== 8 + Math.min(length, limit)) throw new Error("invalid command text packet");
|
|
53
|
+
const result = new Uint8Array(4);
|
|
54
|
+
if (operation === 4) {
|
|
55
|
+
result[0] = nscvCommandLiteral(request, 8, length, [109, 97, 105, 110]) ? 1 : 0;
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
if (length === 0 || length > 128 || nscvCommandLiteral(request, 8, length, [46]) || nscvCommandLiteral(request, 8, length, [46, 46])) { result[0] = 1; return result; }
|
|
59
|
+
for (let i = 8; i < request.length; i++) {
|
|
60
|
+
const byte = request[i]!;
|
|
61
|
+
if (byte === 0 || byte === 47 || byte === 92 || byte === 10 || byte === 13 || byte === 9) { result[0] = 1; return result; }
|
|
62
|
+
}
|
|
63
|
+
// app.check-for-updates is a reserved OS command. Unsupported execution
|
|
64
|
+
// falls through to the app; other capability errors retain their identity.
|
|
65
|
+
if (nscvCommandLiteral(request, 8, length, [97, 112, 112, 46, 99, 104, 101, 99, 107, 45, 102, 111, 114, 45, 117, 112, 100, 97, 116, 101, 115])) result[0] = 2;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
if (operation === 1) {
|
|
69
|
+
if (request.length < 20) throw new Error("truncated command view header");
|
|
70
|
+
const count = wire.getUint32(4, true), labelLength = wire.getUint32(16, true);
|
|
71
|
+
if (count > 32) throw new Error("invalid command view count");
|
|
72
|
+
let at = 20 + Math.min(labelLength, 64);
|
|
73
|
+
if (at > request.length) throw new Error("truncated command view label");
|
|
74
|
+
const entries: number[] = [];
|
|
75
|
+
for (let i = 0; i < count; i++) {
|
|
76
|
+
if (at + 16 > request.length) throw new Error("truncated command view facts");
|
|
77
|
+
const flags = request[at]!, ownLength = request[at + 1]!, parentLength = request[at + 2]!;
|
|
78
|
+
if (flags > 7 || ownLength > 64 || parentLength > 64 || request[at + 3] !== 0 || wire.getUint32(at + 12, true) !== 0 || ((flags & 4) === 0 && parentLength !== 0)) throw new Error("invalid command view facts");
|
|
79
|
+
entries.push(at); at += 16 + ownLength + parentLength;
|
|
80
|
+
if (at > request.length) throw new Error("truncated command view text");
|
|
81
|
+
}
|
|
82
|
+
if (at !== request.length) throw new Error("trailing command view bytes");
|
|
83
|
+
const result = new Uint8Array(4); result[0] = 6; // native_view
|
|
84
|
+
if (labelLength > 64) return result;
|
|
85
|
+
let labelAt = 20, currentLength = labelLength;
|
|
86
|
+
for (let depth = 0; depth < 32; depth++) {
|
|
87
|
+
let found = -1;
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
if ((request[entry]! & 1) !== 0 && nscvCommandSame(request, 8, 8, entry + 4, 8) && nscvCommandSame(request, labelAt, currentLength, entry + 16, request[entry + 1]!)) { found = entry; break; }
|
|
90
|
+
}
|
|
91
|
+
if (found < 0) return result;
|
|
92
|
+
if ((request[found]! & 2) !== 0) { result[0] = 3; return result; } // toolbar
|
|
93
|
+
if ((request[found]! & 4) === 0) return result;
|
|
94
|
+
labelAt = found + 16 + request[found + 1]!; currentLength = request[found + 2]!;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
if (operation === 2) {
|
|
99
|
+
if (request.length < 12) throw new Error("truncated command menu header");
|
|
100
|
+
const count = wire.getUint32(4, true), id = wire.getUint32(8, true);
|
|
101
|
+
if (count > 32) throw new Error("invalid command menu count");
|
|
102
|
+
const result = new Uint8Array(16), out = new DataView(result.buffer);
|
|
103
|
+
out.setUint32(4, 0xffffffff, true); out.setUint32(8, 0xffffffff, true);
|
|
104
|
+
let at = 12, queryDone = false, commandDone = false;
|
|
105
|
+
for (let i = 0; i < count; i++) {
|
|
106
|
+
if (at + 8 > request.length) throw new Error("truncated command menu row");
|
|
107
|
+
const rowId = wire.getUint32(at, true), flags = request[at + 4]!, options = request[at + 5]!;
|
|
108
|
+
if (flags > 15 || options > 8 || request[at + 6] !== 0 || request[at + 7] !== 0) throw new Error("invalid command menu row");
|
|
109
|
+
if (!queryDone && rowId === id) {
|
|
110
|
+
result[0] = 1; result[1] = (flags & 1) === 0 && (flags & 2) !== 0 && (flags & 4) !== 0 ? 1 : 0; queryDone = true;
|
|
111
|
+
}
|
|
112
|
+
if (!commandDone && rowId === id && (flags & 8) !== 0) { out.setUint32(4, i, true); commandDone = true; }
|
|
113
|
+
at += 8;
|
|
114
|
+
for (let option = 0; option < options; option++) {
|
|
115
|
+
if (at + 8 > request.length || request[at + 4]! > 1 || request[at + 5] !== 0 || request[at + 6] !== 0 || request[at + 7] !== 0) throw new Error("invalid command menu option");
|
|
116
|
+
if (wire.getUint32(at, true) === id) {
|
|
117
|
+
if (!queryDone) { result[0] = 1; result[1] = request[at + 4]!; queryDone = true; }
|
|
118
|
+
// Empty segmented commands are still the selected borrowed string.
|
|
119
|
+
if (!commandDone) { out.setUint32(4, i, true); out.setUint32(8, option, true); commandDone = true; }
|
|
120
|
+
}
|
|
121
|
+
at += 8;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (at !== request.length) throw new Error("trailing command menu bytes");
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
// Retained status-item lookup precedes admission's count check; active slots
|
|
128
|
+
// and successful OS results remain in native storage between calls.
|
|
129
|
+
if (request.length !== 80 || wire.getUint32(4, true) > 1 || wire.getUint32(12, true) > 8) throw new Error("invalid command status slots");
|
|
130
|
+
const admission = wire.getUint32(4, true) === 1, id = wire.getUint32(8, true), used = wire.getUint32(12, true);
|
|
131
|
+
const result = new Uint8Array(8), out = new DataView(result.buffer); out.setUint32(4, 0xffffffff, true);
|
|
132
|
+
for (let slot = 0; slot < 8; slot++) {
|
|
133
|
+
const at = 16 + slot * 8;
|
|
134
|
+
if (request[at]! > 1 || request[at + 1] !== 0 || request[at + 2] !== 0 || request[at + 3] !== 0) throw new Error("invalid command status slot");
|
|
135
|
+
}
|
|
136
|
+
for (let slot = 0; slot < 8; slot++) if (request[16 + slot * 8] === 1 && wire.getUint32(20 + slot * 8, true) === id) { result[0] = 1; out.setUint32(4, slot, true); return result; }
|
|
137
|
+
if (!admission) return result;
|
|
138
|
+
if (used < 8) for (let slot = 0; slot < 8; slot++) if (request[16 + slot * 8] === 0) { result[0] = 2; out.setUint32(4, slot, true); return result; }
|
|
139
|
+
result[0] = 3; return result;
|
|
140
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Shared composition recipes compiled by scriptc beside the app model.
|
|
2
|
+
* Operation 19 takes copied facts, exact u64 words and authored f32 words.
|
|
3
|
+
* Native assembles the selected nodes in its arena and retains IDs/routes.
|
|
4
|
+
*/
|
|
5
|
+
function nscvCompositionStateName(state: number): string {
|
|
6
|
+
return state === 0 ? "completed" : state === 1 ? "active" : "pending";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function nscvCompositionPolicy(request: Uint8Array): Uint8Array {
|
|
10
|
+
if (request.length !== 64 || request[0] !== 19 || request[1]! > 7 || request[2]! > 63 || request[3]! > 26)
|
|
11
|
+
throw new Error("invalid composition packet");
|
|
12
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
13
|
+
if (wire.getUint32(4, true) !== 0 || wire.getUint32(40, true) !== 0 || wire.getUint32(44, true) !== 0 || wire.getUint32(48, true) !== 0 || wire.getUint32(52, true) !== 0 || wire.getUint32(56, true) !== 0 || wire.getUint32(60, true) !== 0)
|
|
14
|
+
throw new Error("invalid composition reserved words");
|
|
15
|
+
const op = request[1]!, facts = request[2]!;
|
|
16
|
+
const allowed = op === 0 ? 1 : op === 1 ? 15 : op === 5 ? 31 : op === 6 ? 1 : 0;
|
|
17
|
+
if ((facts & ~allowed) !== 0) throw new Error("invalid composition facts");
|
|
18
|
+
const result = new Uint8Array(128), out = new DataView(result.buffer);
|
|
19
|
+
result[0] = request[3]!;
|
|
20
|
+
const float = (slot: number, value: number): void => out.setFloat32(32 + slot * 4, value, true);
|
|
21
|
+
const authored = (slot: number, at: number): void => out.setUint32(32 + slot * 4, wire.getUint32(at, true), true);
|
|
22
|
+
// The three integers are active, index and count. They never round through
|
|
23
|
+
// a JavaScript number, including max-u64 active navigation and step values.
|
|
24
|
+
const activeLo = wire.getUint32(8, true), activeHi = wire.getUint32(12, true);
|
|
25
|
+
const indexLo = wire.getUint32(16, true), indexHi = wire.getUint32(20, true);
|
|
26
|
+
const countLo = wire.getUint32(24, true), countHi = wire.getUint32(28, true);
|
|
27
|
+
if (op === 0) {
|
|
28
|
+
if (result[0] === 0) result[0] = 1; // input group
|
|
29
|
+
result[1] = facts & 1;
|
|
30
|
+
result[3] = (facts & 1) !== 0 ? 2 : 1;
|
|
31
|
+
} else if (op === 1) {
|
|
32
|
+
result[1] = facts & 7; // dissolve only unauthored entry chrome
|
|
33
|
+
if ((facts & 8) !== 0) float(6, 1);
|
|
34
|
+
else authored(6, 32);
|
|
35
|
+
} else if (op === 2) {
|
|
36
|
+
authored(0, 36);
|
|
37
|
+
float(2, 4); float(3, 8); float(4, 8); float(5, 8);
|
|
38
|
+
} else if (op === 3) {
|
|
39
|
+
if (result[0] === 0) result[0] = 11; // stepper list
|
|
40
|
+
float(0, 8);
|
|
41
|
+
if (countLo !== 0 || countHi !== 0) {
|
|
42
|
+
// Match the host checked count arithmetic before allocating children.
|
|
43
|
+
if (countHi >= 2147483648) throw new Error("composition child count overflow");
|
|
44
|
+
const low = (countLo * 2 - 1) >>> 0;
|
|
45
|
+
const high = (countHi * 2 + (countLo >= 2147483648 ? 1 : 0) - (countLo === 0 ? 1 : 0)) >>> 0;
|
|
46
|
+
out.setUint32(16, low, true); out.setUint32(20, high, true);
|
|
47
|
+
}
|
|
48
|
+
} else if (op === 4) {
|
|
49
|
+
const earlier = indexHi < activeHi || indexHi === activeHi && indexLo < activeLo;
|
|
50
|
+
const same = indexHi === activeHi && indexLo === activeLo;
|
|
51
|
+
result[2] = earlier ? 0 : same ? 1 : 2;
|
|
52
|
+
result[4] = result[2] === 2 ? 3 : 1; // outline / primary
|
|
53
|
+
result[1] = (result[2] === 0 ? 1 : 0) | (same ? 2 : 0) | (result[2] === 2 ? 4 : 0);
|
|
54
|
+
float(0, 6);
|
|
55
|
+
const suffix = new TextEncoder().encode(nscvCompositionStateName(result[2]!));
|
|
56
|
+
result[100] = suffix.length;
|
|
57
|
+
for (let i = 0; i < suffix.length; i++) result[104 + i] = suffix[i]!;
|
|
58
|
+
} else if (op === 5) {
|
|
59
|
+
result[0] = 12; // timeline item
|
|
60
|
+
result[1] = facts & 15;
|
|
61
|
+
result[3] = 1 + ((facts & 2) !== 0 ? 1 : 0) + ((facts & 4) !== 0 ? 1 : 0);
|
|
62
|
+
float(7, (facts & 16) !== 0 ? 10 : 0); float(8, (facts & 16) !== 0 ? 10 : 0);
|
|
63
|
+
float(9, (facts & 1) !== 0 ? 4 : 0); float(10, 1); float(11, 1);
|
|
64
|
+
float(12, 1); float(13, 2); float(14, 10); float(15, 8); float(16, 0.9);
|
|
65
|
+
} else if (op === 7) {
|
|
66
|
+
if (result[0] === 0) result[0] = 11;
|
|
67
|
+
authored(0, 36);
|
|
68
|
+
} else {
|
|
69
|
+
if (result[0] === 0) result[0] = 1; // navigation group
|
|
70
|
+
if (countLo !== 0 || countHi !== 0) {
|
|
71
|
+
const lastLo = (countLo - 1) >>> 0, lastHi = (countHi - (countLo === 0 ? 1 : 0)) >>> 0;
|
|
72
|
+
const beyond = activeHi > lastHi || activeHi === lastHi && activeLo > lastLo;
|
|
73
|
+
out.setUint32(8, beyond ? lastLo : activeLo, true);
|
|
74
|
+
out.setUint32(12, beyond ? lastHi : activeHi, true);
|
|
75
|
+
out.setUint32(16, (facts & 1) !== 0 ? countLo : 1, true);
|
|
76
|
+
out.setUint32(20, (facts & 1) !== 0 ? countHi : 0, true);
|
|
77
|
+
}
|
|
78
|
+
result[1] = facts & 1;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function nscvCompositionRequest(op: number, facts: number, role: number, active: number, index: number, count: number, grow = 0, gap = 0): Uint8Array {
|
|
84
|
+
const request = new Uint8Array(64), wire = new DataView(request.buffer);
|
|
85
|
+
request[0] = 19; request[1] = op; request[2] = facts; request[3] = role;
|
|
86
|
+
for (let i = 0; i < 3; i++) {
|
|
87
|
+
const value = i === 0 ? active : i === 1 ? index : count;
|
|
88
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error("composition requires nonnegative exact integers");
|
|
89
|
+
wire.setUint32(8 + i * 8, value % 4294967296, true);
|
|
90
|
+
wire.setUint32(12 + i * 8, Math.floor(value / 4294967296), true);
|
|
91
|
+
}
|
|
92
|
+
wire.setFloat32(32, grow, true); wire.setFloat32(36, gap, true);
|
|
93
|
+
return nscvCompositionPolicy(request);
|
|
94
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** Portable widget construction, compiled by scriptc with the app.
|
|
2
|
+
* Operation 17 owns element defaults, finalization, synthesized children and
|
|
3
|
+
* builtin composition. Packets contain copied f32 values and presence bits;
|
|
4
|
+
* native retains structural identities, typed routes and generation arenas.
|
|
5
|
+
*/
|
|
6
|
+
function nscvConstructionDefaults(kind: number, size: number): readonly number[] {
|
|
7
|
+
if (kind === 18) return [1, size === 1 ? 16 : 24, size === 1 ? 16 : 24, 12, 0];
|
|
8
|
+
if (kind === 17) return [1, size === 1 ? 14 : size === 2 ? 18 : 16, size === 1 ? 14 : size === 2 ? 18 : 16, 12, 0];
|
|
9
|
+
if (kind === 15) return [1, 10, 12, 0, 0];
|
|
10
|
+
if (kind === 12) return [1, 3, 3, 0, 2];
|
|
11
|
+
return [0, 0, 0, 0, 0];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function nscvConstructionPolicy(request: Uint8Array): Uint8Array {
|
|
15
|
+
if (request.length < 8 || request[0] !== 17) throw new Error("invalid construction packet");
|
|
16
|
+
const op = request[1]!;
|
|
17
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
18
|
+
if (op === 0) {
|
|
19
|
+
// 40 bytes: kind/size/checked-selected-padding/cross; seven f32s;
|
|
20
|
+
// target max-number signed-zero facts. Result is a complete 44-byte plan.
|
|
21
|
+
if (request.length !== 40 || request[2]! > 62 || request[3]! > 5 || request[4]! > 7 || request[5]! > 3 || request[6] !== 0 || request[7] !== 0 || wire.getUint32(36, true) > 3) throw new Error("invalid element construction");
|
|
22
|
+
const kind = request[2]!, size = request[3]!, flags = request[4]!;
|
|
23
|
+
const defaults = nscvConstructionDefaults(kind, size);
|
|
24
|
+
const result = new Uint8Array(44), out = new DataView(result.buffer);
|
|
25
|
+
const selected = (flags & 3) !== 0;
|
|
26
|
+
result[0] = selected ? 1 : 0;
|
|
27
|
+
result[1] = request[5] === 0 && defaults[0] === 1 ? defaults[4]! : request[5]!;
|
|
28
|
+
result[2] = (flags & 4) === 0 && defaults[0] === 1 ? 1 : 0;
|
|
29
|
+
out.setFloat32(4, wire.getFloat32(28, true) === 0 && defaults[0] === 1 ? defaults[3]! : wire.getFloat32(28, true), true);
|
|
30
|
+
const padding = (flags & 4) !== 0 ? wire.getFloat32(24, true) : 0;
|
|
31
|
+
for (let i = 0; i < 4; i++) out.setFloat32(8 + i * 4, result[2] === 1 ? defaults[i % 2 === 0 ? 1 : 2]! : padding, true);
|
|
32
|
+
const width = wire.getFloat32(8, true), minimum = wire.getFloat32(16, true);
|
|
33
|
+
let source = Number.isNaN(width) ? 16 : Number.isNaN(minimum) || width > minimum ? 8 : 16;
|
|
34
|
+
if (width === 0 && minimum === 0) {
|
|
35
|
+
const leftNegative = wire.getUint32(8, true) === 2147483648;
|
|
36
|
+
const rightNegative = wire.getUint32(16, true) === 2147483648;
|
|
37
|
+
const target = wire.getUint32(36, true);
|
|
38
|
+
if (leftNegative !== rightNegative) source = leftNegative ? ((target & 1) !== 0 ? 8 : 16) : ((target & 2) !== 0 ? 16 : 8);
|
|
39
|
+
}
|
|
40
|
+
out.setUint32(24, wire.getUint32(source, true), true);
|
|
41
|
+
out.setUint32(28, wire.getUint32(12, true), true);
|
|
42
|
+
if (kind !== 16) {
|
|
43
|
+
out.setUint32(32, wire.getUint32(width > 0 ? 8 : 20, true), true);
|
|
44
|
+
out.setUint32(36, wire.getUint32(12, true), true);
|
|
45
|
+
}
|
|
46
|
+
if (kind === 48 && selected) out.setFloat32(40, 1, true);
|
|
47
|
+
else out.setUint32(40, wire.getUint32(32, true), true);
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
if (op === 1) {
|
|
51
|
+
// 592 bytes: kind/wrap/facts, seven token references, complete action
|
|
52
|
+
// and handler masks, style presence/values, 28 colors and five radii.
|
|
53
|
+
if (request.length !== 592 || request[2]! > 62 || request[3]! > 2 || request[4]! > 31 || request[5] !== 0 || request[6] !== 0 || request[7] !== 0 || request[15] !== 0 || wire.getUint16(16, true) > 2047 || wire.getUint16(18, true) > 1023 || wire.getUint32(20, true) > 127) throw new Error("invalid final construction");
|
|
54
|
+
for (let i = 8; i < 15; i++) if (request[i] !== 255 && request[i]! >= (i === 14 ? 5 : 28)) throw new Error("invalid construction token");
|
|
55
|
+
const result = new Uint8Array(108), out = new DataView(result.buffer);
|
|
56
|
+
for (let i = 0; i < 104; i++) result[4 + i] = request[20 + i]!;
|
|
57
|
+
let actions = wire.getUint16(16, true), presence = wire.getUint32(20, true);
|
|
58
|
+
const handlers = wire.getUint16(18, true), kind = request[2]!, facts = request[4]!;
|
|
59
|
+
if ((handlers & (1 | 4 | 16)) !== 0) actions |= 2;
|
|
60
|
+
if ((handlers & 2) !== 0) actions |= 256;
|
|
61
|
+
if ((handlers & 8) !== 0) actions |= 4;
|
|
62
|
+
if ((handlers & 128) !== 0) actions |= 32;
|
|
63
|
+
if (kind === 51 && (handlers & (256 | 512)) !== 0) actions |= 8 | 16;
|
|
64
|
+
out.setUint16(0, actions, true);
|
|
65
|
+
result[2] = (kind === 26 && request[3] === 2 && (facts & 1) === 0 && (facts & 2) !== 0 ? 1 : 0) |
|
|
66
|
+
((facts & 16) !== 0 || kind === 26 && request[3] === 1 ? 2 : 0) |
|
|
67
|
+
(kind === 57 && (facts & 4) !== 0 ? 4 : 0) |
|
|
68
|
+
((facts & 8) !== 0 || (handlers & (32 | 64)) !== 0 ? 8 : 0);
|
|
69
|
+
for (let i = 0; i < 6; i++) {
|
|
70
|
+
const token = request[8 + i]!;
|
|
71
|
+
if ((presence & (1 << i)) === 0 && token !== 255) {
|
|
72
|
+
let source = token;
|
|
73
|
+
if (source >= 6 && source <= 12 && wire.getFloat32(124 + source * 16 + 12, true) === 0) source = source === 7 ? 5 : 4;
|
|
74
|
+
for (let j = 0; j < 16; j++) result[8 + i * 16 + j] = request[124 + source * 16 + j]!;
|
|
75
|
+
presence |= 1 << i;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const radius = request[14]!;
|
|
79
|
+
if ((presence & 64) === 0 && radius !== 255) {
|
|
80
|
+
if (radius === 4) out.setFloat32(104, 0, true);
|
|
81
|
+
else out.setUint32(104, wire.getUint32(572 + radius * 4, true), true);
|
|
82
|
+
presence |= 64;
|
|
83
|
+
}
|
|
84
|
+
out.setUint32(4, presence, true);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
if (op === 2) {
|
|
88
|
+
// 24 bytes: divider/menu-item/menu-surface operation and disabled,
|
|
89
|
+
// separator/enabled/point facts; value and pointer coordinates.
|
|
90
|
+
if (request.length !== 24 || request[2]! > 2 || request[3]! > 15 || wire.getUint32(4, true) !== 0 || wire.getUint32(20, true) !== 0) throw new Error("invalid synthesized construction");
|
|
91
|
+
const kind = request[2]!, facts = request[3]!;
|
|
92
|
+
const label = new TextEncoder().encode(kind === 0 ? "Split divider" : kind === 2 ? "Context menu" : "");
|
|
93
|
+
const result = new Uint8Array(24 + label.length), out = new DataView(result.buffer);
|
|
94
|
+
result[0] = kind === 0 ? 58 : kind === 2 ? 25 : (facts & 2) !== 0 ? 53 : 41;
|
|
95
|
+
result[1] = kind === 0 ? facts & 1 : kind === 1 && (facts & 2) === 0 && (facts & 4) === 0 ? 1 : 0;
|
|
96
|
+
result[2] = kind === 1 && (facts & 2) === 0 && (facts & 4) !== 0 ? 1 : 0;
|
|
97
|
+
result[3] = kind === 2 && (facts & 8) !== 0 ? 1 : 0;
|
|
98
|
+
if (kind === 0) out.setUint32(4, wire.getUint32(8, true), true);
|
|
99
|
+
out.setFloat32(8, result[3] === 1 ? 0 : 4, true);
|
|
100
|
+
if (result[3] === 1) { out.setUint32(12, wire.getUint32(12, true), true); out.setUint32(16, wire.getUint32(16, true), true); }
|
|
101
|
+
// Placement/alignment are below/start (zero); the final byte carries
|
|
102
|
+
// the structural menu-item identity admission, separate from enabled.
|
|
103
|
+
result[22] = kind === 1 && (facts & 2) === 0 ? 1 : 0;
|
|
104
|
+
result[23] = kind === 2 ? 1 : 0;
|
|
105
|
+
for (let i = 0; i < label.length; i++) result[24 + i] = label[i]!;
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
if (op === 3) {
|
|
109
|
+
// Builtin extensions retain zero-sentinel spacing independently of
|
|
110
|
+
// element nullable padding. No per-widget allocation or callback.
|
|
111
|
+
if (request.length !== 36 || request[2]! > 31 || request[3] !== 255 && request[3]! > 5 || request[4] !== 255 && request[4]! > 5 || request[5]! > 26 || request[6]! > 3 || request[7]! > 3) throw new Error("invalid builtin construction");
|
|
112
|
+
const roots = [14, 17, 29, 30, 8, 15, 31, 9, 18, 47, 38, 19, 20, 25, 35, 10, 52, 11, 16, 34, 53, 21, 54, 51, 55, 49, 5, 12, 39, 32, 13, 40];
|
|
113
|
+
const roles = [1, 1, 4, 2, 1, 1, 5, 1, 1, 17, 6, 8, 8, 9, 6, 1, 22, 19, 1, 5, 0, 8, 0, 21, 22, 20, 14, 1, 6, 5, 1, 7];
|
|
114
|
+
const component = request[2]!, root = roots[component]!;
|
|
115
|
+
const size = request[4] === 255 ? (component === 24 ? 1 : 0) : request[4]!;
|
|
116
|
+
const result = new Uint8Array(36), out = new DataView(result.buffer);
|
|
117
|
+
for (let i = 8; i < 36; i++) result[i] = request[i]!;
|
|
118
|
+
result[0] = root;
|
|
119
|
+
result[1] = request[3] === 255 ? (component === 6 ? 1 : component === 19 ? 3 : component === 29 ? 4 : 0) : request[3]!;
|
|
120
|
+
result[2] = size; result[3] = request[5] === 0 ? roles[component]! : request[5]!;
|
|
121
|
+
result[4] = request[6]!; result[5] = request[7]! & 1; result[6] = (request[7]! >> 1) & 1;
|
|
122
|
+
const defaults = nscvConstructionDefaults(root, size);
|
|
123
|
+
let applies = defaults[0] === 1, vertical = defaults[1]!, horizontal = defaults[2]!, gap = defaults[3]!, cross = defaults[4]!, clip = applies && root !== 12, minWidth = 0, minHeight = 0;
|
|
124
|
+
if (!applies) {
|
|
125
|
+
applies = component === 18 || component === 11 || component === 12 || component === 21 || component === 13 || component === 15 || component === 4 || component === 7 || component === 17 || component === 30 || component === 0 || component === 26 || component === 28 || component === 20 || component === 22;
|
|
126
|
+
if (component === 18) { vertical = 12; horizontal = 12; gap = 8; clip = true; }
|
|
127
|
+
else if (component === 11 || component === 12 || component === 21) { vertical = 20; horizontal = 20; gap = 16; clip = true; }
|
|
128
|
+
else if (component === 13) { vertical = 4; horizontal = 4; gap = 2; clip = true; }
|
|
129
|
+
else if (component === 15) { gap = 2; cross = 2; }
|
|
130
|
+
else if (component === 4 || component === 7 || component === 17 || component === 30) { gap = 4; cross = 2; }
|
|
131
|
+
else if (component === 0 || component === 26) clip = true;
|
|
132
|
+
else if (component === 28) { minWidth = 160; minHeight = 80; }
|
|
133
|
+
else if (component === 20) { minWidth = 1; minHeight = 1; }
|
|
134
|
+
else if (component === 22) { minWidth = 120; minHeight = 20; }
|
|
135
|
+
}
|
|
136
|
+
if (applies) {
|
|
137
|
+
if (wire.getFloat32(8, true) === 0 && wire.getFloat32(12, true) === 0 && wire.getFloat32(16, true) === 0 && wire.getFloat32(20, true) === 0) {
|
|
138
|
+
for (let i = 0; i < 4; i++) out.setFloat32(8 + i * 4, i % 2 === 0 ? vertical : horizontal, true);
|
|
139
|
+
result[6] = 1;
|
|
140
|
+
}
|
|
141
|
+
if (wire.getFloat32(24, true) === 0) out.setFloat32(24, gap, true);
|
|
142
|
+
if (request[6] === 0) result[4] = cross;
|
|
143
|
+
if (result[5] === 0) result[5] = clip ? 1 : 0;
|
|
144
|
+
if (wire.getFloat32(28, true) === 0 && wire.getFloat32(32, true) === 0) { out.setFloat32(28, minWidth, true); out.setFloat32(32, minHeight, true); }
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
throw new Error("unknown construction operation");
|
|
149
|
+
}
|
|
@@ -78,7 +78,7 @@ export interface ContractInput {
|
|
|
78
78
|
|
|
79
79
|
/// A JSON string literal: quoted and escaped exactly as the extractor's
|
|
80
80
|
/// `js` helper spells it (JSON.stringify would spell control characters
|
|
81
|
-
/// differently
|
|
81
|
+
/// differently, such as the short escape for a backspace byte).
|
|
82
82
|
function js(text: string): string {
|
|
83
83
|
let out = '"';
|
|
84
84
|
for (const ch of text) {
|
|
@@ -167,7 +167,7 @@ class ContractEmitter {
|
|
|
167
167
|
case "optional":
|
|
168
168
|
return { k: "optional", inner: this.reflect(t.inner, decl, top) };
|
|
169
169
|
case "void":
|
|
170
|
-
throw new ContractError(
|
|
170
|
+
throw new ContractError(`a contract slot resolved to no subset type: ${decl?.getText() ?? "unnamed slot"}`, decl ?? this.entryFile);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -465,6 +465,10 @@ class ContractEmitter {
|
|
|
465
465
|
if (helperNames.includes("statusItem") && !model.includes("statusItem")) model.push("statusItem");
|
|
466
466
|
if (helperNames.includes("statusItems") && !model.includes("statusItems")) model.push("statusItems");
|
|
467
467
|
if (helperNames.includes("windows") && !model.includes("windows")) model.push("windows");
|
|
468
|
+
if (helperNames.includes("webPanes") && !model.includes("webPanes")) model.push("webPanes");
|
|
469
|
+
for (const name of ["canvasIcons", "canvasFrameMsg", "canvasChrome", "canvasChromeSuffix", "canvasAnimations", "bootImageMsg", "sliderStateMsg"]) {
|
|
470
|
+
if (helperNames.includes(name) && !model.includes(name)) model.push(name);
|
|
471
|
+
}
|
|
468
472
|
return { model, msg };
|
|
469
473
|
}
|
|
470
474
|
|
|
@@ -528,7 +532,9 @@ class ContractEmitter {
|
|
|
528
532
|
const helperReturns = helperDecls.map((h) => {
|
|
529
533
|
const ret = this.table.resolveTypeNode(h.decl.type!);
|
|
530
534
|
this.collect(ret, h.decl, "helpers", h.name);
|
|
531
|
-
|
|
535
|
+
const params = h.decl.parameters.slice(1).map(p => ({ decl: p, type: this.table.resolveTypeNode(p.type!) }));
|
|
536
|
+
for (const p of params) this.collect(p.type, p.decl, "helpers", h.name);
|
|
537
|
+
return { name: h.name, decl: h.decl, ret, params };
|
|
532
538
|
});
|
|
533
539
|
|
|
534
540
|
// Phase 2: sections.
|
|
@@ -588,7 +594,12 @@ class ContractEmitter {
|
|
|
588
594
|
if (helperCount > 0) helpers += ",\n ";
|
|
589
595
|
const reflected = this.reflect(h.ret, h.decl, true);
|
|
590
596
|
if (this.spellsI64(reflected)) this.appendSlot(`helpers.${h.name}.return`);
|
|
591
|
-
|
|
597
|
+
const params = h.params.map((p, index) => {
|
|
598
|
+
const ref = this.reflect(p.type, p.decl, true);
|
|
599
|
+
if (this.spellsI64(ref)) this.appendSlot(`helpers.${h.name}.params[${index}]`);
|
|
600
|
+
return this.typeRefJson(ref);
|
|
601
|
+
});
|
|
602
|
+
helpers += `{"name": ${js(h.name)}, "params": [${params.join(", ")}], "returns": ${this.typeRefJson(reflected)}, "arena": false}`;
|
|
592
603
|
helperCount += 1;
|
|
593
604
|
}
|
|
594
605
|
|
|
@@ -597,7 +608,13 @@ class ContractEmitter {
|
|
|
597
608
|
const msgUnbound = unbound.msg.map((n) => js(n)).join(", ");
|
|
598
609
|
|
|
599
610
|
// Channels: export presence IS the wiring decision.
|
|
600
|
-
const
|
|
611
|
+
const command = this.entryExportedFunction("commandMsg");
|
|
612
|
+
const hasCommand = command !== null;
|
|
613
|
+
const commandParam = command?.parameters[0]?.type;
|
|
614
|
+
const commandInput = commandParam ? this.table.resolveTypeNode(commandParam).k : null;
|
|
615
|
+
if (command && (command.parameters.length !== 1 || (commandInput !== "bytes" && commandInput !== "string")))
|
|
616
|
+
throw new ContractError("commandMsg requires one string or Uint8Array command name", command);
|
|
617
|
+
const commandBytes = commandInput === "bytes";
|
|
601
618
|
const hasFrame = this.entryExportedFunction("frameMsg") !== null;
|
|
602
619
|
const hasKey = this.entryExportedFunction("keyMsg") !== null;
|
|
603
620
|
const hasPinch = this.entryExportedFunction("pinchMsg") !== null;
|
|
@@ -626,7 +643,7 @@ class ContractEmitter {
|
|
|
626
643
|
'"dispatch_record", "dispatch_text_input", "dispatch_scroll_state", ' +
|
|
627
644
|
'"subscriptions", "model_snapshot", "persist_snapshot", "restore_model", "migrate_model", "helper_call"';
|
|
628
645
|
if (hasCommand) abiExports += ', "command_msg"';
|
|
629
|
-
if (hasFrame) abiExports += ', "frame_msg"';
|
|
646
|
+
if (hasFrame) abiExports += ', "frame_msg", "frame_msg_ns"';
|
|
630
647
|
if (hasKey) abiExports += ', "key_msg"';
|
|
631
648
|
if (hasPinch) abiExports += ', "pinch_msg"';
|
|
632
649
|
if (hasDrop) abiExports += ', "drop_msg"';
|
|
@@ -669,7 +686,7 @@ class ContractEmitter {
|
|
|
669
686
|
return (
|
|
670
687
|
"{\n" +
|
|
671
688
|
' "format": 1,\n' +
|
|
672
|
-
' "wire_version":
|
|
689
|
+
' "wire_version": 10,\n' +
|
|
673
690
|
' "abi_version": 2,\n' +
|
|
674
691
|
' "compiler_version": "0.0.1",\n' +
|
|
675
692
|
` "entry": ${js(this.entry)},\n` +
|
|
@@ -689,6 +706,7 @@ class ContractEmitter {
|
|
|
689
706
|
` "has_migrate": ${boolJson(hasMigrate)},\n` +
|
|
690
707
|
' "channels": {\n' +
|
|
691
708
|
` "command_msg": ${boolJson(hasCommand)},\n` +
|
|
709
|
+
(commandBytes ? ' "command_bytes": true,\n' : "") +
|
|
692
710
|
` "frame_msg": ${boolJson(hasFrame)},\n` +
|
|
693
711
|
` "key_msg": ${boolJson(hasKey)},\n` +
|
|
694
712
|
` "pinch_msg": ${boolJson(hasPinch)},\n` +
|