@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,92 @@
|
|
|
1
|
+
/** Ordered automation gestures over copied observations. Native retains event
|
|
2
|
+
* delivery, clocks, borrowed labels/text/paths and callback failure cleanup.
|
|
3
|
+
* All geometry operations follow the native f32 evaluation order.
|
|
4
|
+
*/
|
|
5
|
+
export function nscvAutomationInteractions(request: Uint8Array): Uint8Array {
|
|
6
|
+
if (request.length !== 128 || request[0] !== 91 || request[1] !== 1 || request[2]! > 12 || request[3]! > 1)
|
|
7
|
+
throw new Error("invalid automation interaction request");
|
|
8
|
+
const mode = request[2]!, phase = request[3]!;
|
|
9
|
+
if (phase !== 0 && mode > 2 && mode !== 10) throw new Error("invalid automation interaction phase");
|
|
10
|
+
const input = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
11
|
+
const facts = input.getUint32(4, true);
|
|
12
|
+
if ((facts & ~4095) !== 0) throw new Error("invalid automation interaction observations");
|
|
13
|
+
const has = (bit: number): boolean => (facts & bit) !== 0;
|
|
14
|
+
const f = Math.fround;
|
|
15
|
+
let x = input.getFloat32(8, true), y = input.getFloat32(12, true);
|
|
16
|
+
let width = input.getFloat32(16, true), height = input.getFloat32(20, true);
|
|
17
|
+
if (width < 0) { x = f(x + width); width = f(-width); }
|
|
18
|
+
if (height < 0) { y = f(y + height); height = f(-height); }
|
|
19
|
+
const empty = width <= 0 || height <= 0;
|
|
20
|
+
const cx = f(x + f(width / 2)), cy = f(y + f(height / 2));
|
|
21
|
+
const ax = input.getFloat32(24, true), ay = input.getFloat32(28, true);
|
|
22
|
+
const dx = input.getFloat32(32, true), dy = input.getFloat32(36, true);
|
|
23
|
+
let status = 0, flags = 4, ox = 0, oy = 0, ex = 0, ey = 0;
|
|
24
|
+
const steps: { event: number; button: number; key: number; text: number; x: number; y: number; dx: number; dy: number; scale: number }[] = [];
|
|
25
|
+
function step(event: number, px: number, py: number, sx: number, sy: number, scale: number, button: number, key: number, text: number): void {
|
|
26
|
+
steps.push({ event, button, key, text, x: px, y: py, dx: sx, dy: sy, scale });
|
|
27
|
+
}
|
|
28
|
+
if (mode === 11) {
|
|
29
|
+
flags = 0;
|
|
30
|
+
status = !has(2048) ? 8 : !has(32) ? 7 : !has(1) ? 1 : !has(64) ? 9 : !has(128) ? 10 : has(256) ? 11 : !has(512) ? 12 : 0;
|
|
31
|
+
} else if (mode === 12) {
|
|
32
|
+
flags = 0;
|
|
33
|
+
let armed = has(1024);
|
|
34
|
+
for (let i = 0; i < 8; i++) if (request[64 + i] !== request[72 + i]) armed = false;
|
|
35
|
+
status = !armed ? 13 : !has(32) ? 14 : 0;
|
|
36
|
+
if (status === 14) flags = 32;
|
|
37
|
+
} else if (mode === 10 && phase === 1) {
|
|
38
|
+
flags = 0; status = !has(32) ? 7 : !has(2) ? 1 : 0;
|
|
39
|
+
} else {
|
|
40
|
+
if (mode <= 2) status = !has(2) || !has(1) || empty ? 1 : 0;
|
|
41
|
+
else if (mode === 3) status = !has(1) ? 2 : !has(2) ? 3 : empty ? 4 : 0;
|
|
42
|
+
else if (mode === 6 || mode === 9 || mode === 10) status = !has(2) || !has(1) || empty ? 1 : 0;
|
|
43
|
+
else if (mode === 7 || mode === 8) status = !has(4) ? 1 : 0;
|
|
44
|
+
if (status === 0 && phase === 0) {
|
|
45
|
+
if (mode <= 2) {
|
|
46
|
+
flags |= mode === 0 ? 1 : mode === 1 ? 16 : 0;
|
|
47
|
+
step(0, ax, ay, 0, 0, 0, mode === 2 ? 1 : 0, 0, 0);
|
|
48
|
+
if (mode === 1) step(9, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
49
|
+
step(1, ax, ay, 0, 0, 0, mode === 2 ? 1 : 0, 0, 0);
|
|
50
|
+
} else if (mode === 3) step(3, cx, cy, dx, dy, 0, 0, 0, 0);
|
|
51
|
+
else if (mode === 4) step(4, 0, 0, 0, 0, 0, 0, 0, 1);
|
|
52
|
+
else if (mode === 5) {
|
|
53
|
+
const scale = f(dx - 1);
|
|
54
|
+
if (f(1 + scale) <= 0) status = 5;
|
|
55
|
+
else {
|
|
56
|
+
const px = has(8) ? ax : f(input.getFloat32(16, true) / 2), py = has(8) ? ay : f(input.getFloat32(20, true) / 2);
|
|
57
|
+
step(6, px, py, 0, 0, 0, 0, 0, 0);
|
|
58
|
+
step(7, px, py, 0, 0, scale, 0, 0, 0);
|
|
59
|
+
step(8, px, py, 0, 0, 0, 0, 0, 0);
|
|
60
|
+
}
|
|
61
|
+
} else if (mode === 6) {
|
|
62
|
+
flags |= 2;
|
|
63
|
+
ox = f(x + f(width * input.getFloat32(40, true))); oy = f(y + f(height * input.getFloat32(44, true)));
|
|
64
|
+
ex = f(x + f(width * input.getFloat32(48, true))); ey = f(y + f(height * input.getFloat32(52, true)));
|
|
65
|
+
step(0, ox, oy, 0, 0, 0, 0, 0, 0);
|
|
66
|
+
step(2, ex, ey, f(ex - ox), f(ey - oy), 0, 0, 0, 0);
|
|
67
|
+
step(1, ex, ey, 0, 0, 0, 0, 0, 0);
|
|
68
|
+
} else if (mode === 7) {
|
|
69
|
+
step(4, 0, 0, 0, 0, 0, 0, 1, 0);
|
|
70
|
+
step(has(16) ? 5 : 4, 0, 0, 0, 0, 0, 0, has(16) ? 0 : 2, has(16) ? 1 : 0);
|
|
71
|
+
} else if (mode === 8) step(10, 0, 0, 0, 0, 0, 0, 0, 1);
|
|
72
|
+
else if (mode === 9) {
|
|
73
|
+
flags = 8; ox = cx; oy = cy; ex = f(cx + dx); ey = f(cy + dy);
|
|
74
|
+
step(2, ex, ey, dx, dy, 0, 0, 0, 0); step(1, ex, ey, 0, 0, 0, 0, 0, 0);
|
|
75
|
+
} else if (mode === 10) { flags = 0; step(11, cx, cy, 0, 0, 0, 0, 0, 0); }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (status !== 0) { steps.length = 0; if (mode !== 12) flags = 0; }
|
|
79
|
+
const result = new Uint8Array(40 + steps.length * 36), out = new DataView(result.buffer);
|
|
80
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true);
|
|
81
|
+
out.setUint32(12, flags, true); out.setUint32(16, steps.length, true);
|
|
82
|
+
out.setFloat32(20, ox, true); out.setFloat32(24, oy, true);
|
|
83
|
+
out.setFloat32(28, ex, true); out.setFloat32(32, ey, true);
|
|
84
|
+
for (let i = 0; i < steps.length; i++) {
|
|
85
|
+
const value = steps[i]!, at = 40 + i * 36;
|
|
86
|
+
out.setUint32(at, value.event, true); out.setUint32(at + 4, value.button, true);
|
|
87
|
+
out.setUint32(at + 8, value.key, true); out.setUint32(at + 12, value.text, true);
|
|
88
|
+
out.setFloat32(at + 16, value.x, true); out.setFloat32(at + 20, value.y, true);
|
|
89
|
+
out.setFloat32(at + 24, value.dx, true); out.setFloat32(at + 28, value.dy, true); out.setFloat32(at + 32, value.scale, true);
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** Portable bridge descriptors over decoded facts and borrowed byte extents. */
|
|
2
|
+
function nscvBridgeDescriptors(request: Uint8Array): Uint8Array {
|
|
3
|
+
if (request.length < 96 || request[0] !== 87 || request[1] !== 1 || request[2]! > 5)
|
|
4
|
+
throw new Error("invalid bridge descriptor header");
|
|
5
|
+
const mode = request[2]!, w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
6
|
+
const word = (at: number): number => w.getUint32(at, true);
|
|
7
|
+
const result = new Uint8Array(64), out = new DataView(result.buffer);
|
|
8
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true);
|
|
9
|
+
let status = 0;
|
|
10
|
+
if (mode === 0) {
|
|
11
|
+
const family = request[3]!;
|
|
12
|
+
if (family > 7 || request.length !== 96 + (word(12) !== 0 ? 64 : Math.min(word(8), 64))) throw new Error("invalid bridge enum extent");
|
|
13
|
+
const names = family === 0 ? ["webview", "toolbar", "titlebar_accessory", "sidebar", "statusbar", "split", "stack", "button", "icon_button", "list_item", "checkbox", "toggle", "segmented_control", "text_field", "search_field", "label", "spacer", "gpu_surface", "progress_indicator"]
|
|
14
|
+
: family === 1 ? ["standard", "hidden_inset", "hidden_inset_tall", "chromeless"]
|
|
15
|
+
: family === 2 ? ["none", "metal", "direct2d", "software"]
|
|
16
|
+
: family === 3 ? ["none", "bgra8_unorm"]
|
|
17
|
+
: family === 4 ? ["none", "timer"]
|
|
18
|
+
: family === 5 ? ["none", "opaque", "premultiplied"]
|
|
19
|
+
: family === 6 ? ["none", "srgb", "display_p3"]
|
|
20
|
+
: ["main_webview", "child_webviews", "native_views", "native_control_commands", "menus", "tray", "shortcuts", "dialogs", "clipboard_text", "clipboard_rich_data", "open_url", "reveal_path", "notifications", "recent_documents", "credentials", "file_drops", "app_activation_events", "gpu_surfaces", "gpu_surface_scroll_drivers", "context_menus", "view_surface_adoption", "audio_playback", "audio_streaming", "audio_spectrum", "microphone_capture", "system_audio_capture", "window_hide_on_close", "video_playback"];
|
|
21
|
+
const aliases = family === 0 ? ["titlebarAccessory", "iconButton", "listItem", "segmentedControl", "textField", "searchField", "gpuSurface", "progressIndicator"]
|
|
22
|
+
: family === 1 ? ["hiddenInset", "hiddenInsetTall"]
|
|
23
|
+
: family === 7 ? ["mainWebView", "childWebViews", "nativeViews", "nativeControlCommands", "clipboardText", "clipboardRichData", "openUrl", "revealPath", "recentDocuments", "fileDrops", "appActivationEvents", "gpuSurfaces", "gpuSurfaceScrollDrivers", "contextMenus", "viewSurfaceAdoption", "audioPlayback", "audioStreaming", "audioSpectrum", "microphoneCapture", "systemAudioCapture", "windowHideOnClose", "videoPlayback"] : [];
|
|
24
|
+
const ordinals = family === 0 ? [2, 8, 9, 12, 13, 14, 17, 18] : family === 1 ? [1, 2] : family === 7 ? [0, 1, 2, 3, 8, 9, 10, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27] : [];
|
|
25
|
+
let selected = 0;
|
|
26
|
+
if (word(12) === 0) for (let group = 0; group < 2; group++) {
|
|
27
|
+
const values = group === 0 ? names : aliases;
|
|
28
|
+
for (let index = 0; index < values.length; index++) {
|
|
29
|
+
const name = values[index]!;
|
|
30
|
+
let equal = name.length === word(8);
|
|
31
|
+
if (equal) for (let i = 0; i < name.length; i++) if (request[96 + i] !== name.charCodeAt(i)) equal = false;
|
|
32
|
+
if (equal) selected = 1 + (group === 0 ? index : ordinals[index]!);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
out.setUint32(16, selected, true);
|
|
36
|
+
} else if (mode === 1) {
|
|
37
|
+
if (request.length !== 96 || request[4]! > 2) throw new Error("invalid GPU descriptor extent");
|
|
38
|
+
const defaults = [1, 1, 1, 1, 1], counts = [4, 2, 2, 3, 3];
|
|
39
|
+
for (let i = 0; i < 5; i++) {
|
|
40
|
+
const value = word(16 + i * 4);
|
|
41
|
+
if (value !== 4294967295 && value > counts[i]!) throw new Error("invalid GPU enum verdict");
|
|
42
|
+
if (value === 0 && status === 0) status = 8;
|
|
43
|
+
out.setUint32(16 + i * 4, value === 4294967295 ? defaults[i]! : value === 0 ? 0 : value - 1, true);
|
|
44
|
+
}
|
|
45
|
+
out.setUint32(36, request[4] === 1 ? 0 : 1, true);
|
|
46
|
+
} else if (mode === 2) {
|
|
47
|
+
if (request.length !== 96 || request[3]! > 1 || request[4]! > 1 || request[5]! > 1) throw new Error("invalid bridge window facts");
|
|
48
|
+
const web = request[3] === 1;
|
|
49
|
+
if (request[4] === 1 && request[5] === 0) status = web ? 1 : 3;
|
|
50
|
+
else if (request[4] === 1 && (word(16) !== word(24) || word(20) !== word(28))) status = web ? 2 : 4;
|
|
51
|
+
result.set(request.subarray(16, 24), 16);
|
|
52
|
+
} else if (mode === 3) {
|
|
53
|
+
if (request.length !== 96) throw new Error("invalid bridge frame extent");
|
|
54
|
+
for (let i = 3; i < 10; i++) if (request[i]! > 1) throw new Error("invalid bridge frame flags");
|
|
55
|
+
const web = request[3] === 1, present = request[5] === 1;
|
|
56
|
+
if (!present && !web) { if (request[4] === 1) status = 5; }
|
|
57
|
+
else if (request[6] === 0 || request[7] === 0) status = web ? 6 : 5;
|
|
58
|
+
else {
|
|
59
|
+
result.set(request.subarray(16, 48), 16);
|
|
60
|
+
if (request[8] === 0) out.setFloat64(16, 0, true);
|
|
61
|
+
if (request[9] === 0) out.setFloat64(24, 0, true);
|
|
62
|
+
const x = out.getFloat64(16, true), y = out.getFloat64(24, true), width = out.getFloat64(32, true), height = out.getFloat64(40, true);
|
|
63
|
+
if (x < 0 || y < 0 || (web ? width <= 0 || height <= 0 : width < 0 || height < 0)) status = web ? 6 : 5;
|
|
64
|
+
out.setUint32(12, 1, true);
|
|
65
|
+
}
|
|
66
|
+
} else if (mode === 4) {
|
|
67
|
+
if (request.length !== 96 || request[3]! > 1 || request[4]! > 1 || request[5]! > 1) throw new Error("invalid bridge layer facts");
|
|
68
|
+
const web = request[3] === 1;
|
|
69
|
+
out.setUint32(12, web || request[4] === 1 ? 1 : 0, true);
|
|
70
|
+
if (request[4] === 1) {
|
|
71
|
+
const layer = w.getFloat64(16, true);
|
|
72
|
+
if (request[5] === 0 || !Number.isFinite(layer) || Math.trunc(layer) !== layer || layer < -2147483648 || layer > 2147483647) status = web ? 6 : 5;
|
|
73
|
+
else result.set(request.subarray(16, 24), 16);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
const count = word(8), final = request[3]!, prior = word(40);
|
|
77
|
+
if (final > 1 || count > 256 || request.length !== 96 + count || prior > 4) throw new Error("invalid bridge origin chunk");
|
|
78
|
+
const endLow = word(24) + count, carry = endLow > 4294967295 ? 1 : 0, endHigh = word(28) + carry, low = endLow - carry * 4294967296;
|
|
79
|
+
if (endHigh > word(20) || endHigh === word(20) && low > word(16) || final === 1 && (endHigh !== word(20) || low !== word(16))) throw new Error("invalid bridge origin extent");
|
|
80
|
+
if (word(24) === 0 && word(28) === 0 && request[48] === 97 && request[49] === 98 && request[50] === 111 && request[51] === 117 && request[52] === 116 && request[53] === 58) out.setUint32(12, 1, true);
|
|
81
|
+
else {
|
|
82
|
+
let state = prior, found = false, invalid = false, positionLow = low, positionHigh = endHigh;
|
|
83
|
+
for (let i = 0; i < count; i++) {
|
|
84
|
+
const ch = request[96 + i]!;
|
|
85
|
+
if (state === 3 || state === 4) {
|
|
86
|
+
if (ch === 47 || ch === 63 || ch === 35) {
|
|
87
|
+
invalid = state === 3; found = true;
|
|
88
|
+
const position = word(24) + i, positionCarry = position > 4294967295 ? 1 : 0;
|
|
89
|
+
positionLow = position - positionCarry * 4294967296; positionHigh = word(28) + positionCarry;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
state = 4;
|
|
93
|
+
} else if (state === 2 && ch === 47) state = 3;
|
|
94
|
+
else if (state === 1 && ch === 47) state = 2;
|
|
95
|
+
else state = ch === 58 ? 1 : 0;
|
|
96
|
+
}
|
|
97
|
+
if (!found && final === 0) status = 2;
|
|
98
|
+
else if (invalid || !found && state !== 4 || positionHigh > word(36) || positionHigh === word(36) && positionLow > word(32)) status = 6;
|
|
99
|
+
out.setUint32(16, positionLow, true); out.setUint32(20, positionHigh, true); out.setUint32(24, state, true);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
out.setUint32(8, status, true);
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/** Complete builtin command routing and error projection. Native owns raw JSON,
|
|
2
|
+
* buffers, handler/capability execution and response-envelope serialization.
|
|
3
|
+
*/
|
|
4
|
+
type NscBuiltinFamily = { prefix: string; permission: number; denial: string; unknown: string };
|
|
5
|
+
type NscBuiltinVerb = { name: string; family: number; operation: number };
|
|
6
|
+
type NscBuiltinError = { name: string; code: number; message: string };
|
|
7
|
+
const NSC_BUILTIN_FAMILIES: nscContracts.Immutable<NscBuiltinFamily[]> = [
|
|
8
|
+
{"prefix": "native-sdk.command.", "permission": 1, "denial": "Command API is not permitted", "unknown": "Unknown command command"},
|
|
9
|
+
{"prefix": "native-sdk.window.", "permission": 2, "denial": "Window API is not permitted", "unknown": "Unknown window command"},
|
|
10
|
+
{"prefix": "native-sdk.view.", "permission": 3, "denial": "View API is not permitted", "unknown": "Unknown view command"},
|
|
11
|
+
{"prefix": "native-sdk.webview.", "permission": 2, "denial": "WebView API is not permitted", "unknown": "Unknown WebView command"},
|
|
12
|
+
{"prefix": "native-sdk.platform.", "permission": 2, "denial": "Platform API is not permitted", "unknown": "Unknown platform command"},
|
|
13
|
+
{"prefix": "native-sdk.dialog.", "permission": 0, "denial": "Dialog API is not permitted", "unknown": "Unknown dialog command"},
|
|
14
|
+
{"prefix": "native-sdk.os.", "permission": 0, "denial": "OS API is not permitted", "unknown": "Unknown OS command"},
|
|
15
|
+
{"prefix": "native-sdk.clipboard.", "permission": 0, "denial": "Clipboard API is not permitted", "unknown": "Unknown clipboard command"},
|
|
16
|
+
{"prefix": "native-sdk.credentials.", "permission": 0, "denial": "Credentials API is not permitted", "unknown": "Unknown credentials command"},
|
|
17
|
+
];
|
|
18
|
+
const NSC_BUILTIN_VERBS: nscContracts.Immutable<NscBuiltinVerb[]> = [
|
|
19
|
+
{"name": "native-sdk.command.invoke", "family": 1, "operation": 1},
|
|
20
|
+
{"name": "native-sdk.command.list", "family": 1, "operation": 2},
|
|
21
|
+
{"name": "native-sdk.platform.supports", "family": 5, "operation": 3},
|
|
22
|
+
{"name": "native-sdk.window.list", "family": 2, "operation": 4},
|
|
23
|
+
{"name": "native-sdk.window.create", "family": 2, "operation": 5},
|
|
24
|
+
{"name": "native-sdk.window.focus", "family": 2, "operation": 6},
|
|
25
|
+
{"name": "native-sdk.window.close", "family": 2, "operation": 7},
|
|
26
|
+
{"name": "native-sdk.view.create", "family": 3, "operation": 8},
|
|
27
|
+
{"name": "native-sdk.view.list", "family": 3, "operation": 9},
|
|
28
|
+
{"name": "native-sdk.view.update", "family": 3, "operation": 10},
|
|
29
|
+
{"name": "native-sdk.view.setFrame", "family": 3, "operation": 11},
|
|
30
|
+
{"name": "native-sdk.view.setVisible", "family": 3, "operation": 12},
|
|
31
|
+
{"name": "native-sdk.view.focus", "family": 3, "operation": 13},
|
|
32
|
+
{"name": "native-sdk.view.focusNext", "family": 3, "operation": 14},
|
|
33
|
+
{"name": "native-sdk.view.focusPrevious", "family": 3, "operation": 15},
|
|
34
|
+
{"name": "native-sdk.view.close", "family": 3, "operation": 16},
|
|
35
|
+
{"name": "native-sdk.webview.create", "family": 4, "operation": 17},
|
|
36
|
+
{"name": "native-sdk.webview.list", "family": 4, "operation": 18},
|
|
37
|
+
{"name": "native-sdk.webview.setFrame", "family": 4, "operation": 19},
|
|
38
|
+
{"name": "native-sdk.webview.navigate", "family": 4, "operation": 20},
|
|
39
|
+
{"name": "native-sdk.webview.setZoom", "family": 4, "operation": 21},
|
|
40
|
+
{"name": "native-sdk.webview.setLayer", "family": 4, "operation": 22},
|
|
41
|
+
{"name": "native-sdk.webview.close", "family": 4, "operation": 23},
|
|
42
|
+
{"name": "native-sdk.dialog.openFile", "family": 6, "operation": 24},
|
|
43
|
+
{"name": "native-sdk.dialog.saveFile", "family": 6, "operation": 25},
|
|
44
|
+
{"name": "native-sdk.dialog.showMessage", "family": 6, "operation": 26},
|
|
45
|
+
{"name": "native-sdk.os.showNotification", "family": 7, "operation": 27},
|
|
46
|
+
{"name": "native-sdk.os.openUrl", "family": 7, "operation": 28},
|
|
47
|
+
{"name": "native-sdk.os.revealPath", "family": 7, "operation": 29},
|
|
48
|
+
{"name": "native-sdk.os.addRecentDocument", "family": 7, "operation": 30},
|
|
49
|
+
{"name": "native-sdk.os.clearRecentDocuments", "family": 7, "operation": 31},
|
|
50
|
+
{"name": "native-sdk.credentials.set", "family": 9, "operation": 32},
|
|
51
|
+
{"name": "native-sdk.credentials.get", "family": 9, "operation": 33},
|
|
52
|
+
{"name": "native-sdk.credentials.delete", "family": 9, "operation": 34},
|
|
53
|
+
{"name": "native-sdk.clipboard.readText", "family": 8, "operation": 35},
|
|
54
|
+
{"name": "native-sdk.clipboard.writeText", "family": 8, "operation": 36},
|
|
55
|
+
{"name": "native-sdk.clipboard.read", "family": 8, "operation": 37},
|
|
56
|
+
{"name": "native-sdk.clipboard.write", "family": 8, "operation": 38},
|
|
57
|
+
];
|
|
58
|
+
const NSC_BUILTIN_ERRORS: nscContracts.Immutable<NscBuiltinError[]> = [
|
|
59
|
+
{"name": "UnsupportedService", "code": 0, "message": "Native service is not available on this platform"},
|
|
60
|
+
{"name": "UnsupportedWindowTransparency", "code": 0, "message": "This backend cannot make window content transparent"},
|
|
61
|
+
{"name": "WindowNotFound", "code": 0, "message": "Window was not found"},
|
|
62
|
+
{"name": "WindowLimitReached", "code": 0, "message": "Window limit reached"},
|
|
63
|
+
{"name": "DuplicateWindowLabel", "code": 0, "message": "Window id or label already exists"},
|
|
64
|
+
{"name": "MissingWindowSource", "code": 0, "message": "Window source is missing"},
|
|
65
|
+
{"name": "WindowSourceTooLarge", "code": 0, "message": "Window source is too large"},
|
|
66
|
+
{"name": "CreateFailed", "code": 5, "message": "Native view creation failed"},
|
|
67
|
+
{"name": "MissingWebViewUrl", "code": 0, "message": "WebView URL is missing"},
|
|
68
|
+
{"name": "InvalidWebViewWindowId", "code": 0, "message": "windowId must be a non-negative integer"},
|
|
69
|
+
{"name": "CrossWindowWebViewDenied", "code": 0, "message": "WebView windowId must match the calling window"},
|
|
70
|
+
{"name": "InvalidWebViewOptions", "code": 0, "message": "WebView options are invalid"},
|
|
71
|
+
{"name": "WebViewNotFound", "code": 0, "message": "WebView was not found"},
|
|
72
|
+
{"name": "WebViewLayerNotBuilt", "code": 0, "message": "this app was built without the web layer because nothing in app.zon declared web use; add \"webview\" to .capabilities (or a .frontend block / a .shell webview view) and rebuild"},
|
|
73
|
+
{"name": "WebViewLimitReached", "code": 0, "message": "WebView limit reached"},
|
|
74
|
+
{"name": "DuplicateWebViewLabel", "code": 0, "message": "WebView label already exists"},
|
|
75
|
+
{"name": "ReservedWebViewLabel", "code": 0, "message": "WebView label \"main\" is reserved for the startup WebView"},
|
|
76
|
+
{"name": "WebViewLabelTooLarge", "code": 0, "message": "WebView label is too large"},
|
|
77
|
+
{"name": "WebViewUrlTooLarge", "code": 0, "message": "WebView URL is too large"},
|
|
78
|
+
{"name": "UnsupportedChildWebViews", "code": 0, "message": "This backend does not support child WebViews yet"},
|
|
79
|
+
{"name": "UnsupportedWebViewBridge", "code": 0, "message": "This backend does not support bridge-enabled child WebViews yet"},
|
|
80
|
+
{"name": "UnsupportedMainWebViewFrame", "code": 0, "message": "This backend does not support resizing the main WebView yet"},
|
|
81
|
+
{"name": "UnsupportedMainWebViewZoom", "code": 0, "message": "This backend does not support zooming the main WebView yet"},
|
|
82
|
+
{"name": "UnsupportedMainWebViewLayer", "code": 0, "message": "This backend does not support changing the main WebView layer"},
|
|
83
|
+
{"name": "NavigationDenied", "code": 0, "message": "URL is not allowed by navigation policy"},
|
|
84
|
+
{"name": "InvalidExternalUrl", "code": 0, "message": "External URL is invalid"},
|
|
85
|
+
{"name": "ExternalUrlTooLarge", "code": 0, "message": "External URL is too large"},
|
|
86
|
+
{"name": "InvalidRevealPath", "code": 0, "message": "Reveal path is invalid"},
|
|
87
|
+
{"name": "RevealPathTooLarge", "code": 0, "message": "Reveal path is too large"},
|
|
88
|
+
{"name": "InvalidRecentDocumentPath", "code": 0, "message": "Recent document path is invalid"},
|
|
89
|
+
{"name": "RecentDocumentPathTooLarge", "code": 0, "message": "Recent document path is too large"},
|
|
90
|
+
{"name": "InvalidDialogOptions", "code": 0, "message": "Dialog options are invalid"},
|
|
91
|
+
{"name": "DialogFieldTooLarge", "code": 0, "message": "Dialog field is too large"},
|
|
92
|
+
{"name": "InvalidNotificationOptions", "code": 0, "message": "Notification options are invalid"},
|
|
93
|
+
{"name": "NotificationFieldTooLarge", "code": 0, "message": "Notification field is too large"},
|
|
94
|
+
{"name": "InvalidClipboardOptions", "code": 0, "message": "Clipboard options are invalid"},
|
|
95
|
+
{"name": "ClipboardFieldTooLarge", "code": 0, "message": "Clipboard field is too large"},
|
|
96
|
+
{"name": "InvalidCredentialOptions", "code": 0, "message": "Credential options are invalid"},
|
|
97
|
+
{"name": "CredentialFieldTooLarge", "code": 0, "message": "Credential field is too large"},
|
|
98
|
+
{"name": "CredentialNotFound", "code": 5, "message": "Credential was not found"},
|
|
99
|
+
{"name": "InvalidTrayOptions", "code": 0, "message": "Tray options are invalid"},
|
|
100
|
+
{"name": "TrayFieldTooLarge", "code": 0, "message": "Tray field is too large"},
|
|
101
|
+
{"name": "InvalidPlatformFeature", "code": 0, "message": "Platform feature is invalid"},
|
|
102
|
+
{"name": "InvalidWindowOptions", "code": 0, "message": "Window options are invalid"},
|
|
103
|
+
{"name": "InvalidCommand", "code": 0, "message": "Command name is invalid"},
|
|
104
|
+
{"name": "DuplicateWindowId", "code": 0, "message": "Window id already exists"},
|
|
105
|
+
{"name": "InvalidViewOptions", "code": 0, "message": "View options are invalid"},
|
|
106
|
+
{"name": "InvalidViewWindowId", "code": 0, "message": "view windowId must be a non-negative integer"},
|
|
107
|
+
{"name": "CrossWindowViewDenied", "code": 0, "message": "view windowId must match the calling window"},
|
|
108
|
+
{"name": "ViewNotFound", "code": 0, "message": "View was not found"},
|
|
109
|
+
{"name": "ViewLimitReached", "code": 0, "message": "View limit reached"},
|
|
110
|
+
{"name": "DuplicateViewLabel", "code": 0, "message": "View label already exists"},
|
|
111
|
+
{"name": "ViewLabelTooLarge", "code": 0, "message": "View label is too large"},
|
|
112
|
+
{"name": "ViewRoleTooLarge", "code": 0, "message": "View role is too large"},
|
|
113
|
+
{"name": "ViewAccessibilityLabelTooLarge", "code": 0, "message": "View accessibility label is too large"},
|
|
114
|
+
{"name": "ViewTextTooLarge", "code": 0, "message": "View text is too large"},
|
|
115
|
+
{"name": "WidgetNodeLimitReached", "code": 5, "message": "Canvas widget node limit reached"},
|
|
116
|
+
{"name": "WidgetTextTooLarge", "code": 5, "message": "Canvas widget text is too large"},
|
|
117
|
+
{"name": "WidgetSemanticsListFull", "code": 5, "message": "Canvas widget semantics limit reached"},
|
|
118
|
+
{"name": "DuplicateWidgetId", "code": 5, "message": "Canvas widget id already exists"},
|
|
119
|
+
{"name": "UnsupportedViewKind", "code": 0, "message": "This backend does not support this native view kind yet"},
|
|
120
|
+
{"name": "UnsupportedViewFocus", "code": 0, "message": "This backend does not support focusing this native view yet"},
|
|
121
|
+
{"name": "NoSpaceLeft", "code": 5, "message": "Native response buffer is too small"},
|
|
122
|
+
{"name": "BuiltinWindowListFailed", "code": 5, "message": "Failed to list windows"},
|
|
123
|
+
];
|
|
124
|
+
function nscBuiltinText(bytes: Uint8Array, text: string, prefix: boolean): boolean {
|
|
125
|
+
if (prefix ? bytes.length < text.length : bytes.length !== text.length) return false;
|
|
126
|
+
for (let i = 0; i < text.length; i++) if (bytes[i] !== text.charCodeAt(i)) return false;
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
function nscBuiltinAppend(out: Uint8Array, at: number, text: string): number {
|
|
130
|
+
for (let i = 0; i < text.length; i++) out[at + i] = text.charCodeAt(i);
|
|
131
|
+
return at + text.length;
|
|
132
|
+
}
|
|
133
|
+
function nscvBuiltinCoordination(request: Uint8Array): Uint8Array {
|
|
134
|
+
if (request.length < 8 || request[0] !== 89 || request[1] !== 1 || request[2]! > 2)
|
|
135
|
+
throw new Error("invalid builtin coordination header");
|
|
136
|
+
const mode = request[2]!;
|
|
137
|
+
if (request[5] !== 0 || request[6] !== 0 || request[7] !== 0) throw new Error("invalid builtin coordination reserve");
|
|
138
|
+
if (mode === 2) {
|
|
139
|
+
if (request.length !== 8 || request[3]! > 1 || request[4]! > 1) throw new Error("invalid notification permission plan");
|
|
140
|
+
const denied = request[3] === 1 && request[4] !== 1;
|
|
141
|
+
const text = denied ? "Notification actions require command invoke permission" : "";
|
|
142
|
+
const result = new Uint8Array(16 + text.length), data = new DataView(result.buffer);
|
|
143
|
+
data.setUint32(0, 1, true); data.setUint32(4, mode, true); result[8] = denied ? 1 : 0;
|
|
144
|
+
data.setUint32(12, text.length, true); nscBuiltinAppend(result, 16, text); return result;
|
|
145
|
+
}
|
|
146
|
+
if (request.length < 16 || request[4] !== 0 || request[3]! > (mode === 0 ? 9 : 0))
|
|
147
|
+
throw new Error("invalid builtin coordination context");
|
|
148
|
+
const input = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
149
|
+
const count = input.getUint32(8, true), upper = input.getUint32(12, true);
|
|
150
|
+
if (upper !== 0 || count !== request.length - 16) throw new Error("invalid builtin coordination extent");
|
|
151
|
+
const value = request.subarray(16);
|
|
152
|
+
if (mode === 1) {
|
|
153
|
+
let code = 5, message = "Native command failed";
|
|
154
|
+
for (const error of NSC_BUILTIN_ERRORS) if (nscBuiltinText(value, error.name, false)) {
|
|
155
|
+
code = error.code; message = error.message; break;
|
|
156
|
+
}
|
|
157
|
+
const result = new Uint8Array(16 + message.length), data = new DataView(result.buffer);
|
|
158
|
+
data.setUint32(0, 1, true); data.setUint32(4, mode, true); result[8] = code;
|
|
159
|
+
data.setUint32(12, message.length, true); nscBuiltinAppend(result, 16, message); return result;
|
|
160
|
+
}
|
|
161
|
+
let family = 0, operation = 0;
|
|
162
|
+
for (let i = 0; i < NSC_BUILTIN_FAMILIES.length; i++) if (nscBuiltinText(value, NSC_BUILTIN_FAMILIES[i]!.prefix, true)) { family = i + 1; break; }
|
|
163
|
+
for (const verb of NSC_BUILTIN_VERBS) if (nscBuiltinText(value, verb.name, false)) { operation = verb.operation; break; }
|
|
164
|
+
const context = request[3] === 0 ? family : request[3]!;
|
|
165
|
+
const denial = context === 0 ? "" : NSC_BUILTIN_FAMILIES[context - 1]!.denial;
|
|
166
|
+
const unknown = context === 0 ? "" : NSC_BUILTIN_FAMILIES[context - 1]!.unknown;
|
|
167
|
+
const result = new Uint8Array(16 + denial.length + unknown.length), data = new DataView(result.buffer);
|
|
168
|
+
data.setUint32(0, 1, true); data.setUint32(4, mode, true); result[8] = family; result[9] = operation;
|
|
169
|
+
result[10] = family === 0 ? 0 : NSC_BUILTIN_FAMILIES[family - 1]!.permission;
|
|
170
|
+
data.setUint16(12, denial.length, true); data.setUint16(14, unknown.length, true);
|
|
171
|
+
nscBuiltinAppend(result, nscBuiltinAppend(result, 16, denial), unknown); return result;
|
|
172
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Frame admission and surface preparation over copied native observations.
|
|
2
|
+
* Native keeps resource/buffer storage, command observation and OS/GPU calls. */
|
|
3
|
+
function nscvCanvasFrameCoordination(request: Uint8Array): Uint8Array {
|
|
4
|
+
if (request.length !== 320 || request[0] !== 75 || request[1] !== 1 || request[2]! > 6 || request[3] !== 0)
|
|
5
|
+
throw new Error("invalid canvas frame coordination header");
|
|
6
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
7
|
+
const mode = request[2]!, facts = wire.getUint32(4, true);
|
|
8
|
+
if (facts > 127 || wire.getUint32(312, true) !== 0 || wire.getUint32(316, true) !== 0)
|
|
9
|
+
throw new Error("invalid canvas frame coordination facts");
|
|
10
|
+
const result = new Uint8Array(64), out = new DataView(result.buffer);
|
|
11
|
+
out.setUint32(0, 1, true);
|
|
12
|
+
let flags = 0;
|
|
13
|
+
const zero = (at: number): boolean => wire.getUint32(at, true) === 0 && wire.getUint32(at + 4, true) === 0;
|
|
14
|
+
const equal64 = (a: number, b: number): boolean => wire.getUint32(a, true) === wire.getUint32(b, true) && wire.getUint32(a + 4, true) === wire.getUint32(b + 4, true);
|
|
15
|
+
const copy = (to: number, from: number): void => { out.setUint32(to, wire.getUint32(from, true), true); };
|
|
16
|
+
const empty = (at: number): boolean => wire.getFloat32(at, true) <= 0 || wire.getFloat32(at + 4, true) <= 0;
|
|
17
|
+
const normalizedScale = (): void => {
|
|
18
|
+
const wanted = wire.getFloat32(32, true), fallback = wire.getFloat32(36, true);
|
|
19
|
+
if ((facts & 32) !== 0 && Number.isFinite(wanted) && wanted > 0) copy(16, 32);
|
|
20
|
+
else if (Number.isFinite(fallback) && fallback > 0) copy(16, 36);
|
|
21
|
+
else out.setFloat32(16, 1, true);
|
|
22
|
+
};
|
|
23
|
+
if (mode === 0) {
|
|
24
|
+
const at = empty(8) ? empty(16) ? 24 : 16 : 8;
|
|
25
|
+
copy(8, at); copy(12, at + 4);
|
|
26
|
+
if (zero(96)) flags |= 1;
|
|
27
|
+
if (zero(104)) flags |= 2;
|
|
28
|
+
let unset = true;
|
|
29
|
+
for (let at = 128; at < 312; at += 8) if (!zero(at)) unset = false;
|
|
30
|
+
if (unset) flags |= 4;
|
|
31
|
+
} else if (mode === 1 || mode === 2) {
|
|
32
|
+
const changed = !equal64(64, 72);
|
|
33
|
+
const surfaceChanged = wire.getFloat32(8, true) !== wire.getFloat32(40, true) ||
|
|
34
|
+
wire.getFloat32(12, true) !== wire.getFloat32(44, true) || wire.getFloat32(32, true) !== wire.getFloat32(48, true);
|
|
35
|
+
const full = (facts & 1) !== 0 || (facts & 2) === 0 || surfaceChanged ||
|
|
36
|
+
changed && ((facts & 4) !== 0 || mode === 2 && (facts & 8) !== 0);
|
|
37
|
+
if (mode === 1) {
|
|
38
|
+
if ((facts & 1) === 0 && (facts & 2) !== 0 && !changed && !surfaceChanged && zero(80) && zero(88)) flags |= 8;
|
|
39
|
+
if (changed) flags |= 16;
|
|
40
|
+
if (surfaceChanged) flags |= 32;
|
|
41
|
+
// Request the current unkeyed observation only when native's original
|
|
42
|
+
// short-circuit would reach it, after the ordered frame planners finish.
|
|
43
|
+
if (!full && changed) flags |= 64;
|
|
44
|
+
} else if (!full && changed && (facts & 16) !== 0 &&
|
|
45
|
+
wire.getFloat32(8, true) === wire.getFloat32(52, true) &&
|
|
46
|
+
wire.getFloat32(12, true) === wire.getFloat32(56, true) &&
|
|
47
|
+
wire.getFloat32(32, true) === wire.getFloat32(60, true)) flags |= 256;
|
|
48
|
+
if (full) flags |= 128;
|
|
49
|
+
} else if (mode === 3) {
|
|
50
|
+
const width = wire.getFloat32(8, true), height = wire.getFloat32(12, true);
|
|
51
|
+
if (!(Math.abs(width) <= 0 || Math.abs(height) <= 0)) {
|
|
52
|
+
flags |= 512;
|
|
53
|
+
// Preserve copied float32 payloads, including signed zero and NaNs.
|
|
54
|
+
// A negative extent moves the zero origin and flips its extent sign.
|
|
55
|
+
if (width < 0) { copy(20, 8); out.setUint32(28, (wire.getUint32(8, true) ^ 2147483648) >>> 0, true); }
|
|
56
|
+
else copy(28, 8);
|
|
57
|
+
if (height < 0) { copy(24, 12); out.setUint32(32, (wire.getUint32(12, true) ^ 2147483648) >>> 0, true); }
|
|
58
|
+
else copy(32, 12);
|
|
59
|
+
} else if ((facts & 64) !== 0) {
|
|
60
|
+
flags |= 512;
|
|
61
|
+
for (let i = 0; i < 4; i++) copy(20 + i * 4, 112 + i * 4);
|
|
62
|
+
}
|
|
63
|
+
} else if (mode === 4) {
|
|
64
|
+
normalizedScale();
|
|
65
|
+
} else if (mode === 5) {
|
|
66
|
+
const rawScale = wire.getFloat32(32, true), scale = Number.isFinite(rawScale) && rawScale > 0 ? rawScale : 1;
|
|
67
|
+
const width = Math.fround(wire.getFloat32(8, true) * scale), height = Math.fround(wire.getFloat32(12, true) * scale);
|
|
68
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0 || width > 16384 || height > 16384) flags |= 1024;
|
|
69
|
+
else {
|
|
70
|
+
const w = Math.ceil(width), h = Math.ceil(height);
|
|
71
|
+
// The extent cap proves all three products fit every supported usize,
|
|
72
|
+
// including the 32-bit targets; the largest byte length is 1 GiB.
|
|
73
|
+
out.setUint32(36, w, true); out.setUint32(40, h, true); out.setUint32(44, w * h * 4, true);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
const at = empty(16) ? 24 : 16;
|
|
77
|
+
copy(8, at); copy(12, at + 4); normalizedScale();
|
|
78
|
+
}
|
|
79
|
+
out.setUint32(4, flags, true);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** Presentation lifecycle decisions over copied host and buffer observations.
|
|
2
|
+
* Native owns rasterization, encoding, uploads, storage and presentation. */
|
|
3
|
+
function nscvCanvasPresentationLifecycle(request: Uint8Array): Uint8Array {
|
|
4
|
+
if (request.length !== 128 || request[0] !== 77 || request[1] !== 1 || request[2]! > 12 || request[3]! > 3)
|
|
5
|
+
throw new Error("invalid presentation lifecycle header");
|
|
6
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
7
|
+
const mode = request[2]!, flags = w.getUint32(4, true);
|
|
8
|
+
const safety = (request[3]! & 1) !== 0, word32 = (request[3]! & 2) !== 0;
|
|
9
|
+
if (flags > 1023 || w.getUint32(112, true) > 5 || w.getUint32(116, true) > 5 ||
|
|
10
|
+
w.getUint32(120, true) !== 0 || w.getUint32(124, true) !== 0)
|
|
11
|
+
throw new Error("invalid presentation lifecycle facts");
|
|
12
|
+
if (word32) for (let at = 12; at < 112; at += 8) if (w.getUint32(at, true) !== 0)
|
|
13
|
+
throw new Error("invalid presentation lifecycle word extent");
|
|
14
|
+
const nonzero = (at: number): boolean => w.getUint32(at, true) !== 0 || w.getUint32(at + 4, true) !== 0;
|
|
15
|
+
const compare = (a: number, b: number): number => {
|
|
16
|
+
const ah = w.getUint32(a + 4, true), bh = w.getUint32(b + 4, true);
|
|
17
|
+
return ah === bh ? w.getUint32(a, true) - w.getUint32(b, true) : ah - bh;
|
|
18
|
+
};
|
|
19
|
+
// skipped, packet, upload, encode, pixels, done, gather, adopt, invalidate, observe image.
|
|
20
|
+
let instruction = 0, refusal = 0, mutations = 0;
|
|
21
|
+
let countLower = 0, countUpper = 0, loggedLower = 0, loggedUpper = 0;
|
|
22
|
+
let detailLower = 0, detailUpper = 0;
|
|
23
|
+
const requested = (flags & 2) === 0 || (flags & 4) === 0;
|
|
24
|
+
if (mode === 0) instruction = requested ? 1 : 4;
|
|
25
|
+
else if (mode === 1) {
|
|
26
|
+
if ((flags & 1) !== 0) {
|
|
27
|
+
instruction = 4;
|
|
28
|
+
if (requested && nonzero(8) && nonzero(16)) {
|
|
29
|
+
if ((flags & 8) !== 0) instruction = 1;
|
|
30
|
+
else refusal = 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else if (mode === 2) {
|
|
34
|
+
instruction = (flags & 16) !== 0 ? 2 : 4;
|
|
35
|
+
refusal = (flags & 16) !== 0 ? 0 : 2;
|
|
36
|
+
} else if (mode === 3) {
|
|
37
|
+
instruction = (flags & 32) !== 0 ? 3 : 4;
|
|
38
|
+
refusal = (flags & 32) !== 0 ? 0 : 1;
|
|
39
|
+
} else if (mode === 4) instruction = (flags & 32) !== 0 ? 5 : 4;
|
|
40
|
+
else if (mode === 5) {
|
|
41
|
+
instruction = (flags & 1) !== 0 ? 4 : 0;
|
|
42
|
+
if (instruction === 4 && compare(24, 32) >= 0) mutations = 1;
|
|
43
|
+
} else if (mode === 6) instruction = (flags & 64) !== 0 ? 6 : 8;
|
|
44
|
+
else if (mode === 7) instruction = (flags & 128) !== 0 ? 7 : 8;
|
|
45
|
+
else if (mode === 8) {
|
|
46
|
+
countLower = w.getUint32(40, true); countUpper = w.getUint32(44, true);
|
|
47
|
+
loggedLower = w.getUint32(48, true); loggedUpper = w.getUint32(52, true);
|
|
48
|
+
if (safety && countLower === 4294967295 && (word32 || countUpper === 4294967295)) mutations = 4;
|
|
49
|
+
else {
|
|
50
|
+
countLower = (countLower + 1) >>> 0;
|
|
51
|
+
if (countLower === 0 && !word32) countUpper = (countUpper + 1) >>> 0;
|
|
52
|
+
const first = countUpper === 0 && countLower === 1;
|
|
53
|
+
const changed = w.getUint32(112, true) !== w.getUint32(116, true);
|
|
54
|
+
// Preserve native short-circuiting: the subtraction is not evaluated
|
|
55
|
+
// on the first fallback or a reason change, even for hostile counters.
|
|
56
|
+
let log = first || changed;
|
|
57
|
+
if (!log) {
|
|
58
|
+
const below = countUpper < loggedUpper || countUpper === loggedUpper && countLower < loggedLower;
|
|
59
|
+
if (below && safety) mutations = 4;
|
|
60
|
+
else {
|
|
61
|
+
const lower = (countLower - loggedLower) >>> 0;
|
|
62
|
+
const upper = word32 ? 0 : (countUpper - loggedUpper - (countLower < loggedLower ? 1 : 0)) >>> 0;
|
|
63
|
+
log = upper !== 0 || lower >= 120;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (log) { mutations |= 2; loggedLower = countLower; loggedUpper = countUpper; }
|
|
67
|
+
}
|
|
68
|
+
const detail = compare(56, 64) < 0 ? 56 : 64;
|
|
69
|
+
detailLower = w.getUint32(detail, true); detailUpper = w.getUint32(detail + 4, true);
|
|
70
|
+
} else if (mode === 9) {
|
|
71
|
+
if ((flags & 256) !== 0 && (flags & 512) !== 0 && compare(72, 80) < 0) instruction = 9;
|
|
72
|
+
} else if (mode === 10) {
|
|
73
|
+
if (nonzero(88) && nonzero(96) && nonzero(104)) instruction = 2;
|
|
74
|
+
} else if (mode === 11) {
|
|
75
|
+
instruction = 2; refusal = (flags & 16) !== 0 ? 1 : 2;
|
|
76
|
+
} else instruction = (flags & 1) !== 0 ? 5 : 0;
|
|
77
|
+
const result = new Uint8Array(64), out = new DataView(result.buffer);
|
|
78
|
+
out.setUint32(0, 1, true); out.setUint32(4, instruction, true);
|
|
79
|
+
out.setUint32(8, refusal, true); out.setUint32(12, mutations, true);
|
|
80
|
+
out.setUint32(16, countLower, true); out.setUint32(20, countUpper, true);
|
|
81
|
+
out.setUint32(24, loggedLower, true); out.setUint32(28, loggedUpper, true);
|
|
82
|
+
out.setUint32(32, detailLower, true); out.setUint32(36, detailUpper, true);
|
|
83
|
+
return result;
|
|
84
|
+
}
|