@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,165 @@
|
|
|
1
|
+
/** Complete host input-region planning over copied layout observations.
|
|
2
|
+
* Native owns measurements, retained buffers, scroll execution and OS calls. */
|
|
3
|
+
interface NscHostNode {
|
|
4
|
+
route: NscRouteNode; raw: NscSurfaceRect; padding: number[]; valueX: number;
|
|
5
|
+
virtualLo: number; virtualHi: number; config: number; measured: boolean;
|
|
6
|
+
extentY: number; extentX: number;
|
|
7
|
+
}
|
|
8
|
+
interface NscHostDriver {
|
|
9
|
+
node: number; parent: number; mask: number; frame: NscSurfaceRect;
|
|
10
|
+
width: number; height: number; x: number; y: number; flags: number;
|
|
11
|
+
}
|
|
12
|
+
interface NscHostRegion { frame: NscSurfaceRect; exclusion: boolean }
|
|
13
|
+
function nscvHostEligible(n: NscHostNode): boolean {
|
|
14
|
+
return n.route.kind === 6 && (n.route.lo !== 0 || n.route.hi !== 0) &&
|
|
15
|
+
((n.config & 1) === 0 || n.virtualLo !== 0 || n.virtualHi !== 0);
|
|
16
|
+
}
|
|
17
|
+
function nscvHostViewport(n: NscHostNode): NscSurfaceRect {
|
|
18
|
+
const f = Math.fround, r = n.raw, p = n.padding;
|
|
19
|
+
return nscvSurfaceNormalize({ x: f(r.x + nscvSurfaceMin(p[3]!, r.width)), y: f(r.y + nscvSurfaceMin(p[0]!, r.height)),
|
|
20
|
+
width: nscvSurfaceMax(0, f(f(r.width - p[3]!) - p[1]!)), height: nscvSurfaceMax(0, f(f(r.height - p[0]!) - p[2]!)) });
|
|
21
|
+
}
|
|
22
|
+
function nscvHostTransformed(n: NscRouteNode): NscSurfaceRect {
|
|
23
|
+
const r = n.frame, t = n.transform, f = Math.fround;
|
|
24
|
+
if (r.width <= 0 || r.height <= 0 || t[0] === 1 && t[1] === 0 && t[2] === 0 && t[3] === 1 && t[4] === 0 && t[5] === 0) return r;
|
|
25
|
+
const xs = [r.x, f(r.x + r.width), r.x, f(r.x + r.width)];
|
|
26
|
+
const ys = [r.y, r.y, f(r.y + r.height), f(r.y + r.height)];
|
|
27
|
+
let minX = 0, minY = 0, maxX = 0, maxY = 0;
|
|
28
|
+
for (let i = 0; i < 4; i++) {
|
|
29
|
+
const x = f(f(f(t[0]! * xs[i]!) + f(t[2]! * ys[i]!)) + t[4]!);
|
|
30
|
+
const y = f(f(f(t[1]! * xs[i]!) + f(t[3]! * ys[i]!)) + t[5]!);
|
|
31
|
+
if (i === 0) { minX = x; maxX = x; minY = y; maxY = y; }
|
|
32
|
+
else { minX = nscvSurfaceMin(minX, x); minY = nscvSurfaceMin(minY, y); maxX = nscvSurfaceMax(maxX, x); maxY = nscvSurfaceMax(maxY, y); }
|
|
33
|
+
}
|
|
34
|
+
return nscvSurfaceNormalize({ x: minX, y: minY, width: f(maxX - minX), height: f(maxY - minY) });
|
|
35
|
+
}
|
|
36
|
+
function nscvHostAncestor(nodes: NscRouteNode[], ancestor: number, child: number): boolean {
|
|
37
|
+
let p = nodes[child]!.parent;
|
|
38
|
+
while (p < nodes.length) { if (p === ancestor) return true; p = nodes[p]!.parent; }
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function nscvHostInputRegions(request: Uint8Array): Uint8Array {
|
|
42
|
+
if (request.length < 64 || request[0] !== 79 || request[1] !== 1 || request[2]! > 3 || request[3] !== 0)
|
|
43
|
+
throw new Error("invalid host input-region header");
|
|
44
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), mode = request[2]!, missing = 4294967295, f = Math.fround;
|
|
45
|
+
const count = w.getUint32(4, true), tracked = w.getUint32(8, true), previous = w.getUint32(12, true);
|
|
46
|
+
const facts = w.getUint32(20, true), baseRubber = w.getUint32(24, true), capacity = w.getUint32(28, true);
|
|
47
|
+
if (count > 1024 || tracked > 16 || previous > 32 || facts > 7 || baseRubber > 1 || capacity > 32 || w.getUint32(16, true) !== 0 ||
|
|
48
|
+
request.length !== 64 + count * 128 + tracked * 16 + previous * 20 || mode === 3 && (count !== 0 || previous !== 0))
|
|
49
|
+
throw new Error("invalid host input-region facts");
|
|
50
|
+
const nodeFacts: NscHostNode[] = [], nodes: NscRouteNode[] = [], layers: number[] = [];
|
|
51
|
+
for (let i = 0; i < 4; i++) layers.push(w.getInt32(48 + i * 4, true));
|
|
52
|
+
for (let i = 0; i < count; i++) {
|
|
53
|
+
const at = 64 + i * 128, kind = w.getUint32(at, true), role = w.getUint32(at + 4, true), parent = w.getUint32(at + 8, true);
|
|
54
|
+
const flags = w.getUint32(at + 24, true), actions = w.getUint32(at + 28, true), config = w.getUint32(at + 108, true), known = w.getUint32(at + 112, true);
|
|
55
|
+
if (kind > 62 || role > 26 || parent !== missing && parent >= i || flags > 4095 || actions > 2047 ||
|
|
56
|
+
config > 63 || (config & 12) === 12 || (config & 48) === 48 || known > 1 || w.getUint32(at + 124, true) !== 0)
|
|
57
|
+
throw new Error("invalid host input-region node");
|
|
58
|
+
const raw = { x: w.getFloat32(at + 40, true), y: w.getFloat32(at + 44, true), width: w.getFloat32(at + 48, true), height: w.getFloat32(at + 52, true) };
|
|
59
|
+
const transform: number[] = [], padding: number[] = [];
|
|
60
|
+
for (let j = 0; j < 6; j++) transform.push(w.getFloat32(at + 56 + j * 4, true));
|
|
61
|
+
for (let j = 0; j < 4; j++) padding.push(w.getFloat32(at + 80 + j * 4, true));
|
|
62
|
+
const route = { kind, role, parent, depth: w.getUint32(at + 12, true), lo: w.getUint32(at + 16, true), hi: w.getUint32(at + 20, true), flags, actions,
|
|
63
|
+
value: w.getFloat32(at + 32, true), layer: w.getInt32(at + 36, true), frame: nscvSurfaceNormalize(raw), transform };
|
|
64
|
+
nodes.push(route); nodeFacts.push({ route, raw, padding, valueX: w.getFloat32(at + 96, true), virtualLo: w.getUint32(at + 100, true), virtualHi: w.getUint32(at + 104, true), config, measured: known !== 0,
|
|
65
|
+
extentY: w.getFloat32(at + 116, true), extentX: w.getFloat32(at + 120, true) });
|
|
66
|
+
}
|
|
67
|
+
const trackedAt = 64 + count * 128, previousAt = trackedAt + tracked * 16;
|
|
68
|
+
for (let i = 0; i < previous; i++) if (w.getUint32(previousAt + i * 20 + 16, true) > 1) throw new Error("invalid retained drag region");
|
|
69
|
+
const stamps: number[] = [], drivers: NscHostDriver[] = [], occluders: NscSurfaceRect[] = [], occluderNodes: number[] = [], regions: NscHostRegion[] = [];
|
|
70
|
+
let verdict = 0;
|
|
71
|
+
const header = (status: number, detail: number): Uint8Array => {
|
|
72
|
+
const result = new Uint8Array(32), out = new DataView(result.buffer);
|
|
73
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true); out.setUint32(28, detail, true); return result;
|
|
74
|
+
};
|
|
75
|
+
if (mode === 0 || mode === 1) {
|
|
76
|
+
if ((facts & 1) !== 0) for (let i = 0; i < count; i++) if (nscvHostEligible(nodeFacts[i]!)) stamps.push(i);
|
|
77
|
+
}
|
|
78
|
+
if (mode === 1 && (facts & 1) !== 0) {
|
|
79
|
+
const vr = nscvSurfaceNormalize({ x: w.getFloat32(32, true), y: w.getFloat32(36, true), width: w.getFloat32(40, true), height: w.getFloat32(44, true) });
|
|
80
|
+
const view = { x: 0, y: 0, width: vr.width, height: vr.height };
|
|
81
|
+
let overflow = false;
|
|
82
|
+
for (let i = 0; i < count; i++) {
|
|
83
|
+
const n = nodes[i]!, modal = nscvRouteModal(n) && (nodeFacts[i]!.config & 2) !== 0;
|
|
84
|
+
if (!((n.flags & 8) !== 0 && n.kind !== 40) && !modal || nscvRouteHidden(nodes, i) || nscvRouteConcealed(nodes, i)) continue;
|
|
85
|
+
const frame = modal ? view : nscvHostTransformed(n);
|
|
86
|
+
if (frame.width <= 0 || frame.height <= 0) continue;
|
|
87
|
+
if (occluders.length >= 8) { overflow = true; break; }
|
|
88
|
+
occluders.push(frame); occluderNodes.push(i);
|
|
89
|
+
}
|
|
90
|
+
if (overflow) { occluders.length = 0; occluders.push(view); }
|
|
91
|
+
for (let i = 0; i < count; i++) {
|
|
92
|
+
const n = nodeFacts[i]!;
|
|
93
|
+
if (!nscvHostEligible(n) || drivers.length >= 16) continue;
|
|
94
|
+
const viewport = nscvHostViewport(n);
|
|
95
|
+
if (viewport.width <= 0 || viewport.height <= 0) continue;
|
|
96
|
+
const virtual = (n.config & 1) !== 0, axes = (n.config >>> 2) & 3;
|
|
97
|
+
const horizontal = !virtual && axes !== 0, vertical = virtual || axes !== 1;
|
|
98
|
+
if (!n.measured) {
|
|
99
|
+
const result = new Uint8Array(48), out = new DataView(result.buffer); result.set(header(1, i));
|
|
100
|
+
out.setUint32(12, horizontal ? 3 : 1, true); nscvRenderPutRect(out, 32, viewport); return result;
|
|
101
|
+
}
|
|
102
|
+
let parent = n.route.parent, root = i;
|
|
103
|
+
while (parent < count && !nscvHostEligible(nodeFacts[parent]!)) parent = nodes[parent]!.parent;
|
|
104
|
+
while (root < count && !nscvRouteEscapes(nodes[root]!)) root = nodes[root]!.parent;
|
|
105
|
+
let mask = overflow ? 1 : 0;
|
|
106
|
+
if (!overflow) for (let b = 0; b < occluderNodes.length; b++) {
|
|
107
|
+
const o = occluderNodes[b]!;
|
|
108
|
+
if (o === i || o === root || nscvHostAncestor(nodes, o, i)) continue;
|
|
109
|
+
if (root < count) {
|
|
110
|
+
const rl = nscvRouteSurfaceLayer(nodes, root, layers), ol = nscvRouteSurfaceLayer(nodes, o, layers);
|
|
111
|
+
if (ol < rl || ol === rl && o < root) continue;
|
|
112
|
+
}
|
|
113
|
+
mask |= 1 << b;
|
|
114
|
+
}
|
|
115
|
+
const x = horizontal ? n.valueX : 0, y = vertical ? n.route.value : 0;
|
|
116
|
+
let matched = missing;
|
|
117
|
+
for (let j = 0; j < tracked; j++) if (w.getUint32(trackedAt + j * 16, true) === n.route.lo && w.getUint32(trackedAt + j * 16 + 4, true) === n.route.hi) { matched = j; break; }
|
|
118
|
+
const pushX = matched === missing || Math.abs(f(w.getFloat32(trackedAt + matched * 16 + 8, true) - x)) > 0.5;
|
|
119
|
+
const pushY = matched === missing || Math.abs(f(w.getFloat32(trackedAt + matched * 16 + 12, true) - y)) > 0.5;
|
|
120
|
+
const override = (n.config >>> 4) & 3, rubber = override === 2 || override === 0 && baseRubber !== 0;
|
|
121
|
+
drivers.push({ node: i, parent, mask, frame: n.route.frame,
|
|
122
|
+
width: horizontal ? f(n.route.frame.width + nscvSurfaceMax(0, f(n.extentX - viewport.width))) : n.route.frame.width,
|
|
123
|
+
height: vertical ? f(n.route.frame.height + nscvSurfaceMax(0, f(n.extentY - viewport.height))) : n.route.frame.height,
|
|
124
|
+
x, y, flags: (pushX ? 1 : 0) | (pushY ? 2 : 0) | (rubber ? 4 : 0) | (horizontal ? 8 : 0) | (vertical ? 16 : 0) });
|
|
125
|
+
}
|
|
126
|
+
} else if (mode === 2 && (facts & 2) !== 0) {
|
|
127
|
+
for (let i = 0; i < count; i++) {
|
|
128
|
+
const n = nodes[i]!;
|
|
129
|
+
if (!nscvRouteLive(n) || (n.flags & 64) === 0 || nscvRouteHidden(nodes, i) || !nscvRouteVisible(nodes, i, false, 0, 0)) continue;
|
|
130
|
+
const start = regions.length;
|
|
131
|
+
if (start >= capacity) break;
|
|
132
|
+
regions.push({ frame: n.frame, exclusion: false });
|
|
133
|
+
let overflow = false;
|
|
134
|
+
for (let j = 0; j < count; j++) {
|
|
135
|
+
if (j === i || !nscvRouteClaims(nodes[j]!) || nscvRouteHidden(nodes, j) || !nscvRouteVisible(nodes, j, false, 0, 0) || !nscvHostAncestor(nodes, i, j)) continue;
|
|
136
|
+
if (regions.length >= capacity) { overflow = true; break; }
|
|
137
|
+
regions.push({ frame: nodes[j]!.frame, exclusion: true });
|
|
138
|
+
}
|
|
139
|
+
if (overflow) { regions.length = start; break; }
|
|
140
|
+
}
|
|
141
|
+
let same = regions.length === previous;
|
|
142
|
+
for (let i = 0; i < regions.length && same; i++) {
|
|
143
|
+
const r = regions[i]!, at = previousAt + i * 20;
|
|
144
|
+
same = r.frame.x === w.getFloat32(at, true) && r.frame.y === w.getFloat32(at + 4, true) && r.frame.width === w.getFloat32(at + 8, true) && r.frame.height === w.getFloat32(at + 12, true) && r.exclusion === (w.getUint32(at + 16, true) !== 0);
|
|
145
|
+
}
|
|
146
|
+
verdict = (facts & 4) !== 0 ? same ? 0 : 1 : regions.length === 0 ? 0 : 1;
|
|
147
|
+
} else if (mode === 3) {
|
|
148
|
+
verdict = tracked < 16 ? tracked : missing;
|
|
149
|
+
for (let i = 0; i < tracked; i++) if (w.getUint32(trackedAt + i * 16, true) === w.getUint32(40, true) && w.getUint32(trackedAt + i * 16 + 4, true) === w.getUint32(44, true)) { verdict = i; break; }
|
|
150
|
+
}
|
|
151
|
+
const result = new Uint8Array(32 + stamps.length * 4 + drivers.length * 64 + occluders.length * 16 + regions.length * 20), out = new DataView(result.buffer);
|
|
152
|
+
result.set(header(0, verdict)); out.setUint32(12, stamps.length, true); out.setUint32(16, drivers.length, true); out.setUint32(20, occluders.length, true); out.setUint32(24, regions.length, true);
|
|
153
|
+
let at = 32;
|
|
154
|
+
for (const i of stamps) { out.setUint32(at, i, true); at += 4; }
|
|
155
|
+
for (const driver of drivers) {
|
|
156
|
+
const n = nodes[driver.node]!;
|
|
157
|
+
out.setUint32(at, n.lo, true); out.setUint32(at + 4, n.hi, true);
|
|
158
|
+
if (driver.parent < count) { out.setUint32(at + 8, nodes[driver.parent]!.lo, true); out.setUint32(at + 12, nodes[driver.parent]!.hi, true); }
|
|
159
|
+
out.setUint32(at + 16, driver.mask, true); out.setUint32(at + 20, driver.flags, true); nscvRenderPutRect(out, at + 24, driver.frame);
|
|
160
|
+
out.setFloat32(at + 40, driver.width, true); out.setFloat32(at + 44, driver.height, true); out.setFloat32(at + 48, driver.x, true); out.setFloat32(at + 52, driver.y, true); at += 64;
|
|
161
|
+
}
|
|
162
|
+
for (const frame of occluders) { nscvRenderPutRect(out, at, frame); at += 16; }
|
|
163
|
+
for (const region of regions) { nscvRenderPutRect(out, at, region.frame); out.setUint32(at + 16, region.exclusion ? 1 : 0, true); at += 20; }
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Loop-thread image and adopted-texture decisions over copied observations.
|
|
2
|
+
* Pixels, allocation, codec calls, producer locks and GPU calls remain native.
|
|
3
|
+
*/
|
|
4
|
+
function nscvImageRegistry(request: Uint8Array): Uint8Array {
|
|
5
|
+
if (request.length < 96 || request[0] !== 82 || request[1] !== 1 || request[2]! > 8 || (request[3] !== 32 && request[3] !== 64))
|
|
6
|
+
throw new Error("invalid image registry header");
|
|
7
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
8
|
+
const mode = request[2]!, count = w.getUint32(4, true), capacity = w.getUint32(8, true), cursor = w.getUint32(12, true), facts = w.getUint32(16, true);
|
|
9
|
+
if (count > capacity || capacity > 32 || request.length !== 96 + count * 32 || facts > 3 || (mode === 5 && capacity !== 4) || (mode <= 3 && capacity !== 16))
|
|
10
|
+
throw new Error("invalid image registry bounds");
|
|
11
|
+
for (let at = 72; at < 96; at++) if (request[at] !== 0) throw new Error("invalid image registry reserved bytes");
|
|
12
|
+
for (let i = 0; i < count; i++) {
|
|
13
|
+
const at = 96 + i * 32;
|
|
14
|
+
if (w.getUint32(at + 16, true) > 3) throw new Error("invalid image registry record");
|
|
15
|
+
for (let j = 20; j < 32; j++) if (request[at + j] !== 0) throw new Error("invalid image registry record padding");
|
|
16
|
+
}
|
|
17
|
+
const same = (a: number, b: number): boolean => w.getUint32(a, true) === w.getUint32(b, true) && w.getUint32(a + 4, true) === w.getUint32(b + 4, true);
|
|
18
|
+
const zero = (at: number): boolean => w.getUint32(at, true) === 0 && w.getUint32(at + 4, true) === 0;
|
|
19
|
+
const greater = (a: number, b: number): boolean => w.getUint32(a + 4, true) > w.getUint32(b + 4, true) || w.getUint32(a + 4, true) === w.getUint32(b + 4, true) && w.getUint32(a, true) > w.getUint32(b, true);
|
|
20
|
+
let selected = -1, status = 0, action = 0, next = 4294967295;
|
|
21
|
+
if (mode !== 4) for (let i = 0; i < count; i++) {
|
|
22
|
+
const at = 96 + i * 32;
|
|
23
|
+
if (same(24, at) && (mode !== 7 && mode !== 8 || !zero(at + 8))) { selected = i; break; }
|
|
24
|
+
}
|
|
25
|
+
if (mode === 0 || mode === 1) {
|
|
26
|
+
if (zero(24) || (w.getUint32(28, true) & 2147483648) !== 0) status = 1;
|
|
27
|
+
else if (mode === 1) {
|
|
28
|
+
if (w.getUint32(52, true) !== 0 || w.getUint32(48, true) > w.getUint32(20, true)) status = 3;
|
|
29
|
+
else action = 1;
|
|
30
|
+
} else {
|
|
31
|
+
// Base-65536 multiplication keeps every intermediate exact, including
|
|
32
|
+
// size_t overflow on both 32-bit and 64-bit native hosts.
|
|
33
|
+
const a: number[] = [], b: number[] = [], product: number[] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
34
|
+
for (let i = 0; i < 4; i++) { a.push(w.getUint16(32 + i * 2, true)); b.push(w.getUint16(40 + i * 2, true)); }
|
|
35
|
+
for (let i = 0; i < 4; i++) for (let j = 0; j < 4; j++) product[i + j] = product[i + j]! + a[i]! * b[j]! * 4;
|
|
36
|
+
for (let i = 0; i < 8; i++) { product[i + 1] = product[i + 1]! + Math.floor(product[i]! / 65536); product[i] = product[i]! % 65536; }
|
|
37
|
+
let overflow = false, matches = true;
|
|
38
|
+
for (let i = request[3] === 32 ? 2 : 4; i < 9; i++) if (product[i] !== 0) overflow = true;
|
|
39
|
+
for (let i = 0; i < 4; i++) if (product[i] !== w.getUint16(48 + i * 2, true)) matches = false;
|
|
40
|
+
if (zero(32) || zero(40) || overflow || !matches) status = 2;
|
|
41
|
+
else if (greater(48, 56)) status = 3;
|
|
42
|
+
else if (selected < 0 && count === capacity) status = 4;
|
|
43
|
+
else { if (selected < 0) selected = count; action = 1; }
|
|
44
|
+
}
|
|
45
|
+
} else if (mode === 3) { if (selected >= 0) action = 2; }
|
|
46
|
+
else if (mode === 4) {
|
|
47
|
+
if (cursor >= count) throw new Error("invalid image registry view cursor");
|
|
48
|
+
if (w.getUint32(96 + cursor * 32 + 16, true) === 3) action = 4;
|
|
49
|
+
selected = cursor;
|
|
50
|
+
} else if (mode === 5) {
|
|
51
|
+
if (selected >= 0) action = 1;
|
|
52
|
+
else if (count < capacity) { selected = count; action = 8; }
|
|
53
|
+
else if ((facts & 1) === 0) { action = 16; next = 0; }
|
|
54
|
+
else {
|
|
55
|
+
if (cursor >= count) throw new Error("invalid image registry reclaim cursor");
|
|
56
|
+
if ((facts & 2) === 0) { selected = cursor; action = 32; }
|
|
57
|
+
else if (cursor + 1 < count) { action = 16; next = cursor + 1; }
|
|
58
|
+
}
|
|
59
|
+
} else if (mode === 6) {
|
|
60
|
+
if (same(64, 56)) action = 64;
|
|
61
|
+
} else if (mode === 8 && selected >= 0) action = 128;
|
|
62
|
+
const result = new Uint8Array(32), out = new DataView(result.buffer);
|
|
63
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true);
|
|
64
|
+
out.setUint32(12, selected < 0 ? 4294967295 : selected, true); out.setUint32(16, action, true); out.setUint32(20, next, true);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Portable spinner geometry, pose, trail and command identities. Appearance
|
|
2
|
+
* owners resolve ink and stroke width. Native evaluates the requested sine and
|
|
3
|
+
* cosine pairs with the platform math the reference uses, and draws. */
|
|
4
|
+
|
|
5
|
+
// Float32 degrees-to-radians factor, exactly as the native reference rounds it.
|
|
6
|
+
const nscIndicatorRadiansPerDegree = 0x8efa35 * 2 ** -29;
|
|
7
|
+
|
|
8
|
+
function nscvIndicatorPlans(request: Uint8Array): Uint8Array {
|
|
9
|
+
if (request.length !== 256 || request[0] !== 51 || request[1]! > 1 || request[2] !== 1 || request[3]! > 15 || request[4]! > 1 || request[5]! > 3 || request[6]! > 31 || request[7] !== 0) throw new Error("invalid indicator plan header");
|
|
10
|
+
for (let i = 84; i < 96; i++) if (request[i] !== 0) throw new Error("invalid indicator plan tail");
|
|
11
|
+
for (let i = 224; i < 256; i++) if (request[i] !== 0) throw new Error("invalid indicator plan tail");
|
|
12
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), f = Math.fround, numeric = request[3]!, flags = request[5]!;
|
|
13
|
+
const max = (a: number, b: number): number => nscvRenderExtreme(a, b, numeric, true);
|
|
14
|
+
const min = (a: number, b: number): number => nscvRenderExtreme(a, b, numeric, false);
|
|
15
|
+
const clamp = (v: number, lo: number, hi: number): number => max(lo, min(v, hi));
|
|
16
|
+
// Raw signaling NaN operands follow the target's native min/max behavior.
|
|
17
|
+
const signaling = (at: number): boolean => { const word = w.getUint32(at, true); return (word & 0x7f800000) === 0x7f800000 && (word & 0x007fffff) !== 0 && (word & 0x00400000) === 0; };
|
|
18
|
+
const unit = (at: number): number => signaling(at) && (request[6]! & 1) !== 0 ? 0 : clamp(w.getFloat32(at, true), 0, 1);
|
|
19
|
+
const positive = (at: number): number => signaling(at) && (request[6]! & 16) !== 0 ? NaN : max(0, w.getFloat32(at, true));
|
|
20
|
+
const id = nscvPrimitiveWord(w, 28), count = Math.trunc(clamp(w.getUint32(52, true), 3, 15)), segmented = request[4] === 1;
|
|
21
|
+
const frame = nscvRenderRect(w, 8);
|
|
22
|
+
if (request[1] === 1) {
|
|
23
|
+
// Motion anchors: the runtime arms loops on exactly these commands and
|
|
24
|
+
// spins the arc about the pixel-snapped painted center.
|
|
25
|
+
const result = new Uint8Array(160), out = new DataView(result.buffer), scale = w.getFloat32(80, true);
|
|
26
|
+
let painted = frame;
|
|
27
|
+
if ((flags & 2) !== 0 && Number.isFinite(scale) && scale > 0) {
|
|
28
|
+
const round = (x: number): number => x < 0 || 1 / x < 0 ? -Math.floor(-x + 0.5) : Math.floor(x + 0.5);
|
|
29
|
+
const snap = (x: number): number => f(round(f(x * scale)) / scale), r = nscvSurfaceNormalize(frame);
|
|
30
|
+
const x0 = snap(r.x), y0 = snap(r.y), x1 = snap(f(r.x + r.width)), y1 = snap(f(r.y + r.height));
|
|
31
|
+
painted = { x: x0, y: y0, width: max(0, f(x1 - x0)), height: max(0, f(y1 - y0)) };
|
|
32
|
+
}
|
|
33
|
+
painted = nscvSurfaceNormalize(painted);
|
|
34
|
+
out.setUint32(0, 1, true); out.setUint32(16, count, true);
|
|
35
|
+
out.setFloat32(20, f(painted.x + f(painted.width * 0.5)), true); out.setFloat32(24, f(painted.y + f(painted.height * 0.5)), true);
|
|
36
|
+
nscvPrimitiveWrite(out, 28, nscvPrimitivePart(id, { primitiveLo: 2, primitiveHi: 0 }));
|
|
37
|
+
for (let i = 0; i < count; i++) nscvPrimitiveWrite(out, 40 + i * 8, nscvPrimitivePart(id, { primitiveLo: 1 + i, primitiveHi: 0 }));
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
const result = new Uint8Array(40 + 15 * 256), out = new DataView(result.buffer);
|
|
41
|
+
out.setUint32(0, 1, true);
|
|
42
|
+
const normalized = nscvSurfaceNormalize(frame);
|
|
43
|
+
if (nscvRenderEmpty(normalized)) return result;
|
|
44
|
+
const size = signaling(16) && (request[6]! & 2) !== 0 || signaling(20) && (request[6]! & 4) !== 0 ? NaN : min(normalized.width, normalized.height);
|
|
45
|
+
if (size <= 0) return result;
|
|
46
|
+
const value = unit(24), radians = (degrees: number): number => f(degrees * nscIndicatorRadiansPerDegree);
|
|
47
|
+
const start = f(-90 + f(value * 360)), total = 4, delta = f(288 / total);
|
|
48
|
+
const angles: number[] = [];
|
|
49
|
+
if (segmented) for (let segment = 0; segment < count; segment++) angles.push(radians(f(-90 + f(f(360 * segment) / count))));
|
|
50
|
+
else { angles.push(radians(start)); for (let segment = 0; segment < total; segment++) angles.push(radians(f(start + f(delta * segment))), radians(f(start + f(delta * (segment + 1))))); }
|
|
51
|
+
if ((flags & 1) === 0) {
|
|
52
|
+
// Ask for ink, the arc stroke with its box-relative fallback, and the
|
|
53
|
+
// platform sine/cosine of every angle the geometry uses.
|
|
54
|
+
out.setUint32(4, 1, true); out.setFloat32(12, segmented ? 0 : f(size * f(2 / 24)), true); out.setUint32(16, angles.length, true);
|
|
55
|
+
angles.forEach((angle, i) => out.setFloat32(40 + i * 4, angle, true));
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
let next = 0;
|
|
59
|
+
const pair = (angle: number): { sin: number; cos: number } => {
|
|
60
|
+
if (next >= angles.length || angles[next] !== angle && !(Number.isNaN(angle) && Number.isNaN(angles[next]!))) throw new Error("indicator angle order changed");
|
|
61
|
+
const at = 96 + next++ * 8;
|
|
62
|
+
return { sin: w.getFloat32(at, true), cos: w.getFloat32(at + 4, true) };
|
|
63
|
+
};
|
|
64
|
+
const center = { x: f(normalized.x + f(normalized.width * 0.5)), y: f(normalized.y + f(normalized.height * 0.5)) };
|
|
65
|
+
const ink = [w.getFloat32(36, true), w.getFloat32(40, true), w.getFloat32(44, true), w.getFloat32(48, true)];
|
|
66
|
+
let commands = 0, cursor = 0;
|
|
67
|
+
const begin = (slot: number, stroke: boolean, alpha: number): void => {
|
|
68
|
+
const at = 40 + commands * 256;
|
|
69
|
+
nscvPrimitiveWrite(out, at, nscvPrimitivePart(id, { primitiveLo: slot, primitiveHi: 0 }));
|
|
70
|
+
out.setUint32(at + 8, stroke ? 1 : 0, true);
|
|
71
|
+
for (let i = 0; i < 3; i++) out.setFloat32(at + 16 + i * 4, ink[i]!, true);
|
|
72
|
+
out.setFloat32(at + 28, alpha, true);
|
|
73
|
+
cursor = at + 32; commands += 1;
|
|
74
|
+
};
|
|
75
|
+
const element = (verb: number, ...points: number[]): void => {
|
|
76
|
+
const at = 40 + (commands - 1) * 256;
|
|
77
|
+
out.setUint32(at + 12, out.getUint32(at + 12, true) + 1, true);
|
|
78
|
+
out.setUint32(cursor, verb, true);
|
|
79
|
+
for (let i = 0; i < points.length; i++) out.setFloat32(cursor + 4 + i * 4, points[i]!, true);
|
|
80
|
+
cursor += 28;
|
|
81
|
+
};
|
|
82
|
+
if (!segmented) {
|
|
83
|
+
const radius = f(size * f(9 / 24));
|
|
84
|
+
if (radius <= 0) return result;
|
|
85
|
+
// The reference evaluates tan(72/4 degrees) at compile time: 0x3ea65be0.
|
|
86
|
+
const kappa = f(f(f(4 / 3) * (0xa65be0 * 2 ** -25)) * radius), first = pair(radians(start));
|
|
87
|
+
out.setFloat32(12, w.getFloat32(76, true), true);
|
|
88
|
+
begin(2, true, ink[3]!);
|
|
89
|
+
element(0, f(center.x + f(radius * first.cos)), f(center.y + f(radius * first.sin)));
|
|
90
|
+
for (let segment = 0; segment < total; segment++) {
|
|
91
|
+
const a0 = pair(radians(f(start + f(delta * segment)))), a1 = pair(radians(f(start + f(delta * (segment + 1)))));
|
|
92
|
+
const from = { x: f(center.x + f(radius * a0.cos)), y: f(center.y + f(radius * a0.sin)) };
|
|
93
|
+
const to = { x: f(center.x + f(radius * a1.cos)), y: f(center.y + f(radius * a1.sin)) };
|
|
94
|
+
element(2, f(from.x - f(kappa * a0.sin)), f(from.y + f(kappa * a0.cos)), f(to.x + f(kappa * a1.sin)), f(to.y - f(kappa * a1.cos)), to.x, to.y);
|
|
95
|
+
}
|
|
96
|
+
out.setUint32(8, commands, true);
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
const length = f(size * positive(56)), thickness = f(size * positive(60)), orbit = f(size * positive(64));
|
|
100
|
+
if (length <= 0 || thickness <= 0) return result;
|
|
101
|
+
const tail = unit(68), reduceMotion = w.getUint32(72, true) === 0;
|
|
102
|
+
const cap = f(thickness * 0.5), half = max(f(f(length * 0.5) - cap), 0), k = f(f(0.5522847498) * cap);
|
|
103
|
+
for (let segment = 0; segment < count; segment++) {
|
|
104
|
+
const trig = pair(radians(f(-90 + f(f(360 * segment) / count))));
|
|
105
|
+
const u = { x: trig.cos, y: trig.sin }, v = { x: -trig.sin, y: trig.cos };
|
|
106
|
+
const pill = { x: f(center.x + f(orbit * u.x)), y: f(center.y + f(orbit * u.y)) };
|
|
107
|
+
const inner = { x: f(pill.x - f(half * u.x)), y: f(pill.y - f(half * u.y)) }, outer = { x: f(pill.x + f(half * u.x)), y: f(pill.y + f(half * u.y)) };
|
|
108
|
+
let opacity = 1;
|
|
109
|
+
if (reduceMotion) {
|
|
110
|
+
// The frozen pose: each step clockwise ahead of the head is one cycle fraction older.
|
|
111
|
+
let distance = f(f(segment / count) - value);
|
|
112
|
+
distance = f(distance - Math.floor(distance));
|
|
113
|
+
let age = f(1 - distance);
|
|
114
|
+
if (age >= 1) age = 0;
|
|
115
|
+
opacity = f(1 - f(f(1 - tail) * age));
|
|
116
|
+
}
|
|
117
|
+
const a = { x: f(inner.x + f(cap * v.x)), y: f(inner.y + f(cap * v.y)) }, b = { x: f(outer.x + f(cap * v.x)), y: f(outer.y + f(cap * v.y)) };
|
|
118
|
+
const outerMid = { x: f(outer.x + f(cap * u.x)), y: f(outer.y + f(cap * u.y)) }, e = { x: f(outer.x - f(cap * v.x)), y: f(outer.y - f(cap * v.y)) };
|
|
119
|
+
const g = { x: f(inner.x - f(cap * v.x)), y: f(inner.y - f(cap * v.y)) }, innerMid = { x: f(inner.x - f(cap * u.x)), y: f(inner.y - f(cap * u.y)) };
|
|
120
|
+
begin(1 + segment, false, clamp(f(ink[3]! * opacity), 0, 1));
|
|
121
|
+
element(0, a.x, a.y);
|
|
122
|
+
element(1, b.x, b.y);
|
|
123
|
+
element(2, f(b.x + f(k * u.x)), f(b.y + f(k * u.y)), f(outerMid.x + f(k * v.x)), f(outerMid.y + f(k * v.y)), outerMid.x, outerMid.y);
|
|
124
|
+
element(2, f(outerMid.x - f(k * v.x)), f(outerMid.y - f(k * v.y)), f(e.x + f(k * u.x)), f(e.y + f(k * u.y)), e.x, e.y);
|
|
125
|
+
element(1, g.x, g.y);
|
|
126
|
+
element(2, f(g.x - f(k * u.x)), f(g.y - f(k * u.y)), f(innerMid.x - f(k * v.x)), f(innerMid.y - f(k * v.y)), innerMid.x, innerMid.y);
|
|
127
|
+
element(2, f(innerMid.x + f(k * v.x)), f(innerMid.y + f(k * v.y)), f(a.x - f(k * u.x)), f(a.y - f(k * u.y)), a.x, a.y);
|
|
128
|
+
element(3);
|
|
129
|
+
}
|
|
130
|
+
out.setUint32(8, commands, true);
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
// into a slot some use forces to be an integer — that is a conflict reported
|
|
24
24
|
// as a teaching error (NS1016), never a downstream Zig type error.
|
|
25
25
|
|
|
26
|
-
import { ts, TypedAst, exportListBindings } from "./typed_ast.ts";
|
|
26
|
+
import { ts, TypedAst, exportListBindings, sdkLibraryModules } from "./typed_ast.ts";
|
|
27
|
+
import path from "node:path";
|
|
27
28
|
import { constFunctionValue } from "./ownership.ts";
|
|
28
29
|
import { thrownShapeOf } from "./checker.ts";
|
|
29
30
|
import type { TypeTable } from "./types.ts";
|
|
@@ -275,7 +276,23 @@ export class IntInference {
|
|
|
275
276
|
this.addSlot(node, node.name.text);
|
|
276
277
|
}
|
|
277
278
|
} else if (ts.isPropertySignature(node) && node.name && ts.isIdentifier(node.name)) {
|
|
278
|
-
if (this.numberish(node.type))
|
|
279
|
+
if (this.numberish(node.type)) {
|
|
280
|
+
// Canonical token numbers cross a fixed native register. Their ABI
|
|
281
|
+
// remains f64 across apps; the native capability validates integer
|
|
282
|
+
// ids/ranges and performs the explicit f32 conversion.
|
|
283
|
+
const theme = sdkLibraryModules.get("@native-sdk/core/theme");
|
|
284
|
+
const events = sdkLibraryModules.get("@native-sdk/core/events");
|
|
285
|
+
let owner: ts.Node = node.parent;
|
|
286
|
+
while (!ts.isInterfaceDeclaration(owner) && !ts.isTypeAliasDeclaration(owner) && owner.parent) owner = owner.parent;
|
|
287
|
+
const canvasRecord = events !== undefined && path.resolve(node.getSourceFile().fileName) === path.resolve(events) &&
|
|
288
|
+
(ts.isInterfaceDeclaration(owner) || ts.isTypeAliasDeclaration(owner)) &&
|
|
289
|
+
["CanvasFrameEvent", "CanvasColor", "CanvasRect", "CanvasPoint", "CanvasGradientStop", "CanvasStroke", "CanvasRadius", "CanvasPathElement", "CanvasChromeCommand", "CanvasChromeContext", "CanvasTransform", "CanvasAnimation"].includes(owner.name.text);
|
|
290
|
+
// Canvas inputs include fractional native geometry; declarations
|
|
291
|
+
// retain one f64 ABI across apps. Native checks integer selectors
|
|
292
|
+
// and durations and explicitly converts GPU scalars to f32.
|
|
293
|
+
if (canvasRecord || theme !== undefined && path.resolve(node.getSourceFile().fileName) === path.resolve(theme)) this.addFloatSlot(node, node.name.text);
|
|
294
|
+
else this.addSlot(node, node.name.text);
|
|
295
|
+
}
|
|
279
296
|
} else if (ts.isPropertyDeclaration(node) && node.name && ts.isIdentifier(node.name)) {
|
|
280
297
|
// R19: a class field is a slot like a record field, fed by its
|
|
281
298
|
// initializer and by `this.x = ...` writes (wired in collectFlows).
|
|
@@ -489,6 +506,14 @@ export class IntInference {
|
|
|
489
506
|
}
|
|
490
507
|
};
|
|
491
508
|
markType("Msg");
|
|
509
|
+
// Fixed helper arguments are constructed by the host. Their nested
|
|
510
|
+
// records, arrays and optional records obey the same boundary rule as
|
|
511
|
+
// Msg; only actual integer demand can specialize a numeric field.
|
|
512
|
+
for (const helper of this.table.modelHelperDecls()) {
|
|
513
|
+
for (const parameter of helper.decl.parameters.slice(1)) {
|
|
514
|
+
if (parameter.type) this.markNested(this.table.resolveTypeNode(parameter.type), markType);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
492
517
|
// Only the ENTRY module's exports face the host ABI (the wiring and
|
|
493
518
|
// markup bind through the entry). An exported function in an imported
|
|
494
519
|
// module is an ordinary cross-module call, so proof still applies —
|
|
@@ -555,7 +580,7 @@ export class IntInference {
|
|
|
555
580
|
// model may return fractional positions or dimensions through the same
|
|
556
581
|
// SDK record. Mark the descriptor's immediate number fields as boundary
|
|
557
582
|
// values, exactly like a host-constructed event record in reverse.
|
|
558
|
-
if (stmt.name?.text === "windows" && stmt.type) {
|
|
583
|
+
if ((stmt.name?.text === "windows" || stmt.name?.text === "webPanes") && stmt.type) {
|
|
559
584
|
const returned = this.table.resolveTypeNode(stmt.type);
|
|
560
585
|
if (returned.k === "slice" && returned.elem.k === "struct") {
|
|
561
586
|
const descriptor = this.table.structs.get(returned.elem.name);
|
|
@@ -841,7 +866,12 @@ export class IntInference {
|
|
|
841
866
|
}
|
|
842
867
|
}
|
|
843
868
|
if (ts.isConditionalExpression(expr)) {
|
|
844
|
-
|
|
869
|
+
// A positive, finite, safe range makes truncation whole, including
|
|
870
|
+
// the NaN/Infinity and negative-zero corners that unguarded Math
|
|
871
|
+
// calls must retain. Only this branch gains the proof; the fallback
|
|
872
|
+
// still contributes its own class normally.
|
|
873
|
+
if (this.positiveBoundedTruncation(expr.condition, expr.whenTrue)) c.intSource = true;
|
|
874
|
+
else this.contribute(expr.whenTrue, c);
|
|
845
875
|
this.contribute(expr.whenFalse, c);
|
|
846
876
|
return;
|
|
847
877
|
}
|
|
@@ -891,7 +921,7 @@ export class IntInference {
|
|
|
891
921
|
for (const arg of expr.arguments) this.contribute(arg, c);
|
|
892
922
|
return;
|
|
893
923
|
}
|
|
894
|
-
if (method === "round" || method === "sqrt") {
|
|
924
|
+
if (method === "round" || method === "sqrt" || method === "fround") {
|
|
895
925
|
// Definitely-float sources: round/sqrt of NaN/Infinity is not an
|
|
896
926
|
// integer (and sqrt is irrational off perfect squares), so these
|
|
897
927
|
// live in f64 slots and an index use is a taught conflict. The
|
|
@@ -976,11 +1006,121 @@ export class IntInference {
|
|
|
976
1006
|
c.unknown = true;
|
|
977
1007
|
}
|
|
978
1008
|
|
|
1009
|
+
private positiveBoundedTruncation(condition: ts.Expression, branch: ts.Expression): boolean {
|
|
1010
|
+
const isTruncation = (node: ts.Expression): node is ts.CallExpression => {
|
|
1011
|
+
if (!ts.isCallExpression(node) || node.arguments.length !== 1 ||
|
|
1012
|
+
!ts.isPropertyAccessExpression(node.expression) ||
|
|
1013
|
+
!ts.isIdentifier(node.expression.expression) || node.expression.expression.text !== "Math" ||
|
|
1014
|
+
node.expression.name.text !== "trunc" || !ts.isIdentifier(node.arguments[0])) return false;
|
|
1015
|
+
const math = this.tast.declarationOf(node.expression.expression);
|
|
1016
|
+
return math === undefined || !this.fileSet.has(math.getSourceFile());
|
|
1017
|
+
};
|
|
1018
|
+
if (!isTruncation(branch)) return false;
|
|
1019
|
+
const declaration = this.tast.declarationOf(branch.arguments[0]!);
|
|
1020
|
+
if (!declaration) return false;
|
|
1021
|
+
const sameValue = (node: ts.Expression): boolean => ts.isIdentifier(node) && this.tast.declarationOf(node) === declaration;
|
|
1022
|
+
let positive = false, bounded = false;
|
|
1023
|
+
const visit = (node: ts.Expression): boolean => {
|
|
1024
|
+
if (ts.isParenthesizedExpression(node)) return visit(node.expression);
|
|
1025
|
+
if (!ts.isBinaryExpression(node)) return false;
|
|
1026
|
+
if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) return visit(node.left) && visit(node.right);
|
|
1027
|
+
if (!sameValue(node.left)) return false;
|
|
1028
|
+
// This optional whole-value check is pure. All other terms are refused:
|
|
1029
|
+
// an intervening call or assignment could invalidate an earlier bound.
|
|
1030
|
+
if (node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken &&
|
|
1031
|
+
isTruncation(node.right) && sameValue(node.right.arguments[0]!)) return true;
|
|
1032
|
+
// Literal bounds require no execution and cannot hide a shadowed Math.
|
|
1033
|
+
if (!ts.isNumericLiteral(node.right)) return false;
|
|
1034
|
+
const bound = Number(node.right.text), op = node.operatorToken.kind;
|
|
1035
|
+
if (!Number.isFinite(bound)) return false;
|
|
1036
|
+
if (op === ts.SyntaxKind.GreaterThanToken && bound >= 0 ||
|
|
1037
|
+
op === ts.SyntaxKind.GreaterThanEqualsToken && bound > 0) { positive = true; return true; }
|
|
1038
|
+
if ((op === ts.SyntaxKind.LessThanToken || op === ts.SyntaxKind.LessThanEqualsToken) &&
|
|
1039
|
+
bound > 0 && Number.isSafeInteger(bound)) { bounded = true; return true; }
|
|
1040
|
+
return false;
|
|
1041
|
+
};
|
|
1042
|
+
return visit(condition) && positive && bounded;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
979
1045
|
private flowInto(target: ts.Node | undefined, expr: ts.Expression): void {
|
|
980
1046
|
if (!target) return;
|
|
981
1047
|
const slot = this.slots.get(target);
|
|
982
|
-
if (
|
|
983
|
-
|
|
1048
|
+
if (slot) {
|
|
1049
|
+
slot.inflows.push(this.contribution(expr));
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
// Passing a whole record does not read its numeric fields syntactically,
|
|
1053
|
+
// but it still assigns each field to the callee's corresponding slot.
|
|
1054
|
+
// Wire declarations, not spellings: separate union arms may use the same
|
|
1055
|
+
// field name while requiring different numeric representations.
|
|
1056
|
+
if (ts.isParameter(target) || ts.isVariableDeclaration(target) ||
|
|
1057
|
+
ts.isPropertySignature(target) || ts.isPropertyDeclaration(target)) {
|
|
1058
|
+
this.flowStructured(this.tast.typeOf(target), this.tast.typeOf(expr), expr);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
private flowStructured(destination: ts.Type, source: ts.Type, site: ts.Expression): void {
|
|
1063
|
+
const visited = new Map<ts.Type, Set<ts.Type>>();
|
|
1064
|
+
const walk = (dst: ts.Type, src: ts.Type): void => {
|
|
1065
|
+
const seen = visited.get(dst);
|
|
1066
|
+
if (seen?.has(src)) return;
|
|
1067
|
+
if (seen) seen.add(src);
|
|
1068
|
+
else visited.set(dst, new Set([src]));
|
|
1069
|
+
if (dst.isUnion()) {
|
|
1070
|
+
for (const member of dst.types) walk(member, src);
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
if (src.isUnion()) {
|
|
1074
|
+
for (const member of src.types) walk(dst, member);
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
if (!(dst.flags & ts.TypeFlags.Object) || !(src.flags & ts.TypeFlags.Object)) return;
|
|
1078
|
+
const dstTag = this.tast.propertyTypeOf(dst, "kind");
|
|
1079
|
+
const srcTag = this.tast.propertyTypeOf(src, "kind");
|
|
1080
|
+
if (dstTag?.isStringLiteral() && srcTag?.isStringLiteral() && dstTag.value !== srcTag.value) return;
|
|
1081
|
+
if (this.tast.isArrayLikeType(dst) && this.tast.isArrayLikeType(src)) {
|
|
1082
|
+
const dstElement = this.tast.typeArgumentsOf(dst)[0];
|
|
1083
|
+
const srcElement = this.tast.typeArgumentsOf(src)[0];
|
|
1084
|
+
if (dstElement && srcElement) walk(dstElement, srcElement);
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
for (const property of dst.getProperties()) {
|
|
1088
|
+
const target = property.valueDeclaration ?? property.declarations?.[0];
|
|
1089
|
+
// Library implementation details and methods are not model fields.
|
|
1090
|
+
if (!target || !this.fileSet.has(target.getSourceFile()) ||
|
|
1091
|
+
!(ts.isPropertySignature(target) || ts.isPropertyDeclaration(target))) continue;
|
|
1092
|
+
const input = src.getProperty(property.name);
|
|
1093
|
+
const inputDecl = input?.valueDeclaration ?? input?.declarations?.[0];
|
|
1094
|
+
if (!inputDecl || inputDecl === target) continue;
|
|
1095
|
+
// SDK records cross their own checked boundary (for example, the
|
|
1096
|
+
// bounded SQLite page decoder). This application forwarding pass
|
|
1097
|
+
// must not invent unknown inflows for declarations it does not
|
|
1098
|
+
// analyze, demoting an already established model field ABI.
|
|
1099
|
+
if (!this.fileSet.has(inputDecl.getSourceFile())) continue;
|
|
1100
|
+
const slot = this.slots.get(target);
|
|
1101
|
+
if (slot) {
|
|
1102
|
+
const inputSlot = this.slots.get(inputDecl);
|
|
1103
|
+
if (inputSlot) {
|
|
1104
|
+
slot.inflows.push({ slots: [inputSlot], float: false, unknown: false, intSource: false, site });
|
|
1105
|
+
} else if (ts.isPropertyAssignment(inputDecl)) {
|
|
1106
|
+
slot.inflows.push(this.contribution(inputDecl.initializer));
|
|
1107
|
+
} else if (ts.isShorthandPropertyAssignment(inputDecl)) {
|
|
1108
|
+
const value = this.tast.shorthandValueDeclaration(inputDecl);
|
|
1109
|
+
const valueSlot = value ? this.slots.get(value) : undefined;
|
|
1110
|
+
slot.inflows.push({ slots: valueSlot ? [valueSlot] : [], float: false,
|
|
1111
|
+
unknown: valueSlot === undefined, intSource: false, site });
|
|
1112
|
+
} else {
|
|
1113
|
+
// An untracked numeric source cannot establish integer proof.
|
|
1114
|
+
slot.inflows.push({ slots: [], float: false, unknown: true, intSource: false, site });
|
|
1115
|
+
}
|
|
1116
|
+
} else {
|
|
1117
|
+
const dstField = this.tast.propertyTypeOf(dst, property.name);
|
|
1118
|
+
const srcField = this.tast.propertyTypeOf(src, property.name);
|
|
1119
|
+
if (dstField && srcField) walk(dstField, srcField);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
walk(destination, source);
|
|
984
1124
|
}
|
|
985
1125
|
|
|
986
1126
|
private demand(expr: ts.Expression): void {
|
|
@@ -1432,7 +1572,9 @@ export class IntInference {
|
|
|
1432
1572
|
);
|
|
1433
1573
|
if (hardFed || tentativeFed) {
|
|
1434
1574
|
demandSlot(s, !hardFed);
|
|
1435
|
-
|
|
1575
|
+
// Comparison demand may yield to a host-boundary inflow.
|
|
1576
|
+
// An unchanged slot does not advance this fixed point.
|
|
1577
|
+
if (s.demanded) changed = true;
|
|
1436
1578
|
}
|
|
1437
1579
|
} else if (s.comparisonDemanded && hardFed) {
|
|
1438
1580
|
demandSlot(s, false);
|