@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,188 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { test } from "node:test";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import { baseContract, coreCases } from "./core_cases.ts";
|
|
10
|
+
|
|
11
|
+
assert.ok(process.argv[2], "run with the compiled corewire path (zig build test-corewire-policy)");
|
|
12
|
+
const corewire = path.resolve(process.argv[2]);
|
|
13
|
+
|
|
14
|
+
test("nested unions in helper arguments retain their decoder type imports", () => {
|
|
15
|
+
const contract = baseContract();
|
|
16
|
+
contract.update_returns_cmd = false;
|
|
17
|
+
contract.types.structs.push({ name: "Envelope", origin: "actions.ts", exported: true,
|
|
18
|
+
fields: [{ name: "choice", type: { kind: "union", name: "Inner" } }] });
|
|
19
|
+
contract.types.unions.push(
|
|
20
|
+
{ name: "Inner", origin: "events.ts", exported: true, arms: [
|
|
21
|
+
{ name: "first", member: null, payload: { kind: "void" } },
|
|
22
|
+
{ name: "second", member: null, payload: { kind: "void" } },
|
|
23
|
+
] },
|
|
24
|
+
{ name: "Outer", origin: "actions.ts", exported: true, arms: [
|
|
25
|
+
{ name: "empty", member: null, payload: { kind: "void" } },
|
|
26
|
+
{ name: "wrapped", member: "value", payload: { kind: "value", name: "Envelope" } },
|
|
27
|
+
] },
|
|
28
|
+
);
|
|
29
|
+
contract.model_helpers.push({ name: "take", params: [{ kind: "union", name: "Outer" }], returns: { kind: "bool" }, arena: false });
|
|
30
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "native-nested-helper-imports-"));
|
|
31
|
+
try {
|
|
32
|
+
fs.writeFileSync(path.join(dir, "input.json"), JSON.stringify(contract, (key, value) => key === "member" && value === null ? undefined : value));
|
|
33
|
+
const result = spawnSync(corewire, ["--sidecar", "input.json", "--facade", "facade.ts"], { cwd: dir, encoding: "utf8" });
|
|
34
|
+
assert.ifError(result.error); assert.equal(result.status, 0, result.stderr);
|
|
35
|
+
fs.writeFileSync(path.join(dir, "events.ts"), 'export type Inner = { readonly kind: "first" } | { readonly kind: "second" };\n');
|
|
36
|
+
fs.writeFileSync(path.join(dir, "actions.ts"), 'import type { Inner } from "./events.ts";\nexport interface Envelope { readonly choice: Inner; }\nexport type Outer = { readonly kind: "empty" } | { readonly kind: "wrapped"; readonly value: Envelope };\n');
|
|
37
|
+
fs.writeFileSync(path.join(dir, "core.ts"), 'import type { Outer } from "./actions.ts";\nexport interface Model { readonly count: number; readonly label: Uint8Array; }\nexport type Msg = { readonly kind: "bump" } | { readonly kind: "label_set"; readonly body: Uint8Array };\nexport function initialModel(): Model { return { count: 0, label: new Uint8Array(0) }; }\nexport function update(model: Model, msg: Msg): Model { return model; }\nexport function take(model: Model, value: Outer): boolean { return value.kind === "wrapped" && value.value.choice.kind === "first"; }\n');
|
|
38
|
+
fs.mkdirSync(path.join(dir, "src"));
|
|
39
|
+
fs.writeFileSync(path.join(dir, "src/core.ts"), 'export type { Model, Msg } from "../core.ts";\n');
|
|
40
|
+
const require = createRequire(new URL("../../packages/core/package.json", import.meta.url));
|
|
41
|
+
const ts = require("@typescript/old");
|
|
42
|
+
const program = ts.createProgram([path.join(dir, "facade.ts")], { noEmit: true, strict: true, skipLibCheck: true,
|
|
43
|
+
target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler, allowImportingTsExtensions: true });
|
|
44
|
+
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
45
|
+
assert.equal(diagnostics.length, 0, diagnostics.map((item: { messageText: string }) => ts.flattenDiagnosticMessageText(item.messageText, "\n")).join("\n"));
|
|
46
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
47
|
+
});
|
|
48
|
+
// Exact diagnostics and complete generated-file hashes captured from the
|
|
49
|
+
// independent native implementation before replacing its admission rules.
|
|
50
|
+
// Mirror hashes include the reviewed stateless-runtime API addition.
|
|
51
|
+
// Mirror hashes also include file-scope host facts: `has_windows` and the
|
|
52
|
+
// virtual extent capability, which the model types forward. Removing that
|
|
53
|
+
// block and nesting the capability back in both model types recovers the
|
|
54
|
+
// previous mirror pins exactly.
|
|
55
|
+
// Facade hashes include exact u32 image identities, nonreplacing file
|
|
56
|
+
// results and exact-range timers. Removing the reviewed timer encoder
|
|
57
|
+
// addition recovers every previous complete facade pin. The byte-key
|
|
58
|
+
// encoder and bounded 4 MiB view changes are also audited against those
|
|
59
|
+
// complete pins; their removal recovers the earlier generator output.
|
|
60
|
+
// Exact audio adds two command records. Removing those two encoder cases
|
|
61
|
+
// recovers every prior complete facade; all other projection pins are retained.
|
|
62
|
+
// Native close/minimize add UTF-8 label records. Removing that encoder block
|
|
63
|
+
// recovers every complete facade from the exact-audio projection.
|
|
64
|
+
// Exact subprocess and cancellation records are independently audited:
|
|
65
|
+
// removing only their encoder cases recovers every preceding complete facade.
|
|
66
|
+
const goldens = JSON.parse(fs.readFileSync(new URL("core_goldens.json", import.meta.url), "utf8")) as Record<string, {
|
|
67
|
+
status: number; diagnostics: string; hashes: Record<string, string>;
|
|
68
|
+
check_status: number; check_diagnostics: string;
|
|
69
|
+
}>;
|
|
70
|
+
const flags = { mirror: "--out", facade: "--facade", profile: "--profile", effective: "--effective-sidecar" };
|
|
71
|
+
for (const item of coreCases()) test(item.name, () => {
|
|
72
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "native-core-contract-"));
|
|
73
|
+
try {
|
|
74
|
+
fs.writeFileSync(path.join(dir, "input.json"), item.input);
|
|
75
|
+
const files = item.mirrorOnly ? ["mirror"] : Object.keys(flags);
|
|
76
|
+
for (const file of files) fs.writeFileSync(path.join(dir, file), "retain");
|
|
77
|
+
const overrides = (item.slots ?? []).flatMap(slot => ["--f64-slot", slot]);
|
|
78
|
+
const args = ["--sidecar", "input.json", ...files.flatMap(file => [flags[file as keyof typeof flags], file]), ...overrides];
|
|
79
|
+
const result = spawnSync(corewire, args, { cwd: dir, encoding: "utf8", maxBuffer: 32 * 1024 * 1024 });
|
|
80
|
+
assert.ifError(result.error); assert.equal(result.signal, null, result.stderr);
|
|
81
|
+
const golden = goldens[item.name]; assert.ok(golden, "missing independent native reference");
|
|
82
|
+
assert.equal(result.status, golden.status, result.stderr); assert.equal(result.stderr, golden.diagnostics);
|
|
83
|
+
for (const file of files) {
|
|
84
|
+
const bytes = fs.readFileSync(path.join(dir, file));
|
|
85
|
+
assert.equal(createHash("sha256").update(bytes).digest("hex"), golden.hashes[file], file);
|
|
86
|
+
if (result.status !== 0) assert.equal(bytes.toString(), "retain", "refusal wrote an output");
|
|
87
|
+
}
|
|
88
|
+
const checked = spawnSync(corewire, ["--sidecar", "input.json", "--check", ...overrides], { cwd: dir, encoding: "utf8", maxBuffer: 32 * 1024 * 1024 });
|
|
89
|
+
assert.ifError(checked.error); assert.equal(checked.signal, null, checked.stderr);
|
|
90
|
+
assert.equal(checked.status, golden.check_status, checked.stderr); assert.equal(checked.stderr, golden.check_diagnostics);
|
|
91
|
+
for (const file of files) assert.equal(createHash("sha256").update(fs.readFileSync(path.join(dir, file))).digest("hex"), golden.hashes[file], "check wrote an output");
|
|
92
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
test("parameterized arena helpers and retained integer estimators keep the attested codecs", () => {
|
|
97
|
+
const contract = baseContract();
|
|
98
|
+
contract.types.structs.push({ name: "Range", origin: "src/events.ts", exported: true, fields: [
|
|
99
|
+
{ name: "first", type: { kind: "i64" } }, { name: "geometry", type: { kind: "f64" } },
|
|
100
|
+
] });
|
|
101
|
+
contract.model_helpers.push(
|
|
102
|
+
{ name: "rows", params: [{ kind: "value", name: "Range" }, { kind: "optional", inner: { kind: "bytes" } }], returns: { kind: "slice", elem: { kind: "value", name: "Range" } }, arena: true },
|
|
103
|
+
{ name: "estimate", params: [{ kind: "i64" }], returns: { kind: "f64" }, arena: false },
|
|
104
|
+
);
|
|
105
|
+
contract.integer_slots.push({ slot: "Range.first", class: "i64" }, { slot: "helpers.estimate.params[0]", class: "u64" });
|
|
106
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "native-helper-codecs-"));
|
|
107
|
+
try {
|
|
108
|
+
fs.writeFileSync(path.join(dir, "input.json"), JSON.stringify(contract, (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value));
|
|
109
|
+
const result = spawnSync(corewire, ["--sidecar", "input.json", "--out", "mirror", "--facade", "facade"], { cwd: dir, encoding: "utf8" });
|
|
110
|
+
assert.ifError(result.error); assert.equal(result.status, 0, result.stderr);
|
|
111
|
+
const mirror = fs.readFileSync(path.join(dir, "mirror"), "utf8"), facade = fs.readFileSync(path.join(dir, "facade"), "utf8");
|
|
112
|
+
assert.match(mirror, /pub fn rows\(self: \*const Model, p0: Range, p1: \?\[\]const u8, arena: std.mem.Allocator\)/);
|
|
113
|
+
assert.match(mirror, /pub fn rows\(self: \*const RuntimeModel, p0: Range, p1: \?\[\]const u8, arena: std.mem.Allocator\)/);
|
|
114
|
+
assert.match(mirror, /pub fn snapshotModel/);
|
|
115
|
+
assert.match(mirror, /decoded_model = null/);
|
|
116
|
+
assert.match(mirror, /const args_tuple = \.\{ p0, p1 \}/);
|
|
117
|
+
assert.match(mirror, /\npub fn virtualExtentHelper\(name: \[\]const u8\) \?u32 \{/);
|
|
118
|
+
assert.match(mirror, /\npub fn virtualExtentEstimate\(context: \?\*const anyopaque, index: u64\) f32 \{/);
|
|
119
|
+
assert.equal(mirror.split(" pub const virtualExtentEstimate = shim_root.virtualExtentEstimate;").length, 3, "both model types forward the capability");
|
|
120
|
+
assert.match(mirror, /\npub const has_windows: bool = false;/);
|
|
121
|
+
assert.match(mirror, /callHelper\(\[\]const Range, 0, args, arena\)/);
|
|
122
|
+
assert.match(mirror, /@bitCast\(@as\(u64, @intCast\(index\)\)\)/);
|
|
123
|
+
assert.match(facade, /rows\(nscfCommitted,/);
|
|
124
|
+
assert.match(facade, /estimate\(nscfCommitted,/);
|
|
125
|
+
for (const name of ["virtualExtentHelper", "virtualExtentEstimate", "shim_root", "has_windows", "RuntimeModel", "RuntimeResult", "decoded_model", "restoreCommittedModel"]) {
|
|
126
|
+
const conflicting = structuredClone(contract);
|
|
127
|
+
conflicting.model_helpers[1].name = name;
|
|
128
|
+
conflicting.integer_slots.find(slot => slot.slot === "helpers.estimate.params[0]")!.slot = `helpers.${name}.params[0]`;
|
|
129
|
+
fs.writeFileSync(path.join(dir, "input.json"), JSON.stringify(conflicting, (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value));
|
|
130
|
+
fs.writeFileSync(path.join(dir, "mirror"), "retain");
|
|
131
|
+
const refused = spawnSync(corewire, ["--sidecar", "input.json", "--out", "mirror"], { cwd: dir, encoding: "utf8" });
|
|
132
|
+
assert.ifError(refused.error); assert.equal(refused.status, 1, refused.stderr);
|
|
133
|
+
assert.match(refused.stderr, /collides with a declaration the generated shim/);
|
|
134
|
+
assert.equal(fs.readFileSync(path.join(dir, "mirror"), "utf8"), "retain");
|
|
135
|
+
if (name !== "virtualExtentHelper" && name !== "virtualExtentEstimate") continue;
|
|
136
|
+
const fieldConflict = structuredClone(contract);
|
|
137
|
+
fieldConflict.types.structs[0].fields.push({ name, type: { kind: "f64" } });
|
|
138
|
+
fs.writeFileSync(path.join(dir, "input.json"), JSON.stringify(fieldConflict, (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value));
|
|
139
|
+
const fieldRefused = spawnSync(corewire, ["--sidecar", "input.json", "--out", "mirror"], { cwd: dir, encoding: "utf8" });
|
|
140
|
+
assert.ifError(fieldRefused.error); assert.equal(fieldRefused.status, 1, fieldRefused.stderr);
|
|
141
|
+
assert.match(fieldRefused.stderr, /model field .*collides with a declaration the generated shim/);
|
|
142
|
+
assert.equal(fs.readFileSync(path.join(dir, "mirror"), "utf8"), "retain");
|
|
143
|
+
}
|
|
144
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("the windows helper fact is published at file scope", () => {
|
|
148
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "native-windows-fact-"));
|
|
149
|
+
try {
|
|
150
|
+
for (const declared of [false, true]) {
|
|
151
|
+
const contract = baseContract();
|
|
152
|
+
if (declared) contract.model_helpers.push({ name: "windows", params: [], returns: { kind: "f64" }, arena: false });
|
|
153
|
+
fs.writeFileSync(path.join(dir, "input.json"), JSON.stringify(contract, (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value));
|
|
154
|
+
const result = spawnSync(corewire, ["--sidecar", "input.json", "--out", "mirror"], { cwd: dir, encoding: "utf8" });
|
|
155
|
+
assert.ifError(result.error); assert.equal(result.status, 0, result.stderr);
|
|
156
|
+
const mirror = fs.readFileSync(path.join(dir, "mirror"), "utf8");
|
|
157
|
+
assert.equal(mirror.split("\npub const has_windows: bool = " + declared + ";\n").length, 2);
|
|
158
|
+
assert.doesNotMatch(mirror, /shim_root/, "no virtual extent capability without numeric helpers or virtual views");
|
|
159
|
+
}
|
|
160
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("Markdown recipe wrapper names reserve only when window policy glue is emitted", () => {
|
|
164
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "native-markdown-collision-"));
|
|
165
|
+
try {
|
|
166
|
+
for (const declaration of ["helper", "type"] as const) for (const enabled of [false, true]) {
|
|
167
|
+
const contract = baseContract();
|
|
168
|
+
if (enabled) contract.abi.exports.push("native_window_policy");
|
|
169
|
+
if (declaration === "helper") {
|
|
170
|
+
contract.model_helpers.push({ name: "nativeMarkdownPolicy", params: [], returns: { kind: "f64" }, arena: false });
|
|
171
|
+
} else {
|
|
172
|
+
contract.types.enums.push({ name: "nativeMarkdownPolicy", origin: "src/core.ts", exported: true, members: ["first", "second"] });
|
|
173
|
+
contract.types.structs[0].fields[1].type = { kind: "enum", name: "nativeMarkdownPolicy" };
|
|
174
|
+
}
|
|
175
|
+
fs.writeFileSync(path.join(dir, "input.json"), JSON.stringify(contract, (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value));
|
|
176
|
+
fs.writeFileSync(path.join(dir, "mirror"), "retain");
|
|
177
|
+
const result = spawnSync(corewire, ["--sidecar", "input.json", "--out", "mirror"], { cwd: dir, encoding: "utf8" });
|
|
178
|
+
assert.ifError(result.error); assert.equal(result.signal, null, result.stderr);
|
|
179
|
+
assert.equal(result.status, enabled ? 1 : 0, result.stderr);
|
|
180
|
+
if (enabled) {
|
|
181
|
+
assert.match(result.stderr, /nativeMarkdownPolicy.*collides with a declaration the generated shim/);
|
|
182
|
+
assert.equal(fs.readFileSync(path.join(dir, "mirror"), "utf8"), "retain", "refusal wrote an output");
|
|
183
|
+
} else {
|
|
184
|
+
assert.doesNotMatch(fs.readFileSync(path.join(dir, "mirror"), "utf8"), /pub fn nativeMarkdownPolicy\(request:/);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
188
|
+
});
|
|
@@ -109,6 +109,60 @@ pub fn Bindings(comptime prefix: []const u8) type {
|
|
|
109
109
|
/// lifetime: valid until the next frame_reset, dispatch entry,
|
|
110
110
|
/// or init.
|
|
111
111
|
pub const boot_cmd = Symbol(fn (cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "boot_cmd");
|
|
112
|
+
/// Optional Native SDK view extension. Versioned tree data evaluated
|
|
113
|
+
/// against the committed TS model; borrowed until frame_reset.
|
|
114
|
+
pub const native_view = Symbol(fn (out: *[*]const u8, len: *usize) callconv(.c) void, "native_view");
|
|
115
|
+
pub const native_media_view = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_media_view");
|
|
116
|
+
pub const native_media_window_view = Symbol(fn (label: [*]const u8, label_len: usize, request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_media_window_view");
|
|
117
|
+
pub const native_virtual_requests = Symbol(fn (label: [*]const u8, label_len: usize, video: [*]const u8, video_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_virtual_requests");
|
|
118
|
+
pub const native_virtual_view = Symbol(fn (label: [*]const u8, label_len: usize, context: [*]const u8, context_len: usize, video: [*]const u8, video_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_virtual_view");
|
|
119
|
+
/// Debug-only development view: prepare a changed markup program, or
|
|
120
|
+
/// return to the compiled view. Results borrow until frame_reset.
|
|
121
|
+
pub const native_dev_view_prepare = Symbol(fn (program: [*]const u8, program_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_dev_view_prepare");
|
|
122
|
+
pub const native_dev_view_reset = Symbol(fn (out: *[*]const u8, len: *usize) callconv(.c) void, "native_dev_view_reset");
|
|
123
|
+
pub const native_window_view = Symbol(fn (label: [*]const u8, label_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_window_view");
|
|
124
|
+
|
|
125
|
+
/// Pure retained radio policy over native tree/eligibility bytes.
|
|
126
|
+
/// The result is borrowed until frame_reset; the host copies it first.
|
|
127
|
+
pub const native_radio_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_radio_policy");
|
|
128
|
+
pub const native_tabs_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_tabs_policy");
|
|
129
|
+
pub const native_tree_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_tree_policy");
|
|
130
|
+
pub const native_list_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_list_policy");
|
|
131
|
+
pub const native_menu_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_menu_policy");
|
|
132
|
+
pub const native_toggle_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_toggle_policy");
|
|
133
|
+
pub const native_accordion_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_accordion_policy");
|
|
134
|
+
pub const native_slider_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_slider_policy");
|
|
135
|
+
pub const native_split_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_split_policy");
|
|
136
|
+
pub const native_scroll_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_scroll_policy");
|
|
137
|
+
pub const native_resizable_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_resizable_policy");
|
|
138
|
+
pub const native_text_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_text_policy");
|
|
139
|
+
|
|
140
|
+
/// Pure timer reconciliation extension. Inputs are borrowed; the host
|
|
141
|
+
/// copies the result and retains the cycle arena until all commands
|
|
142
|
+
/// and subscriptions have been consumed. This call never resets the dispatch frame.
|
|
143
|
+
pub const native_timer_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_timer_policy");
|
|
144
|
+
|
|
145
|
+
/// Pure database reconciliation extension. Inputs are borrowed;
|
|
146
|
+
/// results are copied and finishCycle retains arena reset ownership.
|
|
147
|
+
pub const native_db_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_db_policy");
|
|
148
|
+
|
|
149
|
+
/// Pure named-effect coordination. Borrow inputs, copy outputs; the
|
|
150
|
+
/// host retains command-cycle and completion-frame reset ownership.
|
|
151
|
+
pub const native_effect_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_effect_policy");
|
|
152
|
+
/// Stream decisions borrow input and copy output within the dispatch cycle.
|
|
153
|
+
pub const native_stream_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_stream_policy");
|
|
154
|
+
|
|
155
|
+
/// Pure window reconciliation. Borrow inputs and copy outputs;
|
|
156
|
+
/// view/cycle consumers retain ownership of the compiler frame.
|
|
157
|
+
pub const native_window_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_window_policy");
|
|
158
|
+
|
|
159
|
+
/// Stock-theme decisions. Borrowed requests and copied results retain
|
|
160
|
+
/// dispatch lifetime; finishCycle owns the frame reset.
|
|
161
|
+
pub const native_theme_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_theme_policy");
|
|
162
|
+
|
|
163
|
+
/// Pure status-item reconciliation. Borrowed requests and copied
|
|
164
|
+
/// results retain the cycle arena until finishCycle.
|
|
165
|
+
pub const native_status_policy = Symbol(fn (request: [*]const u8, request_len: usize, out: *[*]const u8, len: *usize) callconv(.c) void, "native_status_policy");
|
|
112
166
|
|
|
113
167
|
// ---------------------------------------------------- dispatch
|
|
114
168
|
pub const dispatch_void = Symbol(fn (tag: u8, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_void");
|
|
@@ -175,6 +229,7 @@ pub fn Bindings(comptime prefix: []const u8) type {
|
|
|
175
229
|
// above) through the ordinary out-pointer pair.
|
|
176
230
|
pub const command_msg = Symbol(fn (name: [*]const u8, name_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "command_msg");
|
|
177
231
|
pub const frame_msg = Symbol(fn (width: f64, height: f64, timestamp_ms: f64, interval_ms: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "frame_msg");
|
|
232
|
+
pub const frame_msg_ns = Symbol(fn (width: f64, height: f64, timestamp_ms: f64, interval_ms: f64, timestamp_ns: [*]const u8, timestamp_ns_len: usize, interval_ns: [*]const u8, interval_ns_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "frame_msg_ns");
|
|
178
233
|
pub const key_msg = Symbol(fn (key: [*]const u8, key_len: usize, shift: u8, control: u8, alt: u8, super_mod: u8, out: *[*]const u8, out_len: *usize) callconv(.c) void, "key_msg");
|
|
179
234
|
pub const pinch_msg = Symbol(fn (window_id: f64, label: [*]const u8, label_len: usize, phase: u32, scale: f64, x: f64, y: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "pinch_msg");
|
|
180
235
|
pub const drop_msg = Symbol(fn (event: [*]const u8, event_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "drop_msg");
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Boundary cases shared by compiled CLI conformance and reference capture.
|
|
2
|
+
import type { CoreContract, TypeRef, RecordType } from "./core_contract.ts";
|
|
3
|
+
export interface Contract extends CoreContract {
|
|
4
|
+
format: number; compiler_version: string; entry: string;
|
|
5
|
+
source_hash: string; build_id: string; model_fingerprint: string;
|
|
6
|
+
has_subscriptions: boolean; has_migrate: boolean; deterministic: boolean; async_free: boolean;
|
|
7
|
+
abi: CoreContract["abi"] & { prefix: string };
|
|
8
|
+
}
|
|
9
|
+
export interface CoreCase { name: string; input: string; slots?: string[]; mirrorOnly?: boolean }
|
|
10
|
+
export function baseContract(): Contract {
|
|
11
|
+
return {
|
|
12
|
+
format: 1, wire_version: 10, abi_version: 2, compiler_version: "0.0.1", entry: "src/core.ts",
|
|
13
|
+
source_hash: "00000000c0ffee00", build_id: "00000000b01dface", model_fingerprint: "00000000a11ce001",
|
|
14
|
+
types: { structs: [{ name: "Model", origin: "src/core.ts", exported: true, fields: [{ name: "count", type: { kind: "i64" } }, { name: "label", type: { kind: "bytes" } }] }], enums: [], unions: [] },
|
|
15
|
+
model: "Model", model_helpers: [], model_unbound: [],
|
|
16
|
+
msg: { name: "Msg", arms: [{ name: "bump", member: null, payload: { kind: "void" } }, { name: "label_set", member: "body", payload: { kind: "bytes" } }], unbound: [] },
|
|
17
|
+
init_returns_cmd: false, update_returns_cmd: true, has_subscriptions: false, has_migrate: false,
|
|
18
|
+
channels: { command_msg: false, frame_msg: false, key_msg: false, pinch_msg: false, drop_msg: false, appearance_msg: null, chrome_msg: null, env_msgs: [] },
|
|
19
|
+
abi: { prefix: "nsc_core_", exports: ["abi_version", "build_id", "set_panic_sink", "init", "collect", "frame_reset", "boot_cmd", "dispatch_void", "dispatch_bytes", "dispatch_number", "dispatch_number_bytes", "dispatch_bool", "dispatch_enum", "dispatch_record", "dispatch_text_input", "dispatch_scroll_state", "subscriptions", "model_snapshot", "persist_snapshot", "restore_model", "migrate_model", "helper_call"], snapshot_format: 1 },
|
|
20
|
+
integer_slots: [{ slot: "Model.count", class: "i64" }], deterministic: true, async_free: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function record(c: Contract, name: string, kind = "node", origin: string | null = "src/core.ts"): RecordType {
|
|
24
|
+
const r: RecordType = { name, origin, exported: true, fields: [{ name: "flag", type: { kind: "bool" } }, { name: "value", type: { kind: "f64" } }] };
|
|
25
|
+
c.types.structs.push(r); c.types.structs[0].fields.push({ name: "nested", type: { kind, name } }); return r;
|
|
26
|
+
}
|
|
27
|
+
function enumeration(c: Contract): void {
|
|
28
|
+
c.types.enums.push({ name: "Choice", origin: "src/core.ts", exported: true, members: ["first", "second"] });
|
|
29
|
+
c.types.structs[0].fields.push({ name: "choice", type: { kind: "enum", name: "Choice" } });
|
|
30
|
+
}
|
|
31
|
+
function union(c: Contract): void {
|
|
32
|
+
c.types.unions.push({ name: "Choice", origin: "src/core.ts", exported: true, arms: [{ name: "empty", member: null, payload: { kind: "void" } }, { name: "number", member: "value", payload: { kind: "f64" } }] });
|
|
33
|
+
c.types.structs[0].fields.push({ name: "choice", type: { kind: "union", name: "Choice" } });
|
|
34
|
+
}
|
|
35
|
+
function armRecord(c: Contract, name = "Msg_insert", origin: string | null = null): RecordType {
|
|
36
|
+
const r: RecordType = { name, origin, exported: true, fields: [{ name: "flag", type: { kind: "bool" } }, { name: "value", type: { kind: "f64" } }] };
|
|
37
|
+
c.types.structs.push(r); c.msg.arms.push({ name: "insert", member: origin === null ? null : "entry", payload: { kind: "record", name } }); return r;
|
|
38
|
+
}
|
|
39
|
+
function helper(c: Contract, name = "total", returns: TypeRef = { kind: "f64" }, params: TypeRef[] = []): void {
|
|
40
|
+
c.model_helpers.push({ name, returns, params, arena: false });
|
|
41
|
+
}
|
|
42
|
+
function encode(c: Contract): string {
|
|
43
|
+
// Absent authored facts decode to null; explicit JSON null is structural
|
|
44
|
+
// invalidity for these optional string fields in format 1.
|
|
45
|
+
return JSON.stringify(c, (key, value) => (key === "origin" || key === "member") && value === null ? undefined : value);
|
|
46
|
+
}
|
|
47
|
+
export function coreCases(): CoreCase[] {
|
|
48
|
+
const out: CoreCase[] = [];
|
|
49
|
+
function add(name: string, mutate: (c: Contract) => void = () => {}, slots?: string[], mirrorOnly = false): void {
|
|
50
|
+
const c = baseContract(); mutate(c); out.push({ name, input: encode(c), slots, mirrorOnly });
|
|
51
|
+
}
|
|
52
|
+
add("minimal");
|
|
53
|
+
for (const field of ["wire_version", "abi_version", "snapshot_format"]) for (const value of ["-9223372036854775808", "9223372036854775807", "9007199254740993", "-9007199254740993", "0"]) {
|
|
54
|
+
const input = encode(baseContract()).replace(new RegExp(`"${field}":\\d+`), `"${field}":${value}`);
|
|
55
|
+
out.push({ name: `${field}-${value}`, input });
|
|
56
|
+
}
|
|
57
|
+
add("version-and-name-order", c => { c.wire_version = 0; c.abi_version = 0; c.abi.snapshot_format = 0; c.msg.arms.push(c.msg.arms[0]); });
|
|
58
|
+
add("duplicate-table", c => { c.types.enums.push({ name: "Model", origin: null, exported: true, members: ["a", "b"] }); });
|
|
59
|
+
add("duplicate-field", c => { c.types.structs[0].fields.push(c.types.structs[0].fields[0]); });
|
|
60
|
+
add("duplicate-enum", c => { enumeration(c); c.types.enums[0].members.push("first"); });
|
|
61
|
+
add("duplicate-union-arm", c => { union(c); c.types.unions[0].arms.push(c.types.unions[0].arms[0]); });
|
|
62
|
+
add("duplicate-helper", c => { helper(c); helper(c); });
|
|
63
|
+
add("duplicate-env", c => { c.channels.env_msgs = [{ env: "HOME", msg: "label_set" }, { env: "HOME", msg: "label_set" }]; });
|
|
64
|
+
for (const kind of ["node", "value", "enum", "union"]) {
|
|
65
|
+
add(`dangling-${kind}`, c => { c.types.structs[0].fields[1].type = { kind, name: "Missing" }; });
|
|
66
|
+
add(`wrong-kind-${kind}`, c => { c.types.structs[0].fields[1].type = { kind, name: kind === "node" || kind === "value" ? "Choice" : "Model" }; if (kind === "node" || kind === "value") enumeration(c); });
|
|
67
|
+
}
|
|
68
|
+
add("missing-model", c => { c.model = "Missing"; });
|
|
69
|
+
add("enum-model", c => { enumeration(c); c.model = "Choice"; });
|
|
70
|
+
add("unreachable-record", c => { record(c, "Extra"); c.types.structs[0].fields.pop(); });
|
|
71
|
+
add("reach-diagnostic-order", c => { const r = record(c, "Nested"); r.fields = [{ name: "bad", type: { kind: "union", name: "Unknown" } }]; c.types.structs[0].fields.push({ name: "bad", type: { kind: "enum", name: "NoEnum" } }); });
|
|
72
|
+
add("self-cycle", c => { c.types.structs[0].fields.push({ name: "self", type: { kind: "optional", inner: { kind: "node", name: "Model" } } }); });
|
|
73
|
+
add("indirect-cycle", c => { const r = record(c, "Nested"); r.fields.push({ name: "root", type: { kind: "node", name: "Model" } }); });
|
|
74
|
+
add("shared-dag", c => { record(c, "Nested"); c.types.structs[0].fields.push({ name: "other", type: { kind: "node", name: "Nested" } }); });
|
|
75
|
+
for (const size of [254, 255, 256, 257]) add(`named-depth-${size}`, c => {
|
|
76
|
+
c.types.structs[0].fields = []; c.integer_slots = [];
|
|
77
|
+
for (let i = 1; i < size; i++) c.types.structs.push({ name: `N${i}`, origin: "src/core.ts", exported: true, fields: [] });
|
|
78
|
+
for (let i = 0; i < size; i++) c.types.structs[i].fields.push({ name: "next", type: i + 1 < size ? { kind: "node", name: c.types.structs[i + 1].name } : { kind: "bool" } });
|
|
79
|
+
});
|
|
80
|
+
add("combined-wrapper-depth", c => {
|
|
81
|
+
c.types.structs[0].fields = []; c.integer_slots = [];
|
|
82
|
+
for (let i = 1; i < 82; i++) c.types.structs.push({ name: `Depth${i}`, origin: "src/core.ts", exported: true, fields: [] });
|
|
83
|
+
let ref: TypeRef = { kind: "bool" }; for (let i = 0; i < 180; i++) ref = { kind: "optional", inner: ref };
|
|
84
|
+
for (let i = 0; i < 82; i++) c.types.structs[i].fields.push({ name: "next", type: i === 81 ? ref : { kind: "node", name: c.types.structs[i + 1].name } });
|
|
85
|
+
});
|
|
86
|
+
for (const size of [0, 256, 257]) {
|
|
87
|
+
add(`message-bound-${size}`, c => { c.msg.arms = Array.from({ length: size }, (_, i) => ({ name: `arm${i}`, member: null, payload: { kind: "void" } })); });
|
|
88
|
+
add(`enum-bound-${size}`, c => { enumeration(c); c.types.enums[0].members = Array.from({ length: size }, (_, i) => `member${i}`); });
|
|
89
|
+
add(`union-bound-${size}`, c => { union(c); c.types.unions[0].arms = Array.from({ length: size }, (_, i) => ({ name: `arm${i}`, member: null, payload: { kind: "void" } })); });
|
|
90
|
+
}
|
|
91
|
+
add("number-bytes-equal", c => { c.msg.arms[0].payload = { kind: "number_bytes", number_field: "same", bytes_field: "same", number_class: "f64" }; });
|
|
92
|
+
for (const kind of ["void", "node", "value"]) add(`scalar-${kind}`, c => { c.msg.arms[0].member = "value"; c.msg.arms[0].payload = { kind: "scalar", type: { kind, name: "Model" } }; });
|
|
93
|
+
for (const wrap of ["plain", "optional", "slice"]) add(`void-field-${wrap}`, c => { c.types.structs[0].fields[1].type = wrap === "plain" ? { kind: "void" } : { kind: wrap, inner: { kind: "void" }, elem: { kind: "void" } }; });
|
|
94
|
+
add("void-helper-return", c => { helper(c, "total", { kind: "void" }); });
|
|
95
|
+
add("unbound-missing", c => { c.model_unbound = ["absent"]; c.msg.unbound = ["absent"]; });
|
|
96
|
+
add("unbound-helper", c => { helper(c); c.model_unbound = ["total"]; });
|
|
97
|
+
add("unbound-field-shadow", c => { c.types.structs[0].fields[1].name = "label_set"; c.msg.unbound = ["label_set"]; });
|
|
98
|
+
add("unbound-helper-shadow", c => { helper(c, "label_set"); c.msg.unbound = ["label_set"]; });
|
|
99
|
+
for (const channel of ["appearance_msg", "chrome_msg"] as const) for (const name of ["absent", "bump", "label_set"]) add(`${channel}-${name}`, c => { c.channels[channel] = name; });
|
|
100
|
+
add("appearance-shape-and-chrome-order", c => { c.channels.appearance_msg = "bump"; c.msg.arms[0].payload = { kind: "scalar", type: { kind: "bool" } }; c.msg.arms[0].member = "value"; c.channels.chrome_msg = "label_set"; });
|
|
101
|
+
for (const name of ["absent", "bump", "label_set"]) add(`env-${name}`, c => { c.channels.env_msgs = [{ env: "APP_VALUE", msg: name }]; });
|
|
102
|
+
for (const channel of ["command_msg", "frame_msg", "key_msg", "pinch_msg", "drop_msg"] as const) {
|
|
103
|
+
add(`channel-missing-${channel}`, c => { c.channels[channel] = true; });
|
|
104
|
+
add(`channel-unwired-${channel}`, c => { c.abi.exports.push(channel); });
|
|
105
|
+
add(`channel-wired-${channel}`, c => { c.channels[channel] = true; c.abi.exports.push(channel); });
|
|
106
|
+
}
|
|
107
|
+
add("abi-missing", c => { c.abi.exports.splice(3, 1); });
|
|
108
|
+
add("abi-unknown", c => { c.abi.exports.push("unknown"); });
|
|
109
|
+
add("abi-duplicate", c => { c.abi.exports.push("helper_call"); });
|
|
110
|
+
add("abi-order", c => { c.abi.exports.push("native_window_view", "native_view"); });
|
|
111
|
+
add("abi-native-views", c => { c.abi.exports.push("native_view", "native_window_view"); });
|
|
112
|
+
for (const slot of ["Missing.field", "Model.label", "Model.count.extra", "Msg.bump", "Msg.label_set", "helpers.missing.return", "Model", ".count", "Model."]) add(`slot-${slot}`, c => { c.integer_slots.push({ slot, class: "i64" }); });
|
|
113
|
+
add("slot-missing", c => { c.integer_slots = []; });
|
|
114
|
+
add("slot-duplicate", c => { c.integer_slots.push(c.integer_slots[0]); });
|
|
115
|
+
add("slot-unsigned", c => { c.integer_slots[0].class = "u64"; });
|
|
116
|
+
add("slot-dotted", c => { c.types.structs[0].fields[0].name = "with.dot"; c.integer_slots[0].slot = "Model.with.dot"; });
|
|
117
|
+
add("slot-ambiguous", c => { c.msg.name = "Model"; c.msg.arms[0].name = "count"; c.msg.arms[0].payload = { kind: "number", class: "i64" }; c.msg.arms[0].member = "value"; });
|
|
118
|
+
for (const kind of ["bool", "f64", "bytes", "enum", "union", "node", "slice", "optional"]) add(`slot-target-${kind}`, c => {
|
|
119
|
+
if (kind === "enum") enumeration(c); if (kind === "union") union(c); if (kind === "node") record(c, "Nested");
|
|
120
|
+
c.types.structs[0].fields.push({ name: "target", type: { kind, name: kind === "node" ? "Nested" : "Choice", elem: { kind: "i64" }, inner: { kind: "i64" } } });
|
|
121
|
+
c.integer_slots.push({ slot: "Model.target", class: "i64" });
|
|
122
|
+
});
|
|
123
|
+
for (const kind of ["number", "number_bytes", "scalar"]) add(`integer-message-${kind}`, c => {
|
|
124
|
+
c.msg.arms[0].member = "value"; c.msg.arms[0].payload = { kind, class: "i64", number_class: "i64", number_field: "id", bytes_field: "body", type: { kind: "optional", inner: { kind: "i64" } } };
|
|
125
|
+
c.integer_slots.push({ slot: kind === "number_bytes" ? "Msg.bump.id" : "Msg.bump", class: "u64" });
|
|
126
|
+
});
|
|
127
|
+
for (const index of ["0", "+0", "00", "0_", "_0", "0__0", "+_0", "1", "999999999999999999999", "-0", "-00", "-1"]) add(`helper-param-index-${index}`, c => {
|
|
128
|
+
helper(c, "total", { kind: "i64" }, [{ kind: "i64" }]); c.integer_slots.push({ slot: "helpers.total.return", class: "i64" }, { slot: "helpers.total.params[0]", class: "i64" });
|
|
129
|
+
if (index !== "0") c.integer_slots.push({ slot: `helpers.total.params[${index}]`, class: "i64" });
|
|
130
|
+
});
|
|
131
|
+
for (const name of ["std", "rt", "view_unbound", "msg_tags", "p0", "FrameEvent", "nativeView", "nativeTextPolicy", "UpdateResult", "Model", "Msg"]) add(`mirror-name-${name}`, c => { record(c, name); if (name === "p0") helper(c, "total", { kind: "f64" }, [{ kind: "f64" }]); });
|
|
132
|
+
add("mirror-view-reserved", c => { record(c, "nativeView"); c.abi.exports.push("native_view"); });
|
|
133
|
+
add("mirror-policy-reserved", c => { record(c, "nativeTextPolicy"); c.abi.exports.push("native_text_policy"); });
|
|
134
|
+
add("mirror-helper-field", c => { helper(c, "label"); });
|
|
135
|
+
add("mirror-helper-type", c => { record(c, "Nested"); helper(c, "Nested"); });
|
|
136
|
+
for (const origin of [null, "src/core.ts"]) for (const fields of [0, 1, 2]) add(`record-plan-${origin === null ? "generated" : "authored"}-${fields}`, c => { armRecord(c, "Msg_insert", origin).fields.length = fields; });
|
|
137
|
+
add("record-shared-pattern", c => { armRecord(c); c.msg.arms.push({ name: "other", member: "value", payload: { kind: "record", name: "Msg_insert" } }); });
|
|
138
|
+
add("record-node-arm", c => { armRecord(c, "Nested", "src/core.ts"); c.types.structs[0].fields.push({ name: "nested", type: { kind: "node", name: "Nested" } }); });
|
|
139
|
+
add("record-model-arm", c => { c.msg.arms.push({ name: "root", member: "value", payload: { kind: "record", name: "Model" } }); });
|
|
140
|
+
add("record-scalar-node-storage", c => { armRecord(c, "Nested", "src/core.ts"); c.msg.arms.push({ name: "maybe", member: "value", payload: { kind: "scalar", type: { kind: "optional", inner: { kind: "node", name: "Nested" } } } }); });
|
|
141
|
+
for (const spelling of ["ts", "canvas", "old", "mixed"]) for (const signed of [false, true]) add(`scroll-${spelling}-${signed}`, c => {
|
|
142
|
+
const r = armRecord(c);
|
|
143
|
+
const ts = ["offsetX", "offsetY", "velocityX", "velocityY", "viewportExtentX", "viewportExtentY", "contentExtentX", "contentExtentY"];
|
|
144
|
+
const canvas = ["offset_x", "offset_y", "velocity_x", "velocity_y", "viewport_extent_x", "viewport_extent_y", "content_extent_x", "content_extent_y"];
|
|
145
|
+
const fields = spelling === "ts" ? ts : spelling === "canvas" ? canvas : spelling === "old" ? ["offset", "velocity", "viewportExtent", "contentExtent"] : ts.map((name, i) => i === 0 ? canvas[0] : name);
|
|
146
|
+
r.fields = fields.map(name => ({ name, type: { kind: "i64" } }));
|
|
147
|
+
for (let i = 0; i < fields.length; i++) c.integer_slots.push({ slot: `${r.name}.${fields[i]}`, class: i < 4 && signed ? "u64" : "i64" });
|
|
148
|
+
});
|
|
149
|
+
for (const name of ["", "_", "1Type", "with-dash", "$Type", "struct", "return", "f64", "u7", "Uint8Array", "Buffer", "init", "nsc_core_test", "nscfValue", "é"]) add(`facade-name-${name}`, c => { record(c, name); });
|
|
150
|
+
for (const name of ["Math", "String", "Error", "dispatch_void", "abi_frame_msg", "$helper", "nscfHelp", "with-dash"]) add(`facade-helper-${name}`, c => { helper(c, name); });
|
|
151
|
+
add("facade-missing-origin", c => { c.types.structs[0].origin = null; });
|
|
152
|
+
add("facade-missing-member", c => { c.msg.arms[1].member = null; });
|
|
153
|
+
add("facade-kind-member", c => { c.msg.arms[1].member = "kind"; });
|
|
154
|
+
add("facade-kind-flattened", c => { armRecord(c).fields[0].name = "kind"; });
|
|
155
|
+
add("facade-generic", c => { record(c, "Box__f64", "node", null); });
|
|
156
|
+
add("facade-private-record", c => { record(c, "Private").exported = false; });
|
|
157
|
+
add("facade-other-origin", c => { record(c, "Other", "node", "src/shared.ts"); });
|
|
158
|
+
add("facade-value-scalars", c => { record(c, "Nested", "value"); });
|
|
159
|
+
add("facade-value-heap", c => { record(c, "Nested", "value").fields[0].type = { kind: "bytes" }; });
|
|
160
|
+
add("facade-value-sequence", c => { record(c, "Nested", "value"); c.types.structs[0].fields[2].type = { kind: "slice", elem: { kind: "value", name: "Nested" } }; });
|
|
161
|
+
add("facade-mixed-storage", c => { record(c, "Nested", "node"); c.types.structs[0].fields.push({ name: "inline", type: { kind: "value", name: "Nested" } }); });
|
|
162
|
+
add("facade-nested-optional", c => { c.types.structs[0].fields[1].type = { kind: "optional", inner: { kind: "optional", inner: { kind: "bytes" } } }; });
|
|
163
|
+
add("facade-optional-slice", c => { c.types.structs[0].fields[1].type = { kind: "optional", inner: { kind: "slice", elem: { kind: "optional", inner: { kind: "bytes" } } } }; });
|
|
164
|
+
for (const authored of [false, true]) for (const invalid of [false, true]) add(`appearance-${authored}-${invalid}`, c => {
|
|
165
|
+
const r = armRecord(c, "Msg_insert", authored ? "src/core.ts" : null);
|
|
166
|
+
c.types.enums.push({ name: "ColorScheme", origin: "src/events.ts", exported: true, members: ["light", "dark"] });
|
|
167
|
+
r.fields = [{ name: "colorScheme", type: { kind: "enum", name: "ColorScheme" } }, { name: "reduceMotion", type: { kind: invalid ? "bytes" : "bool" } }, { name: "highContrast", type: { kind: "bool" } }];
|
|
168
|
+
c.channels.appearance_msg = "insert";
|
|
169
|
+
});
|
|
170
|
+
for (const authored of [false, true]) for (const node of [false, true]) for (const signed of [false, true]) add(`chrome-${authored}-${node}-${signed}`, c => {
|
|
171
|
+
const r = armRecord(c, "Msg_insert", authored ? "src/core.ts" : null);
|
|
172
|
+
r.fields = [{ name: "insets", type: { kind: node ? "node" : "value", name: "Insets" } }, { name: "buttons", type: { kind: "value", name: "Buttons" } }, { name: "tabsProjected", type: { kind: "bool" } }];
|
|
173
|
+
for (const [name, fields] of [["Insets", ["top", "right", "bottom", "left"]], ["Buttons", ["x", "y", "width", "height"]]] as const) {
|
|
174
|
+
c.types.structs.push({ name, origin: "src/events.ts", exported: true, fields: fields.map(field => ({ name: field, type: { kind: "i64" } })) });
|
|
175
|
+
for (const field of fields) c.integer_slots.push({ slot: `${name}.${field}`, class: signed && name === "Buttons" && (field === "x" || field === "y") ? "u64" : "i64" });
|
|
176
|
+
}
|
|
177
|
+
c.channels.chrome_msg = "insert";
|
|
178
|
+
});
|
|
179
|
+
add("flattened-union-record", c => {
|
|
180
|
+
union(c); c.types.structs.push({ name: "Choice_record", origin: null, exported: true, fields: [{ name: "value", type: { kind: "f64" } }, { name: "flag", type: { kind: "bool" } }] });
|
|
181
|
+
c.types.unions[0].arms.push({ name: "record", member: null, payload: { kind: "value", name: "Choice_record" } });
|
|
182
|
+
});
|
|
183
|
+
add("nested-synthesized-record", c => { const r = record(c, "Model_nested", "value", null); r.fields[0].type = { kind: "i64" }; c.integer_slots.push({ slot: "Model_nested.flag", class: "i64" }); });
|
|
184
|
+
add("integer-helper-return", c => { helper(c, "total", { kind: "optional", inner: { kind: "i64" } }); c.integer_slots.push({ slot: "helpers.total.return", class: "u64" }); });
|
|
185
|
+
add("additive-fields-and-demotion", c => { Object.assign(c, { future_contract: { active: true } }); Object.assign(c.types.structs[0], { future_table: [1, 2] }); Object.assign(c.types.structs[0].fields[0], { future_field: "kept" }); }, ["Model.count"]);
|
|
186
|
+
add("f64-demotion", () => {}, ["Model.count"]);
|
|
187
|
+
add("f64-missing", () => {}, ["Model.absent"]);
|
|
188
|
+
add("f64-message", c => { c.msg.arms[0].payload = { kind: "number", class: "i64" }; c.msg.arms[0].member = "value"; c.integer_slots.push({ slot: "Msg.bump", class: "i64" }); }, ["Msg.bump"]);
|
|
189
|
+
add("legacy-mirror", c => { c.types.structs[0].origin = null; c.msg.arms[1].member = null; }, undefined, true);
|
|
190
|
+
for (const identity of ["0000000000000000", "0020000000000001", "ffffffffffffffff"]) add(`emission-identity-${identity}`, c => {
|
|
191
|
+
c.build_id = identity; c.model_fingerprint = identity;
|
|
192
|
+
});
|
|
193
|
+
for (const [index, entry] of ["", "/", "src///core.ts///", "core.ts", "src\\core.ts", "///src//π.ts//"].entries()) add(`emission-entry-${index}`, c => { c.entry = entry; });
|
|
194
|
+
add("emission-comment-utf8", c => { c.entry = "src/雪🙂\n\r\t\u0000\u007f\u2028\u2029.ts"; c.compiler_version = "0.2.2\n\u2028\u2029"; });
|
|
195
|
+
for (const [index, name] of ["error", "_", "with.dot", "é\"\\\t\r\n", "雪🙂", "$$", "\u0000\u007f"].entries()) {
|
|
196
|
+
add(`emission-property-${index}`, c => { c.types.structs[0].fields[1].name = name; });
|
|
197
|
+
add(`emission-mirror-property-${index}`, c => { c.types.structs[0].fields[1].name = name; }, undefined, true);
|
|
198
|
+
}
|
|
199
|
+
add("emission-environment-utf8", c => { c.channels.env_msgs = [{ env: "APP_雪🙂\"\\\t\u0001", msg: "label_set" }]; });
|
|
200
|
+
for (const [index, origin] of ["src/shared.ts", "src/é\"\\\t\r\n\u2028\u2029.ts"].entries()) add(`emission-origin-${index}`, c => {
|
|
201
|
+
record(c, "Other", "node", origin); enumeration(c); c.types.enums[0].origin = origin;
|
|
202
|
+
});
|
|
203
|
+
for (const unsigned of [false, true]) add(`emission-text-input-${unsigned}`, c => {
|
|
204
|
+
c.types.enums.push({ name: "CaretDirection", origin: "src/events.ts", exported: true, members: ["previous", "next", "previous_word", "next_word", "start", "end"] });
|
|
205
|
+
c.types.structs.push(
|
|
206
|
+
{ name: "CaretMove", origin: "src/events.ts", exported: true, fields: [{ name: "direction", type: { kind: "enum", name: "CaretDirection" } }, { name: "extend", type: { kind: "bool" } }] },
|
|
207
|
+
{ name: "Selection", origin: "src/events.ts", exported: true, fields: [{ name: "anchor", type: { kind: "i64" } }, { name: "focus", type: { kind: "i64" } }] },
|
|
208
|
+
{ name: "Composition", origin: "src/events.ts", exported: true, fields: [{ name: "text", type: { kind: "bytes" } }, { name: "cursor", type: { kind: "optional", inner: { kind: "i64" } } }] },
|
|
209
|
+
);
|
|
210
|
+
for (const slot of ["Selection.anchor", "Selection.focus", "Composition.cursor"]) c.integer_slots.push({ slot, class: unsigned && slot !== "Composition.cursor" ? "u64" : "i64" });
|
|
211
|
+
const tags = ["insert_text", "delete_backward", "delete_forward", "delete_word_backward", "delete_word_forward", "delete_to_start", "delete_to_line_start", "clear", "move_caret", "set_selection", "set_composition", "commit_composition", "cancel_composition"];
|
|
212
|
+
c.types.unions.push({ name: "TextInput", origin: "src/events.ts", exported: true, arms: tags.map(name => ({ name, member: name === "insert_text" || name === "set_composition" ? "text" : name === "move_caret" ? "move" : name === "set_selection" ? "selection" : null, payload: name === "insert_text" ? { kind: "bytes" } : name === "move_caret" ? { kind: "value", name: "CaretMove" } : name === "set_selection" ? { kind: "value", name: "Selection" } : name === "set_composition" ? { kind: "value", name: "Composition" } : { kind: "void" } })) });
|
|
213
|
+
c.msg.arms.push({ name: "edit", member: "event", payload: { kind: "union", name: "TextInput" } });
|
|
214
|
+
});
|
|
215
|
+
for (const scalar of ["-0", "9007199254740993", "18446744073709551615", "-9223372036854775808", "1e-300", "5e-324", "1.7976931348623157e308"]) {
|
|
216
|
+
const c = baseContract();
|
|
217
|
+
const input = encode(c).slice(0, -1) + ',"future":{"wide":' + scalar + ',"nested":[{},[],{"a\\b\\\"c":"café 🧪", "kind":"i64", "slot":"Model.count"}],"bool":true,"empty":null}}';
|
|
218
|
+
out.push({ name: "effective-opaque-" + scalar, input, slots: ["Model.count"] });
|
|
219
|
+
}
|
|
220
|
+
add("effective-optional-u64", c => {
|
|
221
|
+
c.types.structs[0].fields[0].type = { kind: "optional", inner: { kind: "i64" } };
|
|
222
|
+
c.integer_slots[0].class = "u64";
|
|
223
|
+
}, ["Model.count"]);
|
|
224
|
+
add("effective-two-slots", c => {
|
|
225
|
+
c.types.structs[0].fields.push({ name: "other", type: { kind: "optional", inner: { kind: "i64" } } });
|
|
226
|
+
c.integer_slots.push({ slot: "Model.other", class: "u64" });
|
|
227
|
+
}, ["Model.other", "Model.count"]);
|
|
228
|
+
add("effective-repeated-slot", () => {}, ["Model.count", "Model.count"]);
|
|
229
|
+
add("effective-missing-before-repeated", () => {}, ["Missing.count", "Model.count", "Model.count"]);
|
|
230
|
+
const untouched = encode(baseContract());
|
|
231
|
+
out.push({ name: "effective-original-whitespace", input: " \n" + untouched + " \t\n" });
|
|
232
|
+
return out;
|
|
233
|
+
}
|