@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
package/build/app.zig
CHANGED
|
@@ -122,6 +122,10 @@ const WebLayerOption = web_layer_contract.WebViewLayer;
|
|
|
122
122
|
|
|
123
123
|
pub const AppOptions = struct {
|
|
124
124
|
name: []const u8,
|
|
125
|
+
/// Expose the embed archive on a desktop host as well as mobile targets.
|
|
126
|
+
/// The core is staged through the ordinary app build, including compiled
|
|
127
|
+
/// TypeScript wiring, before addMobileLib consumes it.
|
|
128
|
+
mobile_lib: bool = false,
|
|
125
129
|
/// Explicit manifest path. Null auto-detects app.json first, then app.zon,
|
|
126
130
|
/// so older owned build.zig files can adopt JSON without a build edit.
|
|
127
131
|
manifest: ?[]const u8 = null,
|
|
@@ -201,7 +205,7 @@ const TsWindowView = struct {
|
|
|
201
205
|
staged_path: []const u8,
|
|
202
206
|
};
|
|
203
207
|
|
|
204
|
-
const
|
|
208
|
+
const TsMarkupSource = struct {
|
|
205
209
|
set_path: []const u8,
|
|
206
210
|
source_path: []const u8,
|
|
207
211
|
staged_path: []const u8,
|
|
@@ -209,9 +213,52 @@ const TsWindowSource = struct {
|
|
|
209
213
|
|
|
210
214
|
const TsWindowViews = struct {
|
|
211
215
|
views: []const TsWindowView,
|
|
212
|
-
sources: []const
|
|
216
|
+
sources: []const TsMarkupSource,
|
|
213
217
|
};
|
|
214
218
|
|
|
219
|
+
const TsAppMarkupSources = struct {
|
|
220
|
+
/// Non-root, non-window files discovered under src/. Window files are
|
|
221
|
+
/// staged by the existing secondary-window registry and must not be
|
|
222
|
+
/// copied a second time.
|
|
223
|
+
files: []const TsMarkupSource,
|
|
224
|
+
/// The root view's embedded resolver set. Its path keys are relative to
|
|
225
|
+
/// src/, matching the root disk watcher; existing window sources are
|
|
226
|
+
/// projected under their staged `windows/...` names.
|
|
227
|
+
sources: []const TsMarkupSource,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const max_markup_source_path_len = 200;
|
|
231
|
+
const max_markup_source_path_segments = 24;
|
|
232
|
+
const root_markup_source_prefix = "src/";
|
|
233
|
+
|
|
234
|
+
/// Whether a path relative to `src/` fits the markup resolver once the
|
|
235
|
+
/// generated desktop watch and `native check` address it as `src/<path>`.
|
|
236
|
+
/// The compiled source set drops that prefix, but accepting a path only the
|
|
237
|
+
/// compiled resolver can represent would make development and release
|
|
238
|
+
/// disagree at the boundary.
|
|
239
|
+
pub fn markupSourcePathWithinBudget(path: []const u8) bool {
|
|
240
|
+
var segments: usize = 1; // the disk resolver's leading `src` segment
|
|
241
|
+
var it = std.mem.tokenizeScalar(u8, path, '/');
|
|
242
|
+
while (it.next() != null) segments += 1;
|
|
243
|
+
return root_markup_source_prefix.len + path.len <= max_markup_source_path_len and
|
|
244
|
+
segments <= max_markup_source_path_segments;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
fn validateMarkupSourcePath(path: []const u8) void {
|
|
248
|
+
if (!markupSourcePathWithinBudget(path)) {
|
|
249
|
+
std.debug.panic(
|
|
250
|
+
"\nTypeScript markup source path `src/{s}` exceeds the import resolver budget: the full app-relative path, including `src/`, must be at most {d} bytes and {d} segments\n",
|
|
251
|
+
.{ path, max_markup_source_path_len, max_markup_source_path_segments },
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
pub fn isRootMarkupSourcePath(path: []const u8) bool {
|
|
257
|
+
return std.mem.endsWith(u8, path, ".native") and
|
|
258
|
+
!std.mem.eql(u8, path, "app.native") and
|
|
259
|
+
!std.mem.startsWith(u8, path, "windows/");
|
|
260
|
+
}
|
|
261
|
+
|
|
215
262
|
/// Default TypeScript secondary-window views are statically discovered under
|
|
216
263
|
/// `src/windows/`: `settings.native` serves descriptor label `settings`.
|
|
217
264
|
/// Direct files form the generated launcher's closed, comptime-compiled view
|
|
@@ -224,7 +271,7 @@ fn collectTsWindowViews(b: *std.Build, app_root: []const u8) TsWindowViews {
|
|
|
224
271
|
var walker = dir.walk(b.allocator) catch return .{ .views = &.{}, .sources = &.{} };
|
|
225
272
|
defer walker.deinit();
|
|
226
273
|
var views: std.ArrayList(TsWindowView) = .empty;
|
|
227
|
-
var sources: std.ArrayList(
|
|
274
|
+
var sources: std.ArrayList(TsMarkupSource) = .empty;
|
|
228
275
|
while (walker.next(b.graph.io) catch null) |entry| {
|
|
229
276
|
if (entry.kind != .file or !std.mem.endsWith(u8, entry.path, ".native")) continue;
|
|
230
277
|
const normalized_path = b.dupe(entry.path);
|
|
@@ -261,14 +308,85 @@ fn collectTsWindowViews(b: *std.Build, app_root: []const u8) TsWindowViews {
|
|
|
261
308
|
}.than;
|
|
262
309
|
std.mem.sort(TsWindowView, views.items, {}, less);
|
|
263
310
|
const source_less = struct {
|
|
264
|
-
fn than(_: void, a:
|
|
311
|
+
fn than(_: void, a: TsMarkupSource, z: TsMarkupSource) bool {
|
|
265
312
|
return std.mem.order(u8, a.set_path, z.set_path) == .lt;
|
|
266
313
|
}
|
|
267
314
|
}.than;
|
|
268
|
-
std.mem.sort(
|
|
315
|
+
std.mem.sort(TsMarkupSource, sources.items, {}, source_less);
|
|
269
316
|
return .{ .views = views.items, .sources = sources.items };
|
|
270
317
|
}
|
|
271
318
|
|
|
319
|
+
/// The root TypeScript view resolves imports from every `.native` file under
|
|
320
|
+
/// `src/` except itself. Window files already come from collectTsWindowViews;
|
|
321
|
+
/// append those under `windows/...` keys so this set matches the root disk
|
|
322
|
+
/// resolver without changing the separate window resolver root.
|
|
323
|
+
fn collectAppMarkupSources(b: *std.Build, app_root: []const u8, window_views: TsWindowViews) TsAppMarkupSources {
|
|
324
|
+
const src_path = appPath(b, app_root, "src");
|
|
325
|
+
var dir = b.build_root.handle.openDir(b.graph.io, src_path, .{ .iterate = true }) catch
|
|
326
|
+
return .{ .files = &.{}, .sources = &.{} };
|
|
327
|
+
defer dir.close(b.graph.io);
|
|
328
|
+
var walker = dir.walk(b.allocator) catch return .{ .files = &.{}, .sources = &.{} };
|
|
329
|
+
defer walker.deinit();
|
|
330
|
+
|
|
331
|
+
var files: std.ArrayList(TsMarkupSource) = .empty;
|
|
332
|
+
while (walker.next(b.graph.io) catch null) |entry| {
|
|
333
|
+
if (entry.kind != .file or !std.mem.endsWith(u8, entry.path, ".native")) continue;
|
|
334
|
+
const normalized_path = b.dupe(entry.path);
|
|
335
|
+
for (normalized_path) |*char| {
|
|
336
|
+
if (char.* == '\\') char.* = '/';
|
|
337
|
+
}
|
|
338
|
+
if (!isRootMarkupSourcePath(normalized_path)) continue;
|
|
339
|
+
validateMarkupSourcePath(normalized_path);
|
|
340
|
+
files.append(b.allocator, .{
|
|
341
|
+
.set_path = normalized_path,
|
|
342
|
+
.source_path = b.fmt("src/{s}", .{normalized_path}),
|
|
343
|
+
.staged_path = normalized_path,
|
|
344
|
+
}) catch @panic("OOM");
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const less = struct {
|
|
348
|
+
fn than(_: void, a: TsMarkupSource, z: TsMarkupSource) bool {
|
|
349
|
+
return std.mem.order(u8, a.set_path, z.set_path) == .lt;
|
|
350
|
+
}
|
|
351
|
+
}.than;
|
|
352
|
+
std.mem.sort(TsMarkupSource, files.items, {}, less);
|
|
353
|
+
|
|
354
|
+
var sources: std.ArrayList(TsMarkupSource) = .empty;
|
|
355
|
+
sources.ensureTotalCapacity(b.allocator, files.items.len + window_views.sources.len) catch @panic("OOM");
|
|
356
|
+
sources.appendSliceAssumeCapacity(files.items);
|
|
357
|
+
for (window_views.sources) |source| {
|
|
358
|
+
validateMarkupSourcePath(source.staged_path);
|
|
359
|
+
sources.appendAssumeCapacity(.{
|
|
360
|
+
.set_path = source.staged_path,
|
|
361
|
+
.source_path = source.source_path,
|
|
362
|
+
.staged_path = source.staged_path,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
std.mem.sort(TsMarkupSource, sources.items, {}, less);
|
|
366
|
+
return .{ .files = files.items, .sources = sources.items };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
fn tsAppMarkupSourcesSource(b: *std.Build, registry: TsAppMarkupSources) []const u8 {
|
|
370
|
+
var out: std.ArrayList(u8) = .empty;
|
|
371
|
+
out.appendSlice(b.allocator,
|
|
372
|
+
\\//! Generated by build/app.zig from src/**/*.native.
|
|
373
|
+
\\const native_sdk = @import("native_sdk");
|
|
374
|
+
\\const canvas = native_sdk.canvas;
|
|
375
|
+
\\pub const sources = [_]canvas.ui_markup.SourceFile{
|
|
376
|
+
\\
|
|
377
|
+
) catch @panic("OOM");
|
|
378
|
+
for (registry.sources) |source| {
|
|
379
|
+
const line = std.fmt.allocPrint(
|
|
380
|
+
b.allocator,
|
|
381
|
+
" .{{ .path = \"{f}\", .source = @embedFile(\"{f}\") }},\n",
|
|
382
|
+
.{ std.zig.fmtString(source.set_path), std.zig.fmtString(source.staged_path) },
|
|
383
|
+
) catch @panic("OOM");
|
|
384
|
+
out.appendSlice(b.allocator, line) catch @panic("OOM");
|
|
385
|
+
}
|
|
386
|
+
out.appendSlice(b.allocator, "};\n") catch @panic("OOM");
|
|
387
|
+
return out.items;
|
|
388
|
+
}
|
|
389
|
+
|
|
272
390
|
fn tsWindowRegistrySource(b: *std.Build, registry: TsWindowViews) []const u8 {
|
|
273
391
|
const views = registry.views;
|
|
274
392
|
var out: std.ArrayList(u8) = .empty;
|
|
@@ -369,6 +487,10 @@ const TsCoreStage = struct {
|
|
|
369
487
|
/// mirror/registry files): the embed static library's `app`
|
|
370
488
|
/// module roots here on iOS/Android targets.
|
|
371
489
|
mobile_root: std.Build.LazyPath,
|
|
490
|
+
/// Release/mobile-only module embedding src/app.native. It lives in a
|
|
491
|
+
/// separate generated directory so a Debug app-code module never gains
|
|
492
|
+
/// the root markup as a transitive file input; Debug links markup_c.
|
|
493
|
+
app_markup_root: std.Build.LazyPath,
|
|
372
494
|
/// The compiled-core archive: the app module links it (with libc,
|
|
373
495
|
/// for the toolchain's runtime) beside the staged mirror.
|
|
374
496
|
archive: std.Build.LazyPath,
|
|
@@ -708,22 +830,32 @@ fn tsParseQuotedManifestValue(manifest_json: []const u8, comptime key: []const u
|
|
|
708
830
|
return suffix;
|
|
709
831
|
}
|
|
710
832
|
|
|
711
|
-
///
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
833
|
+
/// App and root fixture builds share the same scriptc optimization policy.
|
|
834
|
+
pub fn scriptcOptimizationForMode(optimize: std.builtin.OptimizeMode) []const u8 {
|
|
835
|
+
return if (optimize == .Debug) "dev" else "release";
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/// The library-profile optimization field first shipped with the Node
|
|
839
|
+
/// bootstrap. scriptc installs a native binary instead, so either
|
|
840
|
+
/// published entrypoint marks a compiler that accepts the field.
|
|
716
841
|
fn scriptcProfileOptimization(b: *std.Build, dep: *std.Build.Dependency, optimize: std.builtin.OptimizeMode) ?[]const u8 {
|
|
717
842
|
const sdk_root = tsSdkRoot(b.allocator, b.graph.io, dep);
|
|
843
|
+
const release_marker = b.pathJoin(&.{ sdk_root, "packages", "core", "scripts", "scriptc-toolchain.json" });
|
|
844
|
+
if (std.Io.Dir.cwd().access(b.graph.io, release_marker, .{})) |_| {
|
|
845
|
+
return scriptcOptimizationForMode(optimize);
|
|
846
|
+
} else |_| {}
|
|
718
847
|
var dir: []const u8 = b.pathJoin(&.{ sdk_root, "packages", "core" });
|
|
719
848
|
while (true) {
|
|
720
849
|
if (!std.mem.eql(u8, std.fs.path.basename(dir), "node_modules")) {
|
|
721
|
-
const
|
|
722
|
-
std.Io.Dir.cwd().access(b.graph.io,
|
|
723
|
-
|
|
724
|
-
|
|
850
|
+
const native_marker = b.pathJoin(&.{ dir, "node_modules", "scriptc", "bin", "scriptc.exe" });
|
|
851
|
+
std.Io.Dir.cwd().access(b.graph.io, native_marker, .{}) catch {
|
|
852
|
+
const bootstrap_marker = b.pathJoin(&.{ dir, "node_modules", "scriptc", "dist", "bootstrap.js" });
|
|
853
|
+
std.Io.Dir.cwd().access(b.graph.io, bootstrap_marker, .{}) catch {
|
|
854
|
+
dir = std.fs.path.dirname(dir) orelse return null;
|
|
855
|
+
continue;
|
|
856
|
+
};
|
|
725
857
|
};
|
|
726
|
-
return
|
|
858
|
+
return scriptcOptimizationForMode(optimize);
|
|
727
859
|
}
|
|
728
860
|
dir = std.fs.path.dirname(dir) orelse return null;
|
|
729
861
|
}
|
|
@@ -851,15 +983,19 @@ fn tsCoreStage(
|
|
|
851
983
|
relational_capability: bool,
|
|
852
984
|
credentials_capability: bool,
|
|
853
985
|
credentials_permission: bool,
|
|
986
|
+
keyboard_input_permission: bool,
|
|
854
987
|
persist_version: ?u64,
|
|
855
988
|
service_packages: []const ServicePackageConfig,
|
|
856
989
|
service_carrier_choice: ServiceCarrierOption,
|
|
857
990
|
service_pool_workers: ?u8,
|
|
858
991
|
build_trace: bool,
|
|
859
992
|
scriptc_optimization: ?[]const u8,
|
|
993
|
+
typescript_view: bool,
|
|
994
|
+
view_reload: bool,
|
|
860
995
|
) TsCoreStage {
|
|
861
996
|
const node = tsCorePreflight(b, dep, app_root);
|
|
862
997
|
const window_views = collectTsWindowViews(b, app_root);
|
|
998
|
+
const app_markup_sources = collectAppMarkupSources(b, app_root, window_views);
|
|
863
999
|
const has_services = appHasServiceFiles(b, app_root);
|
|
864
1000
|
if (!scriptcCompileSupported(b.graph.host.result, target)) {
|
|
865
1001
|
panicUnsupportedScriptcTarget(b, b.graph.host.result, target);
|
|
@@ -914,7 +1050,7 @@ fn tsCoreStage(
|
|
|
914
1050
|
}
|
|
915
1051
|
sqlite_check.addFileInput(dep.path("packages/core/src/sqlite_codegen.ts"));
|
|
916
1052
|
sqlite_check.addFileInput(dep.path("packages/core/src/sqlite_runtime_policy.ts"));
|
|
917
|
-
for ([_][]const u8{ "events.ts", "text.ts", "bytes_text_methods.d.ts", "events.d.ts", "text.d.ts" }) |source| {
|
|
1053
|
+
for ([_][]const u8{ "bytes.ts", "bytes.d.ts", "events.ts", "text.ts", "bytes_text_methods.d.ts", "events.d.ts", "text.d.ts", "theme.ts", "theme.d.ts", "internal/image_identity.ts", "internal/image_identity.d.ts", "internal/markdown_policy.ts", "internal/markdown_policy.d.ts" }) |source| {
|
|
918
1054
|
sqlite_check.addFileInput(dep.path(b.fmt("packages/core/sdk/{s}", .{source})));
|
|
919
1055
|
}
|
|
920
1056
|
addAppSqlDirInputs(b, sqlite_check, appPath(b, app_root, "src"));
|
|
@@ -961,6 +1097,7 @@ fn tsCoreStage(
|
|
|
961
1097
|
if (relational_capability) check.addArgs(&.{ "--capability", "sqlite" });
|
|
962
1098
|
if (credentials_capability) check.addArgs(&.{ "--capability", "credentials" });
|
|
963
1099
|
if (credentials_permission) check.addArgs(&.{ "--permission", "credentials" });
|
|
1100
|
+
if (keyboard_input_permission) check.addArgs(&.{ "--permission", "keyboard_input" });
|
|
964
1101
|
// Activate the cross-tier registry check even when discovery found no
|
|
965
1102
|
// roots: the empty set must reject a core that declares a window.
|
|
966
1103
|
check.addArg("--window-views");
|
|
@@ -986,7 +1123,7 @@ fn tsCoreStage(
|
|
|
986
1123
|
// corewire, compiled from the SDK dependency for the build host: one
|
|
987
1124
|
// invocation projects the generated compile entry and its profile,
|
|
988
1125
|
// so the profile's entry spelling and the facade file can never skew.
|
|
989
|
-
const corewire_exe =
|
|
1126
|
+
const corewire_exe = @import("corewire.zig").executable(b, dep.builder, node, .Debug, useLlvmWorkaround(b.graph.host));
|
|
990
1127
|
const project = b.addRunArtifact(corewire_exe);
|
|
991
1128
|
project.setName("native corewire (core facade + profile)");
|
|
992
1129
|
project.addArg("--sidecar");
|
|
@@ -1059,6 +1196,8 @@ fn tsCoreStage(
|
|
|
1059
1196
|
if (build_trace) service_compile.setEnvironmentVariable("SCRIPTC_TIMING", "1");
|
|
1060
1197
|
service_compile.addFileArg(dep.path("packages/core/scripts/run_external_service_compiler.mjs"));
|
|
1061
1198
|
service_compile.addFileInput(dep.path("packages/core/scripts/compiler_command.mjs"));
|
|
1199
|
+
service_compile.addFileInput(dep.path("packages/core/scripts/scriptc_toolchain.mjs"));
|
|
1200
|
+
service_compile.addFileInput(dep.path("packages/core/scripts/scriptc-toolchain.json"));
|
|
1062
1201
|
service_compile.addArg("--stage");
|
|
1063
1202
|
service_compile.addDirectoryArg(service_stage_dir);
|
|
1064
1203
|
service_compile.addArg("--manifest");
|
|
@@ -1113,6 +1252,23 @@ fn tsCoreStage(
|
|
|
1113
1252
|
stage_run.addFileArg(facade);
|
|
1114
1253
|
stage_run.addArg("--profile");
|
|
1115
1254
|
stage_run.addFileArg(profile);
|
|
1255
|
+
addViewFrontendInputs(b, dep.builder, stage_run);
|
|
1256
|
+
if (typescript_view) {
|
|
1257
|
+
stage_run.addArg("--view-markup");
|
|
1258
|
+
stage_run.addFileArg(b.path(appPath(b, app_root, "src/app.native")));
|
|
1259
|
+
stage_run.addArg("--view-contract");
|
|
1260
|
+
stage_run.addFileArg(contract);
|
|
1261
|
+
for (app_markup_sources.files) |source| {
|
|
1262
|
+
stage_run.addFileInput(b.path(appPath(b, app_root, source.source_path)));
|
|
1263
|
+
}
|
|
1264
|
+
for (window_views.sources) |source| {
|
|
1265
|
+
stage_run.addFileInput(b.path(appPath(b, app_root, source.source_path)));
|
|
1266
|
+
}
|
|
1267
|
+
if (view_reload) {
|
|
1268
|
+
stage_run.addArg("--view-reload");
|
|
1269
|
+
addViewReloadInputs(dep.builder, stage_run);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1116
1272
|
if (service_client) |client| {
|
|
1117
1273
|
stage_run.addArg("--services-client");
|
|
1118
1274
|
stage_run.addFileArg(client);
|
|
@@ -1137,6 +1293,9 @@ fn tsCoreStage(
|
|
|
1137
1293
|
if (build_trace) compile.setEnvironmentVariable("SCRIPTC_TIMING", "1");
|
|
1138
1294
|
compile.addFileArg(dep.path("packages/core/scripts/run_external_core_compiler.mjs"));
|
|
1139
1295
|
compile.addFileInput(dep.path("packages/core/scripts/compiler_command.mjs"));
|
|
1296
|
+
compile.addFileInput(dep.path("packages/core/scripts/scriptc_toolchain.mjs"));
|
|
1297
|
+
compile.addFileInput(dep.path("packages/core/scripts/scriptc-toolchain.json"));
|
|
1298
|
+
compile.addFileInput(dep.path("packages/core/scripts/run_library_compiler.mjs"));
|
|
1140
1299
|
compile.addArg("--stage");
|
|
1141
1300
|
compile.addDirectoryArg(stage_dir);
|
|
1142
1301
|
compile.addArgs(&.{ "--name", symbol_name });
|
|
@@ -1182,6 +1341,7 @@ fn tsCoreStage(
|
|
|
1182
1341
|
_ = staged.addCopyFile(shim, "core.zig");
|
|
1183
1342
|
_ = staged.addCopyFile(dep.path("tools/corewire/shim_rt.zig"), "shim_rt.zig");
|
|
1184
1343
|
_ = staged.addCopyFile(dep.path("tools/corewire/core_abi.zig"), "core_abi.zig");
|
|
1344
|
+
_ = staged.addCopyFile(dep.path("src/app_runner/ts_compiled_view.zig"), "compiled_view.zig");
|
|
1185
1345
|
_ = staged.addCopyFile(service_registry, "services.zig");
|
|
1186
1346
|
// The carrier selection, as one staged constant module: the generated
|
|
1187
1347
|
// wiring comptime-switches its service transport on it.
|
|
@@ -1195,9 +1355,22 @@ fn tsCoreStage(
|
|
|
1195
1355
|
\\
|
|
1196
1356
|
, .{ service_carrier, service_pool_workers }));
|
|
1197
1357
|
_ = staged.addCopyFile(migrations_zig, "migrations.zig");
|
|
1358
|
+
// A view-reload build announces its contract to the markup watcher at
|
|
1359
|
+
// launch, so the watcher compiles programs for exactly this core.
|
|
1360
|
+
if (view_reload) _ = staged.addCopyFile(contract, "view_reload_contract.json");
|
|
1361
|
+
// Every imported file is an input to Debug's embedded source resolver and
|
|
1362
|
+
// the release/mobile compiled view, so stage those beside the runner.
|
|
1363
|
+
// Keep the ROOT out of this directory: changing any file in one WriteFiles
|
|
1364
|
+
// output changes its directory identity, and the runner lives here. Root
|
|
1365
|
+
// markup gets a separate release-only module below; Debug keeps the small
|
|
1366
|
+
// linked C data object, preserving its link-only edit path.
|
|
1367
|
+
for (app_markup_sources.files) |source| {
|
|
1368
|
+
_ = staged.addCopyFile(b.path(appPath(b, app_root, source.source_path)), source.staged_path);
|
|
1369
|
+
}
|
|
1198
1370
|
// Primary markup bytes live in their own tiny C translation unit. They
|
|
1199
|
-
//
|
|
1200
|
-
// the compiled app/SDK graph and performs
|
|
1371
|
+
// drive Debug desktop without participating in Zig source analysis, so a
|
|
1372
|
+
// root markup edit there reuses the compiled app/SDK graph and performs
|
|
1373
|
+
// only C data compile + relink.
|
|
1201
1374
|
const markup_embed = b.addSystemCommand(&.{node});
|
|
1202
1375
|
markup_embed.setName("native embed primary markup data");
|
|
1203
1376
|
markup_embed.addFileArg(dep.path("packages/core/scripts/embed_markup_c.mjs"));
|
|
@@ -1206,15 +1379,24 @@ fn tsCoreStage(
|
|
|
1206
1379
|
for (window_views.sources) |source| {
|
|
1207
1380
|
_ = staged.addCopyFile(b.path(appPath(b, app_root, source.source_path)), source.staged_path);
|
|
1208
1381
|
}
|
|
1209
|
-
_ = staged.add("
|
|
1382
|
+
_ = staged.add("app_sources.zig", tsAppMarkupSourcesSource(b, app_markup_sources));
|
|
1383
|
+
_ = staged.add("window_views.zig", tsWindowRegistrySource(b, if (typescript_view) .{ .views = &.{}, .sources = &.{} } else window_views));
|
|
1210
1384
|
const main_root = staged.addCopyFile(dep.path("src/app_runner/ts_core_main.zig"), "main.zig");
|
|
1211
1385
|
// The mobile wiring stages beside the desktop entry: same mirror, same
|
|
1212
1386
|
// registry, same carrier constant — only the shell differs (the embed
|
|
1213
1387
|
// host's AppDef contract instead of a process `main`).
|
|
1214
1388
|
const mobile_root = staged.addCopyFile(dep.path("src/app_runner/ts_core_mobile.zig"), "mobile.zig");
|
|
1389
|
+
const release_markup = b.addWriteFiles();
|
|
1390
|
+
_ = release_markup.addCopyFile(b.path(appPath(b, app_root, "src/app.native")), "app.native");
|
|
1391
|
+
const app_markup_root = release_markup.add("app_markup_root.zig",
|
|
1392
|
+
\\//! Generated release/mobile embedding for the TypeScript root view.
|
|
1393
|
+
\\pub const source = @embedFile("app.native");
|
|
1394
|
+
\\
|
|
1395
|
+
);
|
|
1215
1396
|
return .{
|
|
1216
1397
|
.main_root = main_root,
|
|
1217
1398
|
.mobile_root = mobile_root,
|
|
1399
|
+
.app_markup_root = app_markup_root,
|
|
1218
1400
|
.archive = archive,
|
|
1219
1401
|
.service_exe = service_exe,
|
|
1220
1402
|
.service_archive = service_archive,
|
|
@@ -1253,21 +1435,6 @@ fn addAppSqlDirInputs(b: *std.Build, run: *std.Build.Step.Run, src_path: []const
|
|
|
1253
1435
|
}
|
|
1254
1436
|
}
|
|
1255
1437
|
|
|
1256
|
-
/// corewire (the contract-sidecar shim generator), compiled from the SDK
|
|
1257
|
-
/// dependency's sources for the build host.
|
|
1258
|
-
fn corewireExe(b: *std.Build, dep: *std.Build.Dependency) *std.Build.Step.Compile {
|
|
1259
|
-
const mod = b.createModule(.{
|
|
1260
|
-
.root_source_file = dep.path("tools/corewire/main.zig"),
|
|
1261
|
-
.target = b.graph.host,
|
|
1262
|
-
.optimize = .Debug,
|
|
1263
|
-
});
|
|
1264
|
-
return b.addExecutable(.{
|
|
1265
|
-
.name = "corewire",
|
|
1266
|
-
.root_module = mod,
|
|
1267
|
-
.use_llvm = useLlvmWorkaround(b.graph.host),
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
1438
|
/// The archive's symbol-safe stem (`<app>_core` with every non-identifier
|
|
1272
1439
|
/// byte folded to '_'), the -o name the external compile builds under.
|
|
1273
1440
|
fn externalCoreSymbolName(b: *std.Build, app_name: []const u8) []const u8 {
|
|
@@ -1327,6 +1494,31 @@ fn addAppCoreTsDirInputs(b: *std.Build, stage: *std.Build.Step.Run, src_path: []
|
|
|
1327
1494
|
}
|
|
1328
1495
|
}
|
|
1329
1496
|
|
|
1497
|
+
/// Track exactly the ordered portable policies joined by the TypeScript view
|
|
1498
|
+
/// frontend. Both app and repository fixture stages use this inventory, so a
|
|
1499
|
+
/// policy edit or a new manifest entry invalidates a warm staging cache.
|
|
1500
|
+
pub fn addViewFrontendInputs(b: *std.Build, sdk_builder: *std.Build, stage: *std.Build.Step.Run) void {
|
|
1501
|
+
const manifest = "packages/core/src/portable_sources.json";
|
|
1502
|
+
const sources = std.json.parseFromSliceLeaky([]const []const u8, b.allocator, @embedFile("../packages/core/src/portable_sources.json"), .{}) catch
|
|
1503
|
+
@panic("invalid portable source inventory");
|
|
1504
|
+
stage.addFileInput(sdk_builder.path(manifest));
|
|
1505
|
+
stage.addFileInput(sdk_builder.path("packages/core/src/portable_sources.ts"));
|
|
1506
|
+
stage.addFileInput(sdk_builder.path("packages/core/src/view_frontend.ts"));
|
|
1507
|
+
stage.addFileInput(sdk_builder.path("packages/core/src/view_program.ts"));
|
|
1508
|
+
stage.addFileInput(sdk_builder.path("packages/core/src/view_sources.ts"));
|
|
1509
|
+
for (sources) |source| {
|
|
1510
|
+
stage.addFileInput(sdk_builder.path(b.fmt("packages/core/{s}", .{source})));
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
/// The modules stage_external_core.mjs reads for `--view-reload`: the
|
|
1515
|
+
/// development evaluator, its bridge generator and the reload format.
|
|
1516
|
+
pub fn addViewReloadInputs(sdk_builder: *std.Build, stage: *std.Build.Step.Run) void {
|
|
1517
|
+
for ([_][]const u8{ "view_reload.ts", "view_bridge.ts", "view_evaluator.ts", "view_check.ts" }) |source| {
|
|
1518
|
+
stage.addFileInput(sdk_builder.path(sdk_builder.fmt("packages/core/src/{s}", .{source})));
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1330
1522
|
/// Declare the SDK implementation modules copied by
|
|
1331
1523
|
/// stage_external_core.mjs. A directory LazyPath supplies ordering only for
|
|
1332
1524
|
/// this source tree; these file inputs make implementation-only SDK edits
|
|
@@ -1334,7 +1526,7 @@ fn addAppCoreTsDirInputs(b: *std.Build, stage: *std.Build.Step.Run, src_path: []
|
|
|
1334
1526
|
/// contract remains byte-identical. Public for the repository fixture graph,
|
|
1335
1527
|
/// which exercises the same compiler boundary as app builds.
|
|
1336
1528
|
pub fn addStagedCoreSdkInputs(b: *std.Build, sdk_builder: *std.Build, stage: *std.Build.Step.Run) void {
|
|
1337
|
-
for ([_][]const u8{ "text.ts", "events.ts" }) |source| {
|
|
1529
|
+
for ([_][]const u8{ "bytes.ts", "text.ts", "events.ts", "theme.ts", "internal/image_identity.ts", "internal/markdown_policy.ts" }) |source| {
|
|
1338
1530
|
stage.addFileInput(sdk_builder.path(b.fmt("packages/core/sdk/{s}", .{source})));
|
|
1339
1531
|
}
|
|
1340
1532
|
}
|
|
@@ -1453,11 +1645,12 @@ pub const MobileLibOptions = struct {
|
|
|
1453
1645
|
pub const MobileTsCore = struct {
|
|
1454
1646
|
/// The staged mobile wiring (mobile.zig beside the generated mirror).
|
|
1455
1647
|
main_root: std.Build.LazyPath,
|
|
1648
|
+
/// Separate root-markup module consumed by the compiled mobile view.
|
|
1649
|
+
app_markup_root: std.Build.LazyPath,
|
|
1456
1650
|
/// The compiled-core archive; merged into the embed library.
|
|
1457
1651
|
archive: std.Build.LazyPath,
|
|
1458
1652
|
/// The in-process service archive, when src/services exists.
|
|
1459
1653
|
service_archive: ?std.Build.LazyPath,
|
|
1460
|
-
markup_c: std.Build.LazyPath,
|
|
1461
1654
|
/// The app.zon module the mobile wiring reads scene chrome, identity,
|
|
1462
1655
|
/// and theme from (`app_manifest_zon`).
|
|
1463
1656
|
manifest_mod: *std.Build.Module,
|
|
@@ -1522,6 +1715,11 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
|
|
|
1522
1715
|
.optimize = optimize,
|
|
1523
1716
|
});
|
|
1524
1717
|
mod.addImport("app_manifest_zon", ts.manifest_mod);
|
|
1718
|
+
mod.addImport("app_markup_root", b.createModule(.{
|
|
1719
|
+
.root_source_file = ts.app_markup_root,
|
|
1720
|
+
.target = target,
|
|
1721
|
+
.optimize = optimize,
|
|
1722
|
+
}));
|
|
1525
1723
|
break :ts_app mod;
|
|
1526
1724
|
} else localModule(b, target, optimize, options.main);
|
|
1527
1725
|
app_mod.addImport("native_sdk", native_sdk_mod);
|
|
@@ -1536,7 +1734,6 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
|
|
|
1536
1734
|
// host link already passes).
|
|
1537
1735
|
exports_mod.link_libc = true;
|
|
1538
1736
|
exports_mod.addObjectFile(ts.archive);
|
|
1539
|
-
exports_mod.addObjectFile(markupDataObject(b, target, optimize, ts.markup_c).getEmittedBin());
|
|
1540
1737
|
if (ts.service_archive) |service_archive| exports_mod.addObjectFile(service_archive);
|
|
1541
1738
|
}
|
|
1542
1739
|
if (options.store_capability or options.relational_capability) {
|
|
@@ -1562,15 +1759,20 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
|
|
|
1562
1759
|
.use_llvm = useLlvmWorkaround(target),
|
|
1563
1760
|
});
|
|
1564
1761
|
|
|
1762
|
+
if (options.ts_core != null) {
|
|
1763
|
+
// The compiled view decodes JSON numbers through Zig's f128
|
|
1764
|
+
// helpers. C/Objective-C hosts link this archive directly rather
|
|
1765
|
+
// than through Zig, so it must carry its compiler runtime too.
|
|
1766
|
+
lib.bundle_compiler_rt = true;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1565
1769
|
const lib_step = b.step("lib", "Build the mobile embed static library");
|
|
1566
|
-
if (options.ts_core != null and target.result.abi.isAndroid()) {
|
|
1567
|
-
//
|
|
1568
|
-
//
|
|
1569
|
-
//
|
|
1570
|
-
//
|
|
1571
|
-
|
|
1572
|
-
// the archive it already stages.
|
|
1573
|
-
const merged = mergeMobileArchive(b, dep, lib, options.name);
|
|
1770
|
+
if (options.ts_core != null and (target.result.os.tag == .ios or target.result.abi.isAndroid())) {
|
|
1771
|
+
// Android's ELF archive contains nested TypeScript archives that
|
|
1772
|
+
// the NDK linker skips. On iOS, Zig's Mach-O archive can place
|
|
1773
|
+
// members off an 8-byte boundary, which Apple ld64 rejects.
|
|
1774
|
+
// Rebuild either output as a plain object archive before install.
|
|
1775
|
+
const merged = mergeMobileArchive(b, dep, lib, options.name, if (target.result.os.tag == .ios) "darwin" else "gnu");
|
|
1574
1776
|
const lib_name = b.fmt("lib{s}.a", .{options.name});
|
|
1575
1777
|
b.getInstallStep().dependOn(&b.addInstallFileWithDir(merged, .lib, lib_name).step);
|
|
1576
1778
|
lib_step.dependOn(&b.addInstallFileWithDir(merged, .lib, lib_name).step);
|
|
@@ -1580,15 +1782,14 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
|
|
|
1580
1782
|
}
|
|
1581
1783
|
}
|
|
1582
1784
|
|
|
1583
|
-
///
|
|
1584
|
-
///
|
|
1585
|
-
|
|
1586
|
-
fn mergeMobileArchive(b: *std.Build, dep: *std.Build.Dependency, lib: *std.Build.Step.Compile, name: []const u8) std.Build.LazyPath {
|
|
1785
|
+
/// Rebuild a TypeScript embed library from its object members. Android
|
|
1786
|
+
/// needs flattening; iOS needs Darwin archive member alignment.
|
|
1787
|
+
fn mergeMobileArchive(b: *std.Build, dep: *std.Build.Dependency, lib: *std.Build.Step.Compile, name: []const u8, format: []const u8) std.Build.LazyPath {
|
|
1587
1788
|
const node = b.findProgram(&.{"node"}, &.{}) catch
|
|
1588
1789
|
@panic("\nmerging the mobile TypeScript archives needs node on PATH (the TypeScript core lane already requires it).\n");
|
|
1589
1790
|
const merge = b.addSystemCommand(&.{node});
|
|
1590
1791
|
merge.addFileArg(dep.path("packages/core/scripts/merge_static_archives.mjs"));
|
|
1591
|
-
merge.addArgs(&.{ "--zig", b.graph.zig_exe, "--format",
|
|
1792
|
+
merge.addArgs(&.{ "--zig", b.graph.zig_exe, "--format", format });
|
|
1592
1793
|
merge.addArg("--out");
|
|
1593
1794
|
const merged = merge.addOutputFileArg(b.fmt("lib{s}.a", .{name}));
|
|
1594
1795
|
merge.addArg("--in");
|
|
@@ -1627,6 +1828,14 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1627
1828
|
detectCoreTree(b, app_options.app_root)
|
|
1628
1829
|
else
|
|
1629
1830
|
.zig;
|
|
1831
|
+
const typescript_view = b.option(bool, "typescript-view", "Compile Native markup beside the TypeScript model (default for TypeScript apps; rebuild after markup edits)") orelse (core_tree == .ts);
|
|
1832
|
+
if (typescript_view and core_tree != .ts) @panic("-Dtypescript-view requires src/core.ts");
|
|
1833
|
+
const view_reload = b.option(bool, "view-reload", "Debug builds with -Dtypescript-view: let `native dev` apply markup edits to the running app without a rebuild") orelse false;
|
|
1834
|
+
if (view_reload) {
|
|
1835
|
+
if (!typescript_view) @panic("\n-Dview-reload reloads compiled TypeScript views; it requires -Dtypescript-view=true\n");
|
|
1836
|
+
if (app_optimize != .Debug) @panic("\n-Dview-reload is a development feature; it requires -Doptimize=Debug\n");
|
|
1837
|
+
if (target.result.os.tag == .ios or target.result.abi.isAndroid()) @panic("\n-Dview-reload applies to desktop development runs; mobile builds reload by rebuilding\n");
|
|
1838
|
+
}
|
|
1630
1839
|
if (core_tree == .both) {
|
|
1631
1840
|
@panic("\nthis app declares two cores: src/core.ts (TypeScript) and src/main.zig (Zig)." ++
|
|
1632
1841
|
"\nAn app has exactly one core - the tree is the truth. Keep src/core.ts and delete" ++
|
|
@@ -1675,12 +1884,15 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1675
1884
|
app_config.relational_capability,
|
|
1676
1885
|
app_config.credentials_capability,
|
|
1677
1886
|
app_config.credentials_permission,
|
|
1887
|
+
app_config.keyboard_input_permission,
|
|
1678
1888
|
app_config.persist_version,
|
|
1679
1889
|
app_config.service_packages,
|
|
1680
1890
|
service_carrier_choice,
|
|
1681
1891
|
service_pool_workers,
|
|
1682
1892
|
build_trace,
|
|
1683
1893
|
scriptc_optimization,
|
|
1894
|
+
typescript_view,
|
|
1895
|
+
view_reload,
|
|
1684
1896
|
)
|
|
1685
1897
|
else
|
|
1686
1898
|
null;
|
|
@@ -1698,7 +1910,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1698
1910
|
// `-Dtarget`. Desktop targets keep the step absent. A TypeScript core
|
|
1699
1911
|
// roots the library's app module at the staged mobile wiring and
|
|
1700
1912
|
// merges the compiled archives into it.
|
|
1701
|
-
if (target.result.os.tag == .ios or target.result.abi.isAndroid()) {
|
|
1913
|
+
if (app_options.mobile_lib or target.result.os.tag == .ios or target.result.abi.isAndroid()) {
|
|
1702
1914
|
addMobileLibWithTarget(b, dep, target, optimize, .{
|
|
1703
1915
|
.name = app_options.name,
|
|
1704
1916
|
.main = appPath(b, app_options.app_root, app_options.main),
|
|
@@ -1712,9 +1924,9 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1712
1924
|
.max_image_pixel_bytes = app_config.max_image_pixel_bytes,
|
|
1713
1925
|
.ts_core = if (ts_stage) |stage| .{
|
|
1714
1926
|
.main_root = stage.mobile_root,
|
|
1927
|
+
.app_markup_root = stage.app_markup_root,
|
|
1715
1928
|
.archive = stage.archive,
|
|
1716
1929
|
.service_archive = stage.service_archive,
|
|
1717
|
-
.markup_c = stage.markup_c,
|
|
1718
1930
|
.manifest_mod = appManifestModule(b, app_options.app_root, manifest_name),
|
|
1719
1931
|
} else null,
|
|
1720
1932
|
});
|
|
@@ -1723,6 +1935,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1723
1935
|
const trace_option = b.option(TraceOption, "trace", "Trace output: off, events, runtime, all") orelse .events;
|
|
1724
1936
|
const debug_overlay = b.option(bool, "debug-overlay", "Enable debug overlay output") orelse false;
|
|
1725
1937
|
const automation_enabled = b.option(bool, "automation", "Enable Native SDK automation artifacts") orelse false;
|
|
1938
|
+
const webview_inspection = b.option(bool, "webview-inspect", "Enable macOS system WebView inspection (default: Debug builds only)");
|
|
1726
1939
|
const js_bridge_enabled = b.option(bool, "js-bridge", "Enable optional JavaScript bridge stubs") orelse false;
|
|
1727
1940
|
const web_engine_override = b.option(WebEngineOption, "web-engine", "Override app.zon web engine: system, chromium");
|
|
1728
1941
|
const web_layer_override = b.option(WebLayerOption, "web-layer", "Override app.zon webview_layer: auto, include, exclude");
|
|
@@ -1764,17 +1977,26 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1764
1977
|
options.addOption([]const u8, "web_engine", @tagName(web_engine));
|
|
1765
1978
|
options.addOption(bool, "debug_overlay", debug_overlay);
|
|
1766
1979
|
options.addOption(bool, "automation", automation_enabled);
|
|
1980
|
+
options.addOption(?bool, "webview_inspection", webview_inspection);
|
|
1767
1981
|
options.addOption(bool, "js_bridge", js_bridge_enabled);
|
|
1768
1982
|
options.addOption(bool, "web_layer", web_layer);
|
|
1769
1983
|
const options_mod = options.createModule();
|
|
1770
1984
|
|
|
1771
|
-
const
|
|
1985
|
+
const defer_ts_archives = target.result.ofmt == .elf;
|
|
1986
|
+
const app_mod = appModule(b, dep, target, app_optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config, !defer_ts_archives);
|
|
1772
1987
|
// TypeScript app code and platform hosts are expensive Zig/Clang semantic
|
|
1773
1988
|
// work but do not depend on primary markup bytes. Compile them once into
|
|
1774
1989
|
// an object, then make the executable a link-only artifact over that
|
|
1775
1990
|
// cached object plus the tiny generated markup-data object. A markup edit
|
|
1776
1991
|
// therefore avoids re-analyzing the SDK and app runner entirely.
|
|
1777
1992
|
const exe_root = if (ts_stage) |stage| root: {
|
|
1993
|
+
// COFF has no relocatable link for merging the compiled core archive
|
|
1994
|
+
// and platform C/C++ objects into one object. Keep all those inputs
|
|
1995
|
+
// on the executable's final link instead, including Debug markup.
|
|
1996
|
+
if (target.result.os.tag == .windows) {
|
|
1997
|
+
if (app_optimize == .Debug) app_mod.addObject(markupDataObject(b, target, app_optimize, stage.markup_c));
|
|
1998
|
+
break :root app_mod;
|
|
1999
|
+
}
|
|
1778
2000
|
const app_code = b.addObject(.{
|
|
1779
2001
|
.name = b.fmt("{s}-app-code", .{app_options.name}),
|
|
1780
2002
|
.root_module = app_mod,
|
|
@@ -1782,7 +2004,14 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1782
2004
|
});
|
|
1783
2005
|
const link_mod = b.createModule(.{ .target = target, .optimize = app_optimize });
|
|
1784
2006
|
link_mod.addObject(app_code);
|
|
1785
|
-
|
|
2007
|
+
// ELF relocatable links can leave an archive's unwind terminator
|
|
2008
|
+
// before later .eh_frame records. Keep the compiled archives on the
|
|
2009
|
+
// final link, preserving unwind data and the cached app-code split.
|
|
2010
|
+
if (defer_ts_archives) {
|
|
2011
|
+
link_mod.addObjectFile(stage.archive);
|
|
2012
|
+
if (stage.service_archive) |service_archive| link_mod.addObjectFile(service_archive);
|
|
2013
|
+
}
|
|
2014
|
+
if (app_optimize == .Debug) link_mod.addObject(markupDataObject(b, target, app_optimize, stage.markup_c));
|
|
1786
2015
|
// Object dependencies propagate framework/system-library NAMES, but
|
|
1787
2016
|
// Zig does not propagate the search paths or rpaths recorded on the
|
|
1788
2017
|
// module that produced an object. Restate those path-only facts on
|
|
@@ -1849,14 +2078,48 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1849
2078
|
// the production app module feeds the cached app-code object and must not
|
|
1850
2079
|
// absorb the separately linked markup data object.
|
|
1851
2080
|
const test_app_mod = if (ts_stage != null or app_optimize != optimize)
|
|
1852
|
-
appModule(b, dep, target, optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config)
|
|
2081
|
+
appModule(b, dep, target, optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config, true)
|
|
1853
2082
|
else
|
|
1854
2083
|
app_mod;
|
|
1855
|
-
if (ts_stage) |stage|
|
|
2084
|
+
if (ts_stage) |stage| {
|
|
2085
|
+
if (optimize == .Debug) test_app_mod.addObject(markupDataObject(b, target, optimize, stage.markup_c));
|
|
2086
|
+
}
|
|
1856
2087
|
const tests = b.addTest(.{ .root_module = test_app_mod, .use_llvm = useLlvmWorkaround(target) });
|
|
1857
2088
|
const test_step = b.step("test", "Run tests");
|
|
1858
2089
|
test_step.dependOn(&b.addRunArtifact(tests).step);
|
|
1859
2090
|
|
|
2091
|
+
// Authored Node tests drive a separately linked native TestHarness host.
|
|
2092
|
+
// Apps without tests pay no extra compile/link cost.
|
|
2093
|
+
if (ts_stage != null and hasTypeScriptTests(b, app_options.app_root)) {
|
|
2094
|
+
const host_root = b.addWriteFiles().add("native_test_main.zig",
|
|
2095
|
+
\\pub const main = @import("app").testMain;
|
|
2096
|
+
\\
|
|
2097
|
+
);
|
|
2098
|
+
const host_mod = b.createModule(.{ .root_source_file = host_root, .target = target, .optimize = optimize });
|
|
2099
|
+
host_mod.addImport("app", test_app_mod);
|
|
2100
|
+
// The headless host bypasses linkPlatform, but the compiled core's
|
|
2101
|
+
// runtime still references the Windows networking and crypto APIs.
|
|
2102
|
+
if (target.result.os.tag == .windows) {
|
|
2103
|
+
host_mod.linkSystemLibrary("ws2_32", .{});
|
|
2104
|
+
host_mod.linkSystemLibrary("iphlpapi", .{});
|
|
2105
|
+
host_mod.linkSystemLibrary("advapi32", .{});
|
|
2106
|
+
}
|
|
2107
|
+
const host = b.addExecutable(.{
|
|
2108
|
+
.name = b.fmt("{s}-test-host", .{app_options.name}),
|
|
2109
|
+
.root_module = host_mod,
|
|
2110
|
+
.use_llvm = useLlvmWorkaround(target),
|
|
2111
|
+
});
|
|
2112
|
+
const node_tests = b.addSystemCommand(&.{tsToolingPreflight(b, dep, .app_core)});
|
|
2113
|
+
node_tests.addArgs(&.{ "--test-reporter=spec", "--test-reporter-destination=stderr" });
|
|
2114
|
+
node_tests.addFileArg(dep.path("build/ts_run.mjs"));
|
|
2115
|
+
node_tests.addFileArg(dep.path("packages/core/scripts/run_native_tests.mjs"));
|
|
2116
|
+
node_tests.addArtifactArg(host);
|
|
2117
|
+
node_tests.addDirectoryArg(b.path(appPath(b, app_options.app_root, "tests")));
|
|
2118
|
+
node_tests.setCwd(b.path(app_options.app_root));
|
|
2119
|
+
node_tests.has_side_effects = true;
|
|
2120
|
+
test_step.dependOn(&node_tests.step);
|
|
2121
|
+
}
|
|
2122
|
+
|
|
1860
2123
|
// `native test` must surface the app's compile-time teaching errors,
|
|
1861
2124
|
// not just its test failures. Test builds never analyze `main` (the
|
|
1862
2125
|
// test runner replaces the entry point), so rules that fire inside it
|
|
@@ -1888,49 +2151,53 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1888
2151
|
});
|
|
1889
2152
|
test_step.dependOn(&analysis_obj.step);
|
|
1890
2153
|
|
|
1891
|
-
// `zig build model-contract`: reflect
|
|
2154
|
+
// `zig build model-contract`: reflect a Zig core's Model/Msg into
|
|
1892
2155
|
// zig-out/model-contract.zon so `native check` can verify markup
|
|
1893
2156
|
// bindings against the app's real surface without compiling the app.
|
|
1894
2157
|
// The artifact carries a hash over the app's Zig sources; the checker
|
|
1895
2158
|
// degrades to structural checking when it goes stale. Apps without a
|
|
1896
2159
|
// pub Model/Msg pair make this a silent no-op. The test step refreshes
|
|
1897
|
-
// the artifact too, so CI-checked apps always hold a fresh one.
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
);
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2160
|
+
// the artifact too, so CI-checked apps always hold a fresh one. A
|
|
2161
|
+
// TypeScript core needs no artifact: `native check` compiles its views
|
|
2162
|
+
// against the core contract directly.
|
|
2163
|
+
if (ts_stage == null) {
|
|
2164
|
+
const contract_root = b.addWriteFiles().add("model_contract_emit.zig",
|
|
2165
|
+
\\//! Generated by the app build: emits the model contract artifact
|
|
2166
|
+
\\//! (see the toolkit's ui_markup_contract.zig).
|
|
2167
|
+
\\const std = @import("std");
|
|
2168
|
+
\\const native_sdk = @import("native_sdk");
|
|
2169
|
+
\\const app = @import("app");
|
|
2170
|
+
\\
|
|
2171
|
+
\\pub fn main(init: std.process.Init) !void {
|
|
2172
|
+
\\ try native_sdk.canvas.emitModelContractMain(app, init);
|
|
2173
|
+
\\}
|
|
2174
|
+
\\
|
|
2175
|
+
);
|
|
2176
|
+
// The emit root must share the app module's native_sdk instance so
|
|
2177
|
+
// the Msg payload types it classifies are the same types the app
|
|
2178
|
+
// declares its variants with.
|
|
2179
|
+
const contract_mod = b.createModule(.{
|
|
2180
|
+
.root_source_file = contract_root,
|
|
2181
|
+
.target = target,
|
|
2182
|
+
.optimize = optimize,
|
|
2183
|
+
});
|
|
2184
|
+
contract_mod.addImport("app", test_app_mod);
|
|
2185
|
+
if (test_app_mod.import_table.get("native_sdk")) |sdk_mod| {
|
|
2186
|
+
contract_mod.addImport("native_sdk", sdk_mod);
|
|
2187
|
+
}
|
|
2188
|
+
const contract_exe = b.addExecutable(.{
|
|
2189
|
+
.name = b.fmt("{s}-model-contract", .{app_options.name}),
|
|
2190
|
+
.root_module = contract_mod,
|
|
2191
|
+
.use_llvm = useLlvmWorkaround(target),
|
|
2192
|
+
});
|
|
2193
|
+
const contract_run = b.addRunArtifact(contract_exe);
|
|
2194
|
+
contract_run.setCwd(b.path(app_options.app_root));
|
|
2195
|
+
contract_run.addArgs(&.{ "--src", "src", "--out", "zig-out/model-contract.zon" });
|
|
2196
|
+
contract_run.has_side_effects = true;
|
|
2197
|
+
const contract_step = b.step("model-contract", "Emit zig-out/model-contract.zon for `native check`");
|
|
2198
|
+
contract_step.dependOn(&contract_run.step);
|
|
2199
|
+
test_step.dependOn(&contract_run.step);
|
|
1921
2200
|
}
|
|
1922
|
-
const contract_exe = b.addExecutable(.{
|
|
1923
|
-
.name = b.fmt("{s}-model-contract", .{app_options.name}),
|
|
1924
|
-
.root_module = contract_mod,
|
|
1925
|
-
.use_llvm = useLlvmWorkaround(target),
|
|
1926
|
-
});
|
|
1927
|
-
const contract_run = b.addRunArtifact(contract_exe);
|
|
1928
|
-
contract_run.setCwd(b.path(app_options.app_root));
|
|
1929
|
-
contract_run.addArgs(&.{ "--src", "src", "--out", "zig-out/model-contract.zon" });
|
|
1930
|
-
contract_run.has_side_effects = true;
|
|
1931
|
-
const contract_step = b.step("model-contract", "Emit zig-out/model-contract.zon for `native check`");
|
|
1932
|
-
contract_step.dependOn(&contract_run.step);
|
|
1933
|
-
test_step.dependOn(&contract_run.step);
|
|
1934
2201
|
|
|
1935
2202
|
// `zig build package`: bundle the built binary through the `native`
|
|
1936
2203
|
// CLI (built from the native_sdk dependency), so a scaffolded app can
|
|
@@ -2026,7 +2293,7 @@ fn exampleOptimizeMode(b: *std.Build, requested: ?std.builtin.OptimizeMode, defa
|
|
|
2026
2293
|
};
|
|
2027
2294
|
}
|
|
2028
2295
|
|
|
2029
|
-
fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, app_options: AppOptions, manifest_name: []const u8, options_mod: *std.Build.Module, ts_stage: ?TsCoreStage, relational_migrations: std.Build.LazyPath, app_config: AppManifestBuildConfig) *std.Build.Module {
|
|
2296
|
+
fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, app_options: AppOptions, manifest_name: []const u8, options_mod: *std.Build.Module, ts_stage: ?TsCoreStage, relational_migrations: std.Build.LazyPath, app_config: AppManifestBuildConfig, link_ts_archives: bool) *std.Build.Module {
|
|
2030
2297
|
const native_sdk_mod = nativeSdkModuleWithTerminal(b, dep, target, optimize, app_options.terminal_sessions);
|
|
2031
2298
|
const runner_mod = b.createModule(.{
|
|
2032
2299
|
.root_source_file = dep.path("src/app_runner/root.zig"),
|
|
@@ -2062,10 +2329,23 @@ fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Resolv
|
|
|
2062
2329
|
// The compiled-core archive links behind the staged mirror; the
|
|
2063
2330
|
// toolchain's runtime needs libc.
|
|
2064
2331
|
app_mod.link_libc = true;
|
|
2065
|
-
app_mod.addObjectFile(stage.archive);
|
|
2332
|
+
if (link_ts_archives) app_mod.addObjectFile(stage.archive);
|
|
2333
|
+
// Debug reads src/app.native only through the separately linked C
|
|
2334
|
+
// data object. Supplying this generated module in Debug would put
|
|
2335
|
+
// the authored root back into the app-code dependency graph even
|
|
2336
|
+
// though the runner's comptime branch never imports it.
|
|
2337
|
+
if (optimize != .Debug) {
|
|
2338
|
+
app_mod.addImport("app_markup_root", b.createModule(.{
|
|
2339
|
+
.root_source_file = stage.app_markup_root,
|
|
2340
|
+
.target = target,
|
|
2341
|
+
.optimize = optimize,
|
|
2342
|
+
}));
|
|
2343
|
+
}
|
|
2066
2344
|
// The in-process service archive links beside it (distinct symbol
|
|
2067
2345
|
// prefix; its runtime internals are localized).
|
|
2068
|
-
if (
|
|
2346
|
+
if (link_ts_archives) {
|
|
2347
|
+
if (stage.service_archive) |service_archive| app_mod.addObjectFile(service_archive);
|
|
2348
|
+
}
|
|
2069
2349
|
}
|
|
2070
2350
|
if (app_config.sqlite_capability) {
|
|
2071
2351
|
// `store` and the relational `sqlite` tier share this exact object.
|
|
@@ -2749,6 +3029,7 @@ const AppManifestBuildConfig = struct {
|
|
|
2749
3029
|
relational_capability: bool = false,
|
|
2750
3030
|
credentials_capability: bool = false,
|
|
2751
3031
|
credentials_permission: bool = false,
|
|
3032
|
+
keyboard_input_permission: bool = false,
|
|
2752
3033
|
filesystem_permission: bool = false,
|
|
2753
3034
|
max_image_pixel_bytes: usize = 1024 * 1024,
|
|
2754
3035
|
updates_enabled: bool = false,
|
|
@@ -2855,6 +3136,7 @@ fn appManifestBuildConfig(b: *std.Build, app_root: []const u8, manifest_name: []
|
|
|
2855
3136
|
.relational_capability = hasManifestCapability(raw.capabilities, "sqlite"),
|
|
2856
3137
|
.credentials_capability = hasManifestCapability(raw.capabilities, "credentials"),
|
|
2857
3138
|
.credentials_permission = hasManifestPermission(raw.permissions, "credentials"),
|
|
3139
|
+
.keyboard_input_permission = hasManifestPermission(raw.permissions, "keyboard_input"),
|
|
2858
3140
|
.filesystem_permission = hasManifestPermission(raw.permissions, "filesystem"),
|
|
2859
3141
|
.max_image_pixel_bytes = raw.images.max_image_pixel_bytes,
|
|
2860
3142
|
.updates_enabled = raw.updates != null,
|
|
@@ -2893,3 +3175,17 @@ fn resolveWebLayer(config: AppManifestBuildConfig, web_engine: WebEngineOption,
|
|
|
2893
3175
|
);
|
|
2894
3176
|
return decision.enabled;
|
|
2895
3177
|
}
|
|
3178
|
+
|
|
3179
|
+
/// One explicit discovery convention, shared with run_native_tests.mjs.
|
|
3180
|
+
fn hasTypeScriptTests(b: *std.Build, app_root: []const u8) bool {
|
|
3181
|
+
var dir = std.Io.Dir.cwd().openDir(b.graph.io, b.pathFromRoot(appPath(b, app_root, "tests")), .{ .iterate = true }) catch |err| switch (err) {
|
|
3182
|
+
error.FileNotFound => return false,
|
|
3183
|
+
else => @panic("cannot read app tests directory"),
|
|
3184
|
+
};
|
|
3185
|
+
defer dir.close(b.graph.io);
|
|
3186
|
+
var iterator = dir.iterate();
|
|
3187
|
+
while (iterator.next(b.graph.io) catch @panic("cannot enumerate app tests")) |entry| {
|
|
3188
|
+
if (entry.kind == .file and std.mem.endsWith(u8, entry.name, ".test.ts")) return true;
|
|
3189
|
+
}
|
|
3190
|
+
return false;
|
|
3191
|
+
}
|