@native-sdk/cli 0.0.0 → 0.4.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/LICENSE +176 -0
- package/README.md +50 -1
- package/app.zon +30 -0
- package/assets/icon.icns +0 -0
- package/assets/icon.ico +0 -0
- package/assets/icon.png +0 -0
- package/assets/icon.svg +15 -0
- package/assets/native-sdk.entitlements +10 -0
- package/assets/native-sdk.manifest +12 -0
- package/bin/native.js +156 -0
- package/build/app.zig +716 -0
- package/build.zig +2593 -0
- package/build.zig.zon +24 -0
- package/native-sdk.d.ts +615 -0
- package/package.json +45 -8
- package/skill-data/automation/SKILL.md +248 -0
- package/skill-data/core/SKILL.md +249 -0
- package/skill-data/core/references/app-model-runtime.md +141 -0
- package/skill-data/core/references/bridge-security-native-capabilities.md +230 -0
- package/skill-data/core/references/frontend-assets.md +124 -0
- package/skill-data/core/references/project-anatomy.md +108 -0
- package/skill-data/core/references/web-engines-packaging-debugging.md +199 -0
- package/skill-data/native-ui/SKILL.md +1080 -0
- package/skills/native-sdk/SKILL.md +33 -0
- package/src/app_runner/root.zig +740 -0
- package/src/assets/root.zig +20 -0
- package/src/automation/protocol.zig +285 -0
- package/src/automation/root.zig +13 -0
- package/src/automation/server.zig +506 -0
- package/src/automation/snapshot.zig +1202 -0
- package/src/automation/watcher.zig +165 -0
- package/src/bridge/root.zig +507 -0
- package/src/debug/root.zig +246 -0
- package/src/embed/app_exports.zig +11 -0
- package/src/embed/c_api.zig +793 -0
- package/src/embed/c_exports.zig +10 -0
- package/src/embed/chrome.zig +168 -0
- package/src/embed/conversions.zig +359 -0
- package/src/embed/host.zig +960 -0
- package/src/embed/root.zig +81 -0
- package/src/embed/tests.zig +2552 -0
- package/src/embed/types.zig +382 -0
- package/src/embed/ui_host.zig +289 -0
- package/src/extensions/root.zig +197 -0
- package/src/frontend/root.zig +48 -0
- package/src/js/root.zig +65 -0
- package/src/platform/android/NativeSdkActivity.java +1370 -0
- package/src/platform/android/android_host.c +696 -0
- package/src/platform/android/files.zig +9 -0
- package/src/platform/android/native_sdk_app.h +237 -0
- package/src/platform/ios/files.zig +8 -0
- package/src/platform/ios/native_sdk_app.h +289 -0
- package/src/platform/ios/uikit_host.m +2739 -0
- package/src/platform/linux/cef_host.cpp +599 -0
- package/src/platform/linux/gtk_host.c +5362 -0
- package/src/platform/linux/gtk_host.h +265 -0
- package/src/platform/linux/root.zig +1519 -0
- package/src/platform/macos/appkit_host.h +604 -0
- package/src/platform/macos/appkit_host.m +10392 -0
- package/src/platform/macos/automation_host.h +14 -0
- package/src/platform/macos/automation_host.m +12 -0
- package/src/platform/macos/cef_host.mm +3028 -0
- package/src/platform/macos/root.zig +2260 -0
- package/src/platform/null_platform.zig +2232 -0
- package/src/platform/null_platform_tests.zig +670 -0
- package/src/platform/policy_values.zig +14 -0
- package/src/platform/root.zig +181 -0
- package/src/platform/types.zig +2681 -0
- package/src/platform/windows/cef_host.cpp +3 -0
- package/src/platform/windows/root.zig +1521 -0
- package/src/platform/windows/webview2_host.cpp +6230 -0
- package/src/primitives/app_dirs/root.zig +440 -0
- package/src/primitives/app_manifest/root.zig +109 -0
- package/src/primitives/app_manifest/tests.zig +758 -0
- package/src/primitives/app_manifest/types.zig +587 -0
- package/src/primitives/app_manifest/validation.zig +828 -0
- package/src/primitives/assets/root.zig +520 -0
- package/src/primitives/canvas/a11y_audit.zig +390 -0
- package/src/primitives/canvas/a11y_audit_tests.zig +225 -0
- package/src/primitives/canvas/app_icon.zig +1590 -0
- package/src/primitives/canvas/chart.zig +392 -0
- package/src/primitives/canvas/chart_tests.zig +751 -0
- package/src/primitives/canvas/commands.zig +446 -0
- package/src/primitives/canvas/drawing.zig +309 -0
- package/src/primitives/canvas/equality.zig +316 -0
- package/src/primitives/canvas/events.zig +696 -0
- package/src/primitives/canvas/font_coverage.zig +118 -0
- package/src/primitives/canvas/font_ttf.zig +510 -0
- package/src/primitives/canvas/font_ttf_tests.zig +280 -0
- package/src/primitives/canvas/fonts/Geist-Regular.ttf +0 -0
- package/src/primitives/canvas/fonts/GeistMono-Regular.ttf +0 -0
- package/src/primitives/canvas/frame.zig +679 -0
- package/src/primitives/canvas/frame_metrics.zig +462 -0
- package/src/primitives/canvas/gpu.zig +639 -0
- package/src/primitives/canvas/hash.zig +112 -0
- package/src/primitives/canvas/icons/alert.svg +1 -0
- package/src/primitives/canvas/icons/archive.svg +1 -0
- package/src/primitives/canvas/icons/arrow-down.svg +1 -0
- package/src/primitives/canvas/icons/arrow-right.svg +1 -0
- package/src/primitives/canvas/icons/arrow-up.svg +1 -0
- package/src/primitives/canvas/icons/check-circle.svg +1 -0
- package/src/primitives/canvas/icons/check.svg +1 -0
- package/src/primitives/canvas/icons/chevron-down.svg +1 -0
- package/src/primitives/canvas/icons/chevron-left.svg +1 -0
- package/src/primitives/canvas/icons/chevron-right.svg +1 -0
- package/src/primitives/canvas/icons/chevron-up.svg +1 -0
- package/src/primitives/canvas/icons/circle-dot.svg +1 -0
- package/src/primitives/canvas/icons/clock.svg +1 -0
- package/src/primitives/canvas/icons/copy.svg +1 -0
- package/src/primitives/canvas/icons/download.svg +1 -0
- package/src/primitives/canvas/icons/edit.svg +1 -0
- package/src/primitives/canvas/icons/ellipsis.svg +1 -0
- package/src/primitives/canvas/icons/external-link.svg +1 -0
- package/src/primitives/canvas/icons/eye.svg +1 -0
- package/src/primitives/canvas/icons/file-text.svg +1 -0
- package/src/primitives/canvas/icons/folder-open.svg +1 -0
- package/src/primitives/canvas/icons/folder.svg +1 -0
- package/src/primitives/canvas/icons/git-branch.svg +1 -0
- package/src/primitives/canvas/icons/git-merge.svg +1 -0
- package/src/primitives/canvas/icons/git-pull-request.svg +1 -0
- package/src/primitives/canvas/icons/info.svg +1 -0
- package/src/primitives/canvas/icons/menu.svg +1 -0
- package/src/primitives/canvas/icons/missing.svg +1 -0
- package/src/primitives/canvas/icons/moon.svg +1 -0
- package/src/primitives/canvas/icons/music.svg +1 -0
- package/src/primitives/canvas/icons/panel-left.svg +1 -0
- package/src/primitives/canvas/icons/panel-right.svg +1 -0
- package/src/primitives/canvas/icons/pause.svg +1 -0
- package/src/primitives/canvas/icons/play.svg +1 -0
- package/src/primitives/canvas/icons/plus.svg +1 -0
- package/src/primitives/canvas/icons/refresh-cw.svg +1 -0
- package/src/primitives/canvas/icons/repeat.svg +1 -0
- package/src/primitives/canvas/icons/save.svg +1 -0
- package/src/primitives/canvas/icons/search.svg +1 -0
- package/src/primitives/canvas/icons/send.svg +1 -0
- package/src/primitives/canvas/icons/settings.svg +1 -0
- package/src/primitives/canvas/icons/shuffle.svg +1 -0
- package/src/primitives/canvas/icons/skip-back.svg +1 -0
- package/src/primitives/canvas/icons/skip-forward.svg +1 -0
- package/src/primitives/canvas/icons/sun.svg +1 -0
- package/src/primitives/canvas/icons/terminal.svg +1 -0
- package/src/primitives/canvas/icons/trash.svg +1 -0
- package/src/primitives/canvas/icons/volume.svg +1 -0
- package/src/primitives/canvas/icons/wrench.svg +1 -0
- package/src/primitives/canvas/icons/x-circle.svg +1 -0
- package/src/primitives/canvas/icons/x.svg +1 -0
- package/src/primitives/canvas/icons.zig +249 -0
- package/src/primitives/canvas/layout_audit.zig +744 -0
- package/src/primitives/canvas/layout_audit_tests.zig +426 -0
- package/src/primitives/canvas/markdown.zig +1031 -0
- package/src/primitives/canvas/markdown_hostile_tests.zig +471 -0
- package/src/primitives/canvas/markdown_tests.zig +538 -0
- package/src/primitives/canvas/plan_key_index.zig +120 -0
- package/src/primitives/canvas/png.zig +355 -0
- package/src/primitives/canvas/reference.zig +1457 -0
- package/src/primitives/canvas/reference_blur.zig +104 -0
- package/src/primitives/canvas/reference_memo.zig +322 -0
- package/src/primitives/canvas/reference_paths.zig +184 -0
- package/src/primitives/canvas/reference_tests.zig +1650 -0
- package/src/primitives/canvas/render.zig +747 -0
- package/src/primitives/canvas/render_effects.zig +255 -0
- package/src/primitives/canvas/render_fingerprints.zig +256 -0
- package/src/primitives/canvas/render_generic_resources.zig +376 -0
- package/src/primitives/canvas/render_images.zig +247 -0
- package/src/primitives/canvas/render_layers.zig +260 -0
- package/src/primitives/canvas/render_paths.zig +347 -0
- package/src/primitives/canvas/render_resources.zig +51 -0
- package/src/primitives/canvas/render_tests.zig +3186 -0
- package/src/primitives/canvas/root.zig +744 -0
- package/src/primitives/canvas/serialization.zig +1528 -0
- package/src/primitives/canvas/svg_icon.zig +636 -0
- package/src/primitives/canvas/svg_icon_tests.zig +312 -0
- package/src/primitives/canvas/test_support.zig +422 -0
- package/src/primitives/canvas/testdata/markdown_document.md +83 -0
- package/src/primitives/canvas/tests.zig +30 -0
- package/src/primitives/canvas/text.zig +82 -0
- package/src/primitives/canvas/text_atlas.zig +408 -0
- package/src/primitives/canvas/text_batch_tests.zig +431 -0
- package/src/primitives/canvas/text_interaction.zig +615 -0
- package/src/primitives/canvas/text_layout.zig +1069 -0
- package/src/primitives/canvas/text_layout_cache.zig +281 -0
- package/src/primitives/canvas/text_layout_hash.zig +113 -0
- package/src/primitives/canvas/text_layout_types.zig +128 -0
- package/src/primitives/canvas/text_measure_cache.zig +279 -0
- package/src/primitives/canvas/text_metrics.zig +309 -0
- package/src/primitives/canvas/text_metrics_tests.zig +262 -0
- package/src/primitives/canvas/text_span_tests.zig +608 -0
- package/src/primitives/canvas/text_spans.zig +1010 -0
- package/src/primitives/canvas/text_tests.zig +1949 -0
- package/src/primitives/canvas/themes/geist.zig +470 -0
- package/src/primitives/canvas/tokens.zig +1522 -0
- package/src/primitives/canvas/ui.zig +2686 -0
- package/src/primitives/canvas/ui_markup.zig +3791 -0
- package/src/primitives/canvas/ui_markup_binary.zig +522 -0
- package/src/primitives/canvas/ui_markup_binary_tests.zig +591 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +2565 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1669 -0
- package/src/primitives/canvas/ui_markup_contract.zig +1620 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +953 -0
- package/src/primitives/canvas/ui_markup_edit.zig +416 -0
- package/src/primitives/canvas/ui_markup_edit_tests.zig +341 -0
- package/src/primitives/canvas/ui_markup_expr.zig +1152 -0
- package/src/primitives/canvas/ui_markup_expr_tests.zig +779 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +505 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +1545 -0
- package/src/primitives/canvas/ui_markup_view.zig +2352 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +3709 -0
- package/src/primitives/canvas/ui_provenance.zig +96 -0
- package/src/primitives/canvas/ui_provenance_tests.zig +186 -0
- package/src/primitives/canvas/ui_schema.zig +825 -0
- package/src/primitives/canvas/ui_schema_tests.zig +128 -0
- package/src/primitives/canvas/ui_tests.zig +1432 -0
- package/src/primitives/canvas/vector.zig +919 -0
- package/src/primitives/canvas/vector_tests.zig +547 -0
- package/src/primitives/canvas/virtual_extent_tests.zig +317 -0
- package/src/primitives/canvas/virtual_extents.zig +540 -0
- package/src/primitives/canvas/widget_access.zig +208 -0
- package/src/primitives/canvas/widget_anchored_tests.zig +264 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +3160 -0
- package/src/primitives/canvas/widget_invalidation.zig +748 -0
- package/src/primitives/canvas/widget_layout.zig +2055 -0
- package/src/primitives/canvas/widget_layout_tests.zig +2691 -0
- package/src/primitives/canvas/widget_metrics.zig +228 -0
- package/src/primitives/canvas/widget_render.zig +2534 -0
- package/src/primitives/canvas/widget_render_controls.zig +1563 -0
- package/src/primitives/canvas/widget_render_scroll.zig +136 -0
- package/src/primitives/canvas/widget_render_style.zig +626 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +794 -0
- package/src/primitives/canvas/widget_routing.zig +475 -0
- package/src/primitives/canvas/widget_runtime.zig +307 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +3015 -0
- package/src/primitives/canvas/widget_semantics.zig +480 -0
- package/src/primitives/canvas/widget_semantics_tests.zig +2129 -0
- package/src/primitives/canvas/widget_tests.zig +8 -0
- package/src/primitives/canvas/widget_text_input.zig +351 -0
- package/src/primitives/canvas/widget_text_select.zig +147 -0
- package/src/primitives/canvas/widget_tree.zig +232 -0
- package/src/primitives/canvas/widgets.zig +1319 -0
- package/src/primitives/diagnostics/root.zig +445 -0
- package/src/primitives/geometry/root.zig +889 -0
- package/src/primitives/json/root.zig +272 -0
- package/src/primitives/platform_info/root.zig +450 -0
- package/src/primitives/trace/root.zig +569 -0
- package/src/root.zig +165 -0
- package/src/runtime/api.zig +431 -0
- package/src/runtime/async_bridge.zig +49 -0
- package/src/runtime/automation_commands.zig +686 -0
- package/src/runtime/automation_liveness_tests.zig +140 -0
- package/src/runtime/automation_snapshot.zig +246 -0
- package/src/runtime/automation_widget_dispatch.zig +617 -0
- package/src/runtime/bridge_dispatch_tests.zig +202 -0
- package/src/runtime/bridge_payload.zig +194 -0
- package/src/runtime/bridge_permission_tests.zig +551 -0
- package/src/runtime/bridge_responses.zig +414 -0
- package/src/runtime/builtin_bridge.zig +554 -0
- package/src/runtime/canvas_budget_edge_tests.zig +415 -0
- package/src/runtime/canvas_font_tests.zig +410 -0
- package/src/runtime/canvas_fonts.zig +229 -0
- package/src/runtime/canvas_frame.zig +1734 -0
- package/src/runtime/canvas_frame_animation_tests.zig +609 -0
- package/src/runtime/canvas_frame_cache_tests.zig +333 -0
- package/src/runtime/canvas_frame_helpers.zig +414 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +544 -0
- package/src/runtime/canvas_frame_packet_tests.zig +1353 -0
- package/src/runtime/canvas_frame_patch_tests.zig +1051 -0
- package/src/runtime/canvas_frame_retained_tests.zig +753 -0
- package/src/runtime/canvas_frame_tests.zig +9 -0
- package/src/runtime/canvas_frame_text_layout_budget_tests.zig +149 -0
- package/src/runtime/canvas_image_tests.zig +362 -0
- package/src/runtime/canvas_images.zig +224 -0
- package/src/runtime/canvas_limits.zig +317 -0
- package/src/runtime/canvas_screenshot_tests.zig +289 -0
- package/src/runtime/canvas_widget_accessibility_tests.zig +1494 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +678 -0
- package/src/runtime/canvas_widget_chart_tests.zig +249 -0
- package/src/runtime/canvas_widget_clipboard_tests.zig +399 -0
- package/src/runtime/canvas_widget_context_menu.zig +318 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +462 -0
- package/src/runtime/canvas_widget_control_tests.zig +2164 -0
- package/src/runtime/canvas_widget_disclosure_tests.zig +440 -0
- package/src/runtime/canvas_widget_display.zig +677 -0
- package/src/runtime/canvas_widget_event_tests.zig +1779 -0
- package/src/runtime/canvas_widget_events.zig +1098 -0
- package/src/runtime/canvas_widget_floating_tests.zig +695 -0
- package/src/runtime/canvas_widget_layout_tests.zig +26 -0
- package/src/runtime/canvas_widget_runtime.zig +1335 -0
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +582 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +202 -0
- package/src/runtime/canvas_widget_scroll_tests.zig +1549 -0
- package/src/runtime/canvas_widget_semantics_tests.zig +810 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +1031 -0
- package/src/runtime/canvas_widget_state.zig +798 -0
- package/src/runtime/canvas_widget_text_tests.zig +2104 -0
- package/src/runtime/canvas_widget_window_drag_tests.zig +284 -0
- package/src/runtime/clock.zig +231 -0
- package/src/runtime/core.zig +927 -0
- package/src/runtime/effects.zig +4197 -0
- package/src/runtime/effects_audio_tests.zig +690 -0
- package/src/runtime/effects_clipboard_tests.zig +317 -0
- package/src/runtime/effects_fetch_tests.zig +1031 -0
- package/src/runtime/effects_file_tests.zig +407 -0
- package/src/runtime/effects_tests.zig +1251 -0
- package/src/runtime/flow.zig +1175 -0
- package/src/runtime/frame_profile.zig +221 -0
- package/src/runtime/gpu_surface_events.zig +639 -0
- package/src/runtime/launch_timing.zig +59 -0
- package/src/runtime/markdown_app_tests.zig +224 -0
- package/src/runtime/native_command_event_tests.zig +431 -0
- package/src/runtime/platform_bridge_tests.zig +8 -0
- package/src/runtime/platform_config_tests.zig +392 -0
- package/src/runtime/root.zig +150 -0
- package/src/runtime/runtime_event_tests.zig +1079 -0
- package/src/runtime/session_journal.zig +1522 -0
- package/src/runtime/session_record.zig +332 -0
- package/src/runtime/session_replay.zig +274 -0
- package/src/runtime/session_state.zig +30 -0
- package/src/runtime/session_tests.zig +399 -0
- package/src/runtime/shell_layout.zig +472 -0
- package/src/runtime/shell_layout_tests.zig +1246 -0
- package/src/runtime/shell_view_tests.zig +604 -0
- package/src/runtime/state.zig +110 -0
- package/src/runtime/system_services.zig +392 -0
- package/src/runtime/test_support.zig +79 -0
- package/src/runtime/tests.zig +30 -0
- package/src/runtime/ui_app.zig +3290 -0
- package/src/runtime/ui_app_huge_model_tests.zig +351 -0
- package/src/runtime/ui_app_provenance.zig +370 -0
- package/src/runtime/ui_app_tests.zig +3254 -0
- package/src/runtime/ui_app_virtual_variable_tests.zig +485 -0
- package/src/runtime/ui_app_window_tests.zig +442 -0
- package/src/runtime/validation.zig +206 -0
- package/src/runtime/view.zig +908 -0
- package/src/runtime/view_canvas.zig +850 -0
- package/src/runtime/view_widget_control.zig +433 -0
- package/src/runtime/view_widget_scroll.zig +360 -0
- package/src/runtime/view_widget_text.zig +275 -0
- package/src/runtime/view_widget_tree.zig +843 -0
- package/src/runtime/webview_view_bridge_tests.zig +664 -0
- package/src/runtime/widget_bridge.zig +231 -0
- package/src/runtime/window_command_bridge_tests.zig +403 -0
- package/src/runtime/window_storage.zig +255 -0
- package/src/runtime/window_view_runtime.zig +727 -0
- package/src/runtime/window_views.zig +334 -0
- package/src/security/root.zig +118 -0
- package/src/tooling/android.zig +1172 -0
- package/src/tooling/assets.zig +128 -0
- package/src/tooling/buildgraph.zig +379 -0
- package/src/tooling/cef.zig +671 -0
- package/src/tooling/codesign.zig +172 -0
- package/src/tooling/components/identity_tests.zig +185 -0
- package/src/tooling/components/stepper.zig +113 -0
- package/src/tooling/components/timeline.native +27 -0
- package/src/tooling/components/timeline_item.zig +131 -0
- package/src/tooling/default_icon.icns +0 -0
- package/src/tooling/default_icon.png +0 -0
- package/src/tooling/dev.zig +172 -0
- package/src/tooling/doctor.zig +349 -0
- package/src/tooling/eject_components.zig +170 -0
- package/src/tooling/embedlib.zig +290 -0
- package/src/tooling/ios.zig +528 -0
- package/src/tooling/manifest.zig +1939 -0
- package/src/tooling/package.zig +2388 -0
- package/src/tooling/process_tree.zig +114 -0
- package/src/tooling/raw_manifest.zig +193 -0
- package/src/tooling/root.zig +22 -0
- package/src/tooling/templates.zig +3191 -0
- package/src/tooling/toolchain.zig +371 -0
- package/src/tooling/verbs.zig +204 -0
- package/src/tooling/web_engine.zig +135 -0
- package/src/tooling/xcodeproj.zig +462 -0
- package/src/window_state/root.zig +507 -0
- package/index.js +0 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
//! Pin the automation LIVENESS contract: a command landing in the
|
|
2
|
+
//! dropbox while the app is completely idle — no animations, no input,
|
|
3
|
+
//! no timers armed, nothing invalidated — must still be consumed
|
|
4
|
+
//! promptly, because the arrival watcher asks the platform loop for a
|
|
5
|
+
//! frame. The scripted platform below is an honest model of that idle
|
|
6
|
+
//! state: after startup it BLOCKS with no frame source of its own, and
|
|
7
|
+
//! the only thing that can release it is a cross-thread frame request.
|
|
8
|
+
//! Before the watcher existed this test would sit until its failure
|
|
9
|
+
//! deadline, exactly like a real `widget-click` against a quiet app
|
|
10
|
+
//! sat until the CLI's timeout.
|
|
11
|
+
|
|
12
|
+
const support = @import("test_support.zig");
|
|
13
|
+
const std = support.std;
|
|
14
|
+
const automation = support.automation;
|
|
15
|
+
const platform = support.platform;
|
|
16
|
+
const App = support.App;
|
|
17
|
+
const Runtime = support.Runtime;
|
|
18
|
+
const Event = support.Event;
|
|
19
|
+
|
|
20
|
+
/// How long the idle loop is willing to wait for the watcher's frame
|
|
21
|
+
/// request before declaring the liveness contract broken. Generous so a
|
|
22
|
+
/// loaded machine never flakes; the observed wake is a few watcher polls
|
|
23
|
+
/// (~5 ms each) at most.
|
|
24
|
+
const wake_failure_budget_ns: u64 = 10 * std.time.ns_per_s;
|
|
25
|
+
|
|
26
|
+
/// The bound the test ASSERTS on. Still far above the expected wake
|
|
27
|
+
/// (a few watcher poll intervals) but far below the failure budget, so
|
|
28
|
+
/// a wake that only happens by accident-of-scheduling shows up loud.
|
|
29
|
+
const wake_asserted_budget_ns: u64 = 2 * std.time.ns_per_s;
|
|
30
|
+
|
|
31
|
+
const IdleLoop = struct {
|
|
32
|
+
null_platform: *platform.NullPlatform,
|
|
33
|
+
/// The dropbox directory (randomized per run: this test is compiled
|
|
34
|
+
/// into more than one test binary, and the aggregate build step runs
|
|
35
|
+
/// them in parallel — a fixed path would let two copies of this very
|
|
36
|
+
/// test delete each other's slot mid-run).
|
|
37
|
+
automation_dir: []const u8,
|
|
38
|
+
/// Nanoseconds of idle blocking before the watcher's frame request
|
|
39
|
+
/// arrived (sleep-accumulated, so an upper bound on the real wait).
|
|
40
|
+
woke_after_ns: u64 = 0,
|
|
41
|
+
|
|
42
|
+
/// A platform run loop with NO frame source of its own: startup
|
|
43
|
+
/// events, one startup frame, then a bare wait on the cross-thread
|
|
44
|
+
/// frame-request counter. The command is queued AFTER the startup
|
|
45
|
+
/// frame — from the loop's own thread, like a driver writing while
|
|
46
|
+
/// the app idles — so nothing but the watcher can ever drain it.
|
|
47
|
+
fn run(context: *anyopaque, handler: platform.EventHandler, handler_context: *anyopaque) anyerror!void {
|
|
48
|
+
const self: *IdleLoop = @ptrCast(@alignCast(context));
|
|
49
|
+
try handler(handler_context, .app_start);
|
|
50
|
+
try handler(handler_context, .{ .surface_resized = self.null_platform.surface_value });
|
|
51
|
+
try handler(handler_context, .frame_requested);
|
|
52
|
+
|
|
53
|
+
var path_buffer: [128]u8 = undefined;
|
|
54
|
+
try std.Io.Dir.cwd().writeFile(std.testing.io, .{
|
|
55
|
+
.sub_path = try std.fmt.bufPrint(&path_buffer, "{s}/command-1.txt", .{self.automation_dir}),
|
|
56
|
+
.data = "menu-command app.probe\n",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var waited_ns: u64 = 0;
|
|
60
|
+
while (self.null_platform.takeFrameRequest() == null) {
|
|
61
|
+
if (waited_ns > wake_failure_budget_ns) return error.AutomationWakeNeverArrived;
|
|
62
|
+
try std.Io.sleep(std.testing.io, std.Io.Duration.fromNanoseconds(std.time.ns_per_ms), .awake);
|
|
63
|
+
waited_ns += std.time.ns_per_ms;
|
|
64
|
+
}
|
|
65
|
+
self.woke_after_ns = waited_ns;
|
|
66
|
+
|
|
67
|
+
try handler(handler_context, .frame_requested);
|
|
68
|
+
try handler(handler_context, .app_shutdown);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const ProbeApp = struct {
|
|
73
|
+
probed: bool = false,
|
|
74
|
+
|
|
75
|
+
fn event(context: *anyopaque, runtime: *Runtime, event_value: Event) anyerror!void {
|
|
76
|
+
_ = runtime;
|
|
77
|
+
const self: *ProbeApp = @ptrCast(@alignCast(context));
|
|
78
|
+
if (event_value == .command and std.mem.eql(u8, event_value.command.name, "app.probe")) {
|
|
79
|
+
self.probed = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fn app(self: *ProbeApp) App {
|
|
84
|
+
return .{
|
|
85
|
+
.context = self,
|
|
86
|
+
.name = "liveness-probe",
|
|
87
|
+
.source = platform.WebViewSource.html("<p>idle</p>"),
|
|
88
|
+
.event_fn = event,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
test "idle app consumes an automation command promptly via the arrival watcher" {
|
|
94
|
+
// Pid-suffixed: this test is compiled into more than one test binary
|
|
95
|
+
// and the aggregate build step runs them in parallel; parallel copies
|
|
96
|
+
// must not share a dropbox.
|
|
97
|
+
var dir_buffer: [64]u8 = undefined;
|
|
98
|
+
const automation_dir = try automation.watcher.testDirectory(&dir_buffer, ".zig-cache/test-automation-liveness");
|
|
99
|
+
var cwd = std.Io.Dir.cwd();
|
|
100
|
+
cwd.deleteTree(std.testing.io, automation_dir) catch {};
|
|
101
|
+
try cwd.createDirPath(std.testing.io, automation_dir);
|
|
102
|
+
defer cwd.deleteTree(std.testing.io, automation_dir) catch {};
|
|
103
|
+
|
|
104
|
+
// Heap-hosted: NullPlatform and Runtime are both multi-megabyte.
|
|
105
|
+
const null_platform = try std.heap.page_allocator.create(platform.NullPlatform);
|
|
106
|
+
defer std.heap.page_allocator.destroy(null_platform);
|
|
107
|
+
null_platform.* = platform.NullPlatform.init(.{});
|
|
108
|
+
var idle_loop: IdleLoop = .{ .null_platform = null_platform, .automation_dir = automation_dir };
|
|
109
|
+
|
|
110
|
+
// Keep the null platform's services (they carry their own context)
|
|
111
|
+
// but replace the run loop with the idle one above.
|
|
112
|
+
var platform_value = null_platform.platform();
|
|
113
|
+
platform_value.run_fn = IdleLoop.run;
|
|
114
|
+
platform_value.context = &idle_loop;
|
|
115
|
+
|
|
116
|
+
const runtime = try std.heap.page_allocator.create(Runtime);
|
|
117
|
+
defer std.heap.page_allocator.destroy(runtime);
|
|
118
|
+
Runtime.initAt(runtime, .{
|
|
119
|
+
.platform = platform_value,
|
|
120
|
+
.automation = automation.Server.init(std.testing.io, automation_dir, "Liveness"),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
var app_state: ProbeApp = .{};
|
|
124
|
+
try runtime.run(app_state.app());
|
|
125
|
+
|
|
126
|
+
// The command was dispatched through the real path (menu_command ->
|
|
127
|
+
// command event), and the wake arrived promptly — not by luck at the
|
|
128
|
+
// end of some long timeout.
|
|
129
|
+
try std.testing.expect(app_state.probed);
|
|
130
|
+
try std.testing.expect(idle_loop.woke_after_ns < wake_asserted_budget_ns);
|
|
131
|
+
|
|
132
|
+
// The drain deleted the queue entry — that deletion IS the ack the
|
|
133
|
+
// driver's await-consumption poll (the CLI's `delivered` report)
|
|
134
|
+
// watches for.
|
|
135
|
+
var path_buffer: [128]u8 = undefined;
|
|
136
|
+
try std.testing.expectError(
|
|
137
|
+
error.FileNotFound,
|
|
138
|
+
cwd.openFile(std.testing.io, try std.fmt.bufPrint(&path_buffer, "{s}/command-1.txt", .{automation_dir}), .{}),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const builtin = @import("builtin");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const canvas = @import("canvas");
|
|
5
|
+
const automation = @import("../automation/root.zig");
|
|
6
|
+
const platform = @import("../platform/root.zig");
|
|
7
|
+
const canvas_limits = @import("canvas_limits.zig");
|
|
8
|
+
const runtime_clock = @import("clock.zig");
|
|
9
|
+
const runtime_frame_profile = @import("frame_profile.zig");
|
|
10
|
+
const widget_bridge = @import("widget_bridge.zig");
|
|
11
|
+
const runtime_api = @import("api.zig");
|
|
12
|
+
|
|
13
|
+
const FrameDiagnostics = runtime_api.FrameDiagnostics;
|
|
14
|
+
const nowNanoseconds = runtime_clock.nowNanoseconds;
|
|
15
|
+
const timestampToU64 = runtime_clock.timestampToU64;
|
|
16
|
+
const widgetRoleName = widget_bridge.widgetRoleName;
|
|
17
|
+
const canvasWidgetSemanticParentId = widget_bridge.canvasWidgetSemanticParentId;
|
|
18
|
+
const canvasWidgetSelectedState = widget_bridge.canvasWidgetSelectedState;
|
|
19
|
+
const canvasWidgetActions = widget_bridge.canvasWidgetActions;
|
|
20
|
+
const canvasTextRange = widget_bridge.canvasTextRange;
|
|
21
|
+
const canvasVirtualRange = widget_bridge.canvasVirtualRange;
|
|
22
|
+
|
|
23
|
+
pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
24
|
+
return struct {
|
|
25
|
+
pub fn automationSnapshot(self: *Runtime, title: []const u8) automation.snapshot.Input {
|
|
26
|
+
const count = @min(self.window_count, self.automation_windows.len);
|
|
27
|
+
if (count == 0) {
|
|
28
|
+
self.automation_windows[0] = .{ .id = 1, .title = title, .bounds = geometry.RectF.fromSize(self.surface.size), .focused = true };
|
|
29
|
+
return .{
|
|
30
|
+
.windows = self.automation_windows[0..1],
|
|
31
|
+
.views = &.{},
|
|
32
|
+
.widgets = &.{},
|
|
33
|
+
.diagnostics = automationDiagnostics(self),
|
|
34
|
+
.frame_profile = automationFrameProfile(self),
|
|
35
|
+
.tray = automationTray(self),
|
|
36
|
+
.audio = automationAudio(self),
|
|
37
|
+
.errors = self.dispatchErrors(),
|
|
38
|
+
.source = self.loaded_source,
|
|
39
|
+
.widget_node_budget = canvas_limits.max_canvas_widget_nodes_per_view,
|
|
40
|
+
.widget_semantics_budget = canvas_limits.max_canvas_widget_semantics_per_view,
|
|
41
|
+
.widget_context_menu_item_budget = canvas_limits.max_canvas_widget_context_menu_items_per_view,
|
|
42
|
+
.text_layout_plan_budget = canvas_limits.max_canvas_text_layouts_per_view,
|
|
43
|
+
.text_layout_line_budget = canvas_limits.max_canvas_text_layout_lines_per_view,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var view_count: usize = 0;
|
|
47
|
+
var widget_count: usize = 0;
|
|
48
|
+
var menu_item_count: usize = 0;
|
|
49
|
+
for (self.windows[0..count], 0..) |window, index| {
|
|
50
|
+
self.automation_windows[index] = .{
|
|
51
|
+
.id = window.info.id,
|
|
52
|
+
.title = if (window.info.title.len > 0) window.info.title else title,
|
|
53
|
+
.bounds = window.info.frame,
|
|
54
|
+
.focused = window.info.focused,
|
|
55
|
+
};
|
|
56
|
+
if (view_count < self.automation_views.len) {
|
|
57
|
+
const views = self.listViews(window.info.id, self.automation_views[view_count..]);
|
|
58
|
+
view_count += views.len;
|
|
59
|
+
}
|
|
60
|
+
appendAutomationWidgets(self, window.info.id, &widget_count, &menu_item_count);
|
|
61
|
+
}
|
|
62
|
+
return .{
|
|
63
|
+
.windows = self.automation_windows[0..count],
|
|
64
|
+
.views = self.automation_views[0..view_count],
|
|
65
|
+
.widgets = self.automation_widgets[0..widget_count],
|
|
66
|
+
.diagnostics = automationDiagnostics(self),
|
|
67
|
+
.frame_profile = automationFrameProfile(self),
|
|
68
|
+
.tray = automationTray(self),
|
|
69
|
+
.audio = automationAudio(self),
|
|
70
|
+
.errors = self.dispatchErrors(),
|
|
71
|
+
.source = self.loaded_source,
|
|
72
|
+
.widget_node_budget = canvas_limits.max_canvas_widget_nodes_per_view,
|
|
73
|
+
.widget_semantics_budget = canvas_limits.max_canvas_widget_semantics_per_view,
|
|
74
|
+
.widget_context_menu_item_budget = canvas_limits.max_canvas_widget_context_menu_items_per_view,
|
|
75
|
+
.text_layout_plan_budget = canvas_limits.max_canvas_text_layouts_per_view,
|
|
76
|
+
.text_layout_line_budget = canvas_limits.max_canvas_text_layout_lines_per_view,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// The live tray as the runtime last applied it: title +
|
|
81
|
+
/// dropdown rows, or null when no status item exists. The menu
|
|
82
|
+
/// bar is outside every window capture, so the snapshot is the
|
|
83
|
+
/// only automation-visible evidence of the model-driven tray.
|
|
84
|
+
fn automationTray(self: *Runtime) ?automation.snapshot.Tray {
|
|
85
|
+
if (!self.tray_created) return null;
|
|
86
|
+
const count = @min(self.tray_item_count, self.automation_tray_items.len);
|
|
87
|
+
for (self.tray_items[0..count], 0..) |item, index| {
|
|
88
|
+
self.automation_tray_items[index] = .{
|
|
89
|
+
.id = item.id,
|
|
90
|
+
.label = item.label,
|
|
91
|
+
.command = item.command,
|
|
92
|
+
.separator = item.separator,
|
|
93
|
+
.enabled = item.enabled,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return .{
|
|
97
|
+
.title = self.tray_title,
|
|
98
|
+
.items = self.automation_tray_items[0..count],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// Live audio playback as the ui-app layer last mirrored it
|
|
103
|
+
/// (`Runtime.audio_*`), or null when nothing is loaded. The
|
|
104
|
+
/// player is outside every window capture, so the snapshot's
|
|
105
|
+
/// advancing `position_ms` is the automation-visible evidence
|
|
106
|
+
/// music is actually playing.
|
|
107
|
+
fn automationAudio(self: *Runtime) ?automation.snapshot.Audio {
|
|
108
|
+
if (!self.audio_active) return null;
|
|
109
|
+
return .{
|
|
110
|
+
.key = self.audio_key,
|
|
111
|
+
.playing = self.audio_playing,
|
|
112
|
+
.buffering = self.audio_buffering,
|
|
113
|
+
.source = @tagName(self.audio_source),
|
|
114
|
+
.position_ms = self.audio_position_ms,
|
|
115
|
+
.duration_ms = self.audio_duration_ms,
|
|
116
|
+
.spectrum_events = self.audio_spectrum_events,
|
|
117
|
+
.spectrum_bands = &self.audio_spectrum_bands,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// The frame profile's per-stage p50/p90 stats, non-null while
|
|
122
|
+
/// `profile on` is active. Percentile sorting happens HERE — the
|
|
123
|
+
/// snapshot path — never in the frame path; entries land in
|
|
124
|
+
/// runtime-owned storage so the returned slices stay plain values.
|
|
125
|
+
fn automationFrameProfile(self: *Runtime) ?automation.snapshot.FrameProfile {
|
|
126
|
+
if (!self.frame_profile.enabled) return null;
|
|
127
|
+
inline for (comptime std.enums.values(runtime_frame_profile.FrameProfileStage), 0..) |stage, index| {
|
|
128
|
+
const stats = self.frame_profile.stats(stage);
|
|
129
|
+
self.automation_frame_profile_stages[index] = .{
|
|
130
|
+
.name = stage.name(),
|
|
131
|
+
.p50_us = stats.p50_us,
|
|
132
|
+
.p90_us = stats.p90_us,
|
|
133
|
+
.max_us = stats.max_us,
|
|
134
|
+
.count = stats.total,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return .{ .stages = &self.automation_frame_profile_stages };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
fn automationDiagnostics(self: *Runtime) automation.snapshot.Diagnostics {
|
|
141
|
+
const now_ns = timestampToU64(nowNanoseconds());
|
|
142
|
+
const uptime_ns = if (self.started_timestamp_ns > 0 and now_ns >= self.started_timestamp_ns) now_ns - self.started_timestamp_ns else 0;
|
|
143
|
+
return .{
|
|
144
|
+
.frame_index = self.last_diagnostics.frame_index,
|
|
145
|
+
.command_count = self.last_diagnostics.command_count,
|
|
146
|
+
.runtime_uptime_ns = uptime_ns,
|
|
147
|
+
.dispatch_error_count = self.dispatch_error_total,
|
|
148
|
+
.dropped_trace_records = self.dropped_trace_records,
|
|
149
|
+
.publisher_pid = currentProcessId(),
|
|
150
|
+
.markup_watch_armed = self.markup_watch_armed,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/// The publishing process's pid, stamped into every snapshot so
|
|
155
|
+
/// the automation CLI can refuse dropbox files whose publisher is
|
|
156
|
+
/// gone — stale files were once served as live state. 0 on
|
|
157
|
+
/// platforms without a process table.
|
|
158
|
+
fn currentProcessId() u32 {
|
|
159
|
+
return switch (builtin.os.tag) {
|
|
160
|
+
.windows => std.os.windows.GetCurrentProcessId(),
|
|
161
|
+
.wasi, .freestanding, .emscripten => 0,
|
|
162
|
+
else => @intCast(@max(0, std.posix.system.getpid())),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fn appendAutomationWidgets(self: *Runtime, window_id: platform.WindowId, widget_count: *usize, menu_item_count: *usize) void {
|
|
167
|
+
for (self.views[0..self.view_count]) |*view| {
|
|
168
|
+
if (!view.open or view.window_id != window_id or view.kind != .gpu_surface) continue;
|
|
169
|
+
const layout = view.widgetLayoutTree();
|
|
170
|
+
const semantics = view.widgetSemantics();
|
|
171
|
+
for (semantics) |node| {
|
|
172
|
+
if (widget_count.* >= self.automation_widgets.len) return;
|
|
173
|
+
self.automation_widgets[widget_count.*] = .{
|
|
174
|
+
.window_id = view.window_id,
|
|
175
|
+
.view_label = view.label,
|
|
176
|
+
.id = node.id,
|
|
177
|
+
.role = widgetRoleName(node.role),
|
|
178
|
+
.name = node.label,
|
|
179
|
+
.parent_id = canvasWidgetSemanticParentId(semantics, node.parent_index),
|
|
180
|
+
.value = node.value,
|
|
181
|
+
.text_value = node.text_value,
|
|
182
|
+
.placeholder = node.placeholder,
|
|
183
|
+
.grid_row_index = node.grid_row_index,
|
|
184
|
+
.grid_column_index = node.grid_column_index,
|
|
185
|
+
.grid_row_count = node.grid_row_count,
|
|
186
|
+
.grid_column_count = node.grid_column_count,
|
|
187
|
+
.list = .{
|
|
188
|
+
.present = node.list.present,
|
|
189
|
+
.item_index = node.list.item_index,
|
|
190
|
+
.item_count = node.list.item_count,
|
|
191
|
+
},
|
|
192
|
+
.scroll = .{
|
|
193
|
+
.present = node.scroll.present,
|
|
194
|
+
.offset = node.scroll.offset,
|
|
195
|
+
.viewport_extent = node.scroll.viewport_extent,
|
|
196
|
+
.content_extent = node.scroll.content_extent,
|
|
197
|
+
},
|
|
198
|
+
.virtual_range = canvasVirtualRange(layout.virtualRangeById(node.id)),
|
|
199
|
+
.bounds = node.bounds.translate(geometry.OffsetF.init(view.frame.x, view.frame.y)),
|
|
200
|
+
.focused = node.state.focused or (view.focused and node.id == view.canvas_widget_focused_id),
|
|
201
|
+
.enabled = !node.state.disabled,
|
|
202
|
+
.hovered = node.state.hovered or (node.id != 0 and node.id == view.canvas_widget_hovered_id),
|
|
203
|
+
.pressed = node.state.pressed or (node.id != 0 and node.id == view.canvas_widget_pressed_id),
|
|
204
|
+
.selected = canvasWidgetSelectedState(node),
|
|
205
|
+
.expanded = node.state.expanded,
|
|
206
|
+
.required = node.state.required,
|
|
207
|
+
.read_only = node.state.read_only,
|
|
208
|
+
.invalid = node.state.invalid,
|
|
209
|
+
.actions = canvasWidgetActions(node.actions),
|
|
210
|
+
.text_selection = canvasTextRange(node.text_selection),
|
|
211
|
+
.text_composition = canvasTextRange(node.text_composition),
|
|
212
|
+
.context_menu = automationWidgetContextMenu(self, layout, node.id, menu_item_count),
|
|
213
|
+
};
|
|
214
|
+
widget_count.* += 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/// Copy a widget's declared context-menu items into the
|
|
220
|
+
/// snapshot's runtime-owned item storage (labels alias the
|
|
221
|
+
/// view's bounded menu storage). The storage is sized for every
|
|
222
|
+
/// view's full budget, so `count < declared.len` can only mean
|
|
223
|
+
/// a budget invariant broke elsewhere — the copy stays bounded
|
|
224
|
+
/// regardless.
|
|
225
|
+
fn automationWidgetContextMenu(self: *Runtime, layout: canvas.WidgetLayoutTree, id: canvas.ObjectId, menu_item_count: *usize) []const automation.snapshot.WidgetContextMenuItem {
|
|
226
|
+
const node = layout.findById(id) orelse return &.{};
|
|
227
|
+
const declared = node.widget.context_menu;
|
|
228
|
+
if (declared.len == 0) return &.{};
|
|
229
|
+
const start = menu_item_count.*;
|
|
230
|
+
const count = @min(declared.len, self.automation_widget_menu_items.len - start);
|
|
231
|
+
for (declared[0..count], self.automation_widget_menu_items[start .. start + count]) |item, *slot| {
|
|
232
|
+
slot.* = .{
|
|
233
|
+
.label = item.label,
|
|
234
|
+
.enabled = item.enabled,
|
|
235
|
+
.separator = item.separator,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
menu_item_count.* = start + count;
|
|
239
|
+
return self.automation_widget_menu_items[start .. start + count];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
pub fn frameDiagnostics(self: *Runtime) FrameDiagnostics {
|
|
243
|
+
return self.last_diagnostics;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|