@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,203 @@
|
|
|
1
|
+
/** Retained paint scheduling over copied layout, state and command identities.
|
|
2
|
+
* Native executes drawing capabilities; this plan owns traversal decisions. */
|
|
3
|
+
interface NscWalkNode {
|
|
4
|
+
readonly walk_kind: number; readonly walk_flags: number;
|
|
5
|
+
readonly walk_parent: number; readonly walk_parent_high: number;
|
|
6
|
+
readonly walk_id: number; readonly walk_id_high: number;
|
|
7
|
+
readonly walk_preview_id: number; readonly walk_preview_id_high: number;
|
|
8
|
+
readonly walk_depth: number; readonly walk_depth_high: number; readonly walk_layer: number;
|
|
9
|
+
readonly walk_frame: NscSurfaceRect; readonly walk_transform: NscRenderAffine;
|
|
10
|
+
readonly walk_opacity: number; readonly walk_opacity_word: number; readonly walk_value: number; readonly walk_gap: number;
|
|
11
|
+
}
|
|
12
|
+
interface NscWalkMotion extends NscPresentationMotion { readonly walk_dx_word: number; readonly walk_dy_word: number; }
|
|
13
|
+
interface NscWalkOrder { readonly walk_slot: number; readonly walk_layer: number; }
|
|
14
|
+
interface NscWalkContext {
|
|
15
|
+
readonly walk_nodes: readonly NscWalkNode[]; readonly walk_motions: readonly NscWalkMotion[];
|
|
16
|
+
readonly walk_reveals: readonly number[]; readonly walk_ids: readonly number[];
|
|
17
|
+
readonly walk_flags: number; readonly walk_scalar: number; readonly walk_numeric: number; readonly walk_nan: number; readonly walk_layers: readonly number[];
|
|
18
|
+
}
|
|
19
|
+
function nscvWalkHoisted(n: NscWalkNode): boolean { return (n.walk_flags & 2) !== 0 || n.walk_kind === 19 || n.walk_kind === 20 || n.walk_kind === 21; }
|
|
20
|
+
function nscvWalkParent(c: NscWalkContext, n: NscWalkNode): number {
|
|
21
|
+
return (n.walk_flags & 1) === 0 ? -1 : n.walk_parent_high !== 0 || n.walk_parent >= c.walk_nodes.length ? c.walk_nodes.length : n.walk_parent;
|
|
22
|
+
}
|
|
23
|
+
function nscvWalkSameParent(a: NscWalkNode, b: NscWalkNode): boolean {
|
|
24
|
+
return (a.walk_flags & 1) === (b.walk_flags & 1) && ((a.walk_flags & 1) === 0 || (a.walk_parent === b.walk_parent && a.walk_parent_high === b.walk_parent_high));
|
|
25
|
+
}
|
|
26
|
+
function nscvWalkId(n: NscWalkNode, ids: readonly number[], at: number): boolean { return n.walk_id === ids[at] && n.walk_id_high === ids[at + 1]; }
|
|
27
|
+
function nscvWalkNonzero(n: NscWalkNode): boolean { return n.walk_id !== 0 || n.walk_id_high !== 0; }
|
|
28
|
+
function nscvWalkLayer(c: NscWalkContext, n: NscWalkNode, surface: boolean): number {
|
|
29
|
+
if ((n.walk_flags & 8) !== 0) return n.walk_layer;
|
|
30
|
+
if (n.walk_kind === 19 || n.walk_kind === 20 || n.walk_kind === 21) return c.walk_layers[3]!;
|
|
31
|
+
if ((surface && (n.walk_flags & 2) !== 0) || n.walk_kind === 23 || n.walk_kind === 24 || n.walk_kind === 25) return c.walk_layers[1]!;
|
|
32
|
+
return c.walk_layers[n.walk_kind === 40 ? 2 : 0]!;
|
|
33
|
+
}
|
|
34
|
+
function nscvWalkSurfaceLayer(c: NscWalkContext, slot: number): number {
|
|
35
|
+
const n = c.walk_nodes[slot]!;
|
|
36
|
+
let layer = nscvWalkLayer(c, n, true);
|
|
37
|
+
if ((n.walk_flags & 8) !== 0) return layer;
|
|
38
|
+
let parent = nscvWalkParent(c, n);
|
|
39
|
+
while (parent >= 0 && parent < c.walk_nodes.length) {
|
|
40
|
+
const ancestor = c.walk_nodes[parent]!;
|
|
41
|
+
if (nscvWalkHoisted(ancestor)) layer = Math.max(layer, nscvWalkLayer(c, ancestor, true));
|
|
42
|
+
parent = nscvWalkParent(c, ancestor);
|
|
43
|
+
}
|
|
44
|
+
return layer;
|
|
45
|
+
}
|
|
46
|
+
function nscvWalkCompare(a: NscWalkOrder, b: NscWalkOrder): number { return a.walk_layer === b.walk_layer ? a.walk_slot - b.walk_slot : a.walk_layer - b.walk_layer; }
|
|
47
|
+
function nscvWalkDeeper(a: NscWalkNode, b: NscWalkNode): boolean { return a.walk_depth_high > b.walk_depth_high || (a.walk_depth_high === b.walk_depth_high && a.walk_depth > b.walk_depth); }
|
|
48
|
+
function nscvWalkSelected(n: NscWalkNode): boolean { return (n.walk_flags & 128) !== 0 || n.walk_value >= 0.5; }
|
|
49
|
+
function nscvWalkSettled(c: NscWalkContext, slot: number): boolean {
|
|
50
|
+
const n = c.walk_nodes[slot]!;
|
|
51
|
+
if (!nscvWalkSelected(n)) return false;
|
|
52
|
+
let bottom = -Infinity, i = slot + 1;
|
|
53
|
+
while (i < c.walk_nodes.length && nscvWalkDeeper(c.walk_nodes[i]!, n)) {
|
|
54
|
+
const child = c.walk_nodes[i]!;
|
|
55
|
+
if (!nscvWalkHoisted(child)) bottom = nscvRenderExtreme(bottom, nscvSurfaceBottom(nscvSurfaceNormalize(child.walk_frame)), c.walk_numeric, true);
|
|
56
|
+
i++;
|
|
57
|
+
if (nscvWalkHoisted(child) || child.walk_kind === 14) while (i < c.walk_nodes.length && nscvWalkDeeper(c.walk_nodes[i]!, child)) i++;
|
|
58
|
+
}
|
|
59
|
+
return bottom === -Infinity || bottom <= Math.fround(nscvSurfaceBottom(nscvSurfaceNormalize(n.walk_frame)) + 0.5);
|
|
60
|
+
}
|
|
61
|
+
function nscvWalkVisible(c: NscWalkContext, slot: number): boolean {
|
|
62
|
+
let current = slot;
|
|
63
|
+
while (current >= 0 && current < c.walk_nodes.length) {
|
|
64
|
+
const n = c.walk_nodes[current]!;
|
|
65
|
+
if ((n.walk_flags & 4) !== 0 || (current !== slot && n.walk_kind === 14 && !nscvWalkSettled(c, current))) return false;
|
|
66
|
+
current = nscvWalkParent(c, n);
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
function nscvWalkMotion(c: NscWalkContext, n: NscWalkNode, preview: boolean): NscWalkMotion | null {
|
|
71
|
+
if (preview || (c.walk_flags & 64) !== 0 || !nscvWalkNonzero(n)) return null;
|
|
72
|
+
for (const m of c.walk_motions) if (m.presentation_id === n.walk_id && m.presentation_id_high === n.walk_id_high) return m;
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function nscvWalkWithin(c: NscWalkContext, slot: number, target: number): boolean {
|
|
76
|
+
let current = slot;
|
|
77
|
+
while (current >= 0 && current < c.walk_nodes.length) {
|
|
78
|
+
if (current === target) return true;
|
|
79
|
+
current = nscvWalkParent(c, c.walk_nodes[current]!);
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function nscvWalkGroupFocus(c: NscWalkContext, slot: number, preview: boolean, focused: boolean): boolean {
|
|
84
|
+
if (focused) return true;
|
|
85
|
+
if (!preview && (c.walk_flags & 6) !== 0) {
|
|
86
|
+
if ((c.walk_flags & 4) === 0 || (c.walk_ids[2] === 0 && c.walk_ids[3] === 0)) return false;
|
|
87
|
+
for (let i = 0; i < c.walk_nodes.length; i++) if (nscvWalkId(c.walk_nodes[i]!, c.walk_ids, 2)) return nscvWalkWithin(c, i, slot);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
for (let i = 0; i < c.walk_nodes.length; i++) if (i !== slot && (c.walk_nodes[i]!.walk_flags & 16) !== 0 && nscvWalkWithin(c, i, slot)) return true;
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
function nscvWalkDisclosure(c: NscWalkContext, slot: number, preview: boolean): number {
|
|
94
|
+
const n = c.walk_nodes[slot]!;
|
|
95
|
+
if (n.walk_kind !== 14 || nscvWalkSelected(n)) return nscvWalkSettled(c, slot) || n.walk_kind !== 14 ? 2 : 1;
|
|
96
|
+
const remapped = preview || (c.walk_flags & 64) !== 0, low = remapped ? n.walk_preview_id : n.walk_id, high = remapped ? n.walk_preview_id_high : n.walk_id_high;
|
|
97
|
+
if (low === 0 && high === 0) return 0;
|
|
98
|
+
for (let i = 0; i < c.walk_reveals.length; i += 2) if (low === c.walk_reveals[i] && high === c.walk_reveals[i + 1]) return 1;
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
// The target supplies the invalid-operation NaN word. JavaScript does not
|
|
102
|
+
// specify its sign; transferred NaN operands retain their own payload/sign.
|
|
103
|
+
function nscvWalkMultiply(c: NscWalkContext, a: number, b: number): number {
|
|
104
|
+
if (Number.isNaN(a)) return a;
|
|
105
|
+
if (Number.isNaN(b)) return b;
|
|
106
|
+
if ((a === 0 && !Number.isFinite(b)) || (b === 0 && !Number.isFinite(a))) return c.walk_nan;
|
|
107
|
+
return Math.fround(a * b);
|
|
108
|
+
}
|
|
109
|
+
function nscvWalkSubtract(c: NscWalkContext, a: number, b: number): number {
|
|
110
|
+
if (Number.isNaN(a)) return a;
|
|
111
|
+
if (Number.isNaN(b)) return b;
|
|
112
|
+
return !Number.isFinite(a) && a === b ? c.walk_nan : Math.fround(a - b);
|
|
113
|
+
}
|
|
114
|
+
function nscvWalkDivide(c: NscWalkContext, a: number, b: number): number {
|
|
115
|
+
if (Number.isNaN(a)) return a;
|
|
116
|
+
if (Number.isNaN(b)) return b;
|
|
117
|
+
return (a === 0 && b === 0) || (!Number.isFinite(a) && !Number.isFinite(b)) ? c.walk_nan : Math.fround(a / b);
|
|
118
|
+
}
|
|
119
|
+
function nscvWalkNegativeMultiply(c: NscWalkContext, a: number, b: number): number {
|
|
120
|
+
return (c.walk_scalar & 2) !== 0 ? -nscvWalkMultiply(c, a, b) : nscvWalkMultiply(c, -a, b);
|
|
121
|
+
}
|
|
122
|
+
function nscvWalkInverse(c: NscWalkContext, t: NscRenderAffine): NscRenderAffine | null {
|
|
123
|
+
const det = nscvWalkSubtract(c, nscvWalkMultiply(c, t.a, t.d), nscvWalkMultiply(c, t.b, t.c));
|
|
124
|
+
if (Math.abs(det) <= Math.fround(0.000001)) return null;
|
|
125
|
+
const inv = nscvWalkDivide(c, 1, det);
|
|
126
|
+
return { a: nscvWalkMultiply(c, t.d, inv), b: nscvWalkNegativeMultiply(c, t.b, inv), c: nscvWalkNegativeMultiply(c, t.c, inv), d: nscvWalkMultiply(c, t.a, inv), tx: nscvWalkMultiply(c, nscvWalkSubtract(c, nscvWalkMultiply(c, t.c, t.ty), nscvWalkMultiply(c, t.d, t.tx)), inv), ty: nscvWalkMultiply(c, nscvWalkSubtract(c, nscvWalkMultiply(c, t.b, t.tx), nscvWalkMultiply(c, t.a, t.ty)), inv) };
|
|
127
|
+
}
|
|
128
|
+
function nscvWalkPutLane(out: DataView, at: number, c: NscWalkContext, slot: number, preview: boolean): void {
|
|
129
|
+
const n = c.walk_nodes[slot]!, nonzero = nscvWalkNonzero(n), runtimeFocus = !preview && (c.walk_flags & 6) !== 0;
|
|
130
|
+
const focusMask = n.walk_kind === 41 ? 2 : 4, focusAt = n.walk_kind === 41 ? 0 : 2;
|
|
131
|
+
const focused = runtimeFocus ? nonzero && (c.walk_flags & focusMask) !== 0 && nscvWalkId(n, c.walk_ids, focusAt) : (n.walk_flags & 16) !== 0;
|
|
132
|
+
const hovered = !preview && (c.walk_flags & 8) !== 0 ? nonzero && nscvWalkId(n, c.walk_ids, 4) : (n.walk_flags & 32) !== 0;
|
|
133
|
+
const pressed = !preview && (c.walk_flags & 16) !== 0 ? nonzero && nscvWalkId(n, c.walk_ids, 6) : (n.walk_flags & 64) !== 0;
|
|
134
|
+
const logicalId = (c.walk_flags & 64) !== 0 ? n.walk_preview_id === c.walk_ids[0] && n.walk_preview_id_high === c.walk_ids[1] : nscvWalkId(n, c.walk_ids, 0);
|
|
135
|
+
const logical = (preview || (c.walk_flags & 1) !== 0) && (runtimeFocus ? nonzero && (c.walk_flags & 2) !== 0 && logicalId : (n.walk_flags & 16) !== 0);
|
|
136
|
+
const skip = (n.walk_flags & 4) !== 0 || (!preview && (c.walk_flags & 64) === 0 && (c.walk_flags & 32) !== 0 && nscvWalkId(n, c.walk_ids, 8) && n.walk_kind !== 16 && n.walk_kind !== 58);
|
|
137
|
+
const signaling = (n.walk_opacity_word & 0x7f800000) === 0x7f800000 && (n.walk_opacity_word & 0x7fffff) !== 0 && (n.walk_opacity_word & 0x400000) === 0;
|
|
138
|
+
const opacity = signaling && (c.walk_scalar & 1) !== 0 ? 0 : nscvRenderExtreme(0, nscvRenderExtreme(n.walk_opacity, 1, c.walk_numeric, false), c.walk_numeric, true), m = nscvWalkMotion(c, n, preview), t = n.walk_transform;
|
|
139
|
+
const wrapTransform = t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || t.tx !== 0 || t.ty !== 0;
|
|
140
|
+
const inverse = wrapTransform ? nscvWalkInverse(c, t) : nscvPresentationIdentity();
|
|
141
|
+
const flags = (focused ? 1 : 0) | (hovered ? 2 : 0) | (pressed ? 4 : 0) | (logical ? 8 : 0) | ((n.walk_kind === 60 ? nscvWalkGroupFocus(c, slot, preview, focused) : focused) ? 16 : 0) | (skip ? 32 : 0) | (opacity < 1 ? 64 : 0) | (m !== null && (m.presentation_dx !== 0 || m.presentation_dy !== 0) ? 128 : 0) | (wrapTransform ? 256 : 0) | (nscvWalkHoisted(n) || (m !== null && m.presentation_escape) ? 512 : 0) | (nscvWalkDisclosure(c, slot, preview) << 10);
|
|
142
|
+
out.setUint32(at, flags, true); if (Number.isNaN(opacity)) out.setUint32(at + 4, n.walk_opacity_word, true); else out.setFloat32(at + 4, opacity, true); out.setUint32(at + 8, m === null ? 0 : m.walk_dx_word, true); out.setUint32(at + 12, m === null ? 0 : m.walk_dy_word, true);
|
|
143
|
+
nscvPresentationPutTransform(out, at + 16, inverse);
|
|
144
|
+
}
|
|
145
|
+
function nscvWidgetPaintWalk(request: Uint8Array): Uint8Array {
|
|
146
|
+
if (request.length < 80 || request[1] !== 1 || request[2]! > 15 || request[3]! > 3) throw new Error("invalid paint walk header");
|
|
147
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(4, true), motionCount = w.getUint32(8, true), revealCount = w.getUint32(12, true), flags = w.getUint32(16, true);
|
|
148
|
+
if (flags > 255 || !Number.isNaN(w.getFloat32(76, true)) || request.length !== 80 + count * 96 + motionCount * 24 + revealCount * 8) throw new Error("invalid paint walk shape");
|
|
149
|
+
const nodes: NscWalkNode[] = [], motions: NscWalkMotion[] = [], reveals: number[] = [], ids: number[] = [], layers: number[] = [];
|
|
150
|
+
for (let i = 0; i < 4; i++) layers.push(w.getInt32(20 + i * 4, true));
|
|
151
|
+
for (let i = 0; i < 10; i++) ids.push(w.getUint32(36 + i * 4, true));
|
|
152
|
+
for (let i = 0; i < count; i++) {
|
|
153
|
+
const at = 80 + i * 96, kind = w.getUint32(at, true), nodeFlags = w.getUint32(at + 4, true);
|
|
154
|
+
if (kind > 62 || nodeFlags > 255) throw new Error("invalid paint walk node");
|
|
155
|
+
nodes.push({ walk_kind: kind, walk_flags: nodeFlags, walk_parent: w.getUint32(at + 8, true), walk_parent_high: w.getUint32(at + 12, true), walk_id: w.getUint32(at + 16, true), walk_id_high: w.getUint32(at + 20, true), walk_preview_id: w.getUint32(at + 24, true), walk_preview_id_high: w.getUint32(at + 28, true), walk_depth: w.getUint32(at + 32, true), walk_depth_high: w.getUint32(at + 36, true), walk_layer: w.getInt32(at + 40, true), walk_frame: nscvRenderRect(w, at + 44), walk_transform: nscvRenderAffine(w, at + 60), walk_opacity: w.getFloat32(at + 84, true), walk_opacity_word: w.getUint32(at + 84, true), walk_value: w.getFloat32(at + 88, true), walk_gap: w.getFloat32(at + 92, true) });
|
|
156
|
+
}
|
|
157
|
+
for (let i = 0; i < motionCount; i++) {
|
|
158
|
+
const at = 80 + count * 96 + i * 24;
|
|
159
|
+
if (w.getUint32(at + 16, true) > 1 || w.getUint32(at + 20, true) !== 0) throw new Error("invalid paint walk motion");
|
|
160
|
+
motions.push({ presentation_id: w.getUint32(at, true), presentation_id_high: w.getUint32(at + 4, true), presentation_dx: w.getFloat32(at + 8, true), presentation_dy: w.getFloat32(at + 12, true), presentation_escape: w.getUint32(at + 16, true) === 1, walk_dx_word: w.getUint32(at + 8, true), walk_dy_word: w.getUint32(at + 12, true) });
|
|
161
|
+
}
|
|
162
|
+
for (let i = 0; i < revealCount * 2; i++) reveals.push(w.getUint32(80 + count * 96 + motionCount * 24 + i * 4, true));
|
|
163
|
+
const c: NscWalkContext = { walk_nodes: nodes, walk_motions: motions, walk_reveals: reveals, walk_ids: ids, walk_flags: flags, walk_scalar: request[3]!, walk_numeric: request[2]!, walk_nan: w.getFloat32(76, true), walk_layers: layers };
|
|
164
|
+
// Retained parent links may point forward or be present but out of range.
|
|
165
|
+
// Cycles cannot be traversed by the native renderer; reject them explicitly.
|
|
166
|
+
for (let i = 0; i < count; i++) { let p = i, steps = 0; while (p >= 0 && p < count) { if (steps++ >= count) throw new Error("invalid paint walk cycle"); p = nscvWalkParent(c, nodes[p]!); } }
|
|
167
|
+
const orders: NscWalkOrder[] = [], surfaces: NscWalkOrder[] = [], escaping: number[] = [];
|
|
168
|
+
let preview = -1;
|
|
169
|
+
for (let i = 0; i < count; i++) {
|
|
170
|
+
const n = nodes[i]!, visible = nscvWalkVisible(c, i), m = nscvWalkMotion(c, n, false);
|
|
171
|
+
orders.push({ walk_slot: i, walk_layer: nscvWalkLayer(c, n, false) });
|
|
172
|
+
if (nscvWalkHoisted(n) && visible) surfaces.push({ walk_slot: i, walk_layer: nscvWalkSurfaceLayer(c, i) });
|
|
173
|
+
if (!nscvWalkHoisted(n) && m !== null && m.presentation_escape && visible) escaping.push(i);
|
|
174
|
+
if (preview === -1 && (flags & 32) !== 0 && nscvWalkNonzero(n) && nscvWalkId(n, ids, 8)) preview = i;
|
|
175
|
+
}
|
|
176
|
+
if (preview !== -1 && (nodes[preview]!.walk_kind === 16 || nodes[preview]!.walk_kind === 58 || !nscvWalkVisible(c, preview))) preview = -1;
|
|
177
|
+
const ordered = orders.toSorted(nscvWalkCompare), sortedSurfaces = surfaces.toSorted(nscvWalkCompare), result = new Uint8Array(24 + count * 120), out = new DataView(result.buffer);
|
|
178
|
+
result[0] = 1; out.setUint32(4, count, true);
|
|
179
|
+
for (let at = 8; at < result.length; at += 4) out.setUint32(at, 0xffffffff, true);
|
|
180
|
+
out.setUint32(12, sortedSurfaces.length === 0 ? 0xffffffff : sortedSurfaces[0]!.walk_slot, true); out.setUint32(16, escaping.length === 0 ? 0xffffffff : escaping[0]!, true); out.setUint32(20, preview === -1 ? 0xffffffff : preview, true);
|
|
181
|
+
for (const o of ordered) if ((nodes[o.walk_slot]!.walk_flags & 1) === 0) { out.setUint32(8, o.walk_slot, true); break; }
|
|
182
|
+
for (let i = 0; i < count; i++) {
|
|
183
|
+
const at = 24 + i * 120, n = nodes[i]!;
|
|
184
|
+
out.setInt32(at, nscvWalkLayer(c, n, false), true); out.setInt32(at + 4, nscvWalkSurfaceLayer(c, i), true);
|
|
185
|
+
let next = -1, first = -1, childCount = 0;
|
|
186
|
+
for (const o of ordered) {
|
|
187
|
+
const child = nodes[o.walk_slot]!;
|
|
188
|
+
if (nscvWalkSameParent(n, child) && nscvWalkCompare(orders[i]!, o) < 0 && next === -1) next = o.walk_slot;
|
|
189
|
+
if ((child.walk_flags & 1) !== 0 && child.walk_parent_high === 0 && child.walk_parent === i) { if (first === -1) first = o.walk_slot; childCount++; }
|
|
190
|
+
}
|
|
191
|
+
out.setUint32(at + 8, next === -1 ? 0xffffffff : next, true); out.setUint32(at + 12, first === -1 ? 0xffffffff : first, true); out.setUint32(at + 24, childCount, true);
|
|
192
|
+
let segment = 0, total = 0, ordinal = 0;
|
|
193
|
+
const parent = nscvWalkParent(c, n);
|
|
194
|
+
if (parent >= 0 && parent < count && nodes[parent]!.walk_kind === 9 && ((flags & 128) !== 0 || nodes[parent]!.walk_gap <= 0)) {
|
|
195
|
+
for (let j = 0; j < count; j++) if (nscvWalkSameParent(n, nodes[j]!) && (nodes[j]!.walk_flags & 4) === 0) { if (j === i) ordinal = total; total++; }
|
|
196
|
+
if (total > 1) segment = ordinal === 0 ? 1 : ordinal === total - 1 ? 3 : 2;
|
|
197
|
+
}
|
|
198
|
+
out.setUint32(at + 28, segment, true); nscvWalkPutLane(out, at + 32, c, i, false); nscvWalkPutLane(out, at + 76, c, i, true);
|
|
199
|
+
}
|
|
200
|
+
for (let i = 0; i < sortedSurfaces.length; i++) out.setUint32(24 + sortedSurfaces[i]!.walk_slot * 120 + 16, i + 1 < sortedSurfaces.length ? sortedSurfaces[i + 1]!.walk_slot : 0xffffffff, true);
|
|
201
|
+
for (let i = 0; i < escaping.length; i++) out.setUint32(24 + escaping[i]! * 120 + 20, i + 1 < escaping.length ? escaping[i + 1]! : 0xffffffff, true);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/** Retained presentation geometry over copied layout and motion facts. */
|
|
2
|
+
interface NscPresentationNode {
|
|
3
|
+
readonly presentation_kind: number; readonly presentation_flags: number;
|
|
4
|
+
readonly presentation_parent: number; readonly presentation_parent_high: number;
|
|
5
|
+
readonly presentation_id: number; readonly presentation_id_high: number;
|
|
6
|
+
readonly presentation_frame: NscSurfaceRect; readonly presentation_transform: NscRenderAffine;
|
|
7
|
+
}
|
|
8
|
+
interface NscPresentationMotion {
|
|
9
|
+
readonly presentation_id: number; readonly presentation_id_high: number;
|
|
10
|
+
readonly presentation_dx: number; readonly presentation_dy: number; readonly presentation_escape: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface NscPresentationContext {
|
|
13
|
+
readonly presentation_nodes: readonly NscPresentationNode[]; readonly presentation_motions: readonly NscPresentationMotion[];
|
|
14
|
+
readonly presentation_numeric: number; readonly presentation_flags: number; readonly presentation_root: NscSurfaceRect | null;
|
|
15
|
+
readonly presentation_drag: number; readonly presentation_drag_high: number;
|
|
16
|
+
readonly presentation_origin_x: number; readonly presentation_origin_y: number;
|
|
17
|
+
readonly presentation_offset_x: number; readonly presentation_offset_y: number; readonly presentation_scale: number;
|
|
18
|
+
}
|
|
19
|
+
function nscvPresentationIdentity(): NscRenderAffine { return { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; }
|
|
20
|
+
function nscvPresentationHoisted(n: NscPresentationNode): boolean { return (n.presentation_flags & 2) !== 0 || n.presentation_kind === 19 || n.presentation_kind === 20 || n.presentation_kind === 21; }
|
|
21
|
+
function nscvPresentationParent(c: NscPresentationContext, n: NscPresentationNode): number {
|
|
22
|
+
return (n.presentation_flags & 1) === 0 ? -1 : n.presentation_parent_high !== 0 || n.presentation_parent >= c.presentation_nodes.length ? c.presentation_nodes.length : n.presentation_parent;
|
|
23
|
+
}
|
|
24
|
+
function nscvPresentationMotion(c: NscPresentationContext, n: NscPresentationNode, preview: boolean): NscPresentationMotion | null {
|
|
25
|
+
if (preview || (n.presentation_id === 0 && n.presentation_id_high === 0)) return null;
|
|
26
|
+
for (const m of c.presentation_motions) if (m.presentation_id === n.presentation_id && m.presentation_id_high === n.presentation_id_high) return m;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function nscvPresentationTransform(c: NscPresentationContext, slot: number, motion: boolean, preview: boolean, outer: NscRenderAffine): NscRenderAffine | null {
|
|
30
|
+
const indices: number[] = [];
|
|
31
|
+
let current = slot;
|
|
32
|
+
while (current !== -1) {
|
|
33
|
+
if (current >= c.presentation_nodes.length || indices.length >= 32) return null;
|
|
34
|
+
indices.push(current);
|
|
35
|
+
const n = c.presentation_nodes[current]!;
|
|
36
|
+
if (nscvPresentationHoisted(n)) break;
|
|
37
|
+
current = nscvPresentationParent(c, n);
|
|
38
|
+
}
|
|
39
|
+
let t = outer;
|
|
40
|
+
for (let i = indices.length - 1; i >= 0; i--) {
|
|
41
|
+
const n = c.presentation_nodes[indices[i]!]!, m = motion ? nscvPresentationMotion(c, n, preview) : null;
|
|
42
|
+
if (m !== null && (m.presentation_dx !== 0 || m.presentation_dy !== 0)) t = nscvRenderMultiply(t, { ...nscvPresentationIdentity(), tx: m.presentation_dx, ty: m.presentation_dy });
|
|
43
|
+
t = nscvRenderMultiply(t, n.presentation_transform);
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
function nscvPresentationAncestor(c: NscPresentationContext, slot: number): NscRenderAffine | null {
|
|
48
|
+
if (slot >= c.presentation_nodes.length) return null;
|
|
49
|
+
const n = c.presentation_nodes[slot]!;
|
|
50
|
+
if (nscvPresentationHoisted(n)) return nscvPresentationIdentity();
|
|
51
|
+
const p = nscvPresentationParent(c, n);
|
|
52
|
+
return p === -1 ? nscvPresentationIdentity() : nscvPresentationTransform(c, p, false, false, nscvPresentationIdentity());
|
|
53
|
+
}
|
|
54
|
+
function nscvPresentationDrag(c: NscPresentationContext): NscRenderAffine | null {
|
|
55
|
+
if ((c.presentation_flags & 2) === 0 || (c.presentation_drag === 0 && c.presentation_drag_high === 0)) return null;
|
|
56
|
+
for (let i = 0; i < c.presentation_nodes.length; i++) {
|
|
57
|
+
const n = c.presentation_nodes[i]!;
|
|
58
|
+
if (n.presentation_id !== c.presentation_drag || n.presentation_id_high !== c.presentation_drag_high) continue;
|
|
59
|
+
const t = nscvPresentationAncestor(c, i); if (t === null) return null;
|
|
60
|
+
const r = nscvSurfaceNormalize(n.presentation_frame), f = Math.fround;
|
|
61
|
+
const x = (c.presentation_flags & 4) !== 0 ? c.presentation_origin_x : r.x, y = (c.presentation_flags & 4) !== 0 ? c.presentation_origin_y : r.y;
|
|
62
|
+
const currentX = f(f(f(t.a * r.x) + f(t.c * r.y)) + t.tx), currentY = f(f(f(t.b * r.x) + f(t.d * r.y)) + t.ty);
|
|
63
|
+
const sourceX = f(f(f(t.a * x) + f(t.c * y)) + t.tx), sourceY = f(f(f(t.b * x) + f(t.d * y)) + t.ty);
|
|
64
|
+
return { ...nscvPresentationIdentity(), tx: f(f(sourceX + c.presentation_offset_x) - currentX), ty: f(f(sourceY + c.presentation_offset_y) - currentY) };
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function nscvPresentationInverse(t: NscRenderAffine): NscRenderAffine | null {
|
|
69
|
+
const f = Math.fround, determinant = f(f(t.a * t.d) - f(t.b * t.c));
|
|
70
|
+
if (Math.abs(determinant) <= Math.fround(0.000001)) return null;
|
|
71
|
+
const inv = f(1 / determinant);
|
|
72
|
+
return { a: f(t.d * inv), b: f(-t.b * inv), c: f(-t.c * inv), d: f(t.a * inv), tx: f(f(f(t.c * t.ty) - f(t.d * t.tx)) * inv), ty: f(f(f(t.b * t.tx) - f(t.a * t.ty)) * inv) };
|
|
73
|
+
}
|
|
74
|
+
function nscvPresentationSnap(c: NscPresentationContext, raw: NscSurfaceRect): NscSurfaceRect {
|
|
75
|
+
const scale = c.presentation_scale;
|
|
76
|
+
if ((c.presentation_flags & 8) === 0 || !Number.isFinite(scale) || scale <= 0) return raw;
|
|
77
|
+
const f = Math.fround, r = nscvSurfaceNormalize(raw);
|
|
78
|
+
const snap = (v: number): number => { const x = f(v * scale); return f((x < 0 || 1 / x < 0 ? -Math.floor(-x + 0.5) : Math.floor(x + 0.5)) / scale); };
|
|
79
|
+
const x = snap(r.x), y = snap(r.y);
|
|
80
|
+
return { x, y, width: nscvRenderExtreme(0, f(snap(nscvSurfaceRight(r)) - x), c.presentation_numeric, true), height: nscvRenderExtreme(0, f(snap(nscvSurfaceBottom(r)) - y), c.presentation_numeric, true) };
|
|
81
|
+
}
|
|
82
|
+
function nscvPresentationVisible(c: NscPresentationContext, slot: number, preview: boolean, outer: NscRenderAffine | null): NscSurfaceRect | null {
|
|
83
|
+
if (c.presentation_root === null || outer === null) return null;
|
|
84
|
+
let visible = nscvSurfaceNormalize(c.presentation_root), current = slot;
|
|
85
|
+
for (let guard = 0; guard <= c.presentation_nodes.length; guard++) {
|
|
86
|
+
const n = c.presentation_nodes[current]!;
|
|
87
|
+
const dragRoot = preview && (c.presentation_flags & 2) !== 0 && c.presentation_drag === n.presentation_id && c.presentation_drag_high === n.presentation_id_high;
|
|
88
|
+
const m = nscvPresentationMotion(c, n, preview);
|
|
89
|
+
if (nscvPresentationHoisted(n) || dragRoot || (m !== null && m.presentation_escape)) break;
|
|
90
|
+
const parent = nscvPresentationParent(c, n);
|
|
91
|
+
if (parent === -1) break;
|
|
92
|
+
if (parent >= c.presentation_nodes.length || guard === c.presentation_nodes.length) return null;
|
|
93
|
+
const p = c.presentation_nodes[parent]!;
|
|
94
|
+
if (p.presentation_kind === 6 || (p.presentation_flags & 4) !== 0) {
|
|
95
|
+
const transform = nscvPresentationTransform(c, parent, true, preview, outer); if (transform === null) return null;
|
|
96
|
+
visible = nscvRenderIntersection(visible, nscvRenderTransform(transform, nscvSurfaceNormalize(p.presentation_frame), c.presentation_numeric), c.presentation_numeric);
|
|
97
|
+
if (nscvRenderEmpty(visible)) return null;
|
|
98
|
+
}
|
|
99
|
+
current = parent;
|
|
100
|
+
}
|
|
101
|
+
const transform = nscvPresentationTransform(c, slot, true, preview, outer); if (transform === null) return null;
|
|
102
|
+
const inverse = nscvPresentationInverse(transform); if (inverse === null) return null;
|
|
103
|
+
const local = nscvRenderTransform(inverse, visible, c.presentation_numeric);
|
|
104
|
+
const clipped = nscvRenderIntersection(nscvSurfaceNormalize(nscvPresentationSnap(c, c.presentation_nodes[slot]!.presentation_frame)), nscvSurfaceNormalize(local), c.presentation_numeric);
|
|
105
|
+
return nscvRenderEmpty(clipped) ? null : clipped;
|
|
106
|
+
}
|
|
107
|
+
function nscvPresentationPutTransform(w: DataView, at: number, t: NscRenderAffine | null): void {
|
|
108
|
+
w.setUint32(at, t === null ? 0 : 1, true);
|
|
109
|
+
nscvRenderPutAffine(w, at + 4, t ?? { a: 0, b: 0, c: 0, d: 0, tx: 0, ty: 0 });
|
|
110
|
+
}
|
|
111
|
+
function nscvWidgetPresentation(request: Uint8Array): Uint8Array {
|
|
112
|
+
if (request.length < 64 || request[1]! > 1 || request[2] !== 1 || request[3]! > 15) throw new Error("invalid presentation header");
|
|
113
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), count = w.getUint32(4, true), motionCount = w.getUint32(8, true), flags = w.getUint32(12, true);
|
|
114
|
+
if (flags > 31 || request.length !== 64 + count * 64 + motionCount * 24 || w.getUint32(60, true) !== 0 || (request[1] === 0 && motionCount !== 0)) throw new Error("invalid presentation shape");
|
|
115
|
+
const nodes: NscPresentationNode[] = [], motions: NscPresentationMotion[] = [];
|
|
116
|
+
for (let i = 0; i < count; i++) {
|
|
117
|
+
const at = 64 + i * 64, kind = w.getUint32(at, true), nodeFlags = w.getUint32(at + 4, true);
|
|
118
|
+
if (kind > 62 || nodeFlags > 15) throw new Error("invalid presentation node");
|
|
119
|
+
nodes.push({ presentation_kind: kind, presentation_flags: nodeFlags, presentation_parent: w.getUint32(at + 8, true), presentation_parent_high: w.getUint32(at + 12, true), presentation_id: w.getUint32(at + 16, true), presentation_id_high: w.getUint32(at + 20, true), presentation_frame: nscvRenderRect(w, at + 24), presentation_transform: nscvRenderAffine(w, at + 40) });
|
|
120
|
+
}
|
|
121
|
+
for (let i = 0; i < motionCount; i++) {
|
|
122
|
+
const at = 64 + count * 64 + i * 24;
|
|
123
|
+
if (w.getUint32(at + 16, true) > 1 || w.getUint32(at + 20, true) !== 0) throw new Error("invalid presentation motion");
|
|
124
|
+
motions.push({ presentation_id: w.getUint32(at, true), presentation_id_high: w.getUint32(at + 4, true), presentation_dx: w.getFloat32(at + 8, true), presentation_dy: w.getFloat32(at + 12, true), presentation_escape: w.getUint32(at + 16, true) === 1 });
|
|
125
|
+
}
|
|
126
|
+
let root: NscSurfaceRect | null = (flags & 1) !== 0 ? nscvSurfaceNormalize(nscvRenderRect(w, 16)) : null;
|
|
127
|
+
if ((flags & 1) === 0) for (const n of nodes) if ((n.presentation_flags & 1) === 0) { const r = nscvSurfaceNormalize(n.presentation_frame); root = root === null ? r : nscvRenderUnion(root, r, request[3]!); }
|
|
128
|
+
const c: NscPresentationContext = { presentation_nodes: nodes, presentation_motions: motions, presentation_numeric: request[3]!, presentation_flags: flags, presentation_root: root, presentation_drag: w.getUint32(32, true), presentation_drag_high: w.getUint32(36, true), presentation_origin_x: w.getFloat32(40, true), presentation_origin_y: w.getFloat32(44, true), presentation_offset_x: w.getFloat32(48, true), presentation_offset_y: w.getFloat32(52, true), presentation_scale: w.getFloat32(56, true) };
|
|
129
|
+
const resultCount = request[1] === 0 ? 0 : count, result = new Uint8Array(56 + resultCount * 152), out = new DataView(result.buffer), drag = request[1] === 0 ? null : nscvPresentationDrag(c), preview = (flags & 16) !== 0;
|
|
130
|
+
result.set([1, request[1]!, 0, 0]); out.setUint32(4, resultCount, true); nscvRenderPutOptional(out, 8, root); nscvPresentationPutTransform(out, 28, drag);
|
|
131
|
+
for (let i = 0; i < resultCount; i++) {
|
|
132
|
+
const at = 56 + i * 152, ordinary = nscvPresentationTransform(c, i, false, false, nscvPresentationIdentity()), outer = preview ? drag : nscvPresentationIdentity();
|
|
133
|
+
nscvPresentationPutTransform(out, at, ordinary); nscvPresentationPutTransform(out, at + 28, nscvPresentationAncestor(c, i));
|
|
134
|
+
nscvPresentationPutTransform(out, at + 56, !preview && motionCount === 0 ? ordinary : outer === null ? null : nscvPresentationTransform(c, i, true, preview, outer));
|
|
135
|
+
nscvPresentationPutTransform(out, at + 84, drag === null ? null : nscvPresentationTransform(c, i, true, true, drag));
|
|
136
|
+
const text = (nodes[i]!.presentation_flags & 8) !== 0;
|
|
137
|
+
nscvRenderPutOptional(out, at + 112, text ? nscvPresentationVisible(c, i, preview, outer) : null);
|
|
138
|
+
nscvRenderPutOptional(out, at + 132, text ? nscvPresentationVisible(c, i, true, drag) : null);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** One rebuild plan for controls and text. Native supplies exact storage
|
|
2
|
+
* lookups, byte/fingerprint equality and caret geometry; no retained pointer,
|
|
3
|
+
* text buffer, composition or code-cache identity crosses this wire.
|
|
4
|
+
* Header: tag 93, three zero bytes, count u32LE. Each 64-byte fact contains
|
|
5
|
+
* kind, admission flags, comparison flags, zero, four f32 values, selection
|
|
6
|
+
* flags and three zeros, four opaque u64 caret offsets, and eight zeros.
|
|
7
|
+
* Each output is action bits u32LE and a control value f32LE.
|
|
8
|
+
*/
|
|
9
|
+
function nscvWidgetReconcile(request: Uint8Array): Uint8Array {
|
|
10
|
+
if (request.length < 8 || request[0] !== 93 || request[1] !== 0 || request[2] !== 0 || request[3] !== 0)
|
|
11
|
+
throw new Error("invalid widget reconcile header");
|
|
12
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
13
|
+
const count = wire.getUint32(4, true);
|
|
14
|
+
if (count > 1024 || request.length !== 8 + count * 64) throw new Error("invalid widget reconcile table");
|
|
15
|
+
const output = new Uint8Array(8 + count * 8), out = new DataView(output.buffer);
|
|
16
|
+
output[0] = 93; out.setUint32(4, count, true);
|
|
17
|
+
for (let i = 0; i < count; i++) {
|
|
18
|
+
const at = 8 + i * 64, kind = request[at]!, admission = request[at + 1]!, facts = request[at + 2]!;
|
|
19
|
+
if (kind > 62 || facts > 127 || request[at + 3] !== 0 || request[at + 20]! > 127 ||
|
|
20
|
+
request[at + 21] !== 0 || request[at + 22] !== 0 || request[at + 23] !== 0 ||
|
|
21
|
+
wire.getUint32(at + 56, true) !== 0 || wire.getUint32(at + 60, true) !== 0)
|
|
22
|
+
throw new Error("invalid widget reconcile fact");
|
|
23
|
+
const editable = kind >= 35 && kind <= 39;
|
|
24
|
+
let actions = editable ? 1024 : 0, value = 0;
|
|
25
|
+
const eligible = (admission & 7) === 1;
|
|
26
|
+
if (eligible && (admission & 8) !== 0) {
|
|
27
|
+
const source = (facts & 1) !== 0, previous = (facts & 2) !== 0, retained = (facts & 4) !== 0;
|
|
28
|
+
const exclusive = kind === 14 || kind === 41 || kind === 42 || kind === 44 || kind === 46 || kind === 48;
|
|
29
|
+
if (kind === 32 || kind === 47 || kind === 49 || kind === 50 || exclusive) {
|
|
30
|
+
const selected = kind === 32 ? source || previous ? source : retained :
|
|
31
|
+
exclusive && (admission & 16) !== 0 && source !== previous ? source : retained;
|
|
32
|
+
actions |= 1 | (selected ? 2 : 0);
|
|
33
|
+
} else if (kind === 51) {
|
|
34
|
+
const current = wire.getFloat32(at + 4, true), prior = wire.getFloat32(at + 8, true);
|
|
35
|
+
const runtime = wire.getFloat32(at + 12, true);
|
|
36
|
+
const candidate = (admission & 16) === 0 || current === prior || (facts & 8) !== 0 ? runtime : current;
|
|
37
|
+
// Native clamp evaluates max(0, min(candidate, 1)); NaN selects the upper bound.
|
|
38
|
+
value = Number.isNaN(candidate) ? 1 : Math.max(0, Math.min(candidate, 1)); actions |= 4;
|
|
39
|
+
} else if (kind === 16) {
|
|
40
|
+
const minimum = wire.getFloat32(at + 16, true), retainedWidth = wire.getFloat32(at + 12, true);
|
|
41
|
+
value = Number.isNaN(retainedWidth) ? minimum : Math.max(minimum, retainedWidth); actions |= 8;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (eligible && (admission & 32) !== 0) {
|
|
45
|
+
const selection = request[at + 20]!;
|
|
46
|
+
if (kind === 26) {
|
|
47
|
+
if ((selection & 1) === 0 && (facts & 48) === 48) actions |= 64;
|
|
48
|
+
} else if (editable) {
|
|
49
|
+
const packet = new Uint8Array(40);
|
|
50
|
+
packet[0] = 5; packet[1] = (facts & 64) !== 0 ? 1 : 0; packet[2] = (facts & 16) !== 0 ? 1 : 0;
|
|
51
|
+
packet[4] = selection & 7; packet[5] = (selection >>> 3) & 3; packet[6] = (selection >>> 5) & 3;
|
|
52
|
+
packet.set(request.subarray(at + 24, at + 56), 8);
|
|
53
|
+
const result = nscvTextReconcile(packet)[0]!;
|
|
54
|
+
if ((result & 2) !== 0) {
|
|
55
|
+
actions |= 32 | ((result & 1) !== 0 ? 16 : 0) | ((result & 4) !== 0 ? 64 : 0) | ((result & 8) !== 0 ? 128 : 0);
|
|
56
|
+
if ((admission & 64) !== 0) actions |= 256 | ((admission & 128) === 0 ? 512 : 0);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
out.setUint32(8 + i * 8, actions, true); out.setFloat32(12 + i * 8, value, true);
|
|
61
|
+
}
|
|
62
|
+
return output;
|
|
63
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Ordered rebuild collections and edge-triggered autofocus. Native supplies
|
|
2
|
+
* copied widget facts and owns retained storage, text fingerprints and buffers.
|
|
3
|
+
* Identities remain opaque eight-byte keys, including zero and max-u64. */
|
|
4
|
+
function nscvWidgetRetention(request: Uint8Array): Uint8Array {
|
|
5
|
+
if (request.length < 24 || request[0] !== 92 || request[1]! > 6 || request[2] !== 0 || request[3] !== 0)
|
|
6
|
+
throw new Error("invalid widget retention header");
|
|
7
|
+
const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
8
|
+
const operation = request[1]!, count = wire.getUint32(4, true), sources = wire.getUint32(8, true);
|
|
9
|
+
const capacity = wire.getUint32(12, true), states = wire.getUint32(16, true);
|
|
10
|
+
if (count > 1024 || sources > 1024 || capacity > 1024 || states > 1024 || wire.getUint32(20, true) !== 0 ||
|
|
11
|
+
request.length !== 24 + (count + sources) * 16 || (operation !== 5 && operation !== 6 && sources !== 0))
|
|
12
|
+
throw new Error("invalid widget retention table");
|
|
13
|
+
for (let i = 0; i < count + sources; i++) {
|
|
14
|
+
const at = 24 + i * 16;
|
|
15
|
+
if (request[at + 8]! > 62 || request[at + 9]! > 31 || request[at + 10] !== 0 || request[at + 11] !== 0)
|
|
16
|
+
throw new Error("invalid widget retention fact");
|
|
17
|
+
if (i >= count && (request[at + 9] !== 0 || wire.getUint32(at + 12, true) !== 0))
|
|
18
|
+
throw new Error("invalid widget retention source");
|
|
19
|
+
}
|
|
20
|
+
const entries: number[] = [], matches: number[] = [], flags: number[] = [];
|
|
21
|
+
let target = 4294967295;
|
|
22
|
+
// Capacity bounds the copied prefix, but autofocus must scan the whole tree:
|
|
23
|
+
// a newly requested target can occur beyond the tracked flag budget.
|
|
24
|
+
for (let i = 0; i < count; i++) {
|
|
25
|
+
const at = 24 + i * 16, kind = request[at + 8]!, fact = request[at + 9]!;
|
|
26
|
+
const nonzero = wire.getUint32(at, true) !== 0 || wire.getUint32(at + 4, true) !== 0;
|
|
27
|
+
const editable = kind >= 35 && kind <= 39;
|
|
28
|
+
const exclusive = kind === 41 || kind === 42 || kind === 44 || kind === 46 || kind === 48;
|
|
29
|
+
const control = exclusive || kind === 14 || kind === 16 || kind === 32 || kind >= 47 && kind <= 51;
|
|
30
|
+
const admit = nonzero && (operation === 0 ? kind === 6 || kind === 57 :
|
|
31
|
+
operation === 1 ? exclusive || kind === 14 || kind === 32 || kind === 51 :
|
|
32
|
+
operation === 2 ? control : operation === 3 ? kind === 6 && i < states :
|
|
33
|
+
operation === 4 ? editable : operation === 5 ? editable || kind === 26 && (fact & 6) === 6 :
|
|
34
|
+
(fact & 1) !== 0);
|
|
35
|
+
if (!admit) continue;
|
|
36
|
+
if (operation !== 6 && entries.length >= capacity) break;
|
|
37
|
+
let match = 4294967295;
|
|
38
|
+
if (operation === 5 || operation === 6) {
|
|
39
|
+
for (let j = 0; j < sources; j++) {
|
|
40
|
+
const source = 24 + (count + j) * 16;
|
|
41
|
+
if (wire.getUint32(at, true) === wire.getUint32(source, true) &&
|
|
42
|
+
wire.getUint32(at + 4, true) === wire.getUint32(source + 4, true) &&
|
|
43
|
+
(operation === 6 || kind === request[source + 8])) { match = j; break; }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (operation === 6 && target === 4294967295 && match === 4294967295) target = i;
|
|
47
|
+
if (entries.length < capacity) {
|
|
48
|
+
entries.push(i); matches.push(match);
|
|
49
|
+
flags.push(((fact & 16) !== 0 || wire.getFloat32(at + 12, true) >= 0.5 ? 1 : 0) |
|
|
50
|
+
(kind === 16 ? 2 : 0) | ((fact & 8) !== 0 ? 4 : 0));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const output = new Uint8Array(16 + entries.length * 12), out = new DataView(output.buffer);
|
|
54
|
+
output[0] = 92; output[1] = operation;
|
|
55
|
+
out.setUint32(4, entries.length, true); out.setUint32(8, target, true);
|
|
56
|
+
for (let i = 0; i < entries.length; i++) {
|
|
57
|
+
out.setUint32(16 + i * 12, entries[i]!, true);
|
|
58
|
+
out.setUint32(20 + i * 12, matches[i]!, true);
|
|
59
|
+
out.setUint32(24 + i * 12, flags[i]!, true);
|
|
60
|
+
}
|
|
61
|
+
return output;
|
|
62
|
+
}
|