@native-sdk/cli 0.10.1 → 0.11.1
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 +393 -97
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +2030 -83
- package/native-sdk.d.ts +5 -1
- package/package.json +20 -14
- package/packages/core/compile-surface/core.ts +164 -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 +68 -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 +332 -5
- package/packages/core/sdk/core.ts +371 -85
- package/packages/core/sdk/events.d.ts +252 -0
- package/packages/core/sdk/events.ts +240 -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 +186 -19
- package/packages/core/src/cli.ts +2 -11
- 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/context_menus.ts +76 -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/diagnostics.ts +7 -0
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/extent_program.ts +53 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/frontend.ts +12 -10
- 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_canonical.ts +140 -0
- package/packages/core/src/markup_construction.ts +189 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/markup_display.ts +43 -0
- package/packages/core/src/markup_document.ts +226 -0
- package/packages/core/src/markup_elements.ts +225 -0
- package/packages/core/src/markup_expressions.ts +79 -0
- package/packages/core/src/markup_imports.ts +146 -0
- package/packages/core/src/markup_parser.ts +228 -0
- package/packages/core/src/markup_runtime.ts +93 -0
- package/packages/core/src/markup_scalars.ts +143 -0
- package/packages/core/src/markup_shapes.ts +243 -0
- package/packages/core/src/markup_specialized.ts +242 -0
- package/packages/core/src/markup_text.ts +86 -0
- package/packages/core/src/markup_values.ts +336 -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 +98 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +92 -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 +3954 -0
- package/packages/core/src/scalar_text.ts +82 -0
- package/packages/core/src/scroll_mutation.ts +86 -0
- package/packages/core/src/scroll_tree.ts +86 -0
- package/packages/core/src/service_contract.ts +55 -3
- 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 +14 -46
- package/packages/core/src/sqlite_codegen.ts +84 -0
- package/packages/core/src/staged_rebuild.ts +60 -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_bridge.ts +161 -0
- package/packages/core/src/view_check.ts +145 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_evaluator.ts +823 -0
- package/packages/core/src/view_frontend.ts +1102 -0
- package/packages/core/src/view_program.ts +221 -0
- package/packages/core/src/view_reload.ts +166 -0
- package/packages/core/src/view_reload_watch.ts +98 -0
- package/packages/core/src/view_sources.ts +34 -0
- package/packages/core/src/virtual_windows.ts +88 -0
- package/packages/core/src/web_panes.ts +67 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_continuity.ts +37 -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_reconcile.ts +63 -0
- package/packages/core/src/widget_retention.ts +62 -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 +77 -18
- package/skill-data/ts-core/SKILL.md +117 -11
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +288 -144
- package/src/app_runner/root.zig +39 -12
- package/src/app_runner/ts_compiled_view.zig +1702 -0
- package/src/app_runner/ts_core_main.zig +185 -14
- package/src/app_runner/ts_core_mobile.zig +25 -13
- package/src/automation/server.zig +57 -6
- 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/embed/host.zig +2 -0
- package/src/embed/tests.zig +2 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/keyboard_input.zig +32 -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 +4 -0
- package/src/platform/macos/appkit_host.h +7 -2
- package/src/platform/macos/appkit_host.m +219 -39
- package/src/platform/macos/cef_host.mm +15 -1
- package/src/platform/macos/global_shortcuts.zig +138 -0
- package/src/platform/macos/key_codes.zig +102 -0
- package/src/platform/macos/keyboard_input.zig +81 -0
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/root.zig +25 -3
- 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/webview_inspection_test.m +106 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +130 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +15 -0
- package/src/platform/types.zig +115 -0
- package/src/platform/windows/global_shortcuts.zig +157 -0
- package/src/platform/windows/key_codes.zig +63 -0
- package/src/platform/windows/keyboard_input.zig +136 -0
- package/src/platform/windows/root.zig +17 -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/decision_reuse.zig +133 -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/font_ttf.zig +27 -3
- package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
- package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
- package/src/primitives/canvas/fonts/OFL.txt +93 -0
- package/src/primitives/canvas/fonts/README.md +15 -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 +131 -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/markdown_tests.zig +3 -3
- 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 +15 -11
- package/src/primitives/canvas/reference_tests.zig +58 -0
- 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 +107 -4
- 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 +53 -37
- package/src/primitives/canvas/text_metrics_tests.zig +52 -7
- package/src/primitives/canvas/text_query_policy.zig +295 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +234 -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 +47 -0
- package/src/primitives/canvas/ui.zig +251 -83
- package/src/primitives/canvas/ui_markup.zig +207 -46
- package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +1724 -80
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
- package/src/primitives/canvas/ui_markup_construction.zig +146 -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_display.zig +82 -0
- package/src/primitives/canvas/ui_markup_document.zig +196 -0
- package/src/primitives/canvas/ui_markup_elements.zig +163 -0
- package/src/primitives/canvas/ui_markup_expr.zig +192 -2
- package/src/primitives/canvas/ui_markup_imports.zig +262 -0
- package/src/primitives/canvas/ui_markup_parser.zig +117 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
- package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
- package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
- package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_text.zig +128 -0
- package/src/primitives/canvas/ui_markup_values.zig +368 -0
- package/src/primitives/canvas/ui_markup_view.zig +3026 -57
- 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 +350 -0
- package/src/primitives/canvas/virtual_extents.zig +113 -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 +129 -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 +21 -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 +26 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +29 -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/bridge_payload.zig +2 -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 +183 -4
- package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
- 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 +720 -150
- 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/context_menu_policy.zig +112 -0
- package/src/runtime/core.zig +170 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +638 -33
- package/src/runtime/effects_host_tests.zig +25 -0
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +419 -341
- package/src/runtime/flow_reference.zig +1427 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/global_shortcuts.zig +75 -0
- 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/keyboard_input.zig +86 -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 +16 -0
- package/src/runtime/scroll_mutation_policy.zig +130 -0
- package/src/runtime/scroll_mutation_runtime.zig +158 -0
- package/src/runtime/scroll_tree_policy.zig +99 -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 +231 -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/staged_rebuild_policy.zig +83 -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 +65 -36
- package/src/runtime/tests.zig +2 -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 +2451 -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 +1111 -45
- package/src/runtime/ui_app.zig +1381 -650
- 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 +667 -188
- package/src/runtime/ui_app_window_tests.zig +222 -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_reload.zig +226 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +46 -26
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +503 -69
- package/src/runtime/virtual_window_policy.zig +128 -0
- package/src/runtime/web_pane_policy.zig +111 -0
- package/src/runtime/web_pane_test_cases.zig +204 -0
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_continuity_policy.zig +73 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/widget_reconcile_policy.zig +81 -0
- package/src/runtime/widget_retention_policy.zig +75 -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 +179 -11
- package/src/security/root.zig +1 -0
- 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 +23 -3
- package/src/tooling/ts_core.zig +97 -4
- package/src/tooling/verbs.zig +87 -1
- 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 +188 -0
- package/tools/corewire/core_abi.zig +55 -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 +361 -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 +300 -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 +39 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +28 -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 +59 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +204 -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 +269 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/** Runtime value, typed-message and binding programs (113). Native capabilities
|
|
2
|
+
* expose reflected types and exact numeric/storage facts; no pointer or i64 is
|
|
3
|
+
* transported through the numeric program fields. All names remain raw bytes.
|
|
4
|
+
*/
|
|
5
|
+
function nscmDot(path: Uint8Array): number {
|
|
6
|
+
for (let i = 0; i < path.length; i++) if (path[i] === 46) return i;
|
|
7
|
+
return -1;
|
|
8
|
+
}
|
|
9
|
+
function nscmIcon(r: NscElementReader, out: number[]): void {
|
|
10
|
+
const raw = r.blob(), names = r.names(), classification: number[] = [];
|
|
11
|
+
// Icons deliberately use raw expression grammar, even with a typed cache.
|
|
12
|
+
nsccAttribute(classification, 0, new Uint8Array(0), raw);
|
|
13
|
+
const kind = classification[1]!;
|
|
14
|
+
if (kind === 2) { nsceEmit(out, 73); return; }
|
|
15
|
+
if (kind !== 1) { nsceFail(out, 42); return; }
|
|
16
|
+
if (raw.length >= 4 && nsceNamed(raw.subarray(0, 4), "app:")) {
|
|
17
|
+
let dash = true;
|
|
18
|
+
for (let i = 4; i < raw.length; i++) {
|
|
19
|
+
const byte = raw[i]!;
|
|
20
|
+
if (byte >= 97 && byte <= 122 || byte >= 48 && byte <= 57) dash = false;
|
|
21
|
+
else if (byte === 45 && !dash) dash = true;
|
|
22
|
+
else { nsceFail(out, 43); return; }
|
|
23
|
+
}
|
|
24
|
+
if (dash) nsceFail(out, 43);
|
|
25
|
+
else nsceEmit(out, 72, 1);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const byte of raw) if (byte === 58) { nsceFail(out, 44); return; }
|
|
29
|
+
if (nsceIn(raw, names)) nsceEmit(out, 72);
|
|
30
|
+
else nsceFail(out, 42);
|
|
31
|
+
}
|
|
32
|
+
function nscmTrim(bytes: Uint8Array, start: number, end: number, newlines: boolean): number[] {
|
|
33
|
+
while (start < end && (bytes[start] === 32 || bytes[start] === 9 || newlines && (bytes[start] === 13 || bytes[start] === 10))) start++;
|
|
34
|
+
while (end > start && (bytes[end - 1] === 32 || bytes[end - 1] === 9 || newlines && (bytes[end - 1] === 13 || bytes[end - 1] === 10))) end--;
|
|
35
|
+
return [start, end];
|
|
36
|
+
}
|
|
37
|
+
function nscmLanguage(r: NscElementReader, out: number[]): void {
|
|
38
|
+
const raw = r.blob(), names = r.names(), span = nscmTrim(raw, 0, raw.length, true), folded = raw.slice(span[0]!, span[1]!);
|
|
39
|
+
for (let i = 0; i < folded.length; i++) if (folded[i]! >= 65 && folded[i]! <= 90) folded[i] = folded[i]! + 32;
|
|
40
|
+
const groups = ["plain text", "zig", "js mjs javascript", "ts typescript", "json jsonc", "yaml yml", "sh bash zsh shell", "py python", "rs rust", "c h cc cpp c++ cs csharp java kotlin swift", "go golang", "html xml svg", "css scss less", "sql", "jsx", "tsx", "md markdown"];
|
|
41
|
+
const canonical = ["plain", "zig", "javascript", "typescript", "json", "yaml", "shell", "python", "rust", "c_like", "go", "html", "css", "sql", "jsx", "tsx", "markdown"];
|
|
42
|
+
for (let i = 0; i < groups.length; i++) for (const alias of groups[i]!.split(" ")) if (nsceNamed(folded, alias)) {
|
|
43
|
+
for (let j = 0; j < names.length; j++) if (nsceNamed(names[j]!, canonical[i]!)) { nsceEmit(out, 76, 0, j); return; }
|
|
44
|
+
throw new Error("missing native code language capability");
|
|
45
|
+
}
|
|
46
|
+
nsceFail(out, 45);
|
|
47
|
+
}
|
|
48
|
+
function nscmLinePieces(r: NscElementReader, out: number[]): void {
|
|
49
|
+
const spec = r.blob(), span = nscmTrim(spec, 0, spec.length, true), end = span[1]!;
|
|
50
|
+
let start = span[0]!;
|
|
51
|
+
if (start === end) { nsceEmit(out, 200); return; }
|
|
52
|
+
while (start <= end) {
|
|
53
|
+
let stop = start; while (stop < end && spec[stop] !== 44) stop++;
|
|
54
|
+
const piece = nscmTrim(spec, start, stop, true), first = piece[0]!, last = piece[1]!;
|
|
55
|
+
if (first === last) { nsceFail(out, 46); return; }
|
|
56
|
+
let dash = -1;
|
|
57
|
+
for (let i = first; i < last; i++) if (spec[i] === 45) {
|
|
58
|
+
if (dash >= 0) { nsceFail(out, 46); return; }
|
|
59
|
+
dash = i;
|
|
60
|
+
}
|
|
61
|
+
const a = nscmTrim(spec, first, dash < 0 ? last : dash, false);
|
|
62
|
+
const b = dash < 0 ? a : nscmTrim(spec, dash + 1, last, false);
|
|
63
|
+
if (a[0] === a[1] || b[0] === b[1]) { nsceFail(out, 46); return; }
|
|
64
|
+
// Exact usize conversion runs natively, in order, before the next piece.
|
|
65
|
+
out.push(77, 0, a[0]!, a[1]!, b[0]!, b[1]!, 0);
|
|
66
|
+
if (stop === end) break;
|
|
67
|
+
start = stop + 1;
|
|
68
|
+
}
|
|
69
|
+
nsceEmit(out, 200);
|
|
70
|
+
}
|
|
71
|
+
function nscmLineRange(r: NscElementReader, out: number[]): void {
|
|
72
|
+
const firstValid = r.flag(), firstWithin = r.flag(), first = r.word();
|
|
73
|
+
const lastValid = r.flag(), lastWithin = r.flag(), last = r.word(), capacity = r.word(), count = r.word(), lines: number[] = [];
|
|
74
|
+
if (count > capacity) throw new Error("invalid native line storage");
|
|
75
|
+
for (let i = 0; i < count; i++) { const line = r.word(); if (line === 0 || line > capacity) throw new Error("invalid stored line"); lines.push(line); }
|
|
76
|
+
if (!firstValid || !lastValid || !firstWithin || !lastWithin || first === 0 || last < first || last > capacity) { nsceFail(out, 46); return; }
|
|
77
|
+
for (let line = first; line <= last; line++) {
|
|
78
|
+
let duplicate = false; for (const stored of lines) if (stored === line) duplicate = true;
|
|
79
|
+
if (duplicate) continue;
|
|
80
|
+
if (lines.length === capacity) { nsceFail(out, 46); return; }
|
|
81
|
+
nsceEmit(out, 78, 0, lines.length, line); lines.push(line);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function nscmValues(r: NscElementReader, out: number[], mode: number): void {
|
|
85
|
+
if (mode === 0) {
|
|
86
|
+
const channel = r.word(), name = r.blob(), binding = r.flag();
|
|
87
|
+
if (channel > 2) throw new Error("invalid resource channel");
|
|
88
|
+
const element = channel === 0 ? nsceOne(name, ["avatar", "image"]) : nsceNamed(name, channel === 1 ? "media-surface" : "terminal");
|
|
89
|
+
if (!element) nsceFail(out, channel * 2 + 1);
|
|
90
|
+
else if (!binding) nsceFail(out, channel * 2 + 2);
|
|
91
|
+
else nsceEmit(out, 1);
|
|
92
|
+
} else if (mode === 1) {
|
|
93
|
+
const channel = r.word(), kind = r.word(), nonnegative = r.flag();
|
|
94
|
+
if (channel > 2 || kind > 3) throw new Error("invalid resource value");
|
|
95
|
+
if (kind === 0 && nonnegative) nsceEmit(out, 2);
|
|
96
|
+
else if (channel === 2 && kind === 3) nsceEmit(out, 3);
|
|
97
|
+
else nsceFail(out, channel * 2 + 2);
|
|
98
|
+
} else if (mode === 2) {
|
|
99
|
+
const family = r.word(), name = r.blob(), eligible = r.names();
|
|
100
|
+
if (family > 2) throw new Error("invalid element family");
|
|
101
|
+
if (nsceIn(name, eligible)) nsceEmit(out, 1);
|
|
102
|
+
else nsceFail(out, family === 0 ? 7 : family === 1 ? 8 : 9);
|
|
103
|
+
} else if (mode === 3) {
|
|
104
|
+
const kind = r.word(), phase = r.word(), anchor = r.flag(), valid = r.flag();
|
|
105
|
+
if (kind > 2 || phase > 1) throw new Error("invalid anchor phase");
|
|
106
|
+
if (phase === 0 && kind !== 0 && !anchor) nsceFail(out, 10);
|
|
107
|
+
else if (phase === 1 && !valid) nsceFail(out, 11 + kind);
|
|
108
|
+
else nsceEmit(out, 1);
|
|
109
|
+
} else if (mode === 4 || mode === 5) {
|
|
110
|
+
const type = r.word(), kind = r.word(), withinRange = r.flag();
|
|
111
|
+
if (type > 5 || kind > 3) throw new Error("invalid typed value fact");
|
|
112
|
+
const admitted = type === 1 ? kind === 0 || kind === 1 : type === 2 ? true : type === 3 || type === 5 ? kind === 3 : type === 4 ? kind === 0 && withinRange : false;
|
|
113
|
+
if (admitted) nsceEmit(out, type);
|
|
114
|
+
else if (mode === 5) nsceFail(out, 27);
|
|
115
|
+
else nsceFail(out, type === 1 ? 20 : type === 3 ? 21 : type === 4 ? kind === 0 ? 23 : 24 : type === 5 ? 26 : 25);
|
|
116
|
+
} else if (mode === 6) {
|
|
117
|
+
const drag = r.flag(), tag = r.blob(), payload = r.flag(), names = r.names(), classes: number[] = [];
|
|
118
|
+
for (let i = 0; i < names.length; i++) { const kind = r.word(); if (kind > 2) throw new Error("invalid message type"); classes.push(kind); }
|
|
119
|
+
if (drag && !payload) { nsceFail(out, 31); return; }
|
|
120
|
+
for (let i = 0; i < names.length; i++) if (nsceEqual(tag, names[i]!)) {
|
|
121
|
+
const kind = classes[i]!;
|
|
122
|
+
if (drag) { if (kind !== 2) nsceFail(out, 31); else nsceEmit(out, 42, 0, i); }
|
|
123
|
+
else if (kind === 0) { if (payload) nsceFail(out, 28); else nsceEmit(out, 40, 0, i); }
|
|
124
|
+
else if (!payload) nsceFail(out, 29);
|
|
125
|
+
else nsceEmit(out, 41, 0, i);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
nsceFail(out, drag ? 31 : 30);
|
|
129
|
+
} else if (mode === 7) {
|
|
130
|
+
const tag = r.blob(), names = r.names(), classes: number[] = [];
|
|
131
|
+
for (let i = 0; i < names.length; i++) { const kind = r.word(); if (kind > 2) throw new Error("invalid callback class"); classes.push(kind); }
|
|
132
|
+
for (let i = 0; i < names.length; i++) if (classes[i] !== 0 && nsceEqual(tag, names[i]!)) { nsceEmit(out, 43, 0, i, classes[i]!); return; }
|
|
133
|
+
nsceEmit(out, 0);
|
|
134
|
+
} else if (mode === 8) {
|
|
135
|
+
const kind = r.word(), aware = r.flag();
|
|
136
|
+
if (kind > 5) throw new Error("invalid attribute kind");
|
|
137
|
+
if (kind === 0) nsceEmit(out, aware ? 50 : 51);
|
|
138
|
+
else if (kind === 1) nsceEmit(out, 52);
|
|
139
|
+
else if (kind === 2) { nsceEmit(out, 53); nsceEmit(out, 54); nsceEmit(out, 55); }
|
|
140
|
+
else if (kind === 3) nsceEmit(out, 56);
|
|
141
|
+
else nsceFail(out, 32);
|
|
142
|
+
} else if (mode === 9) {
|
|
143
|
+
nsceEmit(out, r.flag() ? 57 : 58);
|
|
144
|
+
} else if (mode === 10) {
|
|
145
|
+
const count = r.word();
|
|
146
|
+
for (let i = 0; i < count; i++) {
|
|
147
|
+
const binding = r.flag(), comparison = r.flag();
|
|
148
|
+
if (binding) nsceEmit(out, 59, 0, i, comparison ? 0 : 1);
|
|
149
|
+
}
|
|
150
|
+
nsceEmit(out, 60);
|
|
151
|
+
} else if (mode === 11) {
|
|
152
|
+
const path = r.blob(), floor = r.word(), names = r.names(), classes: number[] = [];
|
|
153
|
+
if (floor > names.length) throw new Error("invalid binding floor");
|
|
154
|
+
for (let i = 0; i < names.length; i++) { const kind = r.word(); if (kind > 4) throw new Error("invalid scope payload"); classes.push(kind); }
|
|
155
|
+
const dot = nscmDot(path), head = path.subarray(0, dot < 0 ? path.length : dot), tail = dot + 1;
|
|
156
|
+
for (let i = names.length - 1; i >= floor; i--) if (nsceEqual(head, names[i]!)) {
|
|
157
|
+
const kind = classes[i]!;
|
|
158
|
+
if (kind === 0) nsceEmit(out, dot < 0 ? 62 : 61, 0, i, tail);
|
|
159
|
+
else if (kind === 1) nsceFail(out, 36);
|
|
160
|
+
else if (kind === 2) { if (dot >= 0) nsceFail(out, 37); else nsceEmit(out, 63, 0, i); }
|
|
161
|
+
else if (kind === 3) { if (dot < 0) nsceFail(out, 41); else nsceEmit(out, 64, 0, i, tail); }
|
|
162
|
+
else throw new Error("named slot capture is unreachable");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
nsceEmit(out, 65, 0, head.length);
|
|
166
|
+
} else if (mode === 12) {
|
|
167
|
+
const domain = r.word(), phase = r.word(), present = r.flag(), allowArena = r.flag();
|
|
168
|
+
if (domain > 3 || phase > 2) throw new Error("invalid binding resolution phase");
|
|
169
|
+
if (phase === 2) { nsceFail(out, present ? 38 : 39); return; }
|
|
170
|
+
if (phase === 1 && present) { nsceFail(out, 33); return; }
|
|
171
|
+
if (present) { nsceEmit(out, 66); return; }
|
|
172
|
+
if (phase === 0 && domain < 2 && !allowArena) nsceEmit(out, 67);
|
|
173
|
+
else if (domain === 1) nsceEmit(out, 75);
|
|
174
|
+
else nsceFail(out, domain === 0 ? 34 : domain === 2 ? 40 : 35);
|
|
175
|
+
} else if (mode === 13) {
|
|
176
|
+
const type = r.word(), path = r.blob(), arena = r.flag(), fields = r.names(), declarations = r.names(), classes: number[] = [];
|
|
177
|
+
if (type > 2) throw new Error("invalid reflected binding type");
|
|
178
|
+
for (let i = 0; i < declarations.length; i++) { const kind = r.word(); if (kind > 2) throw new Error("invalid declaration class"); classes.push(kind); }
|
|
179
|
+
if (type === 2) { nsceEmit(out, 70); return; }
|
|
180
|
+
if (type === 0) { nsceEmit(out, 0); return; }
|
|
181
|
+
const dot = nscmDot(path), head = path.subarray(0, dot < 0 ? path.length : dot);
|
|
182
|
+
for (let i = 0; i < fields.length; i++) if (nsceEqual(head, fields[i]!)) { nsceEmit(out, 68, 0, i, dot + 1); return; }
|
|
183
|
+
if (dot < 0) for (let i = 0; i < declarations.length; i++) if (classes[i] !== 0 && nsceEqual(head, declarations[i]!)) {
|
|
184
|
+
if (classes[i] === 2 && !arena) nsceEmit(out, 0);
|
|
185
|
+
else nsceEmit(out, 69, 0, i, classes[i]!);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
nsceEmit(out, 0);
|
|
189
|
+
} else if (mode === 14) {
|
|
190
|
+
nscmIcon(r, out);
|
|
191
|
+
} else if (mode === 15) {
|
|
192
|
+
const text = r.blob(), names = r.names();
|
|
193
|
+
for (let i = 0; i < names.length; i++) if (nsceEqual(text, names[i]!)) { nsceEmit(out, 74, 0, i); return; }
|
|
194
|
+
nsceEmit(out, 0);
|
|
195
|
+
} else if (mode === 16) nscmLanguage(r, out);
|
|
196
|
+
else if (mode === 17) nscmLinePieces(r, out);
|
|
197
|
+
else if (mode === 18) nscmLineRange(r, out);
|
|
198
|
+
else if (mode === 19) {
|
|
199
|
+
const raw = r.blob(), names = r.names();
|
|
200
|
+
const area = nsceNamed(raw, "area");
|
|
201
|
+
const canonical = area || nsceNamed(raw, "line") ? "line" : nsceNamed(raw, "bar") ? "bar" : "";
|
|
202
|
+
if (canonical === "") { nsceFail(out, 47); return; }
|
|
203
|
+
for (let i = 0; i < names.length; i++) if (nsceNamed(names[i]!, canonical)) { nsceEmit(out, 79, area ? 1 : 0, i); return; }
|
|
204
|
+
throw new Error("missing native chart kind capability");
|
|
205
|
+
} else if (mode === 20) {
|
|
206
|
+
// Native conversion precedes admission; these are the exact IEEE f32 bits.
|
|
207
|
+
const bits = r.word();
|
|
208
|
+
if (bits > 0xffffffff) throw new Error("invalid native f32 representation");
|
|
209
|
+
if (bits > 0 && bits < 0x7f800000) nsceEmit(out, 1);
|
|
210
|
+
else nsceFail(out, 48);
|
|
211
|
+
} else if (mode === 21) {
|
|
212
|
+
const channel = r.word(), kind = r.word(), low = r.word(), high = r.word(), capacity = r.word();
|
|
213
|
+
if (channel > 2 || kind > 3 || low > 0xffffffff || high > 0xffffffff || capacity > 255) throw new Error("invalid numeric option channel");
|
|
214
|
+
if (kind !== 0) { nsceFail(out, channel === 0 ? 50 : channel === 1 ? 52 : 53); return; }
|
|
215
|
+
// Exact two's-complement i64 words never pass through a floating conversion.
|
|
216
|
+
if (channel === 0) {
|
|
217
|
+
if (high <= 0x1fffff) nsceEmit(out, 1);
|
|
218
|
+
else nsceFail(out, 49);
|
|
219
|
+
} else if (channel === 1) nsceEmit(out, high >= 0x80000000 ? 2 : 1);
|
|
220
|
+
else if (high === 0 && low <= capacity) nsceEmit(out, 1);
|
|
221
|
+
else nsceFail(out, 54);
|
|
222
|
+
} else if (mode === 22) {
|
|
223
|
+
const bits = r.word();
|
|
224
|
+
if (bits > 0xffffffff) throw new Error("invalid native f32 representation");
|
|
225
|
+
if (bits < 0x7f800000 || bits === 0x80000000) nsceEmit(out, 1);
|
|
226
|
+
else nsceFail(out, 51);
|
|
227
|
+
} else if (mode === 23) {
|
|
228
|
+
const raw = r.blob(), names = r.names(), selected = nsceNamed(raw, "trailing") ? "trailing" : "leading";
|
|
229
|
+
for (let i = 0; i < names.length; i++) if (nsceNamed(names[i]!, selected)) { nsceEmit(out, 80, 0, i); return; }
|
|
230
|
+
throw new Error("missing native virtual anchor capability");
|
|
231
|
+
} else if (mode === 24) {
|
|
232
|
+
const base = r.word(), count = r.word();
|
|
233
|
+
if (base <= 9007199254740991 - count) nsceEmit(out, 0);
|
|
234
|
+
else nsceFail(out, 55);
|
|
235
|
+
} else if (mode === 25) {
|
|
236
|
+
const bits = r.word(), estimator = r.flag();
|
|
237
|
+
if (bits > 0xffffffff) throw new Error("invalid native f32 representation");
|
|
238
|
+
if (estimator || bits !== 0 && bits !== 0x80000000) nsceEmit(out, 0);
|
|
239
|
+
else nsceFail(out, 56);
|
|
240
|
+
} else if (mode === 26) {
|
|
241
|
+
const channel = r.word(), name = r.blob(), present = r.flag();
|
|
242
|
+
if (channel > 1 || !nsceOne(name, channel === 0 ? ["item-count", "overscan", "index-base"] : ["item-extent", "gap", "viewport-fallback"])) throw new Error("invalid virtual option name");
|
|
243
|
+
if (present) nsceEmit(out, 1);
|
|
244
|
+
else nsceEmit(out, 0, 0, nsceNamed(name, "overscan") ? 4 : 0);
|
|
245
|
+
}
|
|
246
|
+
else if (mode === 27) {
|
|
247
|
+
const channel = r.word(), form = r.word(), payloadLength = r.word();
|
|
248
|
+
if (channel > 13 || form > 5) throw new Error("invalid specialized attribute form");
|
|
249
|
+
const diagnostics = [57, 58, 59, 60, 61, 62, 63, 45, 64, 65, 47, 66, 67, 46];
|
|
250
|
+
const admitted = channel === 1 || channel === 2 ? form === 4 && payloadLength === 0
|
|
251
|
+
: channel === 5 ? form !== 2 && form !== 5
|
|
252
|
+
: channel === 7 || channel === 10 || channel === 12 ? form === 0
|
|
253
|
+
: channel === 8 ? form === 4
|
|
254
|
+
: channel === 13 ? form !== 5
|
|
255
|
+
: form === 1;
|
|
256
|
+
if (!admitted) nsceFail(out, diagnostics[channel]!);
|
|
257
|
+
else nsceEmit(out, channel === 13 && form !== 0 ? 2 : 1);
|
|
258
|
+
} else if (mode === 28) {
|
|
259
|
+
const channel = r.word(), kind = r.word(), length = r.word();
|
|
260
|
+
if (channel > 4 || kind > 3) throw new Error("invalid specialized value kind");
|
|
261
|
+
const diagnostics = [57, 63, 62, 46, 48];
|
|
262
|
+
if (channel === 4) {
|
|
263
|
+
if (kind < 2) nsceEmit(out, kind === 0 ? 2 : 1);
|
|
264
|
+
else nsceFail(out, 48);
|
|
265
|
+
} else if (kind !== 3) nsceFail(out, diagnostics[channel]!);
|
|
266
|
+
else nsceEmit(out, channel === 2 && length === 0 ? 0 : 1);
|
|
267
|
+
} else if (mode === 29) {
|
|
268
|
+
// Raw empty presence wins even when a typed cache says otherwise.
|
|
269
|
+
nsceEmit(out, r.word() === 0 ? 1 : 2);
|
|
270
|
+
} else if (mode === 30) {
|
|
271
|
+
const phase = r.word();
|
|
272
|
+
if (phase === 0) {
|
|
273
|
+
const count = r.word(), firstKind = r.blob();
|
|
274
|
+
nsceEmit(out, count === 1 && nsceNamed(firstKind, "slot_block") ? 2 : 1);
|
|
275
|
+
} else if (phase === 1) {
|
|
276
|
+
if (r.flag()) nsceEmit(out, 1);
|
|
277
|
+
else nsceFail(out, 68);
|
|
278
|
+
} else throw new Error("invalid stepper capture phase");
|
|
279
|
+
} else if (mode === 31) {
|
|
280
|
+
const phase = r.word();
|
|
281
|
+
if (phase === 0) {
|
|
282
|
+
const raw = r.blob(), aware = r.flag(), name = r.blob(), textNames = r.names();
|
|
283
|
+
// Schema text takes precedence even over exact boolean and numeric text.
|
|
284
|
+
// Conversion is requested in order; exact native values stay native.
|
|
285
|
+
if (aware && nsceIn(name, textNames)) nsceEmit(out, 81);
|
|
286
|
+
else if (nsceNamed(raw, "true")) nsceEmit(out, 82, 1);
|
|
287
|
+
else if (nsceNamed(raw, "false")) nsceEmit(out, 82);
|
|
288
|
+
else nsceEmit(out, 83);
|
|
289
|
+
} else if (phase === 1) nsceEmit(out, r.flag() ? 84 : 85);
|
|
290
|
+
else if (phase === 2) nsceEmit(out, r.flag() ? 86 : 81);
|
|
291
|
+
else throw new Error("invalid literal inference phase");
|
|
292
|
+
} else if (mode === 32) {
|
|
293
|
+
const length = r.word(), floor = r.word();
|
|
294
|
+
if (floor > length) throw new Error("invalid capture floor");
|
|
295
|
+
let selected = 0;
|
|
296
|
+
for (let i = 0; i < length; i++) {
|
|
297
|
+
const slot = r.flag();
|
|
298
|
+
// An empty capture still shadows every outer capture.
|
|
299
|
+
if (i >= floor && slot) selected = i + 1;
|
|
300
|
+
}
|
|
301
|
+
nsceEmit(out, 87, 0, selected);
|
|
302
|
+
} else if (mode === 33) {
|
|
303
|
+
const press = r.flag(), provenance = r.flag();
|
|
304
|
+
// Root construction can fail before either postprocessing capability runs.
|
|
305
|
+
nsceEmit(out, 88);
|
|
306
|
+
if (press) nsceEmit(out, 89);
|
|
307
|
+
if (provenance) nsceEmit(out, 90);
|
|
308
|
+
nsceEmit(out, 91);
|
|
309
|
+
} else if (mode === 34) {
|
|
310
|
+
const count = r.word();
|
|
311
|
+
for (let i = 0; i < count; i++) {
|
|
312
|
+
// Toggle buttons retain their distinct on-toggle contract.
|
|
313
|
+
if (nsceNamed(r.blob(), "button")) nsceEmit(out, 92, 0, i);
|
|
314
|
+
}
|
|
315
|
+
} else if (mode === 35) {
|
|
316
|
+
const path = r.blob(), dot = nscmDot(path);
|
|
317
|
+
// Return borrowed byte offsets; a trailing dot has a present empty tail.
|
|
318
|
+
nsceEmit(out, 93, 0, dot < 0 ? path.length : dot, dot < 0 ? 0 : dot + 1);
|
|
319
|
+
} else if (mode === 36) {
|
|
320
|
+
// A use-site handler replaces the local timeline handler before construction.
|
|
321
|
+
nsceEmit(out, r.flag() ? 1 : 0);
|
|
322
|
+
} else throw new Error("invalid markup value mode");
|
|
323
|
+
}
|
|
324
|
+
function nscvMarkupValues(input: Uint8Array): Uint8Array {
|
|
325
|
+
if (input.length < 4 || input[0] !== 113 || input[1] !== 1 || input[2]! > 36 || input[3]! > 1) throw new Error("invalid markup value header");
|
|
326
|
+
const r = new NscElementReader(input), out: number[] = [];
|
|
327
|
+
nscmValues(r, out, input[2]!);
|
|
328
|
+
if (r.at !== input.length) throw new Error("trailing markup value facts");
|
|
329
|
+
const count = out.length / 7, bytes = new Uint8Array(input[3] === 0 ? 16 : 16 + count * 48), wire = new DataView(bytes.buffer);
|
|
330
|
+
bytes[0] = 113; bytes[1] = 1; bytes[2] = input[3]!; wire.setFloat64(8, count, true);
|
|
331
|
+
if (input[3] === 1) for (let i = 0; i < count; i++) {
|
|
332
|
+
const at = 16 + i * 48, from = i * 7; bytes[at] = out[from]!; bytes[at + 1] = out[from + 1]!;
|
|
333
|
+
for (let j = 0; j < 5; j++) wire.setFloat64(at + 8 + j * 8, out[from + j + 2]!, true);
|
|
334
|
+
}
|
|
335
|
+
return bytes;
|
|
336
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** Copied measurement continuations. Native executes queries and retains the
|
|
2
|
+
* buffers; portable policy owns admission, ordering and recipe composition. */
|
|
3
|
+
function nscvWrappedMeasure(request: Uint8Array): Uint8Array {
|
|
4
|
+
if (request.length < 288 || request[0] !== 34 || request[1] !== 1 || request[2]! > 2 || request[3]! > 7)
|
|
5
|
+
throw new Error("invalid wrapped measurement header");
|
|
6
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(4, true), mode = request[2]!;
|
|
7
|
+
if (request.length !== 288 + count * 32 || w.getUint32(40, true) > 3)
|
|
8
|
+
throw new Error("invalid wrapped measurement shape");
|
|
9
|
+
for (let i = 44; i < 64; i++) if (request[i] !== 0) throw new Error("invalid wrapped measurement reserved bytes");
|
|
10
|
+
const metric = request.slice(64, 288), m = new DataView(metric.buffer), kind = metric[7]!, flags = m.getUint32(12, true);
|
|
11
|
+
if (metric[2] !== 32 || mode === 2 && kind !== 14) throw new Error("invalid wrapped measurement registers");
|
|
12
|
+
const f = Math.fround, max = (a: number, b: number): number => nscvRenderExtreme(a, b, metric[3]!, true);
|
|
13
|
+
const min = (a: number, b: number): number => nscvRenderExtreme(a, b, metric[3]!, false);
|
|
14
|
+
const v = (at: number): number => m.getFloat32(at, true);
|
|
15
|
+
const scalar = (op: number, base: number = 0): number => {
|
|
16
|
+
metric[2] = op; m.setFloat32(16, base, true);
|
|
17
|
+
const r = nscvWidgetMetrics(metric); return new DataView(r.buffer).getFloat32(8, true);
|
|
18
|
+
};
|
|
19
|
+
scalar(29); // Validate complete registers before any short circuit.
|
|
20
|
+
const packet = new Uint8Array(80 + count * 16), p = new DataView(packet.buffer);
|
|
21
|
+
packet[0] = 7; packet[1] = mode === 2 ? 2 : 0; packet[2] = kind;
|
|
22
|
+
packet[3] = ((flags & 4) !== 0 ? 1 : 0) | ((request[3]! & 1) !== 0 ? 2 : 0) |
|
|
23
|
+
((flags & 1) !== 0 ? 4 : 0) | ((request[3]! & 4) !== 0 ? 8 : 0) | (mode === 1 ? 16 : 0);
|
|
24
|
+
p.setUint32(4, count, true); packet.set(request.subarray(8, 32), 8);
|
|
25
|
+
packet.set(metric.subarray(152, 168), 32);
|
|
26
|
+
if (mode !== 1 && (request[3]! & 2) !== 0 && (kind === 17 || kind === 12 && metric[6] === 1)) {
|
|
27
|
+
const padding = scalar(kind === 17 ? 20 : 26);
|
|
28
|
+
for (let i = 0; i < 4; i++) p.setFloat32(32 + i * 4, padding, true);
|
|
29
|
+
}
|
|
30
|
+
const textSize = scalar(1), line = scalar(5, textSize);
|
|
31
|
+
p.setFloat32(48, v(196), true);
|
|
32
|
+
p.setFloat32(52, kind === 14 ? max(scalar(10), f(line + f(scalar(19, v(116)) * 2))) : line, true);
|
|
33
|
+
p.setFloat32(56, f(scalar(27, 16) + scalar(19, v(112))), true);
|
|
34
|
+
p.setFloat32(60, scalar(27, 52), true);
|
|
35
|
+
packet.set(request.subarray(36, 40), 64); packet.set(request.subarray(32, 36), 68);
|
|
36
|
+
p.setFloat32(72, scalar(20), true); p.setFloat32(76, scalar(30, v(120)), true);
|
|
37
|
+
for (let i = 0; i < count; i++) {
|
|
38
|
+
const at = 288 + i * 32, childFlags = w.getUint32(at, true), status = w.getUint32(at + 16, true);
|
|
39
|
+
if (childFlags > 7 || status > 3 || w.getUint32(at + 28, true) !== 0 || (childFlags & 1) === 0 && status !== 0)
|
|
40
|
+
throw new Error("invalid wrapped measurement child");
|
|
41
|
+
const authored = w.getFloat32(at + 4, true), cap = (childFlags & 6) === 2 && authored <= 0 && w.getFloat32(at + 24, true) <= 0;
|
|
42
|
+
const dest = 80 + i * 16;
|
|
43
|
+
p.setUint32(dest, (childFlags & 1) | (cap ? 2 : 0) | ((status & 1) !== 0 ? 4 : 0), true);
|
|
44
|
+
packet.set(request.subarray(at + 4, at + 16), dest + 4);
|
|
45
|
+
}
|
|
46
|
+
let planned = nscvWrappedLayout(packet), q = new DataView(planned.buffer), inner = q.getFloat32(8, true);
|
|
47
|
+
// Bubble queries return the intrinsic width; policy applies the thread cap.
|
|
48
|
+
for (let i = 0; i < count; i++) {
|
|
49
|
+
const at = 288 + i * 32, dest = 80 + i * 16;
|
|
50
|
+
if ((p.getUint32(dest, true) & 6) === 6 && q.getUint32(16, true) === 2) {
|
|
51
|
+
const fitted = min(inner, w.getFloat32(at + 8, true));
|
|
52
|
+
p.setFloat32(dest + 8, inner > 0 ? min(fitted, max(f(inner * f(0.8)), max(0, w.getFloat32(at + 20, true)))) : fitted, true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
planned = nscvWrappedLayout(packet); q = new DataView(planned.buffer);
|
|
56
|
+
const result = new Uint8Array(32), out = new DataView(result.buffer); out.setUint32(0, 1, true);
|
|
57
|
+
const command = (action: number, index: number = 0, width: number = 0): Uint8Array => {
|
|
58
|
+
out.setUint32(4, action, true); out.setUint32(8, index, true); out.setFloat32(16, width, true); return result;
|
|
59
|
+
};
|
|
60
|
+
const action = q.getUint32(4, true), ready = w.getUint32(40, true);
|
|
61
|
+
if (action === 0 && (ready & 1) === 0) {
|
|
62
|
+
if (w.getFloat32(20, true) > 0) p.setFloat32(68, max(max(0, w.getFloat32(24, true)), w.getFloat32(28, true) > 0 ? min(w.getFloat32(20, true), w.getFloat32(28, true)) : w.getFloat32(20, true)), true);
|
|
63
|
+
else return command(1);
|
|
64
|
+
}
|
|
65
|
+
if (action === 2 && (ready & 2) === 0) return command(2, 0, inner);
|
|
66
|
+
if (action === 3) {
|
|
67
|
+
// Preserve the shipped coordinator's separate width and height passes.
|
|
68
|
+
// Each width query may independently repeat intrinsic measurements.
|
|
69
|
+
for (let i = 0; i < count; i++) {
|
|
70
|
+
const query = q.getUint32(24 + i * 8, true);
|
|
71
|
+
if (query !== 0) return command(query === 1 ? 3 : 4, i, inner);
|
|
72
|
+
}
|
|
73
|
+
for (let i = 0; i < count; i++) {
|
|
74
|
+
const at = 288 + i * 32;
|
|
75
|
+
if ((w.getUint32(at, true) & 1) !== 0 && (w.getUint32(at + 16, true) & 2) === 0)
|
|
76
|
+
return command(5, i, q.getFloat32(20 + i * 8, true));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (action === 0 && (ready & 1) !== 0) {
|
|
80
|
+
const value = w.getFloat32(32, true), ceiling = w.getFloat32(28, true);
|
|
81
|
+
p.setFloat32(68, max(max(0, w.getFloat32(24, true)), ceiling > 0 ? min(value, ceiling) : value), true);
|
|
82
|
+
}
|
|
83
|
+
packet[1] = mode === 2 ? 2 : 1;
|
|
84
|
+
const final = nscvWrappedLayout(packet);
|
|
85
|
+
result.set(final.subarray(12, 16), 12);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function nscvAxisChildMeasure(request: Uint8Array): Uint8Array {
|
|
90
|
+
if (request.length !== 80 || request[0] !== 35 || request[1] !== 1 || request[2]! > 1 || request[3]! > 31 || request[4]! > 62 || request[5]! > 5 || request[6]! > 15 || request[7] !== 0)
|
|
91
|
+
throw new Error("invalid axis measurement header");
|
|
92
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), ready = w.getUint32(8, true);
|
|
93
|
+
if (ready > 3 || w.getUint32(12, true) !== 0) throw new Error("invalid axis measurement state");
|
|
94
|
+
for (let i = 60; i < 80; i++) if (request[i] !== 0) throw new Error("invalid axis measurement reserved bytes");
|
|
95
|
+
const horizontal = request[2] === 0, options = request[3]!, kind = request[4]!, primary = request[5] === 0 || request[5] === 1;
|
|
96
|
+
const main = horizontal ? 24 : 28, cross = horizontal ? 28 : 24;
|
|
97
|
+
const max = (a: number, b: number): number => nscvRenderExtreme(a, b, request[6]!, true);
|
|
98
|
+
const result = new Uint8Array(64), out = new DataView(result.buffer); out.setUint32(0, 1, true);
|
|
99
|
+
const needMain = !(w.getFloat32(main, true) > 0 || max(0, w.getFloat32(48, true)) > 0);
|
|
100
|
+
const needCross = (options & 4) !== 0 && !(w.getFloat32(cross, true) > 0);
|
|
101
|
+
if (needMain && (ready & 1) === 0 || needCross && (ready & 2) === 0) {
|
|
102
|
+
const query = needMain && (ready & 1) === 0 ? 1 : 2;
|
|
103
|
+
out.setUint32(4, query, true);
|
|
104
|
+
out.setUint32(8, (query === 1 ? horizontal ? 0 : 1 : horizontal ? 1 : 0) ^ (kind === 53 && horizontal ? 1 : 0), true);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
out.setUint32(16, 1 | ((options & 1) !== 0 && kind === 12 && primary ? 2 : 0) |
|
|
108
|
+
((options & 24) === 24 && kind === 12 && primary ? 4 : 0) | (kind === 15 && request[5] !== 4 ? 8 : 0) |
|
|
109
|
+
((options & 2) !== 0 && kind === 46 ? 16 : 0), true);
|
|
110
|
+
result.set(request.subarray(48, 52), 20);
|
|
111
|
+
const copy = (from: number, to: number): void => { result.set(request.subarray(from, from + 4), to); };
|
|
112
|
+
copy(main, 24); copy(cross, 28); copy(horizontal ? 16 : 20, 32); copy(horizontal ? 20 : 16, 36);
|
|
113
|
+
copy(horizontal ? 32 : 36, 40); copy(horizontal ? 40 : 44, 44);
|
|
114
|
+
copy(horizontal ? 36 : 32, 48); copy(horizontal ? 44 : 40, 52);
|
|
115
|
+
if (needMain) result.set(request.subarray(52, 56), 56);
|
|
116
|
+
if (needCross) result.set(request.subarray(56, 60), 60);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function nscvSpanSubtree(request: Uint8Array): Uint8Array {
|
|
121
|
+
if (request.length < 16 || request[0] !== 36 || request[1] !== 1 || request[2]! > 62 || request[3]! > 1)
|
|
122
|
+
throw new Error("invalid span subtree header");
|
|
123
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(12, true);
|
|
124
|
+
if (request.length !== 16 + count * 4) throw new Error("invalid span subtree length");
|
|
125
|
+
for (let i = 0; i < count; i++) if (w.getUint32(16 + i * 4, true) > 2) throw new Error("invalid span subtree child");
|
|
126
|
+
const result = new Uint8Array(16), out = new DataView(result.buffer); out.setUint32(0, 1, true);
|
|
127
|
+
if (w.getUint32(4, true) >= w.getUint32(8, true)) return result;
|
|
128
|
+
if ((request[2] === 26 || request[2] === 44) && request[3] === 1) { out.setUint32(12, 1, true); return result; }
|
|
129
|
+
for (let i = 0; i < count; i++) {
|
|
130
|
+
const value = w.getUint32(16 + i * 4, true);
|
|
131
|
+
if (value === 0) { out.setUint32(4, 1, true); out.setUint32(8, i, true); return result; }
|
|
132
|
+
if (value === 2) { out.setUint32(12, 1, true); return result; }
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Axis preparation, subtree admission, cross-width and wrapped-height passes
|
|
138
|
+
* keep their reference order. Allocation arithmetic remains operation 5. */
|
|
139
|
+
function nscvAxisMeasure(request: Uint8Array): Uint8Array {
|
|
140
|
+
if (request.length < 64 || request[0] !== 37 || request[1] !== 1 || request[2]! > 15 || request[3] !== 0)
|
|
141
|
+
throw new Error("invalid axis coordination header");
|
|
142
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(4, true);
|
|
143
|
+
if (request.length !== 64 + count * 64 || w.getUint32(8, true) !== 0 || w.getUint32(12, true) !== 0)
|
|
144
|
+
throw new Error("invalid axis coordination shape");
|
|
145
|
+
for (let i = 52; i < 64; i++) if (request[i] !== 0) throw new Error("invalid axis coordination reserved bytes");
|
|
146
|
+
const packet = new Uint8Array(36 + count * 48); packet.set(request.subarray(16, 52));
|
|
147
|
+
const p = new DataView(packet.buffer);
|
|
148
|
+
if (packet[0] !== 5 || packet[1] !== 0 || p.getUint32(8, true) !== count) throw new Error("invalid axis coordination allocation");
|
|
149
|
+
const eligible = (at: number): boolean => packet[2] === 1 && nscvRenderExtreme(0, w.getFloat32(at + 4, true), request[2]!, true) === 0 && w.getFloat32(at + 8, true) <= 0;
|
|
150
|
+
for (let i = 0; i < count; i++) {
|
|
151
|
+
const at = 64 + i * 64, state = w.getUint32(at + 48, true);
|
|
152
|
+
if (w.getUint32(at, true) > 31 || state > 15 || w.getUint32(at + 52, true) > 1 || w.getUint32(at + 56, true) > 1 || (w.getUint32(at, true) & 1) === 0 && state !== 0)
|
|
153
|
+
throw new Error("invalid axis coordination child");
|
|
154
|
+
packet.set(request.subarray(at, at + 48), 36 + i * 48);
|
|
155
|
+
if ((state & 8) !== 0) packet.set(request.subarray(at + 60, at + 64), 76 + i * 48);
|
|
156
|
+
}
|
|
157
|
+
// Complete allocation validation precedes even the first measurement.
|
|
158
|
+
nscvContainerLayout(packet);
|
|
159
|
+
const result = new Uint8Array(32), out = new DataView(result.buffer); out.setUint32(0, 1, true);
|
|
160
|
+
const command = (action: number, index: number, width: number = 0): Uint8Array => {
|
|
161
|
+
out.setUint32(4, action, true); out.setUint32(8, index, true); out.setFloat32(16, width, true); return result;
|
|
162
|
+
};
|
|
163
|
+
let needsWrapped = false;
|
|
164
|
+
for (let i = 0; i < count; i++) {
|
|
165
|
+
const at = 64 + i * 64, state = w.getUint32(at + 48, true);
|
|
166
|
+
if ((w.getUint32(at, true) & 1) === 0) continue;
|
|
167
|
+
if ((state & 1) === 0) return command(1, i);
|
|
168
|
+
if (eligible(at)) {
|
|
169
|
+
if ((state & 2) === 0) return command(2, i);
|
|
170
|
+
if (w.getUint32(at + 52, true) !== 0) needsWrapped = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (needsWrapped) {
|
|
174
|
+
const cross = nscvContainerLayout(packet), c = new DataView(cross.buffer);
|
|
175
|
+
for (let i = 0; i < count; i++) {
|
|
176
|
+
const at = 64 + i * 64, state = w.getUint32(at + 48, true);
|
|
177
|
+
if ((w.getUint32(at, true) & 1) === 0 || !eligible(at)) continue;
|
|
178
|
+
if ((state & 4) === 0) return command(3, i);
|
|
179
|
+
if (w.getUint32(at + 56, true) !== 0 && (state & 8) === 0) return command(4, i, c.getFloat32(12 + i * 4, true));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
packet[1] = 1;
|
|
183
|
+
const allocated = nscvContainerLayout(packet), complete = new Uint8Array(32 + allocated.length);
|
|
184
|
+
complete.set(result); complete.set(allocated, 32); return complete;
|
|
185
|
+
}
|
|
@@ -153,7 +153,7 @@ export function resolveModuleGraph(
|
|
|
153
153
|
if (fileClass === "service" && serviceBuiltins.has(spec)) continue;
|
|
154
154
|
if (fileClass === "service" && allowedServicePackages.has(spec)) continue;
|
|
155
155
|
|
|
156
|
-
if (spec === "@native-sdk/core") continue;
|
|
156
|
+
if (spec === "@native-sdk/core" || spec === "@native-sdk/core/bytes") continue;
|
|
157
157
|
if (fileClass === "core" && spec === "@native-sdk/services") continue;
|
|
158
158
|
if (sdkLibraryModules.has(spec)) {
|
|
159
159
|
const target = path.resolve(sdkLibraryModules.get(spec)!);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** Shared frame-clock sampling compiled by scriptc. The host answers only
|
|
2
|
+
* scalar float32 math requests; phase, easing and channel decisions live here.
|
|
3
|
+
* Each continuation requests all currently available primitives in one batch.
|
|
4
|
+
*/
|
|
5
|
+
function nscvSamplePhase(w: DataView, at: number, now: number): number {
|
|
6
|
+
const duration = w.getUint32(at + 16, true);
|
|
7
|
+
if (duration === 0) return 1;
|
|
8
|
+
const sl = w.getUint32(at + 8, true), sh = w.getUint32(at + 12, true);
|
|
9
|
+
const nl = w.getUint32(now, true), nh = w.getUint32(now + 4, true);
|
|
10
|
+
if (nh < sh || nh === sh && nl <= sl) return 0;
|
|
11
|
+
const low = nl >= sl ? nl - sl : nl + 4294967296 - sl;
|
|
12
|
+
const high = nh - sh - (nl < sl ? 1 : 0), span = duration * 1000000;
|
|
13
|
+
const loop = w.getUint32(at + 24, true), f = Math.fround;
|
|
14
|
+
if (loop === 0) {
|
|
15
|
+
if (high > Math.floor(span / 4294967296) || high === Math.floor(span / 4294967296) && low >= span % 4294967296) return 1;
|
|
16
|
+
return f(f(high * 4294967296 + low) / f(span));
|
|
17
|
+
}
|
|
18
|
+
const divisor = loop === 1 ? span * 2 : span;
|
|
19
|
+
let remainder = 0;
|
|
20
|
+
// Doubling a remainder directly can exceed the exact-number range even
|
|
21
|
+
// though the divisor fits. Subtract first, keeping each intermediate exact.
|
|
22
|
+
for (let bit = 63; bit >= 0; bit--) {
|
|
23
|
+
remainder = remainder >= divisor / 2 ? remainder - (divisor - remainder) : remainder * 2;
|
|
24
|
+
remainder += ((bit >= 32 ? high >>> (bit - 32) : low >>> bit) & 1);
|
|
25
|
+
if (remainder >= divisor) remainder -= divisor;
|
|
26
|
+
}
|
|
27
|
+
const backward = loop === 1 && remainder >= span;
|
|
28
|
+
const sweep = f(f(backward ? remainder - span : remainder) / f(span));
|
|
29
|
+
return backward ? f(1 - sweep) : sweep;
|
|
30
|
+
}
|
|
31
|
+
function nscvSampleLerp(a: number, b: number, t: number): number {
|
|
32
|
+
return Math.fround(a + Math.fround(Math.fround(b - a) * t));
|
|
33
|
+
}
|
|
34
|
+
function nscvMotionSampling(request: Uint8Array): Uint8Array {
|
|
35
|
+
if (request.length < 32 || request[0] !== 73 || request[1] !== 1 || request[2]! > 1 || request[3]! > 15) throw new Error("invalid motion sampling header");
|
|
36
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
37
|
+
const count = w.getUint32(4, true), capacity = w.getUint32(8, true), mode = request[2]!, flags = request[3]!;
|
|
38
|
+
if (request.length !== 32 + count * 144 || w.getUint32(12, true) !== 0 || w.getUint32(24, true) !== 0 || w.getUint32(28, true) !== 0 || mode === 1 && (count !== 1 || capacity !== 1)) throw new Error("invalid motion sampling shape");
|
|
39
|
+
for (let i = 0; i < count; i++) {
|
|
40
|
+
const at = 32 + i * 144;
|
|
41
|
+
if (w.getUint32(at + 20, true) > 3 || w.getUint32(at + 24, true) > 2 || w.getUint32(at + 28, true) > 63 || w.getUint32(at + 116, true) > 31 || w.getUint32(at + 140, true) !== 0) throw new Error("invalid motion sampling record");
|
|
42
|
+
}
|
|
43
|
+
const samples = new Uint8Array(Math.min(count, capacity) * 48), s = new DataView(samples.buffer);
|
|
44
|
+
const primitives = new Uint8Array(count * 32), p = new DataView(primitives.buffer);
|
|
45
|
+
const f = Math.fround, clamp = (v: number): number => nscvRenderExtreme(0, nscvRenderExtreme(v, 1, flags, false), flags, true);
|
|
46
|
+
let used = 0, needed = 0, full = false;
|
|
47
|
+
for (let i = 0; i < count; i++) {
|
|
48
|
+
const at = 32 + i * 144, mask = w.getUint32(at + 28, true);
|
|
49
|
+
if (mode === 0 && (w.getUint32(at, true) === 0 && w.getUint32(at + 4, true) === 0 || (mask & 3) !== 3 && (mask & 12) !== 12 && (mask & 48) !== 48)) continue;
|
|
50
|
+
const cache = w.getUint32(at + 116, true);
|
|
51
|
+
const need = (slot: number, op: number, argument: number): void => {
|
|
52
|
+
const to = needed * 16;
|
|
53
|
+
p.setUint32(to, i, true); p.setUint32(to + 4, slot, true); p.setUint32(to + 8, op, true); p.setFloat32(to + 12, argument, true); needed++;
|
|
54
|
+
};
|
|
55
|
+
let t = clamp(nscvSamplePhase(w, at, 16)), ready = true;
|
|
56
|
+
const easing = w.getUint32(at + 20, true);
|
|
57
|
+
if (easing === 1) t = f(f(t * t) * f(3 - f(2 * t)));
|
|
58
|
+
else if (easing === 2) { const x = f(1 - t); t = f(1 - f(f(x * x) * x)); }
|
|
59
|
+
else if (easing === 3 && t > 0 && t < 1) {
|
|
60
|
+
const mass = nscvRenderExtreme(f(0.001), w.getFloat32(at + 32, true), flags, true);
|
|
61
|
+
const stiffness = nscvRenderExtreme(1, w.getFloat32(at + 36, true), flags, true);
|
|
62
|
+
const damping = nscvRenderExtreme(f(0.001), w.getFloat32(at + 40, true), flags, true);
|
|
63
|
+
if ((cache & 1) === 0) { need(0, 3, f(stiffness / mass)); ready = false; }
|
|
64
|
+
if ((cache & 2) === 0) { need(1, 0, f(f(-damping * t) / f(mass * 24))); ready = false; }
|
|
65
|
+
if ((cache & 1) !== 0 && (cache & 4) === 0) { need(2, 1, f(w.getFloat32(at + 120, true) * t)); ready = false; }
|
|
66
|
+
if (ready) t = clamp(f(1 - f(w.getFloat32(at + 124, true) * w.getFloat32(at + 128, true))));
|
|
67
|
+
}
|
|
68
|
+
let rotation: NscRenderAffine | null = null;
|
|
69
|
+
if (ready && mode === 0 && (mask & 48) === 48) {
|
|
70
|
+
const radians = f(nscvSampleLerp(w.getFloat32(at + 100, true), w.getFloat32(at + 104, true), t) * f(0.017453292519943295));
|
|
71
|
+
if ((cache & 8) === 0) { need(3, 1, radians); ready = false; }
|
|
72
|
+
if ((cache & 16) === 0) { need(4, 2, radians); ready = false; }
|
|
73
|
+
if (ready) {
|
|
74
|
+
const c = w.getFloat32(at + 132, true), sin = w.getFloat32(at + 136, true), x = w.getFloat32(at + 108, true), y = w.getFloat32(at + 112, true);
|
|
75
|
+
rotation = nscvRenderMultiply(nscvRenderMultiply({ a: 1, b: 0, c: 0, d: 1, tx: x, ty: y }, { a: c, b: sin, c: -sin, d: c, tx: 0, ty: 0 }), { a: 1, b: 0, c: 0, d: 1, tx: -x, ty: -y });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (used === capacity) { full = true; break; }
|
|
79
|
+
if (ready) {
|
|
80
|
+
const to = used * 48;
|
|
81
|
+
s.setUint32(to, i, true);
|
|
82
|
+
s.setUint32(to + 8, w.getUint32(at, true), true); s.setUint32(to + 12, w.getUint32(at + 4, true), true);
|
|
83
|
+
let outputMask = mode === 1 || (mask & 3) === 3 ? 1 : 0;
|
|
84
|
+
if (outputMask !== 0) s.setFloat32(to + 20, mode === 1 ? t : nscvSampleLerp(w.getFloat32(at + 44, true), w.getFloat32(at + 48, true), t), true);
|
|
85
|
+
let transform: NscRenderAffine | null = null;
|
|
86
|
+
if (mode === 0 && (mask & 12) === 12) {
|
|
87
|
+
transform = { a: nscvSampleLerp(w.getFloat32(at + 52, true), w.getFloat32(at + 76, true), t), b: nscvSampleLerp(w.getFloat32(at + 56, true), w.getFloat32(at + 80, true), t), c: nscvSampleLerp(w.getFloat32(at + 60, true), w.getFloat32(at + 84, true), t), d: nscvSampleLerp(w.getFloat32(at + 64, true), w.getFloat32(at + 88, true), t), tx: nscvSampleLerp(w.getFloat32(at + 68, true), w.getFloat32(at + 92, true), t), ty: nscvSampleLerp(w.getFloat32(at + 72, true), w.getFloat32(at + 96, true), t) };
|
|
88
|
+
}
|
|
89
|
+
transform = transform === null ? rotation : rotation === null ? transform : nscvRenderMultiply(transform, rotation);
|
|
90
|
+
if (transform !== null) { outputMask |= 2; nscvRenderPutAffine(s, to + 24, transform); }
|
|
91
|
+
s.setUint32(to + 16, outputMask, true);
|
|
92
|
+
}
|
|
93
|
+
used++;
|
|
94
|
+
}
|
|
95
|
+
const out = new Uint8Array(32 + (needed > 0 ? needed * 16 : used * 48)), v = new DataView(out.buffer);
|
|
96
|
+
v.setUint32(0, 1, true); v.setUint32(4, needed > 0 ? 1 : full ? 2 : 0, true);
|
|
97
|
+
v.setUint32(8, needed > 0 ? needed : used, true);
|
|
98
|
+
out.set(needed > 0 ? primitives.subarray(0, needed * 16) : samples.subarray(0, used * 48), 32);
|
|
99
|
+
return out;
|
|
100
|
+
}
|