@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,309 @@
|
|
|
1
|
+
/** Complete session payload layouts. Native supplies raw typed storage slots;
|
|
2
|
+
* TypeScript owns tags, field order, optional suffixes, bounds and byte validation.
|
|
3
|
+
* Scalar payloads are copied as bytes to retain all integer and floating bits.
|
|
4
|
+
*/
|
|
5
|
+
type NscJournalField = { path: string; kind: string; domain: string };
|
|
6
|
+
type NscJournalSlot = { path: string; bytes: Uint8Array };
|
|
7
|
+
function nscjFields(rows: readonly (readonly string[])[]): NscJournalField[] {
|
|
8
|
+
return rows.map(row => ({ path: row[0]!, kind: row[1]!, domain: row[2]! }));
|
|
9
|
+
}
|
|
10
|
+
function nscjEventTag(name: string): number {
|
|
11
|
+
switch (name) {
|
|
12
|
+
case "app_start": return 1;
|
|
13
|
+
case "app_activated": return 2;
|
|
14
|
+
case "app_deactivated": return 3;
|
|
15
|
+
case "appearance_changed": return 4;
|
|
16
|
+
case "frame_requested": return 5;
|
|
17
|
+
case "app_shutdown": return 6;
|
|
18
|
+
case "surface_resized": return 7;
|
|
19
|
+
case "window_frame_changed": return 8;
|
|
20
|
+
case "window_focused": return 9;
|
|
21
|
+
case "bridge_message": return 10;
|
|
22
|
+
case "tray_action": return 11;
|
|
23
|
+
case "shortcut": return 12;
|
|
24
|
+
case "native_command": return 13;
|
|
25
|
+
case "menu_command": return 14;
|
|
26
|
+
case "timer": return 15;
|
|
27
|
+
case "wake": return 16;
|
|
28
|
+
case "files_dropped": return 17;
|
|
29
|
+
case "gpu_surface_frame": return 18;
|
|
30
|
+
case "gpu_surface_resized": return 19;
|
|
31
|
+
case "gpu_surface_input": return 20;
|
|
32
|
+
case "gpu_surface_scroll_driver": return 21;
|
|
33
|
+
case "context_menu_action": return 22;
|
|
34
|
+
case "widget_accessibility_action": return 23;
|
|
35
|
+
case "audio": return 24;
|
|
36
|
+
case "video": return 25;
|
|
37
|
+
case "view_focused": return 26;
|
|
38
|
+
case "tray_command": return 27;
|
|
39
|
+
case "notification_command": return 28;
|
|
40
|
+
case "widget_context_menu_action": return 29;
|
|
41
|
+
default: throw new Error("unknown native event storage");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function nscjEventName(tag: number): string {
|
|
45
|
+
switch (tag) {
|
|
46
|
+
case 1: return "app_start";
|
|
47
|
+
case 2: return "app_activated";
|
|
48
|
+
case 3: return "app_deactivated";
|
|
49
|
+
case 4: return "appearance_changed";
|
|
50
|
+
case 5: return "frame_requested";
|
|
51
|
+
case 6: return "app_shutdown";
|
|
52
|
+
case 7: return "surface_resized";
|
|
53
|
+
case 8: return "window_frame_changed";
|
|
54
|
+
case 9: return "window_focused";
|
|
55
|
+
case 10: return "bridge_message";
|
|
56
|
+
case 11: return "tray_action";
|
|
57
|
+
case 12: return "shortcut";
|
|
58
|
+
case 13: return "native_command";
|
|
59
|
+
case 14: return "menu_command";
|
|
60
|
+
case 15: return "timer";
|
|
61
|
+
case 16: return "wake";
|
|
62
|
+
case 17: return "files_dropped";
|
|
63
|
+
case 18: return "gpu_surface_frame";
|
|
64
|
+
case 19: return "gpu_surface_resized";
|
|
65
|
+
case 20: return "gpu_surface_input";
|
|
66
|
+
case 21: return "gpu_surface_scroll_driver";
|
|
67
|
+
case 22: return "context_menu_action";
|
|
68
|
+
case 23: return "widget_accessibility_action";
|
|
69
|
+
case 24: return "audio";
|
|
70
|
+
case 25: return "video";
|
|
71
|
+
case 26: return "view_focused";
|
|
72
|
+
case 27: return "tray_command";
|
|
73
|
+
case 28: return "notification_command";
|
|
74
|
+
case 29: return "widget_context_menu_action";
|
|
75
|
+
default: return "";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function nscjSchema(record: number, name: string): NscJournalField[] {
|
|
79
|
+
if (record === 2) switch (name) {
|
|
80
|
+
case "appearance_changed": return nscjFields([["color_scheme", "enum", "ColorScheme"], ["reduce_motion", "bool", ""], ["high_contrast", "bool", ""]]);
|
|
81
|
+
case "surface_resized": return nscjFields([["id", "u64", ""], ["size.width", "f32", ""], ["size.height", "f32", ""], ["scale_factor", "f32", ""], ["safe_area_insets.top", "f32", ""], ["safe_area_insets.right", "f32", ""], ["safe_area_insets.bottom", "f32", ""], ["safe_area_insets.left", "f32", ""], ["keyboard_insets.top", "f32", ""], ["keyboard_insets.right", "f32", ""], ["keyboard_insets.bottom", "f32", ""], ["keyboard_insets.left", "f32", ""]]);
|
|
82
|
+
case "window_frame_changed": return nscjFields([["id", "u64", ""], ["label", "str", ""], ["title", "str", ""], ["frame.x", "f32", ""], ["frame.y", "f32", ""], ["frame.width", "f32", ""], ["frame.height", "f32", ""], ["scale_factor", "f32", ""], ["open", "bool", ""], ["focused", "bool", ""], ["maximized", "bool", ""], ["fullscreen", "bool", ""], ["hidden", "bool", ""]]);
|
|
83
|
+
case "window_focused": return nscjFields([["", "u64", ""]]);
|
|
84
|
+
case "view_focused": return nscjFields([["window_id", "u64", ""], ["label", "str", ""]]);
|
|
85
|
+
case "bridge_message": return nscjFields([["bytes", "str", ""], ["origin", "str", ""], ["window_id", "u64", ""], ["webview_label", "str", ""]]);
|
|
86
|
+
case "tray_action": return nscjFields([["status_item_id", "u32", ""], ["item_id", "u32", ""]]);
|
|
87
|
+
case "shortcut": return nscjFields([["id", "str", ""], ["key", "str", ""], ["modifiers", "modifiers", ""], ["window_id", "u64", ""]]);
|
|
88
|
+
case "native_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""], ["view_label", "str", ""]]);
|
|
89
|
+
case "menu_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""]]);
|
|
90
|
+
case "tray_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""], ["status_item_id", "u32", ""]]);
|
|
91
|
+
case "notification_command": return nscjFields([["name", "str", ""], ["window_id", "u64", ""]]);
|
|
92
|
+
case "timer": return nscjFields([["id", "u64", ""], ["timestamp_ns", "u64", ""]]);
|
|
93
|
+
case "audio": return nscjFields([["kind", "enum", "AudioEventKind"], ["position_ms", "u64", ""], ["duration_ms", "u64", ""], ["playing", "bool", ""], ["buffering", "bool", ""], ["bands", "bytes32", ""]]);
|
|
94
|
+
case "video": return nscjFields([["kind", "enum", "VideoEventKind"], ["token", "u64", ""], ["position_ms", "u64", ""], ["duration_ms", "u64", ""], ["playing", "bool", ""], ["buffering", "bool", ""], ["width", "u64", ""], ["height", "u64", ""]]);
|
|
95
|
+
case "files_dropped": return nscjFields([["window_id", "u64", ""], ["view_label", "str", ""], ["point", "optional-point", ""], ["paths", "paths", ""]]);
|
|
96
|
+
case "gpu_surface_frame": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["size.width", "f32", ""], ["size.height", "f32", ""], ["scale_factor", "f32", ""], ["frame_index", "u64", ""], ["timestamp_ns", "u64", ""], ["frame_interval_ns", "u64", ""], ["input_timestamp_ns", "u64", ""], ["canvas_frame_full_repaint", "bool", ""]]);
|
|
97
|
+
case "gpu_surface_resized": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["frame.x", "f32", ""], ["frame.y", "f32", ""], ["frame.width", "f32", ""], ["frame.height", "f32", ""], ["scale_factor", "f32", ""]]);
|
|
98
|
+
case "gpu_surface_input": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["kind", "enum", "GpuSurfaceInputKind"], ["timestamp_ns", "u64", ""], ["pointer_id", "u64", ""], ["x", "f32", ""], ["y", "f32", ""], ["button", "i32", ""], ["pressure", "f32", ""], ["delta_x", "f32", ""], ["delta_y", "f32", ""], ["scroll_is_detented", "bool", ""], ["key", "str", ""], ["text", "str", ""], ["composition_cursor", "optional-usize", ""], ["modifiers", "modifiers", ""], ["scale", "f32", ""]]);
|
|
99
|
+
case "gpu_surface_scroll_driver": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["driver_id", "u64", ""], ["offset_x", "f32", ""], ["offset_y", "f32", ""], ["timestamp_ns", "u64", ""]]);
|
|
100
|
+
case "context_menu_action": return nscjFields([["window_id", "u64", ""], ["view_label", "str", ""], ["token", "u64", ""], ["item_id", "u32", ""]]);
|
|
101
|
+
case "widget_context_menu_action": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["id", "u64", ""], ["item_index", "u32", ""]]);
|
|
102
|
+
case "widget_accessibility_action": return nscjFields([["window_id", "u64", ""], ["label", "str", ""], ["id", "u64", ""], ["action", "enum32", "WidgetAccessibilityActionKind"], ["text", "str", ""], ["selection", "optional-range", ""]]);
|
|
103
|
+
case "app_start": return nscjFields([]);
|
|
104
|
+
case "app_activated": return nscjFields([]);
|
|
105
|
+
case "app_deactivated": return nscjFields([]);
|
|
106
|
+
case "frame_requested": return nscjFields([]);
|
|
107
|
+
case "app_shutdown": return nscjFields([]);
|
|
108
|
+
case "wake": return nscjFields([]);
|
|
109
|
+
default: throw new Error("unknown journal event schema");
|
|
110
|
+
}
|
|
111
|
+
switch (record) {
|
|
112
|
+
case 1: return nscjFields([["protocol_fingerprint", "u64", ""], ["platform_name", "str", ""], ["app_name", "str", ""], ["recorded_at_wall_ms", "i64", ""], ["window_width", "f32", ""], ["window_height", "f32", ""], ["window_chrome_source", "enum", "WindowChromeSource"]]);
|
|
113
|
+
case 4: return nscjFields([["event_ordinal", "u64", ""], ["frame_index", "u64", ""], ["fingerprint", "u64", ""]]);
|
|
114
|
+
case 5: return nscjFields([["event_ordinal", "u64", ""], ["view_label", "str", ""], ["scale", "f32", ""], ["png_hash", "u64", ""], ["png_len", "u64", ""]]);
|
|
115
|
+
case 6: return nscjFields([["event_count", "u64", ""], ["effect_count", "u64", ""], ["checkpoint_count", "u64", ""], ["screenshot_count", "u64", ""], ["window_chrome_count", "u64", ""]]);
|
|
116
|
+
case 7: return nscjFields([["window_id", "u64", ""], ["chrome.insets.top", "f32", ""], ["chrome.insets.right", "f32", ""], ["chrome.insets.bottom", "f32", ""], ["chrome.insets.left", "f32", ""], ["chrome.buttons.x", "f32", ""], ["chrome.buttons.y", "f32", ""], ["chrome.buttons.width", "f32", ""], ["chrome.buttons.height", "f32", ""], ["chrome.form_factor", "enum", "FormFactor"], ["chrome.tabs_projected", "bool", ""]]);
|
|
117
|
+
case 3: return nscjFields([["kind", "enum", "EffectResultKind"], ["key", "u64", ""], ["payload", "str", ""], ["stderr_tail", "str", ""], ["truncated", "bool", ""], ["dropped", "u32", ""], ["code", "i32", ""], ["exit_reason", "enum", "EffectExitReason"], ["output_truncated", "bool", ""], ["stderr_truncated", "bool", ""], ["status", "u16", ""], ["fetch_outcome", "enum", "EffectFetchOutcome"], ["file_op", "enum", "EffectFileOp"], ["file_event", "enum", "EffectFileEvent"], ["file_outcome", "enum", "EffectFileOutcome"], ["file_total", "u64", ""], ["file_mtime_ms", "i64", ""], ["file_exists", "bool", ""], ["file_rejected_admission", "bool", ""], ["clipboard_op", "enum", "EffectClipboardOp"], ["clipboard_outcome", "enum", "EffectClipboardOutcome"], ["timer_timestamp_ns", "u64", ""], ["timer_outcome", "enum", "EffectTimerOutcome"], ["clock_wall_ms", "i64", ""], ["audio_kind", "enum", "EffectAudioEventKind"], ["audio_position_ms", "u64", ""], ["audio_duration_ms", "u64", ""], ["audio_playing", "bool", ""], ["audio_buffering", "bool", ""], ["file_blob_hash", "bytes16", ""], ["file_blob_len", "u64", ""], ["audio_bands", "bytes32", ""], ["image_outcome", "enum", "EffectImageOutcome"], ["image_width", "u64", ""], ["image_height", "u64", ""], ["image_blob_hash", "bytes16", ""], ["image_blob_len", "u64", ""], ["channel_kind", "enum", "EffectChannelEventKind"], ["channel_dropped_total", "u32", ""], ["video_kind", "enum", "EffectVideoEventKind"], ["video_position_ms", "u64", ""], ["video_duration_ms", "u64", ""], ["video_playing", "bool", ""], ["video_buffering", "bool", ""], ["video_width", "u64", ""], ["video_height", "u64", ""], ["video_token", "u64", ""], ["video_source", "enum", "EffectVideoSource"], ["video_handled", "bool", ""], ["pty_kind", "enum", "EffectPtyEventKind"], ["pty_signal", "i32", ""], ["pty_dropped_writes", "u32", ""], ["pty_blob_hash", "bytes16", ""], ["pty_blob_len", "u64", ""], ["persist_outcome", "enum", "EffectPersistOutcome"], ["persist_blob_hash", "bytes16", ""], ["persist_blob_len", "u64", ""], ["db_blob_hash", "bytes16", ""], ["db_blob_len", "u64", ""], ["credentials_operation", "enum", "EffectCredentialsOperation"], ["credentials_outcome", "enum", "EffectCredentialsOutcome"], ["credentials_secret_len", "u64", ""], ["credentials_salt", "bytes16", ""], ["credentials_digest", "bytes32", ""]]);
|
|
118
|
+
default: throw new Error("invalid journal record schema");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function nscjEnumValid(domain: string, value: number): boolean {
|
|
122
|
+
switch (domain) {
|
|
123
|
+
case "ColorScheme": return value >= 0 && value <= 1;
|
|
124
|
+
case "AudioEventKind": return value >= 0 && value <= 4;
|
|
125
|
+
case "VideoEventKind": return value >= 0 && value <= 3;
|
|
126
|
+
case "GpuSurfaceInputKind": return value >= 0 && value <= 14;
|
|
127
|
+
case "EffectResultKind": return value >= 1 && value <= 20;
|
|
128
|
+
case "EffectExitReason": return value >= 0 && value <= 4;
|
|
129
|
+
case "EffectFetchOutcome": return value >= 0 && value <= 6;
|
|
130
|
+
case "EffectFileOp": return value >= 0 && value <= 8;
|
|
131
|
+
case "EffectFileEvent": return value >= 0 && value <= 2;
|
|
132
|
+
case "EffectFileOutcome": return value >= 0 && value <= 8;
|
|
133
|
+
case "EffectClipboardOp": return value >= 0 && value <= 1;
|
|
134
|
+
case "EffectClipboardOutcome": return value >= 0 && value <= 3;
|
|
135
|
+
case "EffectTimerOutcome": return value >= 0 && value <= 1;
|
|
136
|
+
case "EffectAudioEventKind": return value >= 0 && value <= 5;
|
|
137
|
+
case "EffectImageOutcome": return value >= 0 && value <= 14;
|
|
138
|
+
case "EffectChannelEventKind": return value >= 0 && value <= 2;
|
|
139
|
+
case "EffectVideoEventKind": return value >= 0 && value <= 4;
|
|
140
|
+
case "EffectVideoSource": return value >= 0 && value <= 1;
|
|
141
|
+
case "EffectPtyEventKind": return value >= 0 && value <= 2;
|
|
142
|
+
case "EffectPersistOutcome": return value >= 0 && value <= 6;
|
|
143
|
+
case "EffectCredentialsOperation": return value >= 0 && value <= 2;
|
|
144
|
+
case "EffectCredentialsOutcome": return value >= 0 && value <= 6;
|
|
145
|
+
case "WindowChromeSource": return value >= 0 && value <= 1;
|
|
146
|
+
case "FormFactor": return value >= 0 && value <= 2;
|
|
147
|
+
case "WidgetAccessibilityActionKind": return value >= 0 && value <= 13;
|
|
148
|
+
default: throw new Error("unknown journal enum domain");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function nscjWidth(kind: string): number {
|
|
152
|
+
if (kind === "enum" || kind === "bool") return 1;
|
|
153
|
+
if (kind === "u16") return 2;
|
|
154
|
+
if (kind === "f32" || kind === "u32" || kind === "i32" || kind === "enum32") return 4;
|
|
155
|
+
if (kind === "u64" || kind === "i64" || kind === "usize") return 8;
|
|
156
|
+
if (kind === "bytes16") return 16;
|
|
157
|
+
if (kind === "bytes32") return 32;
|
|
158
|
+
throw new Error("invalid journal scalar storage");
|
|
159
|
+
}
|
|
160
|
+
class NscJournalCursor implements nscContracts.Acyclic {
|
|
161
|
+
input: Uint8Array; slots: NscJournalSlot[]; chunks: Uint8Array[] = []; written: number = 0; entries: NscJournalSlot[] = [];
|
|
162
|
+
at: number = 0; status: number = 0; decode: boolean; capacity: number; usizeBits: number;
|
|
163
|
+
constructor(input: Uint8Array, slots: NscJournalSlot[], decode: boolean, capacity: number, usizeBits: number) {
|
|
164
|
+
this.input = input; this.slots = slots; this.decode = decode; this.capacity = capacity; this.usizeBits = usizeBits;
|
|
165
|
+
}
|
|
166
|
+
slot(path: string): Uint8Array {
|
|
167
|
+
for (const slot of this.slots) if (slot.path === path) return slot.bytes;
|
|
168
|
+
throw new Error("missing native journal storage slot");
|
|
169
|
+
}
|
|
170
|
+
write(bytes: Uint8Array): void {
|
|
171
|
+
if (this.status !== 0) return;
|
|
172
|
+
if (bytes.length > this.capacity - this.written) { this.status = 2; return; }
|
|
173
|
+
this.chunks.push(bytes); this.written += bytes.length;
|
|
174
|
+
}
|
|
175
|
+
read(length: number): Uint8Array {
|
|
176
|
+
if (this.status !== 0) return new Uint8Array(0);
|
|
177
|
+
if (length > this.input.length - this.at) { this.status = 1; return new Uint8Array(0); }
|
|
178
|
+
const bytes = this.input.subarray(this.at, this.at + length); this.at += length; return bytes;
|
|
179
|
+
}
|
|
180
|
+
emit(path: string, source: Uint8Array): void {
|
|
181
|
+
// The span descriptor borrows the original payload; no decoded text is retained.
|
|
182
|
+
const bytes = new Uint8Array(8), w = new DataView(bytes.buffer);
|
|
183
|
+
w.setUint32(0, source.byteOffset - this.input.byteOffset, true); w.setUint32(4, source.length, true);
|
|
184
|
+
this.entries.push({ path, bytes });
|
|
185
|
+
}
|
|
186
|
+
scalar(path: string, kind: string, domain: string): number {
|
|
187
|
+
if (this.status !== 0) return 0;
|
|
188
|
+
const length = nscjWidth(kind);
|
|
189
|
+
let bytes = this.decode ? this.read(length) : this.slot(path);
|
|
190
|
+
if (!this.decode && kind === "usize" && bytes.length === 4) { const wide = new Uint8Array(8); wide.set(bytes); bytes = wide; }
|
|
191
|
+
if (this.status !== 0) return 0;
|
|
192
|
+
if (bytes.length !== length) throw new Error("invalid native journal scalar width");
|
|
193
|
+
const w = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
194
|
+
let value = kind === "enum32" ? w.getInt32(0, true) : length === 1 ? bytes[0]! : length === 2 ? w.getUint16(0, true) : w.getUint32(0, true);
|
|
195
|
+
if (this.decode && (kind === "bool" && value > 1 || (kind === "enum" || kind === "enum32") && !nscjEnumValid(domain, value) || kind === "usize" && this.usizeBits === 32 && w.getUint32(4, true) !== 0)) {
|
|
196
|
+
this.status = 1; return 0;
|
|
197
|
+
}
|
|
198
|
+
if (this.decode) this.emit(path, bytes); else this.write(bytes);
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
string(path: string): void {
|
|
202
|
+
if (this.status !== 0) return;
|
|
203
|
+
if (this.decode) {
|
|
204
|
+
const prefix = this.read(4); if (this.status !== 0) return;
|
|
205
|
+
const count = new DataView(prefix.buffer, prefix.byteOffset, 4).getUint32(0, true), bytes = this.read(count);
|
|
206
|
+
if (this.status === 0) this.emit(path, bytes);
|
|
207
|
+
} else {
|
|
208
|
+
const bytes = this.slot(path), prefix = new Uint8Array(4);
|
|
209
|
+
if (bytes.length > 4294967295) { this.status = 2; return; }
|
|
210
|
+
new DataView(prefix.buffer).setUint32(0, bytes.length, true); this.write(prefix); this.write(bytes);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
field(field: NscJournalField): void {
|
|
214
|
+
if (this.status !== 0) return;
|
|
215
|
+
const path = field.path, kind = field.kind;
|
|
216
|
+
if (kind === "str") this.string(path);
|
|
217
|
+
else if (kind === "modifiers") {
|
|
218
|
+
if (this.decode) {
|
|
219
|
+
const bits = this.read(1); if (this.status !== 0) return;
|
|
220
|
+
if (bits[0]! > 31) { this.status = 1; return; }
|
|
221
|
+
this.emit(path, bits);
|
|
222
|
+
} else {
|
|
223
|
+
const names = ["primary", "command", "control", "option", "shift"]; let mask = 0;
|
|
224
|
+
for (let i = 0; i < names.length; i++) if (this.slot(path + "." + names[i]!)[0] === 1) mask |= 1 << i;
|
|
225
|
+
const bits = new Uint8Array(1); bits[0] = mask; this.write(bits);
|
|
226
|
+
}
|
|
227
|
+
} else if (kind === "optional-point" || kind === "optional-usize" || kind === "optional-range") {
|
|
228
|
+
if (this.scalar(path, "bool", "") !== 0) {
|
|
229
|
+
if (kind === "optional-point") { this.scalar(path + ".x", "f32", ""); this.scalar(path + ".y", "f32", ""); }
|
|
230
|
+
else if (kind === "optional-range") { this.scalar(path + ".start", "usize", ""); this.scalar(path + ".end", "usize", ""); }
|
|
231
|
+
else this.scalar(path + ".value", "usize", "");
|
|
232
|
+
}
|
|
233
|
+
} else if (kind === "paths") {
|
|
234
|
+
let count = 0;
|
|
235
|
+
if (this.decode) {
|
|
236
|
+
const raw = this.read(2); if (this.status !== 0) return;
|
|
237
|
+
count = new DataView(raw.buffer, raw.byteOffset, 2).getUint16(0, true);
|
|
238
|
+
if (count > 32) { this.status = 1; return; }
|
|
239
|
+
this.emit(path, raw);
|
|
240
|
+
} else {
|
|
241
|
+
const raw = this.slot(path), w = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);
|
|
242
|
+
count = w.getUint32(0, true);
|
|
243
|
+
if (w.getUint32(4, true) !== 0 || count > 32) { this.status = 2; return; }
|
|
244
|
+
const bytes = new Uint8Array(2); new DataView(bytes.buffer).setUint16(0, count, true); this.write(bytes);
|
|
245
|
+
}
|
|
246
|
+
for (let i = 0; i < count && this.status === 0; i++) this.string(path + "/" + i);
|
|
247
|
+
} else this.scalar(path, kind, field.domain);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/** Opcode 30, version 1: encode raw native slots or decode borrowed wire spans.
|
|
251
|
+
* Result status 1 is corrupt input; 2 is output budget. Failed operations retain
|
|
252
|
+
* their exact written prefix and all already-decoded dropped-path spans.
|
|
253
|
+
*/
|
|
254
|
+
export function sessionCodecPolicy(request: Uint8Array): Uint8Array {
|
|
255
|
+
if (request.length < 24 || request[0] !== 30 || request[1] !== 1 || request[2]! > 1 || request[3]! < 1 || request[3]! > 7)
|
|
256
|
+
throw new Error("invalid journal codec request");
|
|
257
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), decode = request[2] === 1, record = request[3]!;
|
|
258
|
+
const capacity = w.getUint32(4, true), usizeBits = w.getUint32(8, true), nameLength = w.getUint32(12, true), count = w.getUint32(16, true), payloadLength = w.getUint32(20, true);
|
|
259
|
+
if (usizeBits !== 32 && usizeBits !== 64 || nameLength > 64 || count > 512 || decode && (nameLength !== 0 || count !== 0) || !decode && payloadLength !== 0 || 24 + nameLength > request.length)
|
|
260
|
+
throw new Error("invalid journal codec storage bounds");
|
|
261
|
+
let at = 24 + nameLength; const slots: NscJournalSlot[] = [];
|
|
262
|
+
const text = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
263
|
+
let name = text.decode(request.subarray(24, at));
|
|
264
|
+
for (let i = 0; i < count; i++) {
|
|
265
|
+
if (at + 8 > request.length) throw new Error("truncated journal slot");
|
|
266
|
+
const n = w.getUint32(at, true), length = w.getUint32(at + 4, true); at += 8;
|
|
267
|
+
if (n > 256 || n > request.length - at || length > request.length - at - n) throw new Error("invalid journal slot extent");
|
|
268
|
+
const path = text.decode(request.subarray(at, at + n)); at += n;
|
|
269
|
+
for (const slot of slots) if (slot.path === path) throw new Error("duplicate journal slot");
|
|
270
|
+
slots.push({ path, bytes: request.subarray(at, at + length) }); at += length;
|
|
271
|
+
}
|
|
272
|
+
if (payloadLength !== request.length - at) throw new Error("invalid journal payload extent");
|
|
273
|
+
const input = request.subarray(at), cursor = new NscJournalCursor(input, slots, decode, capacity, usizeBits);
|
|
274
|
+
let tag = 0;
|
|
275
|
+
if (record === 2) {
|
|
276
|
+
if (decode) {
|
|
277
|
+
const value = cursor.read(1);
|
|
278
|
+
if (cursor.status === 0) { tag = value[0]!; name = nscjEventName(tag); if (name === "") cursor.status = 1; }
|
|
279
|
+
} else { tag = nscjEventTag(name); const value = new Uint8Array(1); value[0] = tag; cursor.write(value); }
|
|
280
|
+
}
|
|
281
|
+
let effectKind = 0;
|
|
282
|
+
if (cursor.status === 0) {
|
|
283
|
+
for (const field of nscjSchema(record, name)) {
|
|
284
|
+
// The effect's kind-local suffixes preserve all earlier byte layouts.
|
|
285
|
+
if (record === 3 && field.path.startsWith("persist_") && effectKind !== 16 || record === 3 && field.path.startsWith("db_") && effectKind !== 17 || record === 3 && field.path.startsWith("credentials_") && effectKind !== 18) continue;
|
|
286
|
+
if (record === 3 && field.path === "kind") effectKind = cursor.scalar(field.path, field.kind, field.domain);
|
|
287
|
+
else cursor.field(field);
|
|
288
|
+
if (cursor.status !== 0) break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (decode && cursor.status === 0 && cursor.at !== input.length) cursor.status = 1;
|
|
292
|
+
const paths: Uint8Array[] = [];
|
|
293
|
+
let bodyLength = decode ? 0 : cursor.written;
|
|
294
|
+
if (decode) for (const entry of cursor.entries) {
|
|
295
|
+
const path = new TextEncoder().encode(entry.path); paths.push(path); bodyLength += 12 + path.length;
|
|
296
|
+
}
|
|
297
|
+
const eventName = decode && record === 2 ? new TextEncoder().encode(name) : new Uint8Array(0);
|
|
298
|
+
const result = new Uint8Array(16 + eventName.length + bodyLength), out = new DataView(result.buffer);
|
|
299
|
+
out.setUint32(0, 1, true); out.setUint32(4, cursor.status, true); out.setUint32(8, decode ? cursor.entries.length : cursor.written, true); out.setUint32(12, eventName.length, true);
|
|
300
|
+
result.set(eventName, 16);
|
|
301
|
+
let outputAt = 16 + eventName.length;
|
|
302
|
+
if (decode) for (let i = 0; i < cursor.entries.length; i++) {
|
|
303
|
+
const entry = cursor.entries[i]!, path = paths[i]!;
|
|
304
|
+
out.setUint32(outputAt, path.length, true); outputAt += 4;
|
|
305
|
+
result.set(path, outputAt); outputAt += path.length;
|
|
306
|
+
result.set(entry.bytes, outputAt); outputAt += 8;
|
|
307
|
+
} else for (const chunk of cursor.chunks) { result.set(chunk, outputAt); outputAt += chunk.length; }
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Portable scene and runtime descriptor admission over copied raw facts. */
|
|
2
|
+
function nscvShellAdmission(request: Uint8Array): Uint8Array {
|
|
3
|
+
if (request.length < 64 || request[0] !== 85 || request[1] !== 1 || request[2]! > 11 || request[3] !== 0)
|
|
4
|
+
throw new Error("invalid shell admission header");
|
|
5
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength), mode = request[2]!;
|
|
6
|
+
const word = (at: number): number => w.getUint32(at, true);
|
|
7
|
+
const over = (at: number, limit: number): boolean => word(at + 4) !== 0 || word(at) > limit;
|
|
8
|
+
const empty = (at: number): boolean => word(at) === 0 && word(at + 4) === 0;
|
|
9
|
+
let status = 0, state = 0;
|
|
10
|
+
if (mode === 0) {
|
|
11
|
+
const field = word(4), prior = word(12), count = word(32), final = word(36);
|
|
12
|
+
if (field > 9 || prior > 15 || final > 1 || count > 256 || request.length !== 64 + count)
|
|
13
|
+
throw new Error("invalid shell field bounds");
|
|
14
|
+
const endLow = word(24) + count, carry = endLow > 4294967295 ? 1 : 0, endHigh = word(28) + carry;
|
|
15
|
+
if (endHigh > word(20) || endHigh === word(20) && endLow - carry * 4294967296 > word(16) || final === 1 && (endHigh !== word(20) || endLow - carry * 4294967296 !== word(16)))
|
|
16
|
+
throw new Error("invalid shell field extent");
|
|
17
|
+
for (let i = 56; i < 64; i++) if (request[i] !== 0) throw new Error("invalid shell field padding");
|
|
18
|
+
state = prior;
|
|
19
|
+
const dot = word(20) === 0 && (word(16) === 1 && request[48] === 46 || word(16) === 2 && request[48] === 46 && request[49] === 46);
|
|
20
|
+
let prefix = 0, web = false;
|
|
21
|
+
if (field === 6) {
|
|
22
|
+
if (request[48] === 104 && request[49] === 116 && request[50] === 116 && request[51] === 112) {
|
|
23
|
+
if (request[52] === 58 && request[53] === 47 && request[54] === 47) { prefix = 7; web = true; }
|
|
24
|
+
else if (request[52] === 115 && request[53] === 58 && request[54] === 47 && request[55] === 47) { prefix = 8; web = true; }
|
|
25
|
+
} else if ((request[48] === 102 && request[49] === 105 && request[50] === 108 && request[51] === 101 || request[48] === 122 && request[49] === 101 && request[50] === 114 && request[51] === 111) && request[52] === 58 && request[53] === 47 && request[54] === 47) prefix = 7;
|
|
26
|
+
if (prefix === 0 || word(20) === 0 && word(16) <= prefix) state |= 1;
|
|
27
|
+
}
|
|
28
|
+
const appIcon = field === 8 && request[48] === 97 && request[49] === 112 && request[50] === 112 && request[51] === 58;
|
|
29
|
+
for (let i = 0; i < count; i++) {
|
|
30
|
+
const ch = request[64 + i]!, position = word(24) + i, leading = word(28) === 0;
|
|
31
|
+
if (field <= 2 || field === 5 || field === 9) {
|
|
32
|
+
if (ch === 0 || ch === 47 || ch === 92) state |= 1;
|
|
33
|
+
if (ch === 9 || ch === 10 || ch === 13) state |= 2;
|
|
34
|
+
} else if (field === 3 || field === 4) {
|
|
35
|
+
if (ch === 0) state |= 1;
|
|
36
|
+
} else if (field === 6) {
|
|
37
|
+
if (leading && position < prefix) continue;
|
|
38
|
+
if (web && (state & 8) !== 0) continue;
|
|
39
|
+
if (web && ch === 47) { state |= 8; continue; }
|
|
40
|
+
state |= 4;
|
|
41
|
+
if (ch === 0 || ch === 32 || ch === 9 || ch === 10 || ch === 13) state |= 1;
|
|
42
|
+
} else if (field === 7) {
|
|
43
|
+
if (ch < 32 || ch === 127) state |= 1;
|
|
44
|
+
} else if (field === 8) {
|
|
45
|
+
if (appIcon && leading && position < 4) continue;
|
|
46
|
+
if (!(ch >= 97 && ch <= 122 || ch >= 48 && ch <= 57 || ch === 45 || ch === 95)) state |= 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (field <= 2) status = empty(16) || dot || (state & 1) !== 0 || field > 0 && over(16, 64) ? 1 : 0;
|
|
50
|
+
else if (field <= 4) status = (state & 1) !== 0 || field === 3 && over(16, 256) ? 1 : 0;
|
|
51
|
+
else if (field === 5) status = empty(16) || over(16, 128) ? 6 : dot || (state & 1) !== 0 ? 1 : (state & 2) !== 0 ? 6 : 0;
|
|
52
|
+
else if (field === 6) status = (state & 1) !== 0 || final === 1 && (state & 4) === 0 ? 8 : 0;
|
|
53
|
+
else if (field === 7) status = empty(16) || over(16, 128) || (state & 1) !== 0 ? 1 : 0;
|
|
54
|
+
else if (field === 8) status = over(16, 64) || (state & 1) !== 0 || appIcon && word(20) === 0 && word(16) === 4 ? 1 : 0;
|
|
55
|
+
else status = empty(16) || over(16, 128) || dot || (state & 3) !== 0 ? 6 : 0;
|
|
56
|
+
} else if (mode === 3) {
|
|
57
|
+
const count = word(16);
|
|
58
|
+
if (over(16, 128) || request.length !== 64 + count * 4) throw new Error("invalid shell hierarchy bounds");
|
|
59
|
+
const visits: number[] = [];
|
|
60
|
+
for (let i = 0; i < count; i++) visits.push(0);
|
|
61
|
+
for (let i = 0; i < count; i++) {
|
|
62
|
+
let at = i;
|
|
63
|
+
while (at !== 4294967295 && visits[at] === 0) {
|
|
64
|
+
visits[at] = 1;
|
|
65
|
+
at = word(64 + at * 4);
|
|
66
|
+
if (at !== 4294967295 && at >= count) throw new Error("invalid shell parent slot");
|
|
67
|
+
}
|
|
68
|
+
if (at !== 4294967295 && visits[at] === 1) { status = 2; break; }
|
|
69
|
+
at = i;
|
|
70
|
+
while (at !== 4294967295 && visits[at] === 1) { visits[at] = 2; at = word(64 + at * 4); }
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
if (request.length !== (mode === 2 || mode === 8 || mode === 9 ? 160 : 64)) throw new Error("invalid shell admission tail");
|
|
74
|
+
if (mode === 1) {
|
|
75
|
+
status = word(4) || word(8);
|
|
76
|
+
if (status === 0 && (w.getFloat32(32, true) <= 0 || w.getFloat32(36, true) <= 0)) status = 5;
|
|
77
|
+
if (status === 0 && over(16, 128)) status = 2;
|
|
78
|
+
} else if (mode === 2) {
|
|
79
|
+
const flags = word(4), duplicate = word(8), parent = word(12), kind = word(80);
|
|
80
|
+
if (flags > 1023 || duplicate > 1 || kind > 18 || word(84) > 63) throw new Error("invalid shell descriptor facts");
|
|
81
|
+
status = word(16);
|
|
82
|
+
if (status === 0 && duplicate) status = 3;
|
|
83
|
+
if (status === 0 && (flags & 64) !== 0) status = word(20) || (parent === 4294967295 || parent === word(88) ? 2 : 0);
|
|
84
|
+
if (status === 0) {
|
|
85
|
+
for (let i = 0; i < 6; i++) if ((flags & (1 << i)) !== 0) {
|
|
86
|
+
const value = w.getFloat32(48 + i * 4, true);
|
|
87
|
+
if (i === 2 || i === 3 ? value < 0 : value <= 0) status = 5;
|
|
88
|
+
}
|
|
89
|
+
if ((flags & 20) === 20 && w.getFloat32(56, true) > w.getFloat32(64, true) || (flags & 40) === 40 && w.getFloat32(60, true) > w.getFloat32(68, true)) status = 5;
|
|
90
|
+
}
|
|
91
|
+
for (let i = 0; i < 4 && status === 0; i++) status = word(24 + i * 4);
|
|
92
|
+
if (status === 0) status = (flags & 128) !== 0 ? kind !== 0 ? 8 : word(40) : kind === 0 ? 9 : 0;
|
|
93
|
+
if (status === 0 && kind !== 17 && word(84) !== 0) status = 10;
|
|
94
|
+
} else if (mode === 4) status = over(16, 16) ? 2 : 0;
|
|
95
|
+
else if (mode === 5) status = over(16, 5) || word(16) === 1 ? 2 : 0;
|
|
96
|
+
else if (mode === 6) status = word(16) || word(20) || word(24) || (word(4) !== 0 ? 7 : 0);
|
|
97
|
+
else if (mode === 7) status = word(4) !== 0 ? 4 : 0;
|
|
98
|
+
else if (mode === 8 || mode === 9) {
|
|
99
|
+
const flags = word(8), kind = word(4), patch = mode === 9;
|
|
100
|
+
if (kind > 18 || flags > 63) throw new Error("invalid runtime descriptor facts");
|
|
101
|
+
status = empty(64) ? 11 : over(64, 64) ? 12 : 0;
|
|
102
|
+
if (status === 0 && (!patch || (flags & 1) !== 0)) for (let i = 0; i < 4; i++) if (w.getFloat32(32 + i * 4, true) < 0) status = 11;
|
|
103
|
+
if (status === 0 && !patch && (flags & 1) !== 0 && (empty(72) || over(72, 64))) status = 11;
|
|
104
|
+
if (status === 0 && over(80, 64)) status = 13;
|
|
105
|
+
if (status === 0 && over(88, 256)) status = 14;
|
|
106
|
+
if (status === 0 && over(96, 1024)) status = 15;
|
|
107
|
+
if (status === 0 && !empty(104)) status = word(120);
|
|
108
|
+
if (status === 0 && !patch && kind !== 0 && !empty(112)) status = 11;
|
|
109
|
+
if (status === 0 && !patch && kind === 17 && !((request[16] === 1 || request[16] === 3) && request[17] === 1 && request[18] === 1 && (request[19] === 1 || request[19] === 2) && request[20] === 1 && request[21] === 1)) status = 16;
|
|
110
|
+
} else if (mode === 10) {
|
|
111
|
+
const category = word(4);
|
|
112
|
+
if (category > 2) throw new Error("invalid runtime label category");
|
|
113
|
+
status = empty(16) ? category === 0 ? 11 : 18 : over(16, 64) ? category === 0 ? 12 : 19 : 0;
|
|
114
|
+
if (status === 0 && category === 2 && word(20) === 0 && word(16) === 4 && request[40] === 109 && request[41] === 97 && request[42] === 105 && request[43] === 110) status = 20;
|
|
115
|
+
} else if (mode === 11) {
|
|
116
|
+
const category = word(4);
|
|
117
|
+
if (category > 2) throw new Error("invalid runtime frame category");
|
|
118
|
+
const x = w.getFloat32(16, true), y = w.getFloat32(20, true), width = w.getFloat32(24, true), height = w.getFloat32(28, true);
|
|
119
|
+
status = category === 0 ? x < 0 || y < 0 || width < 0 || height < 0 ? 11 : 0 : category === 1 ? !Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0 ? 17 : 0 : x >= 0 && y >= 0 && width > 0 && height > 0 ? 0 : 18;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (status > 20) throw new Error("invalid shell field verdict");
|
|
123
|
+
const result = new Uint8Array(16), out = new DataView(result.buffer);
|
|
124
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true); out.setUint32(12, state, true);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Shell installation decisions. Native owns descriptor bytes, storage, and OS calls. */
|
|
2
|
+
function nscvShellCoordination(request: Uint8Array): Uint8Array {
|
|
3
|
+
if (request.length < 64 || request[0] !== 84 || request[1] !== 1 || request[2]! > 7 || request[3] !== 0)
|
|
4
|
+
throw new Error("invalid shell coordination header");
|
|
5
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
6
|
+
const mode = request[2]!, facts = w.getUint32(4, true), count = w.getUint32(8, true), cursor = w.getUint32(12, true);
|
|
7
|
+
for (let i = 48; i < 64; i++) if (request[i] !== 0) throw new Error("invalid shell coordination padding");
|
|
8
|
+
let status = 0, decisions = 0, selected = 4294967295;
|
|
9
|
+
const choices: number[] = [];
|
|
10
|
+
if (mode === 0) {
|
|
11
|
+
if (facts > 1 || count > 16 || cursor > 7 || cursor !== 0 && count !== 1) throw new Error("invalid shell scene bounds");
|
|
12
|
+
let at = 64, needsSource = false;
|
|
13
|
+
for (let i = 0; i < count; i++) {
|
|
14
|
+
if (at + 4 > request.length || request[at]! > 1 || request[at + 1]! > 1) throw new Error("invalid shell window");
|
|
15
|
+
const hidden = request[at] === 1, explicit = request[at + 1] === 1, views = w.getUint16(at + 2, true);
|
|
16
|
+
if (views > 128) throw new Error("invalid shell view count");
|
|
17
|
+
at += 4;
|
|
18
|
+
let hasMain = (cursor & 1) !== 0, hasWeb = (cursor & 2) !== 0, hasGpu = (cursor & 4) !== 0;
|
|
19
|
+
for (let j = 0; j < views; j++) {
|
|
20
|
+
if (at + 13 > request.length || request[at]! > 18) throw new Error("invalid shell view");
|
|
21
|
+
const kind = request[at]!, length = w.getUint32(at + 1, true);
|
|
22
|
+
if (kind === 0) {
|
|
23
|
+
hasWeb = true;
|
|
24
|
+
if (length === 4 && w.getUint32(at + 5, true) === 0 && request[at + 9] === 109 && request[at + 10] === 97 && request[at + 11] === 105 && request[at + 12] === 110) hasMain = true;
|
|
25
|
+
}
|
|
26
|
+
if (kind === 17) hasGpu = true;
|
|
27
|
+
at += 13;
|
|
28
|
+
}
|
|
29
|
+
const usesSource = hasMain || !(hasGpu && !hasWeb) && facts === 0;
|
|
30
|
+
needsSource = needsSource || hasMain;
|
|
31
|
+
// Carry only observations so an app callback may replace a validated
|
|
32
|
+
// view slice with an oversized one before the ordinary creation gate.
|
|
33
|
+
choices.push((hidden ? 1 : hasGpu ? 2 : 0) | (usesSource ? 4 : 0) | (explicit ? 8 : 0) | ((hasMain ? 1 : 0) | (hasWeb ? 2 : 0) | (hasGpu ? 4 : 0)) << 4);
|
|
34
|
+
}
|
|
35
|
+
if (at !== request.length) throw new Error("invalid shell scene tail");
|
|
36
|
+
decisions = count > 0 && (needsSource || facts === 0) ? 1 : 0;
|
|
37
|
+
} else if (mode === 5) {
|
|
38
|
+
if (facts !== 0 || count > 16 || request.length !== 64 + count * 8) throw new Error("invalid shell binding bounds");
|
|
39
|
+
for (let i = 0; i < count; i++) {
|
|
40
|
+
if (w.getUint32(16, true) === w.getUint32(64 + i * 8, true) && w.getUint32(20, true) === w.getUint32(68 + i * 8, true)) { selected = i; break; }
|
|
41
|
+
}
|
|
42
|
+
if (selected === 4294967295) {
|
|
43
|
+
if (count === 16) status = 1;
|
|
44
|
+
else { selected = count; decisions = 1; }
|
|
45
|
+
}
|
|
46
|
+
} else if (mode === 7) {
|
|
47
|
+
if (facts > 5 || (facts & 2) !== 0 || cursor > 1 || count > 128 || request.length !== 64 + count) throw new Error("invalid shell presentation bounds");
|
|
48
|
+
let hasGpu = cursor === 1;
|
|
49
|
+
for (let i = 0; i < count; i++) {
|
|
50
|
+
if (request[64 + i]! > 18) throw new Error("invalid shell presentation kind");
|
|
51
|
+
if (request[64 + i] === 17) hasGpu = true;
|
|
52
|
+
}
|
|
53
|
+
decisions = ((facts & 1) !== 0 ? 1 : hasGpu ? 2 : 0) | ((facts & 4) !== 0 ? 4 : 0) | (hasGpu ? 8 : 0);
|
|
54
|
+
} else {
|
|
55
|
+
if (request.length !== 64) throw new Error("invalid shell coordination tail");
|
|
56
|
+
if (mode === 1) {
|
|
57
|
+
// Ordered, chunked opaque-byte equality; no native equality verdict.
|
|
58
|
+
if (facts > 1 || count > 16 || cursor !== 0) throw new Error("invalid shell comparison bounds");
|
|
59
|
+
decisions = facts;
|
|
60
|
+
for (let i = 0; i < count; i++) if (request[16 + i] !== request[32 + i]) decisions = 0;
|
|
61
|
+
} else if (mode === 2) {
|
|
62
|
+
if (facts > 7 || w.getUint32(16, true) > 18) throw new Error("invalid shell application facts");
|
|
63
|
+
const update = (facts & 1) !== 0, main = (facts & 2) !== 0 && w.getUint32(16, true) === 0, missing = (facts & 4) !== 0;
|
|
64
|
+
decisions = (main ? 1 : 0) | (!update && !main ? 2 : 4) | (update && missing ? 8 : 0);
|
|
65
|
+
} else if (mode === 3) {
|
|
66
|
+
if (facts !== 0 || count > 128 || cursor > count) throw new Error("invalid shell rollback bounds");
|
|
67
|
+
if (cursor > 0) selected = cursor - 1;
|
|
68
|
+
} else if (mode === 4) {
|
|
69
|
+
if (facts > 3) throw new Error("invalid shell restoration facts");
|
|
70
|
+
let different = (facts & 2) !== 0;
|
|
71
|
+
for (let i = 0; i < 4; i++) if (w.getFloat32(16 + i * 4, true) !== w.getFloat32(32 + i * 4, true)) different = true;
|
|
72
|
+
decisions = (facts & 1) === 0 ? 0 : (different ? 1 : 0) | (count !== cursor ? 2 : 0);
|
|
73
|
+
} else if (mode === 6) {
|
|
74
|
+
if (facts > 7 || cursor > 2 || cursor !== 2 && w.getUint32(16, true) > 18 || w.getUint32(28, true) > 32 || w.getUint32(32, true) > 16) throw new Error("invalid shell admission facts");
|
|
75
|
+
const kind = w.getUint32(16, true), main = kind === 0 && (facts & 4) !== 0;
|
|
76
|
+
if ((facts & 1) !== 0 || !main && (facts & 2) !== 0) status = 2;
|
|
77
|
+
else if (!main) decisions = kind === 0 ? 1 : 2;
|
|
78
|
+
if (cursor === 1) {
|
|
79
|
+
if (w.getUint32(20, true) > 32 - w.getUint32(28, true)) status = 3;
|
|
80
|
+
else if (w.getUint32(24, true) > 16 - w.getUint32(32, true)) status = 4;
|
|
81
|
+
decisions = 0;
|
|
82
|
+
} else if (cursor === 2) {
|
|
83
|
+
status = w.getUint32(20, true) !== 0 || w.getUint32(16, true) > 128 ? 3 : 0;
|
|
84
|
+
decisions = 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const result = new Uint8Array(24 + choices.length * 4), out = new DataView(result.buffer);
|
|
89
|
+
out.setUint32(0, 1, true); out.setUint32(4, mode, true); out.setUint32(8, status, true);
|
|
90
|
+
out.setUint32(12, decisions, true); out.setUint32(16, selected, true); out.setUint32(20, choices.length, true);
|
|
91
|
+
for (let i = 0; i < choices.length; i++) out.setUint32(24 + i * 4, choices[i]!, true);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import { analyzeSqlite, checkMigrationState, formatSqliteDiagnostic, generateCoreSurface, generateMigrationsZig } from "./sqlite_codegen.ts";
|
|
4
|
+
import { analyzeSqlite, checkMigrationState, formatSqliteDiagnostic, generateCoreDeclarations, generateCoreSurface, generateMigrationsZig } from "./sqlite_codegen.ts";
|
|
6
5
|
|
|
7
6
|
function argsOf(argv: string[]): Map<string, string> {
|
|
8
7
|
const out = new Map<string, string>();
|
|
@@ -48,6 +47,17 @@ try {
|
|
|
48
47
|
const sdkSource = generateCoreSurface(fs.readFileSync(sdkIn!, "utf8"), analysis);
|
|
49
48
|
fs.writeFileSync(sdkOut!, sdkSource);
|
|
50
49
|
const sdkDir = path.dirname(sdkIn!);
|
|
50
|
+
// Generated core surfaces retain these relative SDK imports. Carry
|
|
51
|
+
// their complete implementation and declaration siblings with each
|
|
52
|
+
// projection, including the editor's app-specific relational overlay.
|
|
53
|
+
const siblingDirs = new Set([path.dirname(sdkOut!), path.dirname(staticOut!), ...(dtsOut ? [path.dirname(dtsOut)] : [])]);
|
|
54
|
+
for (const destination of siblingDirs) for (const name of ["bytes", "events", "text", "theme", "internal/image_identity", "internal/markdown_policy"]) {
|
|
55
|
+
for (const extension of [".ts", ".d.ts"]) {
|
|
56
|
+
const output = path.join(destination, name + extension);
|
|
57
|
+
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
58
|
+
fs.copyFileSync(path.join(sdkDir, name + extension), output);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
51
61
|
for (const [source, destination] of [
|
|
52
62
|
["events.ts", sdkEventsOut!],
|
|
53
63
|
["text.ts", sdkTextOut!],
|
|
@@ -58,50 +68,8 @@ try {
|
|
|
58
68
|
fs.copyFileSync(path.join(sdkDir, source), destination);
|
|
59
69
|
}
|
|
60
70
|
if (dtsOut) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
exactOptionalPropertyTypes: true,
|
|
64
|
-
target: ts.ScriptTarget.ESNext,
|
|
65
|
-
module: ts.ModuleKind.ESNext,
|
|
66
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
67
|
-
lib: ["lib.esnext.d.ts"],
|
|
68
|
-
types: [],
|
|
69
|
-
allowImportingTsExtensions: true,
|
|
70
|
-
rewriteRelativeImportExtensions: true,
|
|
71
|
-
declaration: true,
|
|
72
|
-
emitDeclarationOnly: true,
|
|
73
|
-
skipLibCheck: false,
|
|
74
|
-
};
|
|
75
|
-
const input = path.resolve(sdkIn!);
|
|
76
|
-
const host = ts.createCompilerHost(compilerOptions);
|
|
77
|
-
const getSourceFile = host.getSourceFile.bind(host);
|
|
78
|
-
host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) =>
|
|
79
|
-
path.resolve(fileName) === input
|
|
80
|
-
? ts.createSourceFile(fileName, sdkSource, languageVersion, true)
|
|
81
|
-
: getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
|
|
82
|
-
let output = "";
|
|
83
|
-
host.writeFile = (fileName, text) => {
|
|
84
|
-
if (fileName.endsWith("core.d.ts")) output = text;
|
|
85
|
-
};
|
|
86
|
-
const program = ts.createProgram([input], compilerOptions, host);
|
|
87
|
-
const errors = ts
|
|
88
|
-
.getPreEmitDiagnostics(program)
|
|
89
|
-
.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
|
|
90
|
-
if (errors.length > 0) {
|
|
91
|
-
throw new Error(
|
|
92
|
-
errors
|
|
93
|
-
.map(
|
|
94
|
-
(diagnostic) =>
|
|
95
|
-
`TS${diagnostic.code} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`,
|
|
96
|
-
)
|
|
97
|
-
.join("\n"),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
const emit = program.emit();
|
|
101
|
-
if (emit.emitSkipped || output.length === 0) {
|
|
102
|
-
throw new Error("generated SQLite SDK declaration emit failed");
|
|
103
|
-
}
|
|
104
|
-
fs.writeFileSync(dtsOut, output.replace(/(from\s+")(\.\.?\/[^\"]+)\.ts(\")/g, "$1$2.js$3"));
|
|
71
|
+
const declarations = fs.readFileSync(path.join(sdkDir, "core.d.ts"), "utf8");
|
|
72
|
+
fs.writeFileSync(dtsOut, generateCoreDeclarations(fs.readFileSync(sdkIn!, "utf8"), declarations, analysis));
|
|
105
73
|
}
|
|
106
74
|
fs.writeFileSync(staticOut!, generateCoreSurface(fs.readFileSync(staticIn!, "utf8"), analysis));
|
|
107
75
|
}
|