@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,243 @@
|
|
|
1
|
+
/** Shared runtime markup shape and diagnostic programs (115). Source bytes,
|
|
2
|
+
* tree indices and type classes are copied; native retains borrowed records,
|
|
3
|
+
* exact literal conversion and the bundled font's glyph coverage capability.
|
|
4
|
+
*/
|
|
5
|
+
interface NscShapeNode {
|
|
6
|
+
readonly kind: number; readonly name: Uint8Array; readonly text: Uint8Array;
|
|
7
|
+
readonly attrs: readonly { name: Uint8Array; value: Uint8Array }[];
|
|
8
|
+
readonly children: readonly number[];
|
|
9
|
+
}
|
|
10
|
+
function nschEmit(out: number[], action: number, code: number, a: number = 0, b: number = 0,
|
|
11
|
+
c: number = 0, d: number = 0, e: number = 0): void { out.push(action, code, a, b, c, d, e); }
|
|
12
|
+
function nschFail(out: number[], code: number, node: number, attr: number = 0,
|
|
13
|
+
offset: number = 0, text: boolean = false): void { nschEmit(out, 255, code, node, attr, offset, text ? 1 : 0); }
|
|
14
|
+
function nschAttr(node: NscShapeNode, name: string): number {
|
|
15
|
+
for (let i = 0; i < node.attrs.length; i++) if (nsceNamed(node.attrs[i]!.name, name)) return i;
|
|
16
|
+
return -1;
|
|
17
|
+
}
|
|
18
|
+
// 0=literal, 1=path/equality, 2=expression, 3=malformed. Attribute braces
|
|
19
|
+
// trim only ASCII space, exactly like the original attribute classifier.
|
|
20
|
+
function nschExpression(value: Uint8Array): number[] {
|
|
21
|
+
if (value.length === 0 || value[0] !== 123) return [0, 0, value.length];
|
|
22
|
+
if (value[value.length - 1] !== 125) return [3, 0, 0];
|
|
23
|
+
const span = nsccTrim(value, 1, value.length - 1), start = span[0]!, end = span[1]!;
|
|
24
|
+
if (start === end) return [3, 0, 0];
|
|
25
|
+
for (let i = start; i + 1 < end; i++) if (value[i] === 61 && value[i + 1] === 61) {
|
|
26
|
+
const left = nsccTrim(value, start, i), right = nsccTrim(value, i + 2, end);
|
|
27
|
+
if (nsccPath(value, left[0]!, left[1]!) && nsccPath(value, right[0]!, right[1]!)) return [1, start, end];
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
return [nsccPath(value, start, end) ? 1 : 2, start, end];
|
|
31
|
+
}
|
|
32
|
+
function nschAttrExpression(out: number[], node: number, attr: number, value: Uint8Array,
|
|
33
|
+
fallback: number, atNode: boolean = false): boolean {
|
|
34
|
+
const form = nschExpression(value);
|
|
35
|
+
if (form[0] === 3) { nschFail(out, fallback, node, atNode ? 0 : attr + 1); return false; }
|
|
36
|
+
if (form[0] === 2) nschEmit(out, 1, 0, node, attr + 1, form[1]!, form[2]! - form[1]!, atNode ? 1 : 0);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
function nschMessage(value: Uint8Array): boolean {
|
|
40
|
+
const colon = nsccFind(value, 0, 58);
|
|
41
|
+
if (colon < 0) return nsccPath(value, 0, value.length);
|
|
42
|
+
return nsccPath(value, 0, colon) && value.length - colon - 1 >= 3 && value[colon + 1] === 123 &&
|
|
43
|
+
value[value.length - 1] === 125 && nsccPath(value, colon + 2, value.length - 1);
|
|
44
|
+
}
|
|
45
|
+
function nschText(out: number[], index: number, text: Uint8Array): boolean {
|
|
46
|
+
let cursor = 0;
|
|
47
|
+
while (true) {
|
|
48
|
+
const open = nsccFind(text, cursor, 123);
|
|
49
|
+
if (open < 0) break;
|
|
50
|
+
const close = nsccFind(text, open, 125);
|
|
51
|
+
if (close < 0) { nschFail(out, 22, index, 0, open, true); return false; }
|
|
52
|
+
const span = nsccTrim(text, open + 1, close);
|
|
53
|
+
if (!nsccPath(text, span[0]!, span[1]!)) nschEmit(out, 4, 0, index, 0, span[0]!, span[1]! - span[0]!, open);
|
|
54
|
+
cursor = close + 1;
|
|
55
|
+
}
|
|
56
|
+
nschEmit(out, 5, 0, index); // literal coverage follows every interpolation
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
function nschMenuItem(nodes: readonly NscShapeNode[], index: number, out: number[]): boolean {
|
|
60
|
+
const node = nodes[index]!; let press = false;
|
|
61
|
+
for (let i = 0; i < node.attrs.length; i++) {
|
|
62
|
+
const attr = node.attrs[i]!;
|
|
63
|
+
if (nsceNamed(attr.name, "on-press")) {
|
|
64
|
+
press = true;
|
|
65
|
+
if (!nschMessage(attr.value)) { nschFail(out, 19, index, i + 1); return false; }
|
|
66
|
+
} else if (nsceNamed(attr.name, "disabled")) {
|
|
67
|
+
if (!nschAttrExpression(out, index, i, attr.value, 20)) return false;
|
|
68
|
+
} else { nschFail(out, 16, index, i + 1); return false; }
|
|
69
|
+
}
|
|
70
|
+
if (!press) { nschFail(out, 17, index); return false; }
|
|
71
|
+
let runs = 0;
|
|
72
|
+
for (const child of node.children) {
|
|
73
|
+
const run = nodes[child]!;
|
|
74
|
+
if (run.kind !== 1) { nschFail(out, 18, child); return false; }
|
|
75
|
+
if (++runs > 1) { nschFail(out, 7, child); return false; }
|
|
76
|
+
if (!nschText(out, child, run.text)) return false;
|
|
77
|
+
}
|
|
78
|
+
if (runs === 0) { nschFail(out, 18, index); return false; }
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
function nschMenuChildren(nodes: readonly NscShapeNode[], index: number, out: number[]): number {
|
|
82
|
+
let previous = -1, count = 0;
|
|
83
|
+
for (const childIndex of nodes[index]!.children) {
|
|
84
|
+
const child = nodes[childIndex]!;
|
|
85
|
+
if (child.kind === 0) {
|
|
86
|
+
if (nsceNamed(child.name, "menu-item")) {
|
|
87
|
+
count++;
|
|
88
|
+
if (!nschMenuItem(nodes, childIndex, out)) return -1;
|
|
89
|
+
} else if (nsceNamed(child.name, "separator")) {
|
|
90
|
+
if (child.attrs.length !== 0 || child.children.length !== 0) { nschFail(out, 12, childIndex); return -1; }
|
|
91
|
+
count++;
|
|
92
|
+
} else { nschFail(out, 11, childIndex); return -1; }
|
|
93
|
+
} else if (child.kind === 2) {
|
|
94
|
+
if (nschAttr(child, "each") < 0) { nschFail(out, 13, childIndex); return -1; }
|
|
95
|
+
if (nschAttr(child, "as") < 0) { nschFail(out, 14, childIndex); return -1; }
|
|
96
|
+
if (child.children.length === 0) { nschFail(out, 15, childIndex); return -1; }
|
|
97
|
+
const repeated = nschMenuChildren(nodes, childIndex, out);
|
|
98
|
+
if (repeated < 0) return -1;
|
|
99
|
+
if (repeated === 0) { nschFail(out, 11, childIndex); return -1; }
|
|
100
|
+
count += repeated;
|
|
101
|
+
} else if (child.kind === 3) {
|
|
102
|
+
const test = nschAttr(child, "test");
|
|
103
|
+
if (test < 0) { nschFail(out, 23, childIndex); return -1; }
|
|
104
|
+
if (!nschAttrExpression(out, childIndex, test, child.attrs[test]!.value, 24, true)) return -1;
|
|
105
|
+
const nested = nschMenuChildren(nodes, childIndex, out); if (nested < 0) return -1; count += nested;
|
|
106
|
+
} else if (child.kind === 4) {
|
|
107
|
+
if (previous !== 2 && previous !== 3) { nschFail(out, 21, childIndex); return -1; }
|
|
108
|
+
const nested = nschMenuChildren(nodes, childIndex, out); if (nested < 0) return -1; count += nested;
|
|
109
|
+
} else { nschFail(out, 11, childIndex); return -1; }
|
|
110
|
+
previous = child.kind;
|
|
111
|
+
}
|
|
112
|
+
return count;
|
|
113
|
+
}
|
|
114
|
+
function nschShape(r: NscElementReader, mode: number, out: number[]): void {
|
|
115
|
+
const count = r.word(), nodes: NscShapeNode[] = [], parents = new Uint8Array(count);
|
|
116
|
+
if (count === 0 || count > r.bytes.length - r.at) throw new Error("invalid shape node count");
|
|
117
|
+
for (let i = 0; i < count; i++) {
|
|
118
|
+
const kind = r.word(), name = r.blob(), text = r.blob(), attrs: { name: Uint8Array; value: Uint8Array }[] = [];
|
|
119
|
+
if (kind > 8) throw new Error("invalid shape node kind");
|
|
120
|
+
const ac = r.word(); for (let a = 0; a < ac; a++) attrs.push({ name: r.blob(), value: r.blob() });
|
|
121
|
+
const cc = r.word(), children: number[] = [];
|
|
122
|
+
for (let c = 0; c < cc; c++) {
|
|
123
|
+
const child = r.word();
|
|
124
|
+
if (child <= i || child >= count || parents[child] !== 0) throw new Error("invalid shape tree edge");
|
|
125
|
+
parents[child] = 1; children.push(child);
|
|
126
|
+
}
|
|
127
|
+
nodes.push({ kind, name, text, attrs, children });
|
|
128
|
+
}
|
|
129
|
+
for (let i = 1; i < count; i++) if (parents[i] !== 1) throw new Error("unreachable shape node");
|
|
130
|
+
const weights = r.names(), colors = r.names(), alignments = r.names(), node = nodes[0]!;
|
|
131
|
+
if (mode === 0) {
|
|
132
|
+
if (node.attrs.length !== 0) { nschFail(out, 9, 0, 1); return; }
|
|
133
|
+
const items = nschMenuChildren(nodes, 0, out);
|
|
134
|
+
if (items === 0) nschFail(out, 10, 0);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
for (let i = 0; i < node.attrs.length; i++) {
|
|
138
|
+
const attr = node.attrs[i]!;
|
|
139
|
+
if (mode === 2) {
|
|
140
|
+
if (!nsceNamed(attr.name, "text-alignment")) { nschFail(out, 25, 0, i + 1); return; }
|
|
141
|
+
if (!nsceIn(attr.value, alignments)) { nschFail(out, 26, 0, i + 1); return; }
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const form = nschExpression(attr.value);
|
|
145
|
+
if (nsceNamed(attr.name, "weight")) {
|
|
146
|
+
if (form[0] === 0 && !nsceIn(attr.value, weights)) { nschFail(out, 1, 0, i + 1); return; }
|
|
147
|
+
} else if (nsceNamed(attr.name, "scale")) {
|
|
148
|
+
if (form[0] === 0) nschEmit(out, 2, 0, 0, i + 1);
|
|
149
|
+
} else if (nsceOne(attr.name, ["mono", "italic", "underline"])) {
|
|
150
|
+
// These channels use the same structural expression check.
|
|
151
|
+
} else if (nsceNamed(attr.name, "foreground")) {
|
|
152
|
+
if (!nsceIn(attr.value, colors)) { nschFail(out, form[0] === 0 ? 3 : 4, 0, i + 1); return; }
|
|
153
|
+
continue;
|
|
154
|
+
} else { nschFail(out, 5, 0, i + 1); return; }
|
|
155
|
+
if (!nschAttrExpression(out, 0, i, attr.value, 20)) return;
|
|
156
|
+
}
|
|
157
|
+
let runs = 0;
|
|
158
|
+
for (const child of node.children) {
|
|
159
|
+
if (nodes[child]!.kind !== 1) { nschFail(out, mode === 1 ? 6 : 27, child); return; }
|
|
160
|
+
if (++runs > 1) { nschFail(out, 7, child); return; }
|
|
161
|
+
}
|
|
162
|
+
if (runs === 0) nschFail(out, mode === 1 ? 6 : 27, 0);
|
|
163
|
+
}
|
|
164
|
+
function nschCoverage(r: NscElementReader, out: number[]): void {
|
|
165
|
+
const text = r.blob(); let at = 0;
|
|
166
|
+
while (at < text.length) {
|
|
167
|
+
const first = text[at]!;
|
|
168
|
+
if (first === 123) { const close = nsccFind(text, at + 1, 125); at = close < 0 ? text.length : close + 1; continue; }
|
|
169
|
+
const size = first < 128 ? 1 : first >= 192 && first < 224 ? 2 : first < 240 && first >= 224 ? 3 : first >= 240 && first < 248 ? 4 : 0;
|
|
170
|
+
if (size === 0) { nschEmit(out, 255, 8, at, 1, 65533); return; }
|
|
171
|
+
if (size > text.length - at) { nschEmit(out, 255, 8, at, text.length - at, 65533); return; }
|
|
172
|
+
let point = first & (size === 1 ? 127 : size === 2 ? 31 : size === 3 ? 15 : 7), valid = true;
|
|
173
|
+
for (let i = 1; i < size; i++) { const b = text[at + i]!; if (b < 128 || b > 191) valid = false; point = point * 64 + (b & 63); }
|
|
174
|
+
if (!valid || size === 2 && point < 128 || size === 3 && point < 2048 || size === 4 && point < 65536 || point > 1114111 || point >= 55296 && point <= 57343) {
|
|
175
|
+
nschEmit(out, 255, 8, at, size, 65533); return;
|
|
176
|
+
}
|
|
177
|
+
if (point >= 32 && point !== 127) nschEmit(out, 3, 0, at, size, point);
|
|
178
|
+
at += size;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function nschTypes(r: NscElementReader, out: number[]): void {
|
|
182
|
+
const count = r.word(), root = r.word(), nodes: number[][] = [], kinds: number[] = [];
|
|
183
|
+
if (count === 0 || count > 64 || root >= count) throw new Error("invalid structural expression tree");
|
|
184
|
+
for (let i = 0; i < count; i++) {
|
|
185
|
+
const row: number[] = []; for (let j = 0; j < 11; j++) row.push(r.word());
|
|
186
|
+
const kind = row[0]!, fn = row[1]!, argc = row[2]!;
|
|
187
|
+
if (kind > 20 || fn > 16 || argc > 4 || row[10]! > 4 || row[9]! > 65535) throw new Error("invalid structural expression node");
|
|
188
|
+
if ((kind === 5 || kind === 6) && row[3]! >= i || kind >= 7 && kind <= 19 && (row[3]! >= i || row[4]! >= i)) throw new Error("invalid structural operand");
|
|
189
|
+
if (kind === 20) {
|
|
190
|
+
const min = fn === 0 || fn === 9 || fn === 10 || fn === 16 ? 2 : fn === 15 ? 3 : 1, max = fn === 2 ? 2 : min;
|
|
191
|
+
if (argc < min || argc > max) throw new Error("invalid structural arity");
|
|
192
|
+
for (let j = 0; j < argc; j++) if (row[5 + j]! >= i) throw new Error("invalid structural argument");
|
|
193
|
+
}
|
|
194
|
+
nodes.push(row);
|
|
195
|
+
}
|
|
196
|
+
for (let i = 0; i < count; i++) {
|
|
197
|
+
const n = nodes[i]!, kind = n[0]!, fn = n[1]!, left = kinds[n[3]!] ?? 0, right = kinds[n[4]!] ?? 0;
|
|
198
|
+
let result = 0, error = 0;
|
|
199
|
+
const badNumber = (k: number): boolean => k !== 0 && k !== 2 && k !== 3;
|
|
200
|
+
if (kind < 4) result = kind === 0 ? 2 : kind === 1 ? 3 : kind === 2 ? 1 : 4;
|
|
201
|
+
else if (kind === 4) result = n[10]!;
|
|
202
|
+
else if (kind === 5) { result = left; if (badNumber(left)) error = 1; }
|
|
203
|
+
else if (kind === 6) { result = 4; if (left !== 0 && left !== 4) error = 2; }
|
|
204
|
+
else if (kind >= 7 && kind <= 10) {
|
|
205
|
+
result = kind === 10 ? 3 : left === 0 || right === 0 ? 0 : left === 2 && right === 2 ? 2 : 3;
|
|
206
|
+
if (badNumber(left) || badNumber(right)) error = 3;
|
|
207
|
+
} else if (kind === 11) result = 1;
|
|
208
|
+
else if (kind === 12 || kind === 13) result = 4;
|
|
209
|
+
else if (kind >= 14 && kind <= 17) { result = 4; if (badNumber(left) || badNumber(right)) error = 4; }
|
|
210
|
+
else if (kind === 18 || kind === 19) { result = 4; if (left !== 0 && left !== 4 || right !== 0 && right !== 4) error = 2; }
|
|
211
|
+
else {
|
|
212
|
+
const a = kinds[n[5]!] ?? 0, b = kinds[n[6]!] ?? 0, c = kinds[n[7]!] ?? 0;
|
|
213
|
+
const bad = (k: number, expected: number): boolean => k !== 0 && k !== expected;
|
|
214
|
+
result = fn === 9 || fn === 10 ? a === 0 || b === 0 ? 0 : a === 2 && b === 2 ? 2 : 3 : fn === 11 ? a : fn >= 12 && fn <= 14 ? 2 : 1;
|
|
215
|
+
if (fn === 0) { if (badNumber(a) || bad(b, 2)) error = 32 + fn; }
|
|
216
|
+
else if (fn === 2) { if (badNumber(a) || n[2]! > 1 && bad(b, 2)) error = 32 + fn; }
|
|
217
|
+
else if (fn === 1 || fn >= 3 && fn <= 5) { if (bad(a, 2)) error = 32 + fn; }
|
|
218
|
+
else if (fn >= 6 && fn <= 8) { if (bad(a, 1)) error = 32 + fn; }
|
|
219
|
+
else if (fn === 9 || fn === 10) { if (badNumber(a) || badNumber(b)) error = 32 + fn; }
|
|
220
|
+
else if (fn >= 11 && fn <= 14) { if (badNumber(a)) error = 32 + fn; }
|
|
221
|
+
else if (fn === 15) { if (bad(a, 2) || bad(b, 1) || bad(c, 1)) error = 32 + fn; }
|
|
222
|
+
else if (bad(a, 2) || bad(b, 2)) error = 32 + fn;
|
|
223
|
+
}
|
|
224
|
+
if (error !== 0) { nschEmit(out, 255, error, i, n[9]!); return; }
|
|
225
|
+
kinds.push(result);
|
|
226
|
+
}
|
|
227
|
+
nschEmit(out, 0, 0, kinds[root]!);
|
|
228
|
+
}
|
|
229
|
+
function nscvMarkupShapes(input: Uint8Array): Uint8Array {
|
|
230
|
+
if (input.length < 4 || input[0] !== 115 || input[1] !== 1 || input[2]! > 4 || input[3]! > 1) throw new Error("invalid markup shape header");
|
|
231
|
+
const r = new NscElementReader(input), out: number[] = [], mode = input[2]!;
|
|
232
|
+
if (mode < 3) nschShape(r, mode, out);
|
|
233
|
+
else if (mode === 3) nschTypes(r, out);
|
|
234
|
+
else nschCoverage(r, out);
|
|
235
|
+
if (r.at !== input.length) throw new Error("trailing markup shape facts");
|
|
236
|
+
const count = out.length / 7, bytes = new Uint8Array(input[3] === 0 ? 16 : 16 + count * 48), wire = new DataView(bytes.buffer);
|
|
237
|
+
bytes[0] = 115; bytes[1] = 1; bytes[2] = input[3]!; wire.setFloat64(8, count, true);
|
|
238
|
+
if (input[3] === 1) for (let i = 0; i < count; i++) {
|
|
239
|
+
const at = 16 + i * 48, from = i * 7; bytes[at] = out[from]!; bytes[at + 1] = out[from + 1]!;
|
|
240
|
+
for (let j = 0; j < 5; j++) wire.setFloat64(at + 8 + j * 8, out[from + j + 2]!, true);
|
|
241
|
+
}
|
|
242
|
+
return bytes;
|
|
243
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/** Specialized runtime markup programs (112). The policy sequences admission,
|
|
2
|
+
* evaluation, scope changes, child construction and publication; native supplies
|
|
3
|
+
* typed reflection, exact conversion, borrowed storage and builder capabilities.
|
|
4
|
+
*/
|
|
5
|
+
function nscsAttrs(node: NscElementNode, out: number[], names: readonly string[], error: number, skipKind: boolean): boolean {
|
|
6
|
+
for (let i = 0; i < node.attrs.length; i++) {
|
|
7
|
+
const name = node.attrs[i]!.name;
|
|
8
|
+
if (skipKind && nsceNamed(name, "kind")) continue;
|
|
9
|
+
let selected = -1;
|
|
10
|
+
for (let j = 0; j < names.length; j++) if (names[j] === "on-*" ? nsceStartsEvent(name) : nsceNamed(name, names[j]!)) { selected = j; break; }
|
|
11
|
+
if (selected < 0) { nsceFail(out, error); return false; }
|
|
12
|
+
nsceEmit(out, selected + 1, 0, i);
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
// Source-known shapes are admitted by static lowering. These programs retain
|
|
17
|
+
// first-occurrence channels in the static engine's fixed evaluation order.
|
|
18
|
+
function nscsStaticAttrs(node: NscElementNode, out: number[], names: readonly string[]): void {
|
|
19
|
+
for (let i = 0; i < names.length; i++) {
|
|
20
|
+
const index = nsceAttr(node, names[i]!);
|
|
21
|
+
if (index >= 0) nsceEmit(out, i + 1, 0, index);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function nscsNode(r: NscElementReader, out: number[], mode: number): void {
|
|
25
|
+
const node = nsceNode(r);
|
|
26
|
+
const kind = mode === 14 ? r.word() : 0;
|
|
27
|
+
const windowFacts = mode === 0 ? [r.flag(), r.flag(), r.flag(), r.flag()] : [];
|
|
28
|
+
const full = mode === 1 ? r.flag() : false;
|
|
29
|
+
if (mode === 22) {
|
|
30
|
+
nscsStaticAttrs(node, out, ["label", "width", "height", "min-width", "grow", "key", "global-key"]);
|
|
31
|
+
nsceEmit(out, 100);
|
|
32
|
+
if (node.children.length > 1) nsceEmit(out, 101, 0, 1);
|
|
33
|
+
nsceEmit(out, 200); return;
|
|
34
|
+
}
|
|
35
|
+
if (mode === 23) {
|
|
36
|
+
nscsStaticAttrs(node, out, ["gap", "key", "global-key"]);
|
|
37
|
+
nsceEmit(out, 100);
|
|
38
|
+
nsceEmit(out, 200); return;
|
|
39
|
+
}
|
|
40
|
+
if (mode === 24) {
|
|
41
|
+
nscsStaticAttrs(node, out, ["gap", "grow", "key", "global-key", "label"]);
|
|
42
|
+
nsceEmit(out, 100);
|
|
43
|
+
nsceEmit(out, 200); return;
|
|
44
|
+
}
|
|
45
|
+
if (mode === 25) {
|
|
46
|
+
nscsStaticAttrs(node, out, ["title", "description", "meta", "indicator", "icon", "variant", "connector", "selected", "on-press", "key", "global-key"]);
|
|
47
|
+
nsceEmit(out, 200); return;
|
|
48
|
+
}
|
|
49
|
+
if (mode === 26) {
|
|
50
|
+
nscsStaticAttrs(node, out, ["y-min", "y-max", "grid-lines", "baseline", "x-labels", "y-labels", "hover-details", "stroke-width", "width", "height", "grow", "padding", "key", "global-key", "label"]);
|
|
51
|
+
nsceEmit(out, 100);
|
|
52
|
+
for (let i = 0; i < node.children.length; i++) nsceEmit(out, 101, 0, i);
|
|
53
|
+
nsceEmit(out, 200); return;
|
|
54
|
+
}
|
|
55
|
+
if (mode === 27) {
|
|
56
|
+
nscsStaticAttrs(node, out, ["kind", "values", "color", "label"]);
|
|
57
|
+
nsceEmit(out, 200); return;
|
|
58
|
+
}
|
|
59
|
+
if (mode === 28) {
|
|
60
|
+
nscsStaticAttrs(node, out, ["src", "controls", "autoplay", "loop", "muted", "width", "height", "grow", "label", "key", "global-key"]);
|
|
61
|
+
nsceEmit(out, 200); return;
|
|
62
|
+
}
|
|
63
|
+
if (mode === 29) {
|
|
64
|
+
nscsStaticAttrs(node, out, ["source", "on-link", "on-details", "details-expanded", "images", "issue-link-base"]);
|
|
65
|
+
nsceEmit(out, 200); return;
|
|
66
|
+
}
|
|
67
|
+
if (mode === 30) {
|
|
68
|
+
nscsStaticAttrs(node, out, ["source", "language", "line-numbers", "added-lines", "removed-lines", "editable", "on-input", "wrap", "width", "height", "min-width", "grow", "label", "key", "global-key"]);
|
|
69
|
+
nsceEmit(out, 200); return;
|
|
70
|
+
}
|
|
71
|
+
if (mode === 31) {
|
|
72
|
+
// Inherited slot steps interpolate in their lexical site scope; ordinary
|
|
73
|
+
// steps use the stepper's scope. The step array precedes every label.
|
|
74
|
+
const steps = r.word(), slot = r.flag();
|
|
75
|
+
if (slot ? node.children.length !== 1 : steps !== node.children.length) throw new Error("invalid static stepper facts");
|
|
76
|
+
nscsStaticAttrs(node, out, ["active", "key", "global-key", "label"]);
|
|
77
|
+
nsceEmit(out, 100);
|
|
78
|
+
for (let i = 0; i < steps; i++) nsceEmit(out, slot ? 102 : 101, 0, i);
|
|
79
|
+
nsceEmit(out, 200); return;
|
|
80
|
+
}
|
|
81
|
+
if (mode === 2) {
|
|
82
|
+
if (node.children.length !== 0) { nsceFail(out, 1, 1); return; }
|
|
83
|
+
if (!nscsAttrs(node, out, ["source", "on-link", "on-details", "details-expanded", "images", "issue-link-base"], 2, true)) return;
|
|
84
|
+
if (nsceAttr(node, "source") < 0) { nsceFail(out, 3, 0); return; }
|
|
85
|
+
nsceEmit(out, 200); return;
|
|
86
|
+
}
|
|
87
|
+
if (mode === 3) {
|
|
88
|
+
if (node.children.length !== 0) { nsceFail(out, 4, 1); return; }
|
|
89
|
+
if (!nscsAttrs(node, out, ["source", "language", "line-numbers", "added-lines", "removed-lines", "editable", "on-input", "wrap", "width", "height", "min-width", "grow", "key", "global-key", "label"], 5, true)) return;
|
|
90
|
+
if (nsceAttr(node, "source") < 0) { nsceFail(out, 6, 0); return; }
|
|
91
|
+
nsceEmit(out, 200); return;
|
|
92
|
+
}
|
|
93
|
+
if (mode === 4) {
|
|
94
|
+
if (!nscsAttrs(node, out, ["active", "key", "global-key", "label"], 7, true)) return;
|
|
95
|
+
if (nsceAttr(node, "active") < 0) { nsceFail(out, 8, 0); return; }
|
|
96
|
+
nsceEmit(out, 100); return;
|
|
97
|
+
}
|
|
98
|
+
if (mode === 5) {
|
|
99
|
+
if (!nscsAttrs(node, out, ["label", "width", "height", "min-width", "grow", "key", "global-key"], 9, true)) return;
|
|
100
|
+
let entry = false, actions = false;
|
|
101
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
102
|
+
const child = node.children[i]!;
|
|
103
|
+
if (child.kind !== 0) { nsceFail(out, 10, i + 1); return; }
|
|
104
|
+
if (nsceNamed(child.name, "textarea")) {
|
|
105
|
+
if (entry || actions) { nsceFail(out, 10, i + 1); return; }
|
|
106
|
+
nsceEmit(out, 100, 0, i); entry = true;
|
|
107
|
+
} else if (nsceNamed(child.name, "input-group-actions")) {
|
|
108
|
+
if (!entry) { nsceFail(out, 11, i + 1); return; }
|
|
109
|
+
if (actions) { nsceFail(out, 10, i + 1); return; }
|
|
110
|
+
nsceEmit(out, 101, 0, i); actions = true;
|
|
111
|
+
} else { nsceFail(out, 10, i + 1); return; }
|
|
112
|
+
}
|
|
113
|
+
if (!entry) { nsceFail(out, 11, 0); return; }
|
|
114
|
+
nsceEmit(out, 200); return;
|
|
115
|
+
}
|
|
116
|
+
if (mode === 6) {
|
|
117
|
+
if (!nscsAttrs(node, out, ["gap", "key", "global-key"], 12, true)) return;
|
|
118
|
+
for (let i = 0; i < node.children.length; i++) if (node.children[i]!.kind === 1) { nsceFail(out, 13, i + 1); return; }
|
|
119
|
+
nsceEmit(out, 100); nsceEmit(out, 200); return;
|
|
120
|
+
}
|
|
121
|
+
if (mode === 7) {
|
|
122
|
+
if (!nscsAttrs(node, out, ["gap", "grow", "key", "global-key", "label"], 14, true)) return;
|
|
123
|
+
nsceEmit(out, 100); nsceEmit(out, 200); return;
|
|
124
|
+
}
|
|
125
|
+
if (mode === 8) {
|
|
126
|
+
if (node.children.length !== 0) { nsceFail(out, 15, 1); return; }
|
|
127
|
+
if (!nscsAttrs(node, out, ["title", "description", "meta", "indicator", "icon", "variant", "connector", "selected", "on-press", "on-*", "key", "global-key"], 16, true)) return;
|
|
128
|
+
if (nsceAttr(node, "title") < 0) { nsceFail(out, 17, 0); return; }
|
|
129
|
+
nsceEmit(out, 200); return;
|
|
130
|
+
}
|
|
131
|
+
if (mode === 9) {
|
|
132
|
+
if (!nscsAttrs(node, out, ["on-*", "y-min", "y-max", "grid-lines", "baseline", "x-labels", "y-labels", "hover-details", "stroke-width", "width", "height", "grow", "padding", "key", "global-key", "label"], 18, true)) return;
|
|
133
|
+
if (node.children.length === 0) { nsceFail(out, 19, 0); return; }
|
|
134
|
+
nsceEmit(out, 100);
|
|
135
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
136
|
+
if (!nsceMetadata(node.children[i]!, "series")) { nsceFail(out, 20, i + 1); return; }
|
|
137
|
+
nsceEmit(out, 101, 0, i);
|
|
138
|
+
}
|
|
139
|
+
nsceEmit(out, 200); return;
|
|
140
|
+
}
|
|
141
|
+
if (mode === 10) {
|
|
142
|
+
if (node.children.length !== 0) { nsceFail(out, 21, 1); return; }
|
|
143
|
+
if (!nscsAttrs(node, out, ["src", "controls", "autoplay", "loop", "muted", "width", "height", "grow", "label", "key", "global-key"], 22, true)) return;
|
|
144
|
+
nsceEmit(out, 200); return;
|
|
145
|
+
}
|
|
146
|
+
if (mode === 11) {
|
|
147
|
+
if (node.children.length !== 0) { nsceFail(out, 23, 1); return; }
|
|
148
|
+
if (!nscsAttrs(node, out, ["kind", "values", "color", "label"], 24, false)) return;
|
|
149
|
+
if (nsceAttr(node, "values") < 0) { nsceFail(out, 25, 0); return; }
|
|
150
|
+
nsceEmit(out, 200); return;
|
|
151
|
+
}
|
|
152
|
+
if (mode === 12) {
|
|
153
|
+
for (const attr of node.attrs) if (nsceOne(attr.name, ["wrap", "overflow"])) { nsceFail(out, 26, 0); return; }
|
|
154
|
+
nsceEmit(out, 100);
|
|
155
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
156
|
+
const child = node.children[i]!;
|
|
157
|
+
if (child.kind === 1) nsceEmit(out, 101, 0, i);
|
|
158
|
+
else if (nsceMetadata(child, "span")) nsceEmit(out, 102, 0, i);
|
|
159
|
+
else { nsceFail(out, 27, i + 1); return; }
|
|
160
|
+
}
|
|
161
|
+
nsceEmit(out, 200); return;
|
|
162
|
+
}
|
|
163
|
+
if (mode === 13 || mode === 21) {
|
|
164
|
+
nsceEmit(out, 100); // shared span-shape capability precedes every evaluation
|
|
165
|
+
const names = ["weight", "scale", "mono", "italic", "underline", "foreground"];
|
|
166
|
+
if (mode === 21) {
|
|
167
|
+
// Static views evaluate the first occurrence of each channel in this
|
|
168
|
+
// order, independently of the source attribute order.
|
|
169
|
+
for (let j = 0; j < names.length; j++) {
|
|
170
|
+
const index = nsceAttr(node, names[j]!);
|
|
171
|
+
if (index >= 0) nsceEmit(out, j + 1, 0, index);
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
for (let i = 0; i < node.attrs.length; i++) {
|
|
175
|
+
for (let j = 0; j < names.length; j++) if (nsceNamed(node.attrs[i]!.name, names[j]!)) nsceEmit(out, j + 1, 0, i);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
nsceEmit(out, 101); nsceEmit(out, 200); return;
|
|
179
|
+
}
|
|
180
|
+
if (mode === 14) {
|
|
181
|
+
if (!nsceNamed(node.name, "step") || kind !== 0) { nsceFail(out, 28, 0); return; }
|
|
182
|
+
for (const attr of node.attrs) if (!nsceNamed(attr.name, "kind")) { nsceFail(out, 29, 0); return; }
|
|
183
|
+
nsceEmit(out, 101); return;
|
|
184
|
+
}
|
|
185
|
+
if (mode === 16) {
|
|
186
|
+
for (let i = 0; i < node.attrs.length; i++) if (!nsceOne(node.attrs[i]!.name, ["window", "each", "as"])) nsceEmit(out, 1, 0, i);
|
|
187
|
+
nsceEmit(out, 100); nsceEmit(out, 200); return;
|
|
188
|
+
}
|
|
189
|
+
if (mode === 0) {
|
|
190
|
+
const nested = windowFacts[0]!, full = windowFacts[1]!, windowsFull = windowFacts[2]!, duplicate = windowFacts[3]!;
|
|
191
|
+
if (nested) { nsceFail(out, 30, 0); return; }
|
|
192
|
+
if (full || node.children.length !== 1 || (node.children[0]!.kind !== 0 && node.children[0]!.kind !== 6)) { nsceFail(out, 31, 0); return; }
|
|
193
|
+
if (nsceAttr(node, "id") < 0) { nsceFail(out, 32, 0); return; }
|
|
194
|
+
if (nsceAttr(node, "as") < 0) { nsceFail(out, 33, 0); return; }
|
|
195
|
+
if (windowsFull) { nsceFail(out, 34, 0); return; }
|
|
196
|
+
if (duplicate) { nsceFail(out, 35, 0); return; }
|
|
197
|
+
for (let i = 1; i <= 6; i++) nsceEmit(out, i);
|
|
198
|
+
nsceEmit(out, 100); // exact logical range fact, before estimator lookup
|
|
199
|
+
if (nsceAttr(node, "extent-estimate") >= 0) nsceEmit(out, 7);
|
|
200
|
+
nsceEmit(out, 101); nsceEmit(out, 102); nsceEmit(out, 103); nsceEmit(out, 200); return;
|
|
201
|
+
}
|
|
202
|
+
if (mode === 1) {
|
|
203
|
+
if (nsceAttr(node, "window") < 0) { nsceFail(out, 36, 0); return; }
|
|
204
|
+
nsceEmit(out, 100); // lookup, admission, then consumed publication
|
|
205
|
+
if (nsceAttr(node, "each") < 0) { nsceFail(out, 37, 0); return; }
|
|
206
|
+
if (nsceAttr(node, "as") < 0) { nsceFail(out, 38, 0); return; }
|
|
207
|
+
if (full || node.children.length !== 1) { nsceFail(out, 39, 0); return; }
|
|
208
|
+
nsceEmit(out, 101); return;
|
|
209
|
+
}
|
|
210
|
+
throw new Error("invalid specialized node mode");
|
|
211
|
+
}
|
|
212
|
+
function nscvMarkupSpecialized(input: Uint8Array): Uint8Array {
|
|
213
|
+
if (input.length < 4 || input[0] !== 112 || input[1] !== 1 || input[2]! > 31 || input[3]! > 1) throw new Error("invalid specialized header");
|
|
214
|
+
const r = new NscElementReader(input), out: number[] = [], mode = input[2]!;
|
|
215
|
+
if (mode === 15) {
|
|
216
|
+
const count = r.word(), expected = r.word();
|
|
217
|
+
if (count !== expected) { nsceFail(out, 40); }
|
|
218
|
+
else { for (let i = 0; i < count; i++) nsceEmit(out, 1, 0, i); nsceEmit(out, 100); nsceEmit(out, 200); }
|
|
219
|
+
} else if (mode === 17) {
|
|
220
|
+
const phase = r.word(), admitted = r.flag();
|
|
221
|
+
if (phase > 2) throw new Error("invalid virtual window phase");
|
|
222
|
+
if (!admitted) nsceFail(out, phase === 0 ? 41 : phase === 1 ? 42 : 43); else nsceEmit(out, 0);
|
|
223
|
+
} else if (mode === 18) {
|
|
224
|
+
const virtual = r.flag(), consumed = r.flag();
|
|
225
|
+
if (!virtual) nsceFail(out, 44); else if (consumed) nsceFail(out, 45); else nsceEmit(out, 0);
|
|
226
|
+
} else if (mode === 19) {
|
|
227
|
+
if (!r.flag()) nsceFail(out, 39); else nsceEmit(out, 0);
|
|
228
|
+
} else if (mode === 20) {
|
|
229
|
+
const count = r.word(), capacity = r.word(), duplicate = r.flag();
|
|
230
|
+
if (count >= capacity) nsceFail(out, 34);
|
|
231
|
+
else if (duplicate) nsceFail(out, 35);
|
|
232
|
+
else nsceEmit(out, 0);
|
|
233
|
+
} else nscsNode(r, out, mode);
|
|
234
|
+
if (r.at !== input.length) throw new Error("trailing specialized facts");
|
|
235
|
+
const count = out.length / 7, bytes = new Uint8Array(input[3] === 0 ? 16 : 16 + count * 48), wire = new DataView(bytes.buffer);
|
|
236
|
+
bytes[0] = 112; bytes[1] = 1; bytes[2] = input[3]!; wire.setFloat64(8, count, true);
|
|
237
|
+
if (input[3] === 1) for (let i = 0; i < count; i++) {
|
|
238
|
+
const at = 16 + i * 48, from = i * 7; bytes[at] = out[from]!; bytes[at + 1] = out[from + 1]!;
|
|
239
|
+
for (let j = 0; j < 5; j++) wire.setFloat64(at + 8 + j * 8, out[from + j + 2]!, true);
|
|
240
|
+
}
|
|
241
|
+
return bytes;
|
|
242
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** Markup text/calendar capabilities (103). Byte chunks carry no pointers;
|
|
2
|
+
* exact integer decimal conversion and timestamp division remain native.
|
|
3
|
+
* Results describe either owned bytes or cuts/choices into caller storage.
|
|
4
|
+
* Modes: upper, lower, trim, thousands, pad, date, time, datetime, plural.
|
|
5
|
+
*/
|
|
6
|
+
function nscvMarkupTextSpace(byte: number): boolean {
|
|
7
|
+
return byte === 32 || byte === 9 || byte === 13 || byte === 10;
|
|
8
|
+
}
|
|
9
|
+
function nscvMarkupTextDigits(out: Uint8Array, at: number, value: number, width: number): void {
|
|
10
|
+
for (let i = width - 1; i >= 0; i--) {
|
|
11
|
+
out[at + i] = 48 + value % 10;
|
|
12
|
+
value = Math.floor(value / 10);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function nscvMarkupText(request: Uint8Array): Uint8Array {
|
|
16
|
+
if (request.length < 32 || request[0] !== 103 || request[1] !== 1 || request[2]! > 8)
|
|
17
|
+
throw new Error("invalid markup text header");
|
|
18
|
+
const mode = request[2]!, width = request[3]!, r = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
19
|
+
const length = r.getUint16(4, true);
|
|
20
|
+
if (length > 256 || request.length !== 32 + length || width > (mode === 4 ? 6 : 0) ||
|
|
21
|
+
r.getUint16(6, true) !== 0 || r.getUint32(8, true) !== 0 || r.getUint32(12, true) !== 0 ||
|
|
22
|
+
(mode >= 5 && length !== 0) || r.getUint32(28, true) !== 0)
|
|
23
|
+
throw new Error("invalid markup text storage");
|
|
24
|
+
if (mode < 5 && (r.getUint32(16, true) !== 0 || r.getUint32(20, true) !== 0 || r.getUint32(24, true) !== 0) ||
|
|
25
|
+
mode === 8 && r.getUint32(24, true) !== 0) throw new Error("invalid markup text facts");
|
|
26
|
+
const bytes = request.subarray(32);
|
|
27
|
+
let resultLength = 0, sign = 0, zeros = 0, first = 0, last = length;
|
|
28
|
+
if (mode === 0 || mode === 1) resultLength = length;
|
|
29
|
+
else if (mode === 2) {
|
|
30
|
+
while (first < length && nscvMarkupTextSpace(bytes[first]!)) first++;
|
|
31
|
+
while (last > first && nscvMarkupTextSpace(bytes[last - 1]!)) last--;
|
|
32
|
+
} else if (mode === 3 || mode === 4) {
|
|
33
|
+
if (length === 0 || length > 20) throw new Error("invalid markup decimal length");
|
|
34
|
+
sign = bytes[0] === 45 ? 1 : 0;
|
|
35
|
+
if (length === sign) throw new Error("invalid markup decimal sign");
|
|
36
|
+
for (let i = sign; i < length; i++) if (bytes[i]! < 48 || bytes[i]! > 57)
|
|
37
|
+
throw new Error("invalid markup decimal byte");
|
|
38
|
+
zeros = Math.max(0, width - (length - sign));
|
|
39
|
+
resultLength = length + (mode === 3 ? Math.floor((length - sign - 1) / 3) : 0);
|
|
40
|
+
} else if (mode < 8) {
|
|
41
|
+
const days = r.getFloat64(16, true), seconds = r.getUint32(24, true);
|
|
42
|
+
if (!Number.isSafeInteger(days) || Math.abs(days) > 106751991167301 || seconds >= 86400)
|
|
43
|
+
throw new Error("invalid markup timestamp facts");
|
|
44
|
+
resultLength = days < -719162 || days > 2932896 ? 0 : mode === 5 ? 10 : mode === 6 ? 5 : 16;
|
|
45
|
+
}
|
|
46
|
+
const out = new Uint8Array(16 + resultLength), w = new DataView(out.buffer);
|
|
47
|
+
out[0] = 103; out[1] = 1; out[2] = mode; w.setUint16(8, resultLength, true);
|
|
48
|
+
if (mode === 0 || mode === 1) {
|
|
49
|
+
for (let i = 0; i < length; i++) {
|
|
50
|
+
const b = bytes[i]!;
|
|
51
|
+
out[16 + i] = mode === 0 && b >= 97 && b <= 122 ? b - 32 : mode === 1 && b >= 65 && b <= 90 ? b + 32 : b;
|
|
52
|
+
}
|
|
53
|
+
} else if (mode === 2) {
|
|
54
|
+
w.setUint16(4, first, true); w.setUint16(6, last, true);
|
|
55
|
+
} else if (mode === 3) {
|
|
56
|
+
let at = 16;
|
|
57
|
+
if (sign === 1) out[at++] = 45;
|
|
58
|
+
for (let i = sign; i < length; i++) {
|
|
59
|
+
if (i > sign && (length - i) % 3 === 0) out[at++] = 44;
|
|
60
|
+
out[at++] = bytes[i]!;
|
|
61
|
+
}
|
|
62
|
+
} else if (mode === 4) {
|
|
63
|
+
out[4] = sign; out[5] = zeros; out[6] = length - sign;
|
|
64
|
+
for (let i = 0; i < length; i++) out[16 + i] = bytes[i]!;
|
|
65
|
+
} else if (mode < 8) {
|
|
66
|
+
if (resultLength === 0) { out[3] = 1; return out; }
|
|
67
|
+
// Gregorian eras use exact small integers after the admitted year range.
|
|
68
|
+
const shifted = r.getFloat64(16, true) + 719468, era = Math.floor(shifted / 146097);
|
|
69
|
+
const dayOfEra = shifted - era * 146097;
|
|
70
|
+
const yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36524) - Math.floor(dayOfEra / 146096)) / 365);
|
|
71
|
+
const dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));
|
|
72
|
+
const monthIndex = Math.floor((5 * dayOfYear + 2) / 153), month = monthIndex < 10 ? monthIndex + 3 : monthIndex - 9;
|
|
73
|
+
const year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0), day = dayOfYear - Math.floor((153 * monthIndex + 2) / 5) + 1;
|
|
74
|
+
if (mode !== 6) {
|
|
75
|
+
nscvMarkupTextDigits(out, 16, year, 4); out[20] = 45;
|
|
76
|
+
nscvMarkupTextDigits(out, 21, month, 2); out[23] = 45; nscvMarkupTextDigits(out, 24, day, 2);
|
|
77
|
+
}
|
|
78
|
+
if (mode !== 5) {
|
|
79
|
+
const at = mode === 6 ? 16 : 27, seconds = r.getUint32(24, true);
|
|
80
|
+
if (mode === 7) out[26] = 32;
|
|
81
|
+
nscvMarkupTextDigits(out, at, Math.floor(seconds / 3600), 2); out[at + 2] = 58;
|
|
82
|
+
nscvMarkupTextDigits(out, at + 3, Math.floor(seconds % 3600 / 60), 2);
|
|
83
|
+
}
|
|
84
|
+
} else out[4] = r.getUint32(16, true) === 1 && r.getUint32(20, true) === 0 ? 1 : 2;
|
|
85
|
+
return out;
|
|
86
|
+
}
|