@native-sdk/cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1796 -83
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Shell installation decisions. Native owns descriptor bytes, storage, and OS calls. */
|
|
2
|
+
function nscvShellCoordination(request: Uint8Array): Uint8Array {
|
|
3
|
+
if (request.length < 64 || request[0] !== 84 || request[1] !== 1 || request[2]! > 7 || request[3] !== 0)
|
|
4
|
+
throw new Error("invalid shell coordination header");
|
|
5
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
6
|
+
const mode = request[2]!, facts = w.getUint32(4, true), count = w.getUint32(8, true), cursor = w.getUint32(12, true);
|
|
7
|
+
for (let i = 48; i < 64; i++) if (request[i] !== 0) throw new Error("invalid shell coordination padding");
|
|
8
|
+
let status = 0, decisions = 0, selected = 4294967295;
|
|
9
|
+
const choices: number[] = [];
|
|
10
|
+
if (mode === 0) {
|
|
11
|
+
if (facts > 1 || count > 16 || cursor > 7 || cursor !== 0 && count !== 1) throw new Error("invalid shell scene bounds");
|
|
12
|
+
let at = 64, needsSource = false;
|
|
13
|
+
for (let i = 0; i < count; i++) {
|
|
14
|
+
if (at + 4 > request.length || request[at]! > 1 || request[at + 1]! > 1) throw new Error("invalid shell window");
|
|
15
|
+
const hidden = request[at] === 1, explicit = request[at + 1] === 1, views = w.getUint16(at + 2, true);
|
|
16
|
+
if (views > 128) throw new Error("invalid shell view count");
|
|
17
|
+
at += 4;
|
|
18
|
+
let hasMain = (cursor & 1) !== 0, hasWeb = (cursor & 2) !== 0, hasGpu = (cursor & 4) !== 0;
|
|
19
|
+
for (let j = 0; j < views; j++) {
|
|
20
|
+
if (at + 13 > request.length || request[at]! > 18) throw new Error("invalid shell view");
|
|
21
|
+
const kind = request[at]!, length = w.getUint32(at + 1, true);
|
|
22
|
+
if (kind === 0) {
|
|
23
|
+
hasWeb = true;
|
|
24
|
+
if (length === 4 && w.getUint32(at + 5, true) === 0 && request[at + 9] === 109 && request[at + 10] === 97 && request[at + 11] === 105 && request[at + 12] === 110) hasMain = true;
|
|
25
|
+
}
|
|
26
|
+
if (kind === 17) hasGpu = true;
|
|
27
|
+
at += 13;
|
|
28
|
+
}
|
|
29
|
+
const usesSource = hasMain || !(hasGpu && !hasWeb) && facts === 0;
|
|
30
|
+
needsSource = needsSource || hasMain;
|
|
31
|
+
// Carry only observations so an app callback may replace a validated
|
|
32
|
+
// view slice with an oversized one before the ordinary creation gate.
|
|
33
|
+
choices.push((hidden ? 1 : hasGpu ? 2 : 0) | (usesSource ? 4 : 0) | (explicit ? 8 : 0) | ((hasMain ? 1 : 0) | (hasWeb ? 2 : 0) | (hasGpu ? 4 : 0)) << 4);
|
|
34
|
+
}
|
|
35
|
+
if (at !== request.length) throw new Error("invalid shell scene tail");
|
|
36
|
+
decisions = count > 0 && (needsSource || facts === 0) ? 1 : 0;
|
|
37
|
+
} else if (mode === 5) {
|
|
38
|
+
if (facts !== 0 || count > 16 || request.length !== 64 + count * 8) throw new Error("invalid shell binding bounds");
|
|
39
|
+
for (let i = 0; i < count; i++) {
|
|
40
|
+
if (w.getUint32(16, true) === w.getUint32(64 + i * 8, true) && w.getUint32(20, true) === w.getUint32(68 + i * 8, true)) { selected = i; break; }
|
|
41
|
+
}
|
|
42
|
+
if (selected === 4294967295) {
|
|
43
|
+
if (count === 16) status = 1;
|
|
44
|
+
else { selected = count; decisions = 1; }
|
|
45
|
+
}
|
|
46
|
+
} else if (mode === 7) {
|
|
47
|
+
if (facts > 5 || (facts & 2) !== 0 || cursor > 1 || count > 128 || request.length !== 64 + count) throw new Error("invalid shell presentation bounds");
|
|
48
|
+
let hasGpu = cursor === 1;
|
|
49
|
+
for (let i = 0; i < count; i++) {
|
|
50
|
+
if (request[64 + i]! > 18) throw new Error("invalid shell presentation kind");
|
|
51
|
+
if (request[64 + i] === 17) hasGpu = true;
|
|
52
|
+
}
|
|
53
|
+
decisions = ((facts & 1) !== 0 ? 1 : hasGpu ? 2 : 0) | ((facts & 4) !== 0 ? 4 : 0) | (hasGpu ? 8 : 0);
|
|
54
|
+
} else {
|
|
55
|
+
if (request.length !== 64) throw new Error("invalid shell coordination tail");
|
|
56
|
+
if (mode === 1) {
|
|
57
|
+
// Ordered, chunked opaque-byte equality; no native equality verdict.
|
|
58
|
+
if (facts > 1 || count > 16 || cursor !== 0) throw new Error("invalid shell comparison bounds");
|
|
59
|
+
decisions = facts;
|
|
60
|
+
for (let i = 0; i < count; i++) if (request[16 + i] !== request[32 + i]) decisions = 0;
|
|
61
|
+
} else if (mode === 2) {
|
|
62
|
+
if (facts > 7 || w.getUint32(16, true) > 18) throw new Error("invalid shell application facts");
|
|
63
|
+
const update = (facts & 1) !== 0, main = (facts & 2) !== 0 && w.getUint32(16, true) === 0, missing = (facts & 4) !== 0;
|
|
64
|
+
decisions = (main ? 1 : 0) | (!update && !main ? 2 : 4) | (update && missing ? 8 : 0);
|
|
65
|
+
} else if (mode === 3) {
|
|
66
|
+
if (facts !== 0 || count > 128 || cursor > count) throw new Error("invalid shell rollback bounds");
|
|
67
|
+
if (cursor > 0) selected = cursor - 1;
|
|
68
|
+
} else if (mode === 4) {
|
|
69
|
+
if (facts > 3) throw new Error("invalid shell restoration facts");
|
|
70
|
+
let different = (facts & 2) !== 0;
|
|
71
|
+
for (let i = 0; i < 4; i++) if (w.getFloat32(16 + i * 4, true) !== w.getFloat32(32 + i * 4, true)) different = true;
|
|
72
|
+
decisions = (facts & 1) === 0 ? 0 : (different ? 1 : 0) | (count !== cursor ? 2 : 0);
|
|
73
|
+
} else if (mode === 6) {
|
|
74
|
+
if (facts > 7 || cursor > 2 || cursor !== 2 && w.getUint32(16, true) > 18 || w.getUint32(28, true) > 32 || w.getUint32(32, true) > 16) throw new Error("invalid shell admission facts");
|
|
75
|
+
const kind = w.getUint32(16, true), main = kind === 0 && (facts & 4) !== 0;
|
|
76
|
+
if ((facts & 1) !== 0 || !main && (facts & 2) !== 0) status = 2;
|
|
77
|
+
else if (!main) decisions = kind === 0 ? 1 : 2;
|
|
78
|
+
if (cursor === 1) {
|
|
79
|
+
if (w.getUint32(20, true) > 32 - w.getUint32(28, true)) status = 3;
|
|
80
|
+
else if (w.getUint32(24, true) > 16 - w.getUint32(32, true)) status = 4;
|
|
81
|
+
decisions = 0;
|
|
82
|
+
} else if (cursor === 2) {
|
|
83
|
+
status = w.getUint32(20, true) !== 0 || w.getUint32(16, true) > 128 ? 3 : 0;
|
|
84
|
+
decisions = 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const result = new Uint8Array(24 + choices.length * 4), out = new DataView(result.buffer);
|
|
89
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true);
|
|
90
|
+
out.setUint32(12, decisions, true); out.setUint32(16, selected, true); out.setUint32(20, choices.length, true);
|
|
91
|
+
for (let i = 0; i < choices.length; i++) out.setUint32(24 + i * 4, choices[i]!, true);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
@@ -48,6 +48,17 @@ try {
|
|
|
48
48
|
const sdkSource = generateCoreSurface(fs.readFileSync(sdkIn!, "utf8"), analysis);
|
|
49
49
|
fs.writeFileSync(sdkOut!, sdkSource);
|
|
50
50
|
const sdkDir = path.dirname(sdkIn!);
|
|
51
|
+
// Generated core surfaces retain these relative SDK imports. Carry
|
|
52
|
+
// their complete implementation and declaration siblings with each
|
|
53
|
+
// projection, including the editor's app-specific relational overlay.
|
|
54
|
+
const siblingDirs = new Set([path.dirname(sdkOut!), path.dirname(staticOut!), ...(dtsOut ? [path.dirname(dtsOut)] : [])]);
|
|
55
|
+
for (const destination of siblingDirs) for (const name of ["bytes", "events", "text", "theme", "internal/image_identity", "internal/markdown_policy"]) {
|
|
56
|
+
for (const extension of [".ts", ".d.ts"]) {
|
|
57
|
+
const output = path.join(destination, name + extension);
|
|
58
|
+
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
59
|
+
fs.copyFileSync(path.join(sdkDir, name + extension), output);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
51
62
|
for (const [source, destination] of [
|
|
52
63
|
["events.ts", sdkEventsOut!],
|
|
53
64
|
["text.ts", sdkTextOut!],
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/** Portable declaration admission. Native supplies bounded copied bytes, f32
|
|
2
|
+
* values and opaque IDs; it owns retained storage and OS capability execution.
|
|
3
|
+
* Oversized cross-row identity lists are compared in bounded copied chunks.
|
|
4
|
+
*/
|
|
5
|
+
interface NscvStatusField { readonly statusByteAt: number; readonly statusByteCount: number; readonly statusNextAt: number }
|
|
6
|
+
interface NscvStatusPresentation { readonly title: NscvStatusField; readonly width: number; readonly opacity: number; readonly font: number; readonly statusNextAt: number }
|
|
7
|
+
interface NscvStatusOption { readonly statusIdentity: number; readonly selected: boolean; readonly overflowDuplicate: boolean; readonly label: NscvStatusField; readonly command: NscvStatusField }
|
|
8
|
+
interface NscvStatusMetric { readonly primary: NscvStatusField; readonly secondary: NscvStatusField; readonly accessibility: NscvStatusField }
|
|
9
|
+
interface NscvStatusChart { readonly statusValueCount: number; readonly minimum: number; readonly maximum: number; readonly values: readonly number[]; readonly leading: NscvStatusField; readonly trailing: NscvStatusField; readonly accessibility: NscvStatusField }
|
|
10
|
+
interface NscvStatusRow {
|
|
11
|
+
readonly statusIdentity: number; readonly role: number; readonly separator: boolean; readonly modifiers: number;
|
|
12
|
+
readonly label: NscvStatusField; readonly command: NscvStatusField; readonly detail: NscvStatusField; readonly key: NscvStatusField;
|
|
13
|
+
readonly segmented: boolean; readonly statusOptionCount: number; readonly options: readonly NscvStatusOption[];
|
|
14
|
+
readonly metric: NscvStatusMetric | null; readonly chart: NscvStatusChart | null;
|
|
15
|
+
}
|
|
16
|
+
function nscvStatusField(input: Uint8Array, at: number, limit: number): NscvStatusField {
|
|
17
|
+
if (at + 4 > input.length) throw new Error("truncated status field length");
|
|
18
|
+
const length = new DataView(input.buffer, input.byteOffset, input.byteLength).getUint32(at, true);
|
|
19
|
+
const next = at + 4 + Math.min(length, limit);
|
|
20
|
+
if (next > input.length) throw new Error("truncated status field bytes");
|
|
21
|
+
return { statusByteAt: at + 4, statusByteCount: length, statusNextAt: next };
|
|
22
|
+
}
|
|
23
|
+
function nscvStatusFieldError(input: Uint8Array, field: NscvStatusField, limit: number): number {
|
|
24
|
+
if (field.statusByteCount > limit) return 2; // TrayFieldTooLarge precedes NUL validation.
|
|
25
|
+
for (let i = 0; i < field.statusByteCount; i++) if (input[field.statusByteAt + i] === 0) return 1;
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
function nscvStatusCommandError(input: Uint8Array, field: NscvStatusField): number {
|
|
29
|
+
const at = field.statusByteAt, length = field.statusByteCount;
|
|
30
|
+
if (length === 0 || length > 128 || (length === 1 && input[at] === 46) || (length === 2 && input[at] === 46 && input[at + 1] === 46)) return 3;
|
|
31
|
+
for (let i = 0; i < length; i++) {
|
|
32
|
+
const byte = input[at + i]!;
|
|
33
|
+
if (byte === 0 || byte === 47 || byte === 92 || byte === 10 || byte === 13 || byte === 9) return 3;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
function nscvStatusAscii(input: Uint8Array, field: NscvStatusField, name: string): boolean {
|
|
38
|
+
const literal = new TextEncoder().encode(name);
|
|
39
|
+
if (field.statusByteCount !== literal.length) return false;
|
|
40
|
+
for (let i = 0; i < literal.length; i++) {
|
|
41
|
+
const byte = input[field.statusByteAt + i]!;
|
|
42
|
+
if ((byte >= 65 && byte <= 90 ? byte + 32 : byte) !== literal[i]) return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function nscvStatusShortcut(input: Uint8Array, field: NscvStatusField, modifiers: number): boolean {
|
|
47
|
+
const length = field.statusByteCount;
|
|
48
|
+
if (length === 0 || length > 32) return false;
|
|
49
|
+
if (length === 1) {
|
|
50
|
+
const c = input[field.statusByteAt]!;
|
|
51
|
+
const valid = (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || c === 61 || c === 45 || c === 44 || c === 46 || c === 47 || c === 59 || c === 39 || c === 91 || c === 93 || c === 92 || c === 96;
|
|
52
|
+
return valid && modifiers !== 0;
|
|
53
|
+
}
|
|
54
|
+
for (const key of ["escape", "enter", "tab", "space", "backspace", "arrowleft", "arrowright", "arrowup", "arrowdown", "delete", "home", "end", "pageup", "pagedown", "insert", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12"]) {
|
|
55
|
+
if (nscvStatusAscii(input, field, key)) return modifiers !== 0 || !(key === "space" || key === "enter" || key === "tab" || key === "backspace");
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
function nscvStatusPresentation(input: Uint8Array, at: number): NscvStatusPresentation {
|
|
60
|
+
const title = nscvStatusField(input, at, 64); at = title.statusNextAt;
|
|
61
|
+
if (at + 12 > input.length) throw new Error("truncated status presentation");
|
|
62
|
+
const data = new DataView(input.buffer, input.byteOffset, input.byteLength);
|
|
63
|
+
return { title, width: data.getFloat32(at, true), opacity: data.getFloat32(at + 4, true), font: data.getFloat32(at + 8, true), statusNextAt: at + 12 };
|
|
64
|
+
}
|
|
65
|
+
function nscvStatusPresentationError(input: Uint8Array, value: NscvStatusPresentation): number {
|
|
66
|
+
const title = nscvStatusFieldError(input, value.title, 64);
|
|
67
|
+
if (title !== 0) return title;
|
|
68
|
+
if (!Number.isFinite(value.width) || value.width < 0 || !Number.isFinite(value.opacity) || value.opacity < 0 || value.opacity > 1 || !Number.isFinite(value.font) || value.font < 0 || value.font > 64) return 1;
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
function nscvStatusMenuError(input: Uint8Array, count: number, rows: readonly NscvStatusRow[]): number {
|
|
72
|
+
if (count > 32) return 1;
|
|
73
|
+
let fallbackCount = 0;
|
|
74
|
+
for (let slot = 0; slot < rows.length; slot++) {
|
|
75
|
+
const row = rows[slot]!;
|
|
76
|
+
for (let field = 0; field < 4; field++) {
|
|
77
|
+
const value = field === 0 ? row.label : field === 1 ? row.command : field === 2 ? row.detail : row.key;
|
|
78
|
+
const error = nscvStatusFieldError(input, value, field === 0 || field === 2 ? 256 : field === 1 ? 128 : 32);
|
|
79
|
+
if (error !== 0) return error;
|
|
80
|
+
}
|
|
81
|
+
if (row.role !== 0 && row.role !== 4 && row.command.statusByteCount > 0) return 1;
|
|
82
|
+
if (row.detail.statusByteCount > 0 && row.role !== 1 && row.role !== 3 && row.role !== 4 && row.role !== 5) return 1;
|
|
83
|
+
if (row.separator && (row.detail.statusByteCount > 0 || row.role !== 0)) return 1;
|
|
84
|
+
if ((row.role === 6) !== row.segmented || (row.role === 7) !== (row.chart !== null) || (row.metric !== null && row.role !== 3)) return 1;
|
|
85
|
+
if ((row.role === 6 || row.role === 7) && (row.statusIdentity !== 0 || row.label.statusByteCount !== 0)) return 1;
|
|
86
|
+
if (row.statusIdentity !== 0) for (let previous = 0; previous < slot; previous++) if (rows[previous]!.statusIdentity === row.statusIdentity) return 1;
|
|
87
|
+
if (row.command.statusByteCount > 0) {
|
|
88
|
+
if (row.separator || row.statusIdentity === 0) return 1;
|
|
89
|
+
const error = nscvStatusCommandError(input, row.command); if (error !== 0) return error;
|
|
90
|
+
}
|
|
91
|
+
if (!row.separator && row.label.statusByteCount === 0 && row.role !== 6 && row.role !== 7 && row.metric === null) return 1;
|
|
92
|
+
if (row.key.statusByteCount > 0 && (row.separator || row.command.statusByteCount === 0 || !nscvStatusShortcut(input, row.key, row.modifiers))) return 1;
|
|
93
|
+
if (row.segmented) {
|
|
94
|
+
if (row.statusOptionCount === 0 || row.statusOptionCount > 8) return 1;
|
|
95
|
+
let selectedCount = 0;
|
|
96
|
+
for (let optionSlot = 0; optionSlot < row.options.length; optionSlot++) {
|
|
97
|
+
const option = row.options[optionSlot]!;
|
|
98
|
+
if (option.statusIdentity === 0) return 1;
|
|
99
|
+
const label = nscvStatusFieldError(input, option.label, 64); if (label !== 0) return label;
|
|
100
|
+
const command = nscvStatusFieldError(input, option.command, 128); if (command !== 0) return command;
|
|
101
|
+
if (option.label.statusByteCount === 0 || option.command.statusByteCount === 0) return 1;
|
|
102
|
+
const commandName = nscvStatusCommandError(input, option.command); if (commandName !== 0) return commandName;
|
|
103
|
+
if (option.selected) selectedCount++;
|
|
104
|
+
for (let previous = 0; previous < optionSlot; previous++) if (row.options[previous]!.statusIdentity === option.statusIdentity) return 1;
|
|
105
|
+
// The native reference checks other rows before validating them. Its
|
|
106
|
+
// scans include oversized segmented arrays; their copied IDs were
|
|
107
|
+
// compared by this policy in bounded chunks, preserving error order.
|
|
108
|
+
if (option.overflowDuplicate) return 1;
|
|
109
|
+
for (let otherSlot = 0; otherSlot < rows.length; otherSlot++) {
|
|
110
|
+
if (otherSlot === slot) continue;
|
|
111
|
+
const other = rows[otherSlot]!;
|
|
112
|
+
if (other.statusIdentity === option.statusIdentity) return 1;
|
|
113
|
+
for (const otherOption of other.options) if (otherOption.statusIdentity === option.statusIdentity) return 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (selectedCount > 1) return 1;
|
|
117
|
+
fallbackCount += row.statusOptionCount;
|
|
118
|
+
} else fallbackCount++;
|
|
119
|
+
if (row.metric !== null) {
|
|
120
|
+
for (let field = 0; field < 3; field++) {
|
|
121
|
+
const value = field === 0 ? row.metric.primary : field === 1 ? row.metric.secondary : row.metric.accessibility;
|
|
122
|
+
const error = nscvStatusFieldError(input, value, field === 2 ? 128 : 256); if (error !== 0) return error;
|
|
123
|
+
}
|
|
124
|
+
if (row.metric.primary.statusByteCount === 0 || row.metric.accessibility.statusByteCount === 0) return 1;
|
|
125
|
+
}
|
|
126
|
+
if (row.chart !== null) {
|
|
127
|
+
const chart = row.chart;
|
|
128
|
+
if (chart.statusValueCount === 0 || chart.statusValueCount > 32 || !Number.isFinite(chart.minimum) || !Number.isFinite(chart.maximum) || !(chart.maximum > chart.minimum)) return 1;
|
|
129
|
+
for (let field = 0; field < 3; field++) {
|
|
130
|
+
const value = field === 0 ? chart.leading : field === 1 ? chart.trailing : chart.accessibility;
|
|
131
|
+
const error = nscvStatusFieldError(input, value, 128); if (error !== 0) return error;
|
|
132
|
+
}
|
|
133
|
+
if (chart.accessibility.statusByteCount === 0) return 1;
|
|
134
|
+
for (const value of chart.values) if (!Number.isFinite(value) || value < chart.minimum || value > chart.maximum) return 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return fallbackCount > 32 ? 1 : 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function nscvStatusValidation(input: Uint8Array): Uint8Array {
|
|
141
|
+
if (input.length < 8 || input[0] !== 70 || input[1]! > 6 || input[2] !== 0 || input[3] !== 0) throw new Error("invalid status admission header");
|
|
142
|
+
const data = new DataView(input.buffer, input.byteOffset, input.byteLength), operation = input[1]!;
|
|
143
|
+
if (operation === 6) {
|
|
144
|
+
if (input.length < 16) throw new Error("truncated status identity comparison");
|
|
145
|
+
const sourceRow = data.getUint32(4, true), queries = data.getUint32(8, true), count = data.getUint32(12, true);
|
|
146
|
+
if (sourceRow >= 32 || queries > 256 || count > 128 || input.length !== 16 + queries * 8 + count * 4) throw new Error("invalid status identity comparison");
|
|
147
|
+
const result = new Uint8Array(queries);
|
|
148
|
+
for (let slot = 0; slot < queries; slot++) {
|
|
149
|
+
const at = 16 + slot * 8;
|
|
150
|
+
if (input[at]! >= 32 || input[at + 1]! >= 8 || input[at + 2] !== 0 || input[at + 3] !== 0) throw new Error("invalid status identity query");
|
|
151
|
+
if (input[at] === sourceRow) continue;
|
|
152
|
+
for (let value = 0; value < count; value++) if (data.getUint32(at + 4, true) === data.getUint32(16 + queries * 8 + value * 4, true)) { result[slot] = 1; break; }
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
let at = 4;
|
|
157
|
+
const fields: NscvStatusField[] = [];
|
|
158
|
+
let presentation: NscvStatusPresentation | null = null;
|
|
159
|
+
if (operation === 0 || operation === 1) {
|
|
160
|
+
const icon = nscvStatusField(input, at, 4096); fields.push(icon); at = icon.statusNextAt;
|
|
161
|
+
if (operation === 0) {
|
|
162
|
+
const title = nscvStatusField(input, at, 64); fields.push(title); at = title.statusNextAt;
|
|
163
|
+
presentation = nscvStatusPresentation(input, at); at = presentation.statusNextAt;
|
|
164
|
+
}
|
|
165
|
+
for (let field = 0; field < 4; field++) { const value = nscvStatusField(input, at, field === 0 ? 256 : 128); fields.push(value); at = value.statusNextAt; }
|
|
166
|
+
} else if (operation === 2) { const title = nscvStatusField(input, at, 64); fields.push(title); at = title.statusNextAt; }
|
|
167
|
+
else if (operation === 3) { presentation = nscvStatusPresentation(input, at); at = presentation.statusNextAt; }
|
|
168
|
+
let count = 0;
|
|
169
|
+
const rows: NscvStatusRow[] = [];
|
|
170
|
+
if (operation === 0 || operation === 4) {
|
|
171
|
+
if (at + 4 > input.length) throw new Error("truncated status menu count");
|
|
172
|
+
count = data.getUint32(at, true); at += 4;
|
|
173
|
+
for (let slot = 0; slot < (count <= 32 ? count : 0); slot++) {
|
|
174
|
+
if (at + 8 > input.length || input[at + 4]! > 7 || input[at + 5]! > 15 || input[at + 6]! > 31 || input[at + 7] !== 0) throw new Error("invalid status row header");
|
|
175
|
+
const identity = data.getUint32(at, true), role = input[at + 4]!, flags = input[at + 5]!, modifiers = input[at + 6]!; at += 8;
|
|
176
|
+
const label = nscvStatusField(input, at, 256); at = label.statusNextAt;
|
|
177
|
+
const command = nscvStatusField(input, at, 128); at = command.statusNextAt;
|
|
178
|
+
const detail = nscvStatusField(input, at, 256); at = detail.statusNextAt;
|
|
179
|
+
const key = nscvStatusField(input, at, 32); at = key.statusNextAt;
|
|
180
|
+
let optionCount = 0; const options: NscvStatusOption[] = [];
|
|
181
|
+
if ((flags & 2) !== 0) {
|
|
182
|
+
if (at + 4 > input.length) throw new Error("truncated status option count");
|
|
183
|
+
optionCount = data.getUint32(at, true); at += 4;
|
|
184
|
+
for (let optionSlot = 0; optionSlot < (optionCount <= 8 ? optionCount : 0); optionSlot++) {
|
|
185
|
+
if (at + 8 > input.length || data.getUint32(at + 4, true) > 3) throw new Error("invalid status option header");
|
|
186
|
+
const optionIdentity = data.getUint32(at, true), optionFlags = data.getUint32(at + 4, true); at += 8;
|
|
187
|
+
const optionLabel = nscvStatusField(input, at, 64); at = optionLabel.statusNextAt;
|
|
188
|
+
const optionCommand = nscvStatusField(input, at, 128); at = optionCommand.statusNextAt;
|
|
189
|
+
options.push({ statusIdentity: optionIdentity, selected: (optionFlags & 1) !== 0, overflowDuplicate: (optionFlags & 2) !== 0, label: optionLabel, command: optionCommand });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
let metric: NscvStatusMetric | null = null;
|
|
193
|
+
if ((flags & 4) !== 0) {
|
|
194
|
+
const primary = nscvStatusField(input, at, 256); at = primary.statusNextAt;
|
|
195
|
+
const secondary = nscvStatusField(input, at, 256); at = secondary.statusNextAt;
|
|
196
|
+
const accessibility = nscvStatusField(input, at, 128); at = accessibility.statusNextAt;
|
|
197
|
+
metric = { primary, secondary, accessibility };
|
|
198
|
+
}
|
|
199
|
+
let chart: NscvStatusChart | null = null;
|
|
200
|
+
if ((flags & 8) !== 0) {
|
|
201
|
+
if (at + 12 > input.length) throw new Error("truncated status chart header");
|
|
202
|
+
const valueCount = data.getUint32(at, true), minimum = data.getFloat32(at + 4, true), maximum = data.getFloat32(at + 8, true); at += 12;
|
|
203
|
+
const values: number[] = [];
|
|
204
|
+
for (let value = 0; value < (valueCount <= 32 ? valueCount : 0); value++) {
|
|
205
|
+
if (at + 4 > input.length) throw new Error("truncated status chart value"); values.push(data.getFloat32(at, true)); at += 4;
|
|
206
|
+
}
|
|
207
|
+
const leading = nscvStatusField(input, at, 128); at = leading.statusNextAt;
|
|
208
|
+
const trailing = nscvStatusField(input, at, 128); at = trailing.statusNextAt;
|
|
209
|
+
const accessibility = nscvStatusField(input, at, 128); at = accessibility.statusNextAt;
|
|
210
|
+
chart = { statusValueCount: valueCount, minimum, maximum, values, leading, trailing, accessibility };
|
|
211
|
+
}
|
|
212
|
+
rows.push({ statusIdentity: identity, role, separator: (flags & 1) !== 0, modifiers, label, command, detail, key, segmented: (flags & 2) !== 0, statusOptionCount: optionCount, options, metric, chart });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
let statusIdentity = 1;
|
|
216
|
+
if (operation === 5) { statusIdentity = data.getUint32(at, true); at += 4; }
|
|
217
|
+
if (at !== input.length) throw new Error("trailing status admission bytes");
|
|
218
|
+
let error = 0;
|
|
219
|
+
if (operation === 0 || operation === 1) {
|
|
220
|
+
for (let field = 0; field < fields.length; field++) {
|
|
221
|
+
const limit = field === 0 ? 4096 : operation === 0 && field === 1 ? 64 : field === (operation === 0 ? 2 : 1) ? 256 : 128;
|
|
222
|
+
error = nscvStatusFieldError(input, fields[field]!, limit); if (error !== 0) break;
|
|
223
|
+
if (operation === 0 && field === 1) { error = nscvStatusPresentationError(input, presentation!); if (error !== 0) break; }
|
|
224
|
+
}
|
|
225
|
+
// All shell command field bounds precede every command-name check.
|
|
226
|
+
if (error === 0) for (let field = operation === 0 ? 3 : 2; field < fields.length; field++) if (fields[field]!.statusByteCount > 0) { error = nscvStatusCommandError(input, fields[field]!); if (error !== 0) break; }
|
|
227
|
+
} else if (operation === 2) error = nscvStatusFieldError(input, fields[0]!, 64);
|
|
228
|
+
else if (operation === 3) error = nscvStatusPresentationError(input, presentation!);
|
|
229
|
+
else if (operation === 5 && statusIdentity === 0) error = 1;
|
|
230
|
+
if (error === 0 && (operation === 0 || operation === 4)) error = nscvStatusMenuError(input, count, rows);
|
|
231
|
+
const result = new Uint8Array(4); result[0] = error; return result;
|
|
232
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Portable routing over native-owned spawn/fetch stream slots.
|
|
2
|
+
* 0 admits, 1 looks up, 2 handles a line, 3 handles a spawn terminal,
|
|
3
|
+
* and 4 handles a fetch terminal. Results are copied; the dispatch cycle
|
|
4
|
+
* retains arena ownership. No OS resource or payload bytes cross this seam.
|
|
5
|
+
*/
|
|
6
|
+
export function native_stream_policy(request: Uint8Array): Uint8Array {
|
|
7
|
+
const operation = request[0];
|
|
8
|
+
if (operation === 0 || operation === 1) {
|
|
9
|
+
const keyAt = operation === 0 ? 5 : 2;
|
|
10
|
+
if (request.length < keyAt) throw new Error("invalid stream declaration");
|
|
11
|
+
if (operation === 0 && (request[1]! > 1 || request[2]! > 1 || request[3]! > 1))
|
|
12
|
+
throw new Error("invalid stream admission fact");
|
|
13
|
+
const keyLength = request[keyAt - 1]!;
|
|
14
|
+
let at = keyAt + keyLength, matching = -1, free = -1;
|
|
15
|
+
if (at > request.length) throw new Error("truncated stream key");
|
|
16
|
+
for (let slot = 0; slot < 16; slot++) {
|
|
17
|
+
if (at + 2 > request.length) throw new Error("truncated stream table");
|
|
18
|
+
const used = request[at]!, length = request[at + 1]!;
|
|
19
|
+
at += 2;
|
|
20
|
+
if (used > 1 || at + length > request.length) throw new Error("invalid stream slot");
|
|
21
|
+
let equal = used === 1 && length === keyLength;
|
|
22
|
+
for (let i = 0; i < length; i++) if (request[at + i] !== request[keyAt + i]) equal = false;
|
|
23
|
+
if (equal && matching < 0) matching = slot;
|
|
24
|
+
if (used === 0 && free < 0) free = slot;
|
|
25
|
+
at += length;
|
|
26
|
+
}
|
|
27
|
+
if (at !== request.length) throw new Error("trailing stream bytes");
|
|
28
|
+
const blocked = operation === 0 && keyLength > 0 &&
|
|
29
|
+
(matching >= 0 || request[2] === 1 || (request[1] === 1 && request[3] === 1));
|
|
30
|
+
const slot = operation === 1 ? matching : blocked ? -1 : free;
|
|
31
|
+
const result = new Uint8Array(1);
|
|
32
|
+
result[0] = slot < 0 ? 255 : slot;
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
// Result: [route, payload (bytes/number/number+bytes), damage, retire,
|
|
36
|
+
// error source (native reason / literal truncated)].
|
|
37
|
+
const result = new Uint8Array(5);
|
|
38
|
+
if (operation === 2) {
|
|
39
|
+
if (request.length !== 6) throw new Error("invalid stream line request");
|
|
40
|
+
for (let i = 1; i < 5; i++) if (request[i]! > 1) throw new Error("invalid stream line fact");
|
|
41
|
+
result[0] = request[5]!;
|
|
42
|
+
result[2] = request[2] === 1 || (request[1] === 1 && (request[3] === 1 || request[4] === 1)) ? 1 : 0;
|
|
43
|
+
} else if (operation === 3) {
|
|
44
|
+
if (request.length !== 6) throw new Error("invalid spawn terminal request");
|
|
45
|
+
for (let i = 1; i < 4; i++) if (request[i]! > 1) throw new Error("invalid spawn terminal fact");
|
|
46
|
+
const success = request[2] === 1 && (request[1] === 0 || request[3] === 0);
|
|
47
|
+
result[0] = request[success ? 4 : 5]!;
|
|
48
|
+
result[1] = success ? request[1] === 1 ? 2 : 1 : 0;
|
|
49
|
+
result[3] = 1;
|
|
50
|
+
result[4] = !success && request[2] === 1 ? 1 : 0;
|
|
51
|
+
} else if (operation === 4) {
|
|
52
|
+
if (request.length !== 7) throw new Error("invalid fetch terminal request");
|
|
53
|
+
for (let i = 1; i < 5; i++) if (request[i]! > 1) throw new Error("invalid fetch terminal fact");
|
|
54
|
+
const damaged = request[1] === 1 || request[2] === 1 || request[3] === 1;
|
|
55
|
+
const success = request[4] === 1 && !damaged;
|
|
56
|
+
result[0] = request[success ? 5 : 6]!;
|
|
57
|
+
result[1] = success ? 1 : 0;
|
|
58
|
+
result[2] = damaged ? 1 : 0;
|
|
59
|
+
result[3] = 1;
|
|
60
|
+
result[4] = request[4] === 1 && damaged ? 1 : 0;
|
|
61
|
+
} else throw new Error("invalid stream policy operation");
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Complete surface chrome recipes over copied appearance and measurement facts.
|
|
2
|
+
* Command identities, fonts, registry paths and drawing storage stay native. */
|
|
3
|
+
function nscvSurfaceRecipes(request: Uint8Array): Uint8Array {
|
|
4
|
+
if (request.length !== 560) throw new Error("invalid surface recipe shape");
|
|
5
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
6
|
+
const op = request[2]!, numeric = request[3]!, flags = w.getUint32(4, true), mask = w.getUint32(8, true);
|
|
7
|
+
if (request[0] !== 31 || request[1] !== 1 || op > 14 || numeric > 15 || flags > 1023 || mask > 1023 || request[12]! > 5 || request[13]! > 2 || request[14]! > 1 || request[15]! > 31) throw new Error("invalid surface recipe header");
|
|
8
|
+
for (let i = 156; i < 160; i++) if (request[i] !== 0) throw new Error("invalid surface recipe reserved bytes");
|
|
9
|
+
for (let i = 464; i < 480; i++) if (request[i] !== 0) throw new Error("invalid surface recipe reserved bytes");
|
|
10
|
+
for (let i = 528; i < 560; i++) if (request[i] !== 0) throw new Error("invalid surface recipe reserved bytes");
|
|
11
|
+
const f = Math.fround, v = (at: number): number => w.getFloat32(at, true);
|
|
12
|
+
const max = (a: number, b: number): number => nscvRenderExtreme(a, b, numeric, true);
|
|
13
|
+
const min = (a: number, b: number): number => nscvRenderExtreme(a, b, numeric, false);
|
|
14
|
+
const r = (x: number, y: number, width: number, height: number): NscSurfaceRect => ({ x, y, width, height });
|
|
15
|
+
const raw = nscvRenderRect(w, 16), frame = nscvSurfaceNormalize(raw), size = v(48), inset = v(52), iconSize = v(56), gap = v(60);
|
|
16
|
+
const empty = (a: NscSurfaceRect): boolean => a.width <= 0 || a.height <= 0;
|
|
17
|
+
const result = new Uint8Array(1088), out = new DataView(result.buffer); out.setUint32(0, 1, true); let count = 0;
|
|
18
|
+
const auxiliary = (bits: number): void => out.setUint32(8, out.getUint32(8, true) | bits, true);
|
|
19
|
+
const color = (at: number): Uint8Array => request.subarray(at, at + 16);
|
|
20
|
+
const content = (kind: number, a: NscSurfaceRect, radius: Uint8Array, width: number, rawInput: boolean): Uint8Array => {
|
|
21
|
+
const b = new Uint8Array(128), d = new DataView(b.buffer); b.set([30, 1, kind, numeric]); b[9] = request[15]!;
|
|
22
|
+
d.setUint32(4, ((flags & 32) !== 0 ? 1 : 0) | ((flags & 64) !== 0 ? 2 : 0), true);
|
|
23
|
+
nscvRenderPutRect(d, 16, a); if (rawInput) b.set(request.subarray(16, 32), 16); b.set(radius, 32); d.setFloat32(48, v(68), true); d.setFloat32(84, v(120), true); d.setFloat32(88, width, true);
|
|
24
|
+
return nscvControlContent(b);
|
|
25
|
+
};
|
|
26
|
+
const zeroRadius = new Uint8Array(16);
|
|
27
|
+
const snap = (a: NscSurfaceRect): NscSurfaceRect => nscvRenderRect(new DataView(content(0, a, zeroRadius, 0, false).buffer), 8);
|
|
28
|
+
const point = (x: number, y: number, text: boolean): Uint8Array => content(text ? 2 : 1, r(x, y, 0, 0), zeroRadius, 0, false).subarray(56, 64);
|
|
29
|
+
const radiusAll = (value: number): Uint8Array => { const b = new Uint8Array(16), d = new DataView(b.buffer); for (let i = 0; i < 4; i++) d.setFloat32(i * 4, value, true); return b; };
|
|
30
|
+
const radius = request.subarray(32, 48);
|
|
31
|
+
// Every command is a complete, zero-initialized record. Selected colors and
|
|
32
|
+
// unsnapped input fields are copied as octets, including NaN payloads.
|
|
33
|
+
const command = (kind: number, slot: number, a: NscSurfaceRect, arc: Uint8Array, ink: Uint8Array, width: number): number => {
|
|
34
|
+
if (count >= 8) throw new Error("surface recipe command overflow");
|
|
35
|
+
const at = 64 + count * 128; count++; out.setUint32(at, kind, true); out.setUint32(at + 4, slot, true);
|
|
36
|
+
nscvRenderPutRect(out, at + 8, a); result.set(arc, at + 24); result.set(ink, at + 40); out.setFloat32(at + 56, width, true);
|
|
37
|
+
const rawInput = (op < 5 || op === 13) && kind < 3;
|
|
38
|
+
if (rawInput) result.set(request.subarray(16, 32), at + 8);
|
|
39
|
+
if (kind === 1) {
|
|
40
|
+
const crisp = content(10, a, arc, width, rawInput); result.set(crisp.subarray(8, 24), at + 8); result.set(crisp.subarray(40, 56), at + 24); result.set(crisp.subarray(64, 68), at + 56);
|
|
41
|
+
}
|
|
42
|
+
return at;
|
|
43
|
+
};
|
|
44
|
+
const fill = (slot: number, a: NscSurfaceRect, arc: Uint8Array, ink: Uint8Array): void => { command(0, slot, a, arc, ink, 0); };
|
|
45
|
+
const border = (slot: number, a: NscSurfaceRect, arc: Uint8Array, ink: Uint8Array): void => { command(1, slot, a, arc, ink, v(100)); };
|
|
46
|
+
const shadow = (): void => { if (v(88) !== 0 || v(92) !== 0 || v(96) !== 0) { const at = command(2, 1, raw, radius, color(224), 0); result.set(request.subarray(88, 100), at + 60); } };
|
|
47
|
+
const text = (slot: number, x: number, y: number, width: number, wrap: number, alignment: number, overflow: number, ink: Uint8Array): void => {
|
|
48
|
+
const at = command(3, slot, r(0, 0, 0, 0), zeroRadius, ink, 0); out.setFloat32(at + 60, size, true); out.setFloat32(at + 64, width, true); out.setFloat32(at + 68, f(size * 1.25), true);
|
|
49
|
+
result.set(point(x, y, true), at + 72); out.setUint32(at + 80, wrap, true); out.setUint32(at + 84, alignment, true); out.setUint32(at + 88, overflow, true);
|
|
50
|
+
};
|
|
51
|
+
const line = (slot: number, x0: number, y0: number, x1: number, y1: number, ink: Uint8Array, width: number): void => {
|
|
52
|
+
const at = command(4, slot, r(0, 0, 0, 0), zeroRadius, ink, width); result.set(point(x0, y0, false), at + 8); result.set(point(x1, y1, false), at + 16);
|
|
53
|
+
};
|
|
54
|
+
const icon = (slot: number, a: NscSurfaceRect, ink: Uint8Array, registry: number, flip: boolean): void => {
|
|
55
|
+
const n = snap(nscvSurfaceNormalize(a)); if (empty(n)) return;
|
|
56
|
+
const at = command(5, slot, n, zeroRadius, ink, 0); out.setUint32(at + 92, registry, true); out.setUint32(at + 80, flip ? 1 : 0, true);
|
|
57
|
+
if (flip) { out.setFloat32(at + 96, -1, true); out.setFloat32(at + 108, -1, true); out.setFloat32(at + 112, f(f(n.x * 2) + n.width), true); out.setFloat32(at + 116, f(f(n.y * 2) + n.height), true); }
|
|
58
|
+
};
|
|
59
|
+
const grip = (): void => {
|
|
60
|
+
if (empty(frame)) return;
|
|
61
|
+
const pad = v(144), space = v(148), height = min(max(v(152), f(frame.height * f(0.48))), max(0, f(frame.height - f(pad * 2)))); if (height <= 0) return;
|
|
62
|
+
const right = max(f(frame.x + pad), f(f(frame.x + frame.width) - pad)), left = max(f(frame.x + pad), f(right - space));
|
|
63
|
+
const y0 = f(frame.y + f(f(frame.height - height) * 0.5)), y1 = f(y0 + height);
|
|
64
|
+
line(4, left, y0, left, y1, color(192), v(104)); line(5, right, y0, right, y1, color(192), v(104));
|
|
65
|
+
};
|
|
66
|
+
const radiusAt = (flags & 256) !== 0 ? 112 : 108, radiusWord = w.getUint32(radiusAt, true);
|
|
67
|
+
const bubbleRadius = radiusAll((flags & 256) !== 0 ? max(0, v(112)) : f(max(0, v(108)) + 12));
|
|
68
|
+
// The native target can propagate a signaling operand through f32 max.
|
|
69
|
+
// Preserve its quieted payload, including the fallback's subsequent add.
|
|
70
|
+
if ((request[15]! & 16) !== 0 && (radiusWord & 0x7f800000) === 0x7f800000 && (radiusWord & 0x007fffff) !== 0 && (radiusWord & 0x00400000) === 0) {
|
|
71
|
+
const arc = new DataView(bubbleRadius.buffer); for (let i = 0; i < 4; i++) arc.setUint32(i * 4, radiusWord | 0x00400000, true);
|
|
72
|
+
}
|
|
73
|
+
if (op === 5) { auxiliary(1); result.set(bubbleRadius, 16); }
|
|
74
|
+
else if (op === 6) {
|
|
75
|
+
const variant = request[12]!;
|
|
76
|
+
const ink = variant === 1 ? (mask & 8) !== 0 ? color(448) : (mask & 64) !== 0 ? color(384) : color(304) : variant === 5 ? color(320) : variant < 3 && (mask & 64) !== 0 ? color(384) : null;
|
|
77
|
+
if (ink !== null) { auxiliary(2); result.set(ink, 32); result.set(ink, 48); out.setFloat32(60, f(0.7), true); }
|
|
78
|
+
} else if (op === 4) {
|
|
79
|
+
const variant = request[12]!;
|
|
80
|
+
const background = (mask & 1) !== 0 ? color(400) : variant === 0 || variant === 2 ? (mask & 16) !== 0 ? color(352) : color(256) : variant === 1 ? (mask & 4) !== 0 ? color(432) : color(288) : variant === 3 ? color(240) : variant === 5 ? (mask & 128) !== 0 ? color(336) : nscvAppearanceAlpha(color(320), f(0.10), numeric) : null;
|
|
81
|
+
if (background !== null) fill(2, raw, bubbleRadius, background);
|
|
82
|
+
const edge = (mask & 2) !== 0 ? color(416) : variant === 3 ? (mask & 32) !== 0 ? color(368) : color(176) : null;
|
|
83
|
+
if (edge !== null) border(3, raw, bubbleRadius, edge);
|
|
84
|
+
} else if (op === 7 || op === 8) {
|
|
85
|
+
if ((flags & 513) === 513 && !empty(frame)) {
|
|
86
|
+
if ((flags & 128) === 0) auxiliary(8);
|
|
87
|
+
else {
|
|
88
|
+
const height = f(f(size * 1.25) + 4), width = max(height, f(Math.ceil(v(116)) + 12));
|
|
89
|
+
const x = request[13] === 0 ? f(frame.x + 12) : request[13] === 1 ? f(frame.x + f(f(frame.width - width) * 0.5)) : f(f(f(frame.x + frame.width) - 12) - width);
|
|
90
|
+
const pill = r(x, f(f(frame.y + frame.height) - f(height * 0.25)), width, height); auxiliary(4); nscvRenderPutRect(out, 16, pill);
|
|
91
|
+
if (op === 8) {
|
|
92
|
+
const n = snap(pill), normalized = nscvSurfaceNormalize(n), ring = r(f(normalized.x - 3), f(normalized.y - 3), f(f(normalized.width + 3) + 3), f(f(normalized.height + 3) + 3));
|
|
93
|
+
fill(4, ring, radiusAll(f(ring.height * 0.5)), color(240)); fill(5, n, radiusAll(f(n.height * 0.5)), color(256));
|
|
94
|
+
text(6, f(n.x + 6), f(n.y + max(size, f(f(f(n.height - f(size * 1.25)) * 0.5) + size))), max(1, f(n.width - 6)), 1, 0, 0, color(272));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} else if (op === 0 || op === 1 || op === 2 || op === 3 || op === 13) {
|
|
99
|
+
if (op === 2 || op === 13 || op === 3 && v(172) >= 1) shadow();
|
|
100
|
+
const slot = op < 2 ? 1 : 2; fill(slot, raw, radius, color(160)); border(slot + 1, raw, radius, color(176));
|
|
101
|
+
if (op === 3 && (flags & 8) !== 0) grip();
|
|
102
|
+
if (op < 3 && (flags & 1) !== 0) {
|
|
103
|
+
if (op === 0) {
|
|
104
|
+
const height = f(size * 1.25), a = r(f(raw.x + inset), f(f(raw.y + inset) + f(f(height - iconSize) * 0.5)), iconSize, iconSize);
|
|
105
|
+
icon(3, a, color(192), request[12] === 5 ? 1 : 0, false);
|
|
106
|
+
text(10, f(f(a.x + iconSize) + gap), f(f(raw.y + inset) + f(f(height + f(size * f(0.7))) * 0.5)), max(1, f(f(f(raw.width - f(inset * 2)) - iconSize) - gap)), 1, request[13]!, 0, color(192));
|
|
107
|
+
} else text(op === 1 ? 3 : 4, f(raw.x + inset), f(f(raw.y + inset) + size), max(1, f(raw.width - f(inset * 2))), 1, request[13]!, 0, color(192));
|
|
108
|
+
}
|
|
109
|
+
} else if (op === 9) {
|
|
110
|
+
if (!empty(frame)) {
|
|
111
|
+
if ((mask & 256) !== 0) fill(1, frame, radius, color(480));
|
|
112
|
+
line(2, frame.x, f(frame.y + frame.height), f(frame.x + frame.width), f(frame.y + frame.height), color(176), v(100));
|
|
113
|
+
const body = r(f(frame.x + min(v(84), frame.width)), f(frame.y + min(v(72), frame.height)), max(0, f(f(frame.width - v(84)) - v(76))), max(0, f(f(frame.height - v(72)) - v(80))));
|
|
114
|
+
if (!empty(nscvSurfaceNormalize(body))) {
|
|
115
|
+
const height = min(body.height, v(64));
|
|
116
|
+
if ((flags & 1) !== 0) text(6, body.x, f(body.y + f(f(height + f(size * f(0.7))) * 0.5)), max(1, f(f(body.width - iconSize) - gap)), 0, request[13]!, request[14]!, color(192));
|
|
117
|
+
icon(4, r(f(f(body.x + body.width) - iconSize), f(body.y + f(f(height - iconSize) * 0.5)), iconSize, iconSize), color(208), 2, (flags & 4) !== 0);
|
|
118
|
+
if ((flags & 2) !== 0) {
|
|
119
|
+
const bounds = content(8, raw, zeroRadius, 0, true), arc = content(9, raw, request.subarray(128, 144), 0, true);
|
|
120
|
+
command(1, 7, nscvRenderRect(new DataView(bounds.buffer), 8), arc.subarray(40, 56), color(512), v(124));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} else if (op === 14) icon(3, raw, color(192), request[12] === 5 ? 1 : 0, false);
|
|
125
|
+
else if (op === 10) icon(4, raw, color(208), 2, (flags & 4) !== 0);
|
|
126
|
+
else if (op === 11) {
|
|
127
|
+
if (!empty(frame)) {
|
|
128
|
+
if ((flags & 16) === 0) { fill(1, frame, radius, color(160)); if ((mask & 512) !== 0) border(2, frame, radius, color(496)); }
|
|
129
|
+
else {
|
|
130
|
+
if ((mask & 256) !== 0) fill(1, frame, radius, color(480));
|
|
131
|
+
const width = min(frame.height, v(100)); if (width > 0) command(6, 2, snap(r(frame.x, f(f(frame.y + frame.height) - width), frame.width, width)), zeroRadius, color(176), 0);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} else if (op === 12) grip();
|
|
135
|
+
out.setUint32(4, count, true); return result;
|
|
136
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Portable OS-service descriptor admission. Payloads and OS results stay native. */
|
|
2
|
+
function nscvSystemAdmission(request: Uint8Array): Uint8Array {
|
|
3
|
+
if (request.length < 32 || request[0] !== 86 || request[1] !== 1 || request[2]! > 6)
|
|
4
|
+
throw new Error("invalid system admission header");
|
|
5
|
+
const mode = request[2]!, data = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
6
|
+
const word = (at: number): number => data.getUint32(at, true);
|
|
7
|
+
const empty = (at: number): boolean => word(at) === 0 && word(at + 4) === 0;
|
|
8
|
+
const over = (at: number, limit: number): boolean => word(at + 4) !== 0 || word(at) > limit;
|
|
9
|
+
let status = 0, next = 0;
|
|
10
|
+
if (mode === 0) {
|
|
11
|
+
const category = request[3]!;
|
|
12
|
+
if (category > 17) throw new Error("invalid system field category");
|
|
13
|
+
const limit = category < 2 || category === 3 || category === 4 ? 4096 : category === 2 ? 512 : category === 7 ? 256 : category === 8 || category === 12 ? 1024 : category === 16 ? 65536 : 128;
|
|
14
|
+
const copied = category === 16 ? 0 : over(8, limit) ? limit : word(8);
|
|
15
|
+
if (request.length !== 32 + copied) throw new Error("invalid system field extent");
|
|
16
|
+
for (let i = 4; i < 8; i++) if (request[i] !== 0) throw new Error("invalid system field padding");
|
|
17
|
+
for (let i = 16; i < 32; i++) if (request[i] !== 0) throw new Error("invalid system field padding");
|
|
18
|
+
const invalid = category === 0 ? 1 : category === 1 ? 3 : category <= 8 ? 5 : category <= 14 ? 7 : category <= 16 ? 10 : 9;
|
|
19
|
+
const tooLarge = category === 0 ? 2 : category === 1 ? 4 : category <= 8 ? 6 : category <= 14 ? 8 : category <= 16 ? 11 : 9;
|
|
20
|
+
const required = category < 2 || category === 5 || category === 8 || category === 15 || category === 17;
|
|
21
|
+
if (required && empty(8)) status = invalid;
|
|
22
|
+
else if (over(8, limit)) status = tooLarge;
|
|
23
|
+
else if (category === 17) status = nscvStatusCommandError(request, { statusByteAt: 32, statusByteCount: word(8), statusNextAt: request.length }) === 0 ? 0 : 9;
|
|
24
|
+
else if (category !== 16) for (let i = 32; i < request.length; i++) {
|
|
25
|
+
const ch = request[i]!;
|
|
26
|
+
if (ch === 0 || category === 8 && ch === 59 || category === 15 && (ch === 92 || ch <= 32 || ch === 127)) status = invalid;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
if (request.length !== 64 || request[3] !== 0) throw new Error("invalid system descriptor extent");
|
|
30
|
+
const fieldCount = mode === 1 ? 2 : mode === 2 ? 3 : mode === 3 || mode === 4 ? 6 : 1;
|
|
31
|
+
for (let i = 0; i < fieldCount; i++) if (word(32 + i * 4) > 11) throw new Error("invalid system field verdict");
|
|
32
|
+
if (mode === 1 || mode === 2) {
|
|
33
|
+
if (empty(8)) status = 5;
|
|
34
|
+
for (let i = 0; i < fieldCount && status === 0; i++) status = word(32 + i * 4);
|
|
35
|
+
} else if (mode === 3) {
|
|
36
|
+
for (let i = 0; i < 6 && status === 0; i++) status = word(32 + i * 4);
|
|
37
|
+
} else if (mode === 4) {
|
|
38
|
+
if (word(56) > 11) throw new Error("invalid notification command verdict");
|
|
39
|
+
if (empty(8)) status = 7;
|
|
40
|
+
for (let i = 0; i < 6 && status === 0; i++) status = word(32 + i * 4);
|
|
41
|
+
if (status === 0 && empty(16) !== empty(24)) status = 7;
|
|
42
|
+
if (status === 0 && !empty(24)) status = word(56);
|
|
43
|
+
} else if (mode === 5) status = word(32) || (over(8, 65536) ? 11 : 0);
|
|
44
|
+
else {
|
|
45
|
+
const previous = word(8);
|
|
46
|
+
if (previous > 1025 || word(12) !== 0) throw new Error("invalid filter continuation");
|
|
47
|
+
status = word(32);
|
|
48
|
+
if (status === 0) {
|
|
49
|
+
if (over(16, 1024)) throw new Error("invalid admitted extension length");
|
|
50
|
+
const total = previous + word(16);
|
|
51
|
+
if (total > 1024) status = 6;
|
|
52
|
+
else next = total + 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const result = new Uint8Array(16), out = new DataView(result.buffer);
|
|
57
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true);
|
|
58
|
+
out.setUint32(8, status, true); out.setUint32(12, next, true);
|
|
59
|
+
return result;
|
|
60
|
+
}
|